The gateway, the key, the project
Where the CLI finds the gateway and the key, what ~/.pinecall keeps, and a project's layout.
Where the gateway and the key come from#
Two things, each with one job. This machine's sign-in says who you are at a gateway:
pinecall login [url] keeps it in ~/.pinecall/session.json, once per machine and gateway, and
pinecall-runtime setup writes the same for the runtime it runs here. A project's
pinecall.json, at its root and committed beside its agents, says where the project runs:
{ "gateway": "https://pinecall.miempresa.com", "org": "clinica" }
It holds no key, so whoever clones the project runs it there on their own sign-in.
pinecall new writes it — the gateway this machine signed in to last and your only org
there, or the one you pick when you belong to several. To move a project to another runtime or
another org, edit the file: there is no verb for it, and nothing else is kept. A project made
beside a runtime of your own names http://127.0.0.1:8080, so on another machine it needs a
runtime of its own, or the file pointed at your Pinecall.
Every verb finds its key in this order, and nothing else is read:
PINECALL_KEYandPINECALL_URLin the process's environment — a server's secrets, a CI job's.PINECALL_KEYin the nearest.envwalking up from where it runs (an app's own secrets), with that file'sPINECALL_URLwhen the environment names none. A key found in 1 or 2 with noPINECALL_URLanywhere goes tohttps://cloud.pinecall.io.- The nearest
pinecall.json: its gateway and its org, and this machine's key in that org. The sign-in's own key when it is that org's; otherwise one minted from it there the first time a verb needs it — a project cloned onto this machine, an org changed in the file — labelled as this machine, kept beside the sign-in and never in the project. - Outside a project, the sign-in at the gateway signed in to last, in the org its own key is in.
So on your own machine with a runtime of its own no verb needs login, and a project of another org
is only another pinecall.json: nothing is switched. v1's PINECALL_API_KEY is never read, because
a shell that still had v1's key exported once pointed every verb at another org with every line
reading the same.
One gateway, two environments, one identity. Production and the sandbox are two environments of the same
gateway — each with its own data, neither reaching the other — and the gateway a verb found
(PINECALL_URL, or the project's pinecall.json) is that one gateway, for both. The environment a request acts in is decided there, from the key and the header,
never from the name: every verb knocks at the same URL with the same key, and says which environment
it means.
| the verb | knocks at | with | saying |
|---|---|---|---|
without --prod — the sandbox |
the gateway | the key found | pinecall-env: sandbox |
with --prod |
the gateway | the key found | pinecall-env: production |
A person's key opens both environments. Nothing is derived, minted or discovered for the sandbox:
the key a verb found is the one it sends, and the pinecall-env header on every
request and every socket (@pinecall/agents/client's signed.ts) says which environment it acts in — absent, the
gateway takes the sandbox. --prod is for one command and keeps nothing, so the next command is
in the sandbox again. Production lets a person through only while their production switch is on —
an admin's always is — and otherwise answers 403 <name> has no production access: an admin gives it in Team.
~/clinica $ pinecall sessions # your sandbox calls
~/clinica $ pinecall sessions --prod # production's, at the same gateway
~/clinica $ pinecall agent set --voice carolina --note "warmer" --prod
A server's token is the other kind of key: the org's, made in the console's API keys screen of
the environment it is for, and put in the server's secrets as PINECALL_KEY. It acts in its own environment
alone, and the header may only agree. A sandbox token (pc_test_) is caught before it knocks:
this PINECALL_KEY is a sandbox server's token, made at <url>: run the verb without --prod. A
production token starts pc_live_ like a person's key, so the CLI cannot tell the two apart: a
production token sent without --prod is refused by the gateway, in its words (this key is a production server's token, and this request is for sandbox: a server's token opens the env it was made in). Production is that path.
whoami and callbacks open by printing where they went, and data export --out ends with it: gateway <url> · org <slug> · key from <where> · <environment> — the org when a project's pinecall.json names one; outside a project the line has none, and
the gateway's answer under it says it. The rest get on with the answer. With no key, every one of them is refused
with exit 2 and the sentence that says what to do: a project whose gateway this machine is not
signed in to names it (pinecall.json runs this project at <url>: sign in there, `pinecall login <url>```), or, when the file names a runtime on this machine and there is none, says pinecall.json runs this project on a runtime on this machine, and there is none: pinecall-runtime setup runs one, or edit pinecall.json to name your Pinecall; an org you are no member of says so; a machine signed in nowhere hears this machine is
signed in nowhere: pinecall login [url] (a server keeps PINECALL_KEY in its secrets), or
pinecall-runtime setup runs a runtime here that the CLI uses by itself``. pinecall whoami is
the first thing to run when an endpoint refuses you and will not say why.
~/.pinecall/#
| file | what it holds |
|---|---|
session.json |
{ "gateways": { "<url>": { key, org, orgs?, calling? } }, "last": … } — this machine, one row per gateway it knows (src/project/session.ts): key, the sign-in (login's, or the local runtime admin's that pinecall-runtime setup writes), and org, the org it acts in; orgs, the keys minted from it in your other orgs, by slug; calling, the phone pinecall line from said, re-sent by every start. A new sign-in at a gateway drops the keys minted from the old one |
The directory is 0700 and the file 0600; PINECALL_HOME moves it. A key is never printed,
never logged, never put in a URL, and never written into a project.
Writing the agent#
The project#
One layout, whether the project holds one agent or five. A project is the business; each agent is
one folder under agents/, and everything the agent is lives in it — copy the folder and you have
copied the agent (src/project/layout.ts):
pinecall.json where the project runs: its gateway and its org, no key (committed)
agents/<name>/agent.tsx the class — and beside it only what this agent uses (callbacks.ts);
agent.ts, agent.rb or agent.py for a class in another language
agents/<name>/docs/ the documents `docs push` sends as the agent's base
agents/<name>/test/agent.test.ts unit tests: the class as software
agents/<name>/test/goldens/ goldens: the conversations `test` runs; beside them `docs.json`,
the questions `docs eval` asks the base, and `memory.json`,
the questions `memory eval` asks recall
agents/<name>/test/memory/ the extraction cases `remember` runs
agents/<name>/test/personas.ts the callers it is tested with, as code (personas.py, personas.rb)
agents/<name>/harness.ts its own judges, as code (harness.py, harness.rb)
agents/<name>/test/candidates/ real calls `runs promote` wrote, before a person keeps them
lib/ what two or more agents share
app.ts the voice app: its lines, its team, its rules (app.py, app.rb)
flows/ the flows the app starts, when they are not written in app.ts
The agent's slug is its folder's name. agents/sales/agent.tsx is the agent sales on the
gateway — its settings, its numbers, its callers and judges — whatever its class is called. A class
that declares another (@agent({ slug })) is refused when it is served, naming both: rename the folder.
The business is not in the repository. What the agent knows by heart — hours, prices, what
needs an authorisation — is one field of its settings, per environment and corner, written in the
console's Configure ▸ Knowledge (the terminal's pinecall agent knowledge edit is an agent built in Studio's), and
read whole into the prompt on every call. Nor are the documents a turn searches: they are a base,
written in the console's Knowledge ▸ Docs, and a local agents/<name>/docs/ is only what docs push sends
when no directory is named. A class
declares its voice, its model, its opening or its memory policy
(Writing an agent),
and what it declares the CLI cannot write: agent says what stays open.
At the root, every verb that reads a class acts on every agent, each against its own folders,
or on the one --agent <name> names — by its folder's name, which is its slug (sales):
| at the root | does |
|---|---|
pinecall start |
every agent at once, in one process of their language; each line prefixed by the slug, one console URL each. --show-prompt prints every agent's prompt under its slug |
pinecall test |
each agent's goldens through its own class, one after another; the exit code is the worst. Paths and --watch are for one agent, so they need --agent |
pinecall docs push · eval |
every agent that has agents/<name>/docs/ · agents/<name>/test/goldens/docs.json; the rest are named and skipped |
pinecall personas |
every verb, since a caller is one agent's: --agent <name> when the project holds several |
pinecall chat · simulate · prompt · remember · memory eval · line · start --ui |
one agent: --agent <name> is required when there are several |
pinecall judges |
one agent's judges: --agent <name> when the project holds several |
A project of several with nobody named is refused with the names: chat talks to one agent and this project has 2: add --agent dispatch or --agent sales. A directory with no agents/ at all is one somebody
typed the verb in by mistake, and the refusal says where it looked. A folder the verb reads and
nobody has written yet is empty, not an error: an agent with no goldens/ has no goldens, the
console's roster says so, and pinecall test names the folder to write one in.
--agent means two things, one per kind of verb. In a verb that reads a class it names an agent
of this project, by its folder's name. In a verb that only asks the gateway — sessions, pipeline,
runs drift, numbers import, callbacks, docs attach — it is a slug, because there is no
class to find. --file is always a file.