@cotal-ai/cli 0.16.0 → 0.18.0

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 (121) hide show
  1. package/cotal-skills/skills/team-topology/SKILL.md +1 -1
  2. package/dist/command.d.ts.map +1 -1
  3. package/dist/command.js +13 -0
  4. package/dist/command.js.map +1 -1
  5. package/dist/commands/agents.d.ts +15 -15
  6. package/dist/commands/agents.d.ts.map +1 -1
  7. package/dist/commands/agents.js +187 -77
  8. package/dist/commands/agents.js.map +1 -1
  9. package/dist/commands/clean.d.ts.map +1 -1
  10. package/dist/commands/clean.js +4 -3
  11. package/dist/commands/clean.js.map +1 -1
  12. package/dist/commands/describe.d.ts +72 -0
  13. package/dist/commands/describe.d.ts.map +1 -0
  14. package/dist/commands/describe.js +148 -0
  15. package/dist/commands/describe.js.map +1 -0
  16. package/dist/commands/doctor.d.ts.map +1 -1
  17. package/dist/commands/doctor.js +27 -8
  18. package/dist/commands/doctor.js.map +1 -1
  19. package/dist/commands/down-manifest.d.ts.map +1 -1
  20. package/dist/commands/down-manifest.js +38 -18
  21. package/dist/commands/down-manifest.js.map +1 -1
  22. package/dist/commands/down.d.ts +9 -0
  23. package/dist/commands/down.d.ts.map +1 -1
  24. package/dist/commands/down.js +38 -10
  25. package/dist/commands/down.js.map +1 -1
  26. package/dist/commands/ext.d.ts.map +1 -1
  27. package/dist/commands/ext.js +16 -10
  28. package/dist/commands/ext.js.map +1 -1
  29. package/dist/commands/join.d.ts.map +1 -1
  30. package/dist/commands/join.js +2 -4
  31. package/dist/commands/join.js.map +1 -1
  32. package/dist/commands/meshes-add.d.ts +17 -0
  33. package/dist/commands/meshes-add.d.ts.map +1 -1
  34. package/dist/commands/meshes-add.js +72 -4
  35. package/dist/commands/meshes-add.js.map +1 -1
  36. package/dist/commands/meshes-wizard.d.ts +3 -0
  37. package/dist/commands/meshes-wizard.d.ts.map +1 -1
  38. package/dist/commands/meshes-wizard.js +78 -6
  39. package/dist/commands/meshes-wizard.js.map +1 -1
  40. package/dist/commands/meshes.d.ts +4 -0
  41. package/dist/commands/meshes.d.ts.map +1 -1
  42. package/dist/commands/meshes.js +14 -4
  43. package/dist/commands/meshes.js.map +1 -1
  44. package/dist/commands/models.d.ts.map +1 -1
  45. package/dist/commands/models.js +2 -2
  46. package/dist/commands/models.js.map +1 -1
  47. package/dist/commands/spawn-manifest.d.ts.map +1 -1
  48. package/dist/commands/spawn-manifest.js +22 -12
  49. package/dist/commands/spawn-manifest.js.map +1 -1
  50. package/dist/commands/spawn.d.ts +5 -0
  51. package/dist/commands/spawn.d.ts.map +1 -1
  52. package/dist/commands/spawn.js +5 -3
  53. package/dist/commands/spawn.js.map +1 -1
  54. package/dist/commands/status.js +25 -5
  55. package/dist/commands/status.js.map +1 -1
  56. package/dist/commands/up.d.ts +17 -2
  57. package/dist/commands/up.d.ts.map +1 -1
  58. package/dist/commands/up.js +685 -50
  59. package/dist/commands/up.js.map +1 -1
  60. package/dist/console/app.d.ts +1 -1
  61. package/dist/console/app.d.ts.map +1 -1
  62. package/dist/console/app.js +16 -5
  63. package/dist/console/app.js.map +1 -1
  64. package/dist/console/commands.d.ts.map +1 -1
  65. package/dist/console/commands.js +5 -5
  66. package/dist/console/commands.js.map +1 -1
  67. package/dist/console/root.d.ts.map +1 -1
  68. package/dist/console/root.js +6 -1
  69. package/dist/console/root.js.map +1 -1
  70. package/dist/ext-loader.d.ts.map +1 -1
  71. package/dist/ext-loader.js +1 -0
  72. package/dist/ext-loader.js.map +1 -1
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +23 -0
  75. package/dist/index.js.map +1 -1
  76. package/dist/lib/attach-client.d.ts +37 -4
  77. package/dist/lib/attach-client.d.ts.map +1 -1
  78. package/dist/lib/attach-client.js +88 -18
  79. package/dist/lib/attach-client.js.map +1 -1
  80. package/dist/lib/auth-proc.d.ts +3 -1
  81. package/dist/lib/auth-proc.d.ts.map +1 -1
  82. package/dist/lib/auth-proc.js +15 -4
  83. package/dist/lib/auth-proc.js.map +1 -1
  84. package/dist/lib/connect.d.ts +1 -1
  85. package/dist/lib/connect.d.ts.map +1 -1
  86. package/dist/lib/connect.js +1 -1
  87. package/dist/lib/connect.js.map +1 -1
  88. package/dist/lib/control.d.ts +48 -12
  89. package/dist/lib/control.d.ts.map +1 -1
  90. package/dist/lib/control.js +258 -46
  91. package/dist/lib/control.js.map +1 -1
  92. package/dist/lib/delivery-proc.d.ts +19 -4
  93. package/dist/lib/delivery-proc.d.ts.map +1 -1
  94. package/dist/lib/delivery-proc.js +129 -43
  95. package/dist/lib/delivery-proc.js.map +1 -1
  96. package/dist/lib/join-target.d.ts +112 -0
  97. package/dist/lib/join-target.d.ts.map +1 -0
  98. package/dist/lib/join-target.js +130 -0
  99. package/dist/lib/join-target.js.map +1 -0
  100. package/dist/lib/manager-proc.d.ts +48 -5
  101. package/dist/lib/manager-proc.d.ts.map +1 -1
  102. package/dist/lib/manager-proc.js +131 -30
  103. package/dist/lib/manager-proc.js.map +1 -1
  104. package/dist/lib/manifest/ledger.d.ts +52 -8
  105. package/dist/lib/manifest/ledger.d.ts.map +1 -1
  106. package/dist/lib/manifest/ledger.js +77 -19
  107. package/dist/lib/manifest/ledger.js.map +1 -1
  108. package/dist/lib/manifest/live.d.ts +21 -16
  109. package/dist/lib/manifest/live.d.ts.map +1 -1
  110. package/dist/lib/manifest/live.js +33 -20
  111. package/dist/lib/manifest/live.js.map +1 -1
  112. package/dist/lib/restore.d.ts.map +1 -1
  113. package/dist/lib/restore.js +21 -3
  114. package/dist/lib/restore.js.map +1 -1
  115. package/dist/view/mesh-view.js +2 -2
  116. package/dist/view/mesh-view.js.map +1 -1
  117. package/package.json +4 -3
  118. package/dist/lib/pid.d.ts +0 -23
  119. package/dist/lib/pid.d.ts.map +0 -1
  120. package/dist/lib/pid.js +0 -39
  121. package/dist/lib/pid.js.map +0 -1
@@ -1,11 +1,14 @@
1
- import { type ControlReply, type ControlTier, type Profile } from "@cotal-ai/core";
1
+ import { type ControlReply, type EpCaller, type Profile } from "@cotal-ai/core";
2
2
  import { type ConnectFlags } from "./connect.js";
3
3
  /** Endpoint auth material for one control call — a static/raw cred OR user-mode bearer+sentinel
4
- * (spread into the endpoint verbatim). */
4
+ * (spread into the endpoint verbatim), plus the minted instrument's v0.4 caller triple when the
5
+ * static mint produced one ({@link askManager}'s ep-rail path rides it). */
5
6
  export type ControlAuth = {
6
7
  creds?: string;
7
8
  bearer?: string;
8
9
  sentinelCreds?: string;
10
+ epCaller?: EpCaller;
11
+ tls?: boolean;
9
12
  };
10
13
  /** Client-side request window for the manager's readiness-waiting launch ops (`start`, and the
11
14
  * manifest `launch` — both funnel into the same startAgent readiness wait). #159 B1: the manager
@@ -24,19 +27,52 @@ export declare const START_TIMEOUT_MS = 40000;
24
27
  * Lived in `@cotal-ai/manager` before stage 2a moved the control clients into the CLI; the
25
28
  * duplicated resolution/preflight wrappers collapsed onto `lib/connect.ts`.
26
29
  */
27
- export declare function resolveControlTarget(flags: ConnectFlags, profile: Profile): Promise<{
30
+ export declare function resolveControlTarget(flags: ConnectFlags, profile: Profile,
31
+ /** `--on <instanceId>`: the instance this invocation addresses. Forwarded to the instrument mint
32
+ * so the one-shot credential carries the exact `ep.inst.…` rows for it. Omitted ⇒ class rails
33
+ * only, exactly as before. It has to arrive HERE rather than at the invoke: the instrument is
34
+ * minted during this resolve, and a credential cannot gain a rail after it is issued. */
35
+ instanceId?: string): Promise<{
28
36
  space: string;
29
37
  server: string;
30
38
  auth: ControlAuth;
31
39
  }>;
32
- /** Connect a short-lived client with the resolved creds, send one control request to the manager,
33
- * disconnect. The target is already reachability- + auth-preflighted by
34
- * {@link resolveControlTarget}, so this connects straight through. `tier` picks the control
35
- * subject: privileged for spawn --detach/ps — and, on a user mesh, for stop/attach too (the
36
- * operator's bearer publishes there with scope "spawn"; the MANAGER authorizes owner-domain vs
37
- * ledger-admin). On a static mesh stop/attach stay admin-tier ops. `creds` is the tier-scoped
38
- * caller cred (`control-caller-privileged` / `control-caller-admin` each holds ONLY its own
39
- * tier's pub grant), or undefined on an open mesh. */
40
- export declare function askManager(space: string, server: string, op: string, args?: Record<string, unknown>, auth?: ControlAuth, tier?: ControlTier, timeoutMs?: number): Promise<ControlReply>;
40
+ /** Operator reach for one targeted control call: `owner` rides the caller's own-domain verb rows
41
+ * (the spawn capability's standing mint), `any` the admin instrument's cross-agent rows (§13.2
42
+ * any-mode). Replaces the deleted manager ctl tiers as the CLI's mode selector (1d). */
43
+ export type ControlReach = "owner" | "any";
44
+ /** Send one control command to the manager over the v0.4 service-endpoint rails and disconnect —
45
+ * since 1d the manager's ONLY control door (the `ctl` tiers are deleted). The target is already
46
+ * reachability- + auth-preflighted by {@link resolveControlTarget}. `reach` picks the operator
47
+ * mode for the two targeted ops (stop/attach): `owner` = the caller's own domain (the spawn
48
+ * capability's standing mint / a user bearer's own owner), `any` = the admin instrument's
49
+ * cross-agent reach. Three auth shapes reach the rails: a static instrument's caller triple, a
50
+ * user bearer's triple, or an OPEN mesh (no credential system — a bare connection under a
51
+ * synthesized DEV_OWNER triple, since the manager registered under DEV_OWNER and the broker
52
+ * enforces nothing). A raw `--creds` file from an older generation carries no ep rows and is
53
+ * refused loud (no silent ctl fallback exists anymore). */
54
+ export declare function askManager(space: string, server: string, op: string, args?: Record<string, unknown>, auth?: ControlAuth, reach?: ControlReach, timeoutMs?: number, instanceId?: string): Promise<ControlReply>;
55
+ /** One instance's slot in a class scatter (P2 item 3): a REACHABLE instance carries its attributed
56
+ * reply (`data` on ok, `error` on a per-instance failure); an UNREACHABLE one (a frozen slot that
57
+ * produced no on-time reply — a severed/stalled manager) is reported, NEVER omitted (SPEC §13.5 pin 3). */
58
+ export interface ScatterInstanceReply {
59
+ instanceId: string;
60
+ reachable: boolean;
61
+ data?: unknown;
62
+ error?: string;
63
+ }
64
+ export type ScatterReply = {
65
+ ok: true;
66
+ instances: ScatterInstanceReply[];
67
+ } | {
68
+ ok: false;
69
+ error: string;
70
+ };
71
+ /** SCATTER one untargeted read (`ps`) across EVERY registered manager instance in the space and merge
72
+ * the attributed results — the `cotal ps` default in a multi-manager space (P2 item 3). Auth shapes
73
+ * match {@link askManager}: a minted instrument or user bearer rides its own caller triple; a raw
74
+ * pre-1c `--creds` file is refused loud; an OPEN mesh synthesizes a DEV_OWNER triple and connects
75
+ * bare (the broker enforces nothing, so the records freeze reads freely). */
76
+ export declare function scatterManager(space: string, server: string, op: string, auth?: ControlAuth, timeoutMs?: number): Promise<ScatterReply>;
41
77
  export declare function failIfNotOk(reply: ControlReply): void;
42
78
  //# sourceMappingURL=control.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/lib/control.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,OAAO,EACb,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEhE;2CAC2C;AAC3C,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF;;;;;wBAKwB;AACxB,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,CAgB/D;AAED;;;;;;;uDAOuD;AACvD,wBAAsB,UAAU,CAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CA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B,IAAI,GAAE,WAAgB,EACtB,KAAK,GAAE,YAAsB,EAC7B,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,CAAC,CAYvB;AAED;;4GAE4G;AAC5G,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,oBAAoB,EAAE,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AA6C1G;;;;8EAI8E;AAC9E,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,GAAE,WAAgB,EACtB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,YAAY,CAAC,CAOvB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAUrD"}
@@ -1,7 +1,18 @@
1
- import { CotalEndpoint, DEFAULT_SPACE, CONTROL_PRIVILEGED, CONTROL_ADMIN, } from "@cotal-ai/core";
2
- import { authDir, endpointAuth, findCotalRoot, loadSpaceAuth, soleSpaceOf } from "@cotal-ai/workspace";
1
+ import { DEFAULT_SPACE, DEV_OWNER, BASELINE_LIFECYCLE_ENDPOINT, EpEnvelopeError, GOAL_BEARING_COMMANDS, invokeCommand, submitAndFollowGoal, scatterCommand, mintLifecycleUid, newIdentity, resolveService, standaloneConnectOpts, } from "@cotal-ai/core";
2
+ import { connect } from "@nats-io/transport-node";
3
+ import { authDir, endpointAuth, findCotalRoot, isWorkspaceTargetError, loadSpaceAuth, resolveMeshTarget, pruneStaleMeshes, renderWorkspaceError, soleSpaceOf, } from "@cotal-ai/workspace";
3
4
  import { c, staleStoreHint } from "../ui.js";
4
- import { connectOrExit } from "./connect.js";
5
+ import { connectOrExit, connectUserControlOrExit } from "./connect.js";
6
+ /** The only {@link MeshTargetErrorCode}s that mean "there is NO registry entry here", and so the
7
+ * only ones the mode peek in {@link resolveControlTarget} may absorb. **Every other code is
8
+ * NON-ABSENCE and must fail loud** — which is the precise claim, and covers more than one
9
+ * situation: `stale-auth-root` / `unreadable-auth` / `user-auth-unrecorded` are an entry that
10
+ * exists and is broken, while `ambiguous-target` can be several perfectly healthy entries and
11
+ * `default-occupied` an intended local target with no entry at all. What unites them is not
12
+ * breakage, it is that absence has NOT been established, so falling through to a
13
+ * credential-less raw-open connect would be unsound. Deliberately a closed allow-list, not a
14
+ * deny-list: a new code defaults to failing loud. */
15
+ const TARGET_ABSENT_CODES = new Set(["unknown-space", "no-meshes"]);
5
16
  /** Client-side request window for the manager's readiness-waiting launch ops (`start`, and the
6
17
  * manifest `launch` — both funnel into the same startAgent readiness wait). #159 B1: the manager
7
18
  * replies only on a REAL outcome — presence join, process exit, or its ~30s readiness backstop —
@@ -19,62 +30,263 @@ export const START_TIMEOUT_MS = 40_000;
19
30
  * Lived in `@cotal-ai/manager` before stage 2a moved the control clients into the CLI; the
20
31
  * duplicated resolution/preflight wrappers collapsed onto `lib/connect.ts`.
21
32
  */
22
- export async function resolveControlTarget(flags, profile) {
33
+ export async function resolveControlTarget(flags, profile,
34
+ /** `--on <instanceId>`: the instance this invocation addresses. Forwarded to the instrument mint
35
+ * so the one-shot credential carries the exact `ep.inst.…` rows for it. Omitted ⇒ class rails
36
+ * only, exactly as before. It has to arrive HERE rather than at the invoke: the instrument is
37
+ * minted during this resolve, and a credential cannot gain a rail after it is issued. */
38
+ instanceId) {
23
39
  const withSpace = flags.creds
24
40
  ? { ...flags, space: flags.space ?? soleSpaceOf(authDir(findCotalRoot())) ?? DEFAULT_SPACE }
25
41
  : flags;
26
- // USER MODE rides through: the control call connects with the operator's bearer (actor `cli`) and
27
- // publishes on its OWN ctl principal subject the broker grants that publish only when the cli
28
- // actor's ledger scope carries the matching capability (`spawn` privileged, `admin` admin).
29
- // The preflight probe STAYS, and the duplicate handshake with it. Removing it saved one connect
30
- // per control command, and cost two things worth more: the classified failure (a live broker
31
- // rejecting stale registry creds reads as `registry-creds-rejected`/`stale-auth` with the right
32
- // repair, not "is it running? run cotal up"), and the probe's 8s bound — `CotalEndpoint` passes no
33
- // connect timeout, so nats-core's 20s default would apply and a blackholed target would hang more
34
- // than twice as long to produce worse copy. Reusing the real connection is the right idea; it needs
35
- // the endpoint to accept a deadline and the classifier to move with it, which is not this change.
36
- const conn = await connectOrExit(withSpace, profile);
37
- return { space: conn.space, server: conn.server, auth: endpointAuth(conn) };
42
+ // USER MODE: ledger-scoped bearer is the control surface; there is no instrument mint.
43
+ // `connectOrExit` refuses control-caller-* on a user mesh (those profiles carry freeze rows the
44
+ // bearer does not hold). Route through {@link connectUserControlOrExit}, which takes NO role
45
+ // a dummy Profile would be meaningless today and wrong the day the user path starts consulting
46
+ // it. Declared translation at this layer (the one that knows), not a silent substitute inside
47
+ // connectOrExit.
48
+ //
49
+ // Cost: the target is resolved here for the mode check and again inside the connect helper.
50
+ // Accepted for this slice so mode choice stays where it is knowable. The two reads are not
51
+ // atomic; a mesh that flips mode between them is an operator action mid-command.
52
+ //
53
+ // This peek reads the MODE and NOTHING ELSE — it must never decide the command's fate. It used
54
+ // to run through `resolveTargetOrExit`, which EXITS on a WorkspaceTargetError, so it killed a
55
+ // legitimate input on the way past: `--server` with an UNREGISTERED `--space` is the raw-open
56
+ // escape hatch, and by definition it has no registry entry to carry a mode. Resolve through the
57
+ // THROWING form instead and read ABSENCE as "not a registry mesh, therefore not user mode",
58
+ // leaving that path to `connectOrExit` below, which owns it.
59
+ //
60
+ // ABSENCE ONLY. The two absent codes are the entire escape hatch; every other
61
+ // MeshTargetErrorCode is NON-ABSENCE, and swallowing those is a
62
+ // fallback, not a restoration. `stale-auth-root` is the one that bites: `targetFromEntry`
63
+ // PRUNES the entry before throwing it, so absorbing it leaves `connectOrExit` seeing no
64
+ // registration at all — and with an explicit `--server` it then takes the raw-open arm and
65
+ // connects with NO CREDENTIALS. A misconfigured AUTH mesh would silently become an OPEN one,
66
+ // hiding the misconfiguration and switching identity planes under the operator. Those codes
67
+ // rethrow and the command dies loud, exactly as it did before this peek existed.
68
+ // Raw `--creds` skips the peek entirely (static/raw path below).
69
+ if (!withSpace.creds) {
70
+ // Sweep first when no space is named, exactly as `resolveTargetOrExit` does before ITS
71
+ // resolve. Without it the peek reads a world `connectOrExit` never sees: a dead entry
72
+ // alongside a live one makes a bare resolve `ambiguous-target` here while the connect,
73
+ // having pruned, resolves the single survivor cleanly. Same sweep, same view, one answer.
74
+ if (!withSpace.space)
75
+ await pruneStaleMeshes();
76
+ let mode;
77
+ try {
78
+ mode = resolveMeshTarget(process.cwd(), { server: withSpace.server, space: withSpace.space }).mode;
79
+ }
80
+ catch (e) {
81
+ // Non-absence propagates and ends the command. It is rethrown rather than rendered-and-exited
82
+ // here so this function stays composable and testable; the CLI boundary renders every
83
+ // WorkspaceTargetError through `renderWorkspaceError` (see the dispatcher's catch), which is
84
+ // what turns "entry X points at a root holding Y" into the removed-fact plus a recovery line.
85
+ if (!isWorkspaceTargetError(e) || !TARGET_ABSENT_CODES.has(e.code))
86
+ throw e;
87
+ }
88
+ if (mode === "user") {
89
+ const conn = await connectUserControlOrExit(withSpace);
90
+ return {
91
+ space: conn.space,
92
+ server: conn.server,
93
+ auth: { ...endpointAuth(conn), ...(conn.epCaller ? { epCaller: conn.epCaller } : {}) },
94
+ };
95
+ }
96
+ }
97
+ // Static / open / raw-creds: mint the requested instrument (or bare open connect).
98
+ const conn = await connectOrExit(withSpace, profile, ...(instanceId !== undefined ? [{ instanceId }] : []));
99
+ return {
100
+ space: conn.space,
101
+ server: conn.server,
102
+ auth: { ...endpointAuth(conn), ...(conn.epCaller ? { epCaller: conn.epCaller } : {}) },
103
+ };
104
+ }
105
+ /** v0.3 ctl op → v0.4 typed command (P2 item 1, 1c.2b): the wire names the manager REGISTERS
106
+ * (manager-service-contract ROWS). `start` is creation (`spawn`), a NAMED `stop` is the one
107
+ * owner/any-mode terminal (`despawn`), the per-agent `status` read is `inspect`; the camelCase
108
+ * admin family maps to its kebab-case wire names. `targeted` marks the two commands whose
109
+ * `{name}` argument becomes a §13.2 target block (resolved to the agent's principal triple via
110
+ * the name-keyed `inspect` read — it rides the spawn capability arm, so resolution reach equals
111
+ * despawn/attach reach; the wire target is (owner, actor, lifecycleUid), never an alias). */
112
+ const EP_COMMANDS = {
113
+ start: { command: "spawn" },
114
+ stop: { command: "despawn", targeted: true },
115
+ attach: { command: "attach", targeted: true },
116
+ status: { command: "inspect" },
117
+ ps: { command: "ps" },
118
+ models: { command: "models" },
119
+ launch: { command: "launch" },
120
+ purge: { command: "purge" },
121
+ resumePreserved: { command: "resume-preserved" },
122
+ commitResume: { command: "commit-resume" },
123
+ finalizeResume: { command: "finalize-resume" },
124
+ preparePreservation: { command: "prepare-preservation" },
125
+ commitPreservation: { command: "commit-preservation" },
126
+ abortPreservation: { command: "abort-preservation" },
127
+ };
128
+ /** The ep-rail control call — since 1d {@link askManager}'s ONLY path: one short-lived raw
129
+ * connection, a fresh `resolveService` (describe → §13.7 store fetch → digest-verified recompile
130
+ * — the generic item-5 caller, no hand-imported manager schemas), then the mapped command.
131
+ * Targeted ops resolve the alias to its CURRENT principal triple through the name-keyed
132
+ * `inspect` read first and ride mode `any` (admin instruments) or `owner` per {@link
133
+ * ControlReach}. */
134
+ async function askManagerEp(space, server, op, args, auth, reach, timeoutMs, instanceId) {
135
+ const mapped = EP_COMMANDS[op];
136
+ if (!mapped)
137
+ return { ok: false, error: `unknown manager op "${op}" (no v0.4 command mapping)` };
138
+ const caller = auth.epCaller;
139
+ // standaloneConnectOpts handles all three auth shapes: static creds, the user bearer + sentinel
140
+ // (client-chosen inbox nonce; the callout scopes the reply inbox on it), or BARE on an open
141
+ // mesh (no credential system; the broker enforces nothing).
142
+ const nc = await connect({
143
+ servers: server,
144
+ ...standaloneConnectOpts(auth.creds ? { creds: auth.creds, tls: auth.tls === true } : auth.bearer ? { bearer: auth.bearer, sentinelCreds: auth.sentinelCreds, tls: auth.tls === true } : { tls: auth.tls === true }),
145
+ maxReconnectAttempts: 0,
146
+ });
147
+ try {
148
+ // P2 item 3 `--on <instance>`: pin the resolve to the exact manager instance's `inst` route so a
149
+ // multi-manager space addresses the intended manager, never whichever wins the class anycast.
150
+ const service = await resolveService(nc, space, BASELINE_LIFECYCLE_ENDPOINT, caller, { deadlineMs: 10_000, ...(instanceId !== undefined ? { instanceId } : {}) });
151
+ let target;
152
+ let sendArgs = args;
153
+ if (mapped.targeted) {
154
+ const name = String(args?.name ?? "").trim();
155
+ if (!name)
156
+ return { ok: false, error: `${op} requires a name` };
157
+ // Alias -> CURRENT principal triple via the manager's name-keyed `inspect` read (§13.2: a
158
+ // target is a triple, never an alias) - the same resolution the connector uses. `inspect`
159
+ // rides the SPAWN capability arm as well as the instrument read set, so every caller class
160
+ // that can despawn/attach can also resolve its target (a `ps` SCAN here broker-drops exactly
161
+ // the spawn-scoped user bearers - the 1c.2b read narrowing - and hangs their stop/attach).
162
+ const info = await invokeCommand(nc, space, service, "inspect", { name }, { deadlineMs: 10_000 });
163
+ if (info.reply.ok !== true)
164
+ return { ok: false, error: `could not resolve "${name}": ${info.reply.error?.message ?? info.reply.error?.code ?? "inspect failed"}` };
165
+ const row = info.reply.data;
166
+ // A STATIC row's `id` is the bare actor under the caller's own owner; a USER-mode row's `id`
167
+ // is the composite `owner.actor` principal key - split it (an embedded dot would break the
168
+ // target block's subject arity). Mode `any` spans owners (operator reach); mode `owner` pins
169
+ // the caller's own, so a foreign-owner target is broker-denied at publish.
170
+ const dot = row.id.indexOf(".");
171
+ const [tOwner, tActor] = dot > 0 ? [row.id.slice(0, dot), row.id.slice(dot + 1)] : [caller.owner, row.id];
172
+ // Target mode from the RESOLVED target owner: an own-domain target rides `owner` mode (pinned
173
+ // to the caller's own owner); a CROSS-owner target rides `any` mode - which the broker admits
174
+ // only for a caller holding the admin instrument rows (a static admin instrument, or a user
175
+ // bearer whose ledger `admin` scope the callout minted them into). `reach: "any"` forces
176
+ // any-mode for a static admin instrument even on its own domain. So a spawn-scoped caller's
177
+ // cross-owner despawn/attach is broker-denied at publish (no any-mode row), while an
178
+ // admin-scoped operator's is admitted and the manager's fresh ledger check governs.
179
+ const mode = reach === "any" || tOwner !== caller.owner ? "any" : "owner";
180
+ target = {
181
+ mode,
182
+ owner: tOwner,
183
+ actor: tActor,
184
+ lifecycleUid: row.lifecycleUid,
185
+ };
186
+ const { name: _dropped, ...rest } = args ?? {};
187
+ sendArgs = Object.keys(rest).length ? rest : undefined;
188
+ }
189
+ const invokeOpts = { ...(target ? { target } : {}), deadlineMs: timeoutMs ?? 10_000 };
190
+ const submit = () => invokeCommand(nc, space, service, mapped.command, sendArgs, invokeOpts);
191
+ // P2 item 2 (2b): a goal-bearing command (spawn/launch) FOLLOWS its acceptance to the goal
192
+ // terminal, so `spawn --detach` still returns on the real outcome (join / exit / ~30s uncertain)
193
+ // exactly like the pre-action blocking reply — UX unchanged, no --no-wait.
194
+ const r = GOAL_BEARING_COMMANDS.includes(mapped.command)
195
+ ? await submitAndFollowGoal(nc, space, BASELINE_LIFECYCLE_ENDPOINT, caller, timeoutMs ?? START_TIMEOUT_MS, submit)
196
+ : await submit();
197
+ if (r.reply.ok !== true)
198
+ return { ok: false, error: r.reply.error?.message ?? r.reply.error?.code ?? "error" };
199
+ // The ep `models` reply is normalized to `{catalogs}` — unwrap so call sites keep the ctl shape.
200
+ const data = mapped.command === "models" ? r.reply.data.catalogs : r.reply.data;
201
+ return { ok: true, ...(data !== undefined ? { data } : {}) };
202
+ }
203
+ catch (e) {
204
+ const msg = e instanceof EpEnvelopeError ? `${e.code}: ${e.message}` : e.message;
205
+ return { ok: false, error: `no manager reachable on the ep rails (${msg})` };
206
+ }
207
+ finally {
208
+ await nc.drain().catch(() => nc.close());
209
+ }
210
+ }
211
+ /** Send one control command to the manager over the v0.4 service-endpoint rails and disconnect —
212
+ * since 1d the manager's ONLY control door (the `ctl` tiers are deleted). The target is already
213
+ * reachability- + auth-preflighted by {@link resolveControlTarget}. `reach` picks the operator
214
+ * mode for the two targeted ops (stop/attach): `owner` = the caller's own domain (the spawn
215
+ * capability's standing mint / a user bearer's own owner), `any` = the admin instrument's
216
+ * cross-agent reach. Three auth shapes reach the rails: a static instrument's caller triple, a
217
+ * user bearer's triple, or an OPEN mesh (no credential system — a bare connection under a
218
+ * synthesized DEV_OWNER triple, since the manager registered under DEV_OWNER and the broker
219
+ * enforces nothing). A raw `--creds` file from an older generation carries no ep rows and is
220
+ * refused loud (no silent ctl fallback exists anymore). */
221
+ export async function askManager(space, server, op, args, auth = {}, reach = "owner", timeoutMs, instanceId) {
222
+ // A user bearer or a minted static instrument carries its own ep caller triple: ride it.
223
+ if (auth.epCaller && (auth.creds || (auth.bearer && auth.sentinelCreds)))
224
+ return askManagerEp(space, server, op, args, auth, reach, timeoutMs, instanceId);
225
+ // A raw `--creds` file with NO minted triple is a pre-1c generation's cred (no ep rows). The ctl
226
+ // rail it used to ride is gone (1d), so refuse loud with the recovery rather than hang.
227
+ if (auth.creds)
228
+ return { ok: false, error: `this --creds file predates the v0.4 control surface (no endpoint-serve rows); re-mint it with a current cotal, or drive the manager from its project folder (\`cotal ps\`/\`cotal stop\`) which mints the instrument for you` };
229
+ // OPEN mesh: no credential system. The manager registered its service under DEV_OWNER and the
230
+ // broker enforces nothing, so synthesize a fresh DEV_OWNER caller triple and connect bare.
231
+ const openAuth = { epCaller: { owner: DEV_OWNER, actor: newIdentity().id, uid: mintLifecycleUid() } };
232
+ return askManagerEp(space, server, op, args, openAuth, reach, timeoutMs, instanceId);
38
233
  }
39
- /** Connect a short-lived client with the resolved creds, send one control request to the manager,
40
- * disconnect. The target is already reachability- + auth-preflighted by
41
- * {@link resolveControlTarget}, so this connects straight through. `tier` picks the control
42
- * subject: privileged for spawn --detach/ps and, on a user mesh, for stop/attach too (the
43
- * operator's bearer publishes there with scope "spawn"; the MANAGER authorizes owner-domain vs
44
- * ledger-admin). On a static mesh stop/attach stay admin-tier ops. `creds` is the tier-scoped
45
- * caller cred (`control-caller-privileged` / `control-caller-admin` — each holds ONLY its own
46
- * tier's pub grant), or undefined on an open mesh. */
47
- export async function askManager(space, server, op, args, auth = {}, tier = CONTROL_PRIVILEGED, timeoutMs) {
48
- const ep = new CotalEndpoint({
49
- space,
234
+ /** The ep-rail CLASS SCATTER (P2 item 3, `cotal ps` default): one short-lived connection, a fresh
235
+ * UNPINNED {@link resolveService} (any instance answers `describe` for the shared command surface),
236
+ * then {@link scatterCommand} freeze the live class from the records registry, publish once on the
237
+ * `all` rail, and gather one attributed reply per instance. Every frozen instance is accounted for:
238
+ * a reachable one carries its reply, a non-answering one is labeled unreachable (never omitted). */
239
+ async function askManagerScatterEp(space, server, op, auth, timeoutMs) {
240
+ const mapped = EP_COMMANDS[op];
241
+ if (!mapped)
242
+ return { ok: false, error: `unknown manager op "${op}" (no v0.4 command mapping)` };
243
+ if (mapped.targeted)
244
+ return { ok: false, error: `${op} is targeted and cannot be scattered across instances` };
245
+ const caller = auth.epCaller;
246
+ const nc = await connect({
50
247
  servers: server,
51
- ...auth,
52
- channels: [],
53
- consume: false, // request/reply only — binds no consumers (and under auth has no pre-created DM durable)
54
- registerPresence: false,
55
- watchPresence: false,
56
- card: { name: "cli", kind: "endpoint" },
248
+ ...standaloneConnectOpts(auth.creds ? { creds: auth.creds, tls: auth.tls === true } : auth.bearer ? { bearer: auth.bearer, sentinelCreds: auth.sentinelCreds, tls: auth.tls === true } : { tls: auth.tls === true }),
249
+ maxReconnectAttempts: 0,
57
250
  });
58
- ep.on("error", (e) => console.error(c.red("! " + e.message)));
59
- await ep.start();
60
251
  try {
61
- return await ep.requestControl(tier, { op, args }, timeoutMs);
252
+ const service = await resolveService(nc, space, BASELINE_LIFECYCLE_ENDPOINT, caller, { deadlineMs: 10_000 });
253
+ const result = await scatterCommand(nc, space, service, mapped.command, undefined, {
254
+ deadlineMs: timeoutMs ?? 8_000,
255
+ reconcileDeadlineMs: 3_000,
256
+ });
257
+ const instances = [];
258
+ for (const [instanceId, ar] of result.replies) {
259
+ if (ar.reply.ok === true)
260
+ instances.push({ instanceId, reachable: true, data: ar.reply.data });
261
+ else
262
+ instances.push({ instanceId, reachable: true, error: ar.reply.error?.message ?? ar.reply.error?.code ?? "error" });
263
+ }
264
+ // A frozen instance that never answered is UNREACHABLE — surfaced, never silently dropped (pin 3).
265
+ for (const instanceId of result.missing)
266
+ instances.push({ instanceId, reachable: false });
267
+ return { ok: true, instances };
62
268
  }
63
269
  catch (e) {
64
- // A user-mode caller whose cli actor lacks the tier's scope gets a broker publish denial (the
65
- // red endpoint error above) and then this timeout — name the grant, not just the silence.
66
- // The re-grant REPLACES the scope list, so the hint must say "add", never a bare one-token
67
- // --scope that would silently strip the caller's spawn/role capabilities.
68
- const need = tier === CONTROL_ADMIN ? "admin" : "spawn";
69
- const scopeHint = auth.bearer
70
- ? ` - on a user-auth mesh this op needs scope "${need}" on your cli actor. Re-grant with "${need}" ADDED to your current scope (the upsert replaces the list; see \`cotal actor list\`), e.g. \`cotal actor grant cli --sub <your IdP subject> --scope 'spawn,role:default,${need}'\``
71
- : "";
72
- return { ok: false, error: `no manager reachable (${e.message})${scopeHint}` };
270
+ const msg = e instanceof EpEnvelopeError ? `${e.code}: ${e.message}` : e.message;
271
+ return { ok: false, error: `no manager reachable on the ep rails (${msg})` };
73
272
  }
74
273
  finally {
75
- await ep.stop();
274
+ await nc.drain().catch(() => nc.close());
76
275
  }
77
276
  }
277
+ /** SCATTER one untargeted read (`ps`) across EVERY registered manager instance in the space and merge
278
+ * the attributed results — the `cotal ps` default in a multi-manager space (P2 item 3). Auth shapes
279
+ * match {@link askManager}: a minted instrument or user bearer rides its own caller triple; a raw
280
+ * pre-1c `--creds` file is refused loud; an OPEN mesh synthesizes a DEV_OWNER triple and connects
281
+ * bare (the broker enforces nothing, so the records freeze reads freely). */
282
+ export async function scatterManager(space, server, op, auth = {}, timeoutMs) {
283
+ if (auth.epCaller && (auth.creds || (auth.bearer && auth.sentinelCreds)))
284
+ return askManagerScatterEp(space, server, op, auth, timeoutMs);
285
+ if (auth.creds)
286
+ return { ok: false, error: `this --creds file predates the v0.4 control surface (no endpoint-serve rows); re-mint it with a current cotal, or drive the manager from its project folder (\`cotal ps\`) which mints the instrument for you` };
287
+ const openAuth = { epCaller: { owner: DEV_OWNER, actor: newIdentity().id, uid: mintLifecycleUid() } };
288
+ return askManagerScatterEp(space, server, op, openAuth, timeoutMs);
289
+ }
78
290
  export function failIfNotOk(reply) {
79
291
  if (!reply.ok) {
80
292
  const msg = reply.error ?? "error";
@@ -1 +1 @@
1
- {"version":3,"file":"control.js","sourceRoot":"","sources":["../../src/lib/control.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,aAAa,GAId,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvG,OAAO,EAAE,CAAC,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAqB,MAAM,cAAc,CAAC;AAMhE;;;;;wBAKwB;AACxB,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEvC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAAmB,EACnB,OAAgB;IAEhB,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK;QAC3B,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,aAA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AE,EAAE,GAAG,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC;IACnH,OAAO,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAmB;IAC7C,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;QACd,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC;QACnC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC;QACjC,6FAA6F;QAC7F,+EAA+E;QAC/E,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,IAAI;YAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -1,19 +1,34 @@
1
+ import { type LivenessProbe } from "@cotal-ai/workspace";
2
+ import { type SignalFn } from "./manager-proc.js";
3
+ /** `tls` is the broker's transport decision, propagated to the daemon's argv. It is not optional
4
+ * information the daemon can do without: it cannot derive the transport itself (see the note at
5
+ * the argv site), and omitting it leaves a standing-credential daemon connecting
6
+ * plaintext-capable to a TLS broker while looking entirely healthy.
7
+ * `wsPort` is the broker's loopback websocket listener (P2 item 6), forwarded to the manager. */
1
8
  type Opts = {
2
9
  space?: string;
3
10
  server?: string;
11
+ tls?: boolean;
4
12
  spawn?: string[];
5
13
  runtime?: string;
6
14
  launch?: string;
7
15
  attachHost?: string;
8
16
  resumeAttempt?: string;
9
17
  resumeCommitToken?: string;
18
+ wsPort?: number;
10
19
  };
11
- /** True if the delivery daemon we started for this folder is still running (pid file + liveness). */
20
+ /** The recorded daemon's liveness, THREE-VALUED plus absent. See {@link managerLiveness} for why the
21
+ * boolean collapse is the defect: `unknown` is reachable on a real kernel (a seccomp
22
+ * `SECCOMP_RET_ERRNO` filter or an LSM policy answers `kill(pid, 0)` with an arbitrary errno and
23
+ * libuv preserves it), and both ways of folding it into a boolean fail silently. */
24
+ export declare function deliveryLiveness(probe?: LivenessProbe): "alive" | "dead" | "unknown" | "absent" | "unattributable";
25
+ /** True only if the daemon is PROVABLY running. Callers that ACT on the answer take
26
+ * {@link deliveryLiveness} instead; this cannot express "cannot tell". */
12
27
  export declare function deliveryUp(): boolean;
13
28
  /** Cutover preflight — the FIRST action, BEFORE the daemon can bind: stop any old Plane-3-hosting
14
29
  * manager (live `manager.pid` without the delivery-aware marker) so it never double-binds the
15
30
  * daemon's durables. A delivery-aware (this-build) manager is left running. No-op on a fresh install. */
16
- export declare function stopOldHostingManagerIfPresent(): void;
31
+ export declare function stopOldHostingManagerIfPresent(probe?: LivenessProbe, signal?: SignalFn): Promise<void>;
17
32
  /** Start the delivery daemon detached (pid in `.cotal/delivery.pid`, output to `.cotal/delivery.log`),
18
33
  * stopped by `cotal down`. Re-execs this CLI's `deliver` command; the daemon loads the pre-minted
19
34
  * scoped `delivery.creds` (written by {@link ensureDelivery}) — it never sees the signer. */
@@ -23,14 +38,14 @@ export declare function startDeliveryDetached(o?: Opts): number;
23
38
  * never double-binds. Mints a SCOPED `delivery` cred from the local signer ONCE, writes it to
24
39
  * `.cotal/delivery.creds` (0600), and launches the daemon WITHOUT signer access. Best-effort — callers
25
40
  * treat it as non-fatal (a missing daemon degrades durable delivery, never live). */
26
- export declare function ensureDelivery(o?: Opts): Promise<{
41
+ export declare function ensureDelivery(o?: Opts, probe?: LivenessProbe): Promise<{
27
42
  running: boolean;
28
43
  }>;
29
44
  /** Stop the detached delivery daemon if we started one, and drop its creds from the store. The pid
30
45
  * kill runs even if the creds delete fails (finally) — a delete error must never leave the daemon
31
46
  * alive to outlive the teardown and reattach to a restarted broker; the error still propagates
32
47
  * after the kill so the caller can surface it. */
33
- export declare function stopDelivery(): Promise<void>;
48
+ export declare function stopDelivery(probe?: LivenessProbe, signal?: SignalFn): Promise<void>;
34
49
  /** Bring up the control plane in the correct cutover order: OLD-manager preflight → delivery daemon
35
50
  * (auth only, fails closed on a live old manager) → manager (lifecycle, writes the delivery-aware
36
51
  * marker). The manager no longer depends on the daemon (it hosts no Plane-3), so the daemon is started
@@ -1 +1 @@
1
- {"version":3,"file":"delivery-proc.d.ts","sourceRoot":"","sources":["../../src/lib/delivery-proc.ts"],"names":[],"mappings":"AAmBA,KAAK,IAAI,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAW9K,qGAAqG;AACrG,wBAAgB,UAAU,IAAI,OAAO,CAKpC;AAeD;;0GAE0G;AAC1G,wBAAgB,8BAA8B,IAAI,IAAI,CAKrD;AAED;;8FAE8F;AAC9F,wBAAgB,qBAAqB,CAAC,CAAC,GAAE,IAAS,GAAG,MAAM,CAkB1D;AAED;;;;sFAIsF;AACtF,wBAAsB,cAAc,CAAC,CAAC,GAAE,IAAS,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA+BhF;AAED;;;mDAGmD;AACnD,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAiBlD;AAED;;;;+FAI+F;AAC/F,wBAAsB,kBAAkB,CAAC,CAAC,GAAE,IAAS,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAIpF"}
1
+ {"version":3,"file":"delivery-proc.d.ts","sourceRo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