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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
held+=("${name}@${version} STAGED for approval on npmjs.com, not published")
# Only a real 404 is a new name; a registry outage or a timeout keeps the line below.
elif { npm view "${name}" name 2>&1 || true; } | grep -q E404; then
held+=("${name}@${version} new package name: first publish needs the owner (README.md, \"First publish of a new package name\")")
held+=("${name}@${version} new package name: first publish needs the owner (docs/release.md, \"First publish of a new package name\")")
else
held+=("${name}@${version} not published and not staged (already staged? approve it on npmjs.com)")
fi
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
19 changes: 12 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`).

Expand Down
249 changes: 59 additions & 190 deletions README.md

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions docs/apphost.md
Original file line number Diff line number Diff line change
@@ -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 (`~<kit minor>.<patch>`): 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.
74 changes: 74 additions & 0 deletions docs/banner.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions docs/extension-package.md
Original file line number Diff line number Diff line change
@@ -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 <id>` or `<id> 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` | `<service> not reachable` | no address, not a URL, or the `url` function threw (`cause`) |
| `unreachable` | `<service> not reachable` | no connection |
| `timeout` | `<service> not reachable` | no answer before the deadline, a stalled body |
| `failed` | `<service> not reachable` | not 2xx, a 404 that is not the market's, a redirect, over 1 MB |
| `not_json` | `<service> 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' } })`.
Loading
Loading