@cotal-ai/manager 0.174.2 → 0.174.4
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/boot.d.ts +3 -17
- package/dist/boot.d.ts.map +1 -1
- package/dist/boot.js +48 -62
- package/dist/boot.js.map +1 -1
- package/dist/broker-transport.d.ts +4 -8
- package/dist/broker-transport.d.ts.map +1 -1
- package/dist/broker-transport.js +15 -19
- package/dist/broker-transport.js.map +1 -1
- package/dist/command-dispatch.d.ts +3 -7
- package/dist/command-dispatch.d.ts.map +1 -1
- package/dist/command-dispatch.js +9 -13
- package/dist/command-dispatch.js.map +1 -1
- package/dist/credential-renewal.d.ts +3 -7
- package/dist/credential-renewal.d.ts.map +1 -1
- package/dist/credential-renewal.js +13 -17
- package/dist/credential-renewal.js.map +1 -1
- package/dist/goal-writer.d.ts +3 -5
- package/dist/goal-writer.d.ts.map +1 -1
- package/dist/goal-writer.js +10 -12
- package/dist/goal-writer.js.map +1 -1
- package/dist/harness-resolution.d.ts +3 -13
- package/dist/harness-resolution.d.ts.map +1 -1
- package/dist/harness-resolution.js +14 -24
- package/dist/harness-resolution.js.map +1 -1
- package/dist/lease-keeper.d.ts +3 -3
- package/dist/lease-keeper.d.ts.map +1 -1
- package/dist/lease-keeper.js +8 -8
- package/dist/lease-keeper.js.map +1 -1
- package/dist/managed-static-lifecycle.d.ts +4 -9
- package/dist/managed-static-lifecycle.d.ts.map +1 -1
- package/dist/managed-static-lifecycle.js +25 -30
- package/dist/managed-static-lifecycle.js.map +1 -1
- package/dist/manager-config.d.ts +55 -0
- package/dist/manager-config.d.ts.map +1 -0
- package/dist/manager-config.js +2 -0
- package/dist/manager-config.js.map +1 -0
- package/dist/manager.d.ts +8 -47
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +96 -122
- package/dist/manager.js.map +1 -1
- package/dist/names-capacity.d.ts +3 -3
- package/dist/names-capacity.d.ts.map +1 -1
- package/dist/names-capacity.js +4 -3
- package/dist/names-capacity.js.map +1 -1
- package/dist/persona-catalog.d.ts +3 -7
- package/dist/persona-catalog.d.ts.map +1 -1
- package/dist/persona-catalog.js +10 -14
- package/dist/persona-catalog.js.map +1 -1
- package/dist/preservation.d.ts +3 -9
- package/dist/preservation.d.ts.map +1 -1
- package/dist/preservation.js +16 -22
- package/dist/preservation.js.map +1 -1
- package/dist/preserved-resume.d.ts +3 -15
- package/dist/preserved-resume.d.ts.map +1 -1
- package/dist/preserved-resume.js +48 -60
- package/dist/preserved-resume.js.map +1 -1
- package/dist/readiness-wait.d.ts +3 -3
- package/dist/readiness-wait.d.ts.map +1 -1
- package/dist/readiness-wait.js +6 -6
- package/dist/readiness-wait.js.map +1 -1
- package/dist/retirement.d.ts +4 -12
- package/dist/retirement.d.ts.map +1 -1
- package/dist/retirement.js +14 -22
- package/dist/retirement.js.map +1 -1
- package/dist/seat-custody.d.ts +4 -6
- package/dist/seat-custody.d.ts.map +1 -1
- package/dist/seat-custody.js +11 -13
- package/dist/seat-custody.js.map +1 -1
- package/dist/seat-launch.d.ts +3 -11
- package/dist/seat-launch.d.ts.map +1 -1
- package/dist/seat-launch.js +16 -26
- package/dist/seat-launch.js.map +1 -1
- package/dist/seat-start.d.ts +3 -8
- package/dist/seat-start.d.ts.map +1 -1
- package/dist/seat-start.js +54 -35
- package/dist/seat-start.js.map +1 -1
- package/dist/seat-stop.d.ts +3 -9
- package/dist/seat-stop.d.ts.map +1 -1
- package/dist/seat-stop.js +9 -15
- package/dist/seat-stop.js.map +1 -1
- package/dist/serve-plane.d.ts +3 -9
- package/dist/serve-plane.d.ts.map +1 -1
- package/dist/serve-plane.js +20 -26
- package/dist/serve-plane.js.map +1 -1
- package/dist/session-recovery.d.ts +3 -4
- package/dist/session-recovery.d.ts.map +1 -1
- package/dist/session-recovery.js +7 -8
- package/dist/session-recovery.js.map +1 -1
- package/dist/spawn-goal.d.ts +4 -8
- package/dist/spawn-goal.d.ts.map +1 -1
- package/dist/spawn-goal.js +7 -11
- package/dist/spawn-goal.js.map +1 -1
- package/dist/start-doors.d.ts +3 -9
- package/dist/start-doors.d.ts.map +1 -1
- package/dist/start-doors.js +10 -16
- package/dist/start-doors.js.map +1 -1
- package/dist/status-and-models.d.ts +3 -11
- package/dist/status-and-models.d.ts.map +1 -1
- package/dist/status-and-models.js +13 -21
- package/dist/status-and-models.js.map +1 -1
- package/dist/terminal-input.d.ts +3 -5
- package/dist/terminal-input.d.ts.map +1 -1
- package/dist/terminal-input.js +6 -8
- package/dist/terminal-input.js.map +1 -1
- package/dist/user-provision.d.ts +4 -8
- package/dist/user-provision.d.ts.map +1 -1
- package/dist/user-provision.js +29 -33
- package/dist/user-provision.js.map +1 -1
- package/package.json +12 -12
|
@@ -18,33 +18,23 @@ export function resolveHarness(name, requires) {
|
|
|
18
18
|
* field the Manager assigns later is current and a member a test replaces on the instance is the one that runs. */
|
|
19
19
|
export function harnessResolutionDeps(m) {
|
|
20
20
|
return {
|
|
21
|
-
eventPayloadsWithheld: () => m["eventPayloadsWithheld"],
|
|
22
|
-
eventsRequired: () => m["eventsRequired"],
|
|
23
|
-
expectedConnectorGeneration: () => m["expectedConnectorGeneration"],
|
|
24
21
|
installedExtensions: () => m["installedExtensions"],
|
|
25
|
-
servers: () => m["servers"],
|
|
26
|
-
space: () => m["space"],
|
|
27
|
-
workspaceRoot: () => m["workspaceRoot"],
|
|
28
22
|
};
|
|
29
23
|
}
|
|
30
24
|
/** Resolving a connector by name and the host fields, harness binaries and capability and events refusals a launch carries. */
|
|
31
25
|
export class HarnessResolution {
|
|
26
|
+
config;
|
|
32
27
|
deps;
|
|
33
28
|
parts;
|
|
34
|
-
constructor(deps, parts) {
|
|
29
|
+
constructor(config, deps, parts) {
|
|
30
|
+
this.config = config;
|
|
35
31
|
this.deps = deps;
|
|
36
32
|
this.parts = parts;
|
|
37
33
|
}
|
|
38
34
|
// The Manager members these bodies read, under their Manager names. Each reads through its dep at
|
|
39
35
|
// use, so a field the Manager assigns later is current and a method a test replaces on the Manager
|
|
40
36
|
// is the one that runs.
|
|
41
|
-
get eventPayloadsWithheld() { return this.deps.eventPayloadsWithheld(); }
|
|
42
|
-
get eventsRequired() { return this.deps.eventsRequired(); }
|
|
43
|
-
get expectedConnectorGeneration() { return this.deps.expectedConnectorGeneration(); }
|
|
44
37
|
get installedExtensions() { return this.deps.installedExtensions(); }
|
|
45
|
-
get servers() { return this.deps.servers(); }
|
|
46
|
-
get space() { return this.deps.space(); }
|
|
47
|
-
get workspaceRoot() { return this.deps.workspaceRoot(); }
|
|
48
38
|
/** Resolve a connector by agent type. Library composition (installedExtensions off) → a registry
|
|
49
39
|
* hit, exactly as before (the composition root imported what it wants). The published binary gates
|
|
50
40
|
* on MANIFEST membership FIRST — so a live `cotal ext remove` is honored even though the registry
|
|
@@ -58,7 +48,7 @@ export class HarnessResolution {
|
|
|
58
48
|
return registry.resolve("connector", name);
|
|
59
49
|
if (!manifestExtensionNames("connector").includes(name))
|
|
60
50
|
throw new Error(connectorInstallHint(name));
|
|
61
|
-
return materializeFromManifest({ kind: "connector", name }, { hint: (ref) => connectorInstallHint(ref.name), expectedGeneration: this.expectedConnectorGeneration });
|
|
51
|
+
return materializeFromManifest({ kind: "connector", name }, { hint: (ref) => connectorInstallHint(ref.name), expectedGeneration: this.config.expectedConnectorGeneration });
|
|
62
52
|
}
|
|
63
53
|
/** The harness binaries a managed launch runs, as boot resolved them, or the refusal naming what is
|
|
64
54
|
* missing. Spawn, resume and the model catalog all take it, so a seat launches from the same files
|
|
@@ -80,8 +70,8 @@ export class HarnessResolution {
|
|
|
80
70
|
* servers and env allowlist come from the contents its checks read. */
|
|
81
71
|
hostLaunchFields(cotalConfig, agent, shareTools, harness) {
|
|
82
72
|
return {
|
|
83
|
-
space: this.space,
|
|
84
|
-
servers: this.servers,
|
|
73
|
+
space: this.config.space,
|
|
74
|
+
servers: this.config.servers,
|
|
85
75
|
// Declared overrides plus the connector's native default, unless this spawn explicitly
|
|
86
76
|
// restricts sharing. An empty selection is deliberate isolation, not the default.
|
|
87
77
|
mcpServers: connectorServers(cotalConfig, agent, shareTools),
|
|
@@ -91,11 +81,11 @@ export class HarnessResolution {
|
|
|
91
81
|
// A connector never reads the config itself.
|
|
92
82
|
envAllow: spawnEnvAllow(cotalConfig),
|
|
93
83
|
resolvedBinaries: harness.binaries,
|
|
94
|
-
eventsRequired: this.eventsRequired,
|
|
95
|
-
...(this.eventPayloadsWithheld ? { eventPayloads: false } : {}),
|
|
84
|
+
eventsRequired: this.config.eventsRequired,
|
|
85
|
+
...(this.config.eventPayloadsWithheld ? { eventPayloads: false } : {}),
|
|
96
86
|
// So a connector that keeps per-agent local state can root it at the workspace, not the
|
|
97
87
|
// (possibly per-agent) launch cwd.
|
|
98
|
-
workspaceRoot: this.workspaceRoot,
|
|
88
|
+
workspaceRoot: this.config.workspaceRoot,
|
|
99
89
|
};
|
|
100
90
|
}
|
|
101
91
|
/** The refusal for a launch choice the connector cannot honour. Spawn and resume both ask before
|
|
@@ -113,11 +103,11 @@ export class HarnessResolution {
|
|
|
113
103
|
* Spawn and resume both ask before a seat's launch is built, so a seat retained without the
|
|
114
104
|
* plane cannot come back on a space that now requires it. An absent choice arms supported planes. */
|
|
115
105
|
eventsRefusal(connector, events) {
|
|
116
|
-
if (this.eventsRequired && events === false)
|
|
117
|
-
return `space "${this.space}" requires the event plane by registration policy; --no-events (events: false on the start op) is not allowed`;
|
|
118
|
-
if ((this.eventsRequired || events === true) && !connector.eventChannel)
|
|
119
|
-
return this.eventsRequired
|
|
120
|
-
? `space "${this.space}" requires the event plane by registration policy, but connector "${connector.name}" does not publish one`
|
|
106
|
+
if (this.config.eventsRequired && events === false)
|
|
107
|
+
return `space "${this.config.space}" requires the event plane by registration policy; --no-events (events: false on the start op) is not allowed`;
|
|
108
|
+
if ((this.config.eventsRequired || events === true) && !connector.eventChannel)
|
|
109
|
+
return this.config.eventsRequired
|
|
110
|
+
? `space "${this.config.space}" requires the event plane by registration policy, but connector "${connector.name}" does not publish one`
|
|
121
111
|
: `connector "${connector.name}" does not publish an AG-UI event plane; omit --events to launch it without one`;
|
|
122
112
|
return undefined;
|
|
123
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness-resolution.js","sourceRoot":"","sources":["../src/harness-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"harness-resolution.js","sourceRoot":"","sources":["../src/harness-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAK3H;yGACyG;AACzG,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,QAA2B;IACtE,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,IAAI;YAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;;YAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,kBAAkB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;AACjI,CAAC;AAQD;oHACoH;AACpH,MAAM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AiB,CAAC,SAAoB,EAAE,MAA6D;QACnG,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,oBAAoB;YACnD,OAAO,GAAG,SAAS,CAAC,IAAI,sDAAsD,CAAC;QACjF,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,cAAc;YAC1D,OAAO,GAAG,SAAS,CAAC,IAAI,wDAAwD,CAAC;QACnF,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,2BAA2B,CAAC;YAC9F,OAAO,GAAG,SAAS,CAAC,IAAI,0EAA0E,CAAC;QACrG,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;0GAEsG;IACtG,aAAa,CAAC,SAAoB,EAAE,MAA2B;QAC7D,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,MAAM,KAAK,KAAK;YAChD,OAAO,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,+GAA+G,CAAC;QACpJ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY;YAC5E,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc;gBAC/B,CAAC,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,qEAAqE,SAAS,CAAC,IAAI,wBAAwB;gBACxI,CAAC,CAAC,cAAc,SAAS,CAAC,IAAI,iFAAiF,CAAC;QACpH,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
package/dist/lease-keeper.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CotalEndpoint, ManagerLeaseInfo } from "@cotal-ai/core";
|
|
2
2
|
import type { Manager } from "./manager.js";
|
|
3
|
+
import type { ManagerConfig } from "./manager-config.js";
|
|
3
4
|
/** `start()`'s refusal when this manager instance's lease is held (#3915): by another live process
|
|
4
5
|
* on this workspace root, or by a holder on another root. A restart whose predecessor on this root
|
|
5
6
|
* is dead, this process's own earlier start included, waits the key out instead (#4092). The
|
|
@@ -18,7 +19,6 @@ export declare class ManagerInstanceLeaseHeld extends Error {
|
|
|
18
19
|
export interface LeaseKeeperDeps {
|
|
19
20
|
endpoint: () => CotalEndpoint;
|
|
20
21
|
instanceId: () => string;
|
|
21
|
-
space: () => string;
|
|
22
22
|
stopping: () => boolean;
|
|
23
23
|
}
|
|
24
24
|
/** Builds the {@link LeaseKeeperDeps} for a Manager. It reads Manager members by name at each use, so a
|
|
@@ -27,6 +27,7 @@ export declare function leaseKeeperDeps(m: Manager): LeaseKeeperDeps;
|
|
|
27
27
|
/** This manager instance's liveness lease key: acquire it at start, renew it on a timer, release it
|
|
28
28
|
* on a clean stop. */
|
|
29
29
|
export declare class LeaseKeeper {
|
|
30
|
+
private readonly config;
|
|
30
31
|
private readonly deps;
|
|
31
32
|
leaseInfo?: Omit<ManagerLeaseInfo, "since">;
|
|
32
33
|
leaseRevision?: number;
|
|
@@ -41,10 +42,9 @@ export declare class LeaseKeeper {
|
|
|
41
42
|
* releasing the key instead of racing it: a renew that lands after the cached revision was read
|
|
42
43
|
* for release would otherwise move the row out from under a same-cached-revision CAS delete. */
|
|
43
44
|
leaseRenewTask?: Promise<void>;
|
|
44
|
-
constructor(deps: LeaseKeeperDeps);
|
|
45
|
+
constructor(config: Readonly<ManagerConfig>, deps: LeaseKeeperDeps);
|
|
45
46
|
private get ep();
|
|
46
47
|
private get managerInstanceId();
|
|
47
|
-
private get space();
|
|
48
48
|
private get leaseStopping();
|
|
49
49
|
/** Create THIS instance's lease key, waiting out a dead predecessor's row first (#4092).
|
|
50
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lease-keeper.d.ts","sourceRoot":"","sources":["../src/lease-keeper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC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UAAU,CAAsB;IACxC;gGAC4F;IAC5F,OAAO,CAAC,kBAAkB,CAAS;IACnC;;qGAEiG;IACjG,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBAEF,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAmB,IAAI,EAAE,eAAe;IAEpG,OAAO,KAAK,EAAE,GAAkD;IAChE,OAAO,KAAK,iBAAiB,GAA6C;IAC1E,OAAO,KAAK,aAAa,GAA4C;IAErE;;;;;;;yDAOqD;IAC/C,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IA+ClF;;;;;;;;mGAQ+F;IACzF,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB7C;;;;;;;;;;;;;;;;;;4BAkBwB;IAClB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAcjC;;;2DAGuD;IACjD,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoDxC;;+EAE2E;IAC3E,OAAO,CAAC,SAAS;IAMjB;;2BAEuB;YACT,cAAc;CAkB7B"}
|
package/dist/lease-keeper.js
CHANGED
|
@@ -35,13 +35,13 @@ export function leaseKeeperDeps(m) {
|
|
|
35
35
|
return {
|
|
36
36
|
endpoint: () => m["ep"],
|
|
37
37
|
instanceId: () => m["managerInstanceId"],
|
|
38
|
-
space: () => m["space"],
|
|
39
38
|
stopping: () => m["leaseStopping"],
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
41
|
/** This manager instance's liveness lease key: acquire it at start, renew it on a timer, release it
|
|
43
42
|
* on a clean stop. */
|
|
44
43
|
export class LeaseKeeper {
|
|
44
|
+
config;
|
|
45
45
|
deps;
|
|
46
46
|
leaseInfo;
|
|
47
47
|
leaseRevision;
|
|
@@ -56,12 +56,12 @@ export class LeaseKeeper {
|
|
|
56
56
|
* releasing the key instead of racing it: a renew that lands after the cached revision was read
|
|
57
57
|
* for release would otherwise move the row out from under a same-cached-revision CAS delete. */
|
|
58
58
|
leaseRenewTask;
|
|
59
|
-
constructor(deps) {
|
|
59
|
+
constructor(config, deps) {
|
|
60
|
+
this.config = config;
|
|
60
61
|
this.deps = deps;
|
|
61
62
|
}
|
|
62
63
|
get ep() { return this.deps.endpoint(); }
|
|
63
64
|
get managerInstanceId() { return this.deps.instanceId(); }
|
|
64
|
-
get space() { return this.deps.space(); }
|
|
65
65
|
get leaseStopping() { return this.deps.stopping(); }
|
|
66
66
|
/** Create THIS instance's lease key, waiting out a dead predecessor's row first (#4092).
|
|
67
67
|
*
|
|
@@ -74,9 +74,9 @@ export class LeaseKeeper {
|
|
|
74
74
|
async acquireInstanceLease(info) {
|
|
75
75
|
const refuse = (held, e) => {
|
|
76
76
|
if (!held)
|
|
77
|
-
return new Error(`could not acquire the manager lease for space "${this.space}": ${rejectionText(e)}`);
|
|
77
|
+
return new Error(`could not acquire the manager lease for space "${this.config.space}": ${rejectionText(e)}`);
|
|
78
78
|
const sameRoot = held.root === info.root;
|
|
79
|
-
return new ManagerInstanceLeaseHeld(`manager instance ${this.managerInstanceId} already serves space "${this.space}" from ${sameRoot ? "this" : "another"} workspace root (${held.runtime}, pid ${held.pid}, root ${held.root}) - stop it first before restarting the same instance`, this.managerInstanceId, this.space, held, sameRoot);
|
|
79
|
+
return new ManagerInstanceLeaseHeld(`manager instance ${this.managerInstanceId} already serves space "${this.config.space}" from ${sameRoot ? "this" : "another"} workspace root (${held.runtime}, pid ${held.pid}, root ${held.root}) - stop it first before restarting the same instance`, this.managerInstanceId, this.config.space, held, sameRoot);
|
|
80
80
|
};
|
|
81
81
|
try {
|
|
82
82
|
return await this.ep.acquireManagerLease(info);
|
|
@@ -135,7 +135,7 @@ export class LeaseKeeper {
|
|
|
135
135
|
why = rejectionText(e);
|
|
136
136
|
}
|
|
137
137
|
if (Date.now() >= deadline) {
|
|
138
|
-
console.error(`! manager instance ${this.managerInstanceId} could not release its liveness lease (space "${this.space}"): ${why}; a same-root restart inside the bucket TTL will be refused`);
|
|
138
|
+
console.error(`! manager instance ${this.managerInstanceId} could not release its liveness lease (space "${this.config.space}"): ${why}; a same-root restart inside the bucket TTL will be refused`);
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
await new Promise((r) => setTimeout(r, LEASE_RELEASE_RETRY_MS));
|
|
@@ -223,7 +223,7 @@ export class LeaseKeeper {
|
|
|
223
223
|
// registration, which is the other process's now. That process took over on the premise
|
|
224
224
|
// that this one was gone, so this exit leaves what a crash would, and seats a custodian or
|
|
225
225
|
// multiplexer owns outlive it the same way.
|
|
226
|
-
console.error(`! manager instance ${this.managerInstanceId} finds its liveness lease key held by ${verdict.by}, not by this process (renew: ${why}); that process serves this instance now, so this one stops serving and exits (space "${this.space}")`);
|
|
226
|
+
console.error(`! manager instance ${this.managerInstanceId} finds its liveness lease key held by ${verdict.by}, not by this process (renew: ${why}); that process serves this instance now, so this one stops serving and exits (space "${this.config.space}")`);
|
|
227
227
|
process.exit(1);
|
|
228
228
|
case "unknown":
|
|
229
229
|
this.noteLease("unknown", `could not renew its liveness lease (${why}) or re-read it (${verdict.why}); serving, retrying until the broker answers`);
|
|
@@ -242,7 +242,7 @@ export class LeaseKeeper {
|
|
|
242
242
|
if (state === this.leaseState)
|
|
243
243
|
return;
|
|
244
244
|
this.leaseState = state;
|
|
245
|
-
console.error(`${state === "held" ? "✓" : "!"} manager instance ${this.managerInstanceId} ${what} (space "${this.space}")`);
|
|
245
|
+
console.error(`${state === "held" ? "✓" : "!"} manager instance ${this.managerInstanceId} ${what} (space "${this.config.space}")`);
|
|
246
246
|
}
|
|
247
247
|
/** What the broker actually says about THIS instance's lease key, right now. `unknown` is a first-class
|
|
248
248
|
* answer and never collapses into `gone`: not being able to look is not the same fact as looking and
|
package/dist/lease-keeper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lease-keeper.js","sourceRoot":"","sources":["../src/lease-keeper.ts"],"names":[],"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K,OAAO,CAAC,GAAG;YAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,OAAO,UAAU,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACnJ,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CotalEndpoint, dialerFor, type DeprovisionResourceAccounting, type IssuanceSeam, type IssuedStore } from "@cotal-ai/core";
|
|
2
|
-
import type { EpCapability, RuntimeReference,
|
|
2
|
+
import type { EpCapability, RuntimeReference, SpaceAuth } from "@cotal-ai/core";
|
|
3
3
|
import { type SeatRecord } from "./resume.js";
|
|
4
4
|
import { type LifecycleStateTransport, type StaticManagedSlotRow } from "@cotal-ai/core";
|
|
5
5
|
import { type ManagerStaticReconciliationFailure, type ManagerStaticReconciliationStatus } from "./manager-service-contract.js";
|
|
@@ -9,6 +9,7 @@ import { type ExpiringChatSession } from "./chat-session.js";
|
|
|
9
9
|
import type { Manager, ManagedAgent } from "./manager.js";
|
|
10
10
|
import type { TeardownTarget, RetirementHold } from "./retirement.js";
|
|
11
11
|
import type { EvictionResult } from "@cotal-ai/core";
|
|
12
|
+
import type { ManagerConfig } from "./manager-config.js";
|
|
12
13
|
/** One initial terminal entry plus three re-drives. The short first retry absorbs a one-shot
|
|
13
14
|
* broker/eviction blip; the wider later spacing avoids hammering a persistently unavailable
|
|
14
15
|
* authority. The finite ~36s window is intentionally not a liveness inference: exhausting it
|
|
@@ -28,17 +29,10 @@ interface StaticReconcileAttempt {
|
|
|
28
29
|
}
|
|
29
30
|
/** Manager-owned authority, runtime and retirement operations for static lifecycle work. */
|
|
30
31
|
export interface ManagedStaticLifecycleDeps {
|
|
31
|
-
space: () => string;
|
|
32
|
-
servers: () => string | undefined;
|
|
33
32
|
auth: () => SpaceAuth | undefined;
|
|
34
|
-
secrets: () => SecretStore;
|
|
35
|
-
workspaceRoot: () => string;
|
|
36
33
|
instanceId: () => string;
|
|
37
|
-
processUid: () => string;
|
|
38
34
|
userMode: () => boolean;
|
|
39
|
-
eventPayloadsWithheld: () => boolean;
|
|
40
35
|
evictor: () => ((principal: string) => Promise<EvictionResult>) | undefined;
|
|
41
|
-
retryDelays: () => readonly number[];
|
|
42
36
|
resumeRequired: () => boolean;
|
|
43
37
|
records: () => KV | undefined;
|
|
44
38
|
agentFor: (name: string) => ManagedAgent | undefined;
|
|
@@ -101,6 +95,7 @@ export interface ManagedStaticLifecycleDeps {
|
|
|
101
95
|
export declare function managedStaticLifecycleDeps(m: Manager): ManagedStaticLifecycleDeps;
|
|
102
96
|
/** Static chat admission, credential renewal, terminal cleanup and resumable reconciliation. */
|
|
103
97
|
export declare class ManagedStaticLifecycle {
|
|
98
|
+
private readonly config;
|
|
104
99
|
private readonly deps;
|
|
105
100
|
/** Static aliases whose startup exact-op terminal is still in flight. Scoped per alias: control
|
|
106
101
|
* serves during the sweep, but no caller can reuse or attach an alias the sweep still owns. */
|
|
@@ -118,7 +113,7 @@ export declare class ManagedStaticLifecycle {
|
|
|
118
113
|
private staticReconcileSweepsInFlight;
|
|
119
114
|
private staticReconcileDrainWaiters;
|
|
120
115
|
private staticReconcileStopping;
|
|
121
|
-
constructor(deps: ManagedStaticLifecycleDeps);
|
|
116
|
+
constructor(config: Readonly<ManagerConfig>, deps: ManagedStaticLifecycleDeps);
|
|
122
117
|
start(): void;
|
|
123
118
|
get stopping(): boolean;
|
|
124
119
|
isReconciling(alias: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managed-static-lifecycle.d.ts","sourceRoot":"","sources":["../src/managed-static-lifecycle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAoD,SAAS,EAA8C,KAAK,6BAA6B,EAAa,KAAK,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O,GAAG,OAAO,GAAG,cAAc,CAAC,GAAG,MAAM;IAI/F;qGACiG;IAC3F,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAavF,4BAA4B,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI;IA2B1E,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa1C,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8DtF;;wDAEoD;IACpD,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,GAAG,EAAE,oBAAoB,EAAE,YAAY,UAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA8D/I,2BAA2B,IAAI,IAAI;IAQnC;;wGAEoG;IAC9F,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC;IAc1C,yBAAyB,CAAC,YAAY,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAgMrE"}
|
|
@@ -25,17 +25,10 @@ const DEPROVISION_TIMEOUT_MS = 15_000;
|
|
|
25
25
|
* field the Manager assigns later is current and a member a test replaces on the instance is the one that runs. */
|
|
26
26
|
export function managedStaticLifecycleDeps(m) {
|
|
27
27
|
return {
|
|
28
|
-
space: () => m["space"],
|
|
29
|
-
servers: () => m["servers"],
|
|
30
28
|
auth: () => m["auth"],
|
|
31
|
-
secrets: () => m["secrets"],
|
|
32
|
-
workspaceRoot: () => m["workspaceRoot"],
|
|
33
29
|
instanceId: () => m["managerInstanceId"],
|
|
34
|
-
processUid: () => m["managerLifecycleUid"],
|
|
35
30
|
userMode: () => m["userMode"],
|
|
36
|
-
eventPayloadsWithheld: () => m["eventPayloadsWithheld"],
|
|
37
31
|
evictor: () => m["staticLifecycleEvict"],
|
|
38
|
-
retryDelays: () => m["staticReconcileRetryDelaysMs"],
|
|
39
32
|
resumeRequired: () => m["resumeRequired"],
|
|
40
33
|
records: () => m["goalWriter"]?.ctx.kv,
|
|
41
34
|
agentFor: (name) => m["agents"].get(name),
|
|
@@ -64,6 +57,7 @@ export function managedStaticLifecycleDeps(m) {
|
|
|
64
57
|
}
|
|
65
58
|
/** Static chat admission, credential renewal, terminal cleanup and resumable reconciliation. */
|
|
66
59
|
export class ManagedStaticLifecycle {
|
|
60
|
+
config;
|
|
67
61
|
deps;
|
|
68
62
|
/** Static aliases whose startup exact-op terminal is still in flight. Scoped per alias: control
|
|
69
63
|
* serves during the sweep, but no caller can reuse or attach an alias the sweep still owns. */
|
|
@@ -85,7 +79,8 @@ export class ManagedStaticLifecycle {
|
|
|
85
79
|
staticReconcileSweepsInFlight = 0;
|
|
86
80
|
staticReconcileDrainWaiters = [];
|
|
87
81
|
staticReconcileStopping = false;
|
|
88
|
-
constructor(deps) {
|
|
82
|
+
constructor(config, deps) {
|
|
83
|
+
this.config = config;
|
|
89
84
|
this.deps = deps;
|
|
90
85
|
}
|
|
91
86
|
start() { this.staticReconcileStopping = false; }
|
|
@@ -124,8 +119,8 @@ export class ManagedStaticLifecycle {
|
|
|
124
119
|
await acceptedRenewal.catch(() => { });
|
|
125
120
|
const opId = managedRetirementOpId(a.lifecycleUid);
|
|
126
121
|
const evict = this.deps.evictor() ?? makeManagerEndpointEvictionEvidence({
|
|
127
|
-
space: this.
|
|
128
|
-
servers: this.
|
|
122
|
+
space: this.config.space,
|
|
123
|
+
servers: this.config.servers ?? DEFAULT_SERVER,
|
|
129
124
|
auth: this.deps.auth(),
|
|
130
125
|
log: (line) => console.error(`static retirement ${a.name}: ${line}`),
|
|
131
126
|
// A daemon credential reload briefly removes its responder while it reconnects.
|
|
@@ -136,24 +131,24 @@ export class ManagedStaticLifecycle {
|
|
|
136
131
|
// inside the barrier and after the ledger rows were revoked (the source is frozen first,
|
|
137
132
|
// then the index is walked). A retirement that lost is surfaced, never skipped: an active
|
|
138
133
|
// attempt row on a retired lifecycle would authorize a run the credential no longer can.
|
|
139
|
-
const retired = await this.deps.withIssuer((i) => i.store.retireSource({ space: this.
|
|
134
|
+
const retired = await this.deps.withIssuer((i) => i.store.retireSource({ space: this.config.space, bucket: epAuthBucket(this.config.space), key: `cred.${a.lifecycleUid}` }));
|
|
140
135
|
if (retired > 0)
|
|
141
136
|
console.error(`static retirement ${a.name}: retired ${retired} issuance(s) bound to uid ${a.lifecycleUid}`);
|
|
142
|
-
const secrets = this.
|
|
143
|
-
const files = a.secretPaths ?? agentLifecycleSecretFilePaths(this.
|
|
137
|
+
const secrets = this.config.secrets;
|
|
138
|
+
const files = a.secretPaths ?? agentLifecycleSecretFilePaths(this.config.workspaceRoot, this.config.space, a.name, a.lifecycleUid);
|
|
144
139
|
// The broker teardown mints its own credential, so a creds file that cannot be removed must not
|
|
145
140
|
// skip it. The failures are thrown together, so the terminal still stops at an incomplete cleanup.
|
|
146
141
|
const failed = [];
|
|
147
142
|
if (files.creds) {
|
|
148
143
|
const creds = files.creds;
|
|
149
|
-
await attemptCleanup(failed, `secret ${creds}`, () => secrets.delete(agentSecretKeyForFile(creds, this.
|
|
144
|
+
await attemptCleanup(failed, `secret ${creds}`, () => secrets.delete(agentSecretKeyForFile(creds, this.config.space)));
|
|
150
145
|
await attemptCleanup(failed, `file ${creds}`, () => rmSync(creds, { force: true }));
|
|
151
146
|
}
|
|
152
147
|
// The lifecycle's inline snapshot, when no earlier step settled it. Keyed by the uid, so a boot
|
|
153
148
|
// sweep or a reconcile that knows only the slot row removes it too.
|
|
154
149
|
if (!a.snapshotSettled) {
|
|
155
|
-
const snapshot = inlineSnapshotPath(this.
|
|
156
|
-
await attemptCleanup(failed, `file ${snapshot}`, () => removeInlineSnapshot(this.
|
|
150
|
+
const snapshot = inlineSnapshotPath(this.config.workspaceRoot, a.lifecycleUid);
|
|
151
|
+
await attemptCleanup(failed, `file ${snapshot}`, () => removeInlineSnapshot(this.config.workspaceRoot, a.lifecycleUid));
|
|
157
152
|
}
|
|
158
153
|
await attemptCleanup(failed, "broker teardown", async () => {
|
|
159
154
|
try {
|
|
@@ -185,7 +180,7 @@ export class ManagedStaticLifecycle {
|
|
|
185
180
|
}
|
|
186
181
|
await runStaticTerminal(t, {
|
|
187
182
|
owner: DEV_OWNER, alias: a.name, actor: a.id, lifecycleUid: a.lifecycleUid, opId,
|
|
188
|
-
managerInstance: this.deps.instanceId(), managerProcessUid: this.
|
|
183
|
+
managerInstance: this.deps.instanceId(), managerProcessUid: this.config.managerLifecycleUid,
|
|
189
184
|
}, { cleanup: reapThenCleanup, evict, log: (line) => console.error(`static retirement ${a.name}: ${line}`) });
|
|
190
185
|
});
|
|
191
186
|
this.deps.recordStaticRetirement(a);
|
|
@@ -249,7 +244,7 @@ export class ManagedStaticLifecycle {
|
|
|
249
244
|
throw new EpEnvelopeError("unavailable", rejectionText(e), undefined, "not-executed");
|
|
250
245
|
}
|
|
251
246
|
try {
|
|
252
|
-
await this.deps.withLifecycleExecutor(pin, (t) => activateStaticLifecycle(t, { owner: DEV_OWNER, alias, actor: identity.id, lifecycleUid, managerInstance: this.
|
|
247
|
+
await this.deps.withLifecycleExecutor(pin, (t) => activateStaticLifecycle(t, { owner: DEV_OWNER, alias, actor: identity.id, lifecycleUid, managerInstance: this.config.managerLifecycleUid, ownerInstanceId: this.deps.instanceId() }));
|
|
253
248
|
const creds = await this.deps.withProvisioner((prov) => provisionAgent(prov, this.deps.auth(), identity, { subscribe: lists.subscribe, allowSubscribe: lists.allowSubscribe, allowPublish: lists.allowPublish, lifecycleUid, expiresAt: exp }));
|
|
254
249
|
// The same credential id the issuance path derives, so a re-sent identical credential maps to
|
|
255
250
|
// the same row.
|
|
@@ -263,7 +258,7 @@ export class ManagedStaticLifecycle {
|
|
|
263
258
|
await casStaticSlot(t, { ...slot.row, phase: "active" }, slot.revision);
|
|
264
259
|
});
|
|
265
260
|
const { sealer, sealed } = sealChatAdmission({
|
|
266
|
-
space: this.
|
|
261
|
+
space: this.config.space, managerInstanceId: this.deps.instanceId(), alias, actor: identity.id, lifecycleUid, expiresAt: exp * 1000, sealTo: input.sealTo, creds,
|
|
267
262
|
});
|
|
268
263
|
this.chatExpiry.arm(lifecycleUid);
|
|
269
264
|
console.error(`chat session ${alias} admitted as ${identity.id} (uid ${lifecycleUid}), expires ${new Date(exp * 1000).toISOString()}`);
|
|
@@ -379,7 +374,7 @@ export class ManagedStaticLifecycle {
|
|
|
379
374
|
/** Whether `row` is a chat slot this process registered, at its exact alias, actor and UID,
|
|
380
375
|
* under this logical instance and this process's incarnation. */
|
|
381
376
|
holdsLiveChatSlot(row) {
|
|
382
|
-
return row.ownerInstanceId === this.deps.instanceId() && row.managerInstance === this.
|
|
377
|
+
return row.ownerInstanceId === this.deps.instanceId() && row.managerInstance === this.config.managerLifecycleUid && this.chatExpiry.holdsExact(row);
|
|
383
378
|
}
|
|
384
379
|
/** The stop's retirement of every chat session this process still tracks, through the same
|
|
385
380
|
* ownership admission and terminal as `chat-session-retire`, at most
|
|
@@ -468,12 +463,12 @@ export class ManagedStaticLifecycle {
|
|
|
468
463
|
// Resolve this incarnation's original issuance, not its current spawner or a reconstructed
|
|
469
464
|
// run admission. Old seats and run helpers keep the exact ceiling they were minted with.
|
|
470
465
|
const caller = { owner: DEV_OWNER, actor: a.id, uid: a.lifecycleUid, generation: issued.generation };
|
|
471
|
-
const { evidence } = await withIssuerSession({ servers: this.
|
|
472
|
-
if (!grantOverreach(this.
|
|
466
|
+
const { evidence } = await withIssuerSession({ servers: this.config.servers ?? DEFAULT_SERVER, space: this.config.space, auth: this.deps.auth(), tls: false }, (s) => s.store.resolve({ space: this.config.space, ...caller }, s.sourceIsLive));
|
|
467
|
+
if (!grantOverreach(this.config.space, caller, evidence.permissions, { endpoints: reads }).length)
|
|
473
468
|
endpoints.push(...reads);
|
|
474
469
|
}
|
|
475
470
|
const creds = await this.deps.withIssuer((i) => mintCreds(this.deps.auth(), { id: a.id, seed: a.seed }, "agent", {
|
|
476
|
-
eventPayloads: this.
|
|
471
|
+
eventPayloads: this.config.eventPayloadsWithheld ? false : a.launch.eventPayloads,
|
|
477
472
|
allowSubscribe: a.launch.allowSubscribe,
|
|
478
473
|
allowPublish: a.launch.allowPublish,
|
|
479
474
|
role: a.role,
|
|
@@ -484,10 +479,10 @@ export class ManagedStaticLifecycle {
|
|
|
484
479
|
issued,
|
|
485
480
|
issuance: this.deps.issuanceSeam(i, "renew", a, exp),
|
|
486
481
|
}));
|
|
487
|
-
const secrets = this.
|
|
482
|
+
const secrets = this.config.secrets;
|
|
488
483
|
const credsPath = a.secretPaths.creds;
|
|
489
|
-
await secrets.put(agentSecretKeyForFile(credsPath, this.
|
|
490
|
-
await materializeSecretToFile(secrets, agentSecretKeyForFile(credsPath, this.
|
|
484
|
+
await secrets.put(agentSecretKeyForFile(credsPath, this.config.space), creds);
|
|
485
|
+
await materializeSecretToFile(secrets, agentSecretKeyForFile(credsPath, this.config.space), credsPath);
|
|
491
486
|
// The record pins the credential's digest, so it follows the re-signed file.
|
|
492
487
|
this.deps.refreshSeatRecord(a);
|
|
493
488
|
console.error(`managed cred renewal ${a.name}: re-signed for the same identity (exp +${exp - now}s); the agent endpoint's source re-read adopts it`);
|
|
@@ -531,7 +526,7 @@ export class ManagedStaticLifecycle {
|
|
|
531
526
|
const creds = await mintCreds(this.deps.auth(), identity, "provisioner");
|
|
532
527
|
const nc = await this.deps.dial({ ...standaloneConnectOpts({ creds, /* not yet wired to a recorded transport */ tls: false }), maxReconnectAttempts: 0 });
|
|
533
528
|
try {
|
|
534
|
-
const recordsKv = await new Kvm(nc).open(recordsBucket(this.
|
|
529
|
+
const recordsKv = await new Kvm(nc).open(recordsBucket(this.config.space));
|
|
535
530
|
return (await readStaticSlot(staticLifecycleTransport(recordsKv, recordsKv), DEV_OWNER, alias))?.row;
|
|
536
531
|
}
|
|
537
532
|
finally {
|
|
@@ -541,7 +536,7 @@ export class ManagedStaticLifecycle {
|
|
|
541
536
|
scheduleStaticReconcileRetry(key, item) {
|
|
542
537
|
if (this.staticReconcileStopping || item.timer || item.attempts >= item.maxAttempts)
|
|
543
538
|
return;
|
|
544
|
-
const delay = this.
|
|
539
|
+
const delay = this.config.staticReconcileRetryDelaysMs[item.attempts - 1];
|
|
545
540
|
if (delay === undefined)
|
|
546
541
|
return;
|
|
547
542
|
const nextRetryAtMs = Date.now() + delay;
|
|
@@ -784,8 +779,8 @@ export class ManagedStaticLifecycle {
|
|
|
784
779
|
try {
|
|
785
780
|
const jsm = await jetstreamManager(nc);
|
|
786
781
|
const kvm = new Kvm(nc);
|
|
787
|
-
await ensureAuthorityStores(jsm, kvm, this.
|
|
788
|
-
const recordsKv = await kvm.open(recordsBucket(this.
|
|
782
|
+
await ensureAuthorityStores(jsm, kvm, this.config.space);
|
|
783
|
+
const recordsKv = await kvm.open(recordsBucket(this.config.space));
|
|
789
784
|
for (const slot of await walkStaticSlots(recordsKv, DEV_OWNER))
|
|
790
785
|
slotRows.push(slot.row);
|
|
791
786
|
}
|