@skrr-ai/cli 0.1.141 → 0.1.143

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 (85) hide show
  1. package/dist/base-command.d.ts +4 -2
  2. package/dist/base-command.js +46 -13
  3. package/dist/commands/agents/always-on/disable.js +9 -1
  4. package/dist/commands/agents/always-on/enable.js +9 -1
  5. package/dist/commands/agents/always-on/status.js +14 -1
  6. package/dist/commands/agents/create.js +10 -1
  7. package/dist/commands/agents/delete.d.ts +6 -0
  8. package/dist/commands/agents/delete.js +24 -0
  9. package/dist/commands/agents/intuitions/list.js +1 -1
  10. package/dist/commands/agents/spawn.d.ts +9 -0
  11. package/dist/commands/agents/spawn.js +127 -7
  12. package/dist/commands/agents/todos/cancel.js +3 -0
  13. package/dist/commands/agents/todos/edit.js +1 -1
  14. package/dist/commands/agents/triggers/policy.js +7 -0
  15. package/dist/commands/commitments/preflight.js +17 -2
  16. package/dist/commands/daemon/index.js +1 -0
  17. package/dist/commands/daemon/logs.d.ts +8 -1
  18. package/dist/commands/daemon/logs.js +32 -22
  19. package/dist/commands/daemon/profile.d.ts +15 -0
  20. package/dist/commands/daemon/profile.js +51 -0
  21. package/dist/commands/goals/briefing/status.js +1 -1
  22. package/dist/commands/machines/profiles/disconnect.d.ts +23 -0
  23. package/dist/commands/machines/profiles/disconnect.js +102 -0
  24. package/dist/commands/machines/profiles/index.d.ts +15 -0
  25. package/dist/commands/machines/profiles/index.js +33 -0
  26. package/dist/commands/machines/profiles/label.d.ts +24 -0
  27. package/dist/commands/machines/profiles/label.js +85 -0
  28. package/dist/commands/machines/profiles/list.d.ts +16 -0
  29. package/dist/commands/machines/profiles/list.js +87 -0
  30. package/dist/commands/profiles/list.js +17 -2
  31. package/dist/commands/spaces/heartbeats/create.js +1 -1
  32. package/dist/commands/spaces/heartbeats/update.js +1 -1
  33. package/dist/commands/triggers/authorization.js +1 -1
  34. package/dist/lib/agent-guides.js +1 -1
  35. package/dist/lib/agent-proactive-baseline.d.ts +6 -0
  36. package/dist/lib/agent-proactive-baseline.js +25 -2
  37. package/dist/lib/always-on-command-result.d.ts +18 -0
  38. package/dist/lib/always-on-command-result.js +52 -0
  39. package/dist/lib/always-on-runtime.d.ts +31 -0
  40. package/dist/lib/always-on-runtime.js +39 -0
  41. package/dist/lib/auth-diagnostics.d.ts +10 -1
  42. package/dist/lib/auth-diagnostics.js +16 -8
  43. package/dist/lib/compasses.js +5 -0
  44. package/dist/lib/daemon-binding.js +6 -3
  45. package/dist/lib/daemon-command-hint.d.ts +10 -5
  46. package/dist/lib/daemon-command-hint.js +11 -6
  47. package/dist/lib/daemonHandoff.js +6 -2
  48. package/dist/lib/drain-stdio.d.ts +22 -0
  49. package/dist/lib/drain-stdio.js +46 -0
  50. package/dist/lib/keychain.d.ts +22 -1
  51. package/dist/lib/keychain.js +40 -1
  52. package/dist/lib/local-daemon-readiness.js +4 -6
  53. package/dist/lib/local-skills.js +4 -1
  54. package/dist/lib/machines.d.ts +68 -0
  55. package/dist/lib/machines.js +67 -0
  56. package/dist/lib/proactiveApi.d.ts +15 -1
  57. package/dist/lib/runtime-start-verification.js +3 -6
  58. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.d.ts +12 -0
  59. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.js +10 -2
  60. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.d.ts +8 -0
  61. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +22 -0
  62. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.d.ts +133 -0
  63. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.js +180 -0
  64. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +4 -2
  65. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +48 -0
  66. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.d.ts +137 -0
  67. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.js +328 -0
  68. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.d.ts +63 -0
  69. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.js +174 -0
  70. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.d.ts +12 -0
  71. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.js +14 -0
  72. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.d.ts +8 -0
  73. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +27 -0
  74. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.d.ts +133 -0
  75. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.js +183 -0
  76. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +4 -2
  77. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +10 -2
  78. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.d.ts +137 -0
  79. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.js +333 -0
  80. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.d.ts +63 -0
  81. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.js +212 -0
  82. package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
  83. package/dist/node_modules/@skrr-ai/data-provider/index.js +7295 -7265
  84. package/oclif.manifest.json +332 -3
  85. package/package.json +1 -1
@@ -46,6 +46,10 @@ export interface MachineHarnessRow {
46
46
  authStatus?: string;
47
47
  lastSeenAt: string | null;
48
48
  daemonId: string | null;
49
+ /** The daemon profile this registration belongs to, when the server knows it. */
50
+ profile?: string;
51
+ /** A person's display label for that profile (OSK-22308); present only when one is set. */
52
+ profileLabel?: MachineProfileLabel;
49
53
  /**
50
54
  * A newer registration of the same provider on this machine replaced this
51
55
  * row. Rows are keyed per daemonId, and daemonId changes when the same daemon
@@ -234,6 +238,33 @@ export declare function parseDaemonId(daemonId: string): {
234
238
  source: string;
235
239
  profile: string;
236
240
  } | null;
241
+ /** A person's display name and note for one daemon profile (OSK-22308). Display only. */
242
+ export interface MachineProfileLabel {
243
+ label?: string;
244
+ description?: string;
245
+ }
246
+ /** One daemon profile on a machine, gathered from its harness rows. */
247
+ export interface MachineProfileSummary {
248
+ /** The profile's name: a directory, a Keychain suffix and a service label, so it cannot change. */
249
+ name: string;
250
+ label: MachineProfileLabel | null;
251
+ /** The same contact words as `summarizeDaemons`. */
252
+ status: MachineDaemonSummary['status'];
253
+ lastSeenAt: string | null;
254
+ /** Current (not superseded) registrations, and the providers they run. */
255
+ harnessCount: number;
256
+ providers: string[];
257
+ /** The daemon ids its registrations used. Several when it was started different ways. */
258
+ daemonIds: string[];
259
+ }
260
+ /** The profile a harness row belongs to: the server's field, else the one its legacy daemon id names. */
261
+ export declare function harnessProfileOf(row: Pick<MachineHarnessRow, 'profile' | 'daemonId'>): string | null;
262
+ /**
263
+ * The daemon profiles one machine's harness rows belong to, live first. A row whose
264
+ * profile cannot be told (a hosted box, an id with no profile in it) is left out: it
265
+ * belongs to no profile a person could disconnect or label.
266
+ */
267
+ export declare function summarizeMachineProfiles(harnesses: readonly MachineHarnessRow[]): MachineProfileSummary[];
237
268
  /** The word the tables print for one harness row: the server's statement, not the bare status. */
238
269
  export declare function harnessStateLabel(row: MachineHarnessRow): string;
239
270
  export declare function summarizeDaemons(harnesses: readonly MachineHarnessRow[], activeProfile: string): MachineDaemonSummary[];
@@ -310,4 +341,41 @@ export declare function listMachines(): Promise<Machine[]>;
310
341
  export declare function getMachine(machineId: string): Promise<Machine | null>;
311
342
  export declare function updateMachine(machineId: string, patch: MachinePreferencesPatch): Promise<Machine | null>;
312
343
  export declare function disconnectMachine(machineId: string): Promise<Record<string, unknown> | null>;
344
+ /** What disconnecting one daemon profile did (`POST .../profiles/:profile/actions/disconnect`). */
345
+ export interface MachineProfileDisconnectResult {
346
+ ok: true;
347
+ profile: string;
348
+ /**
349
+ * The profile shares this computer's server identity with other profiles (a
350
+ * profile created before OSK-13845), so only its own sessions were revoked and
351
+ * the machine stays connected for the others.
352
+ */
353
+ sharedIdentity: boolean;
354
+ otherProfiles: string[];
355
+ revokedDaemon: boolean;
356
+ revokedSessions: number;
357
+ retiredHarnesses: number;
358
+ releasedHolds: number;
359
+ labelCleared: number | boolean;
360
+ }
361
+ /**
362
+ * Disconnect ONE daemon profile of a machine (OSK-22306): revoke that profile's
363
+ * daemon credential and nothing another profile holds, and retire its harness rows.
364
+ * The server refuses while agents are pinned to it (`PROFILE_ASSIGNED_AGENTS`).
365
+ */
366
+ export declare function disconnectMachineProfile(machineId: string, profile: string, options?: {
367
+ clearLabel?: boolean;
368
+ }): Promise<MachineProfileDisconnectResult | null>;
369
+ /**
370
+ * Set or clear one daemon profile's display label and description (OSK-22308).
371
+ * An empty string clears a field; a field left out is unchanged.
372
+ */
373
+ export declare function setMachineProfileLabel(machineId: string, profile: string, patch: {
374
+ label?: string;
375
+ description?: string;
376
+ }): Promise<{
377
+ profile: string;
378
+ runtimeKeys: number;
379
+ label: MachineProfileLabel | null;
380
+ } | null>;
313
381
  export declare function resolveMachineRef(machines: Machine[], ref: string): Machine;
@@ -6,6 +6,8 @@ exports.isReachableMachine = isReachableMachine;
6
6
  exports.isOwnComputer = isOwnComputer;
7
7
  exports.isListedByDefault = isListedByDefault;
8
8
  exports.parseDaemonId = parseDaemonId;
9
+ exports.harnessProfileOf = harnessProfileOf;
10
+ exports.summarizeMachineProfiles = summarizeMachineProfiles;
9
11
  exports.harnessStateLabel = harnessStateLabel;
10
12
  exports.summarizeDaemons = summarizeDaemons;
11
13
  exports.isThisComputer = isThisComputer;
@@ -17,6 +19,8 @@ exports.listMachines = listMachines;
17
19
  exports.getMachine = getMachine;
18
20
  exports.updateMachine = updateMachine;
19
21
  exports.disconnectMachine = disconnectMachine;
22
+ exports.disconnectMachineProfile = disconnectMachineProfile;
23
+ exports.setMachineProfileLabel = setMachineProfileLabel;
20
24
  exports.resolveMachineRef = resolveMachineRef;
21
25
  const data_provider_1 = require("@skrr-ai/data-provider");
22
26
  const api_fetch_1 = require("./api-fetch");
@@ -141,6 +145,54 @@ function newerStamp(a, b) {
141
145
  return new Date(b).getTime() > new Date(a).getTime() ? b : a;
142
146
  }
143
147
  const RANK = { online: 0, reconnecting: 1, stale: 2, offline: 3 };
148
+ /** The profile a harness row belongs to: the server's field, else the one its legacy daemon id names. */
149
+ function harnessProfileOf(row) {
150
+ if (row.profile)
151
+ return row.profile;
152
+ return row.daemonId ? (parseDaemonId(row.daemonId)?.profile ?? null) : null;
153
+ }
154
+ /**
155
+ * The daemon profiles one machine's harness rows belong to, live first. A row whose
156
+ * profile cannot be told (a hosted box, an id with no profile in it) is left out: it
157
+ * belongs to no profile a person could disconnect or label.
158
+ */
159
+ function summarizeMachineProfiles(harnesses) {
160
+ const byName = new Map();
161
+ for (const row of harnesses) {
162
+ const name = harnessProfileOf(row);
163
+ if (!name)
164
+ continue;
165
+ const entry = byName.get(name) ?? {
166
+ name,
167
+ label: null,
168
+ status: 'offline',
169
+ lastSeenAt: null,
170
+ harnessCount: 0,
171
+ providers: [],
172
+ daemonIds: [],
173
+ };
174
+ if (row.profileLabel && !entry.label)
175
+ entry.label = row.profileLabel;
176
+ if (row.daemonId && !entry.daemonIds.includes(row.daemonId))
177
+ entry.daemonIds.push(row.daemonId);
178
+ if (row.superseded !== true) {
179
+ entry.harnessCount += 1;
180
+ if (!entry.providers.includes(row.provider))
181
+ entry.providers.push(row.provider);
182
+ const state = (0, data_provider_1.daemonContactOfRow)(row);
183
+ const rowStatus = state === 'live' ? 'online' : state;
184
+ if (RANK[rowStatus] < RANK[entry.status])
185
+ entry.status = rowStatus;
186
+ }
187
+ entry.lastSeenAt = newerStamp(entry.lastSeenAt, row.lastSeenAt);
188
+ byName.set(name, entry);
189
+ }
190
+ return [...byName.values()].sort((a, b) => {
191
+ if (a.status !== b.status)
192
+ return RANK[a.status] - RANK[b.status];
193
+ return a.name.localeCompare(b.name);
194
+ });
195
+ }
144
196
  /** The word the tables print for one harness row: the server's statement, not the bare status. */
145
197
  function harnessStateLabel(row) {
146
198
  return data_provider_1.DAEMON_CONTACT_WORDS[(0, data_provider_1.daemonContactOfRow)(row)];
@@ -300,6 +352,21 @@ async function updateMachine(machineId, patch) {
300
352
  async function disconnectMachine(machineId) {
301
353
  return (0, api_fetch_1.apiFetch)(`/api/machines/${encodeURIComponent(machineId)}/actions/disconnect`, { method: 'POST', body: {} });
302
354
  }
355
+ /**
356
+ * Disconnect ONE daemon profile of a machine (OSK-22306): revoke that profile's
357
+ * daemon credential and nothing another profile holds, and retire its harness rows.
358
+ * The server refuses while agents are pinned to it (`PROFILE_ASSIGNED_AGENTS`).
359
+ */
360
+ async function disconnectMachineProfile(machineId, profile, options = {}) {
361
+ return (0, api_fetch_1.apiFetch)(`/api/machines/${encodeURIComponent(machineId)}/profiles/${encodeURIComponent(profile)}/actions/disconnect`, { method: 'POST', body: options.clearLabel ? { clearLabel: true } : {} });
362
+ }
363
+ /**
364
+ * Set or clear one daemon profile's display label and description (OSK-22308).
365
+ * An empty string clears a field; a field left out is unchanged.
366
+ */
367
+ async function setMachineProfileLabel(machineId, profile, patch) {
368
+ return (0, api_fetch_1.apiFetch)(`/api/machines/${encodeURIComponent(machineId)}/profiles/${encodeURIComponent(profile)}/label`, { method: 'PUT', body: patch });
369
+ }
303
370
  /**
304
371
  * Resolve a user-supplied reference to exactly one machine.
305
372
  *
@@ -85,7 +85,7 @@ export interface PlanProactiveAgentResponse {
85
85
  needsRefinement: boolean;
86
86
  failure?: {
87
87
  code: string;
88
- retryable: boolean;
88
+ retryable: boolean | null;
89
89
  billingOwnerType: string | null;
90
90
  };
91
91
  droppedWatchers?: string[];
@@ -122,6 +122,11 @@ export interface ApplyProactiveAgentResponse {
122
122
  status?: string;
123
123
  code?: string;
124
124
  };
125
+ compass?: {
126
+ ok: boolean;
127
+ skipped?: string;
128
+ code?: string;
129
+ };
125
130
  orchestrator?: {
126
131
  ok: boolean;
127
132
  status?: string;
@@ -150,17 +155,26 @@ export interface ApplyProactiveAgentResponse {
150
155
  gate?: string;
151
156
  reason?: string;
152
157
  }>;
158
+ /** The gates that actually refused activation (`blockedBy` also lists advisory ones). */
159
+ activationBlockedBy?: Array<{
160
+ gate?: string;
161
+ reason?: string;
162
+ }>;
163
+ /** The first attempt made this one; a retry reported it instead of creating it again. */
164
+ existing?: boolean;
153
165
  }>;
154
166
  initialize?: {
155
167
  goals: Array<{
156
168
  id?: string;
157
169
  ok: boolean;
158
170
  code?: string;
171
+ existing?: boolean;
159
172
  }>;
160
173
  tasks: Array<{
161
174
  id?: string;
162
175
  ok: boolean;
163
176
  code?: string;
177
+ existing?: boolean;
164
178
  }>;
165
179
  jobs: Array<{
166
180
  id?: string;
@@ -5,6 +5,7 @@ exports.statusArgsForStart = statusArgsForStart;
5
5
  exports.parseRuntimeStartStatus = parseRuntimeStartStatus;
6
6
  exports.daemonLoginRecoveryCommand = daemonLoginRecoveryCommand;
7
7
  exports.verifyRuntimeStart = verifyRuntimeStart;
8
+ const auth_core_1 = require("@skrr-ai/auth-core");
8
9
  const keychain_1 = require("./keychain");
9
10
  /** Matches the runtime's EX_CONFIG result for a permanent local configuration failure. */
10
11
  exports.DAEMON_START_REAUTH_EXIT = 78;
@@ -19,10 +20,7 @@ function asString(value) {
19
20
  return typeof value === 'string' && value.length > 0 ? value : null;
20
21
  }
21
22
  function profileFromArgv(argv) {
22
- return ((0, keychain_1.resolveProfileFromArgv)(argv) ??
23
- process.env.OVERSKY_PROFILE ??
24
- (0, keychain_1.getActiveProfile)() ??
25
- keychain_1.DEFAULT_PROFILE);
23
+ return (0, keychain_1.profileForChildProcess)(argv);
26
24
  }
27
25
  function quoteShellArg(value) {
28
26
  return /^[A-Za-z0-9_./:@+=-]+$/.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
@@ -33,8 +31,7 @@ function quoteShellArg(value) {
33
31
  * `status` here and normalized by execRuntimeBinary before spawning.
34
32
  */
35
33
  function statusArgsForStart(argv) {
36
- const requested = (0, keychain_1.resolveProfileFromArgv)(argv);
37
- return requested ? ['status', '--json', '--profile', requested] : ['status', '--json'];
34
+ return ['status', '--json', ...(0, auth_core_1.explicitProfileArgs)(profileFromArgv(argv))];
38
35
  }
39
36
  function parseRuntimeStartStatus(value, fallbackProfile) {
40
37
  const root = asRecord(value);
@@ -32,6 +32,18 @@
32
32
  * child process it is about to spawn, and so tests need no process-wide mutation.
33
33
  */
34
34
  export declare function resolveConfigRoot(env?: NodeJS.ProcessEnv): string;
35
+ /**
36
+ * The variables that relocate the root, newest spelling first. For a message
37
+ * that must tell a person which override to drop; nothing reads the
38
+ * environment through this list.
39
+ */
40
+ export declare const CONFIG_ROOT_ENV_VARS: readonly ["SKRR_CONFIG_DIR", "OVERSKY_CONFIG_DIR"];
41
+ /**
42
+ * `env` with the root pointed at `root`, for a caller that resolves as though the
43
+ * root were elsewhere (a test's temporary home, a child process). Writing the
44
+ * override here keeps the variable's name in its one definition.
45
+ */
46
+ export declare function withConfigRoot(env: NodeJS.ProcessEnv, root: string): NodeJS.ProcessEnv;
35
47
  /** A path under the skrr root, e.g. `configRootPath(env, 'daemon', 'logs')`. */
36
48
  export declare function configRootPath(env: NodeJS.ProcessEnv, ...segments: string[]): string;
37
49
  /**
@@ -28,9 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var configRoot_exports = {};
30
30
  __export(configRoot_exports, {
31
+ CONFIG_ROOT_ENV_VARS: () => CONFIG_ROOT_ENV_VARS,
31
32
  configRootPath: () => configRootPath,
32
33
  isConfigRootOverridden: () => isConfigRootOverridden,
33
- resolveConfigRoot: () => resolveConfigRoot
34
+ resolveConfigRoot: () => resolveConfigRoot,
35
+ withConfigRoot: () => withConfigRoot
34
36
  });
35
37
  module.exports = __toCommonJS(configRoot_exports);
36
38
  var import_node_os = require("node:os");
@@ -39,6 +41,10 @@ function resolveConfigRoot(env = process.env) {
39
41
  const override = (env.SKRR_CONFIG_DIR || env.OVERSKY_CONFIG_DIR)?.trim();
40
42
  return override || import_node_path.default.join((0, import_node_os.homedir)(), ".skrr");
41
43
  }
44
+ const CONFIG_ROOT_ENV_VARS = ["SKRR_CONFIG_DIR", "OVERSKY_CONFIG_DIR"];
45
+ function withConfigRoot(env, root) {
46
+ return { ...env, SKRR_CONFIG_DIR: root };
47
+ }
42
48
  function configRootPath(env, ...segments) {
43
49
  return import_node_path.default.join(resolveConfigRoot(env), ...segments);
44
50
  }
@@ -47,7 +53,9 @@ function isConfigRootOverridden(env = process.env) {
47
53
  }
48
54
  // Annotate the CommonJS export names for ESM import in node:
49
55
  0 && (module.exports = {
56
+ CONFIG_ROOT_ENV_VARS,
50
57
  configRootPath,
51
58
  isConfigRootOverridden,
52
- resolveConfigRoot
59
+ resolveConfigRoot,
60
+ withConfigRoot
53
61
  });
@@ -1,6 +1,7 @@
1
1
  import { type DeviceKeyAlg, type DevicePublicJwk } from './deviceKey.js';
2
2
  import { type DeviceKeyCustody, type DeviceKeyHandle } from './deviceKeyHandle.js';
3
3
  import { type ExecutorStopReceipt, type ExecutorStopReceiptBody } from './executorStopReceipt.js';
4
+ import { type ExecutorStopReceiptBodyV2, type ExecutorStopReceiptV2 } from './executorStopReceiptV2.js';
4
5
  import { type HardwareKeyCapability, type HardwareKeyRecord } from './deviceKeyHardware.js';
5
6
  /**
6
7
  * The `cred_envelope.read.decrypt_failed` hint for the device PRIVATE key
@@ -244,6 +245,13 @@ export declare function signServerRequest(opts: {
244
245
  * server treats as an unproven stop rather than as a failure of the session.
245
246
  */
246
247
  export declare function signExecutorStopReceiptWithDeviceKey(body: ExecutorStopReceiptBody): Promise<ExecutorStopReceipt | null>;
248
+ /**
249
+ * Sign a parent-witnessed stop receipt (OSK-20777, docs/architecture/independent-stop-witness-2026-11-02.md)
250
+ * with the device key. Same contract as `signExecutorStopReceiptWithDeviceKey`: null when device identity is not
251
+ * active or the key cannot sign right now, never throws, and a failed sign emits a telemetry event so the caller
252
+ * sends the response without a receipt, which the server treats as an unproven stop.
253
+ */
254
+ export declare function signExecutorStopReceiptV2WithDeviceKey(body: ExecutorStopReceiptBodyV2): Promise<ExecutorStopReceiptV2 | null>;
247
255
  /** @internal Test seams — file path resolvers. */
248
256
  export declare function __publicKeyPathForTest(profile: string): string;
249
257
  export declare function __privateKeyPathForTest(profile: string): string;
@@ -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 {};