@cotal-ai/manager 0.174.2 → 0.174.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/boot.d.ts +3 -17
  2. package/dist/boot.d.ts.map +1 -1
  3. package/dist/boot.js +48 -62
  4. package/dist/boot.js.map +1 -1
  5. package/dist/broker-transport.d.ts +4 -8
  6. package/dist/broker-transport.d.ts.map +1 -1
  7. package/dist/broker-transport.js +15 -19
  8. package/dist/broker-transport.js.map +1 -1
  9. package/dist/command-dispatch.d.ts +3 -7
  10. package/dist/command-dispatch.d.ts.map +1 -1
  11. package/dist/command-dispatch.js +9 -13
  12. package/dist/command-dispatch.js.map +1 -1
  13. package/dist/credential-renewal.d.ts +3 -7
  14. package/dist/credential-renewal.d.ts.map +1 -1
  15. package/dist/credential-renewal.js +13 -17
  16. package/dist/credential-renewal.js.map +1 -1
  17. package/dist/goal-writer.d.ts +3 -5
  18. package/dist/goal-writer.d.ts.map +1 -1
  19. package/dist/goal-writer.js +10 -12
  20. package/dist/goal-writer.js.map +1 -1
  21. package/dist/harness-resolution.d.ts +3 -13
  22. package/dist/harness-resolution.d.ts.map +1 -1
  23. package/dist/harness-resolution.js +14 -24
  24. package/dist/harness-resolution.js.map +1 -1
  25. package/dist/lease-keeper.d.ts +3 -3
  26. package/dist/lease-keeper.d.ts.map +1 -1
  27. package/dist/lease-keeper.js +8 -8
  28. package/dist/lease-keeper.js.map +1 -1
  29. package/dist/managed-static-lifecycle.d.ts +4 -9
  30. package/dist/managed-static-lifecycle.d.ts.map +1 -1
  31. package/dist/managed-static-lifecycle.js +25 -30
  32. package/dist/managed-static-lifecycle.js.map +1 -1
  33. package/dist/manager-config.d.ts +55 -0
  34. package/dist/manager-config.d.ts.map +1 -0
  35. package/dist/manager-config.js +2 -0
  36. package/dist/manager-config.js.map +1 -0
  37. package/dist/manager.d.ts +8 -47
  38. package/dist/manager.d.ts.map +1 -1
  39. package/dist/manager.js +96 -122
  40. package/dist/manager.js.map +1 -1
  41. package/dist/names-capacity.d.ts +3 -3
  42. package/dist/names-capacity.d.ts.map +1 -1
  43. package/dist/names-capacity.js +4 -3
  44. package/dist/names-capacity.js.map +1 -1
  45. package/dist/persona-catalog.d.ts +3 -7
  46. package/dist/persona-catalog.d.ts.map +1 -1
  47. package/dist/persona-catalog.js +10 -14
  48. package/dist/persona-catalog.js.map +1 -1
  49. package/dist/preservation.d.ts +3 -9
  50. package/dist/preservation.d.ts.map +1 -1
  51. package/dist/preservation.js +16 -22
  52. package/dist/preservation.js.map +1 -1
  53. package/dist/preserved-resume.d.ts +3 -15
  54. package/dist/preserved-resume.d.ts.map +1 -1
  55. package/dist/preserved-resume.js +48 -60
  56. package/dist/preserved-resume.js.map +1 -1
  57. package/dist/readiness-wait.d.ts +3 -3
  58. package/dist/readiness-wait.d.ts.map +1 -1
  59. package/dist/readiness-wait.js +6 -6
  60. package/dist/readiness-wait.js.map +1 -1
  61. package/dist/retirement.d.ts +4 -12
  62. package/dist/retirement.d.ts.map +1 -1
  63. package/dist/retirement.js +14 -22
  64. package/dist/retirement.js.map +1 -1
  65. package/dist/seat-custody.d.ts +4 -6
  66. package/dist/seat-custody.d.ts.map +1 -1
  67. package/dist/seat-custody.js +11 -13
  68. package/dist/seat-custody.js.map +1 -1
  69. package/dist/seat-launch.d.ts +3 -11
  70. package/dist/seat-launch.d.ts.map +1 -1
  71. package/dist/seat-launch.js +16 -26
  72. package/dist/seat-launch.js.map +1 -1
  73. package/dist/seat-start.d.ts +3 -8
  74. package/dist/seat-start.d.ts.map +1 -1
  75. package/dist/seat-start.js +54 -35
  76. package/dist/seat-start.js.map +1 -1
  77. package/dist/seat-stop.d.ts +3 -9
  78. package/dist/seat-stop.d.ts.map +1 -1
  79. package/dist/seat-stop.js +9 -15
  80. package/dist/seat-stop.js.map +1 -1
  81. package/dist/serve-plane.d.ts +3 -9
  82. package/dist/serve-plane.d.ts.map +1 -1
  83. package/dist/serve-plane.js +20 -26
  84. package/dist/serve-plane.js.map +1 -1
  85. package/dist/session-recovery.d.ts +3 -4
  86. package/dist/session-recovery.d.ts.map +1 -1
  87. package/dist/session-recovery.js +7 -8
  88. package/dist/session-recovery.js.map +1 -1
  89. package/dist/spawn-goal.d.ts +4 -8
  90. package/dist/spawn-goal.d.ts.map +1 -1
  91. package/dist/spawn-goal.js +7 -11
  92. package/dist/spawn-goal.js.map +1 -1
  93. package/dist/start-doors.d.ts +3 -9
  94. package/dist/start-doors.d.ts.map +1 -1
  95. package/dist/start-doors.js +10 -16
  96. package/dist/start-doors.js.map +1 -1
  97. package/dist/status-and-models.d.ts +3 -11
  98. package/dist/status-and-models.d.ts.map +1 -1
  99. package/dist/status-and-models.js +13 -21
  100. package/dist/status-and-models.js.map +1 -1
  101. package/dist/terminal-input.d.ts +3 -5
  102. package/dist/terminal-input.d.ts.map +1 -1
  103. package/dist/terminal-input.js +6 -8
  104. package/dist/terminal-input.js.map +1 -1
  105. package/dist/user-provision.d.ts +4 -8
  106. package/dist/user-provision.d.ts.map +1 -1
  107. package/dist/user-provision.js +29 -33
  108. package/dist/user-provision.js.map +1 -1
  109. package/package.json +12 -12
package/dist/manager.js CHANGED
@@ -63,7 +63,7 @@ const ONCE_RETIRE_MS = 60_000;
63
63
  * liveness-inferring timer. This is only the last-resort bound for "neither happened in time": the launch
64
64
  * is then reported UNCERTAIN (a non-success reply that does NOT deprovision — it may still be booting, or
65
65
  * stuck before connector startup). Generous, since a real cold agent join can take several seconds. Held
66
- * as an instance field ({@link Manager.readinessTimeoutMs}) so a test can shorten it. Exported so the
66
+ * on the Manager's config ({@link ManagerConfig.readinessTimeoutMs}) so a test can shorten it. Exported so the
67
67
  * launch-parity smoke can assert every launch client's request timeout OUTLIVES this window — the tier
68
68
  * rule forbids the clients importing it directly. */
69
69
  export const READINESS_TIMEOUT_MS = 30_000;
@@ -109,6 +109,12 @@ async function awaitStartupOutcome(a, launchedAt, readinessTimeoutMs, stopping)
109
109
  await new Promise((resolve) => setTimeout(resolve, 250));
110
110
  }
111
111
  }
112
+ /** The seed, typed as the whole config. The parts are built from field initializers that run before
113
+ * the constructor body, so they receive the object while it holds only the seed; the constructor
114
+ * assigns every other member before it returns, and no part reads one during construction. */
115
+ function seededConfig(seed) {
116
+ return seed;
117
+ }
112
118
  /**
113
119
  * The agent supervisor: a long-lived mesh node that owns agent process lifecycle.
114
120
  * It serves control requests on the "manager" service and spawns/kills agents
@@ -118,53 +124,35 @@ async function awaitStartupOutcome(a, launchedAt, readinessTimeoutMs, stopping)
118
124
  export class Manager {
119
125
  /** The parts, filled at the end of the constructor once every part exists. Parts read a peer from it at use. */
120
126
  parts = {};
121
- space;
122
- servers;
123
- /** The broker ws listener port (loopback) `cotal up` allocated, for the console session
124
- * client's wsUrl. Undefined ⇒ no console session client (POST /session 503s). */
125
- wsPort;
126
- name;
127
- workspaceRoot;
128
- eventsRequired;
129
- eventPayloadsWithheld;
130
- /** The operator-set global live-session ceiling (see {@link ManagerOptions.maxSessions}). */
131
- maxSessions;
132
- /** The operator-set per-owner seat ceiling (see {@link ManagerOptions.seatCap}). */
133
- seatCap;
134
- /** The ONE secret store for every kind this manager touches (daemon-cred remint + agent kinds).
135
- * See {@link ManagerOptions.secretStore}. */
136
- secrets;
137
- /** Named identity of {@link secrets}: the same coordinate the delivery daemon must reload from.
127
+ /** The Manager's identity, operator settings and timing (see {@link ManagerConfig}). Declared ahead of
128
+ * the parts so each part built below receives this object; the constructor fills the rest in. */
129
+ config = seededConfig({
130
+ managerLifecycleUid: mintLifecycleUid(),
131
+ startedAtMs: Date.now(),
132
+ shutdownReadiness: new AbortController(),
133
+ readinessTimeoutMs: READINESS_TIMEOUT_MS,
134
+ staticReconcileRetryDelaysMs: STATIC_RECONCILE_RETRY_DELAYS_MS,
135
+ goalAcceptanceRetentionMs: TURN_ANSWER_RETENTION_MS,
136
+ });
137
+ /** Named identity of {@link ManagerConfig.secrets}: the same coordinate the delivery daemon must reload from.
138
138
  * Set at construction for an injected store; the workspace store is named on first challenge. */
139
139
  secretStoreIdentity;
140
140
  /** See {@link ManagerOptions.installedExtensions}. */
141
141
  installedExtensions;
142
- expectedConnectorGeneration;
143
- machineSetupCommand;
144
- executionState;
145
142
  /** One backend per kind a seat has asked for, beside {@link runtime}. The manager's own runtime
146
143
  * stays the default and is never replaced by a later seat's choice. */
147
144
  runtimes = new Map();
148
- /** Hosted pooled control, recorded so a later seat cannot add a custodial runtime the constructor
149
- * already refused for the manager's own. */
150
- pooled;
151
145
  /** Internal test seam. Production leaves this undefined and uses the scoped delivery-admin evictor. */
152
146
  staticLifecycleEvict;
153
- preserveStopTimeoutMs;
154
- endpointServeExecutorExpiresInSeconds;
155
147
  agents = new Map();
156
148
  /** Lifecycle UIDs already handed to `Runtime.spawnDelegated`: a lifecycle is handed off at most
157
149
  * once, so a lost create acknowledgement can never become a second create. */
158
150
  delegatedLaunched = new Set();
159
- /** This manager process's own incarnation uid (SPEC 13.1; minted once per supervisor process,
160
- * never reused across restarts) — the endpoint's presence key AND the `managerInstance` audit
161
- * coordinate every static activation records. */
162
- managerLifecycleUid = mintLifecycleUid();
163
151
  /** The persisted LOGICAL instance id (SPEC 13.6 item 7): STABLE across restart, so a
164
152
  * restart re-registers the SAME id with an ADVANCED epoch through the §13.1 gate (the successor
165
153
  * fences the predecessor's epoch — the (i) fence bites on a real restart). It is the registration
166
154
  * instanceId, the served-status id, the goal spec's executor.instanceId, the epe route, and the
167
- * resolveExecutorEpoch key — DISTINCT from {@link managerLifecycleUid} (per-process: the presence
155
+ * resolveExecutorEpoch key — DISTINCT from {@link ManagerConfig.managerLifecycleUid} (per-process: the presence
168
156
  * node uid + the managerInstance audit coordinate every static activation records). Set in start(). */
169
157
  managerInstanceId;
170
158
  /** The persisted serve nkey identity: reusing the SAME principal across restart keeps
@@ -174,7 +162,6 @@ export class Manager {
174
162
  /** The local instance identity {@link admitExecutionState} already resolved. The ordinary start
175
163
  * adopts it instead of reading the same record again. */
176
164
  admittedLocalIdentity;
177
- onServiceIdentity;
178
165
  /** The manager's v0.4 service-endpoint serve state — the serve handle +
179
166
  * its dedicated connection, the STABLE serve identity (renewals re-mint the same nkey), the
180
167
  * branded serve grant, and the CURRENT credential (the connection's authenticator reads it on
@@ -227,13 +214,10 @@ export class Manager {
227
214
  /** The acceptance replied for each goal this incarnation accepted, by {@link goalKey}, so an
228
215
  * idempotent same-goalId retry serves the IDENTICAL acceptance (same allocated name/triple)
229
216
  * without a second spawn. An entry lives while its goal is in flight and for
230
- * {@link goalAcceptanceRetentionMs} after its terminal commits; a later retry, or one at another
217
+ * {@link ManagerConfig.goalAcceptanceRetentionMs} after its terminal commits; a later retry, or one at another
231
218
  * incarnation, is answered from the goal index while the goal runs and from its committed
232
219
  * result fact once it has ended. */
233
220
  goalAcceptances = new Map();
234
- /** How long a terminal goal's acceptance stays in {@link goalAcceptances}: the retry window its
235
- * turn twin keeps a settled answer for. An instance field so a test can shorten it. */
236
- goalAcceptanceRetentionMs = TURN_ANSWER_RETENTION_MS;
237
221
  /** The boot reconcile of the durable goal index runs ONCE at start (a
238
222
  * fresh incarnation inherits the endpoint's accepted-but-unterminal goals from any predecessor).
239
223
  * Spawn-as-action REFUSES to accept until it completes, so the sweep never races a live goal's
@@ -247,12 +231,12 @@ export class Manager {
247
231
  return this.turnRelayInstance ??= new TurnRelay({
248
232
  goalWriter: () => this.goalWriter,
249
233
  serviceServe: () => this.serviceServe,
250
- space: this.space,
234
+ space: this.config.space,
251
235
  managerInstanceId: () => this.managerInstanceId,
252
236
  execution: this.execution,
253
237
  executionRefusal: this.executionRefusal(),
254
238
  goalReconcileDone: () => this.goalReconcileDone,
255
- readinessTimeoutMs: () => this.readinessTimeoutMs,
239
+ readinessTimeoutMs: () => this.config.readinessTimeoutMs,
256
240
  adoptsSeats: () => this.auth !== undefined && !this.userMode,
257
241
  onceSeatReconciling: (uid) => this.staticLifecycle.pendingLifecycle(uid),
258
242
  assertGoalWriterEpochCurrent: (epoch) => this.assertGoalWriterEpochCurrent(epoch),
@@ -270,8 +254,6 @@ export class Manager {
270
254
  participants = new Map();
271
255
  /** Once tasks whose seat's exit is watched: that exit, not the spawn's outcome, settles the debt. */
272
256
  onceWatched = new Set();
273
- /** Process start, for the served `status` uptime. */
274
- startedAtMs = Date.now();
275
257
  /** The complete boot task. stop() joins it after fencing static reconciliation, so a registration
276
258
  * already past an earlier shutdown check cannot finish after stop() returns. */
277
259
  startTask;
@@ -281,9 +263,6 @@ export class Manager {
281
263
  * of `agents` before they have exited, so a second teardown would find none and report success
282
264
  * while the first still waits on a live seat. */
283
265
  stopTask;
284
- /** Held as an instance field so broker-owning smokes can compress the schedule without changing
285
- * production semantics. It is never a fence expiry: the durable non-retired row stays authoritative. */
286
- staticReconcileRetryDelaysMs = STATIC_RECONCILE_RETRY_DELAYS_MS;
287
266
  /** Retirements holding one of the {@link RETIREMENT_CONCURRENCY} slots. */
288
267
  retirementsRunning = 0;
289
268
  /** Retirements waiting for a slot, oldest first. */
@@ -293,15 +272,11 @@ export class Manager {
293
272
  /** Space trust material when the mesh runs in auth mode (`.cotal/auth` present);
294
273
  * the manager mints per-agent creds from it at spawn. Undefined when the mesh is open. */
295
274
  auth;
296
- /** Readiness-race backstop (#159 B1) — the {@link READINESS_TIMEOUT_MS} constant, held as an instance
297
- * field so a test can shorten it (the join/exit signals are event-driven; only the backstop is timed).
298
- * Production leaves it at the constant. */
299
- readinessTimeoutMs = READINESS_TIMEOUT_MS;
300
275
  /** True on a USER-AUTH space (the on-disk marker; cross-checked against the registry at start).
301
276
  * Gates the whole spawn path: user mode grants ledger actors + bearer plumbing, never static mints. */
302
277
  userMode = false;
303
- namesCapacity = new NamesCapacity(namesCapacityDeps(this));
304
- servePlane = new ServePlane(servePlaneDeps(this), this.parts);
278
+ namesCapacity = new NamesCapacity(this.config, namesCapacityDeps(this));
279
+ servePlane = new ServePlane(this.config, servePlaneDeps(this), this.parts);
305
280
  resolveServeTarget(t) {
306
281
  if (this.remoteAuthority) {
307
282
  const key = principalKey(t.owner, t.actor).key;
@@ -323,13 +298,12 @@ export class Manager {
323
298
  return { lifecycleUid: a.lifecycleUid, mappingRevision: 0 };
324
299
  return undefined;
325
300
  }
326
- retirement = new Retirement(retirementDeps(this));
327
- lease = new LeaseKeeper(leaseKeeperDeps(this));
301
+ retirement = new Retirement(this.config, retirementDeps(this));
302
+ lease = new LeaseKeeper(this.config, leaseKeeperDeps(this));
328
303
  /** Set at the top of `stop()`. `renewLease` returns at once once this is set, and its `gone` arm
329
304
  * does not re-acquire: a manager that is stopping never puts its own key back. It also closes the
330
305
  * lifecycle fence ({@link beginLifecycle}), so no spawn can launch a seat the stop never sees. */
331
306
  leaseStopping = false;
332
- shutdownReadiness = new AbortController();
333
307
  /** The class-2 renewal owner's half-TTL schedule; armed only on auth meshes. */
334
308
  credRenewTimer;
335
309
  resumeCredRenewal;
@@ -354,7 +328,6 @@ export class Manager {
354
328
  preservationAttemptId;
355
329
  unverifiedStops = [];
356
330
  preservationInventory;
357
- resumeAttemptId;
358
331
  resumeRequired = false;
359
332
  resumeDurableCommitToken;
360
333
  remoteAuthority;
@@ -370,48 +343,49 @@ export class Manager {
370
343
  dial(...args) { return this.brokerTransportComponent.dial(...args); }
371
344
  /** {@link BrokerTransport.dialRemoteStanding}. */
372
345
  dialRemoteStanding(...args) { return this.brokerTransportComponent.dialRemoteStanding(...args); }
373
- seatCustody = new SeatCustody(seatCustodyDeps(this));
374
- sessionRecovery = new SessionRecovery(sessionRecoveryDeps(this));
346
+ seatCustody = new SeatCustody(this.config, seatCustodyDeps(this));
347
+ sessionRecovery = new SessionRecovery(this.config, sessionRecoveryDeps(this));
375
348
  get staticReconcileLastSweepResources() { return this.staticLifecycle.resources(); }
376
349
  set staticReconcileLastSweepResources(value) { this.staticLifecycle.setResources(value); }
377
- staticLifecycle = new ManagedStaticLifecycle(managedStaticLifecycleDeps(this));
350
+ staticLifecycle = new ManagedStaticLifecycle(this.config, managedStaticLifecycleDeps(this));
378
351
  /** User-mode provisioning owns no manager state: each dependency reads through at its use. */
379
- userProvision = new UserProvision(userProvisionDeps(this));
352
+ userProvision = new UserProvision(this.config, userProvisionDeps(this));
380
353
  /** Seat stop, exit, recursive reap and named despawn. Every dependency reads through at its use. */
381
- seatStopComponent = new SeatStop(seatStopDeps(this));
354
+ seatStopComponent = new SeatStop(this.config, seatStopDeps(this));
382
355
  /** The typed command table and its admission. Every dependency reads through at its use. */
383
- commandDispatch = new CommandDispatch(commandDispatchDeps(this));
356
+ commandDispatch = new CommandDispatch(this.config, commandDispatchDeps(this));
384
357
  /** The spawn and launch goal path. Every dependency reads through at its use. */
385
- spawnGoalComponent = new SpawnGoal(spawnGoalDeps(this));
358
+ spawnGoalComponent = new SpawnGoal(this.config, spawnGoalDeps(this));
386
359
  /** The persona catalog doors. Every dependency reads through at its use. */
387
- personaCatalogComponent = new PersonaCatalog(personaCatalogDeps(this));
360
+ personaCatalogComponent = new PersonaCatalog(this.config, personaCatalogDeps(this));
388
361
  /** Seat terminal input and attach sessions. Every dependency reads through at its use. */
389
- terminalInputComponent = new TerminalInput(terminalInputDeps(this));
362
+ terminalInputComponent = new TerminalInput(this.config, terminalInputDeps(this));
390
363
  /** Status, seat list and model catalog reads. Every dependency reads through at its use. */
391
- statusAndModelsComponent = new StatusAndModels(statusAndModelsDeps(this), this.parts);
364
+ statusAndModelsComponent = new StatusAndModels(this.config, statusAndModelsDeps(this), this.parts);
392
365
  /** The launch readiness race and exit watch. Every dependency reads through at its use. */
393
- readinessWaitComponent = new ReadinessWait(readinessWaitDeps(this));
366
+ readinessWaitComponent = new ReadinessWait(this.config, readinessWaitDeps(this));
394
367
  /** Broker dials and scoped executor connections. Every dependency reads through at its use. */
395
- brokerTransportComponent = new BrokerTransport(brokerTransportDeps(this));
368
+ brokerTransportComponent = new BrokerTransport(this.config, brokerTransportDeps(this));
396
369
  /** The start and launch control doors. Every dependency reads through at its use. */
397
- startDoorsComponent = new StartDoors(startDoorsDeps(this));
370
+ startDoorsComponent = new StartDoors(this.config, startDoorsDeps(this));
398
371
  /** Connector and harness resolution for a launch. Every dependency reads through at its use. */
399
- harnessResolutionComponent = new HarnessResolution(harnessResolutionDeps(this), this.parts);
372
+ harnessResolutionComponent = new HarnessResolution(this.config, harnessResolutionDeps(this), this.parts);
400
373
  /** The connector inventory. It owns the connector rows and the boot notes. */
401
374
  connectorInventory;
402
375
  /** Manager preservation and released-seat adoption. Every dependency reads through at its use. */
403
- preservationComponent = new Preservation(preservationDeps(this));
376
+ preservationComponent = new Preservation(this.config, preservationDeps(this));
404
377
  /** Preserved-manager resume and its control doors. Every dependency reads through at its use. */
405
- preservedResumeComponent = new PreservedResume(preservedResumeDeps(this), this.parts);
378
+ preservedResumeComponent = new PreservedResume(this.config, preservedResumeDeps(this), this.parts);
406
379
  /** The goal-writer connection and the goal index it reconciles. Every dependency reads through at its use. */
407
- goalWriterComponent = new GoalWriter(goalWriterDeps(this));
380
+ goalWriterComponent = new GoalWriter(this.config, goalWriterDeps(this));
408
381
  /** Renewal of the manager's standing credentials. Every dependency reads through at its use. */
409
- credentialRenewal = new CredentialRenewal(credentialRenewalDeps(this));
382
+ credentialRenewal = new CredentialRenewal(this.config, credentialRenewalDeps(this));
410
383
  /** The launch pipeline's leaf steps. Every dependency reads through at its use. */
411
- seatLaunch = new SeatLaunch(seatLaunchDeps(this), this.parts);
384
+ seatLaunch = new SeatLaunch(this.config, seatLaunchDeps(this), this.parts);
412
385
  /** Manager boot: execution admission, connect, registration and lease. Every dependency reads through at its use. */
413
- bootComponent = new ManagerBoot(bootDeps(this), this.parts);
386
+ bootComponent = new ManagerBoot(this.config, bootDeps(this), this.parts);
414
387
  constructor(opts) {
388
+ const config = this.config;
415
389
  if (opts.expectedConnectorGeneration !== undefined && opts.expectedConnectorGeneration !== MANAGER_VERSION)
416
390
  throw new Error(`expected connector generation ${opts.expectedConnectorGeneration} differs from this Manager's loaded generation ${MANAGER_VERSION}; restart from the installed CLI`);
417
391
  if (opts.onServiceIdentity !== undefined && typeof opts.onServiceIdentity !== "function")
@@ -429,15 +403,15 @@ export class Manager {
429
403
  throw new Error("pooled control requires signerless remote authority and an explicit non-PTY runtime; local custodial execution is forbidden");
430
404
  if (opts.pooled && !opts.remoteAuthority?.renewStandingBundle)
431
405
  throw new Error("pooled control requires a closed host-issued all-duty renewal callback before construction");
432
- this.space = opts.space;
433
- this.servers = opts.servers;
434
- this.name = opts.name ?? "manager";
435
- this.workspaceRoot = opts.workspaceRoot ?? findCotalRoot();
436
- this.onServiceIdentity = opts.onServiceIdentity;
437
- this.eventsRequired = opts.eventsRequired === true;
438
- this.eventPayloadsWithheld = opts.eventPayloadsWithheld === true;
439
- this.maxSessions = opts.maxSessions;
440
- this.seatCap = opts.seatCap ?? DEFAULT_SEAT_CAP;
406
+ config.space = opts.space;
407
+ config.servers = opts.servers;
408
+ config.name = opts.name ?? "manager";
409
+ config.workspaceRoot = opts.workspaceRoot ?? findCotalRoot();
410
+ config.onServiceIdentity = opts.onServiceIdentity;
411
+ config.eventsRequired = opts.eventsRequired === true;
412
+ config.eventPayloadsWithheld = opts.eventPayloadsWithheld === true;
413
+ config.maxSessions = opts.maxSessions;
414
+ config.seatCap = opts.seatCap ?? DEFAULT_SEAT_CAP;
441
415
  this.remoteAuthority = opts.remoteAuthority;
442
416
  this.remoteExecutorCreds = opts.remoteAuthority?.executorCreds;
443
417
  this.remoteSupervisorCreds = opts.remoteAuthority?.supervisorCreds;
@@ -445,45 +419,45 @@ export class Manager {
445
419
  accountFromCreds(opts.remoteAuthority.supervisorCreds) !== opts.remoteAuthority.accountPublicKey))
446
420
  throw new Error("pooled control requires a proved assigned account for its initial supervisor credential");
447
421
  if (opts.remoteAuthority)
448
- this.managerLifecycleUid = opts.remoteAuthority.lifecycleUid;
449
- this.secrets = opts.secretStore ?? workspaceSecretStore(this.workspaceRoot);
422
+ config.managerLifecycleUid = opts.remoteAuthority.lifecycleUid;
423
+ config.secrets = opts.secretStore ?? workspaceSecretStore(this.config.workspaceRoot);
450
424
  if (opts.secretStore)
451
425
  this.secretStoreIdentity = injectedSecretStoreIdentity(opts.secretStore);
452
426
  this.installedExtensions = opts.installedExtensions ?? false;
453
- this.expectedConnectorGeneration = MANAGER_VERSION;
454
- this.machineSetupCommand = opts.machineSetupCommand;
455
- this.pooled = opts.pooled === true;
456
- this.executionState = opts.execution === "none" ? { kind: "none" } : { kind: "runtime" };
427
+ config.expectedConnectorGeneration = MANAGER_VERSION;
428
+ config.machineSetupCommand = opts.machineSetupCommand;
429
+ config.pooled = opts.pooled === true;
430
+ config.execution = opts.execution === "none" ? "none" : "runtime";
457
431
  if (!this.remoteAuthority) {
458
432
  // A fresh root has no execution record, so construction does not read the identity. Records
459
433
  // survive identity retirement; only the currently stored identity's record can be claimed.
460
- const prefix = `manager-execution.${spaceKey(this.space)}.`;
461
- const dir = join(this.workspaceRoot, ".cotal");
434
+ const prefix = `manager-execution.${spaceKey(this.config.space)}.`;
435
+ const dir = join(this.config.workspaceRoot, ".cotal");
462
436
  const hasRecord = existsSync(dir) && readdirSync(dir).some((name) => name.startsWith(prefix) && name.endsWith(".json"));
463
437
  if (hasRecord) {
464
- const local = loadManagerInstanceIdentity(this.workspaceRoot, this.space);
438
+ const local = loadManagerInstanceIdentity(this.config.workspaceRoot, this.config.space);
465
439
  if (local && existsSync(this.executionRecordPath(local.instanceId))) {
466
440
  this.claimExecutionRecord(local.instanceId);
467
441
  this.admittedLocalIdentity = local;
468
442
  }
469
443
  }
470
444
  }
471
- if (this.executionState.kind === "runtime")
472
- this.runtime = createRuntime(opts.runtime ?? "auto", `cotal-${this.space}`);
473
- if (opts.pooled && this.executionState.kind === "runtime" && isCustodialRuntime(this.requiredRuntime))
445
+ if (this.config.execution === "runtime")
446
+ this.runtime = createRuntime(opts.runtime ?? "auto", `cotal-${this.config.space}`);
447
+ if (opts.pooled && this.config.execution === "runtime" && isCustodialRuntime(this.requiredRuntime))
474
448
  throw new Error(`pooled control refuses custodial runtime "${this.requiredRuntime.kind}" before starting agents`);
475
- this.preserveStopTimeoutMs = opts.preserveStopTimeoutMs ?? PRESERVE_STOP_TIMEOUT_MS;
476
- this.endpointServeExecutorExpiresInSeconds = opts.endpointServeExecutorExpiresInSeconds;
449
+ config.preserveStopTimeoutMs = opts.preserveStopTimeoutMs ?? PRESERVE_STOP_TIMEOUT_MS;
450
+ config.endpointServeExecutorExpiresInSeconds = opts.endpointServeExecutorExpiresInSeconds;
477
451
  if (opts.resumeAttemptId && !/^[A-Za-z0-9_-]{1,128}$/.test(opts.resumeAttemptId))
478
452
  throw new Error("resumeAttemptId must be a safe token (letters, digits, _, -; max 128)");
479
453
  if (opts.resumeDurableCommitToken && !/^[a-f0-9]{64}$/.test(opts.resumeDurableCommitToken))
480
454
  throw new Error("resumeDurableCommitToken must be a lowercase 32-byte token");
481
455
  if (opts.resumeDurableCommitToken && !opts.resumeAttemptId)
482
456
  throw new Error("resumeDurableCommitToken requires resumeAttemptId");
483
- this.resumeAttemptId = opts.resumeAttemptId;
457
+ config.resumeAttemptId = opts.resumeAttemptId;
484
458
  this.resumeRequired = opts.resumeAttemptId !== undefined;
485
459
  this.resumeDurableCommitToken = opts.resumeDurableCommitToken;
486
- this.wsPort = opts.wsPort;
460
+ config.wsPort = opts.wsPort;
487
461
  this.attach = new AttachEndpoint(() => this.list(),
488
462
  // Initial /feed replay for a connecting console: the current peer roster.
489
463
  () => [{ event: "roster", data: this.ep?.getRoster() ?? [] }], opts.consolePort ?? 0,
@@ -497,7 +471,7 @@ export class Manager {
497
471
  // explicit decision; every other caller — an embedded Manager, a bare `cotal supervise` —
498
472
  // keeps the loopback-only console it always had.
499
473
  opts.attachHost ?? "127.0.0.1");
500
- this.connectorInventory = new ConnectorInventory({ execution: this.execution, installedExtensions: this.installedExtensions, machineSetupCommand: this.machineSetupCommand, expectedConnectorGeneration: this.expectedConnectorGeneration }, this.parts, (resumeOperation) => this.beginLifecycle(resumeOperation));
474
+ this.connectorInventory = new ConnectorInventory({ execution: this.execution, installedExtensions: this.installedExtensions, machineSetupCommand: this.config.machineSetupCommand, expectedConnectorGeneration: this.config.expectedConnectorGeneration }, this.parts, (resumeOperation) => this.beginLifecycle(resumeOperation));
501
475
  Object.assign(this.parts, {
502
476
  connectorInventory: this.connectorInventory,
503
477
  harnessResolution: this.harnessResolutionComponent,
@@ -507,23 +481,23 @@ export class Manager {
507
481
  });
508
482
  }
509
483
  get runtimeKind() {
510
- return this.executionState.kind === "none" ? "none" : this.requiredRuntime.kind;
484
+ return this.config.execution === "none" ? "none" : this.requiredRuntime.kind;
511
485
  }
512
486
  /** Whether this manager's runtime opens a terminal stream on the seats it spawns, so a caller
513
487
  * knows before it asks whether `attach` can open one here. A control instance with no execution
514
488
  * spawns no seat, so it streams no terminal either. */
515
489
  get streamsTerminal() {
516
- return this.executionState.kind !== "none" && this.requiredRuntime.streamsTerminal;
490
+ return this.config.execution !== "none" && this.requiredRuntime.streamsTerminal;
517
491
  }
518
492
  get execution() {
519
- return this.executionState.kind;
493
+ return this.config.execution;
520
494
  }
521
495
  executionRefusal() {
522
496
  return EXECUTION_NONE_REFUSAL;
523
497
  }
524
498
  /** A defensive last barrier, not a substitute Runtime. Entry admission runs before effects. */
525
499
  get requiredRuntime() {
526
- if (this.executionState.kind === "none")
500
+ if (this.config.execution === "none")
527
501
  throw new EpEnvelopeError("unimplemented", this.executionRefusal());
528
502
  return this.runtime;
529
503
  }
@@ -536,11 +510,11 @@ export class Manager {
536
510
  * resolves only what its root imported. The refusal names an official runtime's package. */
537
511
  async loadSeatRuntime(kind) {
538
512
  const asked = kind?.trim();
539
- if (!this.installedExtensions || this.executionState.kind === "none" || !asked || asked === "auto" || asked === "pty" || asked === this.runtime.kind)
513
+ if (!this.installedExtensions || this.config.execution === "none" || !asked || asked === "auto" || asked === "pty" || asked === this.runtime.kind)
540
514
  return;
541
515
  if (!manifestExtensionNames("runtime").includes(asked))
542
516
  throw new Error(runtimeInstallHint(asked));
543
- await materializeFromManifest({ kind: "runtime", name: asked }, { hint: (ref) => runtimeInstallHint(ref.name), expectedGeneration: this.expectedConnectorGeneration });
517
+ await materializeFromManifest({ kind: "runtime", name: asked }, { hint: (ref) => runtimeInstallHint(ref.name), expectedGeneration: this.config.expectedConnectorGeneration });
544
518
  }
545
519
  /** The backend one seat launches, restarts, and is reaped through. An omitted or blank choice is
546
520
  * this manager's own runtime. A named one is created once, cached by its resolved kind, and reused
@@ -548,7 +522,7 @@ export class Manager {
548
522
  * unreachable runtime throws, and pooled control refuses a custodial one by the same rule the
549
523
  * constructor applied to the manager's own. */
550
524
  runtimeFor(kind) {
551
- if (this.executionState.kind === "none")
525
+ if (this.config.execution === "none")
552
526
  throw new EpEnvelopeError("unimplemented", this.executionRefusal());
553
527
  const asked = kind?.trim();
554
528
  if (!asked)
@@ -560,8 +534,8 @@ export class Manager {
560
534
  const cached = this.runtimes.get(asked);
561
535
  if (cached)
562
536
  return cached;
563
- const runtime = createRuntime(asked, `cotal-${this.space}`);
564
- if (this.pooled && isCustodialRuntime(runtime))
537
+ const runtime = createRuntime(asked, `cotal-${this.config.space}`);
538
+ if (this.config.pooled && isCustodialRuntime(runtime))
565
539
  throw new Error(`pooled control refuses custodial runtime "${runtime.kind}" before starting agents`);
566
540
  this.runtimes.set(runtime.kind, runtime);
567
541
  return runtime;
@@ -608,8 +582,8 @@ export class Manager {
608
582
  if (!this.managerInstanceId || !this.managerServeIdentity)
609
583
  throw new Error("manager native service identity has not been selected");
610
584
  const principal = this.remoteAuthority
611
- ? { owner: this.remoteAuthority.owner, actor: this.remoteAuthority.actors.serve, uid: this.managerLifecycleUid }
612
- : { owner: DEV_OWNER, actor: this.managerServeIdentity.id, uid: this.managerLifecycleUid };
585
+ ? { owner: this.remoteAuthority.owner, actor: this.remoteAuthority.actors.serve, uid: this.config.managerLifecycleUid }
586
+ : { owner: DEV_OWNER, actor: this.managerServeIdentity.id, uid: this.config.managerLifecycleUid };
613
587
  return Object.freeze({ endpoint: MANAGER_ENDPOINT, instanceId: this.managerInstanceId, principal: Object.freeze(principal) });
614
588
  }
615
589
  /** The console page URL (manager-hosted, loopback). */
@@ -692,7 +666,7 @@ export class Manager {
692
666
  return wrapped;
693
667
  }
694
668
  executionRecordPath(instanceId) {
695
- return join(this.workspaceRoot, ".cotal", `manager-execution.${spaceKey(this.space)}.${instanceId}.json`);
669
+ return join(this.config.workspaceRoot, ".cotal", `manager-execution.${spaceKey(this.config.space)}.${instanceId}.json`);
696
670
  }
697
671
  /** {@link ManagerBoot.claimExecutionRecord}. */
698
672
  claimExecutionRecord(...args) { return this.bootComponent.claimExecutionRecord(...args); }
@@ -758,7 +732,7 @@ export class Manager {
758
732
  if (this.leaseStopping)
759
733
  return "manager is stopping; new lifecycle/control work is fenced";
760
734
  if (this.resumeRequired)
761
- return `manager is waiting for resume attempt ${this.resumeAttemptId}; ordinary lifecycle/control work is fenced`;
735
+ return `manager is waiting for resume attempt ${this.config.resumeAttemptId}; ordinary lifecycle/control work is fenced`;
762
736
  return `manager is in ${this.maintenanceState} mode; new lifecycle/control work is fenced`;
763
737
  }
764
738
  /** {@link Preservation.preparePreservation}. */
@@ -834,7 +808,7 @@ export class Manager {
834
808
  }
835
809
  async stopOnce(withAgents) {
836
810
  this.leaseStopping = true;
837
- this.shutdownReadiness.abort();
811
+ this.config.shutdownReadiness.abort();
838
812
  clearTimeout(this.credentialPushRetry);
839
813
  this.credentialPushRetry = undefined;
840
814
  this.transcripts?.stop();
@@ -975,7 +949,7 @@ export class Manager {
975
949
  }
976
950
  catch (e) {
977
951
  console.error(`! could not deregister manager instance ${iid}: ${rejectionText(e)}\n` +
978
- ` Its registration now outlives this process and will be frozen into every class scatter in space "${this.space}", each paying the full deadline.\n` +
952
+ ` Its registration now outlives this process and will be frozen into every class scatter in space "${this.config.space}", each paying the full deadline.\n` +
979
953
  ` NEXT: once this process is gone, start this manager again and stop it cleanly; on a static space \`cotal endpoint deregister manager ${iid} --yes\` from the space's own root also removes it.`);
980
954
  }
981
955
  }
@@ -1064,7 +1038,7 @@ export class Manager {
1064
1038
  if (this.remoteAuthority && !this.remoteAuthority.runHosting)
1065
1039
  throw new EpEnvelopeError("unimplemented", "this manager does not host workflow runs: its issuing host supplied no closed run callbacks, and a remote-authority manager mints no run-driver credentials (SPEC 14.6); drive the run from a terminal with `cotal run start --local --file <program>`");
1066
1040
  if (this.userMode && !this.remoteAuthority?.runHosting)
1067
- throw new EpEnvelopeError("unimplemented", `user-auth space "${this.space}" hosts no workflow runs yet: a hosted run's seats would be spawned under the static owner, which a user mesh refuses; run programs on a static-auth mesh`);
1041
+ throw new EpEnvelopeError("unimplemented", `user-auth space "${this.config.space}" hosts no workflow runs yet: a hosted run's seats would be spawned under the static owner, which a user mesh refuses; run programs on a static-auth mesh`);
1068
1042
  throw new EpEnvelopeError("unavailable", "the manager is still booting its workflow-run host; retry shortly (SPEC 14.3)");
1069
1043
  }
1070
1044
  /** The answerer a `run-answer` records (SPEC 14.5): the caller as this manager knows them. A
@@ -1224,7 +1198,7 @@ export class Manager {
1224
1198
  caller,
1225
1199
  admin,
1226
1200
  userMode: this.userMode,
1227
- scopeOf: (owner, actor) => resolveAuthProvider().actorScope({ dir: userAuthStateDir(this.workspaceRoot, this.space), owner, actor }),
1201
+ scopeOf: (owner, actor) => resolveAuthProvider().actorScope({ dir: userAuthStateDir(this.config.workspaceRoot, this.config.space), owner, actor }),
1228
1202
  });
1229
1203
  }
1230
1204
  /** The wire principal of a managed agent: {@link managedPrincipal}. */
@@ -1247,7 +1221,7 @@ export class Manager {
1247
1221
  async shredUserSecrets(unshredded, family) {
1248
1222
  for (const path of [family.actorToken, family.sentinelCreds])
1249
1223
  if (path)
1250
- await attemptCleanup(unshredded, `secret ${path}`, () => this.secrets.delete(agentSecretKeyForFile(path, this.space)));
1224
+ await attemptCleanup(unshredded, `secret ${path}`, () => this.config.secrets.delete(agentSecretKeyForFile(path, this.config.space)));
1251
1225
  for (const path of [family.actorToken, family.sentinelCreds, family.health])
1252
1226
  if (path)
1253
1227
  await attemptCleanup(unshredded, `file ${path}`, () => rmSync(path, { force: true }));
@@ -1321,7 +1295,7 @@ export class Manager {
1321
1295
  const source = a.launch.source;
1322
1296
  if (source.kind !== "inline")
1323
1297
  return undefined;
1324
- const path = resolve(inlineSnapshotPath(this.workspaceRoot, a.lifecycleUid));
1298
+ const path = resolve(inlineSnapshotPath(this.config.workspaceRoot, a.lifecycleUid));
1325
1299
  if (resolve(source.configPath) !== path)
1326
1300
  return `its recorded inline persona snapshot ${source.configPath} is not this lifecycle's snapshot path`;
1327
1301
  if (a.restart !== undefined && resolve(a.restart.opts.configPath ?? "") !== path)
@@ -1424,7 +1398,7 @@ export class Manager {
1424
1398
  /** {@link PreservedResume.resumePreservedAgent}. */
1425
1399
  resumePreservedAgent(...args) { return this.preservedResumeComponent.resumePreservedAgent(...args); }
1426
1400
  probeStaticCredential(creds) {
1427
- return probeConnect(this.servers ?? DEFAULT_SERVER, { creds, timeoutMs: 5_000 });
1401
+ return probeConnect(this.config.servers ?? DEFAULT_SERVER, { creds, timeoutMs: 5_000 });
1428
1402
  }
1429
1403
  /** {@link ReadinessWait.awaitReadiness}. */
1430
1404
  awaitReadiness(...args) { return this.readinessWaitComponent.awaitReadiness(...args); }
@@ -1524,7 +1498,7 @@ export class Manager {
1524
1498
  const generation = a?.lifecycleUid === seat.uid ? a.issued?.generation : participant?.generation;
1525
1499
  const caller = { owner: seat.owner, actor: seat.actor, uid: seat.uid, ...(generation !== undefined ? { generation } : {}) };
1526
1500
  try {
1527
- serve.nc.publish(turnNoticeSubject(this.space, this.managerInstanceId, serve.grant.epoch, caller), new TextEncoder().encode(JSON.stringify({ v: 1 })));
1501
+ serve.nc.publish(turnNoticeSubject(this.config.space, this.managerInstanceId, serve.grant.epoch, caller), new TextEncoder().encode(JSON.stringify({ v: 1 })));
1528
1502
  }
1529
1503
  catch (e) {
1530
1504
  console.error(`! turn notice for ${seat.actor} failed: ${rejectionText(e)}`);
@@ -1648,7 +1622,7 @@ export class Manager {
1648
1622
  const connector = await this.resolveConnector(r.connector);
1649
1623
  if (!connector.retireAfterExit)
1650
1624
  throw new Error(`the ${r.connector} connector cannot prove seat ${r.name}'s launched processes gone`);
1651
- return withTimeout(connector.retireAfterExit({ space: this.space, name: r.name, lifecycleUid: r.uid, workspaceRoot: this.workspaceRoot }), ONCE_RETIRE_MS, `seat ${r.name}'s launched processes were not proved gone within ${ONCE_RETIRE_MS}ms`);
1625
+ return withTimeout(connector.retireAfterExit({ space: this.config.space, name: r.name, lifecycleUid: r.uid, workspaceRoot: this.config.workspaceRoot }), ONCE_RETIRE_MS, `seat ${r.name}'s launched processes were not proved gone within ${ONCE_RETIRE_MS}ms`);
1652
1626
  }
1653
1627
  /** Make an adopted seat a once seat again: its exit settles its task, and the task is served to
1654
1628
  * it. A task that ended before the restart owes the stop the predecessor may not have made. */
@@ -1680,7 +1654,7 @@ export class Manager {
1680
1654
  * retirement that confirms the lifecycle is gone. */
1681
1655
  releasedSeatPending(a) {
1682
1656
  try {
1683
- return readReleasedSeatReference(this.workspaceRoot, this.space, a.name)?.lifecycleUid === a.lifecycleUid;
1657
+ return readReleasedSeatReference(this.config.workspaceRoot, this.config.space, a.name)?.lifecycleUid === a.lifecycleUid;
1684
1658
  }
1685
1659
  catch {
1686
1660
  return false;