@agentage/extension 0.14.0 → 0.15.1

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.
Files changed (105) hide show
  1. package/README.md +3 -1
  2. package/dist/contracts/index.d.ts +1 -1
  3. package/dist/contracts/index.js +1 -1
  4. package/dist/discovery/discovery.d.ts +10 -25
  5. package/dist/discovery/discovery.js +7 -1
  6. package/dist/discovery/discovery.schema.d.ts +45 -0
  7. package/dist/discovery/discovery.schema.js +33 -4
  8. package/dist/discovery/served-extras.d.ts +8 -0
  9. package/dist/discovery/served-extras.js +10 -0
  10. package/dist/health/health.d.ts +2 -0
  11. package/dist/health/health.js +4 -2
  12. package/dist/health/health.schema.d.ts +9 -0
  13. package/dist/health/health.schema.js +3 -0
  14. package/dist/host/clock-rate.d.ts +1 -0
  15. package/dist/host/clock-rate.js +12 -0
  16. package/dist/host/daemon/add.js +29 -4
  17. package/dist/host/daemon/child-files.d.ts +20 -0
  18. package/dist/host/daemon/child-files.js +45 -0
  19. package/dist/host/daemon/child.d.ts +10 -4
  20. package/dist/host/daemon/child.js +68 -43
  21. package/dist/host/daemon/daemon-files.d.ts +3 -0
  22. package/dist/host/daemon/daemon-files.js +5 -1
  23. package/dist/host/daemon/daemon.d.ts +1 -0
  24. package/dist/host/daemon/daemon.js +21 -6
  25. package/dist/host/daemon/gate.d.ts +3 -0
  26. package/dist/host/daemon/gate.js +19 -0
  27. package/dist/host/daemon/guard.d.ts +2 -1
  28. package/dist/host/daemon/guard.js +16 -4
  29. package/dist/host/daemon/health-routes.d.ts +17 -0
  30. package/dist/host/daemon/health-routes.js +61 -0
  31. package/dist/host/daemon/host-token.d.ts +6 -0
  32. package/dist/host/daemon/host-token.js +28 -0
  33. package/dist/host/daemon/last-words.d.ts +2 -0
  34. package/dist/host/daemon/last-words.js +28 -0
  35. package/dist/host/daemon/limits.d.ts +4 -0
  36. package/dist/host/daemon/limits.js +7 -0
  37. package/dist/host/daemon/ops.js +4 -1
  38. package/dist/host/daemon/pending.d.ts +1 -1
  39. package/dist/host/daemon/proxy.d.ts +1 -1
  40. package/dist/host/daemon/proxy.js +16 -8
  41. package/dist/host/daemon/redact-stream.d.ts +4 -0
  42. package/dist/host/daemon/redact-stream.js +24 -0
  43. package/dist/host/daemon/reload-marker.d.ts +8 -0
  44. package/dist/host/daemon/reload-marker.js +56 -0
  45. package/dist/host/daemon/reload-route.d.ts +4 -0
  46. package/dist/host/daemon/reload-route.js +21 -0
  47. package/dist/host/daemon/reload.d.ts +10 -0
  48. package/dist/host/daemon/reload.js +73 -0
  49. package/dist/host/daemon/restart.d.ts +14 -0
  50. package/dist/host/daemon/restart.js +59 -0
  51. package/dist/host/daemon/routes.d.ts +2 -10
  52. package/dist/host/daemon/routes.js +13 -31
  53. package/dist/host/daemon/run-lock.d.ts +1 -0
  54. package/dist/host/daemon/run-lock.js +15 -0
  55. package/dist/host/daemon/seal-reach.d.ts +2 -0
  56. package/dist/host/daemon/seal-reach.js +38 -0
  57. package/dist/host/daemon/seal.d.ts +16 -0
  58. package/dist/host/daemon/seal.js +71 -0
  59. package/dist/host/daemon/start-checks.d.ts +7 -0
  60. package/dist/host/daemon/start-checks.js +29 -0
  61. package/dist/host/daemon/supervisor.d.ts +9 -3
  62. package/dist/host/daemon/supervisor.js +33 -40
  63. package/dist/host/data-lock.d.ts +2 -1
  64. package/dist/host/data-lock.js +25 -6
  65. package/dist/host/host-env.d.ts +1 -0
  66. package/dist/host/host-env.js +2 -0
  67. package/dist/host/host-extension.d.ts +6 -0
  68. package/dist/host/host-extension.js +28 -44
  69. package/dist/host/host-parts.d.ts +25 -0
  70. package/dist/host/host-parts.js +82 -0
  71. package/dist/host/host-store.d.ts +3 -0
  72. package/dist/host/host-store.js +21 -2
  73. package/dist/host/main.js +2 -0
  74. package/dist/host/part-checks.d.ts +2 -0
  75. package/dist/host/part-checks.js +19 -0
  76. package/dist/host/serve-host.js +10 -6
  77. package/dist/manifest/parts.d.ts +3 -0
  78. package/dist/manifest/parts.js +3 -0
  79. package/dist/mcp/mcp-app.d.ts +4 -0
  80. package/dist/mcp/mcp-app.js +11 -11
  81. package/dist/runtime/part-mounts.d.ts +31 -0
  82. package/dist/runtime/part-mounts.js +57 -0
  83. package/dist/runtime/part-runners.d.ts +2 -15
  84. package/dist/runtime/part-runners.js +13 -58
  85. package/dist/server/app.d.ts +5 -3
  86. package/dist/server/app.js +16 -17
  87. package/dist/tool/build.d.ts +1 -0
  88. package/dist/tool/build.js +3 -2
  89. package/dist/tool/check.d.ts +3 -1
  90. package/dist/tool/check.js +25 -9
  91. package/dist/tool/container-parts.d.ts +1 -1
  92. package/dist/tool/container-parts.js +6 -6
  93. package/dist/tool/format.d.ts +1 -0
  94. package/dist/tool/format.js +17 -8
  95. package/dist/tool/kit-version.d.ts +2 -0
  96. package/dist/tool/kit-version.js +12 -0
  97. package/dist/tool/record-extras.js +5 -12
  98. package/dist/worker/clock.d.ts +6 -0
  99. package/dist/worker/clock.js +21 -0
  100. package/dist/worker/scheduler.d.ts +1 -0
  101. package/dist/worker/scheduler.js +6 -2
  102. package/package.json +1 -1
  103. package/schemas/extension-discovery.schema.json +61 -34
  104. package/schemas/extension-record.schema.json +1 -1
  105. package/schemas/health.schema.json +17 -0
@@ -1,47 +1,16 @@
1
1
  import { join } from 'node:path';
2
- import { generatedOpenapi } from '../api/openapi-doc.js';
3
2
  import {} from 'express';
4
- import {} from '../context/context.js';
5
- import {} from '../manifest/manifest.schema.js';
6
- import { loadCreate } from '../manifest/entry.js';
7
- import { hasStore } from '../manifest/parts.js';
8
- import {} from '../manifest/primitives.schema.js';
9
- import { createSpan } from '../log/span.js';
10
- import { createMcpApp } from '../mcp/mcp-app.js';
11
- import { createToolRegistry } from '../mcp/tools.js';
12
3
  import { createPagesApp, platformSources } from '../pages/pages-app.js';
13
4
  import {} from '../pages/pages.js';
14
- import { createApiApp, createPartApp } from '../server/app.js';
15
- import { mountApi } from '../server/api-routes.js';
16
- import {} from './build-info.js';
5
+ import {} from '../manifest/primitives.schema.js';
6
+ import { createPartApp } from '../server/app.js';
17
7
  import { createUiApp } from '../ui/ui-app.js';
18
- import { runLog } from '../worker/run-log.js';
19
- import { memoryRuns, storeRuns } from '../worker/runs.js';
20
- import { createScheduler } from '../worker/scheduler.js';
21
- // ui has no code to run; every other part is its create(ctx).
22
- const callCreate = async (input, part, ctx) => (await loadCreate(input.dir, input.pkg, part, input.importModule))(ctx);
23
- const api = async (input) => {
24
- const ctx = input.ctx();
25
- const { router, routes, documents } = await mountApi(ctx, (api) => callCreate(input, 'api', api));
26
- // Declared routes guard at their own scope, whatever the committed file says.
27
- const openapi = routes.length > 0 ? generatedOpenapi(input.pkg, routes) : input.openapi;
28
- return {
29
- app: createApiApp({
30
- ...input.base,
31
- router,
32
- routes,
33
- openapi,
34
- wellKnown: documents,
35
- aliases: input.apiAliases,
36
- }),
37
- };
38
- };
39
- const mcp = async (input) => {
40
- const registry = createToolRegistry();
41
- const ctx = input.ctx();
42
- await callCreate(input, 'mcp', { ...ctx, tool: registry.tool });
43
- const listing = ctx.settings['mcp.listing'] === 'token' ? 'token' : 'open';
44
- return { app: createMcpApp({ ...input.base, tools: registry.tools, listing }) };
8
+ import { callCreate, MOUNTS } from './part-mounts.js';
9
+ export {} from './part-mounts.js';
10
+ // One part in its own image: the part's mount on the kit app.
11
+ const own = (part) => async (input) => {
12
+ const { mount } = await MOUNTS[part](input);
13
+ return { app: createPartApp({ ...input.base, part, mount }) };
45
14
  };
46
15
  const pages = async (input) => {
47
16
  const site = (await callCreate(input, 'pages', input.ctx()));
@@ -55,27 +24,13 @@ const ui = async (input) => ({
55
24
  }),
56
25
  });
57
26
  const worker = async (input) => {
58
- const ctx = input.ctx();
59
- const log = runLog(ctx.log);
60
- const runs = hasStore(input.pkg, 'postgres') ? storeRuns(ctx.store) : memoryRuns();
61
- const scheduler = createScheduler({ runs, log });
62
- await callCreate(input, 'worker', {
63
- ...ctx,
64
- log,
65
- span: createSpan(log),
66
- schedule: scheduler.schedule,
67
- });
68
- // The same object ctx.health adds to, so a later registration still shows.
69
- const checks = Object.assign(input.base.checks ?? {}, scheduler.checks());
70
- scheduler.start();
71
- return {
72
- app: createPartApp({ ...input.base, checks, part: 'worker', mount: () => undefined }),
73
- stop: scheduler.stop,
74
- };
27
+ const { mount, checks, start, stop } = await MOUNTS.worker(input);
28
+ start?.();
29
+ return { app: createPartApp({ ...input.base, checks, part: 'worker', mount }), stop };
75
30
  };
76
31
  export const RUNNERS = {
77
- api,
78
- mcp,
32
+ api: own('api'),
33
+ mcp: own('mcp'),
79
34
  pages,
80
35
  ui,
81
36
  worker,
@@ -3,8 +3,7 @@ import { type Express, type RequestHandler } from 'express';
3
3
  import { type HelmetOptions } from 'helmet';
4
4
  import { type WellKnownEntry } from '../api/well-known.js';
5
5
  import { type TokenCheck } from '../auth/token-check.js';
6
- import { type BuildInfo } from '../discovery/discovery.js';
7
- import { type ExtensionRecord } from '../discovery/discovery.schema.js';
6
+ import { type BuildInfo, type ServedRecord } from '../discovery/discovery.js';
8
7
  import { type HealthCheck } from '../health/health.js';
9
8
  import { type Log } from '../log/log.js';
10
9
  import { type ExtensionPackage } from '../manifest/manifest.schema.js';
@@ -14,7 +13,7 @@ export interface PartAppBase {
14
13
  pkg: ExtensionPackage;
15
14
  build: BuildInfo;
16
15
  log: Log;
17
- record?: ExtensionRecord | null;
16
+ record?: ServedRecord | null;
18
17
  ownImage?: string;
19
18
  origin?: string;
20
19
  checks?: Record<string, HealthCheck>;
@@ -24,6 +23,8 @@ export interface PartAppBase {
24
23
  instance?: string;
25
24
  startedAt?: number;
26
25
  guards?: RequestHandler[];
26
+ parts?: ImagePartKind[];
27
+ clockRate?: number;
27
28
  }
28
29
  export interface PartAppOptions extends PartAppBase {
29
30
  part: ImagePartKind;
@@ -43,4 +44,5 @@ export interface ApiAppOptions extends PartAppBase {
43
44
  export declare const PUBLIC_CORS: CorsOptions;
44
45
  export declare const BODY_LIMIT = "1mb";
45
46
  export declare const createPartApp: (options: PartAppOptions) => Express;
47
+ export declare const mountApiRoutes: (app: Express, options: ApiAppOptions) => void;
46
48
  export declare const createApiApp: (options: ApiAppOptions) => Express;
@@ -6,7 +6,6 @@ import { agcidMiddleware } from '../agcid/scope.js';
6
6
  import { routeAccess, sameShape } from '../auth/route-access.js';
7
7
  import { setCaller } from '../auth/token-check.js';
8
8
  import { discoveryDocument, recordOf, } from '../discovery/discovery.js';
9
- import {} from '../discovery/discovery.schema.js';
10
9
  import { apiPrefix } from '../discovery/openapi.js';
11
10
  import { createHealthHandler } from '../health/health.js';
12
11
  import {} from '../log/log.js';
@@ -52,6 +51,8 @@ const healthHandler = (options) => createHealthHandler({
52
51
  log: options.log,
53
52
  instance: options.instance,
54
53
  startedAt: options.startedAt,
54
+ parts: options.parts,
55
+ clockRate: options.clockRate,
55
56
  });
56
57
  // The kit app every part image runs: agcid, headers, /health, discovery, the part, the envelope.
57
58
  export const createPartApp = (options) => {
@@ -104,19 +105,17 @@ const routeGuard = (options) => {
104
105
  next();
105
106
  };
106
107
  };
107
- export const createApiApp = (options) => createPartApp({
108
- ...options,
109
- part: 'api',
110
- mount: (app) => {
111
- const prefixes = [apiPrefix(options.pkg.agentage.id), ...(options.aliases ?? [])];
112
- app.use(prefixes, cors(PUBLIC_CORS));
113
- for (const { name, render } of options.wellKnown ?? [])
114
- app.get(`/.well-known/${name}`, wellKnownHandler(render));
115
- const { openapi } = options;
116
- if (openapi)
117
- for (const at of prefixes)
118
- app.get(`${at}/openapi.json`, openapiHandler(openapi));
119
- const json = express.json({ limit: BODY_LIMIT });
120
- app.use(prefixes, routeGuard(options), json, options.router);
121
- },
122
- });
108
+ // The api routes on an app: the part's own (createApiApp) or the host's one app of all parts.
109
+ export const mountApiRoutes = (app, options) => {
110
+ const prefixes = [apiPrefix(options.pkg.agentage.id), ...(options.aliases ?? [])];
111
+ app.use(prefixes, cors(PUBLIC_CORS));
112
+ for (const { name, render } of options.wellKnown ?? [])
113
+ app.get(`/.well-known/${name}`, wellKnownHandler(render));
114
+ const { openapi } = options;
115
+ if (openapi)
116
+ for (const at of prefixes)
117
+ app.get(`${at}/openapi.json`, openapiHandler(openapi));
118
+ const json = express.json({ limit: BODY_LIMIT });
119
+ app.use(prefixes, routeGuard(options), json, options.router);
120
+ };
121
+ export const createApiApp = (options) => createPartApp({ ...options, part: 'api', mount: (app) => mountApiRoutes(app, options) });
@@ -33,6 +33,7 @@ export interface BuildResult {
33
33
  images: BuiltImage[];
34
34
  container?: BuiltContainer;
35
35
  recordFile?: string;
36
+ warnings?: string[];
36
37
  }
37
38
  export declare const imageTag: (registry: string, pkg: ExtensionPackage, part: ImagePartKind) => string;
38
39
  export declare const recordFor: (dir: string, pkg: ExtensionPackage, info: BuildInfo, images: BuiltImage[]) => Promise<ExtensionRecord>;
@@ -83,10 +83,11 @@ export const build = async (options = {}, deps = { run: runCommand }) => {
83
83
  const parts = options.container ? containerParts(pkg) : undefined;
84
84
  const info = await resolveBuildInfo(dir, options.env ?? process.env, deps.run);
85
85
  await compile(dir, pkg, deps.run);
86
- await assertConforms(dir, { run: deps.run });
86
+ const warnings = await assertConforms(dir, { run: deps.run });
87
87
  const base = { dir, pkg, info };
88
88
  const built = parts
89
89
  ? await containerOf(base, parts, options, deps)
90
90
  : await partImages(base, options, deps);
91
- return { id: pkg.agentage.id, version: pkg.version, ...info, ...built };
91
+ const warned = warnings.length > 0 ? { warnings } : {};
92
+ return { id: pkg.agentage.id, version: pkg.version, ...info, ...built, ...warned };
92
93
  };
@@ -14,6 +14,7 @@ export type Finding = {
14
14
  file?: string;
15
15
  line?: number;
16
16
  problem: string;
17
+ warning?: true;
17
18
  };
18
19
  export type CheckProblem = Finding & {
19
20
  rule: string;
@@ -30,9 +31,10 @@ export interface CheckReport {
30
31
  conforms: boolean;
31
32
  rules: string[];
32
33
  problems: CheckProblem[];
34
+ warnings?: CheckProblem[];
33
35
  skipped: Record<string, string>;
34
36
  }
35
37
  export declare const NOT_BUILT = "is missing: build the package first (npm run build)";
36
38
  export declare const RULES: readonly CheckRule[];
37
39
  export declare const check: (at: string, options?: CheckOptions) => Promise<CheckReport>;
38
- export declare const assertConforms: (dir: string, options?: CheckOptions) => Promise<void>;
40
+ export declare const assertConforms: (dir: string, options?: CheckOptions) => Promise<string[]>;
@@ -9,12 +9,12 @@ import { entryOf, normalizeParts } from '../manifest/parts.js';
9
9
  import {} from '../manifest/primitives.schema.js';
10
10
  import { formatIssues, readJsonIfExists } from '../manifest/read-manifest.js';
11
11
  import { runCommand } from './exec.js';
12
- import { problemLines } from './format.js';
12
+ import { problemLines, warningLines } from './format.js';
13
13
  import { exportedPartCode } from './rules/folders.js';
14
14
  import { sealing } from './rules/sealing.js';
15
15
  import { store } from './rules/store.js';
16
16
  import { surface } from './rules/surface.js';
17
- import { KIT_VERSION } from './kit-version.js';
17
+ import { KIT_FLOOR, KIT_VERSION, olderKitMinor } from './kit-version.js';
18
18
  import { assertBuilt, exists } from './stage.js';
19
19
  const RECIPE = /^(?:dockerfile|containerfile)(?:\..+)?$|^(?:docker-)?compose(?:\.[\w-]+)?\.ya?ml$/i;
20
20
  export const NOT_BUILT = 'is missing: build the package first (npm run build)';
@@ -73,6 +73,16 @@ const specProblem = (name, spec, needed) => {
73
73
  return [`${name} ${spec || '""'} needs a version range`];
74
74
  return semver.subset(spec, needed) ? [] : [`${name} ${spec}, needs ${needed}`];
75
75
  };
76
+ // D8: an older minor from the floor up still runs (a warning); below it or above the kit, refused.
77
+ const kitRange = (range) => {
78
+ if (semver.satisfies(KIT_VERSION, range))
79
+ return [];
80
+ const older = olderKitMinor(range);
81
+ if (!older)
82
+ return [{ problem: `kit ${KIT_VERSION} is outside engines.agentage ${range}` }];
83
+ const problem = `engines.agentage ${range} is kit ${older}: kit ${KIT_VERSION} runs it (floor ${KIT_FLOOR}), update the extension`;
84
+ return [{ problem, warning: true }];
85
+ };
76
86
  const stack = {
77
87
  name: 'stack',
78
88
  run: async ({ pkg }) => {
@@ -87,34 +97,39 @@ const stack = {
87
97
  });
88
98
  if ('@modelcontextprotocol/sdk' in deps)
89
99
  found.push('@modelcontextprotocol/sdk is MCP SDK 1: use @modelcontextprotocol/server ^2');
90
- if (!semver.satisfies(KIT_VERSION, range))
91
- found.push(`kit ${KIT_VERSION} is outside engines.agentage ${range}`);
92
- return found.map((problem) => ({ problem }));
100
+ return [...found.map((problem) => ({ problem })), ...kitRange(range)];
93
101
  },
94
102
  };
95
103
  // The closed list of extension-kit section 7, in its order; build runs it before any image.
96
104
  export const RULES = [manifest, entries, surface, stack, store, sealing];
97
105
  // A thrown message names its file relative to the package, as every problem line does.
98
106
  const runRule = (rule, input) => rule.run(input).catch((err) => [{ problem: messageOf(err).replace(`${input.dir}/`, '') }]);
107
+ const split = (found) => {
108
+ const warnings = found.flatMap(({ warning, ...rest }) => (warning ? [rest] : []));
109
+ const problems = found.filter((finding) => !finding.warning);
110
+ return { problems, warned: warnings.length > 0 ? { warnings } : {} };
111
+ };
99
112
  export const check = async (at, options = {}) => {
100
113
  const { rules = RULES, run = runCommand } = options;
101
114
  const dir = resolve(at);
102
115
  const read = readJsonIfExists(join(dir, 'package.json')).catch(() => ({}));
103
116
  const pkg = ((await read) ?? {});
104
- const problems = [];
117
+ const found = [];
105
118
  const skipped = {};
106
119
  for (const rule of rules) {
107
120
  const result = await runRule(rule, { ...options, dir, pkg, run });
108
121
  if ('skipped' in result)
109
122
  skipped[rule.name] = result.skipped;
110
123
  else
111
- problems.push(...result.map((found) => ({ rule: rule.name, ...found })));
112
- if (rule.name === 'manifest' && problems.length > 0)
124
+ found.push(...result.map((finding) => ({ rule: rule.name, ...finding })));
125
+ if (rule.name === 'manifest' && found.length > 0)
113
126
  break;
114
127
  }
128
+ const { problems, warned } = split(found);
115
129
  const names = rules.map((rule) => rule.name);
116
130
  const conforms = problems.length === 0;
117
- return { id: pkg.agentage?.id, version: pkg.version, conforms, rules: names, problems, skipped };
131
+ const { agentage, version } = pkg;
132
+ return { id: agentage?.id, version, conforms, rules: names, problems, ...warned, skipped };
118
133
  };
119
134
  // What build runs after the compile and before any image: any problem stops everything.
120
135
  export const assertConforms = async (dir, options = {}) => {
@@ -122,4 +137,5 @@ export const assertConforms = async (dir, options = {}) => {
122
137
  const lines = problemLines(report).map((line) => `check failed: ${line}`);
123
138
  if (!report.conforms)
124
139
  throw new Error(lines.join('\n'));
140
+ return warningLines(report);
125
141
  };
@@ -3,5 +3,5 @@ export interface ContainerParts {
3
3
  runs: string[];
4
4
  skipped: string[];
5
5
  }
6
- export declare const NO_API = "build --container needs an api part: the one image runs only the api part today";
6
+ export declare const NO_API = "build --container needs an api, mcp or worker part: the one image runs the server parts";
7
7
  export declare const containerParts: (pkg: ExtensionPackage) => ContainerParts;
@@ -1,10 +1,10 @@
1
1
  import {} from '../manifest/manifest.schema.js';
2
- import { imageParts } from '../manifest/parts.js';
3
- export const NO_API = 'build --container needs an api part: the one image runs only the api part today';
4
- // The kit host (host/host-extension.ts) serves the api part; other image parts come later.
2
+ import { hostParts, imageParts } from '../manifest/parts.js';
3
+ export const NO_API = 'build --container needs an api, mcp or worker part: the one image runs the server parts';
4
+ // The kit host (host/host-extension.ts) runs every server part; pages and ui come in phase 2.
5
5
  export const containerParts = (pkg) => {
6
- const parts = imageParts(pkg);
7
- if (!parts.includes('api'))
6
+ const runs = hostParts(pkg);
7
+ if (runs.length === 0)
8
8
  throw new Error(NO_API);
9
- return { runs: ['api'], skipped: parts.filter((kind) => kind !== 'api') };
9
+ return { runs, skipped: imageParts(pkg).filter((kind) => !runs.includes(kind)) };
10
10
  };
@@ -2,4 +2,5 @@ import { type BuildResult } from './build.js';
2
2
  import { type CheckReport } from './check.js';
3
3
  export declare const buildLines: (result: BuildResult, cwd?: string) => string[];
4
4
  export declare const problemLines: (report: CheckReport) => string[];
5
+ export declare const warningLines: ({ warnings }: CheckReport) => string[];
5
6
  export declare const checkLines: (report: CheckReport) => string[];
@@ -5,33 +5,42 @@ import { plural } from './up/lines.js';
5
5
  const shortDigest = (digest) => digest.slice(0, 'sha256:'.length + 8);
6
6
  const rowsOf = ({ images, container }) => [
7
7
  ...images.map(({ part, tag, digest }) => ({ label: part, tag, digest })),
8
- ...(container ? [{ label: container.runs.join(','), ...container }] : []),
8
+ ...(container ? [{ label: 'image', ...container }] : []),
9
9
  ];
10
- const skippedLines = ({ container }) => (container?.skipped ?? []).map((part) => `${part.padEnd(8)}not run by the one image yet`);
11
- // One line per image (the one image under the parts it runs), skipped parts, then the record.
10
+ const partsLine = ({ container }) => {
11
+ if (!container)
12
+ return [];
13
+ const skipped = container.skipped.length > 0 ? container.skipped.join(', ') : 'none';
14
+ return [`runs: ${container.runs.join(', ')}; skipped: ${skipped}`];
15
+ };
16
+ // One line per image (the one image as "image"), the parts it runs and skips, then the record.
12
17
  export const buildLines = (result, cwd = process.cwd()) => {
13
18
  const rows = rowsOf(result);
19
+ const warned = result.warnings ?? [];
14
20
  const width = Math.max(...rows.map((row) => row.tag.length)) + 2;
15
21
  const lines = rows.map((row) => {
16
22
  const state = row.digest ? `${shortDigest(row.digest)} pushed` : 'built';
17
23
  return `${row.label.padEnd(8)}${row.tag.padEnd(width)}${state}`;
18
24
  });
19
- lines.push(...skippedLines(result));
25
+ lines.unshift(...warned);
26
+ lines.push(...partsLine(result));
20
27
  if (result.recordFile)
21
28
  lines.push(`${'record'.padEnd(8)}${relative(cwd, result.recordFile)}`);
22
29
  return lines;
23
30
  };
24
31
  const where = ({ file, line }) => file ? `${file}${line ? `:${line}` : ''} ` : '';
25
- export const problemLines = (report) => report.problems.map((found) => `${found.rule}: ${where(found)}${found.problem}`);
26
- // What `agentage extension check` prints (sheet C2): the rules line and PASS, or each problem and FAIL.
32
+ const lineOf = (found) => `${found.rule}: ${where(found)}${found.problem}`;
33
+ export const problemLines = (report) => report.problems.map(lineOf);
34
+ export const warningLines = ({ warnings = [] }) => warnings.map((found) => `warning ${lineOf(found)}`);
35
+ // What `agentage extension check` prints (sheet C2): the rules line and PASS, or each problem and FAIL; warnings first.
27
36
  export const checkLines = (report) => {
28
37
  const { rules, skipped, problems } = report;
29
38
  if (report.conforms) {
30
39
  const states = rules.map((name) => `${name} ${skipped[name] ? `skipped: ${skipped[name]}` : 'ok'}`);
31
40
  const pass = `PASS ${report.id} ${report.version} conforms (${plural(rules.length, 'rule')})`;
32
- return [states.join(' · '), pass];
41
+ return [states.join(' · '), ...warningLines(report), pass];
33
42
  }
34
43
  const failed = new Set(problems.map((found) => found.rule)).size;
35
44
  const fail = `FAIL ${plural(problems.length, 'problem')} in ${plural(failed, 'rule')}`;
36
- return [...problemLines(report), fail];
45
+ return [...warningLines(report), ...problemLines(report), fail];
37
46
  };
@@ -1,2 +1,4 @@
1
1
  export declare const KIT_VERSION: string;
2
+ export declare const KIT_FLOOR = "0.12";
3
+ export declare const olderKitMinor: (range: string, kit?: string) => string | undefined;
2
4
  export declare const kitPgliteVersion: (from?: string) => string | undefined;
@@ -1,10 +1,22 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
+ import semver from 'semver';
4
5
  const KIT_DIR = fileURLToPath(new URL('../..', import.meta.url));
5
6
  const readJson = (file) => JSON.parse(readFileSync(file, 'utf8'));
6
7
  // The kit's own version: what a kit-shaped manifest's engines.agentage ranges over.
7
8
  export const KIT_VERSION = readJson(join(KIT_DIR, 'package.json')).version;
9
+ // D8 (C10): the oldest kit minor the host runs, as the cli KIT_FLOOR; moves only with a breaking ctx change.
10
+ export const KIT_FLOOR = '0.12';
11
+ // The older minor (from the floor up to below the kit) that range names, or undefined.
12
+ export const olderKitMinor = (range, kit = KIT_VERSION) => {
13
+ const [major, minor = 0] = kit.split('.').map(Number);
14
+ const [floorMajor, floor = 0] = KIT_FLOOR.split('.').map(Number);
15
+ if (major !== floorMajor)
16
+ return undefined;
17
+ const minors = Array.from({ length: Math.max(0, minor - floor) }, (_, i) => `${major}.${floor + i}`);
18
+ return minors.find((older) => semver.intersects(range, `~${older}.0`));
19
+ };
8
20
  // The PGlite copy the kit resolves (node_modules up from the kit folder): an exact version, or none.
9
21
  export const kitPgliteVersion = (from = KIT_DIR) => {
10
22
  for (let dir = from;; dir = dirname(dir)) {
@@ -1,18 +1,17 @@
1
1
  import { join } from 'node:path';
2
2
  import { z } from 'zod';
3
3
  import { createRouteRegistry } from '../api/routes.js';
4
- import { scopeOf } from '../auth/token-check.js';
5
4
  import { createContext } from '../context/context.js';
6
5
  import {} from '../discovery/discovery.js';
7
6
  import { WidgetSchema } from '../discovery/discovery.schema.js';
8
7
  import { openapiPath, readOpenapi } from '../discovery/openapi.js';
8
+ import { migrationsOf, toolRecords } from '../discovery/served-extras.js';
9
9
  import { createLog } from '../log/log.js';
10
10
  import { loadCreate } from '../manifest/entry.js';
11
11
  import { readJsonIfExists } from '../manifest/read-manifest.js';
12
12
  import {} from '../manifest/manifest.schema.js';
13
- import { migratesStore, normalizeParts } from '../manifest/parts.js';
14
- import { createToolRegistry, prefixed } from '../mcp/tools.js';
15
- import { sqlFiles } from '../store/migrations.js';
13
+ import { normalizeParts } from '../manifest/parts.js';
14
+ import { createToolRegistry } from '../mcp/tools.js';
16
15
  import {} from '../store/store.types.js';
17
16
  const WidgetsSchema = z.array(WidgetSchema).min(1);
18
17
  const noStore = {
@@ -44,11 +43,7 @@ export const registeredRoutes = async (create, pkg) => {
44
43
  };
45
44
  export const toolsOf = async (dir, pkg) => {
46
45
  const tools = await registeredTools(await loadCreate(dir, pkg, 'mcp'), pkg);
47
- const { id } = pkg.agentage;
48
- return tools.map((tool) => ({
49
- name: prefixed(id, tool.name),
50
- scope: scopeOf(id, tool.spec.scope),
51
- }));
46
+ return toolRecords(pkg.agentage.id, tools);
52
47
  };
53
48
  const widgetsOf = async (dir) => {
54
49
  const value = await readJsonIfExists(join(dir, 'dist', 'ui', 'widgets.json'));
@@ -57,7 +52,7 @@ const widgetsOf = async (dir) => {
57
52
  // What the code serves, for the record: tools, widgets and the migration count.
58
53
  export const recordExtras = async (dir, pkg) => {
59
54
  const { code } = normalizeParts(pkg.agentage.parts);
60
- const extras = {};
55
+ const extras = await migrationsOf(dir, pkg);
61
56
  if (code.mcp) {
62
57
  const tools = await toolsOf(dir, pkg);
63
58
  if (tools.length > 0)
@@ -67,7 +62,5 @@ export const recordExtras = async (dir, pkg) => {
67
62
  extras.widgets = await widgetsOf(dir);
68
63
  if (code.api && (await readOpenapi(dir)))
69
64
  extras.openapi = openapiPath(pkg.agentage.id);
70
- if (migratesStore(pkg))
71
- extras.migrations = (await sqlFiles(join(dir, 'migrations'))).length;
72
65
  return extras;
73
66
  };
@@ -0,0 +1,6 @@
1
+ export declare const CLOCK_RATE_ENV = "AGENTAGE_CLOCK_RATE";
2
+ export declare const MAX_CLOCK_RATE = 3600;
3
+ export declare const parseClockRate: (raw: string | number | undefined) => number;
4
+ export declare const setHostClockRate: (rate: number) => void;
5
+ export declare const hostClockRate: () => number;
6
+ export declare const scaledNow: (rate: number) => (() => Date);
@@ -0,0 +1,21 @@
1
+ export const CLOCK_RATE_ENV = 'AGENTAGE_CLOCK_RATE';
2
+ export const MAX_CLOCK_RATE = 3600;
3
+ // The test clock (tests only): it scales run timestamps, job ms, timeoutMs and the late check. A rate of 60 makes one cron minute last one second; a bad value is refused, never ignored.
4
+ export const parseClockRate = (raw) => {
5
+ if (raw === undefined || raw === '')
6
+ return 1;
7
+ const rate = typeof raw === 'number' ? raw : Number(raw);
8
+ if (!Number.isFinite(rate) || rate < 1 || rate > MAX_CLOCK_RATE) {
9
+ throw new Error(`${CLOCK_RATE_ENV} must be a number from 1 to ${MAX_CLOCK_RATE}, got "${raw}"`);
10
+ }
11
+ return rate;
12
+ };
13
+ // Set once by the kit host child; the cloud part runner never sets it, so it stays 1 there.
14
+ let hostRate = 1;
15
+ export const setHostClockRate = (rate) => void (hostRate = rate);
16
+ export const hostClockRate = () => hostRate;
17
+ // Read once at boot; the clock starts at the real time and runs `rate` times faster.
18
+ export const scaledNow = (rate) => {
19
+ const start = Date.now();
20
+ return () => new Date(start + (Date.now() - start) * rate);
21
+ };
@@ -8,6 +8,7 @@ export interface SchedulerDeps {
8
8
  runs: RunStore;
9
9
  log: Log;
10
10
  now?: () => Date;
11
+ clockRate?: number;
11
12
  }
12
13
  export interface Scheduler {
13
14
  schedule: Schedule;
@@ -2,6 +2,7 @@ import { uuidv7 } from '../agcid/agcid.js';
2
2
  import { requestScope } from '../agcid/current.js';
3
3
  import {} from '../health/health.js';
4
4
  import {} from '../log/log.js';
5
+ import { hostClockRate, parseClockRate, scaledNow } from './clock.js';
5
6
  import { nextRun, parseCron } from './cron.js';
6
7
  import { JobNameSchema, JobOptionsSchema, toMs } from './job-options.js';
7
8
  import { withRunBuffer } from './run-log.js';
@@ -10,7 +11,8 @@ import {} from './runs.js';
10
11
  export const LATE_MS = 60_000;
11
12
  const MAX_DELAY = 2 ** 31 - 1;
12
13
  const arm = (s, entry) => {
13
- const delay = Math.min(MAX_DELAY, Math.max(0, entry.nextAt.getTime() - s.now().getTime()));
14
+ const virtual = Math.max(0, entry.nextAt.getTime() - s.now().getTime());
15
+ const delay = Math.min(MAX_DELAY, Math.ceil(virtual / s.rate));
14
16
  entry.timer = setTimeout(() => void fire(s, entry), delay);
15
17
  };
16
18
  const fire = async (s, entry) => {
@@ -101,9 +103,11 @@ const setStarted = (s, started) => {
101
103
  }
102
104
  };
103
105
  export const createScheduler = (deps) => {
106
+ const rate = parseClockRate(deps.clockRate ?? hostClockRate());
104
107
  const s = {
105
108
  deps,
106
- now: deps.now ?? (() => new Date()),
109
+ now: deps.now ?? scaledNow(rate),
110
+ rate,
107
111
  entries: new Map(),
108
112
  started: false,
109
113
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentage/extension",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
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",