@skrr-ai/cli 0.1.142 → 0.1.144

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 (156) hide show
  1. package/README.md +8 -0
  2. package/dist/base-command.d.ts +4 -2
  3. package/dist/base-command.js +46 -13
  4. package/dist/commands/agenda/trigger/create.js +4 -2
  5. package/dist/commands/agenda/trigger/list.js +7 -7
  6. package/dist/commands/agent/message/approve.d.ts +17 -0
  7. package/dist/commands/agent/message/approve.js +72 -0
  8. package/dist/commands/agent/message/decline.d.ts +17 -0
  9. package/dist/commands/agent/message/decline.js +72 -0
  10. package/dist/commands/agent/message/pending.d.ts +18 -0
  11. package/dist/commands/agent/message/pending.js +79 -0
  12. package/dist/commands/agents/always-on/disable.js +9 -1
  13. package/dist/commands/agents/always-on/enable.js +9 -1
  14. package/dist/commands/agents/always-on/status.js +14 -1
  15. package/dist/commands/agents/create.js +10 -1
  16. package/dist/commands/agents/delete.d.ts +51 -0
  17. package/dist/commands/agents/delete.js +163 -2
  18. package/dist/commands/agents/intuitions/list.js +1 -1
  19. package/dist/commands/agents/plan-day.d.ts +39 -7
  20. package/dist/commands/agents/plan-day.js +254 -65
  21. package/dist/commands/agents/proactive-audit.d.ts +22 -0
  22. package/dist/commands/agents/proactive-audit.js +86 -0
  23. package/dist/commands/agents/schedule-overview.d.ts +7 -0
  24. package/dist/commands/agents/schedule-overview.js +43 -5
  25. package/dist/commands/agents/schedule-trace.js +30 -19
  26. package/dist/commands/agents/spawn.d.ts +51 -0
  27. package/dist/commands/agents/spawn.js +212 -9
  28. package/dist/commands/agents/todos/cancel.js +3 -0
  29. package/dist/commands/agents/todos/edit.js +1 -1
  30. package/dist/commands/agents/todos/list.d.ts +5 -0
  31. package/dist/commands/agents/todos/list.js +19 -5
  32. package/dist/commands/agents/triggers/create.js +1 -1
  33. package/dist/commands/agents/triggers/policy.js +7 -0
  34. package/dist/commands/agents/triggers/update.js +1 -1
  35. package/dist/commands/commitments/create.js +13 -3
  36. package/dist/commands/commitments/preflight.js +31 -5
  37. package/dist/commands/daemon/index.js +1 -0
  38. package/dist/commands/daemon/logs.d.ts +8 -1
  39. package/dist/commands/daemon/logs.js +32 -22
  40. package/dist/commands/daemon/profile.d.ts +15 -0
  41. package/dist/commands/daemon/profile.js +51 -0
  42. package/dist/commands/goals/briefing/status.js +1 -1
  43. package/dist/commands/initiatives/worker/deactivate.d.ts +23 -0
  44. package/dist/commands/initiatives/worker/deactivate.js +78 -0
  45. package/dist/commands/login.js +8 -2
  46. package/dist/commands/logout.d.ts +20 -0
  47. package/dist/commands/logout.js +110 -5
  48. package/dist/commands/machines/profiles/disconnect.d.ts +23 -0
  49. package/dist/commands/machines/profiles/disconnect.js +102 -0
  50. package/dist/commands/machines/profiles/index.d.ts +15 -0
  51. package/dist/commands/machines/profiles/index.js +33 -0
  52. package/dist/commands/machines/profiles/label.d.ts +24 -0
  53. package/dist/commands/machines/profiles/label.js +85 -0
  54. package/dist/commands/machines/profiles/list.d.ts +16 -0
  55. package/dist/commands/machines/profiles/list.js +87 -0
  56. package/dist/commands/memory/maintain.js +16 -2
  57. package/dist/commands/profiles/list.js +17 -2
  58. package/dist/commands/spaces/delete.js +6 -1
  59. package/dist/commands/spaces/workflows/archive.js +6 -1
  60. package/dist/commands/spaces/workflows/publish.js +3 -1
  61. package/dist/commands/spaces/workflows/run.d.ts +1 -0
  62. package/dist/commands/spaces/workflows/run.js +17 -1
  63. package/dist/commands/spaces/workflows/triggers/create.js +3 -1
  64. package/dist/commands/tasks/workflow-context.js +3 -1
  65. package/dist/commands/triggers/authorization.js +1 -1
  66. package/dist/commands/triggers/capabilities.js +17 -1
  67. package/dist/commands/triggers/create.d.ts +2 -0
  68. package/dist/commands/triggers/create.js +23 -7
  69. package/dist/commands/triggers/fire-detail.js +12 -3
  70. package/dist/commands/triggers/list.d.ts +1 -0
  71. package/dist/commands/triggers/list.js +13 -1
  72. package/dist/commands/triggers/preflight.js +18 -0
  73. package/dist/commands/triggers/prune.js +9 -5
  74. package/dist/commands/triggers/update.js +13 -4
  75. package/dist/generated/agent-guides.json +35 -35
  76. package/dist/lib/agent-guides.js +1 -1
  77. package/dist/lib/agent-proactive-baseline.d.ts +6 -0
  78. package/dist/lib/agent-proactive-baseline.js +32 -3
  79. package/dist/lib/always-on-command-result.d.ts +18 -0
  80. package/dist/lib/always-on-command-result.js +52 -0
  81. package/dist/lib/always-on-runtime.d.ts +31 -0
  82. package/dist/lib/always-on-runtime.js +39 -0
  83. package/dist/lib/auth-diagnostics.d.ts +10 -1
  84. package/dist/lib/auth-diagnostics.js +16 -8
  85. package/dist/lib/commitments.d.ts +16 -9
  86. package/dist/lib/commitments.js +65 -4
  87. package/dist/lib/compasses.js +5 -0
  88. package/dist/lib/daemon-binding.js +6 -3
  89. package/dist/lib/daemon-command-hint.d.ts +10 -5
  90. package/dist/lib/daemon-command-hint.js +11 -6
  91. package/dist/lib/daemon-setup.js +9 -3
  92. package/dist/lib/daemonBroker.d.ts +7 -0
  93. package/dist/lib/daemonBroker.js +5 -0
  94. package/dist/lib/daemonHandoff.d.ts +2 -0
  95. package/dist/lib/daemonHandoff.js +16 -3
  96. package/dist/lib/daemonIslandProfile.d.ts +19 -0
  97. package/dist/lib/daemonIslandProfile.js +41 -0
  98. package/dist/lib/drain-stdio.d.ts +22 -0
  99. package/dist/lib/drain-stdio.js +46 -0
  100. package/dist/lib/format.d.ts +32 -0
  101. package/dist/lib/format.js +105 -1
  102. package/dist/lib/initiatives-worker.d.ts +25 -0
  103. package/dist/lib/initiatives-worker.js +13 -0
  104. package/dist/lib/keychain.d.ts +22 -1
  105. package/dist/lib/keychain.js +40 -1
  106. package/dist/lib/local-daemon-readiness.js +4 -6
  107. package/dist/lib/local-skills.js +4 -1
  108. package/dist/lib/login.d.ts +7 -0
  109. package/dist/lib/login.js +5 -0
  110. package/dist/lib/machines.d.ts +68 -0
  111. package/dist/lib/machines.js +67 -0
  112. package/dist/lib/proactive-audit.d.ts +52 -0
  113. package/dist/lib/proactive-audit.js +67 -0
  114. package/dist/lib/proactiveApi.d.ts +23 -0
  115. package/dist/lib/refresh.d.ts +20 -6
  116. package/dist/lib/refresh.js +27 -9
  117. package/dist/lib/roles.d.ts +1 -1
  118. package/dist/lib/runtime-start-verification.js +3 -6
  119. package/dist/lib/schedule.d.ts +189 -9
  120. package/dist/lib/schedule.js +283 -22
  121. package/dist/lib/triggers.d.ts +134 -3
  122. package/dist/lib/triggers.js +370 -17
  123. package/dist/lib/workflow-node-control.js +8 -0
  124. package/dist/lib/workflow-run-view.js +9 -0
  125. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.d.ts +12 -0
  126. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.js +10 -2
  127. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.d.ts +8 -0
  128. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +22 -0
  129. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.d.ts +133 -0
  130. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.js +180 -0
  131. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +5 -3
  132. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +50 -0
  133. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.d.ts +137 -0
  134. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.js +328 -0
  135. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.d.ts +63 -0
  136. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.js +174 -0
  137. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.d.ts +22 -0
  138. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +15 -4
  139. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.d.ts +12 -0
  140. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.js +14 -0
  141. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.d.ts +8 -0
  142. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +27 -0
  143. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.d.ts +133 -0
  144. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.js +183 -0
  145. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +5 -3
  146. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +11 -3
  147. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.d.ts +137 -0
  148. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.js +333 -0
  149. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.d.ts +63 -0
  150. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.js +212 -0
  151. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.d.ts +22 -0
  152. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +22 -4
  153. package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
  154. package/dist/node_modules/@skrr-ai/data-provider/index.js +7446 -7378
  155. package/oclif.manifest.json +844 -47
  156. package/package.json +1 -1
@@ -51,6 +51,7 @@ __export(deviceIdentityBridge_exports, {
51
51
  persistPendingHardwareKey: () => persistPendingHardwareKey,
52
52
  prepareHardwareKeyCandidate: () => prepareHardwareKeyCandidate,
53
53
  resetDeviceIdentity: () => resetDeviceIdentity,
54
+ signExecutorStopReceiptV2WithDeviceKey: () => signExecutorStopReceiptV2WithDeviceKey,
54
55
  signExecutorStopReceiptWithDeviceKey: () => signExecutorStopReceiptWithDeviceKey,
55
56
  signServerRequest: () => signServerRequest,
56
57
  signWithCandidate: () => signWithCandidate
@@ -62,6 +63,7 @@ var import_proper_lockfile = __toESM(require("proper-lockfile"), 1);
62
63
  var import_deviceKey = require("./deviceKey.js");
63
64
  var import_deviceKeyHandle = require("./deviceKeyHandle.js");
64
65
  var import_executorStopReceipt = require("./executorStopReceipt.js");
66
+ var import_executorStopReceiptV2 = require("./executorStopReceiptV2.js");
65
67
  var import_deviceKeyHardware = require("./deviceKeyHardware.js");
66
68
  var import_credentialEnvelopeBridge = require("./credentialEnvelopeBridge.js");
67
69
  var import_profileStateDir = require("./profileStateDir.js");
@@ -848,6 +850,25 @@ async function signExecutorStopReceiptWithDeviceKey(body) {
848
850
  return null;
849
851
  }
850
852
  }
853
+ async function signExecutorStopReceiptV2WithDeviceKey(body) {
854
+ reloadIfRecovered();
855
+ const state = _state;
856
+ if (state.kind !== "active")
857
+ return null;
858
+ try {
859
+ return await (0, import_executorStopReceiptV2.signExecutorStopReceiptV2)(state.key, body);
860
+ } catch (err) {
861
+ emit("sign_failed", false, {
862
+ profile: state.profile,
863
+ thumbprint: state.key.thumbprint,
864
+ custody: state.key.custody,
865
+ method: "executor_stop_receipt_v2",
866
+ ...err instanceof import_deviceKeyHardware.HardwareDeviceKeyError ? { hardwareFailure: err.code } : {},
867
+ message: err?.message ?? "unknown"
868
+ });
869
+ return null;
870
+ }
871
+ }
851
872
  function __publicKeyPathForTest(profile) {
852
873
  return publicKeyPath(profile);
853
874
  }
@@ -1061,6 +1082,7 @@ async function enrollWithServer(opts) {
1061
1082
  persistPendingHardwareKey,
1062
1083
  prepareHardwareKeyCandidate,
1063
1084
  resetDeviceIdentity,
1085
+ signExecutorStopReceiptV2WithDeviceKey,
1064
1086
  signExecutorStopReceiptWithDeviceKey,
1065
1087
  signServerRequest,
1066
1088
  signWithCandidate
@@ -0,0 +1,133 @@
1
+ /**
2
+ * executorStopReceiptV2.ts — a stop receipt the PARENT daemon witnessed, with the coverage it claims.
3
+ *
4
+ * OSK-20777, docs/architecture/independent-stop-witness-2026-11-02.md. A v1 receipt (`executorStopReceipt.ts`)
5
+ * signs a body the session wrapper wrote, so it proves the claim came from the machine and nothing about how the
6
+ * claim was reached. The server holds those back until the evidence is independent and continuous. This body is
7
+ * that evidence's shape:
8
+ *
9
+ * - the observer is the parent daemon, which spawned the wrapper and is not part of the session;
10
+ * - the body states its own COVERAGE (when the witness started, when the wrapper was spawned, how many samples,
11
+ * the largest gap between two), so the server can refuse a receipt that looked too seldom, instead of trusting
12
+ * `survivors: 0`;
13
+ * - erasure is counted by the parent from a directory it created, not reported by the wrapper.
14
+ *
15
+ * The same discipline as v1: no new cryptography, a distinct proof `typ` and `htu` so a v1 receipt can never stand
16
+ * in for a v2 one (or the reverse), a closed body shape, an algorithm taken from the pin, and a reason, never a
17
+ * boolean. This module checks SHAPE and ARITHMETIC (counts add up). It does not decide whether the coverage is
18
+ * enough: the bounds are server policy and live with the server, so they can change without republishing this.
19
+ */
20
+ import { type DeviceKeyAlg, type DeviceKeySigner, type DevicePublicJwk, type VerifyFailureReason } from './deviceKey.js';
21
+ import { type ExecutorStopReceiptStatus } from './executorStopReceipt.js';
22
+ /** Header `typ` of a v2 receipt. Distinct from the v1 `typ` and from `DEVICE_PROOF_TYP` on purpose. */
23
+ export declare const EXECUTOR_STOP_RECEIPT_V2_TYP = "skrr-executor-stop-receipt-v2+jwt";
24
+ /** How the witness kept orphaned descendants from leaving its tree. `sampling_only` closes no gap. */
25
+ export declare const EXECUTOR_STOP_RECEIPT_REAP_SUPPORT: readonly ["subreaper", "kqueue", "sampling_only"];
26
+ export type ExecutorStopReceiptReapSupport = (typeof EXECUTOR_STOP_RECEIPT_REAP_SUPPORT)[number];
27
+ /** Where the process table can be read the same way. */
28
+ export declare const EXECUTOR_STOP_RECEIPT_WITNESS_PLATFORMS: readonly ["darwin", "linux"];
29
+ export type ExecutorStopReceiptWitnessPlatform = (typeof EXECUTOR_STOP_RECEIPT_WITNESS_PLATFORMS)[number];
30
+ /** The one scope the owner allowed (2026-11-01). */
31
+ export declare const EXECUTOR_STOP_RECEIPT_V2_ERASURE_SCOPE: "session_temp";
32
+ export interface ExecutorStopReceiptWitness {
33
+ kind: 'parent_census';
34
+ platform: ExecutorStopReceiptWitnessPlatform;
35
+ /** The witness was armed before the wrapper was spawned. A receipt that says false is refused by the server. */
36
+ startedBeforeSpawn: boolean;
37
+ /** ISO-8601, when the witness started. */
38
+ startedAt: string;
39
+ /** ISO-8601, when the wrapper was spawned. */
40
+ spawnedAt: string;
41
+ /** ISO-8601, after the wrapper exited and the settle window elapsed. */
42
+ endedAt: string;
43
+ /** The sampling interval the witness asked for. */
44
+ intervalMs: number;
45
+ /** Process-table reads that completed between spawn and end. */
46
+ samples: number;
47
+ /** Largest gap between two consecutive observations, counting spawn to the first and the last to the end. */
48
+ maxGapMs: number;
49
+ reapSupport: ExecutorStopReceiptReapSupport;
50
+ }
51
+ export interface ExecutorStopReceiptBodyV2 {
52
+ version: 2;
53
+ daemonId: string;
54
+ /** The scheduled Run (or Source) the dispatch belongs to. */
55
+ sourceId: string;
56
+ sessionId: string;
57
+ requestId: string;
58
+ dispatchId: string;
59
+ status: ExecutorStopReceiptStatus;
60
+ /** ISO-8601, when the session's process tree was last observed stopped. */
61
+ stoppedAt: string;
62
+ witness: ExecutorStopReceiptWitness;
63
+ /**
64
+ * `observed` is every distinct (pid, start time) ever seen under the wrapper; `observed === stopped + survivors`.
65
+ * `reparented` is how many of them were seen with init as their parent, which is what a daemonized grandchild is.
66
+ */
67
+ descendants: {
68
+ observed: number;
69
+ stopped: number;
70
+ survivors: number;
71
+ reparented: number;
72
+ };
73
+ /** Counted by the parent over the directory it created for the session. `inventory === removed + stillPresent`. */
74
+ erasure: {
75
+ scope: typeof EXECUTOR_STOP_RECEIPT_V2_ERASURE_SCOPE;
76
+ inventory: number;
77
+ removed: number;
78
+ stillPresent: number;
79
+ bytes: number;
80
+ };
81
+ }
82
+ export interface ExecutorStopReceiptV2 {
83
+ body: ExecutorStopReceiptBodyV2;
84
+ /** The device-key proof (JWS compact) that commits to `body`. */
85
+ proof: string;
86
+ }
87
+ export type ExecutorStopReceiptV2FailureReason = VerifyFailureReason | 'bad_receipt' | 'no_pin' | 'binding_mismatch' | 'not_quiescent';
88
+ export type VerifyExecutorStopReceiptV2Result = {
89
+ valid: true;
90
+ body: ExecutorStopReceiptBodyV2;
91
+ alg: DeviceKeyAlg;
92
+ thumbprint: string;
93
+ signedAtSeconds: number;
94
+ } | {
95
+ valid: false;
96
+ reason: ExecutorStopReceiptV2FailureReason;
97
+ };
98
+ /** Default ceiling on a receipt's age: one day. A replay from the response WAL can legitimately be late. */
99
+ export declare const EXECUTOR_STOP_RECEIPT_V2_DEFAULT_MAX_AGE_SECONDS: number;
100
+ declare const BINDING_KEYS: readonly ["daemonId", "sourceId", "sessionId", "requestId", "dispatchId"];
101
+ /** The URI a v2 receipt's proof names. Reserved `.invalid` host: it can never be a real request target. */
102
+ export declare function executorStopReceiptV2Htu(dispatchId: string): string;
103
+ /** Shape and arithmetic only. Returns the body as typed, or null when it is not exactly a v2 receipt body. */
104
+ export declare function parseExecutorStopReceiptBodyV2(value: unknown): ExecutorStopReceiptBodyV2 | null;
105
+ export interface SignExecutorStopReceiptV2Options {
106
+ /** Test hooks; production leaves both unset. */
107
+ iat?: number;
108
+ jti?: string;
109
+ }
110
+ /**
111
+ * Sign a v2 receipt with any `DeviceKeySigner`. Throws on a body that is not exactly a v2 receipt body, so a
112
+ * daemon bug cannot produce a signed receipt the server would only reject later.
113
+ */
114
+ export declare function signExecutorStopReceiptV2(signer: DeviceKeySigner, body: ExecutorStopReceiptBodyV2, options?: SignExecutorStopReceiptV2Options): Promise<ExecutorStopReceiptV2>;
115
+ export interface VerifyExecutorStopReceiptV2Options {
116
+ /** The key pinned on the daemon's row. REQUIRED: without it nothing authorizes the signature. */
117
+ pinnedPublicJwk: DevicePublicJwk | undefined;
118
+ /** What the server issued for this dispatch. Every key given must equal the receipt's. */
119
+ expected?: Partial<Pick<ExecutorStopReceiptBodyV2, (typeof BINDING_KEYS)[number]>>;
120
+ /** Ceiling on the receipt's age in seconds. Defaults to one day. */
121
+ maxAgeSeconds?: number;
122
+ /** Tolerated clock skew in seconds. Defaults to the proof verifier's. */
123
+ clockSkewSeconds?: number;
124
+ /** Testing hook. */
125
+ now?: number;
126
+ }
127
+ /**
128
+ * Verify a v2 receipt against the pinned key. Order: shape, then signature and pin, then the binding to the
129
+ * dispatch, then what the body claims. A forged receipt is reported as the forgery it is, not as a quiescence
130
+ * failure. A survivor or an artifact still present is `not_quiescent`. Coverage is NOT judged here.
131
+ */
132
+ export declare function verifyExecutorStopReceiptV2(receipt: unknown, options: VerifyExecutorStopReceiptV2Options): VerifyExecutorStopReceiptV2Result;
133
+ export {};
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var executorStopReceiptV2_exports = {};
20
+ __export(executorStopReceiptV2_exports, {
21
+ EXECUTOR_STOP_RECEIPT_REAP_SUPPORT: () => EXECUTOR_STOP_RECEIPT_REAP_SUPPORT,
22
+ EXECUTOR_STOP_RECEIPT_V2_DEFAULT_MAX_AGE_SECONDS: () => EXECUTOR_STOP_RECEIPT_V2_DEFAULT_MAX_AGE_SECONDS,
23
+ EXECUTOR_STOP_RECEIPT_V2_ERASURE_SCOPE: () => EXECUTOR_STOP_RECEIPT_V2_ERASURE_SCOPE,
24
+ EXECUTOR_STOP_RECEIPT_V2_TYP: () => EXECUTOR_STOP_RECEIPT_V2_TYP,
25
+ EXECUTOR_STOP_RECEIPT_WITNESS_PLATFORMS: () => EXECUTOR_STOP_RECEIPT_WITNESS_PLATFORMS,
26
+ executorStopReceiptV2Htu: () => executorStopReceiptV2Htu,
27
+ parseExecutorStopReceiptBodyV2: () => parseExecutorStopReceiptBodyV2,
28
+ signExecutorStopReceiptV2: () => signExecutorStopReceiptV2,
29
+ verifyExecutorStopReceiptV2: () => verifyExecutorStopReceiptV2
30
+ });
31
+ module.exports = __toCommonJS(executorStopReceiptV2_exports);
32
+ var import_deviceKey = require("./deviceKey.js");
33
+ var import_executorStopReceipt = require("./executorStopReceipt.js");
34
+ const EXECUTOR_STOP_RECEIPT_V2_TYP = "skrr-executor-stop-receipt-v2+jwt";
35
+ const EXECUTOR_STOP_RECEIPT_REAP_SUPPORT = ["subreaper", "kqueue", "sampling_only"];
36
+ const EXECUTOR_STOP_RECEIPT_WITNESS_PLATFORMS = ["darwin", "linux"];
37
+ const EXECUTOR_STOP_RECEIPT_V2_ERASURE_SCOPE = "session_temp";
38
+ const EXECUTOR_STOP_RECEIPT_V2_DEFAULT_MAX_AGE_SECONDS = 24 * 60 * 60;
39
+ const MAX_ID_LENGTH = 160;
40
+ const MAX_INTERVAL_MS = 6e4;
41
+ const BODY_KEYS = [
42
+ "version",
43
+ "daemonId",
44
+ "sourceId",
45
+ "sessionId",
46
+ "requestId",
47
+ "dispatchId",
48
+ "status",
49
+ "stoppedAt",
50
+ "witness",
51
+ "descendants",
52
+ "erasure"
53
+ ];
54
+ const BINDING_KEYS = ["daemonId", "sourceId", "sessionId", "requestId", "dispatchId"];
55
+ const WITNESS_KEYS = [
56
+ "kind",
57
+ "platform",
58
+ "startedBeforeSpawn",
59
+ "startedAt",
60
+ "spawnedAt",
61
+ "endedAt",
62
+ "intervalMs",
63
+ "samples",
64
+ "maxGapMs",
65
+ "reapSupport"
66
+ ];
67
+ const isPlainObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
68
+ const hasExactKeys = (value, keys) => Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
69
+ const isId = (value) => typeof value === "string" && value.length > 0 && value.length <= MAX_ID_LENGTH;
70
+ const isCount = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
71
+ const isInstant = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value));
72
+ function executorStopReceiptV2Htu(dispatchId) {
73
+ return `https://executor-stop-receipt.skrr.invalid/v2/${encodeURIComponent(dispatchId)}`;
74
+ }
75
+ function parseWitness(value) {
76
+ if (!isPlainObject(value) || !hasExactKeys(value, WITNESS_KEYS) || value.kind !== "parent_census")
77
+ return null;
78
+ if (!EXECUTOR_STOP_RECEIPT_WITNESS_PLATFORMS.includes(value.platform))
79
+ return null;
80
+ if (typeof value.startedBeforeSpawn !== "boolean")
81
+ return null;
82
+ if (!isInstant(value.startedAt) || !isInstant(value.spawnedAt) || !isInstant(value.endedAt))
83
+ return null;
84
+ if (!isCount(value.intervalMs) || value.intervalMs < 1 || value.intervalMs > MAX_INTERVAL_MS || !isCount(value.samples) || !isCount(value.maxGapMs))
85
+ return null;
86
+ if (!EXECUTOR_STOP_RECEIPT_REAP_SUPPORT.includes(value.reapSupport))
87
+ return null;
88
+ return value;
89
+ }
90
+ function parseExecutorStopReceiptBodyV2(value) {
91
+ if (!isPlainObject(value) || !hasExactKeys(value, BODY_KEYS) || value.version !== 2)
92
+ return null;
93
+ if (!BINDING_KEYS.every((key) => isId(value[key])))
94
+ return null;
95
+ if (value.status !== "completed" && value.status !== "failed" && value.status !== "cancelled")
96
+ return null;
97
+ if (!isInstant(value.stoppedAt))
98
+ return null;
99
+ if (!parseWitness(value.witness))
100
+ return null;
101
+ const d = value.descendants;
102
+ if (!isPlainObject(d) || !hasExactKeys(d, ["observed", "stopped", "survivors", "reparented"]))
103
+ return null;
104
+ if (!isCount(d.observed) || !isCount(d.stopped) || !isCount(d.survivors) || !isCount(d.reparented))
105
+ return null;
106
+ if (d.observed !== d.stopped + d.survivors || d.reparented > d.observed)
107
+ return null;
108
+ const e = value.erasure;
109
+ if (!isPlainObject(e) || !hasExactKeys(e, ["scope", "inventory", "removed", "stillPresent", "bytes"]) || e.scope !== EXECUTOR_STOP_RECEIPT_V2_ERASURE_SCOPE)
110
+ return null;
111
+ if (!isCount(e.inventory) || !isCount(e.removed) || !isCount(e.stillPresent) || !isCount(e.bytes))
112
+ return null;
113
+ if (e.inventory !== e.removed + e.stillPresent)
114
+ return null;
115
+ return value;
116
+ }
117
+ async function signExecutorStopReceiptV2(signer, body, options = {}) {
118
+ const parsed = parseExecutorStopReceiptBodyV2(body);
119
+ if (!parsed)
120
+ throw new Error("signExecutorStopReceiptV2: body is not a v2 executor stop receipt body");
121
+ const proof = await (0, import_deviceKey.signProofWith)(signer, {
122
+ method: "POST",
123
+ url: executorStopReceiptV2Htu(parsed.dispatchId),
124
+ // `accessToken` is hashed inline into the `ath` claim: the commitment to the body.
125
+ accessToken: (0, import_executorStopReceipt.canonicalReceiptJson)(parsed),
126
+ ...options.iat !== void 0 ? { iat: options.iat } : {},
127
+ ...options.jti !== void 0 ? { jti: options.jti } : {}
128
+ }, EXECUTOR_STOP_RECEIPT_V2_TYP);
129
+ return { body: parsed, proof };
130
+ }
131
+ function verifyExecutorStopReceiptV2(receipt, options) {
132
+ if (!isPlainObject(receipt) || !hasExactKeys(receipt, ["body", "proof"])) {
133
+ return { valid: false, reason: "bad_receipt" };
134
+ }
135
+ const body = parseExecutorStopReceiptBodyV2(receipt.body);
136
+ if (!body || typeof receipt.proof !== "string")
137
+ return { valid: false, reason: "bad_receipt" };
138
+ const pin = options.pinnedPublicJwk;
139
+ if (!pin || !(0, import_deviceKey.isDevicePublicJwk)(pin))
140
+ return { valid: false, reason: "no_pin" };
141
+ const result = (0, import_deviceKey.verifyDevicePublicKeyProof)(receipt.proof, {
142
+ expectedHtm: "POST",
143
+ expectedHtu: executorStopReceiptV2Htu(body.dispatchId),
144
+ expectedAth: (0, import_deviceKey.tokenHash)((0, import_executorStopReceipt.canonicalReceiptJson)(body)),
145
+ pinnedPublicJwk: pin,
146
+ // The algorithm of the PIN, never a list: a receipt cannot pick a weaker one.
147
+ allowedAlgs: [(0, import_deviceKey.algForJwk)(pin)],
148
+ maxAgeSeconds: options.maxAgeSeconds ?? EXECUTOR_STOP_RECEIPT_V2_DEFAULT_MAX_AGE_SECONDS,
149
+ ...options.clockSkewSeconds !== void 0 ? { clockSkewSeconds: options.clockSkewSeconds } : {},
150
+ ...options.now !== void 0 ? { now: options.now } : {}
151
+ }, EXECUTOR_STOP_RECEIPT_V2_TYP);
152
+ if (!result.valid)
153
+ return { valid: false, reason: result.reason };
154
+ for (const key of BINDING_KEYS) {
155
+ const want = options.expected?.[key];
156
+ if (want !== void 0 && body[key] !== want)
157
+ return { valid: false, reason: "binding_mismatch" };
158
+ }
159
+ if (body.descendants.survivors > 0 || body.erasure.stillPresent > 0)
160
+ return { valid: false, reason: "not_quiescent" };
161
+ return {
162
+ valid: true,
163
+ body,
164
+ alg: result.alg,
165
+ thumbprint: (0, import_deviceKey.jwkThumbprint)(result.publicJwk),
166
+ signedAtSeconds: result.claims.iat
167
+ };
168
+ }
169
+ // Annotate the CommonJS export names for ESM import in node:
170
+ 0 && (module.exports = {
171
+ EXECUTOR_STOP_RECEIPT_REAP_SUPPORT,
172
+ EXECUTOR_STOP_RECEIPT_V2_DEFAULT_MAX_AGE_SECONDS,
173
+ EXECUTOR_STOP_RECEIPT_V2_ERASURE_SCOPE,
174
+ EXECUTOR_STOP_RECEIPT_V2_TYP,
175
+ EXECUTOR_STOP_RECEIPT_WITNESS_PLATFORMS,
176
+ executorStopReceiptV2Htu,
177
+ parseExecutorStopReceiptBodyV2,
178
+ signExecutorStopReceiptV2,
179
+ verifyExecutorStopReceiptV2
180
+ });
@@ -13,7 +13,7 @@ export { decodeJwtExpiry, decodeJwtPayload } from './jwtUtils.js';
13
13
  export { isAuthExpiredSseEvent, handleMidStreamAuthExpiry, type ParsedSseLike, type AuthExpiredCallbacks, type HandleMidStreamAuthExpiryResult, } from './authExpiredDetector.js';
14
14
  export { formatReauthMessage, reauthCommand, EXIT_NEEDS_REAUTH, type AuthFailureReason, } from './messages.js';
15
15
  export { classifyRefreshResponse, type RefreshResponseShape, type ClassifiedRefreshResult, type ClassifiedRefreshSuccess, type ClassifiedRefreshFailure, } from './refreshClassification.js';
16
- export { refreshDaemonToken, revokeDaemonRefreshSession, withAuthLock, persistReauthState, needsReauthState, clearReauthState, installLockExitHandlers, __refreshDiagnostics, __resetUnknown401StreaksForTest, UNKNOWN_401_BUDGET, } from './refresh.js';
16
+ export { refreshDaemonToken, revokeDaemonRefreshSession, revokeDaemonRefreshSessionReported, type RefreshRevokeResult, withAuthLock, persistReauthState, needsReauthState, clearReauthState, installLockExitHandlers, __refreshDiagnostics, __resetUnknown401StreaksForTest, UNKNOWN_401_BUDGET, } from './refresh.js';
17
17
  export { createRefreshScheduler, type RefreshScheduler, type RefreshSchedulerOptions, } from './refreshScheduler.js';
18
18
  export { readAuthFromFd, __setFdReaderForTest, type FdAuthPayload } from './fdToken.js';
19
19
  export { CredentialResolver, CREDENTIAL_PRECEDENCE, __resetCredentialResolverForTest, invalidateAuthHelperCache, classifyTokenKind, CI_TOKEN_PREFIX, PERSONAL_ACCESS_TOKEN_PREFIX, isStaticTokenKind, AuthHelperUntrustedError, AuthHelperUnavailableError, type CredentialSource, type CredentialStoreMode, type CredentialResolverOptions, type ResolvedCredential, type TokenKind, type HelperTrustDecision, type AuthHelperBlockedInfo, type AuthHelperSentinelInfo, } from './credentialResolver.js';
@@ -29,12 +29,13 @@ export { __setKekStrategyForTest, getKekStrategy, InMemoryKek, UnavailableKek, K
29
29
  export { ALLOW_LIVE_STATE_ENV, __setAccountHomeForTest, DAEMON_BYOK_KEYCHAIN_SERVICE_BASE, DAEMON_KEYCHAIN_SERVICE_BASE, HERMETIC_HOME_ENV, LEGACY_DAEMON_KEYCHAIN_SERVICE, LIVE_DEFAULT_PROFILE, LIVE_STATE_REFUSED_CODE, LiveStateRefusedError, accountHomeDir, assertMayMutateLiveKeychain, assertMayMutateLiveState, isLiveKeychainService, isLiveStateRefusal, isTestProcess, keychainSuffixForDir, liveKeychainServices, liveStateRoot, refusesLiveKeychainMutation, refusesLiveStateInTest, rethrowIfLiveStateRefusal, testProcessSignal, type LiveKeychainProbe, type LiveStateProbe, } from './liveState.js';
30
30
  export { algForJwk, buildProof as buildDeviceProof, DEVICE_KEY_ALGS, generateDeviceKeyPair, isDevicePublicJwk, jwkThumbprint, normalizeHtu, p256PublicJwkFromRaw, proofSigningInput, publicJwkFromX, signProofWith, tokenHash, verifyProof as verifyDeviceProof, type DeviceKeyAlg, type DeviceKeyPair, type DeviceKeySigner, type DevicePublicJwk, type DeviceProofClaims, type DeviceProofHeader, type Ed25519PrivateJwk, type Ed25519PublicJwk, type P256PublicJwk, type VerifyFailureReason as DeviceProofVerifyFailureReason, type VerifyFailure as DeviceProofVerifyFailure, type VerifyOptions as DeviceProofVerifyOptions, type VerifySuccess as DeviceProofVerifySuccess, } from './deviceKey.js';
31
31
  export { canonicalReceiptJson, EXECUTOR_STOP_RECEIPT_DEFAULT_MAX_AGE_SECONDS, EXECUTOR_STOP_RECEIPT_ERASURE_SCOPES, EXECUTOR_STOP_RECEIPT_TYP, executorStopReceiptHtu, parseExecutorStopReceiptBody, signExecutorStopReceipt, verifyExecutorStopReceipt, type ExecutorStopReceipt, type ExecutorStopReceiptBody, type ExecutorStopReceiptErasureScope, type ExecutorStopReceiptFailureReason, type ExecutorStopReceiptStatus, type SignExecutorStopReceiptOptions, type VerifyExecutorStopReceiptOptions, type VerifyExecutorStopReceiptResult, } from './executorStopReceipt.js';
32
+ export { EXECUTOR_STOP_RECEIPT_REAP_SUPPORT, EXECUTOR_STOP_RECEIPT_V2_DEFAULT_MAX_AGE_SECONDS, EXECUTOR_STOP_RECEIPT_V2_ERASURE_SCOPE, EXECUTOR_STOP_RECEIPT_V2_TYP, EXECUTOR_STOP_RECEIPT_WITNESS_PLATFORMS, executorStopReceiptV2Htu, parseExecutorStopReceiptBodyV2, signExecutorStopReceiptV2, verifyExecutorStopReceiptV2, type ExecutorStopReceiptBodyV2, type ExecutorStopReceiptReapSupport, type ExecutorStopReceiptV2, type ExecutorStopReceiptV2FailureReason, type ExecutorStopReceiptWitness, type ExecutorStopReceiptWitnessPlatform, type SignExecutorStopReceiptV2Options, type VerifyExecutorStopReceiptV2Options, type VerifyExecutorStopReceiptV2Result, } from './executorStopReceiptV2.js';
32
33
  export { softwareEd25519Handle, type DeviceKeyCustody, type DeviceKeyHandle } from './deviceKeyHandle.js';
33
34
  export { AUTH_SERVER_METADATA_PATH, readServerDeviceKeyAlgs, SERVER_DEVICE_KEY_ALGS_FIELD, } from './deviceKeyServerSupport.js';
34
35
  export { configureHardwareDeviceKeyHelper, HARDWARE_KEY_HELPER_NAME, HardwareDeviceKeyError, probeHardwareDeviceKey, resolveHardwareDeviceKeyHelper, type HardwareDeviceKeyErrorCode, type HardwareKeyCapability, } from './deviceKeyHardware.js';
35
36
  export { DPOP_HEADER, DPOP_MAX_AGE_SECONDS, DPOP_PROOF_INVALID, DPOP_PROOF_REQUIRED, DPOP_PROOF_TYP, DPOP_PROOF_VERIFY_UNAVAILABLE, accessTokenHash, createDpopKey, isAth, isJwkThumbprint, normalizeDpopHtu, verifyDpopProof, type DpopKey, type DpopProofClaims, type DpopProofRequest, type DpopVerifyFailureReason, type DpopVerifyOptions, type DpopVerifyResult, } from './dpop.js';
36
37
  export { initCredEnvelope, initExistingCredEnvelope, initNewIndependentCredEnvelope, resetCredEnvelope, shutdownCredEnvelope, isCredEnvelopeActive, hasCredEnvelopePathConflict, describeCredEnvelopeState, splitKeyConvergencePolicy, maybeEncryptForWrite, maybeDecryptOnRead, DEFAULT_UNREADABLE_CREDENTIAL_HINT, type DecryptOnReadOptions, __wrappedDekFilePathForTest, __setStateForTest as __setCredEnvelopeStateForTest, __getStateForTest as __getCredEnvelopeStateForTest, __resetShutdownGuardForTest, type ReadTransformResult, } from './credentialEnvelopeBridge.js';
37
- export { initDeviceIdentity, resetDeviceIdentity, signServerRequest, signExecutorStopReceiptWithDeviceKey, prepareHardwareKeyCandidate, commitDeviceKeyCandidate, signWithCandidate, persistPendingHardwareKey, commitPendingHardwareKey, discardPendingHardwareKey, PENDING_HARDWARE_KEY_MAX_AGE_MS, type DeviceKeyCandidate, type DeviceKeyCandidateResult, type PendingHardwareKeyOutcome, enrollWithServer, clearEnrollmentMarker, isDeviceIdentityActive, getDevicePublicKey, describeDeviceIdentityState, describeDeviceKeySplit, describeStoredDeviceKey, DEVICE_KEY_UNREADABLE_CREDENTIAL_HINT, type StoredDeviceKeyDescription, __publicKeyPathForTest, __privateKeyPathForTest, __enrollmentMarkerPathForTest, __enrollmentBackoffPathForTest, __setUnreadableReloadIntervalForTest, __setStateForTest as __setDeviceIdentityStateForTest, __getStateForTest as __getDeviceIdentityStateForTest, type EnrollmentResult, } from './deviceIdentityBridge.js';
38
+ export { initDeviceIdentity, resetDeviceIdentity, signServerRequest, signExecutorStopReceiptWithDeviceKey, signExecutorStopReceiptV2WithDeviceKey, prepareHardwareKeyCandidate, commitDeviceKeyCandidate, signWithCandidate, persistPendingHardwareKey, commitPendingHardwareKey, discardPendingHardwareKey, PENDING_HARDWARE_KEY_MAX_AGE_MS, type DeviceKeyCandidate, type DeviceKeyCandidateResult, type PendingHardwareKeyOutcome, enrollWithServer, clearEnrollmentMarker, isDeviceIdentityActive, getDevicePublicKey, describeDeviceIdentityState, describeDeviceKeySplit, describeStoredDeviceKey, DEVICE_KEY_UNREADABLE_CREDENTIAL_HINT, type StoredDeviceKeyDescription, __publicKeyPathForTest, __privateKeyPathForTest, __enrollmentMarkerPathForTest, __enrollmentBackoffPathForTest, __setUnreadableReloadIntervalForTest, __setStateForTest as __setDeviceIdentityStateForTest, __getStateForTest as __getDeviceIdentityStateForTest, type EnrollmentResult, } from './deviceIdentityBridge.js';
38
39
  export { getMachineUuid, getMachineUuidForProfile, describeMachineIdentity, type MachineIdentityDescription, type MachineIdentityReason, getHardwareMachineUuid, setMachineUuidProfile, getMachineUuidProfile, qualifyMachineUuid, MACHINE_IDENTITY_FILENAME, hostedRuntimeIdOverride, HOSTED_RUNTIME_MACHINE_SOURCES, __resetMachineUuidCacheForTest, } from './machineUuid.js';
39
40
  export { ensureMachineDaemonId, legacyDaemonUuids, __resetCachedDaemonIdForTest, } from './machineId.js';
40
41
  export { PAIR_AAD_PREFIX, PAIR_AAD_MAX_LEN, PAIR_BUNDLE_MAX_BASE64_LEN, PAIR_NONCE_LEN, PAIR_PUBKEY_LEN, PAIR_SECRET_LEN, PairBundleError, assemblePairBundleBase64, base64ToUint8Array as pairBase64ToUint8Array, base64UrlToUint8Array as pairBase64UrlToUint8Array, buildPairAad, buildPairUrl, generatePairKeyPair, openPairBundleBase64, parsePairBundle, parsePairPlaintext, parsePairUrl, uint8ArrayToBase64 as pairUint8ArrayToBase64, uint8ArrayToBase64Url as pairUint8ArrayToBase64Url, type AssembleBundleOptions as PairAssembleBundleOptions, type OpenBundleOptions as PairOpenBundleOptions, type PairBundle, type PairBundleErrorCode, type PairKeyPair, type PairPlaintextV1, type PairUrlFields, } from './daemonPair.js';
@@ -49,7 +50,8 @@ export { FIRST_PARTY_HARNESS_PREVIOUS_SUFFIX, FIRST_PARTY_HARNESS_PROVENANCE_SUF
49
50
  export { DEFAULT_FIRST_PARTY_HARNESS_CHANNEL, FIRST_PARTY_HARNESS_CHANNELS, firstPartyHarnessChannelPrefix, firstPartyHarnessFeedBase, firstPartyHarnessFeedCandidates, isFirstPartyHarnessChannel, resolveChannelManifestUrl, resolveFirstPartyHarnessChannel, type FirstPartyHarnessChannel, type FirstPartyHarnessFeedCandidate, } from './firstPartyHarnessChannels.js';
50
51
  export { OVERSKY_RELEASE_PUBLIC_KEYS, type ReleaseKey } from './releaseKeys.js';
51
52
  export { MAX_SIGS, TRUSTED_FEED_ORIGINS, buildArtifactMessage, buildManifestMessage, getDeltaFor, isTrustedArtifactOrigin, verifyArtifact, verifyManifest, type DaemonVersionManifest, type DeltaDescriptor, type ManifestSignature, type PlatformArtifact, type VerifyResult, } from './releaseManifest.js';
52
- export { resolveConfigRoot, configRootPath, isConfigRootOverridden } from './configRoot.js';
53
+ export { resolveConfigRoot, configRootPath, isConfigRootOverridden, CONFIG_ROOT_ENV_VARS, withConfigRoot, } from './configRoot.js';
54
+ export { DEFAULT_PROFILE, PROFILE_LOCK_FILENAME, PROFILE_ENV_VAR, assertValidProfileName, isValidProfileName, profileLockPath, readProfileLock, resolveProfileSelection, explicitProfileArgs, profileIsImplicit, describeProfileSelection, type ProfileSelection, type ProfileSelectionSource, type ResolveProfileSelectionInput, } from './profileSelection.js';
53
55
  export { PROFILES_SEGMENT, SUPERSEDED_MARKER_SUFFIX, SUPERSEDED_COPY_SUFFIX, profileStateDir, legacyProfileStateDir, resolveProfileStateDir, resolveProfileStateFile, profileStateFileLocations, profileStateFilePathsToClear, consolidateProfileState, type ResolvedProfileStateDir, type ConsolidationSpec, type ConsolidationStatus, type ConsolidationOutcome, } from './profileStateDir.js';
54
56
  export * from './harnessPermissionControls.js';
55
57
  export { compareReleaseVersions } from './releaseVersions.js';