@cotal-ai/manager 0.171.2 → 0.171.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/broker-transport.d.ts +126 -0
  2. package/dist/broker-transport.d.ts.map +1 -0
  3. package/dist/broker-transport.js +263 -0
  4. package/dist/broker-transport.js.map +1 -0
  5. package/dist/command-dispatch.d.ts +206 -0
  6. package/dist/command-dispatch.d.ts.map +1 -0
  7. package/dist/command-dispatch.js +471 -0
  8. package/dist/command-dispatch.js.map +1 -0
  9. package/dist/connector-inventory.d.ts +37 -0
  10. package/dist/connector-inventory.d.ts.map +1 -0
  11. package/dist/connector-inventory.js +73 -0
  12. package/dist/connector-inventory.js.map +1 -0
  13. package/dist/harness-resolution.d.ts +71 -0
  14. package/dist/harness-resolution.d.ts.map +1 -0
  15. package/dist/harness-resolution.js +111 -0
  16. package/dist/harness-resolution.js.map +1 -0
  17. package/dist/manager.d.ts +91 -375
  18. package/dist/manager.d.ts.map +1 -1
  19. package/dist/manager.js +400 -2811
  20. package/dist/manager.js.map +1 -1
  21. package/dist/persona-catalog.d.ts +86 -0
  22. package/dist/persona-catalog.d.ts.map +1 -0
  23. package/dist/persona-catalog.js +325 -0
  24. package/dist/persona-catalog.js.map +1 -0
  25. package/dist/preservation.d.ts +157 -0
  26. package/dist/preservation.d.ts.map +1 -0
  27. package/dist/preservation.js +583 -0
  28. package/dist/preservation.js.map +1 -0
  29. package/dist/readiness-wait.d.ts +64 -0
  30. package/dist/readiness-wait.d.ts.map +1 -0
  31. package/dist/readiness-wait.js +244 -0
  32. package/dist/readiness-wait.js.map +1 -0
  33. package/dist/runtime/index.d.ts +2 -0
  34. package/dist/runtime/index.d.ts.map +1 -1
  35. package/dist/runtime/index.js +22 -0
  36. package/dist/runtime/index.js.map +1 -1
  37. package/dist/service-adapter.d.ts.map +1 -1
  38. package/dist/service-adapter.js +6 -0
  39. package/dist/service-adapter.js.map +1 -1
  40. package/dist/spawn-goal.d.ts +77 -0
  41. package/dist/spawn-goal.d.ts.map +1 -0
  42. package/dist/spawn-goal.js +357 -0
  43. package/dist/spawn-goal.js.map +1 -0
  44. package/dist/start-doors.d.ts +51 -0
  45. package/dist/start-doors.d.ts.map +1 -0
  46. package/dist/start-doors.js +187 -0
  47. package/dist/start-doors.js.map +1 -0
  48. package/dist/status-and-models.d.ts +155 -0
  49. package/dist/status-and-models.d.ts.map +1 -0
  50. package/dist/status-and-models.js +290 -0
  51. package/dist/status-and-models.js.map +1 -0
  52. package/dist/terminal-input.d.ts +82 -0
  53. package/dist/terminal-input.d.ts.map +1 -0
  54. package/dist/terminal-input.js +266 -0
  55. package/dist/terminal-input.js.map +1 -0
  56. package/package.json +12 -12
@@ -0,0 +1,86 @@
1
+ import type { ControlReply, EpCaller } from "@cotal-ai/core";
2
+ import type { Manager } from "./manager.js";
3
+ /** What {@link PersonaCatalog} reads from the Manager. Every entry is read at use, so a field the Manager
4
+ * assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
5
+ export interface PersonaCatalogDeps {
6
+ agents: () => Manager["agents"];
7
+ execution: () => Manager["execution"];
8
+ meshMode: () => Manager["meshMode"];
9
+ remoteAuthority: () => Manager["remoteAuthority"];
10
+ space: () => Manager["space"];
11
+ userMode: () => Manager["userMode"];
12
+ workspaceRoot: () => Manager["workspaceRoot"];
13
+ executionRefusal: (...args: Parameters<Manager["executionRefusal"]>) => ReturnType<Manager["executionRefusal"]>;
14
+ managedPrincipal: (...args: Parameters<Manager["managedPrincipal"]>) => ReturnType<Manager["managedPrincipal"]>;
15
+ nameError: (...args: Parameters<Manager["nameError"]>) => ReturnType<Manager["nameError"]>;
16
+ spawnBoundRefusal: (...args: Parameters<Manager["spawnBoundRefusal"]>) => ReturnType<Manager["spawnBoundRefusal"]>;
17
+ spawnRun: (...args: Parameters<Manager["spawnRun"]>) => ReturnType<Manager["spawnRun"]>;
18
+ staticSpawnBound: (...args: Parameters<Manager["staticSpawnBound"]>) => ReturnType<Manager["staticSpawnBound"]>;
19
+ }
20
+ /** The persona catalog doors: define, remove, list and show, with the definer's grant check and read reach. */
21
+ export declare class PersonaCatalog {
22
+ private readonly deps;
23
+ constructor(deps: PersonaCatalogDeps);
24
+ private get agents();
25
+ private get execution();
26
+ private get meshMode();
27
+ private get remoteAuthority();
28
+ private get space();
29
+ private get userMode();
30
+ private get workspaceRoot();
31
+ private executionRefusal;
32
+ private managedPrincipal;
33
+ private nameError;
34
+ private spawnBoundRefusal;
35
+ private spawnRun;
36
+ private staticSpawnBound;
37
+ /** Persist a peer-defined persona as config. After this, `start name` auto-discovers
38
+ * .cotal/agents/<name>.md and the connector applies its persona/model at spawn.
39
+ *
40
+ * CONTENT vs POLICY: `owner` has no slot, so a peer cannot claim ownership, and the
41
+ * capabilities the written persona carries, a saved list a redefine keeps included, are bounded
42
+ * against the definer before the write, so a peer can put only what it holds into a persona that
43
+ * a wider spawner might later launch. Channel grants, role, and agent are content: they may
44
+ * arrive as explicit arguments or as a leading frontmatter block inside `persona`. A prompt
45
+ * that starts with `---` is parsed and merged (explicit args win) so the written file has one
46
+ * frontmatter block; a malformed block is refused by name rather than wrapped. A fresh name is
47
+ * created with the owner {@link personaOwner} records. Redefining an EXISTING file is allowed on
48
+ * the privileged tier only if `file.owner == caller`, else admin is required. Fail-closed: an
49
+ * ownerless file (legacy / operator-written) is admin-only. */
50
+ opDefinePersona(args: Record<string, unknown>, caller: string, admin: boolean, authenticated?: EpCaller): Promise<ControlReply>;
51
+ /** Resolve what a persona's definer may put into it, as a check that returns the refusal for
52
+ * capabilities or endpoint commands it does not hold, or `undefined` when it holds them all. The
53
+ * check itself does not yield. An open mesh mints no credential, so nothing is bounded there. A
54
+ * static definer is bounded by its issued evidence, as a spawner is; a user-auth definer by its
55
+ * own ledger row's scope, under the ledger's token rule, with `admin` exempt. A user-auth persona
56
+ * cannot name `endpoints` at all, `[]` included (SPEC 13.15). A hosted manager reads no ledger, so
57
+ * it refuses. A later spawn of the persona is bounded again against its own spawner. */
58
+ private definerGrantRefusal;
59
+ /** Remove one machine-local persona definition without touching any running lifecycle that was
60
+ * launched from it. Removal accepts the catalog's safe filename alphabet without applying the
61
+ * current spawn-name length or user-mode actor rules, so an obsolete invalid-name entry remains
62
+ * repairable. Ownership matches redefine: the recorded owner, or admin for an ownerless file. */
63
+ opRemovePersona(args: Record<string, unknown>, caller: string, admin: boolean): ControlReply;
64
+ /** The owner a fresh wire-defined persona records. A user-auth caller's principal is stable, and
65
+ * so is one of this manager's own seats for its life. Any other static caller, such as the CLI's
66
+ * operator instrument minted for one call, would leave an owner no later call matches, so it
67
+ * records none and the file is operator-owned, as a local `persona create` writes it. A peer
68
+ * joined with its own credential is such a caller too. */
69
+ personaOwner(caller: string): string | undefined;
70
+ /** Whether this caller may READ a catalog card's details (role/model/description/body). Same
71
+ * ownership rule as redefine: owner == caller, or admin. Ownerless / operator-written files are
72
+ * admin-only. Names of parseable files still appear on the list so a definer can see a taken
73
+ * spawn name; details stay off the wire unless this is true. */
74
+ canReadPersona(owner: string | undefined, caller: string, admin: boolean): boolean;
75
+ /** Mesh-side catalog list (#402). Every parseable name is returned so a definer can see a taken
76
+ * spawn name. Role / model / description / owner ride only when the caller could redefine the
77
+ * file (same ownership as `definePersona`); other cards are name-only, so a peer cannot read a
78
+ * prompt it does not own. Unparseable files are omitted for non-admin (no existence leak of a
79
+ * broken card). */
80
+ opListPersonas(caller: string, admin: boolean): ControlReply;
81
+ /** Mesh-side catalog show (#402). Same ownership as list. Unknown, unauthorized, or unparseable
82
+ * names are not-found (no existence or parser-diagnostic leak). The body is included so a peer can
83
+ * inspect a prompt it owns before spawn; policy fields stay off the wire. */
84
+ opShowPersona(args: Record<string, unknown>, caller: string, admin: boolean): ControlReply;
85
+ }
86
+ //# sourceMappingURL=persona-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona-catalog.d.ts","sourceRoot":"","sources":["../src/persona-catalog.ts"],"names":[],"mappings":"AACA,O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,EAAE,OAAO,GAAG,OAAO;IAIlF;;;;wBAIoB;IACpB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,YAAY;IAyB5D;;kFAE8E;IAC9E,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,YAAY;CA2B3F"}
@@ -0,0 +1,325 @@
1
+ import { agentFilePath, capabilityWithin, composeWirePersona, copyPersonaEndpoints, EpEnvelopeError, listPersonaCatalog, loadAgentFile, lowerPersonaEndpoints, parsePersonaEndpoints, parsePrincipalKey, personaCatalogDescription, personaCatalogReadable, rejectionText, resolveAuthProvider, saveAgentFile } from "@cotal-ai/core";
2
+ import { userAuthStateDir } from "@cotal-ai/workspace";
3
+ import { existsSync, readFileSync, rmSync } from "node:fs";
4
+ import { parse as parseYaml } from "yaml";
5
+ import { userMeshEndpointsRefusal } from "./seat-launch.js";
6
+ /** The persona catalog doors: define, remove, list and show, with the definer's grant check and read reach. */
7
+ export class PersonaCatalog {
8
+ deps;
9
+ constructor(deps) {
10
+ this.deps = deps;
11
+ }
12
+ // The Manager members these bodies read, under their Manager names. Each reads through its dep at
13
+ // use, so a field the Manager assigns later is current and a method a test replaces on the Manager
14
+ // is the one that runs.
15
+ get agents() { return this.deps.agents(); }
16
+ get execution() { return this.deps.execution(); }
17
+ get meshMode() { return this.deps.meshMode(); }
18
+ get remoteAuthority() { return this.deps.remoteAuthority(); }
19
+ get space() { return this.deps.space(); }
20
+ get userMode() { return this.deps.userMode(); }
21
+ get workspaceRoot() { return this.deps.workspaceRoot(); }
22
+ executionRefusal(...args) { return this.deps.executionRefusal(...args); }
23
+ managedPrincipal(...args) { return this.deps.managedPrincipal(...args); }
24
+ nameError(...args) { return this.deps.nameError(...args); }
25
+ spawnBoundRefusal(...args) { return this.deps.spawnBoundRefusal(...args); }
26
+ spawnRun(...args) { return this.deps.spawnRun(...args); }
27
+ staticSpawnBound(...args) { return this.deps.staticSpawnBound(...args); }
28
+ /** Persist a peer-defined persona as config. After this, `start name` auto-discovers
29
+ * .cotal/agents/<name>.md and the connector applies its persona/model at spawn.
30
+ *
31
+ * CONTENT vs POLICY: `owner` has no slot, so a peer cannot claim ownership, and the
32
+ * capabilities the written persona carries, a saved list a redefine keeps included, are bounded
33
+ * against the definer before the write, so a peer can put only what it holds into a persona that
34
+ * a wider spawner might later launch. Channel grants, role, and agent are content: they may
35
+ * arrive as explicit arguments or as a leading frontmatter block inside `persona`. A prompt
36
+ * that starts with `---` is parsed and merged (explicit args win) so the written file has one
37
+ * frontmatter block; a malformed block is refused by name rather than wrapped. A fresh name is
38
+ * created with the owner {@link personaOwner} records. Redefining an EXISTING file is allowed on
39
+ * the privileged tier only if `file.owner == caller`, else admin is required. Fail-closed: an
40
+ * ownerless file (legacy / operator-written) is admin-only. */
41
+ async opDefinePersona(args, caller, admin, authenticated) {
42
+ if (this.execution === "none")
43
+ throw new EpEnvelopeError("unimplemented", this.executionRefusal());
44
+ const name = String(args.name ?? "").trim();
45
+ if (!name)
46
+ return { ok: false, error: "name required" };
47
+ const nameErr = this.nameError(name);
48
+ if (nameErr)
49
+ return { ok: false, error: nameErr };
50
+ const persona = String(args.persona ?? "").trim();
51
+ if (!persona)
52
+ return { ok: false, error: "persona required" };
53
+ const path = agentFilePath(this.workspaceRoot, name);
54
+ const strList = (v) => {
55
+ if (v === undefined || v === null)
56
+ return undefined;
57
+ return (Array.isArray(v) ? v : [v]).map((x) => String(x));
58
+ };
59
+ const capabilities = strList(args.capabilities);
60
+ let endpointArg;
61
+ try {
62
+ endpointArg = parsePersonaEndpoints(args.endpoints, "define-persona");
63
+ }
64
+ catch (e) {
65
+ return { ok: false, error: rejectionText(e) };
66
+ }
67
+ // Read, authorize and compose against the catalog as it is now. Nothing yields between this and
68
+ // the write, so no other call in this manager can change the file in between. The handler does
69
+ // not serialize with other processes; their writes are outside this single-manager guarantee.
70
+ const compose = () => {
71
+ let existing;
72
+ if (existsSync(path)) {
73
+ try {
74
+ existing = loadAgentFile(path);
75
+ }
76
+ catch (e) {
77
+ return { reply: { ok: false, error: rejectionText(e) } };
78
+ }
79
+ if (!admin && existing.owner !== caller) {
80
+ const owner = existing.owner ? `owned by ${existing.owner}` : "operator-owned (legacy file - no agent owner)";
81
+ return { reply: {
82
+ ok: false, code: "permission-denied", outcome: "not-executed",
83
+ error: `not authorized to redefine ${name}: ${owner}; only its owner or an operator can`,
84
+ details: [{ kind: "ai.cotal.persona-ownership-refused", operatorOwned: existing.owner === undefined }],
85
+ } };
86
+ }
87
+ }
88
+ try {
89
+ return {
90
+ def: composeWirePersona({
91
+ name,
92
+ owner: this.personaOwner(caller),
93
+ prompt: persona,
94
+ model: args.model,
95
+ role: args.role,
96
+ agent: args.agent,
97
+ subscribe: strList(args.subscribe),
98
+ allowSubscribe: strList(args.allowSubscribe),
99
+ allowPublish: strList(args.allowPublish),
100
+ capabilities,
101
+ endpoints: copyPersonaEndpoints(endpointArg),
102
+ }, existing),
103
+ };
104
+ }
105
+ catch (e) {
106
+ return { reply: { ok: false, error: rejectionText(e) } };
107
+ }
108
+ };
109
+ let composed = compose();
110
+ if ("reply" in composed)
111
+ return composed.reply;
112
+ // The bound reads the persona as written, so a redefine that omits `capabilities` or `endpoints`
113
+ // has the list it keeps checked too. Resolving the definer's grant yields, so the catalog is read
114
+ // again after it.
115
+ if (composed.def.capabilities?.length || composed.def.endpoints !== undefined) {
116
+ const refusal = await this.definerGrantRefusal(caller, authenticated);
117
+ composed = compose();
118
+ if ("reply" in composed)
119
+ return composed.reply;
120
+ const kept = composed.def.capabilities ?? [];
121
+ const keptEndpoints = lowerPersonaEndpoints(composed.def.endpoints);
122
+ // A user-auth persona may not name the field at all; elsewhere `[]` hands on nothing to bound.
123
+ const namesEndpoints = composed.def.endpoints !== undefined;
124
+ const refused = kept.length || keptEndpoints.length || (namesEndpoints && this.meshMode === "user")
125
+ ? refusal({ capabilities: kept, endpoints: keptEndpoints, namesEndpoints })
126
+ : undefined;
127
+ if (refused) {
128
+ const fromSaved = [
129
+ ...(capabilities === undefined && kept.length ? ["capabilities"] : []),
130
+ ...(endpointArg === undefined && composed.def.endpoints?.length ? ["endpoints"] : []),
131
+ ];
132
+ return {
133
+ ok: false,
134
+ code: "permission-denied",
135
+ error: fromSaved.length
136
+ ? `${refused} ${fromSaved.map((f) => `\`${f}\``).join(" and ")} come${fromSaved.length === 1 ? "s" : ""} from the saved persona, which a redefine that omits ${fromSaved.length === 1 ? "it keeps" : "them keeps"}; pass what the definer holds, or [] to clear ${fromSaved.length === 1 ? "it" : "them"}.`
137
+ : refused,
138
+ };
139
+ }
140
+ }
141
+ try {
142
+ saveAgentFile(path, composed.def);
143
+ }
144
+ catch (e) {
145
+ return { ok: false, error: rejectionText(e) };
146
+ }
147
+ return { ok: true, data: { name, path } };
148
+ }
149
+ /** Resolve what a persona's definer may put into it, as a check that returns the refusal for
150
+ * capabilities or endpoint commands it does not hold, or `undefined` when it holds them all. The
151
+ * check itself does not yield. An open mesh mints no credential, so nothing is bounded there. A
152
+ * static definer is bounded by its issued evidence, as a spawner is; a user-auth definer by its
153
+ * own ledger row's scope, under the ledger's token rule, with `admin` exempt. A user-auth persona
154
+ * cannot name `endpoints` at all, `[]` included (SPEC 13.15). A hosted manager reads no ledger, so
155
+ * it refuses. A later spawn of the persona is bounded again against its own spawner. */
156
+ async definerGrantRefusal(caller, authenticated) {
157
+ if (this.meshMode === "open")
158
+ return () => undefined;
159
+ if (this.meshMode === "static") {
160
+ const run = await this.spawnRun(authenticated, undefined);
161
+ const bound = await this.staticSpawnBound(authenticated, run !== undefined && "admission" in run ? run : undefined);
162
+ return ({ capabilities, endpoints }) => this.spawnBoundRefusal(bound, { capabilities, ...(endpoints.length ? { endpoints } : {}) }, false, "define-persona");
163
+ }
164
+ if (this.remoteAuthority)
165
+ return ({ capabilities, namesEndpoints }) => namesEndpoints
166
+ ? userMeshEndpointsRefusal("define-persona")
167
+ : capabilities.length ? "define-persona: this manager's user authority is hosted, so it cannot read the definer's grant and its persona can grant no capabilities." : undefined;
168
+ const p = parsePrincipalKey(caller);
169
+ const scope = p ? await resolveAuthProvider().actorScope({ dir: userAuthStateDir(this.workspaceRoot, this.space), owner: p.owner, actor: p.actor }) : undefined;
170
+ return ({ capabilities, namesEndpoints }) => {
171
+ if (namesEndpoints)
172
+ return userMeshEndpointsRefusal("define-persona");
173
+ if (scope?.includes("admin"))
174
+ return undefined;
175
+ const over = capabilities.filter((c) => !capabilityWithin(scope ?? [], c));
176
+ if (!over.length)
177
+ return undefined;
178
+ return scope === undefined
179
+ ? `define-persona: the definer ${caller} has no grant in this space, so its persona can grant nothing. This persona asks for capabilities ${over.join(", ")}.`
180
+ : `define-persona: this persona grants more than the definer holds: capabilities ${over.join(", ")} beyond [${scope.join(", ") || "none"}]. Drop these from the persona, or have the operator widen the definer's grant.`;
181
+ };
182
+ }
183
+ /** Remove one machine-local persona definition without touching any running lifecycle that was
184
+ * launched from it. Removal accepts the catalog's safe filename alphabet without applying the
185
+ * current spawn-name length or user-mode actor rules, so an obsolete invalid-name entry remains
186
+ * repairable. Ownership matches redefine: the recorded owner, or admin for an ownerless file. */
187
+ opRemovePersona(args, caller, admin) {
188
+ if (this.execution === "none")
189
+ throw new EpEnvelopeError("unimplemented", this.executionRefusal());
190
+ const name = String(args.name ?? "").trim();
191
+ if (!name)
192
+ return { ok: false, code: "bad-request", error: "name required" };
193
+ if (!/^[A-Za-z0-9_-]+$/.test(name))
194
+ return { ok: false, code: "bad-request", error: `unsafe persona name ${JSON.stringify(name)} (allowed: letters, digits, _ -)` };
195
+ const path = agentFilePath(this.workspaceRoot, name);
196
+ if (!existsSync(path))
197
+ return { ok: false, code: "not-found", error: `no persona "${name}"` };
198
+ let owner;
199
+ try {
200
+ owner = loadAgentFile(path).owner;
201
+ }
202
+ catch {
203
+ // A catalog entry may be invalid for launch solely because an older release admitted a name
204
+ // above today's identity limit. Read only its frontmatter owner without asking the launch
205
+ // parser to accept the identity. This does not make the file spawnable or readable.
206
+ try {
207
+ const source = readFileSync(path, "utf8").replace(/^\uFEFF/, "").replace(/\r\n/g, "\n");
208
+ const match = /^---\n([\s\S]*?)\n---(?:\n|$)/.exec(source);
209
+ if (!match)
210
+ throw new Error("missing frontmatter");
211
+ const frontmatter = parseYaml(match[1]);
212
+ if (!frontmatter || typeof frontmatter !== "object" || Array.isArray(frontmatter))
213
+ throw new Error("frontmatter is not a mapping");
214
+ const fields = frontmatter;
215
+ if (String(fields.name ?? "") !== name)
216
+ throw new Error("frontmatter name differs from the catalog entry");
217
+ if (fields.owner !== undefined && typeof fields.owner !== "string")
218
+ throw new Error("owner is not a string");
219
+ owner = fields.owner;
220
+ }
221
+ catch {
222
+ return { ok: false, code: "not-found", error: `no persona "${name}"` };
223
+ }
224
+ }
225
+ if (!admin && owner !== caller) {
226
+ const heldBy = owner ? `owned by ${owner}` : "operator-owned (legacy file - no agent owner)";
227
+ return { ok: false, code: "permission-denied", error: `not authorized to remove ${name}: ${heldBy}; only its owner or an operator can` };
228
+ }
229
+ try {
230
+ rmSync(path);
231
+ }
232
+ catch (e) {
233
+ if (!existsSync(path))
234
+ return { ok: false, code: "not-found", error: `no persona "${name}"` };
235
+ return { ok: false, error: rejectionText(e) };
236
+ }
237
+ return { ok: true, data: { name } };
238
+ }
239
+ /** The owner a fresh wire-defined persona records. A user-auth caller's principal is stable, and
240
+ * so is one of this manager's own seats for its life. Any other static caller, such as the CLI's
241
+ * operator instrument minted for one call, would leave an owner no later call matches, so it
242
+ * records none and the file is operator-owned, as a local `persona create` writes it. A peer
243
+ * joined with its own credential is such a caller too. */
244
+ personaOwner(caller) {
245
+ if (this.userMode)
246
+ return caller;
247
+ for (const a of this.agents.values())
248
+ if (this.managedPrincipal(a) === caller)
249
+ return caller;
250
+ return undefined;
251
+ }
252
+ /** Whether this caller may READ a catalog card's details (role/model/description/body). Same
253
+ * ownership rule as redefine: owner == caller, or admin. Ownerless / operator-written files are
254
+ * admin-only. Names of parseable files still appear on the list so a definer can see a taken
255
+ * spawn name; details stay off the wire unless this is true. */
256
+ canReadPersona(owner, caller, admin) {
257
+ return personaCatalogReadable(owner, caller, admin);
258
+ }
259
+ /** Mesh-side catalog list (#402). Every parseable name is returned so a definer can see a taken
260
+ * spawn name. Role / model / description / owner ride only when the caller could redefine the
261
+ * file (same ownership as `definePersona`); other cards are name-only, so a peer cannot read a
262
+ * prompt it does not own. Unparseable files are omitted for non-admin (no existence leak of a
263
+ * broken card). */
264
+ opListPersonas(caller, admin) {
265
+ const personas = [];
266
+ for (const e of listPersonaCatalog(this.workspaceRoot)) {
267
+ if (e.error) {
268
+ if (!admin)
269
+ continue;
270
+ personas.push({ name: e.name, error: "unparseable" });
271
+ continue;
272
+ }
273
+ const def = e.def;
274
+ if (!this.canReadPersona(def.owner, caller, admin)) {
275
+ personas.push({ name: e.name });
276
+ continue;
277
+ }
278
+ const description = personaCatalogDescription(def);
279
+ personas.push({
280
+ name: e.name,
281
+ ...(def.role ? { role: def.role } : {}),
282
+ ...(def.model ? { model: def.model } : {}),
283
+ ...(description ? { description } : {}),
284
+ ...(def.owner ? { owner: def.owner } : {}),
285
+ });
286
+ }
287
+ return { ok: true, data: { personas } };
288
+ }
289
+ /** Mesh-side catalog show (#402). Same ownership as list. Unknown, unauthorized, or unparseable
290
+ * names are not-found (no existence or parser-diagnostic leak). The body is included so a peer can
291
+ * inspect a prompt it owns before spawn; policy fields stay off the wire. */
292
+ opShowPersona(args, caller, admin) {
293
+ const name = String(args.name ?? "").trim();
294
+ if (!name)
295
+ return { ok: false, error: "name required" };
296
+ const nameErr = this.nameError(name);
297
+ if (nameErr)
298
+ return { ok: false, error: nameErr };
299
+ const path = agentFilePath(this.workspaceRoot, name);
300
+ if (!existsSync(path))
301
+ return { ok: false, error: `no persona "${name}"` };
302
+ let def;
303
+ try {
304
+ def = loadAgentFile(path);
305
+ }
306
+ catch {
307
+ return { ok: false, error: `no persona "${name}"` };
308
+ }
309
+ if (!this.canReadPersona(def.owner, caller, admin))
310
+ return { ok: false, error: `no persona "${name}"` };
311
+ const description = personaCatalogDescription(def);
312
+ return {
313
+ ok: true,
314
+ data: {
315
+ name,
316
+ ...(def.role ? { role: def.role } : {}),
317
+ ...(def.model ? { model: def.model } : {}),
318
+ ...(description ? { description } : {}),
319
+ ...(def.owner ? { owner: def.owner } : {}),
320
+ ...(def.persona ? { persona: def.persona } : {}),
321
+ },
322
+ };
323
+ }
324
+ }
325
+ //# sourceMappingURL=persona-catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona-catalog.js","sourceRoot":"","sources":["../src/persona-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEtU,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAoB5D,+GAA+G;AAC/G,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,IAAwB;QAAxB,SAAI,GAAJ,IAAI,CAAoB;IAAG,CAAC;IAEzD,kGAAkG;IAClG,mGAAmG;IACnG,wBAAwB;IACxB,IAAY,MAAM,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnD,IAAY,SAAS,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CA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C,EAAE,CAAC;gBAC1C,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACjD;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,157 @@
1
+ import type { CotalEndpoint } from "@cotal-ai/core";
2
+ import type { Manager, ManagerPreservationPlan, ManagerPreserveOptions, ManagerPreserveResult, ManagerResumeAgent } from "./manager.js";
3
+ import type { AgentHandle } from "./runtime/index.js";
4
+ import type { ManagedAgent } from "./seat-types.js";
5
+ /** What {@link Preservation} reads from the Manager. Every entry is read at use, so a field the Manager
6
+ * assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
7
+ export interface PreservationDeps {
8
+ agents: () => Manager["agents"];
9
+ auth: () => Manager["auth"];
10
+ credRenewTimer: () => Manager["credRenewTimer"];
11
+ setCredRenewTimer: (value: Manager["credRenewTimer"]) => void;
12
+ ep: () => Manager["ep"];
13
+ execution: () => Manager["execution"];
14
+ lifecycleInFlight: () => Manager["lifecycleInFlight"];
15
+ maintenanceState: () => Manager["maintenanceState"];
16
+ setMaintenanceState: (value: Manager["maintenanceState"]) => void;
17
+ managerInstanceId: () => Manager["managerInstanceId"];
18
+ meshMode: () => Manager["meshMode"];
19
+ preservationAttemptId: () => Manager["preservationAttemptId"];
20
+ setPreservationAttemptId: (value: Manager["preservationAttemptId"]) => void;
21
+ preservationGeneration: () => Manager["preservationGeneration"];
22
+ setPreservationGeneration: (value: Manager["preservationGeneration"]) => void;
23
+ preservationInventory: () => Manager["preservationInventory"];
24
+ setPreservationInventory: (value: Manager["preservationInventory"]) => void;
25
+ preserveStopTimeoutMs: () => Manager["preserveStopTimeoutMs"];
26
+ resumeCredRenewal: () => Manager["resumeCredRenewal"];
27
+ space: () => Manager["space"];
28
+ unverifiedStops: () => Manager["unverifiedStops"];
29
+ setUnverifiedStops: (value: Manager["unverifiedStops"]) => void;
30
+ userMode: () => Manager["userMode"];
31
+ workspaceRoot: () => Manager["workspaceRoot"];
32
+ awaitLifecycleDrain: (...args: Parameters<Manager["awaitLifecycleDrain"]>) => ReturnType<Manager["awaitLifecycleDrain"]>;
33
+ deprovision: (...args: Parameters<Manager["deprovision"]>) => ReturnType<Manager["deprovision"]>;
34
+ dropInlineSnapshot: (...args: Parameters<Manager["dropInlineSnapshot"]>) => ReturnType<Manager["dropInlineSnapshot"]>;
35
+ dropSeatRecord: (...args: Parameters<Manager["dropSeatRecord"]>) => ReturnType<Manager["dropSeatRecord"]>;
36
+ executionRefusal: (...args: Parameters<Manager["executionRefusal"]>) => ReturnType<Manager["executionRefusal"]>;
37
+ fileDigest: (...args: Parameters<Manager["fileDigest"]>) => ReturnType<Manager["fileDigest"]>;
38
+ logSeatReaped: (...args: Parameters<Manager["logSeatReaped"]>) => ReturnType<Manager["logSeatReaped"]>;
39
+ onAgentExit: (...args: Parameters<Manager["onAgentExit"]>) => ReturnType<Manager["onAgentExit"]>;
40
+ recordContinuityAtStop: (...args: Parameters<Manager["recordContinuityAtStop"]>) => ReturnType<Manager["recordContinuityAtStop"]>;
41
+ renewDaemonCreds: (...args: Parameters<Manager["renewDaemonCreds"]>) => ReturnType<Manager["renewDaemonCreds"]>;
42
+ resumeEntry: (...args: Parameters<Manager["resumeEntry"]>) => ReturnType<Manager["resumeEntry"]>;
43
+ resumeEntryOf: (...args: Parameters<Manager["resumeEntryOf"]>) => ReturnType<Manager["resumeEntryOf"]>;
44
+ runtimeFor: (...args: Parameters<Manager["runtimeFor"]>) => ReturnType<Manager["runtimeFor"]>;
45
+ stopHandle: (...args: Parameters<Manager["stopHandle"]>) => ReturnType<Manager["stopHandle"]>;
46
+ teardownTarget: (...args: Parameters<Manager["teardownTarget"]>) => ReturnType<Manager["teardownTarget"]>;
47
+ validateRetainedAuthority: (...args: Parameters<Manager["validateRetainedAuthority"]>) => ReturnType<Manager["validateRetainedAuthority"]>;
48
+ watchExit: (...args: Parameters<Manager["watchExit"]>) => ReturnType<Manager["watchExit"]>;
49
+ withProvisioner: <T>(fn: (prov: CotalEndpoint) => Promise<T>) => Promise<T>;
50
+ }
51
+ /** Preserving the manager for a restart: prepare, commit and abort, the cut that releases or tears down each seat, and adoption of released seats at the next start. */
52
+ export declare class Preservation {
53
+ private readonly deps;
54
+ constructor(deps: PreservationDeps);
55
+ private get agents();
56
+ private get auth();
57
+ private get credRenewTimer();
58
+ private set credRenewTimer(value);
59
+ private get ep();
60
+ private get execution();
61
+ private get lifecycleInFlight();
62
+ private get maintenanceState();
63
+ private set maintenanceState(value);
64
+ private get managerInstanceId();
65
+ private get meshMode();
66
+ private get preservationAttemptId();
67
+ private set preservationAttemptId(value);
68
+ private get preservationGeneration();
69
+ private set preservationGeneration(value);
70
+ private get preservationInventory();
71
+ private set preservationInventory(value);
72
+ private get preserveStopTimeoutMs();
73
+ private get resumeCredRenewal();
74
+ private get space();
75
+ private get unverifiedStops();
76
+ private set unverifiedStops(value);
77
+ private get userMode();
78
+ private get workspaceRoot();
79
+ private awaitLifecycleDrain;
80
+ private deprovision;
81
+ private dropInlineSnapshot;
82
+ private dropSeatRecord;
83
+ private executionRefusal;
84
+ private fileDigest;
85
+ private logSeatReaped;
86
+ private onAgentExit;
87
+ private recordContinuityAtStop;
88
+ private renewDaemonCreds;
89
+ private resumeEntry;
90
+ private resumeEntryOf;
91
+ private runtimeFor;
92
+ private stopHandle;
93
+ private teardownTarget;
94
+ private validateRetainedAuthority;
95
+ private watchExit;
96
+ private withProvisioner;
97
+ private preparationTask?;
98
+ private preservationFailures;
99
+ private preservationTask?;
100
+ private preservationStarted;
101
+ /** The CHAT stream frontier at a preservation cut (issue #545), read through whichever local
102
+ * authority this mesh mode holds: open mode's own endpoint already has `$JS.API.STREAM.INFO`
103
+ * on the CHAT stream. Local and remote supervisor credentials also hold this metadata grant
104
+ * for transcript startup checks, but this preservation path retains its existing local-authority
105
+ * boundary. Static/user modes borrow the ephemeral `provisioner` profile the manager already
106
+ * mints per spawn. A remote-authority manager (`this.auth`
107
+ * undefined in static/user mode) has no local space authority to mint that provisioner with, so
108
+ * it prints one line and returns no floor — the inventory then carries none and resumed seats
109
+ * behave exactly as before this fix, not a silent partial degrade. */
110
+ private chatFrontierForPreservation;
111
+ /** Fence and build the inventory without stopping a child. The coordinator must durably persist
112
+ * this exact plan before calling commitPreservation with the same attempt id. */
113
+ preparePreservation(attemptId: string): Promise<ManagerPreservationPlan>;
114
+ private assertPreservationGeneration;
115
+ runPreparation(attemptId: string, generation: number): Promise<ManagerPreservationPlan>;
116
+ /** Stop children only after the coordinator has persisted the prepared inventory. Same-attempt
117
+ * retries are idempotent; a different attempt is refused. */
118
+ commitPreservation(attemptId: string): Promise<ManagerPreserveResult>;
119
+ /** Recover an abandoned prepare before any child stop. Once commit begins, preservation is
120
+ * irreversible and remains fenced until the coordinator records failure/recourse. */
121
+ abortPreservation(attemptId: string): void;
122
+ /** In-process convenience that preserves the crash barrier by awaiting durable persistence between
123
+ * prepare and commit. Wire callers use the explicit two-phase admin operations. */
124
+ preserveState(opts: ManagerPreserveOptions): Promise<ManagerPreserveResult>;
125
+ private runPreservation;
126
+ awaitHandleExit(handle: AgentHandle): Promise<void>;
127
+ inventoryReferenceError(entry: ManagerResumeAgent): string | undefined;
128
+ fileDigestOrEmpty(path: string): string;
129
+ /** Tear down every managed agent's footprint on an explicit destructive {@link stop}, or only the
130
+ * in-process seats a default stop cannot detach. A manager exit is
131
+ * a mass agent-exit, and without this its agents' footprints (creds files + `dm_`/`dlv_` durables + ACL
132
+ * rows) would orphan exactly as the per-agent exit path prevents. Stop each child gracefully, so its
133
+ * own shutdown runs before the runtime escalates, and AWAIT its deprovision — bounded per agent (`withTimeout`) and
134
+ * best-effort (`allSettled` + a loud log), so one slow/failed teardown can neither hang nor abort exit.
135
+ * The creds file is dropped even if the broker teardown fails (see {@link deprovision}). Deliberately
136
+ * touches NEITHER the lease NOR the endpoints — the caller owns those. */
137
+ teardownManagedAgents(managed?: ManagedAgent[]): Promise<void>;
138
+ isProcessBoundSeat(agent: ManagedAgent): boolean;
139
+ /** Drop local custody of every seat that can outlive this process, and leave it running. A seat
140
+ * with a runtime reference is recorded first, so the next manager on this workspace adopts it, or
141
+ * retires it once its runtime proves it gone. The stopping manager keeps no watch on a released
142
+ * seat: its endpoint is closing, and a retirement it drove afterwards would run over a dead
143
+ * connection and race the next manager's. `stop` is every seat left for the caller to stop and
144
+ * retire now: an in-process seat, a seat the runtime already reports gone, and a seat whose record
145
+ * could not be written, because a released seat nobody can find again is the leak this stop must
146
+ * not create. */
147
+ releaseManagedAgents(): {
148
+ failures: string[];
149
+ stop: ManagedAgent[];
150
+ };
151
+ /** Take back user-mode seats a previous manager released while they were still running. A seat
152
+ * the runtime adopts is watched, and retired when that watch proves it gone. A seat the runtime
153
+ * has already reaped is retired now. Anything the runtime cannot prove is left recorded. */
154
+ adoptReleasedSeats(): Promise<void>;
155
+ private adoptReleasedSeat;
156
+ }
157
+ //# sourceMappingURL=preservation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preservation.d.ts","sourceRoot":"","sources":["../src/preservation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAMpD,OAAO,KAAK,EAAE,OAAO,EAAE,uBAAuB,EAA0B,sBAAsB,EAAE,qBAAqB,EAAE,kBAAkB,EAA0B,MAAM,cAAc,CAAC;AAGxL,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;+GAC+G;AAC/G,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,cAAc,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChD,iBAAiB,EAAE,CA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