Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions docs/part-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ when it runs the image. The audience (`AGENTAGE_AUDIENCE`) is the host a token i
| `AGENTAGE_DATA_DIR`, `AGENTAGE_RUN_DIR` | a git store: its repos (`/data/store` in the image, with `git`) and the folder of its store lock |
| `AGENTAGE_ISSUER`, `AGENTAGE_AUDIENCE`, `AGENTAGE_ORIGIN` | required for api and mcp. Without them the part does not start. It also does not start when its host is not in the audience. |
| `AGENTAGE_ISSUER`, `AGENTAGE_AUDIENCE` on pages | CSP script-src, connect-src add these hosts; helmet's style-src keeps 'unsafe-inline' |
| `AGENTAGE_TELEMETRY_URL` | `ctx.platform.telemetry` (with `issuer`, `audience`; a value a part lacks is `''`) |
| `AGENTAGE_DEV_ISSUER` | set by `up` for the ui part only: its CSP then lets the harness reach the dev issuer |
| `Cookie` request header | dropped before any handler; a part sets no cookie and its CORS carries no credentials |

Expand Down Expand Up @@ -53,21 +52,21 @@ jobs start after every `create` and stop before the store closes. With no token
port or at the port of `AGENTAGE_ORIGIN`. The daemon child and the one container run the entry
`node node_modules/@agentage/extension/dist/host/main.js`.

| Env | Meaning |
| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PORT` | the port, `8080` by default; `0` lets the OS pick, and the port goes to the parent over IPC |
| `AGENTAGE_EXTENSION_DIR` | the package folder, the current folder by default |
| `AGENTAGE_DATA_DIR` | the PGlite folder of a postgres store; `<dir>.lock` holds the pid. Unset: in memory, a warn line |
| `AGENTAGE_RUN_DIR` | the daemon's `run/{id}`: the store lock is `run/{id}/store.lock` there in place of `<dir>.lock`. Unset (the one container): `<dir>.lock` |
| `AGENTAGE_SETTINGS` | JSON of setting values over the manifest defaults |
| `AGENTAGE_SECRETS_DIR` | one file per declared secret, `/run/secrets` by default |
| `AGENTAGE_ORIGIN` | `ctx.extension.origin`, `http://127.0.0.1:<PORT>` by default |
| `AGENTAGE_ISSUER`, `AGENTAGE_AUDIENCE`, `AGENTAGE_TELEMETRY_URL` | `ctx.platform` (`issuer`, `audience`, `telemetry`), as in a part image; a value it lacks is `''` |
| `AGENTAGE_DRAIN_MS` | how long SIGTERM may drain before exit 1, `10000` by default |
| `AGENTAGE_STORE_OPEN_MS` | how long the store may take to open (and to close), `120000` by default; then the api starts and `/health` says the store is `unavailable` until it opens. Under the daemon it is the daemon's `healthMs` (raise both with `createDaemon({ healthMs })`, and `startMs` with it) |
| `AGENTAGE_STORE_URL_FILE` | the estate's store: a file with a `postgres://` URL for a postgres store, an `http://` URL for a clickhouse store. Set, the host opens it in place of PGlite (never both); see [Estate stores in the host](#estate-stores-in-the-host) |
| `AGENTAGE_HOST_BIND=all` | listen on every address. It needs a token check (`AGENTAGE_ISSUER`, `AGENTAGE_AUDIENCE`, `AGENTAGE_ORIGIN`) or `AGENTAGE_HOST_AUTH=off` |
| `AGENTAGE_USER_SUB` | set by the daemon from the signed-in cli (`auth.json`: the platform token of its `issuer`, else the issuer's get-session for the session bearer; no `issuer`, no user). On loopback every request acts as this user with `{id}:read` and `{id}:write`; an admin route stays anonymous. Trust: any local process that reaches the port acts as the user (browsers are blocked by the Host and Origin guard). The daemon reads `auth.json` every `userPollMs` (2 s): a sign-in or sign-out restarts the running children. Unset: no caller |
| Env | Meaning |
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PORT` | the port, `8080` by default; `0` lets the OS pick, and the port goes to the parent over IPC |
| `AGENTAGE_EXTENSION_DIR` | the package folder, the current folder by default |
| `AGENTAGE_DATA_DIR` | the PGlite folder of a postgres store; `<dir>.lock` holds the pid. Unset: in memory, a warn line |
| `AGENTAGE_RUN_DIR` | the daemon's `run/{id}`: the store lock is `run/{id}/store.lock` there in place of `<dir>.lock`. Unset (the one container): `<dir>.lock` |
| `AGENTAGE_SETTINGS` | JSON of setting values over the manifest defaults |
| `AGENTAGE_SECRETS_DIR` | one file per declared secret, `/run/secrets` by default |
| `AGENTAGE_ORIGIN` | `ctx.extension.origin`, `http://127.0.0.1:<PORT>` by default |
| `AGENTAGE_ISSUER`, `AGENTAGE_AUDIENCE` | `ctx.platform` (`issuer`, `audience`), as in a part image; a value it lacks is `''` |
| `AGENTAGE_DRAIN_MS` | how long SIGTERM may drain before exit 1, `10000` by default |
| `AGENTAGE_STORE_OPEN_MS` | how long the store may take to open (and to close), `120000` by default; then the api starts and `/health` says the store is `unavailable` until it opens. Under the daemon it is the daemon's `healthMs` (raise both with `createDaemon({ healthMs })`, and `startMs` with it) |
| `AGENTAGE_STORE_URL_FILE` | the estate's store: a file with a `postgres://` URL for a postgres store, an `http://` URL for a clickhouse store. Set, the host opens it in place of PGlite (never both); see [Estate stores in the host](#estate-stores-in-the-host) |
| `AGENTAGE_HOST_BIND=all` | listen on every address. It needs a token check (`AGENTAGE_ISSUER`, `AGENTAGE_AUDIENCE`, `AGENTAGE_ORIGIN`) or `AGENTAGE_HOST_AUTH=off` |
| `AGENTAGE_USER_SUB` | set by the daemon from the signed-in cli (`auth.json`: the platform token of its `issuer`, else the issuer's get-session for the session bearer; no `issuer`, no user). On loopback every request acts as this user with `{id}:read` and `{id}:write`; an admin route stays anonymous. Trust: any local process that reaches the port acts as the user (browsers are blocked by the Host and Origin guard). The daemon reads `auth.json` every `userPollMs` (2 s): a sign-in or sign-out restarts the running children. Unset: no caller |

The one container (`build --container`) sets `AGENTAGE_HOST_BIND=all`, `PORT=8080` and
`AGENTAGE_DRAIN_MS=8000`. With a postgres or git store it also sets `AGENTAGE_DATA_DIR=/data/store` on
Expand Down
9 changes: 4 additions & 5 deletions packages/extension/src/auth/part-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ const valid = (env: Env, key: keyof typeof AuthEnvSchema.shape): string => {
};

// ctx.platform from the token check's env; pages and worker start without it and get ''.
export const platformOf = (env: Env): PlatformInfo => {
const telemetry = env['AGENTAGE_TELEMETRY_URL'] || undefined;
const issuer = valid(env, 'AGENTAGE_ISSUER');
return { issuer, audience: valid(env, 'AGENTAGE_AUDIENCE'), ...(telemetry && { telemetry }) };
};
export const platformOf = (env: Env): PlatformInfo => ({
issuer: valid(env, 'AGENTAGE_ISSUER'),
audience: valid(env, 'AGENTAGE_AUDIENCE'),
});

// *.agentage.io covers the domain and every host under it at any depth; else one exact host.
export const covers = (audience: string, host: string): boolean =>
Expand Down
Loading