@agentage/extension 0.15.1 → 0.16.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/dist/host/daemon/add.d.ts +2 -0
- package/dist/host/daemon/add.js +6 -1
- package/dist/host/daemon/child-files.d.ts +2 -2
- package/dist/host/daemon/child-files.js +16 -8
- package/dist/host/daemon/child.d.ts +1 -1
- package/dist/host/daemon/child.js +2 -4
- package/dist/host/daemon/daemon-files.js +18 -3
- package/dist/host/daemon/daemon.js +3 -3
- package/dist/host/daemon/health-routes.d.ts +0 -1
- package/dist/host/daemon/health-routes.js +2 -2
- package/dist/host/daemon/installation.js +2 -4
- package/dist/host/daemon/json-file.d.ts +2 -0
- package/dist/host/daemon/json-file.js +38 -10
- package/dist/host/daemon/ops.js +4 -2
- package/dist/host/daemon/proxy.d.ts +6 -1
- package/dist/host/daemon/proxy.js +13 -4
- package/dist/host/daemon/reload-marker.js +2 -1
- package/dist/host/daemon/reload.js +3 -4
- package/dist/host/daemon/routes.js +9 -5
- package/dist/host/daemon/seal.d.ts +2 -2
- package/dist/host/daemon/seal.js +1 -1
- package/dist/host/daemon/start-checks.d.ts +0 -1
- package/dist/host/daemon/start-checks.js +1 -1
- package/dist/host/daemon/supervisor.d.ts +1 -4
- package/dist/host/daemon/supervisor.js +15 -17
- package/dist/host/host-env.d.ts +1 -0
- package/dist/host/host-env.js +2 -0
- package/dist/host/host-extension.d.ts +2 -0
- package/dist/host/host-extension.js +11 -4
- package/dist/host/host-migrations.d.ts +8 -0
- package/dist/host/host-migrations.js +62 -0
- package/dist/host/host-parts.d.ts +1 -1
- package/dist/host/host-parts.js +2 -2
- package/dist/host/host-url-store.d.ts +21 -0
- package/dist/host/host-url-store.js +62 -0
- package/dist/host/main.js +9 -3
- package/dist/host/serve-host.js +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/manifest/parts.d.ts +2 -1
- package/dist/manifest/parts.js +1 -1
- package/dist/mcp/mcp-app.d.ts +0 -1
- package/dist/mcp/mcp-app.js +1 -1
- package/dist/runtime/part-mounts.d.ts +1 -1
- package/dist/store/clickhouse-http.d.ts +20 -0
- package/dist/store/clickhouse-http.js +90 -0
- package/dist/store/clickhouse-store.d.ts +22 -0
- package/dist/store/clickhouse-store.js +87 -0
- package/dist/store/migrate.js +1 -3
- package/dist/store/store-url.d.ts +4 -0
- package/dist/store/store-url.js +28 -0
- package/dist/store/store.d.ts +1 -0
- package/dist/store/store.js +2 -0
- package/dist/worker/clock.d.ts +0 -1
- package/dist/worker/clock.js +1 -1
- package/dist/worker/scheduler.d.ts +1 -1
- package/dist/worker/scheduler.js +12 -2
- package/package.json +1 -1
- package/dist/host/daemon/reload-route.d.ts +0 -4
- package/dist/host/daemon/reload-route.js +0 -21
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { messageOf } from '../log/log.js';
|
|
3
|
+
export const STORE_URL_FILE_ENV = 'AGENTAGE_STORE_URL_FILE';
|
|
4
|
+
const SCHEMES = {
|
|
5
|
+
postgres: { protocol: /^postgres(ql)?:$/, form: 'postgres://' },
|
|
6
|
+
clickhouse: { protocol: /^https?:$/, form: 'http:// or https://' },
|
|
7
|
+
};
|
|
8
|
+
export const isUrlStoreKind = (kind) => kind === 'postgres' || kind === 'clickhouse';
|
|
9
|
+
const refused = (file, why) => new Error(`${STORE_URL_FILE_ENV} ${file}: ${why}`);
|
|
10
|
+
const readText = async (file, read) => {
|
|
11
|
+
try {
|
|
12
|
+
return (await read(file)).trim();
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
throw refused(file, `cannot read it (${err.code ?? messageOf(err)})`);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
// Every error names the variable and the file, never the URL: it holds a credential.
|
|
19
|
+
export const readStoreUrl = async (file, kind, read = (at) => readFile(at, 'utf8')) => {
|
|
20
|
+
const text = await readText(file, read);
|
|
21
|
+
if (!text)
|
|
22
|
+
throw refused(file, 'the file is empty');
|
|
23
|
+
const { protocol, form } = SCHEMES[kind];
|
|
24
|
+
const url = URL.parse(text);
|
|
25
|
+
if (!url || !protocol.test(url.protocol) || !url.hostname)
|
|
26
|
+
throw refused(file, `holds no ${form} URL for the ${kind} store`);
|
|
27
|
+
return text;
|
|
28
|
+
};
|
package/dist/store/store.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface StoreTimeouts {
|
|
|
10
10
|
statementMs: number;
|
|
11
11
|
}
|
|
12
12
|
export declare const PART_TIMEOUTS: StoreTimeouts;
|
|
13
|
+
export declare const MIGRATE_TIMEOUTS: StoreTimeouts;
|
|
13
14
|
export declare const storeUrl: (env: Env, read?: (file: string) => string) => string | undefined;
|
|
14
15
|
export declare const isOutage: (err: unknown) => boolean;
|
|
15
16
|
export declare const createStore: (env: Env, log: Log, timeouts?: StoreTimeouts) => PoolStore;
|
package/dist/store/store.js
CHANGED
|
@@ -7,6 +7,8 @@ import {} from '../runtime/build-info.js';
|
|
|
7
7
|
import {} from './store.types.js';
|
|
8
8
|
// A part's query is bounded by the server and, if the network itself hangs, by the client too.
|
|
9
9
|
export const PART_TIMEOUTS = { connectMs: 5_000, statementMs: 10_000 };
|
|
10
|
+
// A migration may rewrite a table: minutes, not a request's seconds.
|
|
11
|
+
export const MIGRATE_TIMEOUTS = { connectMs: 10_000, statementMs: 300_000 };
|
|
10
12
|
const CLIENT_SLACK_MS = 2_000;
|
|
11
13
|
// The host sets the connection: AGENTAGE_STORE_URL, a secret file named by _FILE, else libpq PG* env.
|
|
12
14
|
export const storeUrl = (env, read = (file) => readFileSync(file, 'utf8')) => {
|
package/dist/worker/clock.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const CLOCK_RATE_ENV = "AGENTAGE_CLOCK_RATE";
|
|
2
|
-
export declare const MAX_CLOCK_RATE = 3600;
|
|
3
2
|
export declare const parseClockRate: (raw: string | number | undefined) => number;
|
|
4
3
|
export declare const setHostClockRate: (rate: number) => void;
|
|
5
4
|
export declare const hostClockRate: () => number;
|
package/dist/worker/clock.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const CLOCK_RATE_ENV = 'AGENTAGE_CLOCK_RATE';
|
|
2
|
-
|
|
2
|
+
const MAX_CLOCK_RATE = 3600;
|
|
3
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
4
|
export const parseClockRate = (raw) => {
|
|
5
5
|
if (raw === undefined || raw === '')
|
package/dist/worker/scheduler.js
CHANGED
|
@@ -49,7 +49,13 @@ const runJob = async (entry, log, buffer) => {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
// Never twice at once; every run saved with its log, a failed save is logged and the job goes on.
|
|
52
|
-
const execute = (s, entry) =>
|
|
52
|
+
const execute = (s, entry) => {
|
|
53
|
+
const run = requestScope.run({ agcid: uuidv7() }, () => executeScoped(s, entry));
|
|
54
|
+
s.running.add(run);
|
|
55
|
+
const gone = () => void s.running.delete(run);
|
|
56
|
+
run.then(gone, gone);
|
|
57
|
+
return run;
|
|
58
|
+
};
|
|
53
59
|
// Inside the run's scope: every log line of the job, its failure and its save share one agcid.
|
|
54
60
|
const executeScoped = async (s, entry) => {
|
|
55
61
|
const startedAt = s.now();
|
|
@@ -110,11 +116,15 @@ export const createScheduler = (deps) => {
|
|
|
110
116
|
rate,
|
|
111
117
|
entries: new Map(),
|
|
112
118
|
started: false,
|
|
119
|
+
running: new Set(),
|
|
113
120
|
};
|
|
114
121
|
return {
|
|
115
122
|
schedule: scheduleOn(s),
|
|
116
123
|
start: () => setStarted(s, true),
|
|
117
|
-
stop: () =>
|
|
124
|
+
stop: async () => {
|
|
125
|
+
setStarted(s, false);
|
|
126
|
+
await Promise.allSettled([...s.running]);
|
|
127
|
+
},
|
|
118
128
|
run: async (name) => {
|
|
119
129
|
const entry = s.entries.get(name);
|
|
120
130
|
return entry && !entry.running ? execute(s, entry) : undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentage/extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type Express } from 'express';
|
|
2
|
-
import { type Entries } from './entries.js';
|
|
3
|
-
import { type SupervisorDeps } from './supervisor.js';
|
|
4
|
-
export declare const reloadRoute: (app: Express, deps: SupervisorDeps, entries: Entries, readable: () => Promise<void>) => void;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import express, {} from 'express';
|
|
2
|
-
import { ok } from '../../envelope/envelope.js';
|
|
3
|
-
import { BODY_LIMIT } from '../../server/app.js';
|
|
4
|
-
import {} from './entries.js';
|
|
5
|
-
import { waitAtMost } from './queue.js';
|
|
6
|
-
import { reloadExtension } from './reload.js';
|
|
7
|
-
import { stopsNow } from './stopping.js';
|
|
8
|
-
import {} from './supervisor.js';
|
|
9
|
-
// In the change queue (a second reload waits); refused like every change while installation.json is unreadable.
|
|
10
|
-
export const reloadRoute = (app, deps, entries, readable) => {
|
|
11
|
-
app.post('/host/extensions/:id/reload', express.json({ limit: BODY_LIMIT }), async (req, res) => {
|
|
12
|
-
const id = String(req.params['id']);
|
|
13
|
-
const run = () => waitAtMost(deps.queue, deps.installMs, async () => {
|
|
14
|
-
if (deps.stopping.signal.aborted)
|
|
15
|
-
throw stopsNow();
|
|
16
|
-
await readable();
|
|
17
|
-
return reloadExtension(deps, entries, id, req.body);
|
|
18
|
-
});
|
|
19
|
-
res.json(ok(await deps.pending.track({ op: 'reload', id }, run)));
|
|
20
|
-
});
|
|
21
|
-
};
|