@cotal-ai/manager 0.171.2 → 0.171.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.
Files changed (56) hide show
  1. package/dist/broker-transport.d.ts +126 -0
  2. package/dist/broker-transport.d.ts.map +1 -0
  3. package/dist/broker-transport.js +263 -0
  4. package/dist/broker-transport.js.map +1 -0
  5. package/dist/command-dispatch.d.ts +206 -0
  6. package/dist/command-dispatch.d.ts.map +1 -0
  7. package/dist/command-dispatch.js +471 -0
  8. package/dist/command-dispatch.js.map +1 -0
  9. package/dist/connector-inventory.d.ts +37 -0
  10. package/dist/connector-inventory.d.ts.map +1 -0
  11. package/dist/connector-inventory.js +73 -0
  12. package/dist/connector-inventory.js.map +1 -0
  13. package/dist/harness-resolution.d.ts +71 -0
  14. package/dist/harness-resolution.d.ts.map +1 -0
  15. package/dist/harness-resolution.js +111 -0
  16. package/dist/harness-resolution.js.map +1 -0
  17. package/dist/manager.d.ts +91 -375
  18. package/dist/manager.d.ts.map +1 -1
  19. package/dist/manager.js +400 -2811
  20. package/dist/manager.js.map +1 -1
  21. package/dist/persona-catalog.d.ts +86 -0
  22. package/dist/persona-catalog.d.ts.map +1 -0
  23. package/dist/persona-catalog.js +325 -0
  24. package/dist/persona-catalog.js.map +1 -0
  25. package/dist/preservation.d.ts +157 -0
  26. package/dist/preservation.d.ts.map +1 -0
  27. package/dist/preservation.js +583 -0
  28. package/dist/preservation.js.map +1 -0
  29. package/dist/readiness-wait.d.ts +64 -0
  30. package/dist/readiness-wait.d.ts.map +1 -0
  31. package/dist/readiness-wait.js +244 -0
  32. package/dist/readiness-wait.js.map +1 -0
  33. package/dist/runtime/index.d.ts +2 -0
  34. package/dist/runtime/index.d.ts.map +1 -1
  35. package/dist/runtime/index.js +22 -0
  36. package/dist/runtime/index.js.map +1 -1
  37. package/dist/service-adapter.d.ts.map +1 -1
  38. package/dist/service-adapter.js +6 -0
  39. package/dist/service-adapter.js.map +1 -1
  40. package/dist/spawn-goal.d.ts +77 -0
  41. package/dist/spawn-goal.d.ts.map +1 -0
  42. package/dist/spawn-goal.js +357 -0
  43. package/dist/spawn-goal.js.map +1 -0
  44. package/dist/start-doors.d.ts +51 -0
  45. package/dist/start-doors.d.ts.map +1 -0
  46. package/dist/start-doors.js +187 -0
  47. package/dist/start-doors.js.map +1 -0
  48. package/dist/status-and-models.d.ts +155 -0
  49. package/dist/status-and-models.d.ts.map +1 -0
  50. package/dist/status-and-models.js +290 -0
  51. package/dist/status-and-models.js.map +1 -0
  52. package/dist/terminal-input.d.ts +82 -0
  53. package/dist/terminal-input.d.ts.map +1 -0
  54. package/dist/terminal-input.js +266 -0
  55. package/dist/terminal-input.js.map +1 -0
  56. package/package.json +12 -12
@@ -0,0 +1,126 @@
1
+ import { dialerFor } from "@cotal-ai/core";
2
+ import type { CotalEndpoint, EpServeHandle, IssuanceSeam, IssuedStore, LifecycleStateTransport } from "@cotal-ai/core";
3
+ import type { KV } from "@nats-io/kv";
4
+ import type { NatsConnection } from "@nats-io/transport-node";
5
+ import type { Manager } from "./manager.js";
6
+ /** What {@link BrokerTransport} reads from the Manager. Every entry is read at use, so a field the Manager
7
+ * assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
8
+ export interface BrokerTransportDeps {
9
+ auth: () => Manager["auth"];
10
+ endpointServeExecutorExpiresInSeconds: () => Manager["endpointServeExecutorExpiresInSeconds"];
11
+ leaseStopping: () => Manager["leaseStopping"];
12
+ managerInstanceId: () => Manager["managerInstanceId"];
13
+ remoteAuthority: () => Manager["remoteAuthority"];
14
+ remoteBundleAdoption: () => Manager["remoteBundleAdoption"];
15
+ remoteExecutorCreds: () => Manager["remoteExecutorCreds"];
16
+ servers: () => Manager["servers"];
17
+ space: () => Manager["space"];
18
+ transportDown: () => Manager["transportDown"];
19
+ renewRemoteExecutor: (...args: Parameters<Manager["renewRemoteExecutor"]>) => ReturnType<Manager["renewRemoteExecutor"]>;
20
+ renewRemoteStandingBundle: (...args: Parameters<Manager["renewRemoteStandingBundle"]>) => ReturnType<Manager["renewRemoteStandingBundle"]>;
21
+ }
22
+ /** Dialing the broker, tracking and retiring connections, and the scoped one-shot executor connections the manager's writes ride. */
23
+ export declare class BrokerTransport {
24
+ private readonly deps;
25
+ constructor(deps: BrokerTransportDeps);
26
+ private get auth();
27
+ private get endpointServeExecutorExpiresInSeconds();
28
+ private get leaseStopping();
29
+ private get managerInstanceId();
30
+ private get remoteAuthority();
31
+ private get remoteBundleAdoption();
32
+ private get remoteExecutorCreds();
33
+ private get servers();
34
+ private get space();
35
+ private get transportDown();
36
+ private renewRemoteExecutor;
37
+ private renewRemoteStandingBundle;
38
+ /** Every broker dial this manager makes, through ONE transport decision.
39
+ *
40
+ * `this.servers` is whatever the mesh record held (`cotal supervise` reads it from there), so it
41
+ * can be a `ws://`/`wss://` broker published through an HTTPS edge. The raw node transport
42
+ * refuses such a URL instead of dialing it, so the scheme picks the dialer here rather than at
43
+ * thirteen call sites. `dialerFor` also owns the websocket transport's options, which is why
44
+ * callers below still pass their own auth options unchanged. */
45
+ dial(opts: Parameters<ReturnType<typeof dialerFor>>[0]): Promise<NatsConnection>;
46
+ /** Initial NATS timeout is per dial, not per server list. Keep the aggregate deadline too, and
47
+ * close a late result rather than letting an abandoned preflight or recovery install a transport. */
48
+ dialRemoteStanding(opts: Parameters<ReturnType<typeof dialerFor>>[0], deadline: number): Promise<NatsConnection>;
49
+ /** Retire a dedicated connection on stop: drain it while its transport is up, close it while the
50
+ * client is reconnecting it. A drain on a reconnecting connection does not fail, it waits for the
51
+ * reconnect, so the stop would last as long as the outage; a broker this connection cannot reach
52
+ * has nothing left to flush. `flush` (the serve loop's own drain) runs only while the transport is
53
+ * up. Best-effort, so a graceful stop completes its remaining teardown even when the broker is gone. */
54
+ retireConnection(nc: NatsConnection, flush?: () => Promise<unknown>): Promise<void>;
55
+ /** A failed candidate must not extend preparation by draining subscriptions on a stalled socket.
56
+ * Close only that candidate first. Native stop still owns any already-dispatched handlers, whose
57
+ * outcomes remain unknown to callers and must not be replayed; they do not hold family adoption. */
58
+ discardServeCandidate(nc: NatsConnection, handle?: EpServeHandle): Promise<void>;
59
+ /** Track a dedicated connection's transport into {@link transportDown} from the first moment:
60
+ * nats.js reports `disconnect` when the socket drops and `reconnect` only after it has re-sent the
61
+ * connection's subscriptions. If the status stream itself fails, the transport can no longer be
62
+ * observed, so it counts as down. */
63
+ trackTransport(nc: NatsConnection): void;
64
+ /** Run one static §13.1 lifecycle OPERATION over an ephemeral, key-pinned `lifecycle-executor`
65
+ * connection: the credential's grants name exactly ONE incarnation's head/uid/gate/
66
+ * cred-family/slot keys, so the write authority exists only for this operation's window and
67
+ * can move nothing else. The transport is the direct-KV binding the shared core saga drives. */
68
+ withLifecycleExecutor<T>(pin: {
69
+ owner: string;
70
+ actor: string;
71
+ lifecycleUid: string;
72
+ alias: string;
73
+ }, fn: (t: LifecycleStateTransport) => Promise<T>): Promise<T>;
74
+ /** Run one SPEC 13.15 issuance operation over an ephemeral `issuer` connection: the evidence
75
+ * stage/release of one mint, or the retirement walk of one lifecycle's issuances. The store
76
+ * handle and the accepted-row KV live only for this window; the standing supervisor holds no
77
+ * grant on either bucket. */
78
+ withIssuer<T>(fn: (i: {
79
+ store: IssuedStore;
80
+ accepted: KV;
81
+ }) => Promise<T>): Promise<T>;
82
+ /** The issuance seam of ONE static credential mint (SPEC 13.15): the evidence is bound to the
83
+ * incarnation's own `cred.<uid>` ledger family, so the family's revocation (the static
84
+ * terminal) retires every issuance that named it. The finalizer is the §13.1 ledger append
85
+ * (slot credentialId + `cred.<uid>.<credId>` row); release runs it, then activates. */
86
+ issuanceSeam(i: {
87
+ store: IssuedStore;
88
+ accepted: KV;
89
+ }, mode: "issue" | "renew", a: {
90
+ name: string;
91
+ id: string;
92
+ lifecycleUid: string;
93
+ }, exp: number): IssuanceSeam;
94
+ /** Run one §13.1 endpoint-instance maintenance operation over an ephemeral,
95
+ * key-pinned `endpoint-serve-executor` connection: the credential's grants name exactly the
96
+ * manager instance's `epgate`/`epcred` keys plus its registration's two records keys, so the
97
+ * gate CAS, mint fence, spec/governance writes, and clean deregistration ride a one-shot scoped
98
+ * authority. The remote boot goal-index sweep instead uses the authenticated host-owned scan.
99
+ * This is NEVER the manager's standing seed/supervisor connection. */
100
+ withEndpointServeExecutor<T>(fn: (kvs: {
101
+ recordsKv: KV;
102
+ authKv: KV;
103
+ nc: NatsConnection;
104
+ }) => Promise<T>): Promise<T>;
105
+ /** The open-mesh counterpart of {@link withEndpointServeExecutor}: an OPEN mesh has no
106
+ * credential system, so there is no scoped executor to mint - the same §13.1 gate/records
107
+ * writes ride a bare one-shot connection (the broker enforces nothing on an open mesh; the
108
+ * ceremony still produces the real gate, epoch, and registration the serve rails run on). */
109
+ withOpenServeConnection<T>(fn: (kvs: {
110
+ recordsKv: KV;
111
+ authKv: KV;
112
+ nc: NatsConnection;
113
+ }) => Promise<T>): Promise<T>;
114
+ /** Open a short-lived PROVISIONER connection, run the onboarding ops on it, and drain it (closure (ii),
115
+ * residual 2). The DM/DLV consumer-create surface — the irreducible onboarding power — lives only for
116
+ * this window, never as a standing grant on the long-lived supervisor. A provision-only endpoint
117
+ * (no presence/consume/channel-watch) connected with memory-only `provisioner` creds; it sets its own
118
+ * `inboxPrefix` so JS-API replies land on the `_INBOX_<id>.>` the provisioner cred subscribes. */
119
+ withProvisioner<T>(fn: (prov: CotalEndpoint) => Promise<T>): Promise<T>;
120
+ /** A connection holding this instance's transfer reader grants (docs/design/resume-transfer.md
121
+ * section 6) for this one receive or sweep: minted from the space's signing seed, or issued by the
122
+ * host to a remote manager. An open mesh enforces no grants, so a bare one-shot connection is that
123
+ * reader there. */
124
+ withTransferReader<T>(fn: (nc: NatsConnection) => Promise<T>): Promise<T>;
125
+ }
126
+ //# sourceMappingURL=broker-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-transport.d.ts","sourceRoot":"","sources":["../src/broker-transport.ts"],"names":[],"mappings":"AAAA,O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AE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAM7E;;;wBAGoB;IACd,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAgBhF"}
@@ -0,0 +1,263 @@
1
+ import { bindIssuedStores, DEFAULT_SERVER, DEV_OWNER, dialerFor, drainAndClose, ensureAuthorityStores, epAuthBucket, inspectCredHealth, mintCreds, newIdentity, principalKey, recordsBucket, rejectionText, standaloneConnectOpts } from "@cotal-ai/core";
2
+ import { jetstreamManager } from "@nats-io/jetstream";
3
+ import { Kvm } from "@nats-io/kv";
4
+ import { remoteStandingTimeLeft } from "./credential-renewal.js";
5
+ import { withScopedEndpoint } from "./endpoint-evict.js";
6
+ import { MANAGER_ENDPOINT } from "./manager-service-contract.js";
7
+ import { withTimeout } from "./manager-timeout.js";
8
+ import { appendStaticCredentialRow, recordSlotCredential, staticLifecycleTransport } from "./static-lifecycle.js";
9
+ /** Dialing the broker, tracking and retiring connections, and the scoped one-shot executor connections the manager's writes ride. */
10
+ export class BrokerTransport {
11
+ deps;
12
+ constructor(deps) {
13
+ this.deps = deps;
14
+ }
15
+ // The Manager members these bodies read, under their Manager names. Each reads through its dep at
16
+ // use, so a field the Manager assigns later is current and a method a test replaces on the Manager
17
+ // is the one that runs.
18
+ get auth() { return this.deps.auth(); }
19
+ get endpointServeExecutorExpiresInSeconds() { return this.deps.endpointServeExecutorExpiresInSeconds(); }
20
+ get leaseStopping() { return this.deps.leaseStopping(); }
21
+ get managerInstanceId() { return this.deps.managerInstanceId(); }
22
+ get remoteAuthority() { return this.deps.remoteAuthority(); }
23
+ get remoteBundleAdoption() { return this.deps.remoteBundleAdoption(); }
24
+ get remoteExecutorCreds() { return this.deps.remoteExecutorCreds(); }
25
+ get servers() { return this.deps.servers(); }
26
+ get space() { return this.deps.space(); }
27
+ get transportDown() { return this.deps.transportDown(); }
28
+ renewRemoteExecutor(...args) { return this.deps.renewRemoteExecutor(...args); }
29
+ renewRemoteStandingBundle(...args) { return this.deps.renewRemoteStandingBundle(...args); }
30
+ /** Every broker dial this manager makes, through ONE transport decision.
31
+ *
32
+ * `this.servers` is whatever the mesh record held (`cotal supervise` reads it from there), so it
33
+ * can be a `ws://`/`wss://` broker published through an HTTPS edge. The raw node transport
34
+ * refuses such a URL instead of dialing it, so the scheme picks the dialer here rather than at
35
+ * thirteen call sites. `dialerFor` also owns the websocket transport's options, which is why
36
+ * callers below still pass their own auth options unchanged. */
37
+ dial(opts) {
38
+ const servers = this.servers ?? DEFAULT_SERVER;
39
+ return dialerFor(servers)({ ...opts, servers });
40
+ }
41
+ /** Initial NATS timeout is per dial, not per server list. Keep the aggregate deadline too, and
42
+ * close a late result rather than letting an abandoned preflight or recovery install a transport. */
43
+ async dialRemoteStanding(opts, deadline) {
44
+ const ms = remoteStandingTimeLeft(deadline);
45
+ const pending = this.dial({ ...opts, timeout: ms });
46
+ try {
47
+ const nc = await withTimeout(pending, ms, "remote manager standing dial exceeded its 10000ms aggregate budget");
48
+ remoteStandingTimeLeft(deadline);
49
+ if (this.leaseStopping)
50
+ throw new Error("manager stopped while a remote standing dial was in flight");
51
+ return nc;
52
+ }
53
+ catch (e) {
54
+ // Timing out our wait does not cancel connect(). It still owns its socket until it rejects
55
+ // or returns a connection, which must close without serving or changing a current holder.
56
+ void pending.then((nc) => nc.close(), () => { }).catch((error) => console.error(`! remote manager abandoned standing dial cleanup: ${rejectionText(error)}`));
57
+ throw e;
58
+ }
59
+ }
60
+ /** Retire a dedicated connection on stop: drain it while its transport is up, close it while the
61
+ * client is reconnecting it. A drain on a reconnecting connection does not fail, it waits for the
62
+ * reconnect, so the stop would last as long as the outage; a broker this connection cannot reach
63
+ * has nothing left to flush. `flush` (the serve loop's own drain) runs only while the transport is
64
+ * up. Best-effort, so a graceful stop completes its remaining teardown even when the broker is gone. */
65
+ async retireConnection(nc, flush) {
66
+ if (this.transportDown.has(nc)) {
67
+ try {
68
+ await nc.close();
69
+ }
70
+ catch { /* best effort */ }
71
+ return;
72
+ }
73
+ if (flush)
74
+ try {
75
+ await flush();
76
+ }
77
+ catch { /* best effort */ }
78
+ try {
79
+ await drainAndClose(nc);
80
+ }
81
+ catch { /* best effort */ }
82
+ }
83
+ /** A failed candidate must not extend preparation by draining subscriptions on a stalled socket.
84
+ * Close only that candidate first. Native stop still owns any already-dispatched handlers, whose
85
+ * outcomes remain unknown to callers and must not be replayed; they do not hold family adoption. */
86
+ async discardServeCandidate(nc, handle) {
87
+ await nc.close();
88
+ if (handle)
89
+ void handle.stop().catch((e) => console.error(`! remote manager discarded serve candidate cleanup: ${rejectionText(e)}`));
90
+ }
91
+ /** Track a dedicated connection's transport into {@link transportDown} from the first moment:
92
+ * nats.js reports `disconnect` when the socket drops and `reconnect` only after it has re-sent the
93
+ * connection's subscriptions. If the status stream itself fails, the transport can no longer be
94
+ * observed, so it counts as down. */
95
+ trackTransport(nc) {
96
+ void (async () => {
97
+ for await (const st of nc.status()) {
98
+ if (st.type === "disconnect")
99
+ this.transportDown.add(nc);
100
+ else if (st.type === "reconnect")
101
+ this.transportDown.delete(nc);
102
+ }
103
+ })().catch(() => this.transportDown.add(nc));
104
+ }
105
+ /** Run one static §13.1 lifecycle OPERATION over an ephemeral, key-pinned `lifecycle-executor`
106
+ * connection: the credential's grants name exactly ONE incarnation's head/uid/gate/
107
+ * cred-family/slot keys, so the write authority exists only for this operation's window and
108
+ * can move nothing else. The transport is the direct-KV binding the shared core saga drives. */
109
+ async withLifecycleExecutor(pin, fn) {
110
+ if (!this.auth)
111
+ throw new Error("withLifecycleExecutor: no space auth (an open mesh has no lifecycle registry)");
112
+ const identity = newIdentity();
113
+ const creds = await mintCreds(this.auth, identity, "lifecycle-executor", {
114
+ lifecycleExecutor: { owner: pin.owner, actor: pin.actor, lifecycleUid: pin.lifecycleUid, alias: pin.alias },
115
+ });
116
+ const nc = await this.dial({ ...standaloneConnectOpts({ creds, /* not yet wired to a recorded transport */ tls: false }), maxReconnectAttempts: 0 });
117
+ try {
118
+ const kvm = new Kvm(nc);
119
+ const recordsKv = await kvm.open(recordsBucket(this.space));
120
+ const authKv = await kvm.open(epAuthBucket(this.space));
121
+ return await fn(staticLifecycleTransport(recordsKv, authKv));
122
+ }
123
+ finally {
124
+ await drainAndClose(nc);
125
+ }
126
+ }
127
+ /** Run one SPEC 13.15 issuance operation over an ephemeral `issuer` connection: the evidence
128
+ * stage/release of one mint, or the retirement walk of one lifecycle's issuances. The store
129
+ * handle and the accepted-row KV live only for this window; the standing supervisor holds no
130
+ * grant on either bucket. */
131
+ async withIssuer(fn) {
132
+ if (!this.auth)
133
+ throw new Error("withIssuer: no space auth (an open mesh issues nothing)");
134
+ const creds = await mintCreds(this.auth, newIdentity(), "issuer");
135
+ const nc = await this.dial({ ...standaloneConnectOpts({ creds, /* not yet wired to a recorded transport */ tls: false }), maxReconnectAttempts: 0 });
136
+ try {
137
+ const kvm = new Kvm(nc);
138
+ return await fn(await bindIssuedStores(kvm, await jetstreamManager(nc), this.space));
139
+ }
140
+ finally {
141
+ await drainAndClose(nc);
142
+ }
143
+ }
144
+ /** The issuance seam of ONE static credential mint (SPEC 13.15): the evidence is bound to the
145
+ * incarnation's own `cred.<uid>` ledger family, so the family's revocation (the static
146
+ * terminal) retires every issuance that named it. The finalizer is the §13.1 ledger append
147
+ * (slot credentialId + `cred.<uid>.<credId>` row); release runs it, then activates. */
148
+ issuanceSeam(i, mode, a, exp) {
149
+ return {
150
+ mode,
151
+ store: i.store,
152
+ accepted: i.accepted,
153
+ sources: mode === "issue" ? [{ space: this.space, bucket: epAuthBucket(this.space), key: `cred.${a.lifecycleUid}` }] : [],
154
+ finalize: async (credentialId) => {
155
+ await this.withLifecycleExecutor({ owner: DEV_OWNER, actor: a.id, lifecycleUid: a.lifecycleUid, alias: a.name }, async (t) => {
156
+ await recordSlotCredential(t, DEV_OWNER, a.name, a.lifecycleUid, credentialId);
157
+ await appendStaticCredentialRow(t, { lifecycleUid: a.lifecycleUid, credentialId, holderPrincipal: principalKey(DEV_OWNER, a.id).key, exp });
158
+ });
159
+ },
160
+ };
161
+ }
162
+ /** Run one §13.1 endpoint-instance maintenance operation over an ephemeral,
163
+ * key-pinned `endpoint-serve-executor` connection: the credential's grants name exactly the
164
+ * manager instance's `epgate`/`epcred` keys plus its registration's two records keys, so the
165
+ * gate CAS, mint fence, spec/governance writes, and clean deregistration ride a one-shot scoped
166
+ * authority. The remote boot goal-index sweep instead uses the authenticated host-owned scan.
167
+ * This is NEVER the manager's standing seed/supervisor connection. */
168
+ async withEndpointServeExecutor(fn) {
169
+ const identity = this.remoteAuthority?.identities.executor ?? newIdentity();
170
+ if (this.remoteAuthority && (!this.remoteExecutorCreds || inspectCredHealth(this.remoteExecutorCreds).state !== "healthy")) {
171
+ // Shutdown has drained and discarded the standing serve context. Renew only its scoped
172
+ // maintenance executor through the existing host operation; never resurrect standing duties.
173
+ if (this.leaseStopping)
174
+ await this.renewRemoteExecutor(true);
175
+ else if (this.remoteAuthority.renewStandingBundle) {
176
+ // The renewal drains old handlers after adopting. A handler waiting here must be
177
+ // released at adoption, not after its own completion is required by that drain.
178
+ const renewal = this.renewRemoteStandingBundle(true);
179
+ void renewal.catch((error) => console.error(`! remote manager standing renewal completion: ${rejectionText(error)}`));
180
+ await this.remoteBundleAdoption;
181
+ if (!this.remoteExecutorCreds || inspectCredHealth(this.remoteExecutorCreds).state !== "healthy") {
182
+ await renewal;
183
+ throw new Error("standing renewal did not adopt a healthy scoped executor");
184
+ }
185
+ }
186
+ else
187
+ await this.renewRemoteExecutor(true);
188
+ }
189
+ const creds = this.remoteExecutorCreds ?? (this.auth
190
+ ? await mintCreds(this.auth, identity, "endpoint-serve-executor", {
191
+ endpointServeExecutor: { endpoint: MANAGER_ENDPOINT, instanceId: this.managerInstanceId },
192
+ ...(this.endpointServeExecutorExpiresInSeconds !== undefined
193
+ ? { expiresInSeconds: this.endpointServeExecutorExpiresInSeconds }
194
+ : {}),
195
+ })
196
+ : undefined);
197
+ if (!creds)
198
+ throw new Error("withEndpointServeExecutor: no scoped executor authority (an open mesh must use the bare path)");
199
+ const nc = await this.dial({ ...standaloneConnectOpts({ creds, /* not yet wired to a recorded transport */ tls: false }), maxReconnectAttempts: 0 });
200
+ try {
201
+ const kvm = new Kvm(nc);
202
+ return await fn({ recordsKv: await kvm.open(recordsBucket(this.space)), authKv: await kvm.open(epAuthBucket(this.space)), nc });
203
+ }
204
+ finally {
205
+ await drainAndClose(nc);
206
+ }
207
+ }
208
+ /** The open-mesh counterpart of {@link withEndpointServeExecutor}: an OPEN mesh has no
209
+ * credential system, so there is no scoped executor to mint - the same §13.1 gate/records
210
+ * writes ride a bare one-shot connection (the broker enforces nothing on an open mesh; the
211
+ * ceremony still produces the real gate, epoch, and registration the serve rails run on). */
212
+ async withOpenServeConnection(fn) {
213
+ if (this.auth || this.remoteAuthority)
214
+ throw new Error("withOpenServeConnection: an authenticated mesh must use the scoped endpoint-serve executor");
215
+ const nc = await this.dial({ maxReconnectAttempts: 0 });
216
+ try {
217
+ const kvm = new Kvm(nc);
218
+ // An open mesh may be a RAW broker (no `cotal up` provisioning ran), and `Kvm.open` binds
219
+ // lazily without checking the stream exists — create-or-verify the §13.12 authority stores
220
+ // first (the same mode-neutral treatment {@link registerManagerService} gives the contract
221
+ // store), or the first gate write dies "stream not found".
222
+ await ensureAuthorityStores(await jetstreamManager(nc), kvm, this.space);
223
+ return await fn({ recordsKv: await kvm.open(recordsBucket(this.space)), authKv: await kvm.open(epAuthBucket(this.space)), nc });
224
+ }
225
+ finally {
226
+ await drainAndClose(nc);
227
+ }
228
+ }
229
+ /** Open a short-lived PROVISIONER connection, run the onboarding ops on it, and drain it (closure (ii),
230
+ * residual 2). The DM/DLV consumer-create surface — the irreducible onboarding power — lives only for
231
+ * this window, never as a standing grant on the long-lived supervisor. A provision-only endpoint
232
+ * (no presence/consume/channel-watch) connected with memory-only `provisioner` creds; it sets its own
233
+ * `inboxPrefix` so JS-API replies land on the `_INBOX_<id>.>` the provisioner cred subscribes. */
234
+ async withProvisioner(fn) {
235
+ if (!this.auth)
236
+ throw new Error("withProvisioner: no space auth (an open mesh has no scoped creds)");
237
+ // Onboarding runs several provisioning ops, so it keeps the provisioner profile's five-minute window.
238
+ return withScopedEndpoint({ space: this.space, servers: this.servers ?? DEFAULT_SERVER, auth: this.auth }, "provisioner", "provisioner", fn, 5 * 60);
239
+ }
240
+ /** A connection holding this instance's transfer reader grants (docs/design/resume-transfer.md
241
+ * section 6) for this one receive or sweep: minted from the space's signing seed, or issued by the
242
+ * host to a remote manager. An open mesh enforces no grants, so a bare one-shot connection is that
243
+ * reader there. */
244
+ async withTransferReader(fn) {
245
+ const issue = this.remoteAuthority?.mintTransferReader;
246
+ if (this.remoteAuthority && !issue)
247
+ throw new Error("withTransferReader: this manager's remote authority issues no transfer reader");
248
+ const identity = newIdentity();
249
+ const creds = issue
250
+ ? await issue(identity)
251
+ : this.auth && await mintCreds(this.auth, identity, "transfer-reader", { transferReader: { instanceId: this.managerInstanceId } });
252
+ const nc = await this.dial(creds
253
+ ? { ...standaloneConnectOpts({ creds, /* not yet wired to a recorded transport */ tls: false }), maxReconnectAttempts: 0 }
254
+ : { maxReconnectAttempts: 0 });
255
+ try {
256
+ return await fn(nc);
257
+ }
258
+ finally {
259
+ await drainAndClose(nc);
260
+ }
261
+ }
262
+ }
263
+ //# sourceMappingURL=broker-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-transport.js","sourceRoot":"","sources":["../src/broker-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,qBAAqB,EAAE,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,E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CAAC,EAAE,KAAK,EAAE,2CAA2C,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,oBAAoB,EAAE,CAAC,EAAE;YAC1H,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC,EAAE,CAAC,CAAC;QACjC,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QACtB,CAAC;gBAAS,CAAC;YACT,MAAM,aAAa,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,206 @@
1
+ import type { ControlReply, EpCaller, EpCommandDef, EpServeContext } from "@cotal-ai/core";
2
+ import type { Manager } from "./manager.js";
3
+ export declare function participantKey(owner: string, actor: string, uid: string): string;
4
+ /** What {@link CommandDispatch} reads from the Manager. Every entry is read at use, so a field the Manager
5
+ * assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
6
+ export interface CommandDispatchDeps {
7
+ agents: () => Manager["agents"];
8
+ auth: () => Manager["auth"];
9
+ execution: () => Manager["execution"];
10
+ goalWriter: () => Manager["goalWriter"];
11
+ managerInstanceId: () => Manager["managerInstanceId"];
12
+ participants: () => Manager["participants"];
13
+ remoteAuthority: () => Manager["remoteAuthority"];
14
+ resumeRequired: () => Manager["resumeRequired"];
15
+ runHosting: () => Manager["runHosting"];
16
+ space: () => Manager["space"];
17
+ transcripts: () => Manager["transcripts"];
18
+ userMode: () => Manager["userMode"];
19
+ workspaceRoot: () => Manager["workspaceRoot"];
20
+ attachAuthorized: (...args: Parameters<Manager["attachAuthorized"]>) => ReturnType<Manager["attachAuthorized"]>;
21
+ authorizeNamed: (...args: Parameters<Manager["authorizeNamed"]>) => ReturnType<Manager["authorizeNamed"]>;
22
+ authorizeRunAmend: (...args: Parameters<Manager["authorizeRunAmend"]>) => ReturnType<Manager["authorizeRunAmend"]>;
23
+ authorizeRunAnswer: (...args: Parameters<Manager["authorizeRunAnswer"]>) => ReturnType<Manager["authorizeRunAnswer"]>;
24
+ beginLifecycle: (...args: Parameters<Manager["beginLifecycle"]>) => ReturnType<Manager["beginLifecycle"]>;
25
+ despawnAuthorized: (...args: Parameters<Manager["despawnAuthorized"]>) => ReturnType<Manager["despawnAuthorized"]>;
26
+ executionRefusal: (...args: Parameters<Manager["executionRefusal"]>) => ReturnType<Manager["executionRefusal"]>;
27
+ findManagedByTarget: (...args: Parameters<Manager["findManagedByTarget"]>) => ReturnType<Manager["findManagedByTarget"]>;
28
+ inputAuthorized: (...args: Parameters<Manager["inputAuthorized"]>) => ReturnType<Manager["inputAuthorized"]>;
29
+ lifecycleMembershipRefusal: (...args: Parameters<Manager["lifecycleMembershipRefusal"]>) => ReturnType<Manager["lifecycleMembershipRefusal"]>;
30
+ list: (...args: Parameters<Manager["list"]>) => ReturnType<Manager["list"]>;
31
+ listSpawnDirectory: (...args: Parameters<Manager["listSpawnDirectory"]>) => ReturnType<Manager["listSpawnDirectory"]>;
32
+ loggedSpawnRefusal: <T>(ctx: EpServeContext, serve: () => Promise<T>) => Promise<T>;
33
+ maintenanceError: (...args: Parameters<Manager["maintenanceError"]>) => ReturnType<Manager["maintenanceError"]>;
34
+ managedPrincipal: (...args: Parameters<Manager["managedPrincipal"]>) => ReturnType<Manager["managedPrincipal"]>;
35
+ managerStatusData: (...args: Parameters<Manager["managerStatusData"]>) => ReturnType<Manager["managerStatusData"]>;
36
+ opCommitResume: (...args: Parameters<Manager["opCommitResume"]>) => ReturnType<Manager["opCommitResume"]>;
37
+ opDefinePersona: (...args: Parameters<Manager["opDefinePersona"]>) => ReturnType<Manager["opDefinePersona"]>;
38
+ opFinalizeResume: (...args: Parameters<Manager["opFinalizeResume"]>) => ReturnType<Manager["opFinalizeResume"]>;
39
+ opLaunch: (...args: Parameters<Manager["opLaunch"]>) => ReturnType<Manager["opLaunch"]>;
40
+ opListPersonas: (...args: Parameters<Manager["opListPersonas"]>) => ReturnType<Manager["opListPersonas"]>;
41
+ opModels: (...args: Parameters<Manager["opModels"]>) => ReturnType<Manager["opModels"]>;
42
+ opPreservationCtl: (...args: Parameters<Manager["opPreservationCtl"]>) => ReturnType<Manager["opPreservationCtl"]>;
43
+ opPurge: (...args: Parameters<Manager["opPurge"]>) => ReturnType<Manager["opPurge"]>;
44
+ opRemovePersona: (...args: Parameters<Manager["opRemovePersona"]>) => ReturnType<Manager["opRemovePersona"]>;
45
+ opResumePreserved: (...args: Parameters<Manager["opResumePreserved"]>) => ReturnType<Manager["opResumePreserved"]>;
46
+ opShowPersona: (...args: Parameters<Manager["opShowPersona"]>) => ReturnType<Manager["opShowPersona"]>;
47
+ opStart: (...args: Parameters<Manager["opStart"]>) => ReturnType<Manager["opStart"]>;
48
+ openStaticChatSession: (...args: Parameters<Manager["openStaticChatSession"]>) => ReturnType<Manager["openStaticChatSession"]>;
49
+ psOwnerFilter: (...args: Parameters<Manager["psOwnerFilter"]>) => ReturnType<Manager["psOwnerFilter"]>;
50
+ resolveSpawnCwd: (...args: Parameters<Manager["resolveSpawnCwd"]>) => ReturnType<Manager["resolveSpawnCwd"]>;
51
+ retireStaticChatSession: (...args: Parameters<Manager["retireStaticChatSession"]>) => ReturnType<Manager["retireStaticChatSession"]>;
52
+ runAnswerer: (...args: Parameters<Manager["runAnswerer"]>) => ReturnType<Manager["runAnswerer"]>;
53
+ runHost: (...args: Parameters<Manager["runHost"]>) => ReturnType<Manager["runHost"]>;
54
+ serveGated: <T>(ctx: EpServeContext, fn: () => T | Promise<T>) => Promise<T>;
55
+ serveObservation: <T>(ctx: EpServeContext, fn: () => T | Promise<T>) => Promise<T>;
56
+ serveSpawnGoal: (...args: Parameters<Manager["serveSpawnGoal"]>) => ReturnType<Manager["serveSpawnGoal"]>;
57
+ serveTurnCancel: (...args: Parameters<Manager["serveTurnCancel"]>) => ReturnType<Manager["serveTurnCancel"]>;
58
+ serveTurnGoal: (...args: Parameters<Manager["serveTurnGoal"]>) => ReturnType<Manager["serveTurnGoal"]>;
59
+ serveTurnParticipation: (...args: Parameters<Manager["serveTurnParticipation"]>) => ReturnType<Manager["serveTurnParticipation"]>;
60
+ serveTurnUnconfirmed: (...args: Parameters<Manager["serveTurnUnconfirmed"]>) => ReturnType<Manager["serveTurnUnconfirmed"]>;
61
+ serveTurnYield: (...args: Parameters<Manager["serveTurnYield"]>) => ReturnType<Manager["serveTurnYield"]>;
62
+ spawnPersona: (...args: Parameters<Manager["spawnPersona"]>) => ReturnType<Manager["spawnPersona"]>;
63
+ stopHandle: (...args: Parameters<Manager["stopHandle"]>) => ReturnType<Manager["stopHandle"]>;
64
+ stopWindowsSeat: (...args: Parameters<Manager["stopWindowsSeat"]>) => ReturnType<Manager["stopWindowsSeat"]>;
65
+ trackStoppedHandle: (...args: Parameters<Manager["trackStoppedHandle"]>) => ReturnType<Manager["trackStoppedHandle"]>;
66
+ turnPendingFor: (...args: Parameters<Manager["turnPendingFor"]>) => ReturnType<Manager["turnPendingFor"]>;
67
+ turnTarget: (...args: Parameters<Manager["turnTarget"]>) => ReturnType<Manager["turnTarget"]>;
68
+ }
69
+ /** The typed manager command table, the control admission both doors share, and the admin reach it reads. */
70
+ export declare class CommandDispatch {
71
+ private readonly deps;
72
+ constructor(deps: CommandDispatchDeps);
73
+ private get agents();
74
+ private get auth();
75
+ private get execution();
76
+ private get goalWriter();
77
+ private get managerInstanceId();
78
+ private get participants();
79
+ private get remoteAuthority();
80
+ private get resumeRequired();
81
+ private get runHosting();
82
+ private get space();
83
+ private get transcripts();
84
+ private get userMode();
85
+ private get workspaceRoot();
86
+ private attachAuthorized;
87
+ private authorizeNamed;
88
+ private authorizeRunAmend;
89
+ private authorizeRunAnswer;
90
+ private beginLifecycle;
91
+ private despawnAuthorized;
92
+ private executionRefusal;
93
+ private findManagedByTarget;
94
+ private inputAuthorized;
95
+ private lifecycleMembershipRefusal;
96
+ private list;
97
+ private listSpawnDirectory;
98
+ private loggedSpawnRefusal;
99
+ private maintenanceError;
100
+ private managedPrincipal;
101
+ private managerStatusData;
102
+ private opCommitResume;
103
+ private opDefinePersona;
104
+ private opFinalizeResume;
105
+ private opLaunch;
106
+ private opListPersonas;
107
+ private opModels;
108
+ private opPreservationCtl;
109
+ private opPurge;
110
+ private opRemovePersona;
111
+ private opResumePreserved;
112
+ private opShowPersona;
113
+ private opStart;
114
+ private openStaticChatSession;
115
+ private psOwnerFilter;
116
+ private resolveSpawnCwd;
117
+ private retireStaticChatSession;
118
+ private runAnswerer;
119
+ private runHost;
120
+ private serveGated;
121
+ private serveObservation;
122
+ private serveSpawnGoal;
123
+ private serveTurnCancel;
124
+ private serveTurnGoal;
125
+ private serveTurnParticipation;
126
+ private serveTurnUnconfirmed;
127
+ private serveTurnYield;
128
+ private spawnPersona;
129
+ private stopHandle;
130
+ private stopWindowsSeat;
131
+ private trackStoppedHandle;
132
+ private turnPendingFor;
133
+ private turnTarget;
134
+ /** The ONE shared control-admission chokepoint BOTH dispatch doors
135
+ * run — the v0.3 `ctl` door ({@link handle}) and the v0.4 `ep` service handlers
136
+ * ({@link serveGated}): the maintenance/resume fence (`beginLifecycle`: a resume-pending or
137
+ * non-active manager accepts no ordinary control work) and then the membership gate
138
+ * ({@link lifecycleMembershipRefusal}: a retiring/terminalizing/retired managed incarnation's
139
+ * AUTHENTICATED principal holds no control authority even with a valid JWT). Refusal carries
140
+ * WHICH fence refused so the ep door can map onto the §13.3 catalog; admission returns the
141
+ * accepted-work release. Never re-implemented per door — a fence on one door is a bypass. */
142
+ admitControl(caller: string): {
143
+ refusal: string;
144
+ fence: "maintenance" | "membership";
145
+ release?: undefined;
146
+ } | {
147
+ refusal?: undefined;
148
+ release: () => void;
149
+ };
150
+ /** The ep door's ADMIN flag for a caller. Static mesh: `true` — the
151
+ * admin-grade rows (any-mode despawn/attach, the `manager.admin` family, `launch`) are minted
152
+ * only into operator instruments (§13.2: `any` is operator-policy-mintable; the agent/spawn
153
+ * rollups never carry them), so REACHING the handler is holding the admin tier, exactly as
154
+ * holding `ctl.<admin>` is today. User mesh: the caller's CURRENT ledger scope must carry
155
+ * `admin`. A local-host manager reads its own ledger fresh. A remote-authority manager relays the
156
+ * subject-parsed caller tuple to its host-owned authorization callback, with no participant-ledger
157
+ * fallback. The same fresh authority drives {@link psOwnerFilter}, so a revoked scope demotes the
158
+ * very next call even on a still-valid bearer. Local ledger read failures authorize nothing;
159
+ * remote host-state faults throw and fail the operation closed.
160
+ * NAMED RESIDUAL: the static `true` has no serve-time re-check — a LEAKED static admin
161
+ * instrument keeps its reach until the credential's bounded
162
+ * TTL (the one-shot 5-minute profile), the same static-revoke≠reconnect-death class ruled
163
+ * across this campaign; static revocation is the TTL, not a ledger. */
164
+ epAdminReach(caller: EpCaller): Promise<boolean>;
165
+ /** A targeted request's admin flag: mode `any` (the operator instrument's cross-agent form,
166
+ * rev 3) resolves through {@link epAdminReach}; a user-mode any-mode caller whose CURRENT
167
+ * ledger row lost `admin` since its rows were minted refuses loud rather than silently
168
+ * downgrading to the owner path (the request's declared mode is honored or denied, never
169
+ * reinterpreted). Owner mode is always the privileged (own-domain) path. */
170
+ private epAnyModeAdmin;
171
+ /** The v0.4 typed command table: every ordinary handler runs the SHARED
172
+ * admission chokepoint ({@link serveGated}) and then delegates to the SAME op core the ctl
173
+ * door dispatches (one core, two thin doors). The resume/preservation family
174
+ * deliberately BYPASSES serveGated — exactly as it sits before {@link admitControl} on the ctl
175
+ * door (those ops must run while `resumeRequired` fences ordinary work) — riding its own state
176
+ * fences; its ep gate is the admin-grade `manager.admin` capability grant (static
177
+ * admin-class commands are capability-gated + untargeted, never a fabricated ledger mode).
178
+ *
179
+ * TIER SEMANTICS on the ep door: the tier lives in the CALLER'S
180
+ * GRANT, refined per-op exactly as the ctl doors refine their subject tier. Owner-mode
181
+ * `despawn`/`attach` keep the privileged semantics (`admin=false`, own-domain via
182
+ * {@link authorizeNamed}) — every spawn-capable agent holds those rows. ANY-mode requests are
183
+ * the operator instrument's cross-agent reach (rev 3): the any-mode subject row is mintable
184
+ * only under operator policy (§13.2), so on a static mesh holding it IS the admin tier, and in
185
+ * user mode the caller's CURRENT ledger scope must still carry `admin`
186
+ * ({@link epAdminReach}, the same fresh-read authority `psOwnerFilter` consults). The
187
+ * `manager.admin` family (purge + the resume/preservation ops) is capability-gated at mint AND
188
+ * re-checked at serve time via {@link epAdminReach} (the `adminGated` wrapper) so a user's
189
+ * revoked scope demotes the next call. `launch` is OWNER-EQUALITY on this door for everyone:
190
+ * the deploy path is its only consumer and stamps the caller's own owner,
191
+ * so cross-owner launch was a ctl-tier incidental never exercised, and keying it on the actor's
192
+ * ledger scope broke the deployer-view attenuation - uniform owner-equality is the safe tier.
193
+ * TWO DELIBERATE NARROWINGS vs the ctl doors (NOT bit-exact parity): (1)
194
+ * `define-persona` is `admin=false` for everyone (own-persona discipline; no ep consumer needs
195
+ * cross-owner persona writes - an operator redefines via config, not the wire), where the ctl
196
+ * admin tier allowed operator cross-owner redefine; (2) launch is owner-equality-only, above.
197
+ * Both are least-privilege reductions, never widenings. */
198
+ managerServiceDefs(): EpCommandDef[];
199
+ /** Self-despawn (P2b): stop the managed agent whose id == the authenticated caller. The
200
+ * no-name self-op can only ever resolve to the caller's OWN managed entry (ids are unique
201
+ * per spawn + non-forgeable in auth mode), never a peer — so it's structurally incapable of
202
+ * hitting another agent. Non-managed callers (human CLI, the manager itself, observers) find
203
+ * no match and get a loud error, not a silent no-op. */
204
+ opStopSelf(callerId: string, args: Record<string, unknown>): ControlReply | Promise<ControlReply>;
205
+ }
206
+ //# sourceMappingURL=command-dispatch.d.ts.map