@cotal-ai/manager 0.171.3 → 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.
@@ -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,OAAO,EAA+C,SAAS,EAAoK,MAAM,gBAAgB,CAAC;AAC1P,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGvH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAK9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C;+GAC+G;AAC/G,MAAM,WAA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th, 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,EAAE,MAAM,gBAAgB,CAAC;AAE1P,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EA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{ Manager } from "./manager.js";
2
+ /** What {@link ConnectorInventory} reads from the Manager. Every entry is read at use, so a field the Manager
3
+ * assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
4
+ export interface ConnectorInventoryDeps {
5
+ bootNotes: () => Manager["bootNotes"];
6
+ setBootNotes: (value: Manager["bootNotes"]) => void;
7
+ connectorRequirements: () => Manager["connectorRequirements"];
8
+ setConnectorRequirements: (value: Manager["connectorRequirements"]) => void;
9
+ connectorStatuses: () => Manager["connectorStatuses"];
10
+ setConnectorStatuses: (value: Manager["connectorStatuses"]) => void;
11
+ execution: () => Manager["execution"];
12
+ installedExtensions: () => Manager["installedExtensions"];
13
+ machineSetupCommand: () => Manager["machineSetupCommand"];
14
+ classSpawnEnabled: (...args: Parameters<Manager["classSpawnEnabled"]>) => ReturnType<Manager["classSpawnEnabled"]>;
15
+ prepareClaudeWake: (...args: Parameters<Manager["prepareClaudeWake"]>) => ReturnType<Manager["prepareClaudeWake"]>;
16
+ }
17
+ /** The connector inventory taken at boot: which harnesses resolve on this host and the notes for those that do not. */
18
+ export declare class ConnectorInventory {
19
+ private readonly deps;
20
+ constructor(deps: ConnectorInventoryDeps);
21
+ private get bootNotes();
22
+ private set bootNotes(value);
23
+ private get connectorRequirements();
24
+ private set connectorRequirements(value);
25
+ private get connectorStatuses();
26
+ private set connectorStatuses(value);
27
+ private get execution();
28
+ private get installedExtensions();
29
+ private get machineSetupCommand();
30
+ private classSpawnEnabled;
31
+ private prepareClaudeWake;
32
+ /** Resolve every installed/registered connector's declared harness binaries before the manager
33
+ * reports ready. A missing harness degrades only that connector, never unrelated lifecycle work:
34
+ * boot continues, names it once start completes and records it on both manager status surfaces. */
35
+ inspectConnectorsAtBoot(): Promise<void>;
36
+ }
37
+ //# sourceMappingURL=connector-inventory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-inventory.d.ts","sourceRoot":"","sources":["../src/connector-inventory.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OA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,OAAO,KAAK,iBAAiB,QAAgF;IAC7G,OAAO,KAAK,SAAS,GAAoC;IACzD,OAAO,KAAK,mBAAmB,GAA8C;IAC7E,OAAO,KAAK,mBAAmB,GAA8C;IAC7E,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,iBAAiB;IAEzB;;uGAEmG;IAC7F,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;CAuC/C"}
@@ -0,0 +1,73 @@
1
+ import { registry, rejectionText } from "@cotal-ai/core";
2
+ import { extensionConnectors, loadExtensionsManifest, OFFICIAL_CONNECTORS } from "@cotal-ai/workspace";
3
+ import { resolveHarness } from "./harness-resolution.js";
4
+ /** The connector inventory taken at boot: which harnesses resolve on this host and the notes for those that do not. */
5
+ export class ConnectorInventory {
6
+ deps;
7
+ constructor(deps) {
8
+ this.deps = deps;
9
+ }
10
+ // The Manager members these bodies read, under their Manager names. Each reads through its dep at
11
+ // use, so a field the Manager assigns later is current and a method a test replaces on the Manager
12
+ // is the one that runs.
13
+ get bootNotes() { return this.deps.bootNotes(); }
14
+ set bootNotes(value) { this.deps.setBootNotes(value); }
15
+ get connectorRequirements() { return this.deps.connectorRequirements(); }
16
+ set connectorRequirements(value) { this.deps.setConnectorRequirements(value); }
17
+ get connectorStatuses() { return this.deps.connectorStatuses(); }
18
+ set connectorStatuses(value) { this.deps.setConnectorStatuses(value); }
19
+ get execution() { return this.deps.execution(); }
20
+ get installedExtensions() { return this.deps.installedExtensions(); }
21
+ get machineSetupCommand() { return this.deps.machineSetupCommand(); }
22
+ classSpawnEnabled(...args) { return this.deps.classSpawnEnabled(...args); }
23
+ prepareClaudeWake(...args) { return this.deps.prepareClaudeWake(...args); }
24
+ /** Resolve every installed/registered connector's declared harness binaries before the manager
25
+ * reports ready. A missing harness degrades only that connector, never unrelated lifecycle work:
26
+ * boot continues, names it once start completes and records it on both manager status surfaces. */
27
+ async inspectConnectorsAtBoot() {
28
+ this.bootNotes = [];
29
+ if (this.execution === "none") {
30
+ this.connectorStatuses = [];
31
+ return;
32
+ }
33
+ const rows = [];
34
+ let declared;
35
+ if (this.installedExtensions) {
36
+ try {
37
+ declared = loadExtensionsManifest().extensions.flatMap((ext) => extensionConnectors(ext).map((connector) => ({ ...connector, pkg: ext.pkg })));
38
+ }
39
+ catch (error) {
40
+ const reason = rejectionText(error);
41
+ this.bootNotes.push(`! manager boot: connector inventory unavailable - ${reason}`);
42
+ this.connectorStatuses = [{ agent: "(inventory)", state: "unavailable", binaries: {}, eventPlane: false, reason }];
43
+ this.bootNotes.push("! manager: no agent application is available here, so a spawn without --on goes to another manager in this space");
44
+ return;
45
+ }
46
+ }
47
+ else {
48
+ declared = registry.all("connector").map((connector) => ({
49
+ name: connector.name,
50
+ requires: connector.requires ?? [],
51
+ eventPlane: connector.eventChannel !== undefined,
52
+ }));
53
+ }
54
+ this.connectorRequirements = new Map(declared.map(({ name, requires, pkg }) => [name, {
55
+ requires, needsClaudeWake: !!this.machineSetupCommand && name === "claude" && pkg === OFFICIAL_CONNECTORS.claude,
56
+ }]));
57
+ for (const { name, requires, eventPlane } of declared) {
58
+ const { binaries, reason: missing } = resolveHarness(name, requires);
59
+ const reason = missing ?? (this.connectorRequirements.get(name)?.needsClaudeWake ? await this.prepareClaudeWake() : undefined);
60
+ if (reason) {
61
+ rows.push({ agent: name, state: "unavailable", binaries, eventPlane, reason });
62
+ this.bootNotes.push(`! manager boot: connector ${name} unavailable - ${reason}`);
63
+ }
64
+ else {
65
+ rows.push({ agent: name, state: "available", binaries, eventPlane });
66
+ }
67
+ }
68
+ this.connectorStatuses = rows.sort((a, b) => a.agent.localeCompare(b.agent));
69
+ if (!this.classSpawnEnabled())
70
+ this.bootNotes.push("! manager: no agent application is available here, so a spawn without --on goes to another manager in this space");
71
+ }
72
+ }
73
+ //# sourceMappingURL=connector-inventory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-inventory.js","sourceRoot":"","sources":["../src/connector-inventory.ts"],"names":[],"mappings":"AAAA,OAAO,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B,MAAM,EAAE,CAAC,CAAC;YACnF,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC3B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,kHAAkH,CAAC,CAAC;IAC5I,CAAC;CACF"}
@@ -0,0 +1,71 @@
1
+ import type { Connector, CotalConfig, LaunchOpts } from "@cotal-ai/core";
2
+ import type { Manager } from "./manager.js";
3
+ /** One connector's declared harness binaries resolved on PATH now. The refusal sentence is built only
4
+ * here, so the boot row and the check for a connector registered after boot can never word it apart. */
5
+ export declare function resolveHarness(name: string, requires: readonly string[]): {
6
+ binaries: Record<string, string>;
7
+ reason?: string;
8
+ };
9
+ /** What {@link HarnessResolution} reads from the Manager. Every entry is read at use, so a field the Manager
10
+ * assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
11
+ export interface HarnessResolutionDeps {
12
+ connectorStatuses: () => Manager["connectorStatuses"];
13
+ eventPayloadsWithheld: () => Manager["eventPayloadsWithheld"];
14
+ eventsRequired: () => Manager["eventsRequired"];
15
+ expectedConnectorGeneration: () => Manager["expectedConnectorGeneration"];
16
+ installedExtensions: () => Manager["installedExtensions"];
17
+ servers: () => Manager["servers"];
18
+ space: () => Manager["space"];
19
+ workspaceRoot: () => Manager["workspaceRoot"];
20
+ }
21
+ /** Resolving a connector by name and the host fields, harness binaries and capability and events refusals a launch carries. */
22
+ export declare class HarnessResolution {
23
+ private readonly deps;
24
+ constructor(deps: HarnessResolutionDeps);
25
+ private get connectorStatuses();
26
+ private get eventPayloadsWithheld();
27
+ private get eventsRequired();
28
+ private get expectedConnectorGeneration();
29
+ private get installedExtensions();
30
+ private get servers();
31
+ private get space();
32
+ private get workspaceRoot();
33
+ /** Resolve a connector by agent type. Library composition (installedExtensions off) → a registry
34
+ * hit, exactly as before (the composition root imported what it wants). The published binary gates
35
+ * on MANIFEST membership FIRST — so a live `cotal ext remove` is honored even though the registry
36
+ * still holds a connector imported earlier this session — then returns the registry hit or lazily
37
+ * imports the providing package (transactional + single-flight, via the workspace primitive).
38
+ * The captured Manager generation is checked for first-party providers under that lock,
39
+ * including providers already present in the registry.
40
+ * Fail-loud with an install hint; no fallback. */
41
+ resolveConnector(name: string): Promise<Connector>;
42
+ /** The harness binaries a managed launch runs, as boot resolved them, or the refusal naming what is
43
+ * missing. Spawn, resume and the model catalog all take it, so a seat launches from the same files
44
+ * whichever path starts it and the catalog never disagrees with a launch about whether the harness
45
+ * is there. Callers recheck unavailable rows first; available rows retain their resolved files.
46
+ * A connector registered after boot has no inventory row and is checked on PATH now. */
47
+ launchHarness(connector: Connector): {
48
+ binaries?: Readonly<Record<string, string>>;
49
+ } | {
50
+ refusal: string;
51
+ };
52
+ /** The launch fields the host supplies rather than the seat. Spawn and resume both take them from
53
+ * here, so a resumed seat launches under the same host policy, `eventsRequired` included, as the
54
+ * same seat spawned fresh. The caller passes the cotal config it judged the launch by, so the
55
+ * servers and env allowlist come from the contents its checks read. */
56
+ hostLaunchFields(cotalConfig: CotalConfig, agent: string, shareTools: readonly string[] | undefined, harness: {
57
+ binaries?: Readonly<Record<string, string>>;
58
+ }): Pick<LaunchOpts, "space" | "servers" | "mcpServers" | "mcpServersExclusive" | "envAllow" | "resolvedBinaries" | "eventsRequired" | "eventPayloads" | "workspaceRoot">;
59
+ /** The refusal for a launch choice the connector cannot honour. Spawn and resume both ask before
60
+ * a seat's launch is built, so a rule changed here holds on both paths. */
61
+ capabilityRefusal(connector: Connector, launch: {
62
+ variant?: string;
63
+ prompt?: string;
64
+ exact: boolean;
65
+ }): string | undefined;
66
+ /** The refusal for an event-plane choice the registration policy or the connector cannot meet.
67
+ * Spawn and resume both ask before a seat's launch is built, so a seat retained without the
68
+ * plane cannot come back on a space that now requires it. An absent choice arms supported planes. */
69
+ eventsRefusal(connector: Connector, events: boolean | undefined): string | undefined;
70
+ }
71
+ //# sourceMappingURL=harness-resolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-resolution.d.ts","sourceRoot":"","sources":["../src/harness-resolution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;yGACyG;AACzG,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAS/H;AAED;+GAC+G;AAC/G,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACtD,qBAAqB,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC9D,cAAc,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChD,2BAA2B,EAAE,MAAM,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC1E,mBAAmB,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC1D,OAAO,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,aAAa,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/C;AAED,+HAA+H;A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