@agentage/extension 0.20.1 → 0.20.2
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/auth/part-auth.js +4 -5
- package/dist/context/context.d.ts +0 -1
- package/dist/host/child-env.d.ts +11 -0
- package/dist/host/child-env.js +12 -0
- package/dist/host/{daemon/guard.js → guard.js} +1 -1
- package/dist/host/host-extension.js +1 -1
- package/dist/host/host-main.d.ts +1 -0
- package/dist/host/host-main.js +3 -0
- package/dist/host/index.d.ts +1 -5
- package/dist/host/index.js +1 -5
- package/dist/host/kit-shell.d.ts +1 -0
- package/dist/host/kit-shell.js +8 -0
- package/dist/host/serve-host.js +1 -1
- package/dist/internal/index.d.ts +29 -0
- package/dist/internal/index.js +30 -0
- package/dist/runtime/part-mounts.d.ts +0 -1
- package/dist/runtime/part-mounts.js +1 -1
- package/dist/runtime/run-part.js +0 -2
- package/dist/server/app.d.ts +0 -1
- package/dist/server/app.js +4 -5
- package/dist/shell/dist/index.html +1 -1
- package/dist/shell/dist/shell.css +1 -1
- package/dist/tool/check.js +3 -0
- package/dist/tool/recipe.js +2 -2
- package/dist/tool/up/gateway.js +0 -3
- package/package.json +5 -1
- package/dist/host/daemon/add.d.ts +0 -11
- package/dist/host/daemon/add.js +0 -93
- package/dist/host/daemon/app-files.d.ts +0 -8
- package/dist/host/daemon/app-files.js +0 -34
- package/dist/host/daemon/app-header.d.ts +0 -2
- package/dist/host/daemon/app-header.js +0 -12
- package/dist/host/daemon/app-reload.d.ts +0 -10
- package/dist/host/daemon/app-reload.js +0 -18
- package/dist/host/daemon/child-files.d.ts +0 -20
- package/dist/host/daemon/child-files.js +0 -53
- package/dist/host/daemon/child.d.ts +0 -30
- package/dist/host/daemon/child.js +0 -126
- package/dist/host/daemon/cli-user-watch.d.ts +0 -9
- package/dist/host/daemon/cli-user-watch.js +0 -47
- package/dist/host/daemon/cli-user.d.ts +0 -2
- package/dist/host/daemon/cli-user.js +0 -42
- package/dist/host/daemon/daemon-files.d.ts +0 -20
- package/dist/host/daemon/daemon-files.js +0 -46
- package/dist/host/daemon/daemon-owner.d.ts +0 -1
- package/dist/host/daemon/daemon-owner.js +0 -32
- package/dist/host/daemon/daemon.d.ts +0 -19
- package/dist/host/daemon/daemon.js +0 -137
- package/dist/host/daemon/entries.d.ts +0 -21
- package/dist/host/daemon/entries.js +0 -24
- package/dist/host/daemon/gate.d.ts +0 -3
- package/dist/host/daemon/gate.js +0 -19
- package/dist/host/daemon/health-routes.d.ts +0 -18
- package/dist/host/daemon/health-routes.js +0 -75
- package/dist/host/daemon/host-token.d.ts +0 -6
- package/dist/host/daemon/host-token.js +0 -28
- package/dist/host/daemon/installation.d.ts +0 -35
- package/dist/host/daemon/installation.js +0 -90
- package/dist/host/daemon/installer-call.d.ts +0 -21
- package/dist/host/daemon/installer-call.js +0 -48
- package/dist/host/daemon/json-file.d.ts +0 -6
- package/dist/host/daemon/json-file.js +0 -90
- package/dist/host/daemon/lane.d.ts +0 -9
- package/dist/host/daemon/lane.js +0 -24
- package/dist/host/daemon/last-words.d.ts +0 -2
- package/dist/host/daemon/last-words.js +0 -28
- package/dist/host/daemon/limits.d.ts +0 -16
- package/dist/host/daemon/limits.js +0 -31
- package/dist/host/daemon/ops.d.ts +0 -12
- package/dist/host/daemon/ops.js +0 -94
- package/dist/host/daemon/patch-values.d.ts +0 -6
- package/dist/host/daemon/patch-values.js +0 -39
- package/dist/host/daemon/pending.d.ts +0 -15
- package/dist/host/daemon/pending.js +0 -18
- package/dist/host/daemon/proxy.d.ts +0 -11
- package/dist/host/daemon/proxy.js +0 -106
- package/dist/host/daemon/queue.d.ts +0 -3
- package/dist/host/daemon/queue.js +0 -27
- package/dist/host/daemon/redact-stream.d.ts +0 -4
- package/dist/host/daemon/redact-stream.js +0 -24
- package/dist/host/daemon/reload-marker.d.ts +0 -8
- package/dist/host/daemon/reload-marker.js +0 -57
- package/dist/host/daemon/reload.d.ts +0 -10
- package/dist/host/daemon/reload.js +0 -72
- package/dist/host/daemon/restart.d.ts +0 -14
- package/dist/host/daemon/restart.js +0 -59
- package/dist/host/daemon/routes.d.ts +0 -6
- package/dist/host/daemon/routes.js +0 -101
- package/dist/host/daemon/run-lock.d.ts +0 -1
- package/dist/host/daemon/run-lock.js +0 -15
- package/dist/host/daemon/seal-reach.d.ts +0 -2
- package/dist/host/daemon/seal-reach.js +0 -38
- package/dist/host/daemon/seal.d.ts +0 -20
- package/dist/host/daemon/seal.js +0 -93
- package/dist/host/daemon/shell-events.d.ts +0 -9
- package/dist/host/daemon/shell-events.js +0 -36
- package/dist/host/daemon/shell-routes.d.ts +0 -29
- package/dist/host/daemon/shell-routes.js +0 -68
- package/dist/host/daemon/sign-in-page.d.ts +0 -3
- package/dist/host/daemon/sign-in-page.js +0 -30
- package/dist/host/daemon/start-checks.d.ts +0 -6
- package/dist/host/daemon/start-checks.js +0 -29
- package/dist/host/daemon/stopping.d.ts +0 -10
- package/dist/host/daemon/stopping.js +0 -28
- package/dist/host/daemon/supervisor.d.ts +0 -59
- package/dist/host/daemon/supervisor.js +0 -107
- package/dist/host/daemon/write-all.d.ts +0 -8
- package/dist/host/daemon/write-all.js +0 -45
- /package/dist/host/{daemon/guard.d.ts → guard.d.ts} +0 -0
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { type Log } from '../../log/log.js';
|
|
2
|
-
import { type Launch } from './child.js';
|
|
3
|
-
import { type CliUser } from './cli-user-watch.js';
|
|
4
|
-
import { type InstallEntry } from './installation.js';
|
|
5
|
-
import { type Lane } from './lane.js';
|
|
6
|
-
import { type Limits } from './limits.js';
|
|
7
|
-
import { type PendingChanges } from './pending.js';
|
|
8
|
-
import { type Queue } from './queue.js';
|
|
9
|
-
import { type Retry } from './restart.js';
|
|
10
|
-
import { type Stopping } from './stopping.js';
|
|
11
|
-
export interface InstallSpec {
|
|
12
|
-
id: string;
|
|
13
|
-
version?: string;
|
|
14
|
-
signal?: AbortSignal;
|
|
15
|
-
}
|
|
16
|
-
export type Installer = (spec: InstallSpec) => Promise<{
|
|
17
|
-
id: string;
|
|
18
|
-
version: string;
|
|
19
|
-
dir: string;
|
|
20
|
-
}>;
|
|
21
|
-
export type State = 'starting' | 'running' | 'failed' | 'disabled';
|
|
22
|
-
export interface Entry {
|
|
23
|
-
id: string;
|
|
24
|
-
install: InstallEntry;
|
|
25
|
-
state: State;
|
|
26
|
-
version: string;
|
|
27
|
-
dir?: string;
|
|
28
|
-
error?: string;
|
|
29
|
-
lane?: Lane;
|
|
30
|
-
gate?: Promise<void>;
|
|
31
|
-
exits?: number[];
|
|
32
|
-
restarts?: number;
|
|
33
|
-
retry?: Retry;
|
|
34
|
-
}
|
|
35
|
-
export interface Values {
|
|
36
|
-
settings: Record<string, unknown>;
|
|
37
|
-
secrets: Record<string, string>;
|
|
38
|
-
}
|
|
39
|
-
export interface Next {
|
|
40
|
-
install: InstallEntry;
|
|
41
|
-
values: Values;
|
|
42
|
-
dir?: string;
|
|
43
|
-
}
|
|
44
|
-
export interface SupervisorDeps extends Limits {
|
|
45
|
-
configDir: string;
|
|
46
|
-
launch: Launch;
|
|
47
|
-
origin: () => string;
|
|
48
|
-
install?: Installer;
|
|
49
|
-
log: Log;
|
|
50
|
-
queue: Queue;
|
|
51
|
-
pending: PendingChanges;
|
|
52
|
-
stopping: Stopping;
|
|
53
|
-
unsynced: Set<string>;
|
|
54
|
-
user: CliUser;
|
|
55
|
-
}
|
|
56
|
-
export declare const valuesOf: (configDir: string, id: string) => Promise<Values>;
|
|
57
|
-
export declare const startEntry: (deps: SupervisorDeps, entry: Entry, fresh?: boolean) => Promise<Error | undefined>;
|
|
58
|
-
export declare const startFailed: (entry: Entry, err: unknown) => import("../../envelope/envelope.js").Failure;
|
|
59
|
-
export declare const swap: (deps: SupervisorDeps, entry: Entry, to: Next, undo?: () => Promise<unknown>) => Promise<void>;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { fail } from '../../envelope/envelope.js';
|
|
2
|
-
import {} from '../../log/log.js';
|
|
3
|
-
import { readManifest } from '../../manifest/read-manifest.js';
|
|
4
|
-
import {} from './child.js';
|
|
5
|
-
import {} from './cli-user-watch.js';
|
|
6
|
-
import { dataDirOf, readValues } from './daemon-files.js';
|
|
7
|
-
import {} from './installation.js';
|
|
8
|
-
import { halt } from './gate.js';
|
|
9
|
-
import { laneOf } from './lane.js';
|
|
10
|
-
import {} from './limits.js';
|
|
11
|
-
import { runInstaller } from './installer-call.js';
|
|
12
|
-
import {} from './pending.js';
|
|
13
|
-
import {} from './queue.js';
|
|
14
|
-
import { crashed, healthyFor, reasonOf, resetRestarts } from './restart.js';
|
|
15
|
-
import { assertSecrets, healthy, redact } from './start-checks.js';
|
|
16
|
-
import {} from './stopping.js';
|
|
17
|
-
export const valuesOf = async (configDir, id) => ({
|
|
18
|
-
settings: await readValues(configDir, 'settings', id),
|
|
19
|
-
secrets: (await readValues(configDir, 'secrets', id)),
|
|
20
|
-
});
|
|
21
|
-
// The package folder: the source itself, the folder an install gave, or the installer again.
|
|
22
|
-
const dirOf = async (deps, entry, install, given) => {
|
|
23
|
-
if (given)
|
|
24
|
-
return given;
|
|
25
|
-
if (install.source)
|
|
26
|
-
return install.source;
|
|
27
|
-
if (entry.dir && install.version === entry.install.version)
|
|
28
|
-
return entry.dir;
|
|
29
|
-
return (await runInstaller(deps, { id: entry.id, version: install.version })).dir;
|
|
30
|
-
};
|
|
31
|
-
// A new child for to, healthy, then the route; fresh: a start the owner asked for (restarts reset).
|
|
32
|
-
const launchFor = async (deps, entry, to, fresh) => {
|
|
33
|
-
const dir = await dirOf(deps, entry, to.install, to.dir);
|
|
34
|
-
const pkg = await readManifest(dir);
|
|
35
|
-
assertSecrets(pkg, to.values.secrets);
|
|
36
|
-
const spec = { id: entry.id, dir, dataDir: dataDirOf(deps.configDir, entry.id), ...to.values };
|
|
37
|
-
const child = await deps
|
|
38
|
-
.launch({ ...spec, origin: deps.origin(), storeOpenMs: deps.healthMs, userSub: deps.user.sub })
|
|
39
|
-
.catch((err) => Promise.reject(Object.assign(err, { message: redact(err.message, to.values.secrets) })));
|
|
40
|
-
await healthy(child.port, deps.healthMs).catch(async (err) => {
|
|
41
|
-
await child.stop();
|
|
42
|
-
throw err;
|
|
43
|
-
});
|
|
44
|
-
const lane = laneOf(child);
|
|
45
|
-
Object.assign(entry, { dir, version: pkg.version, lane, state: 'running', error: undefined });
|
|
46
|
-
if (fresh)
|
|
47
|
-
resetRestarts(entry);
|
|
48
|
-
// Watched only once it is the route: an exit that came before this line is seen, not lost.
|
|
49
|
-
const words = (how) => redact(reasonOf(how), to.values.secrets);
|
|
50
|
-
void child.exited.then((how) => exitedEarly(deps, entry, lane, words(how)));
|
|
51
|
-
healthyFor(deps, entry, lane);
|
|
52
|
-
};
|
|
53
|
-
// A child that exits while it is the route restarts (C6); a retired one was detached first.
|
|
54
|
-
const exitedEarly = (deps, entry, lane, why) => {
|
|
55
|
-
if (entry.lane !== lane)
|
|
56
|
-
return;
|
|
57
|
-
entry.lane = undefined;
|
|
58
|
-
crashed(deps, entry, why, () => restartEntry(deps, entry));
|
|
59
|
-
};
|
|
60
|
-
const failed = (deps, entry, err) => {
|
|
61
|
-
Object.assign(entry, { state: 'failed', error: err.message });
|
|
62
|
-
deps.log.warn('extension failed to start', { id: entry.id, reason: entry.error });
|
|
63
|
-
};
|
|
64
|
-
// The install and values of installation.json, as they are on disk; the error when it failed.
|
|
65
|
-
export const startEntry = async (deps, entry, fresh = false) => {
|
|
66
|
-
entry.state = 'starting';
|
|
67
|
-
try {
|
|
68
|
-
const values = await valuesOf(deps.configDir, entry.id);
|
|
69
|
-
await launchFor(deps, entry, { install: entry.install, values }, fresh);
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
catch (err) {
|
|
73
|
-
failed(deps, entry, err);
|
|
74
|
-
return err;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
// A restart that does not start counts as one more exit.
|
|
78
|
-
const restartEntry = async (deps, entry) => {
|
|
79
|
-
const err = await startEntry(deps, entry);
|
|
80
|
-
if (err)
|
|
81
|
-
crashed(deps, entry, err.message, () => restartEntry(deps, entry));
|
|
82
|
-
};
|
|
83
|
-
// The old install again after a refused change; a disabled one stays stopped.
|
|
84
|
-
const restore = async (deps, entry) => {
|
|
85
|
-
if (entry.install.enabled === false)
|
|
86
|
-
entry.state = 'disabled';
|
|
87
|
-
else
|
|
88
|
-
await startEntry(deps, entry);
|
|
89
|
-
};
|
|
90
|
-
// C6: the envelope of a refused start; reason is the child's own words.
|
|
91
|
-
export const startFailed = (entry, err) => {
|
|
92
|
-
const reason = err.message;
|
|
93
|
-
const details = { code: 'START_FAILED', reason };
|
|
94
|
-
return fail('VALIDATION_ERROR', `${entry.id} failed to start: ${reason}`, { details });
|
|
95
|
-
};
|
|
96
|
-
// One writer per data folder (the caller holds the gate): stop the old child, start the new one.
|
|
97
|
-
export const swap = async (deps, entry, to, undo = async () => undefined) => {
|
|
98
|
-
try {
|
|
99
|
-
await halt(entry, deps.drainMs);
|
|
100
|
-
await launchFor(deps, entry, to, true);
|
|
101
|
-
}
|
|
102
|
-
catch (err) {
|
|
103
|
-
await undo();
|
|
104
|
-
await restore(deps, entry);
|
|
105
|
-
throw startFailed(entry, err);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type InstallEntry } from './installation.js';
|
|
2
|
-
import { type SupervisorDeps, type Values } from './supervisor.js';
|
|
3
|
-
export interface Written {
|
|
4
|
-
install?: InstallEntry;
|
|
5
|
-
values?: Values;
|
|
6
|
-
}
|
|
7
|
-
export declare const unsynced: (deps: SupervisorDeps, id: string) => void;
|
|
8
|
-
export declare const writeAll: (deps: SupervisorDeps, id: string, to: Written, was?: Written) => Promise<void>;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { writeValues } from './daemon-files.js';
|
|
2
|
-
import { persist } from './entries.js';
|
|
3
|
-
import {} from './installation.js';
|
|
4
|
-
import {} from './supervisor.js';
|
|
5
|
-
const stepsOf = (deps, id, to, was) => {
|
|
6
|
-
// An empty object is no row: what valuesOf reads for an id the file does not name.
|
|
7
|
-
const values = (kind, v) => () => {
|
|
8
|
-
const rows = v?.[kind];
|
|
9
|
-
return writeValues(deps.configDir, kind, id, rows && Object.keys(rows).length ? rows : undefined, deps.lockMs);
|
|
10
|
-
};
|
|
11
|
-
const steps = [
|
|
12
|
-
[() => persist(deps, id, to.install), () => persist(deps, id, was.install)],
|
|
13
|
-
[values('settings', to.values), values('settings', was.values)],
|
|
14
|
-
// Last: a failed write before it leaves secrets.json as it was.
|
|
15
|
-
[values('secrets', to.values), values('secrets', was.values)],
|
|
16
|
-
];
|
|
17
|
-
// A remove deletes the secrets first: a crash half way leaves none for a later install of id.
|
|
18
|
-
return to.install ? steps : steps.reverse();
|
|
19
|
-
};
|
|
20
|
-
// An undo that failed leaves the files of id unlike the list: one warn line, and /health names it.
|
|
21
|
-
export const unsynced = (deps, id) => {
|
|
22
|
-
deps.unsynced.add(id);
|
|
23
|
-
deps.log.warn('a failed write could not be undone: the daemon files may not match the list', {
|
|
24
|
-
id,
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
// installation.json, settings.json, secrets.json in turn; a failed one undoes those written before it.
|
|
28
|
-
export const writeAll = async (deps, id, to, was = {}) => {
|
|
29
|
-
const done = [];
|
|
30
|
-
try {
|
|
31
|
-
for (const [run, undo] of stepsOf(deps, id, to, was)) {
|
|
32
|
-
await run();
|
|
33
|
-
done.unshift(undo);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
let lost = false;
|
|
38
|
-
for (const undo of done)
|
|
39
|
-
await undo().catch(() => (lost = true));
|
|
40
|
-
if (lost)
|
|
41
|
-
unsynced(deps, id);
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
44
|
-
deps.unsynced.delete(id);
|
|
45
|
-
};
|
|
File without changes
|