@agentage/extension 0.13.0 → 0.15.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 +3 -1
- package/dist/discovery/discovery.d.ts +1 -0
- package/dist/discovery/discovery.schema.d.ts +2 -0
- package/dist/discovery/discovery.schema.js +22 -10
- package/dist/health/health.d.ts +2 -0
- package/dist/health/health.js +4 -2
- package/dist/health/health.schema.d.ts +9 -0
- package/dist/health/health.schema.js +3 -0
- package/dist/host/clock-rate.d.ts +1 -0
- package/dist/host/clock-rate.js +12 -0
- package/dist/host/daemon/add.d.ts +9 -0
- package/dist/host/daemon/add.js +84 -0
- package/dist/host/daemon/child-files.d.ts +20 -0
- package/dist/host/daemon/child-files.js +45 -0
- package/dist/host/daemon/child.d.ts +12 -4
- package/dist/host/daemon/child.js +78 -44
- package/dist/host/daemon/daemon-files.d.ts +6 -5
- package/dist/host/daemon/daemon-files.js +20 -12
- package/dist/host/daemon/daemon-owner.d.ts +1 -0
- package/dist/host/daemon/daemon-owner.js +32 -0
- package/dist/host/daemon/daemon.d.ts +3 -3
- package/dist/host/daemon/daemon.js +72 -35
- package/dist/host/daemon/entries.d.ts +21 -0
- package/dist/host/daemon/entries.js +24 -0
- package/dist/host/daemon/gate.d.ts +3 -0
- package/dist/host/daemon/gate.js +19 -0
- package/dist/host/daemon/guard.d.ts +2 -1
- package/dist/host/daemon/guard.js +17 -4
- package/dist/host/daemon/health-routes.d.ts +17 -0
- package/dist/host/daemon/health-routes.js +61 -0
- package/dist/host/daemon/host-token.d.ts +6 -0
- package/dist/host/daemon/host-token.js +28 -0
- package/dist/host/daemon/installation.d.ts +17 -4
- package/dist/host/daemon/installation.js +52 -8
- package/dist/host/daemon/installer-call.d.ts +16 -2
- package/dist/host/daemon/installer-call.js +33 -7
- package/dist/host/daemon/json-file.d.ts +3 -2
- package/dist/host/daemon/json-file.js +21 -10
- package/dist/host/daemon/lane.d.ts +1 -3
- package/dist/host/daemon/lane.js +4 -9
- package/dist/host/daemon/last-words.d.ts +2 -0
- package/dist/host/daemon/last-words.js +28 -0
- package/dist/host/daemon/limits.d.ts +15 -0
- package/dist/host/daemon/limits.js +29 -0
- package/dist/host/daemon/ops.d.ts +2 -26
- package/dist/host/daemon/ops.js +46 -103
- package/dist/host/daemon/patch-values.d.ts +6 -0
- package/dist/host/daemon/patch-values.js +39 -0
- package/dist/host/daemon/pending.d.ts +15 -0
- package/dist/host/daemon/pending.js +18 -0
- package/dist/host/daemon/proxy.d.ts +3 -2
- package/dist/host/daemon/proxy.js +54 -24
- package/dist/host/daemon/queue.d.ts +1 -0
- package/dist/host/daemon/queue.js +19 -0
- package/dist/host/daemon/reload-marker.d.ts +8 -0
- package/dist/host/daemon/reload-marker.js +56 -0
- package/dist/host/daemon/reload-route.d.ts +4 -0
- package/dist/host/daemon/reload-route.js +21 -0
- package/dist/host/daemon/reload.d.ts +10 -0
- package/dist/host/daemon/reload.js +73 -0
- package/dist/host/daemon/restart.d.ts +14 -0
- package/dist/host/daemon/restart.js +59 -0
- package/dist/host/daemon/routes.d.ts +3 -9
- package/dist/host/daemon/routes.js +54 -22
- package/dist/host/daemon/run-lock.d.ts +1 -0
- package/dist/host/daemon/run-lock.js +15 -0
- package/dist/host/daemon/seal-reach.d.ts +2 -0
- package/dist/host/daemon/seal-reach.js +38 -0
- package/dist/host/daemon/seal.d.ts +16 -0
- package/dist/host/daemon/seal.js +71 -0
- package/dist/host/daemon/start-checks.d.ts +6 -0
- package/dist/host/daemon/start-checks.js +28 -0
- package/dist/host/daemon/stopping.d.ts +10 -0
- package/dist/host/daemon/stopping.js +28 -0
- package/dist/host/daemon/supervisor.d.ts +19 -11
- package/dist/host/daemon/supervisor.js +39 -47
- package/dist/host/daemon/write-all.d.ts +8 -0
- package/dist/host/daemon/write-all.js +45 -0
- package/dist/host/data-lock.d.ts +3 -1
- package/dist/host/data-lock.js +88 -29
- package/dist/host/host-env.d.ts +3 -1
- package/dist/host/host-env.js +10 -2
- package/dist/host/host-extension.d.ts +8 -0
- package/dist/host/host-extension.js +30 -45
- package/dist/host/host-parts.d.ts +25 -0
- package/dist/host/host-parts.js +75 -0
- package/dist/host/host-store.d.ts +11 -1
- package/dist/host/host-store.js +45 -12
- package/dist/host/index.d.ts +4 -0
- package/dist/host/index.js +4 -0
- package/dist/host/main.js +2 -0
- package/dist/host/part-checks.d.ts +2 -0
- package/dist/host/part-checks.js +19 -0
- package/dist/host/serve-host.d.ts +2 -1
- package/dist/host/serve-host.js +16 -10
- package/dist/manifest/parts.d.ts +3 -0
- package/dist/manifest/parts.js +3 -0
- package/dist/mcp/mcp-app.d.ts +4 -0
- package/dist/mcp/mcp-app.js +11 -11
- package/dist/runtime/part-mounts.d.ts +29 -0
- package/dist/runtime/part-mounts.js +52 -0
- package/dist/runtime/part-runners.d.ts +2 -15
- package/dist/runtime/part-runners.js +13 -58
- package/dist/server/app.d.ts +5 -1
- package/dist/server/app.js +17 -17
- package/dist/server/serve.d.ts +3 -0
- package/dist/server/serve.js +9 -4
- package/dist/tool/build.d.ts +3 -0
- package/dist/tool/build.js +42 -27
- package/dist/tool/capabilities.d.ts +1 -0
- package/dist/tool/capabilities.js +8 -0
- package/dist/tool/check.d.ts +2 -0
- package/dist/tool/check.js +23 -8
- package/dist/tool/container-parts.d.ts +7 -0
- package/dist/tool/container-parts.js +10 -0
- package/dist/tool/container-recipe.d.ts +4 -0
- package/dist/tool/container-recipe.js +55 -0
- package/dist/tool/container-stage.d.ts +3 -0
- package/dist/tool/container-stage.js +51 -0
- package/dist/tool/container.d.ts +73 -0
- package/dist/tool/container.js +28 -0
- package/dist/tool/docker.d.ts +5 -0
- package/dist/tool/docker.js +15 -0
- package/dist/tool/format.js +23 -9
- package/dist/tool/index.d.ts +2 -0
- package/dist/tool/index.js +2 -0
- package/dist/tool/kit-version.d.ts +3 -0
- package/dist/tool/kit-version.js +28 -2
- package/dist/tool/labels.d.ts +1 -1
- package/dist/tool/labels.js +4 -2
- package/dist/tool/main.js +10 -1
- package/dist/tool/stage.d.ts +1 -0
- package/dist/tool/stage.js +1 -1
- package/dist/tool/up/local-record.d.ts +1 -0
- package/dist/worker/clock.d.ts +6 -0
- package/dist/worker/clock.js +21 -0
- package/dist/worker/scheduler.d.ts +1 -0
- package/dist/worker/scheduler.js +6 -2
- package/package.json +1 -1
- package/schemas/extension-discovery.schema.json +8 -1
- package/schemas/extension-record.schema.json +8 -1
- package/schemas/health.schema.json +17 -0
- package/dist/host/daemon/secret-names.d.ts +0 -1
- package/dist/host/daemon/secret-names.js +0 -14
- package/dist/host/daemon/setting-values.d.ts +0 -1
- package/dist/host/daemon/setting-values.js +0 -26
package/dist/tool/format.js
CHANGED
|
@@ -3,28 +3,42 @@ import {} from './build.js';
|
|
|
3
3
|
import {} from './check.js';
|
|
4
4
|
import { plural } from './up/lines.js';
|
|
5
5
|
const shortDigest = (digest) => digest.slice(0, 'sha256:'.length + 8);
|
|
6
|
-
|
|
6
|
+
const rowsOf = ({ images, container }) => [
|
|
7
|
+
...images.map(({ part, tag, digest }) => ({ label: part, tag, digest })),
|
|
8
|
+
...(container ? [{ label: 'image', ...container }] : []),
|
|
9
|
+
];
|
|
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.
|
|
7
17
|
export const buildLines = (result, cwd = process.cwd()) => {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
const rows = rowsOf(result);
|
|
19
|
+
const width = Math.max(...rows.map((row) => row.tag.length)) + 2;
|
|
20
|
+
const lines = rows.map((row) => {
|
|
21
|
+
const state = row.digest ? `${shortDigest(row.digest)} pushed` : 'built';
|
|
22
|
+
return `${row.label.padEnd(8)}${row.tag.padEnd(width)}${state}`;
|
|
12
23
|
});
|
|
24
|
+
lines.push(...partsLine(result));
|
|
13
25
|
if (result.recordFile)
|
|
14
26
|
lines.push(`${'record'.padEnd(8)}${relative(cwd, result.recordFile)}`);
|
|
15
27
|
return lines;
|
|
16
28
|
};
|
|
17
29
|
const where = ({ file, line }) => file ? `${file}${line ? `:${line}` : ''} ` : '';
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
const lineOf = (found) => `${found.rule}: ${where(found)}${found.problem}`;
|
|
31
|
+
export const problemLines = (report) => report.problems.map(lineOf);
|
|
32
|
+
const warningLines = ({ warnings = [] }) => warnings.map((found) => `warning ${lineOf(found)}`);
|
|
33
|
+
// What `agentage extension check` prints (sheet C2): the rules line and PASS, or each problem and FAIL; warnings first.
|
|
20
34
|
export const checkLines = (report) => {
|
|
21
35
|
const { rules, skipped, problems } = report;
|
|
22
36
|
if (report.conforms) {
|
|
23
37
|
const states = rules.map((name) => `${name} ${skipped[name] ? `skipped: ${skipped[name]}` : 'ok'}`);
|
|
24
38
|
const pass = `PASS ${report.id} ${report.version} conforms (${plural(rules.length, 'rule')})`;
|
|
25
|
-
return [states.join(' · '), pass];
|
|
39
|
+
return [states.join(' · '), ...warningLines(report), pass];
|
|
26
40
|
}
|
|
27
41
|
const failed = new Set(problems.map((found) => found.rule)).size;
|
|
28
42
|
const fail = `FAIL ${plural(problems.length, 'problem')} in ${plural(failed, 'rule')}`;
|
|
29
|
-
return [...problemLines(report), fail];
|
|
43
|
+
return [...warningLines(report), ...problemLines(report), fail];
|
|
30
44
|
};
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { SERVED_KINDS, STORE_KINDS, type StoreKind } from '../manifest/primitive
|
|
|
6
6
|
export { readManifest, validateManifest } from '../manifest/read-manifest.js';
|
|
7
7
|
export { canonical, mcpSnapshot, PROTOCOL_VERSIONS, type McpSnapshot, type ProtocolVersion, } from '../mcp/snapshot.js';
|
|
8
8
|
export { build, type BuildDeps, type BuildOptions, type BuildResult, type BuiltImage, } from './build.js';
|
|
9
|
+
export { type BuiltContainer } from './container.js';
|
|
10
|
+
export { capabilities } from './capabilities.js';
|
|
9
11
|
export { check, type CheckProblem, type CheckReport } from './check.js';
|
|
10
12
|
export { writeContracts } from './contracts.js';
|
|
11
13
|
export { buildLines, checkLines } from './format.js';
|
package/dist/tool/index.js
CHANGED
|
@@ -6,6 +6,8 @@ export { SERVED_KINDS, STORE_KINDS } from '../manifest/primitives.schema.js';
|
|
|
6
6
|
export { readManifest, validateManifest } from '../manifest/read-manifest.js';
|
|
7
7
|
export { canonical, mcpSnapshot, PROTOCOL_VERSIONS, } from '../mcp/snapshot.js';
|
|
8
8
|
export { build, } from './build.js';
|
|
9
|
+
export {} from './container.js';
|
|
10
|
+
export { capabilities } from './capabilities.js';
|
|
9
11
|
export { check } from './check.js';
|
|
10
12
|
export { writeContracts } from './contracts.js';
|
|
11
13
|
export { buildLines, checkLines } from './format.js';
|
package/dist/tool/kit-version.js
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
const KIT_DIR = fileURLToPath(new URL('../..', import.meta.url));
|
|
6
|
+
const readJson = (file) => JSON.parse(readFileSync(file, 'utf8'));
|
|
2
7
|
// The kit's own version: what a kit-shaped manifest's engines.agentage ranges over.
|
|
3
|
-
export const KIT_VERSION =
|
|
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
|
+
};
|
|
20
|
+
// The PGlite copy the kit resolves (node_modules up from the kit folder): an exact version, or none.
|
|
21
|
+
export const kitPgliteVersion = (from = KIT_DIR) => {
|
|
22
|
+
for (let dir = from;; dir = dirname(dir)) {
|
|
23
|
+
const file = join(dir, 'node_modules', '@electric-sql', 'pglite', 'package.json');
|
|
24
|
+
if (existsSync(file))
|
|
25
|
+
return readJson(file).version;
|
|
26
|
+
if (dirname(dir) === dir)
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
};
|
package/dist/tool/labels.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type BuildInfo } from '../discovery/discovery.js';
|
|
2
2
|
import { type ExtensionPackage } from '../manifest/manifest.schema.js';
|
|
3
3
|
import { type ImagePartKind } from '../manifest/primitives.schema.js';
|
|
4
|
-
export declare const labelsOf: (pkg: ExtensionPackage, part: ImagePartKind, build: BuildInfo) => Record<string, string>;
|
|
4
|
+
export declare const labelsOf: (pkg: ExtensionPackage, part: ImagePartKind | undefined, build: BuildInfo) => Record<string, string>;
|
package/dist/tool/labels.js
CHANGED
|
@@ -9,15 +9,17 @@ const repositoryUrl = (pkg) => {
|
|
|
9
9
|
return url.replace(/^git\+/, '').replace(/\.git$/, '');
|
|
10
10
|
};
|
|
11
11
|
// OCI labels: revision is the full sha, created the build time; source links the GHCR package.
|
|
12
|
+
// No part: the one image, titled {id} with no io.agentage.part.
|
|
12
13
|
export const labelsOf = (pkg, part, build) => {
|
|
13
14
|
const labels = {
|
|
14
15
|
'org.opencontainers.image.revision': build.commit,
|
|
15
16
|
'org.opencontainers.image.created': build.buildTime,
|
|
16
17
|
'org.opencontainers.image.version': pkg.version,
|
|
17
|
-
'org.opencontainers.image.title': `${pkg.agentage.id}-${part}
|
|
18
|
+
'org.opencontainers.image.title': part ? `${pkg.agentage.id}-${part}` : pkg.agentage.id,
|
|
18
19
|
'io.agentage.extension': pkg.agentage.id,
|
|
19
|
-
'io.agentage.part': part,
|
|
20
20
|
};
|
|
21
|
+
if (part)
|
|
22
|
+
labels['io.agentage.part'] = part;
|
|
21
23
|
const source = repositoryUrl(pkg);
|
|
22
24
|
if (source)
|
|
23
25
|
labels['org.opencontainers.image.source'] = source;
|
package/dist/tool/main.js
CHANGED
|
@@ -10,6 +10,9 @@ const USAGE = `usage: agentage-extension <build|up|down|token> [options]
|
|
|
10
10
|
|
|
11
11
|
build one image per part from the kit recipe
|
|
12
12
|
--push push the images and write dist/agentage-extension.json with their digests
|
|
13
|
+
--container one image, ghcr.io/agentage/<id>:<version>, that runs the api part; it
|
|
14
|
+
lists the parts it does not run yet; with --push the record is
|
|
15
|
+
dist/agentage-container.json
|
|
13
16
|
--registry image registry and owner (default: ghcr.io/agentage)
|
|
14
17
|
up the release images on Docker: store, dev issuer, gateway on localhost:4280
|
|
15
18
|
down remove what up started; --keep-data keeps the store volume
|
|
@@ -25,6 +28,7 @@ const defaultDeps = {
|
|
|
25
28
|
};
|
|
26
29
|
const OPTIONS = {
|
|
27
30
|
push: { type: 'boolean' },
|
|
31
|
+
container: { type: 'boolean' },
|
|
28
32
|
dir: { type: 'string' },
|
|
29
33
|
registry: { type: 'string' },
|
|
30
34
|
'keep-data': { type: 'boolean' },
|
|
@@ -35,7 +39,12 @@ const OPTIONS = {
|
|
|
35
39
|
const parse = (argv) => parseArgs({ args: argv, allowPositionals: true, options: OPTIONS });
|
|
36
40
|
const COMMANDS = {
|
|
37
41
|
build: async (v, deps) => {
|
|
38
|
-
for (const line of buildLines(await deps.build({
|
|
42
|
+
for (const line of buildLines(await deps.build({
|
|
43
|
+
push: v.push,
|
|
44
|
+
container: v.container,
|
|
45
|
+
dir: v.dir,
|
|
46
|
+
registry: v.registry,
|
|
47
|
+
})))
|
|
39
48
|
deps.out(line);
|
|
40
49
|
},
|
|
41
50
|
up: async (v, deps) => void (await deps.up({ dir: v.dir, onLine: deps.out })),
|
package/dist/tool/stage.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const RECORD_FILE = "agentage-extension.json";
|
|
|
4
4
|
export declare const MIGRATE_SHIM = "// Generated by @agentage/extension build.\nimport '@agentage/extension/migrate';\n";
|
|
5
5
|
export declare const localTarballs: (pkg: ExtensionPackage) => string[];
|
|
6
6
|
export declare const exists: (path: string) => Promise<boolean>;
|
|
7
|
+
export declare const copyDeps: (dir: string, root: string, pkg: ExtensionPackage) => Promise<void>;
|
|
7
8
|
export declare const appPaths: (dir: string, pkg: ExtensionPackage, part: ImagePartKind) => Promise<string[]>;
|
|
8
9
|
export declare const assertBuilt: (dir: string, pkg: ExtensionPackage, part: ImagePartKind) => Promise<void>;
|
|
9
10
|
export declare const stageContext: (dir: string, pkg: ExtensionPackage, part: ImagePartKind, tmpRoot?: string) => Promise<string>;
|
package/dist/tool/stage.js
CHANGED
|
@@ -30,7 +30,7 @@ const copyInto = async (from, to) => {
|
|
|
30
30
|
await mkdir(dirname(to), { recursive: true });
|
|
31
31
|
await cp(from, to, { recursive: true });
|
|
32
32
|
};
|
|
33
|
-
const copyDeps = async (dir, root, pkg) => {
|
|
33
|
+
export const copyDeps = async (dir, root, pkg) => {
|
|
34
34
|
if (!(await exists(join(dir, 'package-lock.json')))) {
|
|
35
35
|
throw new Error('package-lock.json is missing: the image installs with npm ci');
|
|
36
36
|
}
|
|
@@ -34,6 +34,7 @@ export declare const writeLocalRecord: (dir: string, pkg: ExtensionPackage, buil
|
|
|
34
34
|
};
|
|
35
35
|
secrets?: string[] | undefined;
|
|
36
36
|
secretParts?: Record<string, ("pages" | "api" | "mcp" | "worker")[]> | undefined;
|
|
37
|
+
image?: string | undefined;
|
|
37
38
|
openapi?: string | undefined;
|
|
38
39
|
tools?: {
|
|
39
40
|
name: string;
|
|
@@ -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
|
+
};
|
package/dist/worker/scheduler.js
CHANGED
|
@@ -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
|
|
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 ?? (
|
|
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.
|
|
3
|
+
"version": "0.15.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",
|
|
@@ -121,9 +121,16 @@
|
|
|
121
121
|
},
|
|
122
122
|
"additionalProperties": false
|
|
123
123
|
},
|
|
124
|
+
"image": {
|
|
125
|
+
"description": "The one image (build --container). A record has part images or this image: never both, never none.",
|
|
126
|
+
"type": "string",
|
|
127
|
+
"maxLength": 256,
|
|
128
|
+
"pattern": "^[a-z0-9][a-z0-9.-]*(:[0-9]{1,5})?(\\/[a-z0-9][a-z0-9_.-]*)+\\/[a-z][a-z0-9-]*@sha256:[0-9a-f]{64}$"
|
|
129
|
+
},
|
|
124
130
|
"openapi": {
|
|
125
131
|
"type": "string",
|
|
126
|
-
"pattern": "^\\/api\\/(?:v[0-9]+|[a-z][a-z0-9-]*)\\/openapi\\.json$"
|
|
132
|
+
"pattern": "^\\/api\\/(?:v[0-9]+|[a-z][a-z0-9-]*)\\/openapi\\.json$",
|
|
133
|
+
"description": "/api/{id}/openapi.json, or the old /api/v{N}; only the kit checks that {id} is the id"
|
|
127
134
|
},
|
|
128
135
|
"tools": {
|
|
129
136
|
"minItems": 1,
|
|
@@ -121,9 +121,16 @@
|
|
|
121
121
|
},
|
|
122
122
|
"additionalProperties": false
|
|
123
123
|
},
|
|
124
|
+
"image": {
|
|
125
|
+
"description": "The one image (build --container). A record has part images or this image: never both, never none.",
|
|
126
|
+
"type": "string",
|
|
127
|
+
"maxLength": 256,
|
|
128
|
+
"pattern": "^[a-z0-9][a-z0-9.-]*(:[0-9]{1,5})?(\\/[a-z0-9][a-z0-9_.-]*)+\\/[a-z][a-z0-9-]*@sha256:[0-9a-f]{64}$"
|
|
129
|
+
},
|
|
124
130
|
"openapi": {
|
|
125
131
|
"type": "string",
|
|
126
|
-
"pattern": "^\\/api\\/(?:v[0-9]+|[a-z][a-z0-9-]*)\\/openapi\\.json$"
|
|
132
|
+
"pattern": "^\\/api\\/(?:v[0-9]+|[a-z][a-z0-9-]*)\\/openapi\\.json$",
|
|
133
|
+
"description": "/api/{id}/openapi.json, or the old /api/v{N}; only the kit checks that {id} is the id"
|
|
127
134
|
},
|
|
128
135
|
"tools": {
|
|
129
136
|
"minItems": 1,
|
|
@@ -34,6 +34,20 @@
|
|
|
34
34
|
"store"
|
|
35
35
|
]
|
|
36
36
|
},
|
|
37
|
+
"parts": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"enum": [
|
|
42
|
+
"pages",
|
|
43
|
+
"ui",
|
|
44
|
+
"api",
|
|
45
|
+
"mcp",
|
|
46
|
+
"worker",
|
|
47
|
+
"store"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
},
|
|
37
51
|
"version": {
|
|
38
52
|
"type": "string",
|
|
39
53
|
"pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
|
|
@@ -47,6 +61,9 @@
|
|
|
47
61
|
"format": "date-time",
|
|
48
62
|
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
|
49
63
|
},
|
|
64
|
+
"clockRate": {
|
|
65
|
+
"type": "number"
|
|
66
|
+
},
|
|
50
67
|
"instance": {
|
|
51
68
|
"type": "string",
|
|
52
69
|
"pattern": "^[0-9a-f]{8,32}$"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const checkSecrets: (dir: string | undefined, names: string[], id: string) => Promise<void>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { fail } from '../../envelope/envelope.js';
|
|
2
|
-
import { readManifest } from '../../manifest/read-manifest.js';
|
|
3
|
-
const declared = (secrets = []) => secrets.map((s) => (typeof s === 'string' ? s : s.name));
|
|
4
|
-
// Only a secret the package declares: the name becomes a file name in the child's folder.
|
|
5
|
-
export const checkSecrets = async (dir, names, id) => {
|
|
6
|
-
if (!names.length)
|
|
7
|
-
return;
|
|
8
|
-
if (!dir)
|
|
9
|
-
throw fail('VALIDATION_ERROR', `${id} has no package yet: install it first`);
|
|
10
|
-
const known = declared((await readManifest(dir)).agentage.secrets);
|
|
11
|
-
const unknown = names.filter((name) => !known.includes(name));
|
|
12
|
-
if (unknown.length)
|
|
13
|
-
throw fail('VALIDATION_ERROR', `${id} declares no secret ${unknown.join(', ')}`);
|
|
14
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const coerceSettings: (dir: string | undefined, given: Record<string, unknown>, id: string) => Promise<Record<string, unknown>>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { fits } from '../../context/settings.js';
|
|
2
|
-
import { fail } from '../../envelope/envelope.js';
|
|
3
|
-
import { readManifest } from '../../manifest/read-manifest.js';
|
|
4
|
-
const PARSE = {
|
|
5
|
-
number: (t) => (/^-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i.test(t) ? Number(t) : t),
|
|
6
|
-
integer: (t) => (/^-?\d+$/.test(t) ? Number(t) : t),
|
|
7
|
-
boolean: (t) => (t === 'true' ? true : t === 'false' ? false : t),
|
|
8
|
-
};
|
|
9
|
-
const refused = (key, message) => fail('VALIDATION_ERROR', `setting ${key}: ${message}`, { code: 'INVALID_SETTING' });
|
|
10
|
-
const valueOf = (key, setting, given) => {
|
|
11
|
-
if (!setting)
|
|
12
|
-
throw refused(key, 'not declared in the manifest');
|
|
13
|
-
const value = typeof given === 'string' ? (PARSE[setting.type]?.(given) ?? given) : given;
|
|
14
|
-
if (!fits(setting, value))
|
|
15
|
-
throw refused(key, `${JSON.stringify(given)} is not a valid ${setting.type}`);
|
|
16
|
-
return value;
|
|
17
|
-
};
|
|
18
|
-
// A client sends text (`configure probe limit=5`): a string becomes the type the manifest declares.
|
|
19
|
-
export const coerceSettings = async (dir, given, id) => {
|
|
20
|
-
if (!Object.keys(given).length)
|
|
21
|
-
return given;
|
|
22
|
-
if (!dir)
|
|
23
|
-
throw fail('VALIDATION_ERROR', `${id} has no package yet: install it first`);
|
|
24
|
-
const declared = (await readManifest(dir)).agentage.settings ?? {};
|
|
25
|
-
return Object.fromEntries(Object.entries(given).map(([key, value]) => [key, valueOf(key, declared[key], value)]));
|
|
26
|
-
};
|