From bdd9a527c080ab9865b790c54141c2c0a6e482bb Mon Sep 17 00:00:00 2001 From: Volodymyr Vreshch Date: Thu, 19 Nov 2026 13:09:55 +0100 Subject: [PATCH] feat(extension): the kit drops AGENTAGE_TELEMETRY_URL (J.4.2 row 7) Claude-Session: https://claude.ai/code/session_01XQkodgygL4W8UcLQDwC212 --- docs/part-image.md | 31 +++++++++---------- packages/extension/src/auth/part-auth.ts | 9 +++--- .../extension/src/context/context.test.ts | 13 ++------ packages/extension/src/context/context.ts | 3 +- packages/extension/src/host/host-extension.ts | 2 +- .../extension/src/host/serve-host.test.ts | 6 ++-- 6 files changed, 26 insertions(+), 38 deletions(-) diff --git a/docs/part-image.md b/docs/part-image.md index 3a70c88a..99c5a0ec 100644 --- a/docs/part-image.md +++ b/docs/part-image.md @@ -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 | @@ -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; `.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 `.lock`. Unset (the one container): `.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:` 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; `.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 `.lock`. Unset (the one container): `.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:` 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 diff --git a/packages/extension/src/auth/part-auth.ts b/packages/extension/src/auth/part-auth.ts index 37f02fbb..5804aae3 100644 --- a/packages/extension/src/auth/part-auth.ts +++ b/packages/extension/src/auth/part-auth.ts @@ -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 => diff --git a/packages/extension/src/context/context.test.ts b/packages/extension/src/context/context.test.ts index bc24c3bf..f16be57e 100644 --- a/packages/extension/src/context/context.test.ts +++ b/packages/extension/src/context/context.test.ts @@ -123,31 +123,24 @@ describe('ctx.platform', () => { const env = { AGENTAGE_ISSUER: 'https://auth.agentage.io', AGENTAGE_AUDIENCE: '*.agentage.io', - AGENTAGE_TELEMETRY_URL: 'https://telemetry.agentage.io/v1', }; - it('reads the issuer, the audience and the telemetry URL, frozen', () => { + it('reads the issuer and the audience only, frozen', () => { const ctx = createContext({ ...BASE, part: 'pages', platform: platformOf(env) }); expect(ctx.platform).toEqual({ issuer: 'https://auth.agentage.io', audience: '*.agentage.io', - telemetry: 'https://telemetry.agentage.io/v1', }); expect(Object.isFrozen(ctx.platform)).toBe(true); }); - it('leaves telemetry out when unset, and a missing or invalid value empty', () => { - const rest = { ...env, AGENTAGE_TELEMETRY_URL: '' }; - expect(platformOf(rest)).toEqual({ - issuer: 'https://auth.agentage.io', - audience: '*.agentage.io', - }); + it('gives a missing or invalid value as empty', () => { expect(platformOf({ AGENTAGE_ISSUER: 'https://auth.agentage.io/path' })).toEqual({ issuer: '', audience: '', }); expect(createContext(BASE).platform).toEqual({ issuer: '', audience: '' }); - expect(createTestContext({ platform: platformOf(rest) }).platform.issuer).toBe( + expect(createTestContext({ platform: platformOf(env) }).platform.issuer).toBe( 'https://auth.agentage.io' ); }); diff --git a/packages/extension/src/context/context.ts b/packages/extension/src/context/context.ts index 1a9606a1..59e67109 100644 --- a/packages/extension/src/context/context.ts +++ b/packages/extension/src/context/context.ts @@ -22,11 +22,10 @@ export interface ExtensionInfo { store?: StoreKind; } -// The platform this deployment trusts: AGENTAGE_ISSUER, AGENTAGE_AUDIENCE, AGENTAGE_TELEMETRY_URL. +// The platform this deployment trusts: AGENTAGE_ISSUER, AGENTAGE_AUDIENCE. export interface PlatformInfo { issuer: string; audience: string; - telemetry?: string; } export const NO_PLATFORM: PlatformInfo = Object.freeze({ issuer: '', audience: '' }); diff --git a/packages/extension/src/host/host-extension.ts b/packages/extension/src/host/host-extension.ts index 3f7741e6..4fc2675c 100644 --- a/packages/extension/src/host/host-extension.ts +++ b/packages/extension/src/host/host-extension.ts @@ -29,7 +29,7 @@ export interface HostOptions { onExit?: () => void; // ctx.extension.origin; http://127.0.0.1 when left out. origin?: string; - // ctx.platform (issuer, audience, telemetry), as a part image reads it; empty when left out. + // ctx.platform (issuer, audience), as a part image reads it; empty when left out. platform?: PlatformInfo; // The daemon's guard: a Host of 127.0.0.1 or localhost at the port, a local Origin, no cross-site fetch. localOnly?: boolean; diff --git a/packages/extension/src/host/serve-host.test.ts b/packages/extension/src/host/serve-host.test.ts index 8d1817d0..d024f9d4 100644 --- a/packages/extension/src/host/serve-host.test.ts +++ b/packages/extension/src/host/serve-host.test.ts @@ -99,14 +99,12 @@ describe('serveHost', () => { ); }); - it('gives ctx.platform the issuer, audience and telemetry of its env, as a part image does', async () => { - const telemetry = { AGENTAGE_TELEMETRY_URL: 'https://logs.next.agentage.io' }; - const { url } = await start({ ...TOKEN_ENV, ...telemetry }); + it('gives ctx.platform the issuer and audience of its env, as a part image does', async () => { + const { url } = await start(TOKEN_ENV); const body = (await (await fetch(`${url}/api/hosted/platform`)).json()) as { data: object }; expect(body.data).toEqual({ issuer: 'https://127.0.0.1:9', audience: '*.agentage.io', - telemetry: 'https://logs.next.agentage.io', }); });