@cotal-ai/manager 0.16.0 → 0.17.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/attach-endpoint.d.ts +53 -59
- package/dist/attach-endpoint.d.ts.map +1 -1
- package/dist/attach-endpoint.js +120 -244
- package/dist/attach-endpoint.js.map +1 -1
- package/dist/commands.js +9 -4
- package/dist/commands.js.map +1 -1
- package/dist/console/app.js +68 -30
- package/dist/console/index.html +3 -2
- package/dist/console/session-bundle.js +9736 -0
- package/dist/console-crypto-shim.d.ts +16 -0
- package/dist/console-crypto-shim.d.ts.map +1 -0
- package/dist/console-crypto-shim.js +20 -0
- package/dist/console-crypto-shim.js.map +1 -0
- package/dist/console-session-entry.d.ts +2 -0
- package/dist/console-session-entry.d.ts.map +1 -0
- package/dist/console-session-entry.js +26 -0
- package/dist/console-session-entry.js.map +1 -0
- package/dist/endpoint-evict.d.ts +29 -0
- package/dist/endpoint-evict.d.ts.map +1 -0
- package/dist/endpoint-evict.js +80 -0
- package/dist/endpoint-evict.js.map +1 -0
- package/dist/manager-service-contract.d.ts +132 -0
- package/dist/manager-service-contract.d.ts.map +1 -0
- package/dist/manager-service-contract.js +332 -0
- package/dist/manager-service-contract.js.map +1 -0
- package/dist/manager.d.ts +504 -22
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +2193 -257
- package/dist/manager.js.map +1 -1
- package/dist/runtime/pty.d.ts.map +1 -1
- package/dist/runtime/pty.js +15 -2
- package/dist/runtime/pty.js.map +1 -1
- package/dist/session/bridge.d.ts +63 -0
- package/dist/session/bridge.d.ts.map +1 -0
- package/dist/session/bridge.js +157 -0
- package/dist/session/bridge.js.map +1 -0
- package/dist/session/establish.d.ts +212 -0
- package/dist/session/establish.d.ts.map +1 -0
- package/dist/session/establish.js +174 -0
- package/dist/session/establish.js.map +1 -0
- package/dist/session/index.d.ts +12 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +15 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/plane.d.ts +120 -0
- package/dist/session/plane.d.ts.map +1 -0
- package/dist/session/plane.js +327 -0
- package/dist/session/plane.js.map +1 -0
- package/dist/static-lifecycle.d.ts +97 -0
- package/dist/static-lifecycle.d.ts.map +1 -0
- package/dist/static-lifecycle.js +262 -0
- package/dist/static-lifecycle.js.map +1 -0
- package/package.json +9 -5
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A build-time `node:crypto` shim for the console session bundle (P2 item 6). The core §13.6 rail
|
|
3
|
+
* (endpoint-session-rail) + terminal-frame codec (session-terminal-frames) transitively import
|
|
4
|
+
* `node:crypto` at MODULE level — via endpoint-envelope → canonical.js (`createHash`) and
|
|
5
|
+
* endpoint-subjects → subjects.js (`randomBytes`) — but they NEVER invoke hashing or uid-minting at
|
|
6
|
+
* runtime (the rail moves bytes + derives subjects; the grant mint/verify that hashes stays on the
|
|
7
|
+
* node side). esbuild aliases `node:crypto` to this so the module-level imports RESOLVE for the
|
|
8
|
+
* browser.
|
|
9
|
+
*
|
|
10
|
+
* Both entries THROW LOUD if ever called: a reached call means the browser bundle started
|
|
11
|
+
* hashing / uid-minting, which is a bug (the wrong code got pulled in), never a silent degrade — so
|
|
12
|
+
* this is a fail-loud boundary, not a fallback.
|
|
13
|
+
*/
|
|
14
|
+
export declare function randomBytes(): never;
|
|
15
|
+
export declare function createHash(): never;
|
|
16
|
+
//# sourceMappingURL=console-crypto-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-crypto-shim.d.ts","sourceRoot":"","sources":["../src/console-crypto-shim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,IAAI,KAAK,CAEnC;AAED,wBAAgB,UAAU,IAAI,KAAK,CAElC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A build-time `node:crypto` shim for the console session bundle (P2 item 6). The core §13.6 rail
|
|
3
|
+
* (endpoint-session-rail) + terminal-frame codec (session-terminal-frames) transitively import
|
|
4
|
+
* `node:crypto` at MODULE level — via endpoint-envelope → canonical.js (`createHash`) and
|
|
5
|
+
* endpoint-subjects → subjects.js (`randomBytes`) — but they NEVER invoke hashing or uid-minting at
|
|
6
|
+
* runtime (the rail moves bytes + derives subjects; the grant mint/verify that hashes stays on the
|
|
7
|
+
* node side). esbuild aliases `node:crypto` to this so the module-level imports RESOLVE for the
|
|
8
|
+
* browser.
|
|
9
|
+
*
|
|
10
|
+
* Both entries THROW LOUD if ever called: a reached call means the browser bundle started
|
|
11
|
+
* hashing / uid-minting, which is a bug (the wrong code got pulled in), never a silent degrade — so
|
|
12
|
+
* this is a fail-loud boundary, not a fallback.
|
|
13
|
+
*/
|
|
14
|
+
export function randomBytes() {
|
|
15
|
+
throw new Error("node:crypto.randomBytes is not available in the console session bundle (the §13.6 rail/codec never mint uids in-browser; a reached call is a bug)");
|
|
16
|
+
}
|
|
17
|
+
export function createHash() {
|
|
18
|
+
throw new Error("node:crypto.createHash is not available in the console session bundle (the §13.6 rail/codec never hash in-browser; a reached call is a bug)");
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=console-crypto-shim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-crypto-shim.js","sourceRoot":"","sources":["../src/console-crypto-shim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,IAAI,KAAK,CAAC,mJAAmJ,CAAC,CAAC;AACvK,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,KAAK,CAAC,6IAA6I,CAAC,CAAC;AACjK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-session-entry.d.ts","sourceRoot":"","sources":["../src/console-session-entry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The manager console's browser session-client bundle ENTRY (P2 item 6). esbuild bundles this (and
|
|
3
|
+
* ONLY this: the browser-safe core subpath + nats-core's ws connect) into
|
|
4
|
+
* `dist/console/session-bundle.js`, served as a static asset. It runs IN THE BROWSER — the manager's
|
|
5
|
+
* node side never imports it (nats-core's ws path is baked into the bundle at build time; node rides
|
|
6
|
+
* `@nats-io/transport-node`).
|
|
7
|
+
*
|
|
8
|
+
* It exposes the core §13.6 rail + terminal-frame codec + `wsconnect` on one global so the console
|
|
9
|
+
* page can open a mesh session CALLER without a module loader: connect over the broker's websocket
|
|
10
|
+
* listener with the per-session, rails-only credential the loopback face hands it, open the caller
|
|
11
|
+
* rail with the redeemed grant, and drive xterm — the SAME core rail code the manager serves.
|
|
12
|
+
*/
|
|
13
|
+
import { wsconnect, credsAuthenticator } from "@nats-io/nats-core";
|
|
14
|
+
import { openSessionRail, encodeTerminalData, terminalFrameBytes, decodeTerminalFrame, } from "@cotal-ai/core/session-browser";
|
|
15
|
+
// A single browser global (no module system in the served console page). `credsAuthenticator` lets
|
|
16
|
+
// the page present the per-session, rails-only caller credential the loopback face minted (static
|
|
17
|
+
// mesh); an open mesh hands empty creds and the page connects bare.
|
|
18
|
+
globalThis.CotalSession = {
|
|
19
|
+
wsconnect,
|
|
20
|
+
credsAuthenticator,
|
|
21
|
+
openSessionRail,
|
|
22
|
+
encodeTerminalData,
|
|
23
|
+
terminalFrameBytes,
|
|
24
|
+
decodeTerminalFrame,
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=console-session-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-session-entry.js","sourceRoot":"","sources":["../src/console-session-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AAExC,mGAAmG;AACnG,kGAAkG;AAClG,oEAAoE;AACnE,UAAmD,CAAC,YAAY,GAAG;IAClE,SAAS;IACT,kBAAkB;IAClB,eAAe;IACf,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;CACpB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The manager's VERIFIED-EVICTION seam for its own endpoint-registration barrier (SPEC 13.1, P2
|
|
3
|
+
* item 3, slice 3a). A restart re-registers the SAME logical instanceId with an ADVANCED epoch, and
|
|
4
|
+
* §13.1 requires the SUPERSEDED serve family to die BEFORE the new authority is visible — so the
|
|
5
|
+
* registration barrier's PHASE 2 must VERIFY-EVICT the predecessor's serve principal. The `$SYS`
|
|
6
|
+
* scan → KICK → verify capability lives with the DELIVERY DAEMON (co-located with the broker), never
|
|
7
|
+
* in this process (the manager holds the DATA signing seed; the D5 rail-split keeps `$SYS` material
|
|
8
|
+
* out of any seed-holder). This reaches the daemon over the privileged `ctl.delivery-admin` rail
|
|
9
|
+
* with a per-call SCOPED `endpoint-evictor` credential (pub the delivery-admin subject + reply +
|
|
10
|
+
* `$JS.API.INFO`, nothing else — narrower than the `supervisor` profile auth's barrier-evict reuses).
|
|
11
|
+
*
|
|
12
|
+
* NO-ORACLE = LOUD (no-fallbacks): if the daemon is unreachable the evictor THROWS an error NAMING
|
|
13
|
+
* THE CURE, so the barrier's PHASE-2 failure carries it and the gate stays frozen for reconciliation
|
|
14
|
+
* — a crash-restart on an auth mesh NEVER skips eviction. A reachable daemon that reports the
|
|
15
|
+
* principal still connected (or a garbled/contradictory result) returns `false` (not verified),
|
|
16
|
+
* which the barrier also treats as fail-closed. Verified-gone is conclusive only as (scan complete,
|
|
17
|
+
* none remain).
|
|
18
|
+
*/
|
|
19
|
+
import { type SpaceAuth } from "@cotal-ai/core";
|
|
20
|
+
/** Build the registration barrier's `evict(holderPrincipal) → verifiedGone` over the delivery
|
|
21
|
+
* daemon's `ctl.delivery-admin` rail. Per-call connection (eviction is a rare, heavyweight barrier
|
|
22
|
+
* step; a standing privileged connection would be a wider surface holding nothing). */
|
|
23
|
+
export declare function makeManagerEndpointEvictor(opts: {
|
|
24
|
+
space: string;
|
|
25
|
+
servers: string;
|
|
26
|
+
auth: SpaceAuth;
|
|
27
|
+
log: (line: string) => void;
|
|
28
|
+
}): (holderPrincipal: string) => Promise<boolean>;
|
|
29
|
+
//# sourceMappingURL=endpoint-evict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-evict.d.ts","sourceRoot":"","sources":["../src/endpoint-evict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAA8D,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE5G;;wFAEwF;AACxF,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,GAAG,CAAC,eAAe,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CA0DhD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The manager's VERIFIED-EVICTION seam for its own endpoint-registration barrier (SPEC 13.1, P2
|
|
3
|
+
* item 3, slice 3a). A restart re-registers the SAME logical instanceId with an ADVANCED epoch, and
|
|
4
|
+
* §13.1 requires the SUPERSEDED serve family to die BEFORE the new authority is visible — so the
|
|
5
|
+
* registration barrier's PHASE 2 must VERIFY-EVICT the predecessor's serve principal. The `$SYS`
|
|
6
|
+
* scan → KICK → verify capability lives with the DELIVERY DAEMON (co-located with the broker), never
|
|
7
|
+
* in this process (the manager holds the DATA signing seed; the D5 rail-split keeps `$SYS` material
|
|
8
|
+
* out of any seed-holder). This reaches the daemon over the privileged `ctl.delivery-admin` rail
|
|
9
|
+
* with a per-call SCOPED `endpoint-evictor` credential (pub the delivery-admin subject + reply +
|
|
10
|
+
* `$JS.API.INFO`, nothing else — narrower than the `supervisor` profile auth's barrier-evict reuses).
|
|
11
|
+
*
|
|
12
|
+
* NO-ORACLE = LOUD (no-fallbacks): if the daemon is unreachable the evictor THROWS an error NAMING
|
|
13
|
+
* THE CURE, so the barrier's PHASE-2 failure carries it and the gate stays frozen for reconciliation
|
|
14
|
+
* — a crash-restart on an auth mesh NEVER skips eviction. A reachable daemon that reports the
|
|
15
|
+
* principal still connected (or a garbled/contradictory result) returns `false` (not verified),
|
|
16
|
+
* which the barrier also treats as fail-closed. Verified-gone is conclusive only as (scan complete,
|
|
17
|
+
* none remain).
|
|
18
|
+
*/
|
|
19
|
+
import { CotalEndpoint, mintCreds, newIdentity } from "@cotal-ai/core";
|
|
20
|
+
/** Build the registration barrier's `evict(holderPrincipal) → verifiedGone` over the delivery
|
|
21
|
+
* daemon's `ctl.delivery-admin` rail. Per-call connection (eviction is a rare, heavyweight barrier
|
|
22
|
+
* step; a standing privileged connection would be a wider surface holding nothing). */
|
|
23
|
+
export function makeManagerEndpointEvictor(opts) {
|
|
24
|
+
return async (principal) => {
|
|
25
|
+
const id = newIdentity();
|
|
26
|
+
let ep;
|
|
27
|
+
try {
|
|
28
|
+
// A per-eviction SCOPED cred for ONE ~15s delivery-admin call (60s TTL bounds a copied cred to
|
|
29
|
+
// a minute). endpoint-evictor holds EXACTLY its own delivery-admin request+reply rail — no
|
|
30
|
+
// lease, presence, store, consumer, KV, or executing right.
|
|
31
|
+
const creds = await mintCreds(opts.auth, id, "endpoint-evictor", { expiresInSeconds: 60 });
|
|
32
|
+
ep = new CotalEndpoint({
|
|
33
|
+
space: opts.space,
|
|
34
|
+
servers: opts.servers,
|
|
35
|
+
creds,
|
|
36
|
+
card: { id: id.id, name: "manager-endpoint-evict", kind: "endpoint" },
|
|
37
|
+
channels: [],
|
|
38
|
+
consume: false,
|
|
39
|
+
watchChannels: false,
|
|
40
|
+
watchPresence: false,
|
|
41
|
+
registerPresence: false,
|
|
42
|
+
});
|
|
43
|
+
ep.on("error", () => { });
|
|
44
|
+
await ep.start();
|
|
45
|
+
const r = await ep.requestDeliveryAdmin("evictPrincipal", { principal }, 15_000);
|
|
46
|
+
if (!r.ok) {
|
|
47
|
+
// The daemon is REACHABLE but refused (e.g. the principal is still connected — a genuine live
|
|
48
|
+
// predecessor). Not verified gone → fail-closed (the barrier leaves the gate frozen).
|
|
49
|
+
opts.log(`manager-endpoint-evict: ${principal}: the delivery daemon refused the eviction: ${r.error ?? "(no error copy)"}`);
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const d = r.data;
|
|
53
|
+
if (d === undefined || d === null || d.principal !== principal ||
|
|
54
|
+
typeof d.kicked !== "number" || !Number.isSafeInteger(d.kicked) || d.kicked < 0 ||
|
|
55
|
+
typeof d.remaining !== "number" || !Number.isSafeInteger(d.remaining) || d.remaining < 0 ||
|
|
56
|
+
typeof d.verifiedGone !== "boolean" || typeof d.scanComplete !== "boolean") {
|
|
57
|
+
opts.log(`manager-endpoint-evict: ${principal}: garbled or foreign eviction result (${JSON.stringify(r.data ?? null)}); a result that does not verifiably describe this principal never authorizes`);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
// An internally CONTRADICTORY success never authorizes (verified-gone is (scan complete, none remain)).
|
|
61
|
+
if (d.verifiedGone === true && (d.scanComplete !== true || d.remaining !== 0)) {
|
|
62
|
+
opts.log(`manager-endpoint-evict: ${principal}: verifiedGone with scanComplete=${String(d.scanComplete)} remaining=${d.remaining}; a contradictory result never authorizes`);
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return d.verifiedGone === true;
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
// NO-ORACLE = LOUD (pin 3, SPEC 13.1, no-fallbacks): the delivery-admin rail is unreachable, so
|
|
69
|
+
// eviction is UNKNOWN. THROW naming the cure so the barrier's PHASE-2 error carries it and the
|
|
70
|
+
// gate stays frozen — never a silent skip that could resurrect old-epoch authority.
|
|
71
|
+
throw new Error(`the delivery daemon is not reachable on the ctl.delivery-admin rail (${e instanceof Error ? e.message : String(e)}); ` +
|
|
72
|
+
`a restart on an auth mesh cannot verify-evict the superseded serve family principal "${principal}" without the liveness oracle. ` +
|
|
73
|
+
`Start the delivery daemon (\`cotal up\` runs it) and retry — eviction is never skipped (SPEC 13.1)`);
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
await ep?.stop().catch(() => { });
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=endpoint-evict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-evict.js","sourceRoot":"","sources":["../src/endpoint-evict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAuC,MAAM,gBAAgB,CAAC;AAE5G;;wFAEwF;AACxF,MAAM,UAAU,0BAA0B,CAAC,IAK1C;IACC,OAAO,KAAK,EAAE,SAAiB,EAAoB,EAAE;QACnD,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;QACzB,IAAI,EAA6B,CAAC;QAClC,IAAI,CAAC;YACH,+FAA+F;YAC/F,2FAA2F;YAC3F,4DAA4D;YAC5D,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,kBAAkB,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;YAC3F,EAAE,GAAG,IAAI,aAAa,CAAC;gBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,KAAK;gBACL,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EA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,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,+EAA+E,CAAC,CAAC;gBACrM,OAAO,KAAK,CAAC;YACf,CAAC;YACD,wGAAwG;YACxG,IAAI,CAAC,CAAC,YAAY,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC9E,IAAI,CAAC,GAAG,CAAC,2BAA2B,SAAS,oCAAoC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,SAAS,2CAA2C,CAAC,CAAC;gBAC7K,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,CAAC,CAAC,YAAY,KAAK,IAAI,CAAC;QACjC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,gGAAgG;YAChG,+FAA+F;YAC/F,oFAAoF;YACpF,MAAM,IAAI,KAAK,CACb,wEAAwE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;gBACvH,wFAAwF,SAAS,iCAAiC;gBAClI,oGAAoG,CACrG,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The manager's v0.4 SERVICE CONTRACT (control-surface P2 item 1): the §13.7 cluster document +
|
|
3
|
+
* compiled command contracts that let the manager register as an ordinary `service` endpoint and
|
|
4
|
+
* serve typed commands on the `ep.*` rails, dual-served beside its bespoke
|
|
5
|
+
* `ctl.<tier>.<owner>.<actor>` control subjects until 1d deletes those.
|
|
6
|
+
*
|
|
7
|
+
* This module is PURE DATA + schema (no broker, no barrier, no wire I/O): the content-addressed
|
|
8
|
+
* cluster document (the authority for every command's served shape) and the provenance-branded
|
|
9
|
+
* `compileContract` pairs each `EpCommandDef` must carry. The registration/serve WIRING lives in
|
|
10
|
+
* the manager (`registerManagerService`).
|
|
11
|
+
*
|
|
12
|
+
* REVISION 2 (slice 1b): the FULL op fan-out. Every served `ctl` op maps to a typed command; the
|
|
13
|
+
* v0.3 op names map onto the Appendix-B caller vocabulary where one exists (`start` -> `spawn`;
|
|
14
|
+
* the named `stop` -> `despawn` — on the v0.3 surface a named stop and a despawn are the same
|
|
15
|
+
* terminal; the self no-name `stop` -> `stop` with authz-mode `self`; the per-agent `status`
|
|
16
|
+
* read -> `inspect`, distinct from the 1a manager-level `status`). Targeting: `despawn`/`attach`
|
|
17
|
+
* ride owner mode (the target block names the agent's principal + lifecycle uid; the fresh
|
|
18
|
+
* resolver checks currency). `child` mode is DELIBERATELY NOT DECLARED anywhere — the panel's 1b
|
|
19
|
+
* gate requires a DURABLE spawner record before child mode exists, so it fails closed by absence
|
|
20
|
+
* until that record lands; own-child narrowing on despawn/attach meanwhile rides the SAME
|
|
21
|
+
* `authorizeNamedControl` policy the ctl privileged tier runs (in-memory spawner, identical
|
|
22
|
+
* source both doors). `ledger` mode is likewise absent (admin != ledger in static mode): every
|
|
23
|
+
* admin-class command is untargeted + capability-gated — the broker grant (who holds the
|
|
24
|
+
* request-publish row) stays the load-bearing tier boundary, exactly as the ctl cred layer is
|
|
25
|
+
* today; the 1c migration table names who mints which capability.
|
|
26
|
+
*
|
|
27
|
+
* Capability labels (describe/grant vocabulary, one per tier class):
|
|
28
|
+
* manager.read status / ps / inspect / models (read-only)
|
|
29
|
+
* manager.spawn spawn (privileged-grade creation)
|
|
30
|
+
* manager.lifecycle despawn / attach (owner-mode terminal/interactive)
|
|
31
|
+
* manager.self stop (self-mode halt; baseline)
|
|
32
|
+
* manager.persona definePersona (privileged-grade; ownership-checked)
|
|
33
|
+
* manager.admin purge / launch / resume family (operator instruments only)
|
|
34
|
+
*/
|
|
35
|
+
import { type CompiledContract, type EpAuthzMode, type EpCommandDef, type EpServeContext } from "@cotal-ai/core";
|
|
36
|
+
/** The manager's endpoint NAME — a core single-label name (needs OPERATOR name authority at
|
|
37
|
+
* registration; the manager holds the space signing seed, so it self-authorizes). */
|
|
38
|
+
export declare const MANAGER_ENDPOINT = "manager";
|
|
39
|
+
/** The manager cluster document's URN (§13.7 content-addressed authority). */
|
|
40
|
+
export declare const MANAGER_CLUSTER_URN = "ai.cotal.manager";
|
|
41
|
+
/** The typed shape a `status` invocation returns (the compiled output contract validates it). */
|
|
42
|
+
export interface ManagerStatus {
|
|
43
|
+
instanceId: string;
|
|
44
|
+
runtime: string;
|
|
45
|
+
agentCount: number;
|
|
46
|
+
uptimeMs: number;
|
|
47
|
+
}
|
|
48
|
+
/** Per-command compiled contract pairs, exported for CALLERS (`epCall` pins the same digests the
|
|
49
|
+
* cluster document registers; the generic invoke CLI compiles these from the STORE instead). */
|
|
50
|
+
export declare const MANAGER_CONTRACTS: Readonly<Record<string, {
|
|
51
|
+
input: CompiledContract;
|
|
52
|
+
output: CompiledContract;
|
|
53
|
+
}>>;
|
|
54
|
+
/** Every §13.7 contract artifact the manager PUBLISHES to the EPC store at registration (P2 item
|
|
55
|
+
* 1, 1c): each DISTINCT schema root plus its single-member closure manifest — the two artifacts
|
|
56
|
+
* a caller fetches at a command's input/output CLOSURE digest (`fetchContractClosure` walks
|
|
57
|
+
* manifest → root) to recompile the digest-matching validators. The cluster document + ITS
|
|
58
|
+
* manifest ride separately ({@link managerClusterArtifacts}). */
|
|
59
|
+
export declare function managerContractArtifactValues(): unknown[];
|
|
60
|
+
/** The 1a `status` pair, kept as a named export (existing callers/smokes). */
|
|
61
|
+
export declare const MANAGER_STATUS_CONTRACT: {
|
|
62
|
+
input: CompiledContract;
|
|
63
|
+
output: CompiledContract;
|
|
64
|
+
};
|
|
65
|
+
/** The §13.7 cluster DOCUMENT: the content-addressed authority for the manager's served command
|
|
66
|
+
* surface. Revisions: 3 = the 1c any-mode despawn/attach admission; 4 = item-2's spawn-as-action;
|
|
67
|
+
* 5 = item-6's `attach` output flip (ws:// URL → the holder-bound §13.6 session grant).
|
|
68
|
+
*
|
|
69
|
+
* 6 = `launch` accepts the inline `spec` of a remote manifest deploy. The handler branch for it
|
|
70
|
+
* merged in ahead of the schema, so the compiled contract refused every request that carried the
|
|
71
|
+
* field and the feature was unreachable through this door (executed: the compiled input validator
|
|
72
|
+
* returned false for `{runId, name, spec}` while the CLI sends exactly that). ONE revision 6
|
|
73
|
+
* covers the whole branch: when the journal-action work lands, its `action` marker and
|
|
74
|
+
* `readinessDeadlineMs` declaration join THIS revision rather than minting a seventh. */
|
|
75
|
+
export declare function managerClusterDocument(): {
|
|
76
|
+
urn: string;
|
|
77
|
+
revision: number;
|
|
78
|
+
attributes: never[];
|
|
79
|
+
events: never[];
|
|
80
|
+
commands: Array<{
|
|
81
|
+
name: string;
|
|
82
|
+
class: "ephemeral";
|
|
83
|
+
targeted: boolean;
|
|
84
|
+
modes?: EpAuthzMode[];
|
|
85
|
+
capability: string;
|
|
86
|
+
inputDigest: string;
|
|
87
|
+
outputDigest: string;
|
|
88
|
+
}>;
|
|
89
|
+
};
|
|
90
|
+
/** The two-digest §13.7 content addressing for the manager document: the registered CLOSURE digest
|
|
91
|
+
* names a `{v:1, root:<artifactDigest>, members:[]}` manifest whose root names the DOCUMENT. Both
|
|
92
|
+
* artifacts are published to the `epc` store at their own digest; `clusterDigests` in the service
|
|
93
|
+
* spec carries the closure digest. Returned together so the manager publishes both then registers
|
|
94
|
+
* under the closure digest. */
|
|
95
|
+
export declare function managerClusterArtifacts(): {
|
|
96
|
+
document: ReturnType<typeof managerClusterDocument>;
|
|
97
|
+
rootDigest: string;
|
|
98
|
+
manifest: {
|
|
99
|
+
v: 1;
|
|
100
|
+
root: string;
|
|
101
|
+
members: string[];
|
|
102
|
+
};
|
|
103
|
+
closureDigest: string;
|
|
104
|
+
};
|
|
105
|
+
/** The handlers the manager supplies to back each served command. Each receives the serve
|
|
106
|
+
* CONTEXT (the broker-authenticated subject shape beside the validated args/target) so the
|
|
107
|
+
* manager can run its shared admission chokepoint and derive the caller principal; each returns
|
|
108
|
+
* the command's output value (the compiled output contract validates it at the serve boundary).
|
|
109
|
+
* Kept as a narrow interface so the contract module stays broker-free. */
|
|
110
|
+
export interface ManagerServiceHandlers {
|
|
111
|
+
status(ctx: EpServeContext): ManagerStatus | Promise<ManagerStatus>;
|
|
112
|
+
ps(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
113
|
+
inspect(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
114
|
+
models(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
115
|
+
spawn(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
116
|
+
despawn(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
117
|
+
attach(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
118
|
+
stopSelf(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
119
|
+
definePersona(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
120
|
+
purge(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
121
|
+
launch(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
122
|
+
resumePreserved(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
123
|
+
commitResume(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
124
|
+
finalizeResume(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
125
|
+
preparePreservation(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
126
|
+
commitPreservation(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
127
|
+
abortPreservation(ctx: EpServeContext): unknown | Promise<unknown>;
|
|
128
|
+
}
|
|
129
|
+
/** Build the `EpCommandDef[]` `serveEndpoint` consumes: each command's provenance-branded compiled
|
|
130
|
+
* contracts (matching the document's pinned digests exactly) plus its handler. */
|
|
131
|
+
export declare function managerCommandDefs(handlers: ManagerServiceHandlers): EpCommandDef[];
|
|
132
|
+
//# sourceMappingURL=manager-service-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager-service-contract.d.ts","sourceRoot":"","sources":["../src/manager-service-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAExB;sFACsF;AACtF,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAqBtD,iGAAiG;AACjG,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AA2OD;iGACiG;AACjG,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC,CACrF,CAAC;AAE1B;;;;kEAIkE;AAClE,wBAAgB,6BAA6B,IAAI,OAAO,EAAE,CAYzD;AAED,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,EAAE;IAAE,KAAK,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAA6B,CAAC;AAEvH;;;;;;;;;0FAS0F;AAC1F,wBAAgB,sBAAsB,IAAI;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,KAAK,EAAE,CAAC;IACpB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,K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