@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,111 @@
1
+ import { connectorServers, registry, spawnEnvAllow } from "@cotal-ai/core";
2
+ import { connectorInstallHint, manifestExtensionNames, materializeFromManifest, resolveOnPath } from "@cotal-ai/workspace";
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 function resolveHarness(name, requires) {
6
+ const binaries = {};
7
+ const missing = [];
8
+ for (const bin of requires) {
9
+ const path = resolveOnPath(bin);
10
+ if (path)
11
+ binaries[bin] = path;
12
+ else
13
+ missing.push(bin);
14
+ }
15
+ return missing.length ? { binaries, reason: `${name} harness needs ${missing.join(", ")} on PATH - not found` } : { binaries };
16
+ }
17
+ /** Resolving a connector by name and the host fields, harness binaries and capability and events refusals a launch carries. */
18
+ export class HarnessResolution {
19
+ deps;
20
+ constructor(deps) {
21
+ this.deps = deps;
22
+ }
23
+ // The Manager members these bodies read, under their Manager names. Each reads through its dep at
24
+ // use, so a field the Manager assigns later is current and a method a test replaces on the Manager
25
+ // is the one that runs.
26
+ get connectorStatuses() { return this.deps.connectorStatuses(); }
27
+ get eventPayloadsWithheld() { return this.deps.eventPayloadsWithheld(); }
28
+ get eventsRequired() { return this.deps.eventsRequired(); }
29
+ get expectedConnectorGeneration() { return this.deps.expectedConnectorGeneration(); }
30
+ get installedExtensions() { return this.deps.installedExtensions(); }
31
+ get servers() { return this.deps.servers(); }
32
+ get space() { return this.deps.space(); }
33
+ get workspaceRoot() { return this.deps.workspaceRoot(); }
34
+ /** Resolve a connector by agent type. Library composition (installedExtensions off) → a registry
35
+ * hit, exactly as before (the composition root imported what it wants). The published binary gates
36
+ * on MANIFEST membership FIRST — so a live `cotal ext remove` is honored even though the registry
37
+ * still holds a connector imported earlier this session — then returns the registry hit or lazily
38
+ * imports the providing package (transactional + single-flight, via the workspace primitive).
39
+ * The captured Manager generation is checked for first-party providers under that lock,
40
+ * including providers already present in the registry.
41
+ * Fail-loud with an install hint; no fallback. */
42
+ async resolveConnector(name) {
43
+ if (!this.installedExtensions)
44
+ return registry.resolve("connector", name);
45
+ if (!manifestExtensionNames("connector").includes(name))
46
+ throw new Error(connectorInstallHint(name));
47
+ return materializeFromManifest({ kind: "connector", name }, { hint: (ref) => connectorInstallHint(ref.name), expectedGeneration: this.expectedConnectorGeneration });
48
+ }
49
+ /** The harness binaries a managed launch runs, as boot resolved them, or the refusal naming what is
50
+ * missing. Spawn, resume and the model catalog all take it, so a seat launches from the same files
51
+ * whichever path starts it and the catalog never disagrees with a launch about whether the harness
52
+ * is there. Callers recheck unavailable rows first; available rows retain their resolved files.
53
+ * A connector registered after boot has no inventory row and is checked on PATH now. */
54
+ launchHarness(connector) {
55
+ const row = this.connectorStatuses.find((status) => status.agent === connector.name);
56
+ if (row?.state === "unavailable")
57
+ return { refusal: row.reason ?? `${connector.name} harness is unavailable` };
58
+ if (row)
59
+ return { binaries: row.binaries };
60
+ const { reason } = resolveHarness(connector.name, connector.requires ?? []);
61
+ return reason ? { refusal: reason } : {};
62
+ }
63
+ /** The launch fields the host supplies rather than the seat. Spawn and resume both take them from
64
+ * here, so a resumed seat launches under the same host policy, `eventsRequired` included, as the
65
+ * same seat spawned fresh. The caller passes the cotal config it judged the launch by, so the
66
+ * servers and env allowlist come from the contents its checks read. */
67
+ hostLaunchFields(cotalConfig, agent, shareTools, harness) {
68
+ return {
69
+ space: this.space,
70
+ servers: this.servers,
71
+ // Declared overrides plus the connector's native default, unless this spawn explicitly
72
+ // restricts sharing. An empty selection is deliberate isolation, not the default.
73
+ mcpServers: connectorServers(cotalConfig, agent, shareTools),
74
+ mcpServersExclusive: shareTools !== undefined,
75
+ // The operator's spawn-env policy travels the same route: absent means no extras (the OS
76
+ // allow-list + operator knobs + connector-declared inputs), present means those names too.
77
+ // A connector never reads the config itself.
78
+ envAllow: spawnEnvAllow(cotalConfig),
79
+ resolvedBinaries: harness.binaries,
80
+ eventsRequired: this.eventsRequired,
81
+ ...(this.eventPayloadsWithheld ? { eventPayloads: false } : {}),
82
+ // So a connector that keeps per-agent local state can root it at the workspace, not the
83
+ // (possibly per-agent) launch cwd.
84
+ workspaceRoot: this.workspaceRoot,
85
+ };
86
+ }
87
+ /** The refusal for a launch choice the connector cannot honour. Spawn and resume both ask before
88
+ * a seat's launch is built, so a rule changed here holds on both paths. */
89
+ capabilityRefusal(connector, launch) {
90
+ if (launch.variant && !connector.supportsModelVariant)
91
+ return `${connector.name} connector does not support model variants (variant)`;
92
+ if (launch.prompt !== undefined && !connector.supportsPrompt)
93
+ return `${connector.name} connector does not support an initial prompt (prompt)`;
94
+ if (launch.exact && (!connector.supportsSessionReopen || !connector.supportsSessionContinuation))
95
+ return `${connector.name} connector does not support exact session continuity (continuity: exact)`;
96
+ return undefined;
97
+ }
98
+ /** The refusal for an event-plane choice the registration policy or the connector cannot meet.
99
+ * Spawn and resume both ask before a seat's launch is built, so a seat retained without the
100
+ * plane cannot come back on a space that now requires it. An absent choice arms supported planes. */
101
+ eventsRefusal(connector, events) {
102
+ if (this.eventsRequired && events === false)
103
+ return `space "${this.space}" requires the event plane by registration policy; --no-events (events: false on the start op) is not allowed`;
104
+ if ((this.eventsRequired || events === true) && !connector.eventChannel)
105
+ return this.eventsRequired
106
+ ? `space "${this.space}" requires the event plane by registration policy, but connector "${connector.name}" does not publish one`
107
+ : `connector "${connector.name}" does not publish an AG-UI event plane; omit --events to launch it without one`;
108
+ return undefined;
109
+ }
110
+ }
111
+ //# sourceMappingURL=harness-resolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-resolution.js","sourceRoot":"","sources":["../src/harness-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAA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AS,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,2BAA2B,CAAC;YAC9F,OAAO,GAAG,SAAS,CAAC,IAAI,0EAA0E,CAAC;QACrG,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;0GAEsG;IACtG,aAAa,CAAC,SAAoB,EAAE,MAA2B;QAC7D,IAAI,IAAI,CAAC,cAAc,IAAI,MAAM,KAAK,KAAK;YACzC,OAAO,UAAU,IAAI,CAAC,KAAK,+GAA+G,CAAC;QAC7I,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY;YACrE,OAAO,IAAI,CAAC,cAAc;gBACxB,CAAC,CAAC,UAAU,IAAI,CAAC,KAAK,qEAAqE,SAAS,CAAC,IAAI,wBAAwB;gBACjI,CAAC,CAAC,cAAc,SAAS,CAAC,IAAI,iFAAiF,CAAC;QACpH,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
package/dist/manager.d.ts CHANGED
@@ -8,6 +8,8 @@ export { STATIC_RECONCILE_RETRY_DELAYS_MS } from "./managed-static-lifecycle.js"
8
8
  export { credRenewIntervalMs } from "./credential-renewal.js";
9
9
  export { ManagerInstanceLeaseHeld } from "./lease-keeper.js";
10
10
  import { CommandDispatch } from "./command-dispatch.js";
11
+ import { StatusAndModels } from "./status-and-models.js";
12
+ import { Preservation } from "./preservation.js";
11
13
  export { PASTE_END, PASTE_START, RUNTIME_NO_TERMINAL_DETAIL } from "./terminal-input.js";
12
14
  import { CredentialRenewal } from "./credential-renewal.js";
13
15
  import { type EpServeGrant, type Identity } from "@cotal-ai/core";
@@ -663,12 +665,8 @@ export declare class Manager {
663
665
  private maintenanceState;
664
666
  private lifecycleInFlight;
665
667
  private lifecycleDrainWaiters;
666
- private preservationTask?;
667
- private preparationTask?;
668
668
  private preservationGeneration;
669
669
  private preservationAttemptId?;
670
- private preservationStarted;
671
- private preservationFailures;
672
670
  private unverifiedStops;
673
671
  private preservationInventory?;
674
672
  private resumeAttemptId?;
@@ -692,16 +690,9 @@ export declare class Manager {
692
690
  /** A refused or failed standing candidate is cleanup debt, never a silent loss: the last-good
693
691
  * family stays live and this records what the host may have signed but the manager never adopted. */
694
692
  private remoteRenewalDebt?;
695
- /** Every broker dial this manager makes, through ONE transport decision.
696
- *
697
- * `this.servers` is whatever the mesh record held (`cotal supervise` reads it from there), so it
698
- * can be a `ws://`/`wss://` broker published through an HTTPS edge. The raw node transport
699
- * refuses such a URL instead of dialing it, so the scheme picks the dialer here rather than at
700
- * thirteen call sites. `dialerFor` also owns the websocket transport's options, which is why
701
- * callers below still pass their own auth options unchanged. */
693
+ /** {@link BrokerTransport.dial}. */
702
694
  private dial;
703
- /** Initial NATS timeout is per dial, not per server list. Keep the aggregate deadline too, and
704
- * close a late result rather than letting an abandoned preflight or recovery install a transport. */
695
+ /** {@link BrokerTransport.dialRemoteStanding}. */
705
696
  private dialRemoteStanding;
706
697
  private readonly seatCustody;
707
698
  private readonly sessionRecovery;
@@ -742,6 +733,20 @@ export declare class Manager {
742
733
  private readonly personaCatalogComponent;
743
734
  /** Seat terminal input and attach sessions. Every dependency reads through at its use. */
744
735
  private readonly terminalInputComponent;
736
+ /** Status, seat list and model catalog reads. Every dependency reads through at its use. */
737
+ private readonly statusAndModelsComponent;
738
+ /** The launch readiness race and exit watch. Every dependency reads through at its use. */
739
+ private readonly readinessWaitComponent;
740
+ /** Broker dials and scoped executor connections. Every dependency reads through at its use. */
741
+ private readonly brokerTransportComponent;
742
+ /** The start and launch control doors. Every dependency reads through at its use. */
743
+ private readonly startDoorsComponent;
744
+ /** Connector and harness resolution for a launch. Every dependency reads through at its use. */
745
+ private readonly harnessResolutionComponent;
746
+ /** The boot connector inventory. Every dependency reads through at its use. */
747
+ private readonly connectorInventoryComponent;
748
+ /** Manager preservation and released-seat adoption. Every dependency reads through at its use. */
749
+ private readonly preservationComponent;
745
750
  /** The goal-writer connection and the goal index it reconciles. Every dependency reads through at its use. */
746
751
  private readonly goalWriterComponent;
747
752
  /** Renewal of the manager's standing credentials. Every dependency reads through at its use. */
@@ -829,16 +834,6 @@ export declare class Manager {
829
834
  * silently, since `switch` has no default arm to catch it.
830
835
  */
831
836
  private get meshMode();
832
- /** The CHAT stream frontier at a preservation cut (issue #545), read through whichever local
833
- * authority this mesh mode holds: open mode's own endpoint already has `$JS.API.STREAM.INFO`
834
- * on the CHAT stream. Local and remote supervisor credentials also hold this metadata grant
835
- * for transcript startup checks, but this preservation path retains its existing local-authority
836
- * boundary. Static/user modes borrow the ephemeral `provisioner` profile the manager already
837
- * mints per spawn. A remote-authority manager (`this.auth`
838
- * undefined in static/user mode) has no local space authority to mint that provisioner with, so
839
- * it prints one line and returns no floor — the inventory then carries none and resumed seats
840
- * behave exactly as before this fix, not a silent partial degrade. */
841
- private chatFrontierForPreservation;
842
837
  private readerRemedy;
843
838
  start(): Promise<void>;
844
839
  private executionRecordPath;
@@ -879,54 +874,36 @@ export declare class Manager {
879
874
  private trackDeprovision;
880
875
  private awaitLifecycleDrain;
881
876
  private maintenanceError;
882
- /** Fence and build the inventory without stopping a child. The coordinator must durably persist
883
- * this exact plan before calling commitPreservation with the same attempt id. */
884
- preparePreservation(attemptId: string): Promise<ManagerPreservationPlan>;
885
- private assertPreservationGeneration;
886
- private runPreparation;
887
- /** Stop children only after the coordinator has persisted the prepared inventory. Same-attempt
888
- * retries are idempotent; a different attempt is refused. */
889
- commitPreservation(attemptId: string): Promise<ManagerPreserveResult>;
890
- /** Recover an abandoned prepare before any child stop. Once commit begins, preservation is
891
- * irreversible and remains fenced until the coordinator records failure/recourse. */
892
- abortPreservation(attemptId: string): void;
893
- /** In-process convenience that preserves the crash barrier by awaiting durable persistence between
894
- * prepare and commit. Wire callers use the explicit two-phase admin operations. */
895
- preserveState(opts: ManagerPreserveOptions): Promise<ManagerPreserveResult>;
896
- private runPreservation;
877
+ /** {@link Preservation.preparePreservation}. */
878
+ preparePreservation(...args: Parameters<Preservation["preparePreservation"]>): ReturnType<Preservation["preparePreservation"]>;
879
+ /** {@link Preservation.runPreparation}. */
880
+ runPreparation(...args: Parameters<Preservation["runPreparation"]>): ReturnType<Preservation["runPreparation"]>;
881
+ /** {@link Preservation.commitPreservation}. */
882
+ commitPreservation(...args: Parameters<Preservation["commitPreservation"]>): ReturnType<Preservation["commitPreservation"]>;
883
+ /** {@link Preservation.abortPreservation}. */
884
+ abortPreservation(...args: Parameters<Preservation["abortPreservation"]>): ReturnType<Preservation["abortPreservation"]>;
885
+ /** {@link Preservation.preserveState}. */
886
+ preserveState(...args: Parameters<Preservation["preserveState"]>): ReturnType<Preservation["preserveState"]>;
887
+ /** {@link Preservation.awaitHandleExit}. */
897
888
  private awaitHandleExit;
889
+ /** {@link Preservation.inventoryReferenceError}. */
898
890
  private inventoryReferenceError;
899
891
  private fileDigest;
892
+ /** {@link Preservation.fileDigestOrEmpty}. */
900
893
  private fileDigestOrEmpty;
901
894
  private resumeEntry;
902
895
  /** The resume entry of one live seat, with no side effect: a preservation cut and a supervised
903
896
  * seat's record both build it. The entry is its own copy, so a caller's write to the plan it was
904
897
  * handed cannot change the launch the manager keeps supervising (#3241). */
905
898
  private resumeEntryOf;
906
- /** Tear down every managed agent's footprint on an explicit destructive {@link stop}, or only the
907
- * in-process seats a default stop cannot detach. A manager exit is
908
- * a mass agent-exit, and without this its agents' footprints (creds files + `dm_`/`dlv_` durables + ACL
909
- * rows) would orphan exactly as the per-agent exit path prevents. Stop each child gracefully, so its
910
- * own shutdown runs before the runtime escalates, and AWAIT its deprovision — bounded per agent (`withTimeout`) and
911
- * best-effort (`allSettled` + a loud log), so one slow/failed teardown can neither hang nor abort exit.
912
- * The creds file is dropped even if the broker teardown fails (see {@link deprovision}). Deliberately
913
- * touches NEITHER the lease NOR the endpoints — the caller owns those. */
899
+ /** {@link Preservation.teardownManagedAgents}. */
914
900
  private teardownManagedAgents;
901
+ /** {@link Preservation.isProcessBoundSeat}. */
915
902
  private isProcessBoundSeat;
916
- /** Drop local custody of every seat that can outlive this process, and leave it running. A seat
917
- * with a runtime reference is recorded first, so the next manager on this workspace adopts it, or
918
- * retires it once its runtime proves it gone. The stopping manager keeps no watch on a released
919
- * seat: its endpoint is closing, and a retirement it drove afterwards would run over a dead
920
- * connection and race the next manager's. `stop` is every seat left for the caller to stop and
921
- * retire now: an in-process seat, a seat the runtime already reports gone, and a seat whose record
922
- * could not be written, because a released seat nobody can find again is the leak this stop must
923
- * not create. */
903
+ /** {@link Preservation.releaseManagedAgents}. */
924
904
  private releaseManagedAgents;
925
- /** Take back user-mode seats a previous manager released while they were still running. A seat
926
- * the runtime adopts is watched, and retired when that watch proves it gone. A seat the runtime
927
- * has already reaped is retired now. Anything the runtime cannot prove is left recorded. */
905
+ /** {@link Preservation.adoptReleasedSeats}. */
928
906
  private adoptReleasedSeats;
929
- private adoptReleasedSeat;
930
907
  private stopRetainedAgentsOnExit;
931
908
  /** Every call joins the first stop and settles with it. A call that asks for a different
932
909
  * `withAgents` is refused, since the running stop has already applied its own policy. */
@@ -955,20 +932,11 @@ export declare class Manager {
955
932
  * and drop its dedicated connection, or only close the connection while its transport is down.
956
933
  * Best-effort so a graceful stop completes its remaining teardown even when the broker is gone. */
957
934
  private stopServiceServe;
958
- /** Retire a dedicated connection on stop: drain it while its transport is up, close it while the
959
- * client is reconnecting it. A drain on a reconnecting connection does not fail, it waits for the
960
- * reconnect, so the stop would last as long as the outage; a broker this connection cannot reach
961
- * has nothing left to flush. `flush` (the serve loop's own drain) runs only while the transport is
962
- * up. Best-effort, so a graceful stop completes its remaining teardown even when the broker is gone. */
935
+ /** {@link BrokerTransport.retireConnection}. */
963
936
  private retireConnection;
964
- /** A failed candidate must not extend preparation by draining subscriptions on a stalled socket.
965
- * Close only that candidate first. Native stop still owns any already-dispatched handlers, whose
966
- * outcomes remain unknown to callers and must not be replayed; they do not hold family adoption. */
937
+ /** {@link BrokerTransport.discardServeCandidate}. */
967
938
  private discardServeCandidate;
968
- /** Track a dedicated connection's transport into {@link transportDown} from the first moment:
969
- * nats.js reports `disconnect` when the socket drops and `reconnect` only after it has re-sent the
970
- * connection's subscriptions. If the status stream itself fails, the transport can no longer be
971
- * observed, so it counts as down. */
939
+ /** {@link BrokerTransport.trackTransport}. */
972
940
  private trackTransport;
973
941
  private opFinalizeResume;
974
942
  private opCommitResume;
@@ -1106,33 +1074,16 @@ export declare class Manager {
1106
1074
  * resolution: a same-named *unmanaged* peer already present could satisfy this early. That's
1107
1075
  * acceptable for cold-start staggering; it never routes anything. */
1108
1076
  waitForPresence(name: string, timeoutMs?: number): Promise<boolean>;
1109
- /** Parse a served `spawn` request into {@link StartAgentOpts}. The compiled spawn input contract
1110
- * is the shape check: it already refused a non-mapping `launchOptions`, a `supervise` that is not
1111
- * the closed `{ restarts, windowMs }` pair, and a list on `subscribe`, `allowSubscribe`,
1112
- * `allowPublish`, `shareTools`, `join` or `callerAcl` that is not an array of strings. This reads
1113
- * those fields as admitted, the way it reads the string fields. The connector still validates the
1114
- * launch-option keys, and `startAgent` still refuses a supervise budget the seat record would not
1115
- * take. `once` is shape-checked by that same contract. Its omitted `deadlineMs` takes the default
1116
- * here, and a deadline past the scheduler's last instant is refused here, which the schema does
1117
- * not express. */
1077
+ /** {@link StartDoors.opStart}. */
1118
1078
  private opStart;
1119
1079
  private listSpawnDirectory;
1120
1080
  /** {@link SeatLaunch.resolveSpawnCwd}. */
1121
1081
  private resolveSpawnCwd;
1122
- /** Resolve a connector by agent type. Library composition (installedExtensions off) → a registry
1123
- * hit, exactly as before (the composition root imported what it wants). The published binary gates
1124
- * on MANIFEST membership FIRST — so a live `cotal ext remove` is honored even though the registry
1125
- * still holds a connector imported earlier this session — then returns the registry hit or lazily
1126
- * imports the providing package (transactional + single-flight, via the workspace primitive).
1127
- * The captured Manager generation is checked for first-party providers under that lock,
1128
- * including providers already present in the registry.
1129
- * Fail-loud with an install hint; no fallback. */
1082
+ /** {@link HarnessResolution.resolveConnector}. */
1130
1083
  private resolveConnector;
1131
1084
  /** {@link SeatLaunch.connectorNames}. */
1132
1085
  private connectorNames;
1133
- /** Resolve every installed/registered connector's declared harness binaries before the manager
1134
- * reports ready. A missing harness degrades only that connector, never unrelated lifecycle work:
1135
- * boot continues, names it once start completes and records it on both manager status surfaces. */
1086
+ /** {@link ConnectorInventory.inspectConnectorsAtBoot}. */
1136
1087
  private inspectConnectorsAtBoot;
1137
1088
  /** Install and verify the hosted Claude wake channel, or report the cause and remedy. */
1138
1089
  private prepareClaudeWake;
@@ -1142,49 +1093,21 @@ export declare class Manager {
1142
1093
  /** {@link SeatLaunch.classSpawnEnabled}. */
1143
1094
  private classSpawnEnabled;
1144
1095
  private omitClassCommands;
1145
- /** The harness binaries a managed launch runs, as boot resolved them, or the refusal naming what is
1146
- * missing. Spawn, resume and the model catalog all take it, so a seat launches from the same files
1147
- * whichever path starts it and the catalog never disagrees with a launch about whether the harness
1148
- * is there. Callers recheck unavailable rows first; available rows retain their resolved files.
1149
- * A connector registered after boot has no inventory row and is checked on PATH now. */
1096
+ /** {@link HarnessResolution.launchHarness}. */
1150
1097
  private launchHarness;
1151
- /** The launch fields the host supplies rather than the seat. Spawn and resume both take them from
1152
- * here, so a resumed seat launches under the same host policy, `eventsRequired` included, as the
1153
- * same seat spawned fresh. The caller passes the cotal config it judged the launch by, so the
1154
- * servers and env allowlist come from the contents its checks read. */
1098
+ /** {@link HarnessResolution.hostLaunchFields}. */
1155
1099
  private hostLaunchFields;
1156
- /** The refusal for a launch choice the connector cannot honour. Spawn and resume both ask before
1157
- * a seat's launch is built, so a rule changed here holds on both paths. */
1100
+ /** {@link HarnessResolution.capabilityRefusal}. */
1158
1101
  private capabilityRefusal;
1159
1102
  /** {@link SeatLaunch.onceRefusal}. */
1160
1103
  onceRefusal(connector: Connector, runtime: Runtime, launch: Pick<StartAgentOpts, "once" | "supervise" | "launchOptions" | "prompt">, spawner: string | undefined, hooks: SpawnHooks | undefined): string | undefined;
1161
- /** The refusal for an event-plane choice the registration policy or the connector cannot meet.
1162
- * Spawn and resume both ask before a seat's launch is built, so a seat retained without the
1163
- * plane cannot come back on a space that now requires it. An absent choice arms supported planes. */
1104
+ /** {@link HarnessResolution.eventsRefusal}. */
1164
1105
  private eventsRefusal;
1165
- /** Return connector-provided model catalogs for selector UIs. Optional by connector: a host with no
1166
- * local model-list API reports `supported:false` rather than blocking the manager. A connector that
1167
- * fails to import shows an `error:` row (from manifest enumeration) and never blocks the others. */
1106
+ /** {@link StatusAndModels.opModels}. */
1168
1107
  private opModels;
1169
- /** The owner-domain bound on `ps`/`status` metadata: on a USER mesh, a privileged-tier caller
1170
- * sees only agents under its OWN subject-pinned owner. Two ways to see ALL owners: the admin
1171
- * TIER (operator), or a fresh ledger `admin` SCOPE on the caller's row — the SAME authority that
1172
- * lets `stop`/`attach` reach cross-owner agents ({@link authorizeNamedControl}). Without this the
1173
- * two surfaces disagree: an admin operator could cross-owner stop an agent it could not list.
1174
- * Read fresh so a revoked admin loses visibility on its next call; a read failure and an
1175
- * unparseable caller both fall closed (own-owner / matches-nothing). Static meshes are unbounded. */
1108
+ /** {@link StatusAndModels.psOwnerFilter}. */
1176
1109
  private psOwnerFilter;
1177
- /** Boot one resolved agent from a mesh-manifest launch spec, for `cotal spawn -f` onto a RUNNING
1178
- * manager. The request carries `{ runId, name }` — plus, for a deploy from another checkout or
1179
- * host, the resolved `spec` itself inline (validated as untrusted input and persisted under THIS
1180
- * manager's `.cotal/run/` first) — NEVER a path: the manager derives + validates
1181
- * `.cotal/run/<runId>.json` itself ({@link launchSpecForRun} — token-safe id, no-follow,
1182
- * `loadLaunchSpec`'s untrusted-input + `validateLaunchPolicy` contract), materializes the named
1183
- * agent's transient persona, and spawns via the same `startAgent({ resolved })` path as
1184
- * `supervise --launch`. The reply is enriched for the ownership ledger: the SPAWNED
1185
- * (collision-numbered) name + nkey id creds are filed under, plus the manifest `requested` name,
1186
- * `runId`, and resolved `hash`. USER mesh: a privileged-tier launch is owner-equality-authorized
1187
- * (spec owner === caller owner) before any side effect; the admin tier keeps operator behavior. */
1110
+ /** {@link StartDoors.opLaunch}. */
1188
1111
  private opLaunch;
1189
1112
  /** Spawn and supervise one agent. The single spawn path: both the control-plane
1190
1113
  * `start` op and declarative roster boot call this. Mints scoped creds in auth mode,
@@ -1248,33 +1171,11 @@ export declare class Manager {
1248
1171
  * fence's `joinedAfter` bound: the row the dead seat left must not stand in for the new process.
1249
1172
  * A heartbeat on that row moves only its time and emits no presence event, so the bound is polled. */
1250
1173
  private watchResumeAdoption;
1251
- /** #159 B1: wait for a detached launch to reach a REAL outcome before replying — never a liveness-
1252
- * inferring timer. Races three:
1253
- * • the assigned id joins presence (live) → **started** — the honest signal (the manager owns mesh
1254
- * lifecycle, not app health, so `ok:true` means "it joined the mesh", not "fully healthy");
1255
- * • the child process exits → **failed** — surface its last output and reap the slot;
1256
- * • neither within {@link readinessTimeoutMs} → **uncertain** — a non-success diagnostic that does NOT
1257
- * deprovision (it may still be booting; the caller keeps {@link watchExit} wired so a later death is
1258
- * still reaped).
1259
- * Presence is keyed on the EXACT freshly-minted id, never the name — a fresh id has no prior record, so
1260
- * any live presence for it is from THIS launch (stale/same-name records can't false-start it). The
1261
- * `"presence"` event is only a wake; the roster is re-read as the source of truth (subscribe-then-check
1262
- * catches a join/exit that landed before we subscribed). A runtime whose `attach()` throws (an external
1263
- * surface) streams no output or exit, so its exit leg polls the runtime's exit proof ({@link pollProvedExit}),
1264
- * reads it once more when the window closes, and its failure carries no last output; one that cannot prove an
1265
- * exit either races presence-vs-backstop only.
1266
- * A launch that waits for the operator at `opts.operator`, a screen its connector names, is ready once a
1267
- * process this runtime owns has run for {@link OPERATOR_READINESS_MS} without exiting. An uncertain verdict
1268
- * says whether a process this runtime owns is still running. */
1174
+ /** {@link ReadinessWait.awaitReadiness}. */
1269
1175
  private awaitReadiness;
1270
- /** Last non-empty line of the session's rendered backlog as a single trimmed snippet (≤160 chars)
1271
- * — a readable one-line cause for an early-exit diagnostic. The backlog repaints cells a TUI
1272
- * skipped with cursor moves, so it is rendered and the line is read off the terminal; stripping
1273
- * its escapes would glue the words those moves separate. */
1176
+ /** {@link ReadinessWait.tail}. */
1274
1177
  private tail;
1275
- /** Subscribe to a managed agent's process-exit so a self-driven exit frees its slot and reaps
1276
- * its children (P4b/P4c). The watch is bound to the current handle: a restart swaps in a new one
1277
- * and watches it, so a late exit proved for the old handle must not retire the row. */
1178
+ /** {@link ReadinessWait.watchExit}. */
1278
1179
  private watchExit;
1279
1180
  private occupancy;
1280
1181
  private occupancyText;
@@ -1293,47 +1194,21 @@ export declare class Manager {
1293
1194
  retireDelegatedAgent(name: string, intentId: string): Promise<ControlReply>;
1294
1195
  /** {@link SeatStop.findManagedByTarget}. */
1295
1196
  private findManagedByTarget;
1296
- /** Run one static §13.1 lifecycle OPERATION over an ephemeral, key-pinned `lifecycle-executor`
1297
- * connection: the credential's grants name exactly ONE incarnation's head/uid/gate/
1298
- * cred-family/slot keys, so the write authority exists only for this operation's window and
1299
- * can move nothing else. The transport is the direct-KV binding the shared core saga drives. */
1197
+ /** {@link BrokerTransport.withLifecycleExecutor}. */
1300
1198
  private withLifecycleExecutor;
1301
- /** Run one SPEC 13.15 issuance operation over an ephemeral `issuer` connection: the evidence
1302
- * stage/release of one mint, or the retirement walk of one lifecycle's issuances. The store
1303
- * handle and the accepted-row KV live only for this window; the standing supervisor holds no
1304
- * grant on either bucket. */
1199
+ /** {@link BrokerTransport.withIssuer}. */
1305
1200
  private withIssuer;
1306
- /** The issuance seam of ONE static credential mint (SPEC 13.15): the evidence is bound to the
1307
- * incarnation's own `cred.<uid>` ledger family, so the family's revocation (the static
1308
- * terminal) retires every issuance that named it. The finalizer is the §13.1 ledger append
1309
- * (slot credentialId + `cred.<uid>.<credId>` row); release runs it, then activates. */
1201
+ /** {@link BrokerTransport.issuanceSeam}. */
1310
1202
  private issuanceSeam;
1311
- /** Run one §13.1 endpoint-instance maintenance operation over an ephemeral,
1312
- * key-pinned `endpoint-serve-executor` connection: the credential's grants name exactly the
1313
- * manager instance's `epgate`/`epcred` keys plus its registration's two records keys, so the
1314
- * gate CAS, mint fence, spec/governance writes, and clean deregistration ride a one-shot scoped
1315
- * authority. The remote boot goal-index sweep instead uses the authenticated host-owned scan.
1316
- * This is NEVER the manager's standing seed/supervisor connection. */
1203
+ /** {@link BrokerTransport.withEndpointServeExecutor}. */
1317
1204
  private withEndpointServeExecutor;
1318
- /** The open-mesh counterpart of {@link withEndpointServeExecutor}: an OPEN mesh has no
1319
- * credential system, so there is no scoped executor to mint - the same §13.1 gate/records
1320
- * writes ride a bare one-shot connection (the broker enforces nothing on an open mesh; the
1321
- * ceremony still produces the real gate, epoch, and registration the serve rails run on). */
1205
+ /** {@link BrokerTransport.withOpenServeConnection}. */
1322
1206
  private withOpenServeConnection;
1323
- /** Parent-local inventory read. It does not enter maintenance or change admission. */
1324
- hostedSeatCount(): number;
1325
- /** Public local-seat facts for the owning machine daemon. No mesh or secret reads. */
1326
- hostedAgents(): {
1327
- name: string;
1328
- application: string;
1329
- model?: string;
1330
- cwd: string;
1331
- startedAt: string;
1332
- state: "running" | "exited";
1333
- }[];
1334
- /** The served manager-level health summary. Given an owner, `agentCount` counts only that owner's
1335
- * seats, as `ps` lists them ({@link psOwnerFilter}), so a person reading a shared Manager does not
1336
- * learn how many seats other owners hold on it. */
1207
+ /** {@link StatusAndModels.hostedSeatCount}. */
1208
+ hostedSeatCount(...args: Parameters<StatusAndModels["hostedSeatCount"]>): ReturnType<StatusAndModels["hostedSeatCount"]>;
1209
+ /** {@link StatusAndModels.hostedAgents}. */
1210
+ hostedAgents(...args: Parameters<StatusAndModels["hostedAgents"]>): ReturnType<StatusAndModels["hostedAgents"]>;
1211
+ /** {@link StatusAndModels.managerStatusData}. */
1337
1212
  private managerStatusData;
1338
1213
  private staticReconciliationStatus;
1339
1214
  /** Complete a crashed predecessor's FROZEN registration gate before this incarnation starts a
@@ -1490,16 +1365,9 @@ export declare class Manager {
1490
1365
  private reconcileStaticLifecycles;
1491
1366
  /** {@link SeatStop.lifecycleMembershipRefusal}. */
1492
1367
  private lifecycleMembershipRefusal;
1493
- /** Open a short-lived PROVISIONER connection, run the onboarding ops on it, and drain it (closure (ii),
1494
- * residual 2). The DM/DLV consumer-create surface — the irreducible onboarding power — lives only for
1495
- * this window, never as a standing grant on the long-lived supervisor. A provision-only endpoint
1496
- * (no presence/consume/channel-watch) connected with memory-only `provisioner` creds; it sets its own
1497
- * `inboxPrefix` so JS-API replies land on the `_INBOX_<id>.>` the provisioner cred subscribes. */
1368
+ /** {@link BrokerTransport.withProvisioner}. */
1498
1369
  private withProvisioner;
1499
- /** A connection holding this instance's transfer reader grants (docs/design/resume-transfer.md
1500
- * section 6) for this one receive or sweep: minted from the space's signing seed, or issued by the
1501
- * host to a remote manager. An open mesh enforces no grants, so a bare one-shot connection is that
1502
- * reader there. */
1370
+ /** {@link BrokerTransport.withTransferReader}. */
1503
1371
  private withTransferReader;
1504
1372
  /** {@link SeatStop.opPurge}. */
1505
1373
  private opPurge;
@@ -1521,10 +1389,7 @@ export declare class Manager {
1521
1389
  private attachAuthorized;
1522
1390
  /** {@link TerminalInput.establishConsoleSession}. */
1523
1391
  private establishConsoleSession;
1524
- /** Managed agents cross-referenced with live presence (the manager sees the roster).
1525
- *
1526
- * `ownerFilter`: restrict to agents whose spawn-time stored `userOwner` equals it (the ps/status
1527
- * owner-domain bound); undefined = unbounded. {@link NO_OWNER_MATCHES} matches nothing. */
1392
+ /** {@link StatusAndModels.list}. */
1528
1393
  private list;
1529
1394
  }
1530
1395
  //# sourceMappingURL=manager.d.ts.map