From 165ef02e77910b39f2fe79a4ba1e5afdce165dfb Mon Sep 17 00:00:00 2001 From: Volodymyr Vreshch Date: Sun, 22 Nov 2026 16:26:32 +0100 Subject: [PATCH 1/2] docs: simple READMEs with banner, details moved to docs/ Claude-Session: https://claude.ai/code/session_01XQkodgygL4W8UcLQDwC212 --- AGENTS.md | 1 + CLAUDE.md | 19 +- README.md | 248 ++++-------------- docs/apphost.md | 53 ++++ docs/banner.svg | 74 ++++++ docs/extension-package.md | 84 ++++++ docs/identity.md | 23 ++ docs/packages.svg | 44 ++++ docs/release.md | 70 +++++ docs/shell-dashboard.md | 98 +++++++ docs/widget.md | 58 ++++ packages/apphost/README.md | 66 ++--- packages/extension/README.md | 103 ++------ .../extension/src/core-client/core-client.ts | 2 +- packages/identity/README.md | 37 ++- packages/shell-dashboard/README.md | 102 ++----- packages/widget/README.md | 88 ++----- template/CLAUDE.md | 2 +- template/README.md | 120 ++++----- 19 files changed, 729 insertions(+), 563 deletions(-) create mode 120000 AGENTS.md create mode 100644 docs/apphost.md create mode 100644 docs/banner.svg create mode 100644 docs/extension-package.md create mode 100644 docs/identity.md create mode 100644 docs/packages.svg create mode 100644 docs/release.md create mode 100644 docs/shell-dashboard.md create mode 100644 docs/widget.md diff --git a/AGENTS.md b/AGENTS.md new file mode 120000 index 00000000..681311eb --- /dev/null +++ b/AGENTS.md @@ -0,0 +1 @@ +CLAUDE.md \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 47fe7d00..4c0d1b12 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -3,7 +3,7 @@ Public repo. The extension kit and its build tool, and the widget kit; no product code. Standards: the engineering standards batch (repo-baseline, typescript, monorepo, code-style, testing, ci-cd, docker-deploy, security, backend); this file only adds what the tree does not say. Words: [README.md](README.md) -"Words used here" (record, sealing: `docs/tool.md`); this file does not repeat the docs listed below. +"What is in this repo" (record, sealing: `docs/tool.md`); this file does not repeat the docs listed below. ## Where facts live @@ -15,15 +15,20 @@ docker-deploy, security, backend); this file only adds what the tree does not sa - Build steps, six rules, image recipe, `up`, `down`, `token`, timeouts: `docs/tool.md` (proof: `src/tool/`). - Part image entry, port, `AGENTAGE_*` settings: `docs/part-image.md` (proof: `src/runtime/`, `src/auth/part-auth.ts`). - Host, daemon routes, limits, seal: `docs/part-image.md` "Host one extension" and `docs/daemon.md` (proof: `src/host/`, `packages/apphost/src/`). +- App host program: cloud `installation.json`, request lines, security headers: `docs/apphost.md`. - Manifest, record, discovery, `/health` and envelope schemas: `packages/extension/schemas/*.json` (generated, never edit by hand). -- Check report JSON, secrets: `packages/extension/README.md`. +- Kit subpaths, the core client, check report JSON, secrets: `docs/extension-package.md`. - Event line kinds, redaction and limits, events client: `packages/logs/README.md` (proof: `packages/logs/src/`). -- Widget: `packages/widget/README.md` "Imports", "Bundle output", "The harness page", "Rules the code enforces". +- Widget: `docs/widget.md` "Imports", "Bundle output", "The harness page", "Rules the code enforces". - App kit `@agentage/extension/app` (hooks, `Region`, `Split`, test host): `packages/app/README.md`. -- Dashboard shell (`@agentage/shell-dashboard`, served by `@agentage/apphost`): `packages/shell-dashboard/README.md`. -- Sign in, page token, `mintToken`, `revokeToken`, sign out: `packages/identity/README.md`. -- The extension template: `template/` (its own `CLAUDE.md`, lockfile and CI files); README "The extension template". -- CI jobs: `.github/workflows/ci.yml`. Coverage floor: `vitest.config.ts`. Release rules: `README.md` "Release" (proof: `.github/workflows/release.yml`). +- Dashboard shell (`@agentage/shell-dashboard`, served by `@agentage/apphost`): `docs/shell-dashboard.md`. +- Sign in, page token, `mintToken`, `revokeToken`, sign out: `docs/identity.md`. +- The extension template: `template/` (its own `CLAUDE.md`, lockfile and CI files). It is not a workspace: it takes the kit + from npm, and the root lint, format, tests, type-check, build and image context leave it out. The `Template` check + runs its verify, `extension check`, `up --docker`, the e2e gate and `Template create` (short and long id) when + `template/` or `ci.yml` changes. Its `README.md` is copied into each new extension with `template` replaced by the + id: keep the id out of tables (prettier aligns them). The cli refuses a symbolic link in it. +- CI jobs: `.github/workflows/ci.yml`. Coverage floor: `vitest.config.ts`. Release rules: `docs/release.md` (proof: `.github/workflows/release.yml`). Read the file named here before you read `src/` (`src/` = `packages/extension/src`). diff --git a/README.md b/README.md index 7e562ef4..c040814c 100644 --- a/README.md +++ b/README.md @@ -1,220 +1,88 @@ -# kit +# agentage kit -agentage is a small platform that runs extensions. An extension is one npm package that adds pages, -an app, widgets, an API, MCP tools, jobs or CLI commands. This repo holds the kit, the library every -extension is built on. Extension authors, the agentage cli and the web pages that show widgets use -it, and it holds no product code. +![agentage kit: your code uses the kit and runs on an app host](https://github.com/agentage/kit/raw/master/docs/banner.svg) -## Start +The kit is the library that every agentage extension is built on. An extension is one npm package +that adds pages, an app, widgets, an API, MCP tools, jobs or terminal commands to agentage. You +write each part as one `create(ctx)` function; the kit owns the server, `/health`, auth, the store +and the images. This repo is for extension authors and for the people who work on the kit. -To write an extension, make one from the template. You need Node 22+, npm 10+ and git. `build` and -`up --docker` also need Docker. +Status: before 1.0. Extensions built on the kit run on the staging estate "next" +(`*.next.agentage.io`). You need Node 22 or newer, npm 10 or newer and git. -```bash -npx @agentage/cli@latest extension create [part...] # makes ./extension- -cd extension- && npm ci # installs the cli the project pins -git init -q && git add -A && git commit -qm init # up needs one commit -npx agentage extension up # runs it on the local daemon -``` +## Quick start -No part named means all parts. `up` runs the package's `build` script itself, adds the folder to -the daemon on `127.0.0.1:4243` and reloads the extension at each change. `up --docker` runs the -part images on Docker instead; it needs the ports 4280 and 4281 free. The template and its guide are in -[template/](template). See "The extension template" below. - -To work on this repo, you need Node 22+ and npm 10+: +Make a new extension from the template in this repo and check it: ```bash -npm ci -npm run build +npx @agentage/cli@latest extension create my-ext --no-install +cd extension-my-ext && npm ci npm run verify +npx agentage extension check # PASS my-ext 0.1.2 conforms (6 rules) ``` -## Words used here - -- **Extension**: one npm package whose `package.json` has an `agentage` block (the manifest). -- **Part**: one folder of an extension: `pages`, `app`, `ui`, `api`, `mcp`, `worker` or `cli`. A - `store` (postgres, git, clickhouse or signoz) is a part with no code folder. -- **Kit**: the library that runs a part. It owns servers, ports, `/health` and the store. -- **Tool**: the build and local-run program in the kit. The cli runs it as `agentage extension`. -- **agcid**: the request id. It is 32 hex characters. - -## Packages - -- [`@agentage/extension`](packages/extension): the extension kit and its tool (one image per part). -- [`@agentage/logs`](packages/logs): the event line: one JSON row per unit of work on stderr. - It is private: the kit ships it inside its own tarball. Import it from `@agentage/extension/logs`. -- [`@agentage/widget`](packages/widget): the `ui` part. React widgets as custom elements, the host - bridge (`useHost`), `Button` and `Card`, and the bundler with its harness page. -- [`@agentage/identity`](packages/identity): the identity client for browser pages. Sign in at - auth, get a one-hour token for the parts, `mintToken`, `revokeToken`, sign out. -- [`packages/app`](packages/app): the app kit, `useAppShell`, `useAppHost`, `Region`, `Split`. - It is private: import it from `@agentage/extension/app`. -- [`@agentage/shell-dashboard`](packages/shell-dashboard): the dashboard shell. The app host program - (`@agentage/apphost`) depends on it and serves it at `/`. - -## Write the parts - -Each part exports only `create(ctx)`. Part code never reads `process.env` or starts a server. - -```ts -// src/mcp/index.ts: tools served as {id}__{name} on POST /mcp -export function create(ctx: McpContext) { - ctx.tool('echo', { description, input, output }, async ({ msg }) => ({ msg: `pong ${msg}` })); -} -``` - -- `pages`: a map of paths to pages, files or redirects. -- `ui`: a `widgets` map of React components. -- `app`: one React root component in `src/app/index.tsx`, shown in the dashboard shell. -- `api`: an Express router mounted at `/api/{id}/`. A part image also serves it at `/api/v1/` - during the move. -- `mcp`: MCP tools, as above. -- `worker`: jobs on a five-field cron. A job never runs twice at once. -- `cli`: one handler per command in `agentage.commands`. - -[the probe extension](https://github.com/agentage/examples) has every part kind. - -More: [docs/parts.md](docs/parts.md). +`--no-install` only makes the folder. Without it, `create` also runs the new extension on the +local daemon (`127.0.0.1:4243`). The guide of the new folder is its own `README.md`. -## The tool: build, up, token +## What is in this repo -Run each command as `npx agentage extension ` inside the extension folder. +![The five npm packages of the kit and the extension template](https://github.com/agentage/kit/raw/master/docs/packages.svg) -- `check`: runs the six check rules. `--write` first rewrites the committed contracts. -- `build`: checks, then builds one image per server part. `--push` pushes the images. Needs Docker - and a committed, clean git tree (the cli checks this). -- `up`: runs the working copy on the local daemon and reloads it at each change. `up --docker` - runs it on Docker, with a store, a gateway on `localhost:4280` and a dev token issuer on - `localhost:4281`. -- `down`: removes what `up` started. `--keep-data` keeps the store volume. -- `token --scope :`: prints a dev token for the parts that `up --docker` started. +| Path | npm package | What it is | +| -------------------------- | --------------------------- | -------------------------------------------------------------- | +| `packages/extension` | `@agentage/extension` | The kit: parts, the build tool, the app kit, the event line | +| `packages/widget` | `@agentage/widget` | The `ui` part: React widgets as custom elements | +| `packages/identity` | `@agentage/identity` | Sign-in and a one-hour part token for a browser page | +| `packages/apphost` | `@agentage/apphost` | The app host program: the local daemon and the cloud host | +| `packages/shell-dashboard` | `@agentage/shell-dashboard` | The dashboard shell that an app host serves at `/` | +| `packages/app`, `logs` | private | Built into `@agentage/extension` (`/app`, `/logs`) | +| `template/` | not on npm | The start of every new extension, copied by `extension create` | +| `docs/` | - | The parts, the tool, the part image, the daemon, the release | -More: [docs/tool.md](docs/tool.md). +Words: a **part** is one folder of an extension (`pages`, `app`, `ui`, `api`, `mcp`, `worker`, +`cli`, and `store` with no code folder). An **app host** runs extensions: the daemon on your +machine, or a cloud host. The **probe** extension in +[agentage/examples](https://github.com/agentage/examples) has one part of every kind. -## Run a part image - -An image starts with `node node_modules/@agentage/extension/dist/runtime/main.js `. It -listens on port 3000. `PORT` changes the port. `AGENTAGE_*` variables set the origin, store, -settings and tokens. - -More: [docs/part-image.md](docs/part-image.md). - -## Host extensions on a machine - -`@agentage/extension/host` runs the api, mcp and worker parts of one package in one process -(`hostExtension`). `createDaemon` of `@agentage/apphost` is the local app host: one child per extension, `/api/{id}/*`, -`/mcp/{id}`, `/app/{id}/*` and the dashboard shell at `/`. The cli starts it as `agentage daemon`. -The contract is in [docs/part-image.md](docs/part-image.md#host-one-extension) and [docs/daemon.md](docs/daemon.md). - -## Write a widget - -`src/ui/index.ts` exports `widgets = { echo: Echo }`, each a React component. The full API, the -import table and the harness page are in [`packages/widget`](packages/widget/README.md). - -## Verify +## How to work on it ```bash -npm run verify -npm run test:e2e -npm run test:e2e -w @agentage/shell-dashboard +npm ci +npm run verify # type-check, lint, format:check, test with coverage, build +npx vitest run packages/identity # the tests of one package +npm run test:e2e # the widget harness in Chromium ``` -`test:e2e` runs the widget harness in Chromium with an axe WCAG A/AA sweep and screenshots in both -themes. The second e2e command checks the dashboard shell against its prototype at 1280 and -400 px. The widget screenshot baselines come from the CI container image. - -## Release - -A `v` tag on master, or a manual dispatch, runs `.github/workflows/release.yml`. The tag -must be the version of one package. The workflow runs `verify`, then publishes every package -version not yet on npm, using OIDC trusted publishing with provenance. It skips private packages. - -The same run builds the app host program image from `packages/apphost/Dockerfile`. It pushes -`ghcr.io/agentage/platform/apphost:` and a tag of the commit. Then it uploads the record -`agentage-apphost.json` to the release `@agentage/apphost@`. This job needs only -`verify`, so a held npm publish does not stop it. It does nothing when the record is already on -the release. A re-run records the image that it pushed before. It refuses a version tag with -another digest. The decision and the record are in `packages/apphost/scripts/image-release.mjs`. - -Before that, CI builds [the probe extension](https://github.com/agentage/examples) on the -packed packages, runs `up`, and checks every part image and the served discovery document. A kit -change is proven in containers before it ships. - -### Before the next release - -The repo is now `agentage/kit` (it was `agentage/platform`). npm provenance and trusted publishing match the repo and the workflow file, so the owner must change the trusted publisher on npmjs.com of each of the five packages (`@agentage/extension`, `@agentage/apphost`, `@agentage/identity`, `@agentage/shell-dashboard`, `@agentage/widget`) to repository `agentage/kit` and workflow `release.yml` before the next kit release. The program image name stays `ghcr.io/agentage/platform/apphost`: old release records name it. - -### When a release run fails +`npm run test:e2e -w @agentage/shell-dashboard` checks the dashboard shell in Chromium. The +`template/` folder is not a workspace: it has its own lock and its own CI jobs (`Template`). -Run the failed run of the tag again (`gh run rerun -R agentage/kit`). Do not open a -version-only PR: CI refuses a package version that moves with no other change in that package -(`scripts/check-bumps.mjs`). A second attempt is safe: +## How a change is released -- it passes the "release already exists" guard, which stops only a first attempt; -- the publish step skips each version that is already on npm, so it publishes only what is missing; -- a package whose `@agentage` dependency is not on npm yet waits, and the next attempt publishes it. +A merge to master releases nothing. A `v` tag on master runs +`.github/workflows/release.yml`: it runs `verify`, publishes each package version that is not on +npm yet (OIDC trusted publishing, with provenance), and pushes the app host image +`ghcr.io/agentage/platform/apphost:`. A change in `README.md`, `docs/` or a package +README ships on npm only with the next tag. Details and what to do when a run fails: +[docs/release.md](docs/release.md). -A version that the run staged (`STAGED for approval` in the log) needs the owner: approve or discard -it on npmjs.com, then run the attempt again. A run that failed in `Verify` on a known flaky test is -the same case. A real defect is a fix PR with a new version; that PR changes the package, so the -check passes. +An extension made from `template/` releases differently: each merge to its master is a release, +with a date version such as `2026.1122.1`. -### First publish of a new package name +## For agents -A name that is not on npm yet has no trusted publisher, and `release.yml` has no token: its publish -and its stage both fail. When npm answers 404 for the name, the run holds it with "new package -name: first publish needs the owner". The owner gives the name a trusted publisher; the pipeline -then publishes the real version (done this way for `@agentage/apphost` and -`@agentage/shell-dashboard`, 2026-11-19): +- Read [AGENTS.md](AGENTS.md) (the same file as `CLAUDE.md`): commands, layout, rules and where each fact lives. +- Required checks: `Verify`, `Widget screenshots`, `Probe local gate on this kit`, `Image smokes`, `Template`. +- Never publish to npm by hand, never push a `v*` tag unless the owner asks, and in automation never run `extension create` without `--no-install`. -1. Publish a placeholder by hand: a two-file package (`package.json` and `README.md`) at version - `0.0.0-bootstrap.0`, `npm publish --access public --tag bootstrap`. On a first publish npm also - points `latest` at it, until the real version is published. The trusted publisher was added on - the name with this placeholder; a name with no version was not tried. A hand publish of - `0.0.0-stage` is refused with 403 ("You cannot publish using the version"), but npm lists a - `0.0.0-stage` version on the name anyway (as on four older `@agentage` packages): use - `0.0.0-bootstrap.0`. -2. Add the trusted publisher with publish allowed: - `npx npm@12 trust github --repo agentage/kit --file release.yml --allow-publish --yes`. - Without `--allow-publish` it is stage-only, and each release needs the owner again. A new - trusted publisher expires if it does not publish within 2 days; then remove it and add it again. -3. Run the tag run again. It skips every version already on npm and publishes the new name. -4. Wait for the registry: a new version took about 3 minutes to show in `npm view`. Until the real - version shows, `latest` may still name the placeholder; check `npm view dist-tags`. +## Links -Cleanup (optional, any time, the owner): deprecate the placeholder versions and remove the -`bootstrap` dist-tag of each new name: - -``` -npm deprecate @0.0.0-bootstrap.0 "placeholder for the first trusted publish" -npm deprecate @0.0.0-stage "placeholder for the first trusted publish" -npm dist-tag rm bootstrap -``` - -## The extension template - -The folder [template/](template) is the start of every new extension. It came here with its -history from the repo `agentage/extension-template`. It is not an npm workspace: it keeps its own -`package-lock.json` and takes the kit from npm, as a new extension does. The root lint, format, tests, -type-check, build and image context leave it out. - -- CI: the `Template` check runs its verify, `agentage extension check`, `up --docker` and the e2e gate - when `template/` or `ci.yml` changes. A change in a kit package it imports runs the same jobs on the - candidate kit and widget. -- Release: `template/.github/workflows/release.yml` never runs here. A repo made by - `agentage extension create` gets it at its root: a merge to master is its release. -- The cli clones the old repo `agentage/extension-template` until a cli release takes this folder. - The old repo stays readable for older cli versions until it is archived. +- [docs/parts.md](docs/parts.md), [docs/tool.md](docs/tool.md), + [docs/part-image.md](docs/part-image.md), [docs/daemon.md](docs/daemon.md), + [docs/release.md](docs/release.md). +- [agentage/cli](https://github.com/agentage/cli): the `agentage` command (`@agentage/cli`). +- [agentage/examples](https://github.com/agentage/examples): the probe and fixture extensions. +- [agentage.io](https://agentage.io): the product. ## License MIT. See [LICENSE](LICENSE). - -## Documentation - -- [docs/parts.md](docs/parts.md): write each part, the store, workers, logs and spans, tests. -- [docs/tool.md](docs/tool.md): build, check, up, down and token in detail. -- [docs/part-image.md](docs/part-image.md): run a part image in a deployment, every setting and the - host. -- [docs/daemon.md](docs/daemon.md): the local daemon, its routes, limits and seal. diff --git a/docs/apphost.md b/docs/apphost.md new file mode 100644 index 00000000..b93fbca9 --- /dev/null +++ b/docs/apphost.md @@ -0,0 +1,53 @@ +# @agentage/apphost in detail + +The short form is the [package README](../packages/apphost/README.md). Paths are relative to +`packages/apphost/`. + +It builds on the extension kit `@agentage/extension`, a peer dependency (`~.`): the child entry, the host document schema and the combine function. Install it beside a kit of that minor. The kit does not import this package. + +## The cloud entry + +The bin `agentage-apphost-cloud` runs a cloud app host. It reads `installation.json` and `upstreams.json` of the host. The cloud form of `installation.json` names the program on one line: + +```json +{ + "host": "platform", + "program": { "version": "0.4.0" }, + "shell": { "package": "@agentage/shell-dashboard" }, + "extensions": [{ "id": "fixture", "version": "0.2.19", "expose": { "api": "public" } }] +} +``` + +- `program.version` must be the version of this program, or the start is refused. +- `shell` names a package only. The program serves the shell version it carries and reports that version in the host document. +- `source` and `enabled` are for a machine only. A row needs a `version`. +- The ids `router` and `host`, an id that ends in `-pages` and a shell package as a row are refused. Only one row serves pages. + +The router writes one request line per call as extension `host`, part `router`. Its route names the id of the matched row (`/api/{id}/*` with the real id, also on a 503 of a starting row); a path of no row is `(unmatched)`. It sends its `agcid` upstream, so the upstream rows carry the same id. Env: `AGENTAGE_URL` is required; `AGENTAGE_CORE_URL` is optional and not read (a value that is set must still be an https origin). + +The route of the line is `/api/{id}/*` or `/mcp/{id}/*` for an id of a row. A path of a pages host that no row of `/api`, `/mcp` or `/app` takes has the route `/*`, and its `/.well-known/` names have `/.well-known/*`. `(unmatched)` is the route of every request that no row and no route answers: an `/api`, `/mcp` or `/app` path whose id is of no row (a caller id never reaches the line), and any other path on a host with no pages row. + +## Security headers + +The cloud router and the daemon send the same set, from `helmet` with the values of the edge, so a header the edge also sets never has two values. The values: + +| Header | Value | +| ----------------------------------- | --------------------------------- | +| `Cross-Origin-Opener-Policy` | `same-origin` | +| `Cross-Origin-Resource-Policy` | `same-origin` | +| `Origin-Agent-Cluster` | `?1` | +| `Referrer-Policy` | `strict-origin-when-cross-origin` | +| `Strict-Transport-Security` | `max-age=31536000` | +| `X-Content-Type-Options` | `nosniff` | +| `X-DNS-Prefetch-Control` | `off` | +| `X-Download-Options` | `noopen` | +| `X-Frame-Options` | `DENY` | +| `X-Permitted-Cross-Domain-Policies` | `none` | +| `X-XSS-Protection` | `0` | + +- `Strict-Transport-Security` is sent only when `AGENTAGE_URL` starts with `https:`. The daemon (loopback http) never sends it. +- There is no `Content-Security-Policy` header from the program (`contentSecurityPolicy: false`). The shell page carries its own policy in a meta tag, and a proxied answer keeps the policy of its upstream. +- On a proxied answer the upstream value of a header replaces the program value, so there is one value per name. +- `Cross-Origin-Resource-Policy: same-origin` stops a page on another origin from showing an image that the router serves. A public site that wants hot-linked images must send its own value. + +`agentage-apphost-cloud --check DIR` runs the checks of the start on `DIR/installation.json` and `DIR/upstreams.json`. It also refuses a `host` that is not the folder name. It needs no env and never listens. It prints one line for each refusal and exits 0 or 1. The files in `fixtures/check/` show the form. diff --git a/docs/banner.svg b/docs/banner.svg new file mode 100644 index 00000000..d44039a6 --- /dev/null +++ b/docs/banner.svg @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + agentage kit + + the library every agentage extension + is built on, and the app host program + npx @agentage/cli extension create my-ext + five npm packages and the extension template, one repo + + + + YOUR CODE + one folder per part + create(ctx) + + + + THE KIT + server, /health, store + @agentage/extension + + + + AN APP HOST + your machine or a cloud + @agentage/apphost + + + + uses + + runs on + + + you write each part as create(ctx); the kit owns the server, the store and the images; an app host runs the extension + diff --git a/docs/extension-package.md b/docs/extension-package.md new file mode 100644 index 00000000..e78a2c3e --- /dev/null +++ b/docs/extension-package.md @@ -0,0 +1,84 @@ +# @agentage/extension in detail + +The short form is the [package README](../packages/extension/README.md). + +## Subpaths + +The agentage extension kit. Each server and cli part (pages, api, mcp, worker, cli) exports only +`create(ctx)` (the ui part is a `widgets` map, the app part one React root component); the kit owns the server, port, `/health`, the discovery document, the `agcid` +correlation id, the response envelope, the store pool, the scheduler and argument parsing. +`@agentage/extension/tool` is the tool behind `agentage extension check | build | up --docker | down | token`. +`@agentage/extension/host` is the host and the daemon, `@agentage/extension/contracts` the wire +schemas. The host document has the optional key `program { version, commit }` since 0.20.4: a cloud +app host fills it with its program; the daemon leaves it out. +The route `GET /api/{id}/caller` (the caller's own token facts) exists since 0.21.0. +The app kit has `setNavSection` since 0.22.0: an open app gives the shell a titled nav section. +`@agentage/extension/logs` is the event line (`EventSchema`, `parseLine`, `createLogger`, +`createEventsClient`, `KINDS`, `LEVELS`, `USER_TYPES`), built into the kit's own tarball. +`@agentage/extension/core` is the one client of the core's services (see "The core client"). +`@agentage/extension/app` is the app part: `useAppShell()` (route, regions, notices, state) and +`useAppHost()` (`user`, `scopes`, `api`, and since 0.18.2 `extension { id, version }` and +`host { kind, url }`, kind `local`, `desktop` or `cloud`). + +````bash + +## The core client + +`createCoreClient({ url, timeoutMs, token })` calls the core: `market.latest(id)`, `market.list()`, +`market.down()`, `logs.send(rows)` and `logs.down()`. It never throws. Each method call ends +before `timeoutMs` (default 2000 ms): the address and all requests of the call share one deadline. + +- Each call answers `{ data, down }`. When the core is silent, `data` is the empty answer: `null` + or an empty listing. `down` then has a `code`, a `message` and a `detail`. +- `data: null, down: null` from `market.latest` means the market itself refused the id: a 404 + with its error envelope, `no listed extension ` or ` has no release yet`. Any other + 404, such as a route miss of the app host or a proxy page, is `failed`. +- `market.down()` and `logs.down()` keep the first reason of that service. +- The address: `url` (an origin, or a function that resolves one), else `AGENTAGE_CORE_URL` of + `env`. A missing or empty address is no error: each call answers `down.code` `no_core`. +- `logs.send` drops a failed send with one warning, until a send goes through again. It needs + `token`, sent over https or to this machine only (`localhost`, `*.localhost`, `127.x`, `::1`). +- `./core` is for Node: `logs.send` uses the Node events client. The market reads import nothing, so a + browser entry for them is a small split later. + +| `down.code` | `message` | When | +| ------------- | ------------------------- | ----------------------------------------------------------------- | +| `no_core` | ` not reachable` | no address, not a URL, or the `url` function threw (`cause`) | +| `unreachable` | ` not reachable` | no connection | +| `timeout` | ` not reachable` | no answer before the deadline, a stalled body | +| `failed` | ` not reachable` | not 2xx, a 404 that is not the market's, a redirect, over 1 MB | +| `not_json` | ` not reachable` | a market body that is not JSON | +| `refused` | `market answer refused` | a 2xx with no release or rows, or not an exact version of that id | +| `no_token` | `logs needs a token` | `logs.send` with no token | + +The rules for a caller: + +- A caller that needs the market, such as an install or an update with no version, treats + `down !== null` as an error and changes nothing. Only a list for a page shows the empty answer. +- A release loop reads `data: null` as "no release" only when `down` is null. It also skips a + prerelease version and a `commit` of `null`, and keeps its own origin on https. +- Pass `timeoutMs` for the work: about 10 s for an install or a list in a terminal; a worker + sets its own. The default suits a page or a start that must not wait. + +`agentage extension check [dir] --json` prints the conformance report (exit 1 when `conforms` is +false); `file` and `line` are there only when a problem has them. `warnings` is there only when a +rule warned: an `engines.agentage` of an older kit minor from the floor `0.12` up conforms with a +warning; below the floor or above the running kit it is a problem: + +```json +{ + "id": "probe", + "version": "0.4.0", + "conforms": false, + "rules": ["manifest", "entries", "surface", "stack", "store", "sealing"], + "problems": [ + { "rule": "sealing", "file": "src/api/index.ts", "line": 7, "problem": "reads process.env" } + ], + "skipped": {} +} +```` + +Secrets: `agentage.secrets` lists names, never values. A plain name is mounted in every part +but ui; `{ "name": "github-app-key", "parts": ["worker"] }` only in the parts it names. Any +other part starts without it, and a read of `ctx.secrets.githubAppKey` there throws. A test +takes a part's view with `createTestContext({ extension: { part: 'worker' } })`. diff --git a/docs/identity.md b/docs/identity.md new file mode 100644 index 00000000..f055ba72 --- /dev/null +++ b/docs/identity.md @@ -0,0 +1,23 @@ +# @agentage/identity in detail + +The short form is the [package README](../packages/identity/README.md). + +`/sign-in?next=` and comes back after sign-in; call `signIn()` again on load. + +- `token()` returns `() => Promise`. The first call mints a one-hour PAT (`expiresInMinutes: 60`) + (`POST /account/pat`, `format: 'jwt'`, label `browser`); it stays in page memory only and is + minted again 60 s before it expires. Without a session it gives `undefined`. +- `signOut()` deletes that PAT (`DELETE /account/pat/{id}`; the parts refuse it within 60 s), + then ends the auth session. +- `account()` is the signed-in account or `null`; `tokens()` lists the account's PATs. +- `mintToken({ label, scopes, expiresInDays })` mints a PAT of that label, scopes and lifetime + (1-730 days) and resolves `{ id, token, expiresAt }`; the token is shown once. + `revokeToken(id)` revokes one (`DELETE /account/pat/{id}`). + +Two options are for tests and embedders: `fetch` (a `fetch`-shaped function; the global `fetch` is +used, read at call time, when left out) and `location` (`{ href, assign }`; `window.location` when +left out) that `signIn()` navigates. + +`scopes` is required: auth mints no PAT without one. Auth sets the token's audience itself. A +failed call throws an `IdentityError` with `code`, `message` and the HTTP `status`. The client +never logs a token. diff --git a/docs/packages.svg b/docs/packages.svg new file mode 100644 index 00000000..1ebe6e3a --- /dev/null +++ b/docs/packages.svg @@ -0,0 +1,44 @@ + + + + + + + + + What is in this repo + + + THE KIT + @agentage/extension + parts, build tool, + app kit, logs + + WIDGETS + @agentage/widget + the ui part as React + custom elements + + SIGN IN + @agentage/identity + browser sign-in and + a one-hour token + + APP HOST + @agentage/apphost + the daemon and the + cloud host program + + SHELL + @agentage/shell-dashboard + the dashboard frame + an app host serves + + TEMPLATE + template/ + the start of every + new extension + + the five packages are public on npm; a v* tag on master releases them + agentage extension create copies template/ into a new repo of its own + diff --git a/docs/release.md b/docs/release.md new file mode 100644 index 00000000..38d689fa --- /dev/null +++ b/docs/release.md @@ -0,0 +1,70 @@ +# Release the kit + +How the five public packages and the app host program image are released. The short form is in +the [README](../README.md#how-a-change-is-released). + +A `v` tag on master, or a manual dispatch, runs `.github/workflows/release.yml`. The tag +must be the version of one package. The workflow runs `verify`, then publishes every package +version not yet on npm, using OIDC trusted publishing with provenance. It skips private packages. + +The same run builds the app host program image from `packages/apphost/Dockerfile`. It pushes +`ghcr.io/agentage/platform/apphost:` and a tag of the commit. Then it uploads the record +`agentage-apphost.json` to the release `@agentage/apphost@`. This job needs only +`verify`, so a held npm publish does not stop it. It does nothing when the record is already on +the release. A re-run records the image that it pushed before. It refuses a version tag with +another digest. The decision and the record are in `packages/apphost/scripts/image-release.mjs`. + +Before that, CI builds [the probe extension](https://github.com/agentage/examples) on the +packed packages, runs `up`, and checks every part image and the served discovery document. A kit +change is proven in containers before it ships. + +## Before the next release + +The repo is now `agentage/kit` (it was `agentage/platform`). npm provenance and trusted publishing match the repo and the workflow file, so the owner must change the trusted publisher on npmjs.com of each of the five packages (`@agentage/extension`, `@agentage/apphost`, `@agentage/identity`, `@agentage/shell-dashboard`, `@agentage/widget`) to repository `agentage/kit` and workflow `release.yml` before the next kit release. The program image name stays `ghcr.io/agentage/platform/apphost`: old release records name it. + +## When a release run fails + +Run the failed run of the tag again (`gh run rerun -R agentage/kit`). Do not open a +version-only PR: CI refuses a package version that moves with no other change in that package +(`scripts/check-bumps.mjs`). A second attempt is safe: + +- it passes the "release already exists" guard, which stops only a first attempt; +- the publish step skips each version that is already on npm, so it publishes only what is missing; +- a package whose `@agentage` dependency is not on npm yet waits, and the next attempt publishes it. + +A version that the run staged (`STAGED for approval` in the log) needs the owner: approve or discard +it on npmjs.com, then run the attempt again. A run that failed in `Verify` on a known flaky test is +the same case. A real defect is a fix PR with a new version; that PR changes the package, so the +check passes. + +## First publish of a new package name + +A name that is not on npm yet has no trusted publisher, and `release.yml` has no token: its publish +and its stage both fail. When npm answers 404 for the name, the run holds it with "new package +name: first publish needs the owner". The owner gives the name a trusted publisher; the pipeline +then publishes the real version (done this way for `@agentage/apphost` and +`@agentage/shell-dashboard`, 2026-11-19): + +1. Publish a placeholder by hand: a two-file package (`package.json` and `README.md`) at version + `0.0.0-bootstrap.0`, `npm publish --access public --tag bootstrap`. On a first publish npm also + points `latest` at it, until the real version is published. The trusted publisher was added on + the name with this placeholder; a name with no version was not tried. A hand publish of + `0.0.0-stage` is refused with 403 ("You cannot publish using the version"), but npm lists a + `0.0.0-stage` version on the name anyway (as on four older `@agentage` packages): use + `0.0.0-bootstrap.0`. +2. Add the trusted publisher with publish allowed: + `npx npm@12 trust github --repo agentage/kit --file release.yml --allow-publish --yes`. + Without `--allow-publish` it is stage-only, and each release needs the owner again. A new + trusted publisher expires if it does not publish within 2 days; then remove it and add it again. +3. Run the tag run again. It skips every version already on npm and publishes the new name. +4. Wait for the registry: a new version took about 3 minutes to show in `npm view`. Until the real + version shows, `latest` may still name the placeholder; check `npm view dist-tags`. + +Cleanup (optional, any time, the owner): deprecate the placeholder versions and remove the +`bootstrap` dist-tag of each new name: + +``` +npm deprecate @0.0.0-bootstrap.0 "placeholder for the first trusted publish" +npm deprecate @0.0.0-stage "placeholder for the first trusted publish" +npm dist-tag rm bootstrap +``` diff --git a/docs/shell-dashboard.md b/docs/shell-dashboard.md new file mode 100644 index 00000000..4eab2131 --- /dev/null +++ b/docs/shell-dashboard.md @@ -0,0 +1,98 @@ +# @agentage/shell-dashboard in detail + +The short form is the [package README](../packages/shell-dashboard/README.md). Paths are relative +to `packages/shell-dashboard/`. + +The dashboard shell: one static folder that a host serves at `/`. It is the frame of the accepted +prototype (variant B; a copy is `e2e/prototype/index.html`) in React 19, styled by Tailwind v4 with the +`@agentage/design-system` token files (no `base.css`) and the prototype CSS as a `components` layer. + +It is published on npm (`files`: `dist`). The app host program (`@agentage/apphost`) depends on it +and serves this package on both kinds: the daemon, and a cloud host whose `installation.json` names it. +The page names this package's version. The kit carries no copy of it. +Since 0.4.0 the shell shows a titled nav section that the open app provides (`setNavSection`). + +## Bundle output + +`npm run build` writes `dist/`: + +| Path | Served at | What | +| --------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------- | +| `dist/index.html` | `/` and every app page | pre-paint scripts, the import map, `` | +| `dist/shell.js`, `dist/shell.css` | `/shell/*` | the frame | +| `dist/vendor/*.js` | `/shell/vendor/*` | one React, react-dom and `@agentage/extension/app` for the shell and every app | + +The host serves `dist/*` at `/shell/*` (one mapping, `shellFileOf` in `scripts/build.mjs`). A host finds the folder with `import.meta.resolve('@agentage/shell-dashboard/dist/index.html')`. + +### Content Security Policy + +`dist/index.html` carries its policy in a `` tag, so every host that serves the page applies it: scripts, styles, fonts, images and connections come from the page origin only (`data:` for images and fonts), with no `unsafe-inline` and no `unsafe-eval`. The build (`scripts/csp.mjs`) adds the sha256 of each inline script, so an edit to an inline script cannot make the hash stale. An app entry, an app stylesheet or a `fetch` on another origin, or an injected `