@agentage/extension 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,85 +1,45 @@
1
1
  # @agentage/extension
2
2
 
3
- The agentage extension kit. Each server and cli part (pages, api, mcp, worker, cli) exports only
4
- `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`
5
- correlation id, the response envelope, the store pool, the scheduler and argument parsing.
6
- `@agentage/extension/tool` is the tool behind `agentage extension check | build | up --docker | down | token`.
7
- `@agentage/extension/host` is the host and the daemon, `@agentage/extension/contracts` the wire
8
- schemas. The host document has the optional key `program { version, commit }` since 0.20.4: a cloud
9
- app host fills it with its program; the daemon leaves it out.
10
- The route `GET /api/{id}/caller` (the caller's own token facts) exists since 0.21.0.
11
- The app kit has `setNavSection` since 0.22.0: an open app gives the shell a titled nav section.
12
- `@agentage/extension/logs` is the event line (`EventSchema`, `parseLine`, `createLogger`,
13
- `createEventsClient`, `KINDS`, `LEVELS`, `USER_TYPES`), built into the kit's own tarball.
14
- `@agentage/extension/core` is the one client of the core's services (see "The core client").
15
- `@agentage/extension/app` is the app part: `useAppShell()` (route, regions, notices, state) and
16
- `useAppHost()` (`user`, `scopes`, `api`, and since 0.18.2 `extension { id, version }` and
17
- `host { kind, url }`, kind `local`, `desktop` or `cloud`).
3
+ ![agentage kit: your code uses the kit and runs on an app host](https://github.com/agentage/kit/raw/master/docs/banner.svg)
4
+
5
+ The extension kit of agentage. You write each part of an extension as one `create(ctx)` function.
6
+ The kit owns the server, the port, `/health`, auth, the store and the images. It also holds the
7
+ build tool that the `agentage extension` commands run. It is for extension authors.
18
8
 
19
9
  ```bash
20
10
  npm install @agentage/extension express zod
21
11
  ```
22
12
 
23
- ## The core client
24
-
25
- `createCoreClient({ url, timeoutMs, token })` calls the core: `market.latest(id)`, `market.list()`,
26
- `market.down()`, `logs.send(rows)` and `logs.down()`. It never throws. Each method call ends
27
- before `timeoutMs` (default 2000 ms): the address and all requests of the call share one deadline.
28
-
29
- - Each call answers `{ data, down }`. When the core is silent, `data` is the empty answer: `null`
30
- or an empty listing. `down` then has a `code`, a `message` and a `detail`.
31
- - `data: null, down: null` from `market.latest` means the market itself refused the id: a 404
32
- with its error envelope, `no listed extension <id>` or `<id> has no release yet`. Any other
33
- 404, such as a route miss of the app host or a proxy page, is `failed`.
34
- - `market.down()` and `logs.down()` keep the first reason of that service.
35
- - The address: `url` (an origin, or a function that resolves one), else `AGENTAGE_CORE_URL` of
36
- `env`. A missing or empty address is no error: each call answers `down.code` `no_core`.
37
- - `logs.send` drops a failed send with one warning, until a send goes through again. It needs
38
- `token`, sent over https or to this machine only (`localhost`, `*.localhost`, `127.x`, `::1`).
39
- - `./core` is for Node: `logs.send` uses the Node events client. The market reads import nothing, so a
40
- browser entry for them is a small split later.
41
-
42
- | `down.code` | `message` | When |
43
- | ------------- | ------------------------- | ----------------------------------------------------------------- |
44
- | `no_core` | `<service> not reachable` | no address, not a URL, or the `url` function threw (`cause`) |
45
- | `unreachable` | `<service> not reachable` | no connection |
46
- | `timeout` | `<service> not reachable` | no answer before the deadline, a stalled body |
47
- | `failed` | `<service> not reachable` | not 2xx, a 404 that is not the market's, a redirect, over 1 MB |
48
- | `not_json` | `<service> not reachable` | a market body that is not JSON |
49
- | `refused` | `market answer refused` | a 2xx with no release or rows, or not an exact version of that id |
50
- | `no_token` | `logs needs a token` | `logs.send` with no token |
51
-
52
- The rules for a caller:
53
-
54
- - A caller that needs the market, such as an install or an update with no version, treats
55
- `down !== null` as an error and changes nothing. Only a list for a page shows the empty answer.
56
- - A release loop reads `data: null` as "no release" only when `down` is null. It also skips a
57
- prerelease version and a `commit` of `null`, and keeps its own origin on https.
58
- - Pass `timeoutMs` for the work: about 10 s for an install or a list in a terminal; a worker
59
- sets its own. The default suits a page or a start that must not wait.
60
-
61
- `agentage extension check [dir] --json` prints the conformance report (exit 1 when `conforms` is
62
- false); `file` and `line` are there only when a problem has them. `warnings` is there only when a
63
- rule warned: an `engines.agentage` of an older kit minor from the floor `0.12` up conforms with a
64
- warning; below the floor or above the running kit it is a problem:
65
-
66
- ```json
67
- {
68
- "id": "probe",
69
- "version": "0.4.0",
70
- "conforms": false,
71
- "rules": ["manifest", "entries", "surface", "stack", "store", "sealing"],
72
- "problems": [
73
- { "rule": "sealing", "file": "src/api/index.ts", "line": 7, "problem": "reads process.env" }
74
- ],
75
- "skipped": {}
13
+ A part is one folder in `src/`. This MCP part, from the extension template, serves the tool
14
+ `{id}__echo` on `POST /mcp`:
15
+
16
+ ```ts
17
+ import { type McpContext } from '@agentage/extension';
18
+ import { z } from 'zod';
19
+
20
+ export function create(ctx: McpContext) {
21
+ ctx.tool(
22
+ 'echo',
23
+ {
24
+ description: 'Echo a message back',
25
+ scope: 'read',
26
+ input: z.object({ msg: z.string().min(1).max(200) }),
27
+ output: z.object({ msg: z.string() }),
28
+ },
29
+ async ({ msg }) => ({ msg: `pong ${msg}` })
30
+ );
76
31
  }
77
32
  ```
78
33
 
79
- Secrets: `agentage.secrets` lists names, never values. A plain name is mounted in every part
80
- but ui; `{ "name": "github-app-key", "parts": ["worker"] }` only in the parts it names. Any
81
- other part starts without it, and a read of `ctx.secrets.githubAppKey` there throws. A test
82
- takes a part's view with `createTestContext({ extension: { part: 'worker' } })`.
34
+ Start a new extension with `npx @agentage/cli extension create my-ext`: it pins this kit for you.
35
+
36
+ Since 0.23.0, `check` asks an app part for `@agentage/components` ^0.21, the library that replaces
37
+ `@agentage/design-system`.
38
+
39
+ - The subpaths, the core client, the check report and secrets:
40
+ [docs/extension-package.md](https://github.com/agentage/kit/blob/master/docs/extension-package.md).
41
+ - Every part kind: [docs/parts.md](https://github.com/agentage/kit/blob/master/docs/parts.md). The tool:
42
+ [docs/tool.md](https://github.com/agentage/kit/blob/master/docs/tool.md). The whole kit: the
43
+ [kit README](https://github.com/agentage/kit#readme).
83
44
 
84
- See the [platform README](https://github.com/agentage/platform#readme) for every part kind, the
85
- manifest, the tool and how a part image runs.
45
+ License: MIT
@@ -79,7 +79,7 @@ const logsOf = (s, o) => {
79
79
  };
80
80
  return { send, down: () => s.first.logs ?? null };
81
81
  };
82
- // Never throws and never waits past timeoutMs; the caller rules: README "The core client".
82
+ // Never throws, never waits past timeoutMs; caller rules: docs/extension-package.md "The core client".
83
83
  export const createCoreClient = (o = {}) => {
84
84
  const s = {
85
85
  url: o.url ?? coreUrlOf(o.env ?? {}),
@@ -8,6 +8,6 @@ export interface AppBuilder {
8
8
  rebuild(): Promise<AppFiles>;
9
9
  dispose(): Promise<void>;
10
10
  }
11
- export declare const dsSources: (dir: string, metafile?: Esbuild.Metafile) => string[];
11
+ export declare const libSources: (dir: string, metafile?: Esbuild.Metafile) => string[];
12
12
  export declare const appBuilder: (at: string) => Promise<AppBuilder>;
13
13
  export declare const buildApp: (dir: string) => Promise<AppFiles>;
@@ -38,28 +38,25 @@ const esbuildOptions = (dir, entry) => ({
38
38
  metafile: true,
39
39
  outfile: join(dir, APP_DIR, 'app.js'),
40
40
  });
41
- const DS = /(^|\/)node_modules\/@agentage\/design-system\//;
42
- // The design-system files the app bundles: their classes are scanned too, or a DS Button has no style.
43
- export const dsSources = (dir, metafile) => Object.keys(metafile?.inputs ?? {})
44
- .filter((file) => DS.test(file))
41
+ const LIB = /(^|\/)node_modules\/@agentage\/components\//;
42
+ // The components files the app bundles: their classes are scanned too, or a Button has no style.
43
+ export const libSources = (dir, metafile) => Object.keys(metafile?.inputs ?? {})
44
+ .filter((file) => LIB.test(file))
45
45
  .map((file) => resolve(dir, file));
46
- // The @theme blocks of the design-system tokens (the file also has :root rules), as reference only.
47
- const dsTheme = async (dir) => {
48
- const file = resolveFrom(dir, '@agentage/design-system/styles/tokens.css');
49
- if (!file)
50
- return [];
51
- const blocks = (await readFile(file, 'utf8')).match(/@theme\s*\{[^{}]*\}/g) ?? [];
52
- return blocks.map((b) => b.replace(/^@theme/, '@theme reference'));
46
+ // The components tokens as reference: names, @utility and keyframes; the shell gives the values.
47
+ const libTokens = (dir) => {
48
+ const file = resolveFrom(dir, '@agentage/components/styles/tokens.css');
49
+ return file ? [`@import "${file}" reference;`] : [];
53
50
  };
54
51
  // Utilities only, no preflight and no theme variables: the shell owns both.
55
52
  // Token names only (reference): utilities like bg-primary exist; the shell gives the values.
56
- const cssInput = async (dir, extra) => {
53
+ const cssInput = (dir, extra) => {
57
54
  const tw = packageDir(dir, 'tailwindcss');
58
55
  const tokens = resolveFrom(dir, '@agentage/extension/app/theme.css');
59
56
  return [
60
57
  '@layer theme, utilities;',
61
58
  `@import "${join(tw, 'theme.css')}" layer(theme) theme(reference inline);`,
62
- ...(await dsTheme(dir)),
59
+ ...libTokens(dir),
63
60
  ...(tokens ? [`@import "${tokens}" layer(theme) theme(reference);`] : []),
64
61
  `@import "${join(tw, 'utilities.css')}" layer(utilities) source(none);`,
65
62
  `@source "${join(dir, 'src', 'app')}";`,
@@ -71,7 +68,7 @@ const compileCss = async (dir, extra) => {
71
68
  const tailwind = await loadFrom(dir, '@tailwindcss/postcss');
72
69
  const plugin = tailwind({ base: dir, optimize: { minify: true } });
73
70
  const from = join(dir, 'src', 'app', 'app.css');
74
- return (await postcss([plugin]).process(await cssInput(dir, extra), { from })).css;
71
+ return (await postcss([plugin]).process(cssInput(dir, extra), { from })).css;
75
72
  };
76
73
  const hashed = (code, ext) => `app-${createHash('sha256').update(code).digest('hex').slice(0, 10)}.${ext}`;
77
74
  // Written then renamed: a reader sees the old file or the new one, never half of one.
@@ -110,7 +107,7 @@ export const appBuilder = async (at) => {
110
107
  const rebuild = async () => {
111
108
  const result = await ctx.rebuild();
112
109
  const code = result.outputFiles?.[0]?.contents ?? new Uint8Array();
113
- return writeApp(dir, code, await compileCss(dir, dsSources(dir, result.metafile)));
110
+ return writeApp(dir, code, await compileCss(dir, libSources(dir, result.metafile)));
114
111
  };
115
112
  return { rebuild, dispose: () => ctx.dispose() };
116
113
  };
@@ -10,7 +10,7 @@ import {} from '../manifest/primitives.schema.js';
10
10
  import { formatIssues, readJsonIfExists } from '../manifest/read-manifest.js';
11
11
  import { runCommand } from './exec.js';
12
12
  import { problemLines, warningLines } from './format.js';
13
- import { designSystemProblems } from './rules/app-deps.js';
13
+ import { componentsProblems } from './rules/app-deps.js';
14
14
  import { exportedPartCode } from './rules/folders.js';
15
15
  import { sealing } from './rules/sealing.js';
16
16
  import { store } from './rules/store.js';
@@ -63,7 +63,7 @@ const appProblem = async ({ dir, pkg }) => {
63
63
  if (!appOf(pkg))
64
64
  return [];
65
65
  const built = (await exists(join(dir, 'dist/app/index.js'))) ? [] : [{ problem: APP_BUILT }];
66
- return [...built, ...designSystemProblems(pkg)];
66
+ return [...built, ...componentsProblems(pkg)];
67
67
  };
68
68
  // Every part built and exporting only create; cli handlers = commands; exports hold no part code.
69
69
  const entries = {
@@ -1,3 +1,3 @@
1
1
  import { type ExtensionPackage } from '../../manifest/manifest.schema.js';
2
2
  import { type Finding } from '../check.js';
3
- export declare const designSystemProblems: (pkg: ExtensionPackage) => Finding[];
3
+ export declare const componentsProblems: (pkg: ExtensionPackage) => Finding[];
@@ -1,25 +1,27 @@
1
1
  import semver from 'semver';
2
2
  import {} from '../../manifest/manifest.schema.js';
3
3
  import {} from '../check.js';
4
- const DS = '@agentage/design-system';
5
- const NEEDED = '^0.20';
6
- // The kit's app code imports the design system (resizable-split, 0.20+), so the app part must declare it.
7
- export const designSystemProblems = (pkg) => {
4
+ const LIB = '@agentage/components';
5
+ const OLD = '@agentage/design-system';
6
+ const NEEDED = '^0.21';
7
+ const specsOf = (pkg, name) => {
8
8
  const declared = pkg;
9
- const specs = [
10
- declared.dependencies,
11
- declared.devDependencies,
12
- declared.peerDependencies,
13
- ].flatMap((group) => (group?.[DS] ?? []));
9
+ return [declared.dependencies, declared.devDependencies, declared.peerDependencies].flatMap((group) => (group?.[name] ?? []));
10
+ };
11
+ const finding = (problem) => [{ file: 'package.json', problem }];
12
+ // The kit's app code imports the components (resizable-split, 0.21+), so the app part must declare them.
13
+ export const componentsProblems = (pkg) => {
14
+ const old = specsOf(pkg, OLD).length > 0;
15
+ const specs = specsOf(pkg, LIB);
14
16
  if (specs.length === 0)
15
- return [
16
- {
17
- file: 'package.json',
18
- problem: `the app part needs ${DS} ${NEEDED}: declare it in dependencies, devDependencies or peerDependencies`,
19
- },
20
- ];
17
+ return finding(old
18
+ ? `${OLD} is replaced: switch the app part to ${LIB} ${NEEDED}`
19
+ : `the app part needs ${LIB} ${NEEDED}: declare it in dependencies, devDependencies or peerDependencies`);
21
20
  const bad = specs.find((spec) => !semver.validRange(spec) || !semver.subset(spec, NEEDED));
22
- return bad === undefined
23
- ? []
24
- : [{ file: 'package.json', problem: `${DS} ${bad}, the app part needs ${NEEDED}` }];
21
+ if (bad !== undefined)
22
+ return finding(`${LIB} ${bad}, the app part needs ${NEEDED}`);
23
+ // Both: a kit of 0.22 or older still imports the old library; remove it once no kit needs it.
24
+ return old
25
+ ? [{ file: 'package.json', problem: `${OLD} is replaced by ${LIB}: remove it`, warning: true }]
26
+ : [];
25
27
  };
@@ -1,7 +1,7 @@
1
- import { type ResizableSplitApi } from '@agentage/design-system/resizable-split';
1
+ import { type ResizableSplitApi } from '@agentage/components/resizable-split';
2
2
  import { type ReactNode, type Ref } from 'react';
3
- export { useResizableSplit as useSplit } from '@agentage/design-system/resizable-split';
4
- export type { ResizableSplitApi as SplitApi } from '@agentage/design-system/resizable-split';
3
+ export { useResizableSplit as useSplit } from '@agentage/components/resizable-split';
4
+ export type { ResizableSplitApi as SplitApi } from '@agentage/components/resizable-split';
5
5
  export declare const splitKey: (app: string, id: string) => string;
6
6
  export declare const splitVar: (app: string, id: string) => string;
7
7
  export declare const SPLIT_PREPAINT = "try{var d=document.documentElement,L=localStorage,E=function(k){return k.replace(/[^A-Za-z0-9-]/g,function(c){return '_'+c.charCodeAt(0).toString(16)+'_'})};for(var i=0;i<L.length;i++){var k=L.key(i),m=/^ag\\.split\\.[a-z0-9-]+\\.[a-z0-9-]+$/.test(k),n=parseInt(L.getItem(k),10);if(m&&n>0&&n<8000)d.style.setProperty('--split-'+E(k),n+'px');if(m&&L.getItem(k+'.collapsed')==='1')d.style.setProperty('--splitc-'+E(k),'0px')}}catch(e){}";
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ResizableSplit } from '@agentage/design-system/resizable-split';
2
+ import { ResizableSplit } from '@agentage/components/resizable-split';
3
3
  import { useEffect, useState } from 'react';
4
4
  import { useAppContext } from './context.js';
5
- export { useResizableSplit as useSplit } from '@agentage/design-system/resizable-split';
5
+ export { useResizableSplit as useSplit } from '@agentage/components/resizable-split';
6
6
  const NAME = /^[a-z0-9-]+$/;
7
7
  const PHONE = '(max-width: 759px)';
8
- // The stored size key; the design-system split names its CSS variables from it.
8
+ // The stored size key; the components split names its CSS variables from it.
9
9
  export const splitKey = (app, id) => `ag.split.${app}.${id}`;
10
- // The design-system encoding of a storage key in a CSS variable name (`.` -> `_2e_`).
10
+ // The components encoding of a storage key in a CSS variable name (`.` -> `_2e_`).
11
11
  const encode = (key) => key.replace(/[^A-Za-z0-9-]/g, (c) => `_${(c.codePointAt(0) ?? 0).toString(16)}_`);
12
12
  export const splitVar = (app, id) => `--split-${encode(splitKey(app, id))}`;
13
13
  // Runs in the page head before any module: every stored `ag.split.{app}.{id}` (size and collapsed)
14
- // is registered by its key pattern and set as the design-system split variables, so the first
14
+ // is registered by its key pattern and set as the components split variables, so the first
15
15
  // paint is final. A test holds the names equal to resizableSplitVar and resizableSplitCollapsedVar.
16
16
  export const SPLIT_PREPAINT = `try{var d=document.documentElement,L=localStorage,E=function(k){return k.replace(/[^A-Za-z0-9-]/g,function(c){return '_'+c.charCodeAt(0).toString(16)+'_'})};for(var i=0;i<L.length;i++){var k=L.key(i),m=/^ag\\.split\\.[a-z0-9-]+\\.[a-z0-9-]+$/.test(k),n=parseInt(L.getItem(k),10);if(m&&n>0&&n<8000)d.style.setProperty('--split-'+E(k),n+'px');if(m&&L.getItem(k+'.collapsed')==='1')d.style.setProperty('--splitc-'+E(k),'0px')}}catch(e){}`;
17
17
  const usePhone = () => {
@@ -25,7 +25,7 @@ const usePhone = () => {
25
25
  }, []);
26
26
  return phone;
27
27
  };
28
- // Two panes of an app on the design-system ResizableSplit (px, pre-paint, collapsible).
28
+ // Two panes of an app on the components ResizableSplit (px, pre-paint, collapsible).
29
29
  export const Split = ({ id, pane = 1, children, ...rest }) => {
30
30
  const { id: app } = useAppContext();
31
31
  if (!NAME.test(id))
@@ -1,4 +1,4 @@
1
- /* K11: the shell-samples/index.html hex values under the design-system token names, dark only. */
1
+ /* K11: the shell-samples/index.html hex values under the @agentage/components token names, dark only. */
2
2
  @theme {
3
3
  --color-background: #1f2028;
4
4
  --color-foreground: #ffffff;
@@ -22,8 +22,16 @@
22
22
  --color-muted-foreground: #a9adc1;
23
23
  --color-destructive: #f08a7e;
24
24
  --color-destructive-foreground: #1f2028;
25
+ --color-destructive-solid: oklch(0.588 0.208 25.6);
25
26
  --color-success: #5fd08f;
26
27
  --color-success-foreground: #1f2028;
28
+ /* 4.9:1 on the kit accent; the library dark warning is 3.8:1 there. */
29
+ --color-warning: oklch(0.77 0.16 50);
30
+ --color-warning-foreground: oklch(0.085 0.013 277);
31
+ /* The prototype blue: the library dark info is 3.6:1 on the kit card. */
32
+ --color-info: #8fa8ff;
33
+ --color-info-foreground: #1f2028;
34
+ --color-status-offline: oklch(0.7 0.014 256);
27
35
  --color-border: #3a3d4a;
28
36
  --color-input: #3a3d4a;
29
37
  --color-ring: #f5a623;
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@agentage/extension",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "The agentage extension kit: create(ctx) per part (pages, ui, api, mcp, worker, cli), the store, /health, discovery, the envelope, and the build tool with up and token",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/agentage/platform.git",
9
+ "url": "git+https://github.com/agentage/kit.git",
10
10
  "directory": "packages/extension"
11
11
  },
12
12
  "homepage": "https://agentage.io",
13
13
  "bugs": {
14
- "url": "https://github.com/agentage/platform/issues"
14
+ "url": "https://github.com/agentage/kit/issues"
15
15
  },
16
16
  "publishConfig": {
17
17
  "access": "public"
@@ -86,7 +86,7 @@
86
86
  "zod": "^4.2.0"
87
87
  },
88
88
  "peerDependencies": {
89
- "@agentage/design-system": "^0.20",
89
+ "@agentage/components": "^0.21",
90
90
  "@electric-sql/pglite": "^0.5.0",
91
91
  "@tailwindcss/postcss": "^4.3.0",
92
92
  "esbuild": ">=0.25.0",
@@ -97,7 +97,7 @@
97
97
  "tailwindcss": "^4.3.0"
98
98
  },
99
99
  "peerDependenciesMeta": {
100
- "@agentage/design-system": {
100
+ "@agentage/components": {
101
101
  "optional": true
102
102
  },
103
103
  "@electric-sql/pglite": {