@skrr-ai/cli 0.1.190 → 0.1.192

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 (30) hide show
  1. package/dist/commands/convos/handover.js +8 -3
  2. package/dist/commands/duties/preflight.d.ts +1 -1
  3. package/dist/commands/duties/preflight.js +24 -10
  4. package/dist/commands/harnesses/evaluations/platform-h9-turn.js +13 -3
  5. package/dist/commands/tasks/interrupt.js +12 -1
  6. package/dist/lib/agent-activity.js +7 -2
  7. package/dist/lib/agentic-stream.d.ts +6 -3
  8. package/dist/lib/agentic-stream.js +25 -6
  9. package/dist/lib/balance.js +8 -16
  10. package/dist/lib/computer-files.js +4 -0
  11. package/dist/lib/h9-platform-stream.d.ts +2 -0
  12. package/dist/lib/h9-platform-stream.js +10 -3
  13. package/dist/lib/write-outcome.d.ts +1 -1
  14. package/dist/lib/write-outcome.js +3 -1
  15. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/systemdUserUnit.d.ts +49 -0
  16. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/systemdUserUnit.js +93 -0
  17. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/systemdUserUnit.d.ts +49 -0
  18. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/systemdUserUnit.js +108 -0
  19. package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
  20. package/dist/node_modules/@skrr-ai/data-provider/index.js +7281 -7259
  21. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +2 -2
  22. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +4 -0
  23. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +38 -0
  24. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +77 -12
  25. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +2 -2
  26. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +2 -2
  27. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +38 -0
  28. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +113 -13
  29. package/oclif.manifest.json +4 -4
  30. package/package.json +2 -2
@@ -19,7 +19,7 @@ const web_url_1 = require("../../lib/web-url");
19
19
  * docs/architecture/agent-chat-handover-2026-08-20.md
20
20
  */
21
21
  class ConvosHandover extends base_command_1.BaseCommand {
22
- static description = 'Hand a conversation over to another agent, carrying its context';
22
+ static description = 'Copy saved chat history to a new conversation with another agent. The source chat and any live turn continue independently.';
23
23
  static examples = [
24
24
  '<%= config.bin %> convos handover <id> --to <agentId>',
25
25
  '<%= config.bin %> convos handover <id> --to <agentId> --reason "frontend problem"',
@@ -39,7 +39,7 @@ class ConvosHandover extends base_command_1.BaseCommand {
39
39
  required: true,
40
40
  }),
41
41
  'up-to': core_1.Flags.string({
42
- description: 'Carry history up to this message ID (default: the whole thread)',
42
+ description: 'Carry saved history up to this message ID (default: the latest saved turn)',
43
43
  }),
44
44
  reason: core_1.Flags.string({
45
45
  description: 'Why the work is moving — recorded in provenance and the forward link',
@@ -84,6 +84,10 @@ class ConvosHandover extends base_command_1.BaseCommand {
84
84
  this.handleApiError(err);
85
85
  }
86
86
  const r = result;
87
+ const disposition = {
88
+ handoverMode: 'saved_history_snapshot',
89
+ sourceDisposition: 'continues_independently',
90
+ };
87
91
  if (flags.json) {
88
92
  // The link belongs in BOTH modes. The repo's own rule is to hand over a
89
93
  // clickable link rather than a bare id, and PR #1842 added one — to the
@@ -92,7 +96,7 @@ class ConvosHandover extends base_command_1.BaseCommand {
92
96
  const jsonUrl = r.conversation
93
97
  ? (0, web_url_1.conversationUrlFrom)(this.cliConfig.baseURL, r.conversation)
94
98
  : null;
95
- this.log(JSON.stringify({ ...result, ...(jsonUrl ? { url: jsonUrl } : {}) }, null, 2));
99
+ this.log(JSON.stringify({ ...result, ...disposition, ...(jsonUrl ? { url: jsonUrl } : {}) }, null, 2));
96
100
  return;
97
101
  }
98
102
  const newId = r.conversation?.conversationId ?? r.conversation?._id ?? '?';
@@ -114,6 +118,7 @@ class ConvosHandover extends base_command_1.BaseCommand {
114
118
  this.log(carried === undefined
115
119
  ? '? messages carried'
116
120
  : `${carried} ${carried === 1 ? 'message' : 'messages'} carried`);
121
+ this.log('The source chat and any live turn continue independently.');
117
122
  if (r.forwardLinked === false) {
118
123
  // The handover itself committed; only the breadcrumb is missing. Say so
119
124
  // rather than letting it look like a partial failure.
@@ -42,7 +42,7 @@ export declare function nextRunsLines(report: {
42
42
  * not stop the sensing lane, so refusing activation would be wrong for a Duty that only
43
43
  * observes. The headline carries the caveat instead of contradicting the gate below it.
44
44
  */
45
- export declare function preflightHeadline(report: Pick<DutyPreflightReport, 'verdict' | 'gates'>, persisted: boolean): string;
45
+ export declare function preflightHeadline(report: Pick<DutyPreflightReport, 'verdict' | 'gates' | 'activation'>, persisted: boolean): string;
46
46
  export declare function preflightGateLines(gate: PreflightGate, verbose?: boolean, refusesActivation?: boolean): string[];
47
47
  /**
48
48
  * The `Attention:` footer, and under it the settings behind the verdict (OSK-21120).
@@ -53,8 +53,18 @@ function nextRunsLines(report) {
53
53
  */
54
54
  function preflightHeadline(report, persisted) {
55
55
  const label = persisted ? 'Preflight' : 'Pre-create preview (nothing persisted)';
56
- if (report.verdict === 'blocked')
56
+ if (report.verdict === 'blocked') {
57
+ if (report.activation?.canActivate === true) {
58
+ const status = report.gates?.find((gate) => gate.id === 'status')?.reason;
59
+ if (status === 'status_draft') {
60
+ return `${label}: Activation checks passed. The Duty is still a draft.`;
61
+ }
62
+ if (status === 'status_paused') {
63
+ return `${label}: Activation checks passed. The Duty is paused.`;
64
+ }
65
+ }
57
66
  return `${label}: Run is blocked`;
67
+ }
58
68
  if (report.verdict !== 'ready')
59
69
  return `${label}: A capability or configuration check is still needed`;
60
70
  const reasons = report.gates?.find((gate) => gate.id === 'budget_bounds')?.detail?.reasons;
@@ -192,8 +202,12 @@ function preflightGateLines(gate, verbose = false, refusesActivation = false) {
192
202
  if (!item || typeof item !== 'object' || Array.isArray(item))
193
203
  return [];
194
204
  const { source, event } = item;
195
- return typeof source === 'string' && typeof event === 'string' && source.trim() && event.trim()
196
- ? [`${source}: ${event}`] : [];
205
+ return typeof source === 'string' &&
206
+ typeof event === 'string' &&
207
+ source.trim() &&
208
+ event.trim()
209
+ ? [`${source}: ${event}`]
210
+ : [];
197
211
  });
198
212
  if (events.length)
199
213
  lines.push(` Event types in the derived plan (not proof of delivery): ${events.join(', ')}`);
@@ -234,7 +248,7 @@ function attentionFooterLines(attention, policy, verbose = false) {
234
248
  return lines;
235
249
  }
236
250
  class DutiesPreflight extends base_command_1.BaseCommand {
237
- static description = 'Dry-run a duty: runtime gates, capabilities, attention policy and upcoming runs (runs nothing)';
251
+ static description = 'Dry-run a duty: current runtime gates, activation readiness, capabilities, attention policy and upcoming runs (runs nothing). Text mode exits 1 when current execution is blocked.';
238
252
  static examples = [
239
253
  '<%= config.bin %> duties preflight <duty-id>',
240
254
  '<%= config.bin %> duties preflight <duty-id> --next 5',
@@ -277,8 +291,7 @@ class DutiesPreflight extends base_command_1.BaseCommand {
277
291
  : undefined;
278
292
  report = await duties_1.dutyApi.preflight(args.id, flags.next, eventFixture);
279
293
  try {
280
- policy =
281
- (await duties_1.dutyApi.get(args.id))?.duty?.policy ?? null;
294
+ policy = (await duties_1.dutyApi.get(args.id))?.duty?.policy ?? null;
282
295
  }
283
296
  catch {
284
297
  policy = null;
@@ -309,9 +322,10 @@ class DutiesPreflight extends base_command_1.BaseCommand {
309
322
  }
310
323
  const fixtureContext = report.renderedPlan?.eventContext;
311
324
  const fixtureNote = flags['event-fixture']
312
- ? fixtureContext?.fixtureNote || (fixtureContext?.available
313
- ? 'The fixture appears in preview context; event matching was not verified.'
314
- : 'The server did not confirm that it used the supplied fixture; event matching was not verified.')
325
+ ? fixtureContext?.fixtureNote ||
326
+ (fixtureContext?.available
327
+ ? 'The fixture appears in preview context; event matching was not verified.'
328
+ : 'The server did not confirm that it used the supplied fixture; event matching was not verified.')
315
329
  : undefined;
316
330
  if (flags.json) {
317
331
  this.log(JSON.stringify(fixtureNote ? { ...report, eventFixturePreview: fixtureNote } : report, null, 2));
@@ -332,7 +346,7 @@ class DutiesPreflight extends base_command_1.BaseCommand {
332
346
  if (retired)
333
347
  this.log(retired);
334
348
  }
335
- this.log('\nGates:');
349
+ this.log('\nCurrent-state gates:');
336
350
  for (const gate of report.gates || []) {
337
351
  const refusesActivation = (0, duties_1.gateRefusesActivation)(report.activation, gate);
338
352
  for (const line of preflightGateLines(gate, flags.verbose, refusesActivation))
@@ -173,8 +173,11 @@ class HarnessesEvaluationsPlatformH9Turn extends base_command_1.BaseCommand {
173
173
  ...(0, h9_prior_stream_1.bindH9PriorStreamSettlement)(plan, stream, priorFinance, priorEvidence, grantBinding),
174
174
  });
175
175
  }
176
- const deadline = Math.min(Date.now() + 60_000, Date.parse(grant.expiresAt ?? ''), Date.parse(plan.expiresAt));
177
- if (cancelled.signal.aborted || !Number.isFinite(deadline) || deadline <= Date.now() + 10_000)
176
+ const authorizationDeadline = Math.min(Date.parse(grant.expiresAt ?? ''), Date.parse(plan.expiresAt));
177
+ const acceptanceDeadline = Math.min(Date.now() + h9_platform_stream_1.H9_ACCEPTANCE_WINDOW_MS, authorizationDeadline);
178
+ if (cancelled.signal.aborted ||
179
+ !Number.isFinite(acceptanceDeadline) ||
180
+ acceptanceDeadline <= Date.now() + 10_000)
178
181
  throw new Error('H9_TIMELINE_EXHAUSTED');
179
182
  const recover = receiptPath(label);
180
183
  const identity = {
@@ -197,7 +200,7 @@ class HarnessesEvaluationsPlatformH9Turn extends base_command_1.BaseCommand {
197
200
  credential: this.resolvedCredential,
198
201
  signal: AbortSignal.any([
199
202
  cancelled.signal,
200
- AbortSignal.timeout(Math.max(1, deadline - Date.now())),
203
+ AbortSignal.timeout(Math.max(1, acceptanceDeadline - Date.now())),
201
204
  ]),
202
205
  body: {
203
206
  endpoint: 'agents',
@@ -229,6 +232,7 @@ class HarnessesEvaluationsPlatformH9Turn extends base_command_1.BaseCommand {
229
232
  (0, operator_probe_files_1.durable)(recover, { ...identity, ...admittedIds, state: 'accepted' });
230
233
  (0, h9_platform_stream_1.validateH9Acceptance)(accepted, scope);
231
234
  emit({ type: 'run.accepted', ...admittedIds });
235
+ const deadline = Math.min(Date.now() + h9_platform_stream_1.H9_EXECUTION_WINDOW_MS, authorizationDeadline);
232
236
  const summary = await (0, h9_platform_stream_1.streamH9PlatformTurn)({
233
237
  label,
234
238
  nonce: plan.nonce,
@@ -279,6 +283,12 @@ class HarnessesEvaluationsPlatformH9Turn extends base_command_1.BaseCommand {
279
283
  process.exitCode = 1;
280
284
  }
281
285
  catch (error) {
286
+ // Retain the reviewed probe's typed failure across the operator's child
287
+ // process boundary without forwarding arbitrary provider error text.
288
+ const code = error instanceof Error && /^H9_[A-Z0-9_]+$/.test(error.message)
289
+ ? error.message
290
+ : 'H9_PLATFORM_TURN_FAILED';
291
+ emit({ type: 'h9.turn.failure', code });
282
292
  // A normal start may already have launched. Bind interruption to its actual returned session.
283
293
  if (admittedIds.sessionId) {
284
294
  const client = new agentic_stream_1.AgenticStreamClient({
@@ -45,7 +45,18 @@ class TasksInterrupt extends base_command_1.BaseCommand {
45
45
  return;
46
46
  }
47
47
  const c = result;
48
- this.log(`Stop requested for task ${taskRef} (comment ${c.id ?? c._id ?? '?'}). Child runs and schedules are unchanged; inspect run state to confirm it stopped.`);
48
+ const stop = c.interrupt;
49
+ if (stop?.acknowledged) {
50
+ this.log(`Run ${stop.runId ?? '?'} for task ${taskRef} has ended.`);
51
+ return;
52
+ }
53
+ if (stop?.requested === false) {
54
+ this.log(stop.reason === 'no_current_checkout'
55
+ ? `Task ${taskRef} has no current checkout to stop.`
56
+ : `No stop was requested for task ${taskRef} (${stop.reason ?? 'run unavailable'}). Check the current run before trying again.`);
57
+ return;
58
+ }
59
+ this.log(`Stop requested for ${stop?.runId ? `run ${stop.runId} of ` : ''}task ${taskRef} (comment ${c.id ?? c._id ?? '?'}). Inspect run state to confirm it stopped.`);
49
60
  }
50
61
  }
51
62
  exports.default = TasksInterrupt;
@@ -144,7 +144,10 @@ function renderAgentActivity(response, log) {
144
144
  }
145
145
  // No result from a source that failed or is not implemented is not proof of
146
146
  // no activity. Always print the server's coverage, even on an empty page.
147
- if (items.length) {
147
+ if (response.scope === 'duty') {
148
+ log('Duty trace: activity show --duty <dutyId> (independently authorized).');
149
+ }
150
+ else if (items.length) {
148
151
  log('');
149
152
  log('Trigger Activity detail is unavailable: the original Trigger identity was not recorded.');
150
153
  log('Duty trace: activity show --duty <dutyId> (independently authorized).');
@@ -152,7 +155,9 @@ function renderAgentActivity(response, log) {
152
155
  log('Current chat: messages show <conversationId> <messageId> (independently authorized; Activity identity unverified).');
153
156
  log('Group reply: activity show --group-chat <groupChatId> --message <messageId>.');
154
157
  }
155
- log('Scan your older activity: activity scan-older chat|group-chat|task|trigger.');
158
+ if (response.scope !== 'duty') {
159
+ log('Scan your older activity: activity scan-older chat|group-chat|task|trigger.');
160
+ }
156
161
  log('');
157
162
  const coverage = Array.isArray(response.coverage) ? response.coverage : [];
158
163
  if (!coverage.length)
@@ -187,7 +187,7 @@ export type AgenticStreamOptions = {
187
187
  sessionId: string;
188
188
  /** Caller-owned conversation identity, never taken from a permission payload. */
189
189
  conversationId?: string;
190
- /** Action-required notices when stdout is reserved for a final result. */
190
+ /** Human status notices when stdout is reserved for a final result. */
191
191
  statusOutput?: NodeJS.WritableStream;
192
192
  jsonl?: boolean;
193
193
  /**
@@ -649,6 +649,7 @@ export declare class AgenticStreamClient {
649
649
  /** The cumulative text of the last `text.delta` written as JSON, for `delta`/`replace`. */
650
650
  private lastJsonlText;
651
651
  private idleTimer;
652
+ private idleNoticeShown;
652
653
  /** Releases a connect wait still in flight; `close()` calls it. */
653
654
  private abandonConnectWait;
654
655
  private reconciling;
@@ -692,8 +693,9 @@ export declare class AgenticStreamClient {
692
693
  /**
693
694
  * (Re)start the silence watchdog that asks the durable record what happened.
694
695
  *
695
- * Armed on join and reset by every event, so it only fires when the stream
696
- * has actually gone quiet. A probe that finds the turn still running re-arms
696
+ * Armed on join and reset by answer, tool or interaction progress. A
697
+ * diagnostic frame can keep arriving after the durable result is ready.
698
+ * A probe that finds the turn still running re-arms
697
699
  * rather than giving up — a 200-second tool call is silence, not a failure —
698
700
  * so the cost of being wrong is one cheap read, while the cost of not asking
699
701
  * was an interactive session that never returned.
@@ -866,6 +868,7 @@ export declare class AgenticStreamClient {
866
868
  */
867
869
  private trackWaiting;
868
870
  private stopWaiting;
871
+ private reportIdleWait;
869
872
  /**
870
873
  * A `text.delta` is named for a delta and carries the whole answer so far (`text`), so a long
871
874
  * answer written as JSON lines grows with the square of its length: 207 events for a 2.4 KB
@@ -907,6 +907,7 @@ class AgenticStreamClient {
907
907
  /** The cumulative text of the last `text.delta` written as JSON, for `delta`/`replace`. */
908
908
  lastJsonlText = '';
909
909
  idleTimer = null;
910
+ idleNoticeShown = false;
910
911
  /** Releases a connect wait still in flight; `close()` calls it. */
911
912
  abandonConnectWait = null;
912
913
  reconciling = false;
@@ -997,8 +998,9 @@ class AgenticStreamClient {
997
998
  /**
998
999
  * (Re)start the silence watchdog that asks the durable record what happened.
999
1000
  *
1000
- * Armed on join and reset by every event, so it only fires when the stream
1001
- * has actually gone quiet. A probe that finds the turn still running re-arms
1001
+ * Armed on join and reset by answer, tool or interaction progress. A
1002
+ * diagnostic frame can keep arriving after the durable result is ready.
1003
+ * A probe that finds the turn still running re-arms
1002
1004
  * rather than giving up — a 200-second tool call is silence, not a failure —
1003
1005
  * so the cost of being wrong is one cheap read, while the cost of not asking
1004
1006
  * was an interactive session that never returned.
@@ -1051,6 +1053,8 @@ class AgenticStreamClient {
1051
1053
  if (this.settled)
1052
1054
  return true;
1053
1055
  if (!terminal) {
1056
+ if (reason === 'idle')
1057
+ this.reportIdleWait();
1054
1058
  this.armIdleProbe();
1055
1059
  return false;
1056
1060
  }
@@ -2403,7 +2407,7 @@ class AgenticStreamClient {
2403
2407
  this.stopWaiting();
2404
2408
  return;
2405
2409
  }
2406
- if (event.type !== 'run.started' || this.outputSeen || this.waitingTimer)
2410
+ if (event.type !== 'run.started' || this.outputSeen || this.waitingTimer || this.idleNoticeShown)
2407
2411
  return;
2408
2412
  this.waitingStartedAt = Date.now();
2409
2413
  const schedule = (first) => {
@@ -2427,6 +2431,21 @@ class AgenticStreamClient {
2427
2431
  clearTimeout(this.waitingTimer);
2428
2432
  this.waitingTimer = null;
2429
2433
  }
2434
+ reportIdleWait() {
2435
+ if (this.idleNoticeShown || this.closed || this.options.jsonl ||
2436
+ this.openPermissionPrompts.size || this.openQuestionPrompts.size ||
2437
+ this.browserPermissionRequests.size || this.heldUnboundAsks.size)
2438
+ return;
2439
+ this.idleNoticeShown = true;
2440
+ this.stopWaiting();
2441
+ const url = this.options.conversationId
2442
+ ? (0, web_url_1.conversationUrlFrom)(this.options.baseURL, { conversationId: this.options.conversationId })
2443
+ : null;
2444
+ const output = this.options.quiet
2445
+ ? this.options.statusOutput ?? process.stderr
2446
+ : this.options.output ?? process.stdout;
2447
+ output.write(`\n[run] Still waiting for the run to finish.${url ? ` Open ${url} to follow the chat.` : ''}\n`);
2448
+ }
2430
2449
  /**
2431
2450
  * A `text.delta` is named for a delta and carries the whole answer so far (`text`), so a long
2432
2451
  * answer written as JSON lines grows with the square of its length: 207 events for a 2.4 KB
@@ -2462,9 +2481,9 @@ class AgenticStreamClient {
2462
2481
  this.cancel('Fixed Copilot probe observed an unexpected or cancelled tool');
2463
2482
  this.lastEvent = event;
2464
2483
  this.options.onEvent?.(event);
2465
- // Any event is proof the stream is alive; the watchdog only fires on real
2466
- // silence.
2467
- this.armIdleProbe();
2484
+ if (!this.idleTimer || event.type === 'question.requested' ||
2485
+ (event.type !== 'session.notice' && OUTPUT_EVENT_TYPES.has(event.type)))
2486
+ this.armIdleProbe();
2468
2487
  // A handed-over turn can hold the terminal for minutes, so a person is told
2469
2488
  // why — in every human mode. `--no-stream` reserves stdout for the final
2470
2489
  // result, so there the line goes to stderr (OSK-13543).
@@ -22,6 +22,7 @@ exports.describeCharge = describeCharge;
22
22
  exports.formatCreditsWithUsd = formatCreditsWithUsd;
23
23
  exports.formatTransactionAmount = formatTransactionAmount;
24
24
  exports.formatBalanceTimestamp = formatBalanceTimestamp;
25
+ const data_provider_1 = require("@skrr-ai/data-provider");
25
26
  const api_fetch_1 = require("./api-fetch");
26
27
  const DESCRIBE_CHARGE_RE = /([a-z0-9])([A-Z])/g;
27
28
  const DESCRIBE_CHARGE_RE_2 = /[_-]+/g;
@@ -49,22 +50,13 @@ async function setSkyCodeOverageConsent(enabled) {
49
50
  });
50
51
  }
51
52
  async function getUsageEvents(workspaceId, params = {}) {
52
- const query = new URLSearchParams();
53
- if (params.from)
54
- query.set('from', params.from);
55
- if (params.to)
56
- query.set('to', params.to);
57
- if (params.cursor)
58
- query.set('cursor', params.cursor);
59
- if (params.limit !== undefined)
60
- query.set('limit', String(params.limit));
61
- if (params.view)
62
- query.set('view', params.view);
63
- const base = workspaceId
64
- ? `/api/balance/usage/sky-code/workspace/${encodeURIComponent(workspaceId)}/events`
65
- : '/api/balance/usage/sky-code/events';
66
- const suffix = query.toString();
67
- return (0, api_fetch_1.apiFetch)(suffix ? `${base}?${suffix}` : base);
53
+ // Through data-provider, not an inline path: the web's Charge corrections read the same view for
54
+ // each turn's `gatewayAdjustment` (OSK-24709), so the URL and its query are built in one place
55
+ // (`skyCodeUsageEvents`). `domain-api-parity` follows a `dataService` call to that builder.
56
+ const { view, ...window } = params;
57
+ return view === 'settlements'
58
+ ? data_provider_1.dataService.getHostedUsageSettlements(workspaceId, window)
59
+ : data_provider_1.dataService.getSkyCodeUsageEvents(workspaceId, window);
68
60
  }
69
61
  async function getUsageBreakdown(workspaceId, params = {}) {
70
62
  const query = new URLSearchParams();
@@ -612,6 +612,10 @@ function describeComputerFileRefusal(refusal, ctx) {
612
612
  return `${refusal.message}${tag}${fix}`;
613
613
  }
614
614
  case 'path_withheld': {
615
+ // The server named the roots this machine reaches (`details.roots`, OSK-32126), so its
616
+ // sentence already says what the line below would add.
617
+ if (Array.isArray(refusal.details?.roots))
618
+ return refusal.message;
615
619
  const detail = (key) => typeof refusal.details?.[key] === 'string' ? refusal.details[key] : '';
616
620
  const rule = detail('rule') || detail('reason');
617
621
  return `${refusal.message}${rule ? ` Withheld by: ${rule}.` : ''} On a Dedicated Runtime only repos/ and user-data/ are reachable; the rest of the workspace belongs to the runtime.`;
@@ -2,6 +2,8 @@ import { type AgenticStreamEvent, type EnvelopeReplayPage } from './agentic-stre
2
2
  export declare const H9_TURN_LABELS: readonly ["streaming", "toolCalls", "remember", "interrupt", "recall", "cancel"];
3
3
  export type H9TurnLabel = (typeof H9_TURN_LABELS)[number];
4
4
  export type H9Harness = 'pi' | 'copilot-sdk';
5
+ export declare const H9_EXECUTION_WINDOW_MS = 120000;
6
+ export declare const H9_ACCEPTANCE_WINDOW_MS = 60000;
5
7
  type Row = Record<string, any>;
6
8
  /** Fixed prompts for the two reviewed platform qualification pairs. */
7
9
  export declare function h9FixedPrompt(label: H9TurnLabel, nonce: string, harness?: H9Harness): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.H9_TURN_LABELS = void 0;
3
+ exports.H9_ACCEPTANCE_WINDOW_MS = exports.H9_EXECUTION_WINDOW_MS = exports.H9_TURN_LABELS = void 0;
4
4
  exports.h9FixedPrompt = h9FixedPrompt;
5
5
  exports.validateH9Acceptance = validateH9Acceptance;
6
6
  exports.streamH9PlatformTurn = streamH9PlatformTurn;
@@ -16,6 +16,10 @@ exports.H9_TURN_LABELS = [
16
16
  'recall',
17
17
  'cancel',
18
18
  ];
19
+ // An accepted production turn still needs to clear the worker queue, prepare
20
+ // managed inference and reach the daemon before it can run the fixed case.
21
+ exports.H9_EXECUTION_WINDOW_MS = 120_000;
22
+ exports.H9_ACCEPTANCE_WINDOW_MS = 60_000;
19
23
  const need = (value, code) => {
20
24
  if (!value)
21
25
  throw new Error(code);
@@ -37,7 +41,8 @@ ${(0, copilot_fixed_probe_1.copilotPlatformScratchCommand)(nonce)}`;
37
41
  case 'remember':
38
42
  return `Remember this marker: H9-MARKER-${nonce}. Reply OK only. Do not use tools.`;
39
43
  case 'recall':
40
- return 'What was the marker I asked you to remember? Reply with the marker only. Do not use tools.';
44
+ return ('The earlier lighthouse story request was cancelled. Do not continue it. ' +
45
+ 'Reply with only the exact marker I asked you to remember earlier. Do not use tools.');
41
46
  case 'interrupt':
42
47
  case 'cancel':
43
48
  // A counting prompt can trigger a shell command before the first text delta.
@@ -123,7 +128,9 @@ function recordedH9Response(rows, accepted, outcome) {
123
128
  async function streamH9PlatformTurn(input) {
124
129
  h9FixedPrompt(input.label, input.nonce, input.scope.harness);
125
130
  const now = Date.now();
126
- need(Number.isFinite(input.deadline) && input.deadline > now && input.deadline <= now + 60_000, 'H9_TURN_DEADLINE_INVALID');
131
+ need(Number.isFinite(input.deadline) &&
132
+ input.deadline > now &&
133
+ input.deadline <= now + exports.H9_EXECUTION_WINDOW_MS, 'H9_TURN_DEADLINE_INVALID');
127
134
  const context = validateH9Acceptance(input.accepted, input.scope);
128
135
  // Non-tool turns intentionally have no permission gate. Their first ask cancels the run.
129
136
  const permission = input.label === 'toolCalls'
@@ -28,7 +28,7 @@ export declare function requestPathOf(url: unknown): string | undefined;
28
28
  export declare function requestOfError(err: unknown): FailedRequest;
29
29
  /** Stamp the request on an error that does not carry it yet (a transport error has neither). Returns the same error. */
30
30
  export declare function stampRequest<E>(err: E, method: string, url: unknown): E;
31
- /** A request known to be a write: it names a method, and the method is not a read. */
31
+ /** A request known to be a write. Duty Plan sends input in a POST body and creates no draft. */
32
32
  export declare function isKnownWrite(request: FailedRequest | undefined): request is FailedRequest;
33
33
  /** Does the server keep a replay receipt for this request? False unless the registry says so. */
34
34
  export declare function requestHasReceipt(request: FailedRequest | undefined): boolean;
@@ -69,9 +69,11 @@ function stampRequest(err, method, url) {
69
69
  }
70
70
  return err;
71
71
  }
72
- /** A request known to be a write: it names a method, and the method is not a read. */
72
+ /** A request known to be a write. Duty Plan sends input in a POST body and creates no draft. */
73
73
  function isKnownWrite(request) {
74
74
  const method = request?.method?.trim().toUpperCase();
75
+ if (method === 'POST' && request?.path === '/api/duties/plan')
76
+ return false;
75
77
  return Boolean(method) && !READ_METHODS.includes(method);
76
78
  }
77
79
  /** Does the server keep a replay receipt for this request? False unless the registry says so. */
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The [Service] lines that decide what a stop or restart of the local daemon takes with it, for
3
+ * every systemd USER unit that starts the daemon on a person's Linux machine.
4
+ *
5
+ * Two programs write such a unit, and both render these lines from here:
6
+ *
7
+ * - `skrrd install` / `skrrd setup`: `daemon/src/service/systemd.ts`
8
+ * (`~/.config/systemd/user/<profile unit>.service`);
9
+ * - the desktop app: `desktop/src/main/daemon/service/linux-systemd.ts`
10
+ * (`~/.config/systemd/user/oversky-daemon.service`).
11
+ *
12
+ * They were two copies, and they drifted. `skrrd install` has written `KillMode=process` since
13
+ * OSK-2059; the desktop unit never carried a `KillMode` at all, so it ran with systemd's default
14
+ * `control-group`, and a daemon self-restart (exit 75) or a `systemctl --user restart` killed every
15
+ * process in the unit's cgroup: each detached session wrapper and the harness it was running. That
16
+ * is the class of bug OSK-26592 fixed for the Dedicated Runtime unit and OSK-32266 for the SPACE
17
+ * staging unit. `daemon/src/wrapper/session-cgroup.test.ts` fails when a source file under
18
+ * daemon/src, desktop/src, cli/src or packages writes a unit with a `[Service]` section that does
19
+ * not render these lines, or sets one of their keys itself.
20
+ *
21
+ * What a USER unit deliberately does NOT copy from those two system units: `Delegate=yes`,
22
+ * `DelegateSubgroup=daemon` and the root `ExecStopPost=+` script. That contract works because a
23
+ * wrapper on a managed guest moves itself out of the daemon's delegated leaf
24
+ * (`daemon/src/wrapper/session-cgroup.ts`), which lets the stop-post script end the daemon's other
25
+ * children on every exit while sessions survive. On a person's machine the wrapper never moves
26
+ * (`joinSessionCgroup` returns `not-a-guest`), so a delegated leaf would only change where the
27
+ * daemon runs; `DelegateSubgroup=` needs systemd 254, an older manager ignores it with a warning;
28
+ * and nothing here installs a stop-post script. `KillMode=process` alone keeps a wrapper alive
29
+ * across a restart on every systemd that runs user units, with the reaping trade-off the lines
30
+ * themselves state.
31
+ *
32
+ * The restart policy (`Restart=`, `RestartPreventExitStatus=`, `StartLimit*`) is NOT here: it is
33
+ * each supervisor's own choice. `skrrd install` is the daemon's only supervisor and maps its exit
34
+ * codes (docs/daemon-supervisor-contract.md); the desktop app supervises its daemon as well and
35
+ * restarts it on any failure, as its launchd agent does on macOS.
36
+ *
37
+ * The text is rendered into the unit file verbatim, so it is systemd syntax: `#` comments and
38
+ * `Key=value` lines. Changing it changes every unit both writers render, and each rewrites its unit
39
+ * the next time it installs.
40
+ */
41
+ /** The directives the lines below set, by key. Each appears in them exactly once. */
42
+ export declare const SYSTEMD_USER_UNIT_PROCESS_DIRECTIVES: Readonly<Record<string, string>>;
43
+ /**
44
+ * Keys of the Dedicated Runtime system unit's lifetime contract that a user unit must not set (see
45
+ * above). A user unit that sets one has copied a contract whose other half does not run here.
46
+ */
47
+ export declare const SYSTEMD_USER_UNIT_WITHHELD_DIRECTIVES: readonly string[];
48
+ /** The lines, comments included, for a user unit's `[Service]` section. No trailing newline. */
49
+ export declare const SYSTEMD_USER_UNIT_PROCESS_LINES: string;
@@ -0,0 +1,93 @@
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 systemdUserUnit_exports = {};
20
+ __export(systemdUserUnit_exports, {
21
+ SYSTEMD_USER_UNIT_PROCESS_DIRECTIVES: () => SYSTEMD_USER_UNIT_PROCESS_DIRECTIVES,
22
+ SYSTEMD_USER_UNIT_PROCESS_LINES: () => SYSTEMD_USER_UNIT_PROCESS_LINES,
23
+ SYSTEMD_USER_UNIT_WITHHELD_DIRECTIVES: () => SYSTEMD_USER_UNIT_WITHHELD_DIRECTIVES
24
+ });
25
+ module.exports = __toCommonJS(systemdUserUnit_exports);
26
+ const SYSTEMD_USER_UNIT_PROCESS_DIRECTIVES = Object.freeze({
27
+ TimeoutStopSec: "30",
28
+ KillMode: "process",
29
+ LimitNOFILE: "1048576"
30
+ });
31
+ const SYSTEMD_USER_UNIT_WITHHELD_DIRECTIVES = Object.freeze([
32
+ "Delegate",
33
+ "DelegateSubgroup",
34
+ "ExecStopPost"
35
+ ]);
36
+ const SYSTEMD_USER_UNIT_PROCESS_LINES = [
37
+ "# TimeoutStopSec: systemd default is 90 s. We set 30 s to match the",
38
+ "# 25 s disconnect deadline in index.ts (shutdown()) plus 5 s headroom,",
39
+ "# ensuring the daemon can flush the offline WAL before SIGKILL.",
40
+ "TimeoutStopSec=30",
41
+ "# OSK-2059 \u2014 KillMode=process, NOT the default control-group.",
42
+ "#",
43
+ "# control-group tears down every process in the unit's cgroup when the main",
44
+ "# process exits, which killed the per-session WRAPPER CHILDREN the daemon",
45
+ "# spawns. Those children hold their own session-scoped token and POST envelopes",
46
+ "# straight to the API; wrapper-manifest.ts + wrapper-adoption.ts exist precisely",
47
+ "# so a restarted daemon can adopt them and harvest their response. Under",
48
+ '# control-group that machinery could never fire on Linux: a "systemctl restart",',
49
+ "# or the daemon's own exit-75 supervised restart (self-upgrade, reconnect storm,",
50
+ "# transport switch), took every in-flight agent session with it and the server",
51
+ '# finalized the task "failed" with no explanation.',
52
+ "#",
53
+ "# Detaching at the spawn site is not sufficient here \u2014 it escapes the POSIX",
54
+ "# process group but a cgroup kill reaches the child regardless. Only the unit",
55
+ "# can decide this.",
56
+ "#",
57
+ "# What we give up, stated plainly because the first version of this comment",
58
+ "# claimed a backstop that does not exist: the cgroup was the ONLY reaper of last",
59
+ "# resort for the daemon's other children (bash-tool children, which are spawned",
60
+ "# detached in their own process group, Engine Terminal PTYs, and the browser",
61
+ "# relay), and nothing replaces it on Linux.",
62
+ "#",
63
+ "# - Graceful exit is clean: connection.ts reaps all three explicitly",
64
+ "# (killActiveBashProcesses / killActiveSessions / terminalManager.killAll)",
65
+ "# before the process leaves.",
66
+ "# - Abnormal death is NOT covered. SIGKILL, an OOM kill, or a drain that",
67
+ "# overruns SHUTDOWN_DEADLINE_MS and gets SIGKILLed at TimeoutStopSec above",
68
+ "# leaks those children permanently. pid-tracker.ts does not see them: all",
69
+ "# seven trackPid() call sites are provider CLIs (tools/claude-session.ts and",
70
+ "# backends/{codex,copilot,cursor,acp,pi,openclaw}.ts), so its next-boot",
71
+ "# SIGTERM sweep has nothing to reap for bash, terminals, or the relay.",
72
+ "#",
73
+ "# Note also that wrapper children are NOT excluded from pid-tracker \u2014 each",
74
+ "# wrapper trackPid()s its own provider child, which is exactly why",
75
+ "# connection.ts::reapOrphansExcludingAdopted has to withhold adopted sessions",
76
+ "# from the boot reaper. Closing the gap means tracking the three untracked",
77
+ "# classes too, and that is not free: recoverOrphans() SIGTERMs every live entry",
78
+ "# on EVERY daemon:registered, so a naive trackPid() there would kill healthy",
79
+ "# in-flight children on an ordinary reconnect.",
80
+ "KillMode=process",
81
+ "# OSK-1667 \u2014 raise the open-file-descriptor ceiling for the daemon and every",
82
+ "# wrapper child it spawns. A heavy provider session under concurrency exhausts",
83
+ "# the distro-default soft limit (often 1024) and an EMFILE from libuv's kqueue/",
84
+ "# epoll backend can hard-abort the wrapper. 1048576 matches the systemd",
85
+ "# hard-limit default and is inherited by all children.",
86
+ "LimitNOFILE=1048576"
87
+ ].join("\n");
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ SYSTEMD_USER_UNIT_PROCESS_DIRECTIVES,
91
+ SYSTEMD_USER_UNIT_PROCESS_LINES,
92
+ SYSTEMD_USER_UNIT_WITHHELD_DIRECTIVES
93
+ });