@agentage/extension 0.14.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/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.js +24 -3
- 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 +10 -4
- package/dist/host/daemon/child.js +63 -37
- package/dist/host/daemon/daemon-files.d.ts +3 -0
- package/dist/host/daemon/daemon-files.js +5 -1
- package/dist/host/daemon/daemon.d.ts +1 -0
- package/dist/host/daemon/daemon.js +21 -6
- 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 +16 -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/last-words.d.ts +2 -0
- package/dist/host/daemon/last-words.js +28 -0
- package/dist/host/daemon/limits.d.ts +4 -0
- package/dist/host/daemon/limits.js +7 -0
- package/dist/host/daemon/ops.js +4 -1
- package/dist/host/daemon/pending.d.ts +1 -1
- package/dist/host/daemon/proxy.d.ts +1 -1
- package/dist/host/daemon/proxy.js +16 -8
- 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 +2 -10
- package/dist/host/daemon/routes.js +13 -31
- 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/supervisor.d.ts +9 -3
- package/dist/host/daemon/supervisor.js +33 -40
- package/dist/host/data-lock.d.ts +2 -1
- package/dist/host/data-lock.js +25 -6
- package/dist/host/host-env.d.ts +1 -0
- package/dist/host/host-env.js +2 -0
- package/dist/host/host-extension.d.ts +4 -0
- package/dist/host/host-extension.js +23 -43
- package/dist/host/host-parts.d.ts +25 -0
- package/dist/host/host-parts.js +75 -0
- package/dist/host/host-store.d.ts +3 -0
- package/dist/host/host-store.js +21 -2
- 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.js +6 -3
- 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 +3 -0
- package/dist/server/app.js +16 -16
- package/dist/tool/check.d.ts +2 -0
- package/dist/tool/check.js +23 -8
- package/dist/tool/container-parts.d.ts +1 -1
- package/dist/tool/container-parts.js +6 -6
- package/dist/tool/format.js +15 -8
- package/dist/tool/kit-version.d.ts +2 -0
- package/dist/tool/kit-version.js +12 -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/health.schema.json +17 -0
package/dist/tool/kit-version.js
CHANGED
|
@@ -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)) {
|
|
@@ -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",
|
|
@@ -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}$"
|