@cotal-ai/workspace 0.90.1 → 0.92.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 (200) hide show
  1. package/build/Release/win32-arm64/build.json +1 -1
  2. package/build/Release/win32-x64/build.json +2 -2
  3. package/build/Release/win32-x64/creation.node +0 -0
  4. package/dist/agent-secrets.d.ts +2 -2
  5. package/dist/agent-secrets.d.ts.map +1 -1
  6. package/dist/agent-secrets.js +2 -2
  7. package/dist/agent-secrets.js.map +1 -1
  8. package/dist/auth-paths.d.ts +8 -2
  9. package/dist/auth-paths.d.ts.map +1 -1
  10. package/dist/auth-paths.js +12 -5
  11. package/dist/auth-paths.js.map +1 -1
  12. package/dist/broker-display.d.ts +4 -0
  13. package/dist/broker-display.d.ts.map +1 -0
  14. package/dist/broker-display.js +29 -0
  15. package/dist/broker-display.js.map +1 -0
  16. package/dist/colors.d.ts +11 -4
  17. package/dist/colors.d.ts.map +1 -1
  18. package/dist/colors.js +36 -9
  19. package/dist/colors.js.map +1 -1
  20. package/dist/connect.d.ts +81 -10
  21. package/dist/connect.d.ts.map +1 -1
  22. package/dist/connect.js +195 -75
  23. package/dist/connect.js.map +1 -1
  24. package/dist/control-target.d.ts +2 -2
  25. package/dist/control-target.d.ts.map +1 -1
  26. package/dist/control-target.js +13 -5
  27. package/dist/control-target.js.map +1 -1
  28. package/dist/credential-actions.d.ts +91 -0
  29. package/dist/credential-actions.d.ts.map +1 -0
  30. package/dist/credential-actions.js +74 -0
  31. package/dist/credential-actions.js.map +1 -0
  32. package/dist/deprecated-daemon-entries.d.ts +30 -0
  33. package/dist/deprecated-daemon-entries.d.ts.map +1 -0
  34. package/dist/deprecated-daemon-entries.js +37 -0
  35. package/dist/deprecated-daemon-entries.js.map +1 -0
  36. package/dist/endpoint-actions.d.ts +31 -0
  37. package/dist/endpoint-actions.d.ts.map +1 -0
  38. package/dist/endpoint-actions.js +2 -0
  39. package/dist/endpoint-actions.js.map +1 -0
  40. package/dist/endpoint-caller.d.ts +74 -0
  41. package/dist/endpoint-caller.d.ts.map +1 -0
  42. package/dist/endpoint-caller.js +118 -0
  43. package/dist/endpoint-caller.js.map +1 -0
  44. package/dist/endpoint-contract.d.ts +32 -0
  45. package/dist/endpoint-contract.d.ts.map +1 -0
  46. package/dist/endpoint-contract.js +92 -0
  47. package/dist/endpoint-contract.js.map +1 -0
  48. package/dist/extension-mutation.d.ts.map +1 -1
  49. package/dist/extension-mutation.js +4 -1
  50. package/dist/extension-mutation.js.map +1 -1
  51. package/dist/extensions.d.ts +28 -8
  52. package/dist/extensions.d.ts.map +1 -1
  53. package/dist/extensions.js +20 -8
  54. package/dist/extensions.js.map +1 -1
  55. package/dist/flags.d.ts +8 -1
  56. package/dist/flags.d.ts.map +1 -1
  57. package/dist/flags.js +9 -7
  58. package/dist/flags.js.map +1 -1
  59. package/dist/index.d.ts +25 -0
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +25 -0
  62. package/dist/index.js.map +1 -1
  63. package/dist/launch-persona.d.ts +10 -0
  64. package/dist/launch-persona.d.ts.map +1 -0
  65. package/dist/launch-persona.js +34 -0
  66. package/dist/launch-persona.js.map +1 -0
  67. package/dist/local-process.d.ts +60 -12
  68. package/dist/local-process.d.ts.map +1 -1
  69. package/dist/local-process.js +173 -4
  70. package/dist/local-process.js.map +1 -1
  71. package/dist/maintenance.d.ts +267 -4
  72. package/dist/maintenance.d.ts.map +1 -1
  73. package/dist/maintenance.js +666 -12
  74. package/dist/maintenance.js.map +1 -1
  75. package/dist/mesh-manifest-schema.d.ts +118 -0
  76. package/dist/mesh-manifest-schema.d.ts.map +1 -0
  77. package/dist/mesh-manifest-schema.js +96 -0
  78. package/dist/mesh-manifest-schema.js.map +1 -0
  79. package/dist/mesh-registry.d.ts +30 -0
  80. package/dist/mesh-registry.d.ts.map +1 -1
  81. package/dist/mesh-registry.js +74 -13
  82. package/dist/mesh-registry.js.map +1 -1
  83. package/dist/mesh-target.d.ts +15 -7
  84. package/dist/mesh-target.d.ts.map +1 -1
  85. package/dist/mesh-target.js +77 -26
  86. package/dist/mesh-target.js.map +1 -1
  87. package/dist/official-connectors.d.ts +13 -0
  88. package/dist/official-connectors.d.ts.map +1 -1
  89. package/dist/official-connectors.js +18 -2
  90. package/dist/official-connectors.js.map +1 -1
  91. package/dist/output.d.ts +147 -0
  92. package/dist/output.d.ts.map +1 -0
  93. package/dist/output.js +186 -0
  94. package/dist/output.js.map +1 -0
  95. package/dist/pid.d.ts +5 -3
  96. package/dist/pid.d.ts.map +1 -1
  97. package/dist/pid.js +25 -13
  98. package/dist/pid.js.map +1 -1
  99. package/dist/preferences.d.ts +93 -0
  100. package/dist/preferences.d.ts.map +1 -0
  101. package/dist/preferences.js +272 -0
  102. package/dist/preferences.js.map +1 -0
  103. package/dist/preflight.d.ts +3 -0
  104. package/dist/preflight.d.ts.map +1 -1
  105. package/dist/preflight.js +6 -3
  106. package/dist/preflight.js.map +1 -1
  107. package/dist/prepared-spaces.d.ts +27 -0
  108. package/dist/prepared-spaces.d.ts.map +1 -0
  109. package/dist/prepared-spaces.js +57 -0
  110. package/dist/prepared-spaces.js.map +1 -0
  111. package/dist/present.d.ts +108 -0
  112. package/dist/present.d.ts.map +1 -0
  113. package/dist/present.js +249 -0
  114. package/dist/present.js.map +1 -0
  115. package/dist/prompt-input.d.ts +12 -0
  116. package/dist/prompt-input.d.ts.map +1 -0
  117. package/dist/prompt-input.js +35 -0
  118. package/dist/prompt-input.js.map +1 -0
  119. package/dist/protected-records.d.ts +102 -0
  120. package/dist/protected-records.d.ts.map +1 -0
  121. package/dist/protected-records.js +465 -0
  122. package/dist/protected-records.js.map +1 -0
  123. package/dist/registration-policy.d.ts +4 -1
  124. package/dist/registration-policy.d.ts.map +1 -1
  125. package/dist/registration-policy.js +4 -3
  126. package/dist/registration-policy.js.map +1 -1
  127. package/dist/render.d.ts +8 -0
  128. package/dist/render.d.ts.map +1 -1
  129. package/dist/render.js +49 -32
  130. package/dist/render.js.map +1 -1
  131. package/dist/renewal-path.d.ts +5 -0
  132. package/dist/renewal-path.d.ts.map +1 -0
  133. package/dist/renewal-path.js +9 -0
  134. package/dist/renewal-path.js.map +1 -0
  135. package/dist/renewal.d.ts +6 -9
  136. package/dist/renewal.d.ts.map +1 -1
  137. package/dist/renewal.js +7 -12
  138. package/dist/renewal.js.map +1 -1
  139. package/dist/service-adapter.d.ts +201 -0
  140. package/dist/service-adapter.d.ts.map +1 -0
  141. package/dist/service-adapter.js +294 -0
  142. package/dist/service-adapter.js.map +1 -0
  143. package/dist/service-custody.d.ts +5 -0
  144. package/dist/service-custody.d.ts.map +1 -0
  145. package/dist/service-custody.js +41 -0
  146. package/dist/service-custody.js.map +1 -0
  147. package/dist/service-definition.d.ts +52 -0
  148. package/dist/service-definition.d.ts.map +1 -0
  149. package/dist/service-definition.js +85 -0
  150. package/dist/service-definition.js.map +1 -0
  151. package/dist/service-definition.schema.json +79 -0
  152. package/dist/service-extension-metadata.d.ts +11 -0
  153. package/dist/service-extension-metadata.d.ts.map +1 -0
  154. package/dist/service-extension-metadata.js +66 -0
  155. package/dist/service-extension-metadata.js.map +1 -0
  156. package/dist/service-identity.d.ts +51 -0
  157. package/dist/service-identity.d.ts.map +1 -0
  158. package/dist/service-identity.js +103 -0
  159. package/dist/service-identity.js.map +1 -0
  160. package/dist/service-observation.d.ts +32 -0
  161. package/dist/service-observation.d.ts.map +1 -0
  162. package/dist/service-observation.js +134 -0
  163. package/dist/service-observation.js.map +1 -0
  164. package/dist/service-preset.d.ts +12 -0
  165. package/dist/service-preset.d.ts.map +1 -0
  166. package/dist/service-preset.js +10 -0
  167. package/dist/service-preset.js.map +1 -0
  168. package/dist/service-startup.d.ts +23 -0
  169. package/dist/service-startup.d.ts.map +1 -0
  170. package/dist/service-startup.js +39 -0
  171. package/dist/service-startup.js.map +1 -0
  172. package/dist/service-stop.d.ts +47 -0
  173. package/dist/service-stop.d.ts.map +1 -0
  174. package/dist/service-stop.js +152 -0
  175. package/dist/service-stop.js.map +1 -0
  176. package/dist/service-target.d.ts +5 -0
  177. package/dist/service-target.d.ts.map +1 -0
  178. package/dist/service-target.js +19 -0
  179. package/dist/service-target.js.map +1 -0
  180. package/dist/signer-export.d.ts +31 -0
  181. package/dist/signer-export.d.ts.map +1 -0
  182. package/dist/signer-export.js +114 -0
  183. package/dist/signer-export.js.map +1 -0
  184. package/dist/space-segmentation.d.ts +21 -7
  185. package/dist/space-segmentation.d.ts.map +1 -1
  186. package/dist/space-segmentation.js +26 -9
  187. package/dist/space-segmentation.js.map +1 -1
  188. package/dist/space.d.ts +5 -5
  189. package/dist/space.d.ts.map +1 -1
  190. package/dist/space.js +8 -6
  191. package/dist/space.js.map +1 -1
  192. package/dist/system-rotation.d.ts +4 -3
  193. package/dist/system-rotation.d.ts.map +1 -1
  194. package/dist/system-rotation.js +16 -6
  195. package/dist/system-rotation.js.map +1 -1
  196. package/dist/web-session.d.ts +7 -0
  197. package/dist/web-session.d.ts.map +1 -1
  198. package/dist/web-session.js +9 -0
  199. package/dist/web-session.js.map +1 -1
  200. package/package.json +6 -2
@@ -0,0 +1,39 @@
1
+ import { basename, dirname, isAbsolute, join } from "node:path";
2
+ import { writeSecretFileCreateOnly } from "@cotal-ai/core";
3
+ import { spaceKey } from "./auth-paths.js";
4
+ import { identityRecord } from "./pid.js";
5
+ import { CommandFailure } from "./output.js";
6
+ import { decodeLocalJson, protectedLocalDirectory, readLocalRecordSource } from "./protected-records.js";
7
+ import { serviceOperationId } from "./service-adapter.js";
8
+ const name = (id, request) => `.${spaceKey(serviceOperationId(id))}.${spaceKey(serviceOperationId(request))}.ready.json`;
9
+ export const serviceStartupPath = (context) => join(context.stateDirectory, name(context.instanceId, context.launchRequestId));
10
+ export function validateServiceStartupPath(path, id, request) {
11
+ if (!isAbsolute(path) || /[\u0000-\u001f\u007f]/u.test(path) || basename(path) !== name(id, request))
12
+ throw new CommandFailure("refused", "CONFLICT", "the native service readiness path does not name its full instance and launch request");
13
+ protectedLocalDirectory(dirname(path));
14
+ }
15
+ /** Call from the native child only after its real initialization and signal handlers exist.
16
+ * This receipt grants no authority and carries no bootstrap URL, token or credential. */
17
+ export function publishServiceStartup(path, value) {
18
+ validateServiceStartupPath(path, value.instanceId, value.launchRequestId);
19
+ if (!/^[a-z][a-z0-9-]{0,63}$/.test(value.phase))
20
+ throw new CommandFailure("refused", "SCHEMA_INVALID", "the native startup phase is invalid");
21
+ const processIdentity = identityRecord(process.pid);
22
+ if (!("token" in processIdentity))
23
+ throw new CommandFailure("refused", "UNSUPPORTED", "the native service child has no creation-pinned process identity");
24
+ writeSecretFileCreateOnly(path, JSON.stringify({ schemaVersion: 1, phase: value.phase, space: value.space, instanceId: value.instanceId, launchRequestId: value.launchRequestId, process: processIdentity, observedAt: new Date().toISOString() }) + "\n");
25
+ }
26
+ /** A native startup receipt plus the controller's current process proof. This is not an HTTP
27
+ * health query, a native endpoint response or proof of ongoing application availability. */
28
+ export function observeServiceStartup(context, phase) {
29
+ context.signal.throwIfAborted();
30
+ const bytes = readLocalRecordSource(serviceStartupPath(context), 8192, true);
31
+ if (!bytes)
32
+ return { state: "pending" };
33
+ const row = decodeLocalJson(bytes);
34
+ const identity = row?.process;
35
+ if (!row || Object.keys(row).some((key) => !["schemaVersion", "phase", "space", "instanceId", "launchRequestId", "process", "observedAt"].includes(key)) || row.schemaVersion !== 1 || row.phase !== phase || row.space !== context.space || row.instanceId !== context.instanceId || row.launchRequestId !== context.launchRequestId || !identity || identity.pid !== context.process.pid || identity.token !== context.process.token || Object.keys(identity).length !== 2 || typeof row.observedAt !== "string" || !Number.isFinite(Date.parse(row.observedAt)) || Date.parse(row.observedAt) > Date.now() + 1000)
36
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the startup receipt does not match this full owned launch; no other receipt or process was adopted");
37
+ return { state: "ready", process: { ...context.process }, observedAt: new Date().toISOString() };
38
+ }
39
+ //# sourceMappingURL=service-startup.js.map
@@ -0,0 +1 @@
1
+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-adapter.js";
3
+ type StopContext = Pick<ServiceAdapterContext, "space" | "instanceId" | "launchRequestId" | "stateDirectory">;
4
+ export interface NativeServiceStopRequest {
5
+ schemaVersion: 1;
6
+ space: string;
7
+ instanceId: string;
8
+ launchRequestId: string;
9
+ requestId: string;
10
+ target: ProcessIdentityRecord;
11
+ stopper: ProcessIdentityRecord;
12
+ withAgents: boolean;
13
+ scopeSha256: string;
14
+ /** A preserved-exit stop only, with `withAgents: false`: the maintenance attempt and inventory
15
+ * digest the native child must still hold. Absent from ordinary requests. */
16
+ preserved?: {
17
+ attemptId: string;
18
+ inventorySha256: string;
19
+ };
20
+ }
21
+ export interface NativeServiceStopReceipt extends NativeServiceStopRequest {
22
+ phase: "accepted" | "refused" | "completed" | "failed";
23
+ observedAt: string;
24
+ /** A returned native stop is not proof that every lease, registration or family was cleaned. */
25
+ cleanup: "not-checked";
26
+ }
27
+ export declare const serviceStopRequestPath: (context: StopContext) => string;
28
+ /** Call only while the native PID stop reservation and service definition hold are owned.
29
+ * The file is a same-UID local handoff, not a wire grant or a signature. It is never overwritten. */
30
+ export declare function publishServiceStopRequest(context: StopContext, value: NativeServiceStopRequest): void;
31
+ /** Read from the native child before choosing any stop policy. A missing request authorizes nothing. */
32
+ export declare function readServiceStopRequest(context: StopContext): NativeServiceStopRequest | undefined;
33
+ /** Native child only. Each phase is immutable and attributed to the original full request. */
34
+ export declare function publishServiceStopReceipt(context: StopContext, value: NativeServiceStopRequest, phase: NativeServiceStopReceipt["phase"]): void;
35
+ /** Read all present phases without replacing an unknown with mere process disappearance. */
36
+ export declare function readServiceStopReceipts(context: StopContext, expected: NativeServiceStopRequest): NativeServiceStopReceipt[];
37
+ /** Clear only this live caller's acknowledged no-stop handoff, still under its native reservation.
38
+ * Phase receipts stay retained. A submitted, failed or unknown stop cannot use this cleanup. */
39
+ export declare function clearRefusedServiceStopRequest(context: StopContext, expected: NativeServiceStopRequest): void;
40
+ /** The new controller refuses every existing native reservation, including stale or malformed
41
+ * ones. It does not reuse the legacy PID-only reclaim path or silently steal another attempt. */
42
+ export declare function reserveNativeServiceStop(marker: string): {
43
+ stopper: ProcessIdentityRecord;
44
+ release(): void;
45
+ };
46
+ export {};
47
+ //# sourceMappingURL=service-stop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-stop.d.ts","sourceRoot":"","sources":["../src/service-stop.ts"],"names":[],"mappings":"AAMA,OAAO,EAAwC,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAE5F,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,KAAK,WAAW,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,CAAC,CAAC;AAC9G,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,CAAC,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB;kFAC8E;IAC9E,SAAS,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D;AACD,MAAM,WAAW,wBAAyB,SAAQ,wBAAwB;IACxE,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,gGAAgG;IAChG,OAAO,EAAE,aAAa,CAAC;CACxB;AAoBD,eAAO,MAAM,sBAAsB,GAAI,SAAS,WAAW,KAAG,MAA0E,CAAC;AAkBzI;sGACsG;AACtG,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,wBAAwB,GAAG,IAAI,CAKrG;AAED,wGAAwG;AACxG,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,wBAAwB,GAAG,SAAS,CAGjG;AAED,8FAA8F;AAC9F,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,wBAAwB,EAAE,KAAK,EAAE,wBAAwB,CAAC,OAAO,CAAC,GAAG,IAAI,CAI/I;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,wBAAwB,GAAG,wBAAwB,EAAE,CAiB5H;AAED;iGACiG;AACjG,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAK7G;AAED;kGACkG;AAClG,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,qBAAqB,CAAC;IAAC,OAAO,IAAI,IAAI,CAAA;CAAE,CAoB5G"}
@@ -0,0 +1,152 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { linkSync, lstatSync, rmSync } from "node:fs";
3
+ import { dirname, isAbsolute, join } from "node:path";
4
+ import { token, writeSecretFileCreateOnly } from "@cotal-ai/core";
5
+ import { spaceKey } from "./auth-paths.js";
6
+ import { CommandFailure } from "./output.js";
7
+ import { assertRecordIdentity, identityRecord } from "./pid.js";
8
+ import { decodeLocalJson, protectedLocalDirectory, readLocalRecordSource } from "./protected-records.js";
9
+ import { serviceOperationId } from "./service-adapter.js";
10
+ const object = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value) && [Object.prototype, null].includes(Object.getPrototypeOf(value)));
11
+ const invalid = () => { throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the private native stop record does not match this full process/launch/request; no other attempt was adopted"); };
12
+ const requestKeys = ["schemaVersion", "space", "instanceId", "launchRequestId", "requestId", "target", "stopper", "withAgents", "scopeSha256"];
13
+ /** The closed key list of one request: the ordinary nine, plus `preserved` when it is present. */
14
+ const keysOf = (input) => input.preserved === undefined ? requestKeys : [...requestKeys, "preserved"];
15
+ function preservedBinding(value) {
16
+ if (!object(value) || Object.keys(value).length !== 2 || typeof value.attemptId !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(value.attemptId) || typeof value.inventorySha256 !== "string" || !/^[0-9a-f]{64}$/.test(value.inventorySha256))
17
+ return invalid();
18
+ return { attemptId: value.attemptId, inventorySha256: value.inventorySha256 };
19
+ }
20
+ function pinned(value) {
21
+ if (!object(value) || Object.keys(value).length !== 2 || !Number.isSafeInteger(value.pid) || Number(value.pid) <= 0 || Number(value.pid) > 2_147_483_647 || typeof value.token !== "string" || value.token.length > 128 || !/^[0-9]+$/.test(value.token))
22
+ return invalid();
23
+ return { pid: Number(value.pid), token: value.token };
24
+ }
25
+ function contextKey(context) {
26
+ if (!isAbsolute(context.stateDirectory) || context.stateDirectory.length > 4096 || /[\u0000-\u001f\u007f]/u.test(context.stateDirectory) || !context.space || context.space.length > 200 || token(context.space) !== context.space)
27
+ return invalid();
28
+ protectedLocalDirectory(context.stateDirectory);
29
+ return `.${spaceKey(serviceOperationId(context.instanceId))}.${spaceKey(serviceOperationId(context.launchRequestId))}`;
30
+ }
31
+ export const serviceStopRequestPath = (context) => join(context.stateDirectory, `${contextKey(context)}.stop.json`);
32
+ const receiptPath = (context, requestId, phase) => join(context.stateDirectory, `${contextKey(context)}.${spaceKey(serviceOperationId(requestId))}.${phase}.json`);
33
+ function request(input, context) {
34
+ if (!object(input))
35
+ return invalid();
36
+ const keys = keysOf(input);
37
+ if (Object.keys(input).some((key) => !keys.includes(key)) || Object.keys(input).length !== keys.length || input.schemaVersion !== 1 || input.space !== context.space || input.instanceId !== context.instanceId || input.launchRequestId !== context.launchRequestId || typeof input.requestId !== "string" || typeof input.withAgents !== "boolean" || typeof input.scopeSha256 !== "string" || !/^[0-9a-f]{64}$/.test(input.scopeSha256))
38
+ return invalid();
39
+ try {
40
+ serviceOperationId(input.requestId);
41
+ }
42
+ catch {
43
+ return invalid();
44
+ }
45
+ // A preserved-exit stop never reaps agents.
46
+ const preserved = input.preserved === undefined ? undefined : preservedBinding(input.preserved);
47
+ if (preserved && input.withAgents !== false)
48
+ return invalid();
49
+ return { schemaVersion: 1, space: context.space, instanceId: context.instanceId, launchRequestId: context.launchRequestId, requestId: input.requestId, target: pinned(input.target), stopper: pinned(input.stopper), withAgents: input.withAgents, scopeSha256: input.scopeSha256, ...(preserved ? { preserved } : {}) };
50
+ }
51
+ function sameRequest(a, b) {
52
+ return a.space === b.space && a.instanceId === b.instanceId && a.launchRequestId === b.launchRequestId && a.requestId === b.requestId && a.target.pid === b.target.pid && a.target.token === b.target.token && a.stopper.pid === b.stopper.pid && a.stopper.token === b.stopper.token && a.withAgents === b.withAgents && a.scopeSha256 === b.scopeSha256 &&
53
+ (a.preserved === undefined ? b.preserved === undefined : b.preserved !== undefined && a.preserved.attemptId === b.preserved.attemptId && a.preserved.inventorySha256 === b.preserved.inventorySha256);
54
+ }
55
+ /** Call only while the native PID stop reservation and service definition hold are owned.
56
+ * The file is a same-UID local handoff, not a wire grant or a signature. It is never overwritten. */
57
+ export function publishServiceStopRequest(context, value) {
58
+ const checked = request(value, context);
59
+ const self = identityRecord(process.pid);
60
+ if (!("token" in self) || checked.stopper.pid !== self.pid || checked.stopper.token !== self.token || assertRecordIdentity(checked.target).kind !== "match")
61
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "the native stop handoff has no current creation-pinned caller and target; no request was published");
62
+ writeSecretFileCreateOnly(serviceStopRequestPath(context), JSON.stringify(checked) + "\n");
63
+ }
64
+ /** Read from the native child before choosing any stop policy. A missing request authorizes nothing. */
65
+ export function readServiceStopRequest(context) {
66
+ const bytes = readLocalRecordSource(serviceStopRequestPath(context), 8192, true);
67
+ return bytes === undefined ? undefined : request(decodeLocalJson(bytes), context);
68
+ }
69
+ /** Native child only. Each phase is immutable and attributed to the original full request. */
70
+ export function publishServiceStopReceipt(context, value, phase) {
71
+ const checked = request(value, context), self = identityRecord(process.pid);
72
+ if (!("token" in self) || checked.target.pid !== self.pid || checked.target.token !== self.token || !["accepted", "refused", "completed", "failed"].includes(phase))
73
+ return invalid();
74
+ writeSecretFileCreateOnly(receiptPath(context, checked.requestId, phase), JSON.stringify({ ...checked, phase, observedAt: new Date().toISOString(), cleanup: "not-checked" }) + "\n");
75
+ }
76
+ /** Read all present phases without replacing an unknown with mere process disappearance. */
77
+ export function readServiceStopReceipts(context, expected) {
78
+ const checked = request(expected, context), receipts = [];
79
+ for (const phase of ["accepted", "refused", "completed", "failed"]) {
80
+ const bytes = readLocalRecordSource(receiptPath(context, checked.requestId, phase), 8192, true);
81
+ if (bytes === undefined)
82
+ continue;
83
+ const row = decodeLocalJson(bytes);
84
+ // A receipt row carries the expected request's own key list, `preserved` included iff it had one.
85
+ const keys = keysOf(checked);
86
+ if (!object(row) || Object.keys(row).length !== keys.length + 3 || Object.keys(row).some((key) => ![...keys, "phase", "observedAt", "cleanup"].includes(key)) || row.phase !== phase || row.cleanup !== "not-checked" || typeof row.observedAt !== "string" || row.observedAt.length > 100 || !Number.isFinite(Date.parse(row.observedAt)) || Date.parse(row.observedAt) > Date.now() + 1000)
87
+ return invalid();
88
+ const base = Object.fromEntries(keys.map((key) => [key, row[key]]));
89
+ if (!sameRequest(request(base, context), checked))
90
+ return invalid();
91
+ receipts.push({ ...checked, phase, observedAt: row.observedAt, cleanup: "not-checked" });
92
+ }
93
+ if (receipts.filter((row) => row.phase !== "accepted").length > 1 || receipts.some((row) => row.phase === "refused") && receipts.some((row) => row.phase === "accepted"))
94
+ return invalid();
95
+ const accepted = receipts.find((row) => row.phase === "accepted");
96
+ if (receipts.some((row) => row.phase === "completed" || row.phase === "failed") && !accepted || accepted && receipts.some((row) => row.phase !== "accepted" && Date.parse(row.observedAt) < Date.parse(accepted.observedAt)))
97
+ return invalid();
98
+ return receipts;
99
+ }
100
+ /** Clear only this live caller's acknowledged no-stop handoff, still under its native reservation.
101
+ * Phase receipts stay retained. A submitted, failed or unknown stop cannot use this cleanup. */
102
+ export function clearRefusedServiceStopRequest(context, expected) {
103
+ const checked = request(expected, context), self = identityRecord(process.pid);
104
+ const current = readServiceStopRequest(context), phases = readServiceStopReceipts(context, checked);
105
+ if (!("token" in self) || checked.stopper.pid !== self.pid || checked.stopper.token !== self.token || assertRecordIdentity(checked.target).kind !== "match" || !current || !sameRequest(current, checked) || phases.length !== 1 || phases[0]?.phase !== "refused")
106
+ return invalid();
107
+ rmSync(serviceStopRequestPath(context));
108
+ }
109
+ /** The new controller refuses every existing native reservation, including stale or malformed
110
+ * ones. It does not reuse the legacy PID-only reclaim path or silently steal another attempt. */
111
+ export function reserveNativeServiceStop(marker) {
112
+ if (process.platform !== "linux")
113
+ throw new CommandFailure("refused", "UNSUPPORTED", "this native stop reservation requires Linux process creation identity; no weaker platform path was selected");
114
+ if (!isAbsolute(marker) || /[\u0000-\u001f\u007f]/u.test(marker))
115
+ throw new CommandFailure("refused", "USAGE_INVALID", "a native stop reservation needs its exact protected absolute marker path");
116
+ protectedLocalDirectory(dirname(marker));
117
+ const stopper = identityRecord(process.pid);
118
+ if (!("token" in stopper) || !/^[0-9]+$/.test(stopper.token))
119
+ throw new CommandFailure("refused", "UNSUPPORTED", "this native stop requires a creation-pinned Linux caller; no PID-only reservation was substituted");
120
+ const temp = `${marker}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`;
121
+ writeSecretFileCreateOnly(temp, String(process.pid));
122
+ const original = lstatSync(temp);
123
+ try {
124
+ try {
125
+ linkSync(temp, marker);
126
+ }
127
+ catch (error) {
128
+ if (error.code === "EEXIST")
129
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "a native stop reservation already exists; inspect its original attempt before retrying. No marker was reclaimed or signal sent");
130
+ throw error;
131
+ }
132
+ }
133
+ finally {
134
+ rmSync(temp);
135
+ }
136
+ return { stopper, release() {
137
+ let current;
138
+ try {
139
+ current = lstatSync(marker);
140
+ }
141
+ catch (error) {
142
+ if (error.code === "ENOENT")
143
+ return;
144
+ throw error;
145
+ }
146
+ const bytes = readLocalRecordSource(marker, 128, true);
147
+ if (!current.isFile() || current.isSymbolicLink() || current.dev !== original.dev || current.ino !== original.ino || bytes?.toString("utf8") !== String(stopper.pid))
148
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the native stop reservation changed; another marker was not removed");
149
+ rmSync(marker);
150
+ } };
151
+ }
152
+ //# sourceMappingURL=service-stop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-stop.js","sourceRoot":"","sources":["../src/service-stop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAA8B,MAAM,UAAU,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAA8B,MAAM,sBAAsB,CAAC;AAwBtF,MAAM,MAAM,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CA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1,5 @@
1
+ import { type MeshTarget } from "./mesh-target.js";
2
+ /** Public coordinates only. Do not put resolved signer material in a server handler's closure. */
3
+ export type NativeServiceTarget = Pick<MeshTarget, "root" | "space" | "server" | "tlsRequired" | "mode">;
4
+ export declare function resolveNativeServiceTarget(root: string, space: string, server?: string, allowBrokerOverride?: boolean): NativeServiceTarget;
5
+ //# sourceMappingURL=service-target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-target.d.ts","sourceRoot":"","sources":["../src/service-target.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGtE,kGAAkG;AAClG,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,CAAC,CAAC;AAEzG,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,mBAAmB,UAAQ,GAAG,mBAAmB,CAQzI"}
@@ -0,0 +1,19 @@
1
+ import { canonicalRoot } from "./mesh-registry.js";
2
+ import { resolveMeshTarget } from "./mesh-target.js";
3
+ import { CommandFailure } from "./output.js";
4
+ export function resolveNativeServiceTarget(root, space, server, allowBrokerOverride = false) {
5
+ const target = resolveMeshTarget(root, { space, ...(allowBrokerOverride && server !== undefined ? { server } : {}), readOnly: true });
6
+ if (canonicalRoot(target.root) !== canonicalRoot(root) || target.space !== space || !allowBrokerOverride && server !== undefined && server !== target.server)
7
+ throw new CommandFailure("refused", "CONFLICT", "the service root, registered space and broker do not resolve to one target; no different target was substituted");
8
+ let url;
9
+ try {
10
+ url = new URL(target.server.includes("://") ? target.server : `nats://${target.server}`);
11
+ }
12
+ catch {
13
+ throw new CommandFailure("refused", "UNSUPPORTED", "the native service preset requires one supported broker URL; no server list or credential-bearing URL was placed on argv");
14
+ }
15
+ if (!["nats:", "tls:", "ws:", "wss:"].includes(url.protocol) || url.username || url.password || url.hash || url.search || target.server.includes(","))
16
+ throw new CommandFailure("refused", "UNSUPPORTED", "the native service preset requires one broker URL without credentials, query or fragment");
17
+ return { root: target.root, space: target.space, server: target.server, tlsRequired: target.tlsRequired, mode: target.mode };
18
+ }
19
+ //# sourceMappingURL=service-target.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-target.js","sourceRoot":"","sources":["../src/service-target.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAK7C,MAAM,UAAU,0BAA0B,CAAC,IAAY,EAAE,KAAa,EAAE,MAAe,EAAE,mBAAmB,GAAG,KAAK;IAClH,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,mBAAmB,IAAI,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACtI,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,aAAa,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,mBAAmB,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,MAAM,CAAC,MAAM;QAAE,MAAM,IAAI,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,iHAAiH,CAAC,CAAC;IACjU,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAAC,CAAC;IACjG,MAAM,CAAC;QAAC,MAAM,IAAI,cAAc,CAAC,SAAS,EAAE,aAAa,EAAE,0HAA0H,CAAC,CAAC;IAAC,CAAC;IACzL,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,cAAc,CAAC,SAAS,EAAE,aAAa,EAAE,0FAA0F,CAAC,CAAC;IACtS,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAC/H,CAAC"}
@@ -0,0 +1,31 @@
1
+ export declare const signerExportFlags: readonly [{
2
+ readonly name: "out";
3
+ readonly type: "string";
4
+ readonly value: "<private-file>";
5
+ readonly description: "private output file; required for signer export and endpoint caller issuance";
6
+ }, {
7
+ readonly name: "force";
8
+ readonly type: "boolean";
9
+ readonly description: "signer: replace only an inspected private stripped signer for the same account";
10
+ }];
11
+ interface SignerExportInput {
12
+ out?: unknown;
13
+ force?: unknown;
14
+ space?: unknown;
15
+ }
16
+ export declare function validateSignerExportInput(values: SignerExportInput): void;
17
+ /** Export existing account-signing material only. Never issue a caller, rotate a key or start a service. */
18
+ export declare function exportSpaceSigner(values: SignerExportInput, cwd?: string): Promise<{
19
+ replaced: boolean;
20
+ noOp: boolean;
21
+ space: string;
22
+ account: string;
23
+ path: string;
24
+ contains: string;
25
+ operatorRootExported: boolean;
26
+ callerIssued: boolean;
27
+ keyRotated: boolean;
28
+ secretOnStdout: boolean;
29
+ }>;
30
+ export {};
31
+ //# sourceMappingURL=signer-export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer-export.d.ts","sourceRoot":"","sources":["../src/signer-export.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,iBAAiB;;;;;;;;;EAGU,CAAC;AACzC,UAAU,iBAAiB;IAAG,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE;AAC/E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAGzE;AAkBD,4GAA4G;AAC5G,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,SAAgB;;;;;;;;;;;GAuCrF"}
@@ -0,0 +1,114 @@
1
+ import { createHash } from "node:crypto";
2
+ import { lstatSync } from "node:fs";
3
+ import { dirname, resolve } from "node:path";
4
+ import { acquireLock, stripSpaceAuth, writeSecretFileAtomic, writeSecretFileCreateOnly } from "@cotal-ai/core";
5
+ import { authDir, findCotalRoot, getSoleSpaceAuth, getSpaceAuth } from "./auth-paths.js";
6
+ import { canonicalRoot } from "./mesh-registry.js";
7
+ import { isWorkspaceTargetError, resolveMeshTarget } from "./mesh-target.js";
8
+ import { targetErrorCode } from "./connect.js";
9
+ import { privateOutputFlag } from "./credential-actions.js";
10
+ import { CommandFailure } from "./output.js";
11
+ import { assertExternalCredentialExport, decodeLocalJson, localRecordObject, protectedCredentialReference, protectedLocalDirectory, readLocalRecordSource } from "./protected-records.js";
12
+ import { workspaceSecretStore } from "./secret-store-fs.js";
13
+ export const signerExportFlags = [
14
+ privateOutputFlag,
15
+ { name: "force", type: "boolean", description: "signer: replace only an inspected private stripped signer for the same account" },
16
+ ];
17
+ export function validateSignerExportInput(values) {
18
+ if (typeof values.out !== "string" || !values.out.trim() || /[\u0000-\u001f\u007f]/u.test(values.out))
19
+ throw new CommandFailure("refused", "USAGE_INVALID", "auth signer requires --out <private-file> without terminal controls; signing material is never printed");
20
+ if (values.force !== undefined && typeof values.force !== "boolean")
21
+ throw new CommandFailure("refused", "USAGE_INVALID", "signer --force is a boolean replacement decision");
22
+ }
23
+ function exportTarget(cwd, space) {
24
+ try {
25
+ const selected = resolveMeshTarget(cwd, { space, readOnly: true });
26
+ return { root: selected.root, space: selected.space };
27
+ }
28
+ catch (error) {
29
+ if (!isWorkspaceTargetError(error))
30
+ throw error;
31
+ if (error.code === "not-started" && error.details.root && error.details.space)
32
+ return { root: error.details.root, space: error.details.space };
33
+ throw new CommandFailure("refused", targetErrorCode(error.code), "the selected signer authority could not be resolved; no other space was chosen");
34
+ }
35
+ }
36
+ const digest = (bytes) => createHash("sha256").update(bytes).digest("hex");
37
+ function replacementIsSigner(bytes, auth) {
38
+ const value = localRecordObject(decodeLocalJson(bytes), ["space", "operator", "account", "sys"]);
39
+ const operator = localRecordObject(value.operator, ["seed", "jwt"]);
40
+ const account = localRecordObject(value.account, ["pub", "seed", "jwt", "signingSeed", "signingPub"]);
41
+ const sys = localRecordObject(value.sys, ["pub", "jwt"]);
42
+ if (value.space !== auth.space || account.pub !== auth.account.pub || typeof account.signingSeed !== "string" || !account.signingSeed || operator.seed !== "" || operator.jwt !== "" || account.seed !== "" || account.jwt !== "" || account.signingPub !== "" || sys.pub !== "" || sys.jwt !== "")
43
+ throw new CommandFailure("refused", "CONFLICT", "the existing file is not a stripped signer for this space and account; full trust bundles and other accounts are never replaced");
44
+ }
45
+ /** Export existing account-signing material only. Never issue a caller, rotate a key or start a service. */
46
+ export async function exportSpaceSigner(values, cwd = process.cwd()) {
47
+ validateSignerExportInput(values);
48
+ const path = resolve(values.out);
49
+ protectedLocalDirectory(dirname(path));
50
+ const lock = acquireLock(`${path}.cotal-export.lock`, { label: "signer export", waitMs: 0, onTimeout: () => new CommandFailure("refused", "CONFLICT", "another writer holds this signer export path") });
51
+ try {
52
+ let before;
53
+ try {
54
+ before = lstatSync(path);
55
+ }
56
+ catch (error) {
57
+ if (error.code !== "ENOENT")
58
+ throw new CommandFailure("refused", "PERMISSION_DENIED", "the signer export target could not be inspected");
59
+ }
60
+ if (before && values.force !== true)
61
+ throw new CommandFailure("refused", "CONFLICT", "the signer export path already exists; no secret was written", { target: { path }, remedy: "review it before an explicit --force replacement, or choose a different private path" });
62
+ let existing;
63
+ if (before) {
64
+ protectedCredentialReference(path);
65
+ existing = readLocalRecordSource(path, 64 * 1024, true);
66
+ if (!existing)
67
+ throw new CommandFailure("refused", "CONFLICT", "the inspected export target disappeared");
68
+ }
69
+ const target = exportTarget(cwd, typeof values.space === "string" ? values.space : undefined);
70
+ const currentRoot = findCotalRoot(cwd);
71
+ assertExternalCredentialExport(path, [target.root, currentRoot]);
72
+ let auth, cwdAuth;
73
+ try {
74
+ auth = await getSpaceAuth(workspaceSecretStore(target.root), target.space);
75
+ cwdAuth = canonicalRoot(currentRoot) === canonicalRoot(target.root) ? auth : await getSoleSpaceAuth(workspaceSecretStore(currentRoot), authDir(currentRoot));
76
+ }
77
+ catch {
78
+ throw new CommandFailure("refused", "SCHEMA_INVALID", "the selected trust chain or current-folder authority could not be established; no signer was exported");
79
+ }
80
+ if (!auth)
81
+ throw new CommandFailure("refused", "AUTH_REQUIRED", "this machine holds no validated static signing trust for the selected space; a cached login cannot replace it");
82
+ if (cwdAuth && (cwdAuth.space !== auth.space || cwdAuth.account.pub !== auth.account.pub))
83
+ throw new CommandFailure("refused", "CONFLICT", "the selected root and current folder hold different account authorities; no signer was exported", { target: { space: target.space }, remedy: "run the export from the intended authority root" });
84
+ if (existing)
85
+ replacementIsSigner(existing, auth);
86
+ protectedLocalDirectory(dirname(path));
87
+ if (before) {
88
+ protectedCredentialReference(path);
89
+ const now = lstatSync(path), current = readLocalRecordSource(path, 64 * 1024, true);
90
+ if (now.dev !== before.dev || now.ino !== before.ino || !current || digest(current) !== digest(existing))
91
+ throw new CommandFailure("refused", "CONFLICT", "the inspected signer target changed; no replacement was made");
92
+ }
93
+ const material = JSON.stringify(stripSpaceAuth(auth), null, 2) + "\n";
94
+ const receipt = { space: auth.space, account: auth.account.pub, path, contains: "data-account signing authority", operatorRootExported: false, callerIssued: false, keyRotated: false, secretOnStdout: false };
95
+ if (existing && digest(existing) === digest(Buffer.from(material, "utf8")))
96
+ return { ...receipt, replaced: false, noOp: true };
97
+ try {
98
+ if (before)
99
+ writeSecretFileAtomic(path, material);
100
+ else
101
+ writeSecretFileCreateOnly(path, material);
102
+ }
103
+ catch (error) {
104
+ if (error.code === "EEXIST")
105
+ throw new CommandFailure("refused", "CONFLICT", "the export path was claimed by another writer; it was not overwritten");
106
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "private signer publication was attempted but its outcome is unconfirmed; no write was retried", { target: { space: auth.space, path }, remedy: "inspect the private output and any owned temporary file before using or replacing it; never paste its contents into support output" });
107
+ }
108
+ return { ...receipt, replaced: before !== undefined, noOp: false };
109
+ }
110
+ finally {
111
+ lock.release();
112
+ }
113
+ }
114
+ //# sourceMappingURL=signer-export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer-export.js","sourceRoot":"","sources":["../src/signer-export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,qBAAqB,EAAE,yBAAyB,EAAiC,MAAM,gBAAgB,CAAC;AAC9I,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,kB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AC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,gCAAgC,EAAE,oBAAoB,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;QAC/M,IAAI,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAAE,OAAO,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC/H,IAAI,CAAC;YAAC,IAAI,MAAM;gBAAE,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;;gBAAM,yBAAyB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAAC,CAAC;QAC1G,OAAO,KAAK,EAAE,CAAC;YACb,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;gBAAE,MAAM,IAAI,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,uEAAuE,CAAC,CAAC;YACjL,MAAM,IAAI,cAAc,CAAC,SAAS,EAAE,mBAAmB,EAAE,+FAA+F,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,oIAAoI,EAAE,CAAC,CAAC;QACnV,CAAC;QACD,OAAO,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACrE,CAAC;YAAS,CAAC;QAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IAAC,CAAC;AAC/B,CAAC"}
@@ -84,6 +84,17 @@ export interface SpaceMaterialMigrationRefusal {
84
84
  * one is not the one someone edits.
85
85
  */
86
86
  export declare function spaceMaterialMigrationRefusal(root: string): SpaceMaterialMigrationRefusal | undefined;
87
+ export interface MaterialMigrationReceipt {
88
+ readonly space: string;
89
+ readonly kind: string;
90
+ readonly from: string;
91
+ readonly to: string;
92
+ }
93
+ export interface MaterialPathOptions {
94
+ readonly readOnly?: boolean;
95
+ /** Called only after the native rename returns. Contents never cross this observation seam. */
96
+ readonly onMigrated?: (receipt: MaterialMigrationReceipt) => void;
97
+ }
87
98
  /**
88
99
  * THE CHOKE POINT (§2 rules 1-4): resolve one kind's per-space location, migrating a legacy
89
100
  * root-scoped copy into it on first touch, or REFUSING when the move cannot be made honestly.
@@ -109,10 +120,10 @@ export declare function spaceMaterialMigrationRefusal(root: string): SpaceMateri
109
120
  * rules 2-4 is the second idiom §4 forbids. `root` stays alongside it because rule 4's tenant count
110
121
  * is a property of the ROOT's account records, not of whichever directory the material sits in.
111
122
  */
112
- export declare function migrateLegacyMaterialIn(parent: string, root: string, space: string, kind: string): string;
123
+ export declare function migrateLegacyMaterialIn(parent: string, root: string, space: string, kind: string, options?: MaterialPathOptions): string;
113
124
  /** {@link migrateLegacyMaterialIn} at P7's placement — a legacy copy sitting directly under
114
125
  * `<root>/.cotal/`. The five P7 resolvers' one entry point. */
115
- export declare function migrateLegacyCotalMaterial(root: string, space: string, kind: string): string;
126
+ export declare function migrateLegacyCotalMaterial(root: string, space: string, kind: string, options?: MaterialPathOptions): string;
116
127
  /**
117
128
  * THE `space add` DOOR (§2.1): refuse to add a second tenant to a root that still holds unmigrated
118
129
  * root-scoped material.
@@ -232,8 +243,9 @@ export declare function spaceMaterialDir(root: string, space: string): string;
232
243
  */
233
244
  export declare function assertSpaceMaterialReapable(root: string, space: string, operation: string): void;
234
245
  /**
235
- * `cotal space rm` STEP 7 (`per-space-lifecycle.md` §2.2): reap ONE tenant's segmented material — the
236
- * `$SYS` pair that step names, plus the rest of that tenant's segment, which P7 keyed alongside it.
246
+ * `cotal space rm` STEP 7 (`per-space-lifecycle.md` §2.2): reap ONE tenant's material — its
247
+ * root-level renewal audit record and segmented `$SYS` pair, plus the rest of that tenant's segment,
248
+ * which P7 keyed alongside it.
237
249
  *
238
250
  * IT CANNOT REFUSE, and that is a contract, not an omission. It runs past step 5's point of no
239
251
  * return, where a throw would strand the journal entry that gates every other verb on the root; §2.2
@@ -249,9 +261,11 @@ export declare function assertSpaceMaterialReapable(root: string, space: string,
249
261
  * a raw sweep of `.cotal/` to fall back on and this is not: for an INJECTED store the segment removal
250
262
  * below reaches nothing, so a kind missing from the seam loop would outlive its tenant.
251
263
  *
252
- * It removes only THIS space's segment. A reap spelled `.cotal/space.*` is the shape a reader reaches
253
- * for after seeing a directory removal, and on the multi-tenant root that is the only root this verb
254
- * runs on it would take every surviving tenant's live material and report success.
264
+ * It removes only THIS space's segment and renewal record. A reap spelled `.cotal/space.*` is the
265
+ * shape a reader reaches for after seeing a directory removal, and on the multi-tenant root that is
266
+ * the only root this verb runs on it would take every surviving tenant's live material and report
267
+ * success. The renewal filename is obtained from the same dependency-neutral path primitive as its
268
+ * writer and readers, never reconstructed here.
255
269
  */
256
270
  export declare function reapSpaceMaterial(root: string, space: string, secrets: SecretStore): Promise<{
257
271
  removed: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"space-segmentation.d.ts","sourceRoot":"","sources":["../src/space-segmentation.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG/D,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAKpD,CAAC;AAEF;;;;;+BAK+B;AAC/B,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD;;2DAE2D;AAC3D,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAE9D;;;;;;2EAM2E;AAC3E,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAE1E;;;;;;qFAMqF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