@skrr-ai/cli 0.1.143 → 0.1.145

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 (102) hide show
  1. package/README.md +13 -0
  2. package/dist/commands/agenda/plan.d.ts +7 -0
  3. package/dist/commands/agenda/plan.js +17 -0
  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 +70 -0
  8. package/dist/commands/agent/message/decline.d.ts +17 -0
  9. package/dist/commands/agent/message/decline.js +70 -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/delete.d.ts +45 -0
  13. package/dist/commands/agents/delete.js +139 -2
  14. package/dist/commands/agents/plan-day.d.ts +50 -7
  15. package/dist/commands/agents/plan-day.js +293 -65
  16. package/dist/commands/agents/proactive-audit.d.ts +22 -0
  17. package/dist/commands/agents/proactive-audit.js +86 -0
  18. package/dist/commands/agents/schedule-overview.d.ts +7 -0
  19. package/dist/commands/agents/schedule-overview.js +49 -5
  20. package/dist/commands/agents/schedule-trace.js +42 -21
  21. package/dist/commands/agents/spawn.d.ts +78 -1
  22. package/dist/commands/agents/spawn.js +262 -6
  23. package/dist/commands/agents/todos/list.d.ts +5 -0
  24. package/dist/commands/agents/todos/list.js +19 -5
  25. package/dist/commands/agents/triggers/create.js +1 -1
  26. package/dist/commands/agents/triggers/update.js +1 -1
  27. package/dist/commands/agents/upcoming.d.ts +1 -0
  28. package/dist/commands/agents/upcoming.js +18 -7
  29. package/dist/commands/commitments/create.js +14 -4
  30. package/dist/commands/commitments/preflight.js +14 -3
  31. package/dist/commands/commitments/update.js +1 -1
  32. package/dist/commands/initiatives/worker/deactivate.d.ts +23 -0
  33. package/dist/commands/initiatives/worker/deactivate.js +78 -0
  34. package/dist/commands/login.js +8 -2
  35. package/dist/commands/logout.d.ts +20 -0
  36. package/dist/commands/logout.js +110 -5
  37. package/dist/commands/memory/maintain.js +16 -2
  38. package/dist/commands/spaces/delete.js +6 -1
  39. package/dist/commands/spaces/workflow-templates/insert.js +4 -0
  40. package/dist/commands/spaces/workflows/archive.js +6 -1
  41. package/dist/commands/spaces/workflows/publish.js +3 -1
  42. package/dist/commands/spaces/workflows/run.d.ts +1 -0
  43. package/dist/commands/spaces/workflows/run.js +17 -1
  44. package/dist/commands/spaces/workflows/triggers/create.js +3 -1
  45. package/dist/commands/store/show.js +22 -0
  46. package/dist/commands/tasks/workflow-context.js +3 -1
  47. package/dist/commands/triggers/capabilities.js +17 -1
  48. package/dist/commands/triggers/create.d.ts +2 -0
  49. package/dist/commands/triggers/create.js +23 -7
  50. package/dist/commands/triggers/fire-detail.js +12 -3
  51. package/dist/commands/triggers/list.d.ts +1 -0
  52. package/dist/commands/triggers/list.js +13 -1
  53. package/dist/commands/triggers/preflight.js +18 -0
  54. package/dist/commands/triggers/prune.js +9 -5
  55. package/dist/commands/triggers/update.js +13 -4
  56. package/dist/generated/agent-guides.json +35 -35
  57. package/dist/lib/agent-proactive-baseline.js +7 -1
  58. package/dist/lib/agentic-stream.d.ts +7 -0
  59. package/dist/lib/agentic-stream.js +22 -0
  60. package/dist/lib/commitments.d.ts +16 -9
  61. package/dist/lib/commitments.js +78 -5
  62. package/dist/lib/compasses.js +1 -1
  63. package/dist/lib/daemon-setup.js +9 -3
  64. package/dist/lib/daemonBroker.d.ts +7 -0
  65. package/dist/lib/daemonBroker.js +5 -0
  66. package/dist/lib/daemonHandoff.d.ts +2 -0
  67. package/dist/lib/daemonHandoff.js +10 -1
  68. package/dist/lib/daemonIslandProfile.d.ts +19 -0
  69. package/dist/lib/daemonIslandProfile.js +41 -0
  70. package/dist/lib/dedicated-power.js +10 -3
  71. package/dist/lib/format.d.ts +47 -0
  72. package/dist/lib/format.js +136 -1
  73. package/dist/lib/initiatives-worker.d.ts +25 -0
  74. package/dist/lib/initiatives-worker.js +13 -0
  75. package/dist/lib/login.d.ts +7 -0
  76. package/dist/lib/login.js +5 -0
  77. package/dist/lib/planOutcome.d.ts +51 -0
  78. package/dist/lib/planOutcome.js +88 -0
  79. package/dist/lib/proactive-audit.d.ts +52 -0
  80. package/dist/lib/proactive-audit.js +67 -0
  81. package/dist/lib/proactiveApi.d.ts +71 -0
  82. package/dist/lib/proactiveApi.js +10 -1
  83. package/dist/lib/refresh.d.ts +20 -6
  84. package/dist/lib/refresh.js +27 -9
  85. package/dist/lib/roles.d.ts +1 -1
  86. package/dist/lib/schedule.d.ts +214 -10
  87. package/dist/lib/schedule.js +317 -21
  88. package/dist/lib/triggers.d.ts +139 -3
  89. package/dist/lib/triggers.js +382 -18
  90. package/dist/lib/workflow-node-control.js +8 -0
  91. package/dist/lib/workflow-run-view.js +9 -0
  92. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +1 -1
  93. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +2 -0
  94. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.d.ts +22 -0
  95. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +15 -4
  96. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +1 -1
  97. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +1 -1
  98. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.d.ts +22 -0
  99. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +22 -4
  100. package/dist/node_modules/@skrr-ai/data-provider/index.js +5252 -5211
  101. package/oclif.manifest.json +526 -29
  102. package/package.json +1 -1
@@ -848,6 +848,13 @@ class AgenticStreamClient {
848
848
  */
849
849
  openPermissionPrompts = new Map();
850
850
  browserPermissionRequests = new Set();
851
+ /**
852
+ * Tool calls THIS client refused (the person answered no, or nobody was asked
853
+ * and the CLI declined). A cloud run's `tool:end` for such a call carries no
854
+ * status, so without this it printed `[tool completed]` for a call that never
855
+ * ran (OSK-22553).
856
+ */
857
+ deniedToolUseIds = new Set();
851
858
  permissionGenerations = new Map();
852
859
  permissionEpochs = new Map();
853
860
  /**
@@ -1074,6 +1081,7 @@ class AgenticStreamClient {
1074
1081
  this.stopHandoverTimers();
1075
1082
  this.pendingEnvelopes.clear();
1076
1083
  this.browserPermissionRequests.clear();
1084
+ this.deniedToolUseIds.clear();
1077
1085
  this.permissionGenerations.clear();
1078
1086
  this.permissionEpochs.clear();
1079
1087
  this.abandonConnectWait?.();
@@ -1823,6 +1831,8 @@ class AgenticStreamClient {
1823
1831
  // This CLI makes the decision and nobody is asked, so it says so FIRST. The bound path used
1824
1832
  // to return before any event, and the only lines a person saw were the server's "The
1825
1833
  // response was admitted. Tool execution is not confirmed.", which read like an approval.
1834
+ if (event.toolUseId)
1835
+ this.deniedToolUseIds.add(event.toolUseId);
1826
1836
  this.emit({ ...event, type: 'permission.denied', reason: 'noninteractive_or_not_enabled' });
1827
1837
  if (event.toolUseId) {
1828
1838
  if (await this.sendBoundPermissionDecision(event, false, {
@@ -1891,6 +1901,9 @@ class AgenticStreamClient {
1891
1901
  if (prompt.signal.aborted)
1892
1902
  return;
1893
1903
  const approved = /^y(es)?$/i.test(answer.trim());
1904
+ // Recorded before the decision is sent, so the call's end can never arrive first.
1905
+ if (!approved && event.toolUseId)
1906
+ this.deniedToolUseIds.add(event.toolUseId);
1894
1907
  if (await this.sendBoundPermissionDecision(event, approved, approved ? {} : { reason: 'Declined by CLI user' }))
1895
1908
  return;
1896
1909
  this.socket.emit(approved ? 'permission:approve' : 'permission:deny', {
@@ -2224,6 +2237,15 @@ class AgenticStreamClient {
2224
2237
  const id = typeof event.toolUseId === 'string' ? event.toolUseId : undefined;
2225
2238
  if (!this.firstTimeSeen(String(event.type), id))
2226
2239
  return;
2240
+ // The refusal is this client's own fact, so it outranks an end that names no
2241
+ // status. A status the run did report (`failed`, `cancelled`) is kept.
2242
+ if (event.type === 'tool.completed' &&
2243
+ id &&
2244
+ this.deniedToolUseIds.has(id) &&
2245
+ (event.status === undefined || event.status === null || event.status === 'completed')) {
2246
+ this.emit({ ...event, status: 'denied' });
2247
+ return;
2248
+ }
2227
2249
  this.emit(event);
2228
2250
  }
2229
2251
  /**
@@ -102,6 +102,13 @@ export type CommitmentPreflightReport = {
102
102
  retired?: string[];
103
103
  retiredReason?: string;
104
104
  } & Record<string, unknown>;
105
+ renderedPlan?: {
106
+ eventContext?: {
107
+ available?: boolean;
108
+ fixtureEvaluation?: string;
109
+ fixtureNote?: string;
110
+ };
111
+ };
105
112
  /**
106
113
  * Whether Resume / `create --activate` would be accepted, answered by the server's one activation
107
114
  * rule (`CommitmentActivation`). Absent from an older server. A gate can be advisory for a run and
@@ -424,7 +431,7 @@ export declare const commitmentApi: {
424
431
  reasonCode?: import("@skrr-ai/data-provider").ProposalDiscardReasonCode;
425
432
  }) => Promise<Record<string, unknown>>;
426
433
  executeActionProposal: (id: string, proposalId: string, body?: Record<string, unknown>) => Promise<Record<string, unknown>>;
427
- preflight: (id: string, nextRunCount?: number) => Promise<CommitmentPreflightReport>;
434
+ preflight: (id: string, nextRunCount?: number, eventFixture?: Record<string, unknown>) => Promise<CommitmentPreflightReport>;
428
435
  effectivePolicy: (id: string) => Promise<Record<string, unknown>>;
429
436
  /**
430
437
  * Executor rebind — `POST /api/commitments/:id/executor` (impl contract B4,
@@ -894,6 +901,13 @@ export declare function buildSuccessCriteria(labels: string[], opts?: {
894
901
  * id, and `show` listed none, so a person could not find the id to pass (OSK-15422).
895
902
  */
896
903
  export declare function pendingCadenceRequestLines(commitment: unknown): string[];
904
+ /**
905
+ * What `event+<interval>` promises, in one sentence. A watched-source event is an accelerator: it
906
+ * makes a check happen sooner, and one that is lost on the way is not replayed. The interval is what
907
+ * recovers: at each one the Commitment re-checks current state, which finds what the missed event
908
+ * would have reported. It does not replay the event, and it runs only while the Commitment is running.
909
+ */
910
+ export declare function eventBackstopNote(intervalMs: number | undefined): string;
897
911
  export declare function cadenceLabel(commitment: CommitmentView): string;
898
912
  export declare function renderCommitmentList(commitments: CommitmentView[], log: (line: string) => void): void;
899
913
  /**
@@ -950,14 +964,7 @@ export declare function standstillFixForRead(standstill: {
950
964
  * null rather than printing a guess.
951
965
  */
952
966
  export declare function describeExecutorBlocked(commitment: CommitmentView): string | null;
953
- /**
954
- * The Operation line's wording for a Commitment that is not running because of its lifecycle.
955
- *
956
- * The assessment reports `waiting` with reason `lifecycle_<status>` for a Commitment a person
957
- * paused, and `show` printed that verbatim ("waiting — lifecycle_paused"): the word "waiting" and a
958
- * raw code, indistinguishable from one waiting on a machine or an approval (OSK-15423). Any other
959
- * operation and reason is printed as it always was.
960
- */
967
+ export declare function operationReasonWords(reason: string | null | undefined): string | undefined;
961
968
  export declare function describeOperation(operation: string | null | undefined, reason: string | null | undefined): string;
962
969
  /**
963
970
  * What to do about an operation that is not running, from the operating state's
@@ -22,11 +22,13 @@ exports.describeEvidenceHealth = describeEvidenceHealth;
22
22
  exports.describeIntervalMs = describeIntervalMs;
23
23
  exports.buildSuccessCriteria = buildSuccessCriteria;
24
24
  exports.pendingCadenceRequestLines = pendingCadenceRequestLines;
25
+ exports.eventBackstopNote = eventBackstopNote;
25
26
  exports.cadenceLabel = cadenceLabel;
26
27
  exports.renderCommitmentList = renderCommitmentList;
27
28
  exports.extractStandstillFromCheck = extractStandstillFromCheck;
28
29
  exports.standstillFixForRead = standstillFixForRead;
29
30
  exports.describeExecutorBlocked = describeExecutorBlocked;
31
+ exports.operationReasonWords = operationReasonWords;
30
32
  exports.describeOperation = describeOperation;
31
33
  exports.describeOperationFix = describeOperationFix;
32
34
  exports.describeStoppedBy = describeStoppedBy;
@@ -261,8 +263,9 @@ exports.commitmentApi = {
261
263
  via: 'cli',
262
264
  }),
263
265
  executeActionProposal: (id, proposalId, body = {}) => data_provider_2.request.post(`${base(id)}/action-proposals/${encodeURIComponent(proposalId)}/execute`, body),
264
- preflight: (id, nextRunCount) => data_provider_2.request.post(`${base(id)}/preflight`, {
266
+ preflight: (id, nextRunCount, eventFixture) => data_provider_2.request.post(`${base(id)}/preflight`, {
265
267
  ...(typeof nextRunCount === 'number' ? { nextRunCount } : {}),
268
+ ...(eventFixture !== undefined ? { eventFixture } : {}),
266
269
  }),
267
270
  effectivePolicy: (id) => data_provider_2.request.get(`${base(id)}/effective-policy`),
268
271
  /**
@@ -980,6 +983,16 @@ function baseCadenceLabel(commitment) {
980
983
  }
981
984
  return `${cadence.mode === 'event_plus_interval' ? 'event+' : ''}${describeIntervalMs(cadence.intervalMs)}`;
982
985
  }
986
+ /**
987
+ * What `event+<interval>` promises, in one sentence. A watched-source event is an accelerator: it
988
+ * makes a check happen sooner, and one that is lost on the way is not replayed. The interval is what
989
+ * recovers: at each one the Commitment re-checks current state, which finds what the missed event
990
+ * would have reported. It does not replay the event, and it runs only while the Commitment is running.
991
+ */
992
+ function eventBackstopNote(intervalMs) {
993
+ const every = describeIntervalMs(intervalMs);
994
+ return `Events make a check come sooner; a missed event is not replayed. Every ${every} it re-checks current state instead, which finds what the event would have reported (only while it is running).`;
995
+ }
983
996
  function cadenceLabel(commitment) {
984
997
  const base = baseCadenceLabel(commitment);
985
998
  const window = (0, data_provider_1.describeCommitmentCadenceWindow)(commitment.cadence);
@@ -998,7 +1011,12 @@ function renderCommitmentList(commitments, log) {
998
1011
  status: o.status ?? '-',
999
1012
  outcome: o.assessment?.label ?? 'Unknown',
1000
1013
  evidence: o.assessment?.evidence ?? 'unavailable',
1001
- operation: o.assessment?.operation ?? 'blocked',
1014
+ // `blocked` + `operation_read_unavailable` is "no sweep has recorded an operation for this
1015
+ // contract yet", which `show` then reads live as ready: the bare `blocked` here read as a
1016
+ // refusal and contradicted it (OSK-22586).
1017
+ operation: o.assessment?.operationReason === 'operation_read_unavailable'
1018
+ ? 'not read yet'
1019
+ : (o.assessment?.operation ?? 'blocked'),
1002
1020
  cadence: cadenceLabel(o),
1003
1021
  agent: o.agentId ?? '-',
1004
1022
  })), [
@@ -1014,6 +1032,28 @@ function renderCommitmentList(commitments, log) {
1014
1032
  // 40-character ids and would break on the next longer prefix.
1015
1033
  { key: 'id', header: 'ID', verbatim: true },
1016
1034
  ], log);
1035
+ // The OPERATION column says `blocked` and no more; the reason was only in `--json` and `show`.
1036
+ // Name each reason we can put in words once, with how many rows it covers (OSK-22417).
1037
+ const blockedByReason = new Map();
1038
+ for (const commitment of commitments) {
1039
+ const assessment = commitment.assessment;
1040
+ if (assessment?.operation !== 'blocked' || !operationReasonWords(assessment.operationReason)) {
1041
+ continue;
1042
+ }
1043
+ const reason = assessment.operationReason;
1044
+ blockedByReason.set(reason, (blockedByReason.get(reason) ?? 0) + 1);
1045
+ }
1046
+ const notRead = commitments.filter((commitment) => commitment.assessment?.operationReason ===
1047
+ 'operation_read_unavailable').length;
1048
+ if (notRead) {
1049
+ log('');
1050
+ log(`${notRead} not read yet: no status is recorded for the current contract, which is not a failure. ` +
1051
+ '`skrr commitments show <id>` reads it live.');
1052
+ }
1053
+ for (const [reason, count] of blockedByReason) {
1054
+ log('');
1055
+ log(`${count} blocked (${reason}): ${operationReasonWords(reason)}. \`skrr commitments show <id>\` names the fix.`);
1056
+ }
1017
1057
  }
1018
1058
  /**
1019
1059
  * A `commitment_standstill` policyTrace entry, extracted from the latest
@@ -1099,10 +1139,24 @@ function describeExecutorBlocked(commitment) {
1099
1139
  : reason === 'offline'
1100
1140
  ? 'executor runtime offline'
1101
1141
  : reason === 'waiting_for_machine'
1102
- ? 'executor machine is stopped and will be started for the work'
1142
+ ? describeStoppedMachine(b.wake)
1103
1143
  : reason || 'blocked';
1104
1144
  return `${label}${until ? ` until ${until}` : ''}`;
1105
1145
  }
1146
+ /**
1147
+ * What happens next to a stopped Dedicated machine, said only as far as the
1148
+ * server told us (OSK-22392). `wake: 'owner'` is a `manual` power policy:
1149
+ * automation never starts such a machine, so promising a start sent people to
1150
+ * wait for one that never came. An older server sends no `wake`, and then the
1151
+ * honest sentence makes no promise.
1152
+ */
1153
+ function describeStoppedMachine(wake) {
1154
+ if (wake === 'owner')
1155
+ return 'executor machine is stopped and its power policy is manual, so it waits until you start it';
1156
+ if (wake === 'automatic')
1157
+ return 'executor machine is stopped and will be started for the work';
1158
+ return 'executor machine is stopped';
1159
+ }
1106
1160
  /**
1107
1161
  * The Operation line's wording for a Commitment that is not running because of its lifecycle.
1108
1162
  *
@@ -1111,6 +1165,18 @@ function describeExecutorBlocked(commitment) {
1111
1165
  * raw code, indistinguishable from one waiting on a machine or an approval (OSK-15423). Any other
1112
1166
  * operation and reason is printed as it always was.
1113
1167
  */
1168
+ /**
1169
+ * A blocked-operation reason in words. `blocked — runtime_commitment_contract_unavailable` was all a
1170
+ * list or `show` said about the system loops of an Agent on the cloud Agent Worker, and nothing in it
1171
+ * names what is wrong or what to change (OSK-22417). Only reasons whose meaning is certain are here;
1172
+ * any other reason is printed as the code, as before.
1173
+ */
1174
+ const OPERATION_REASON_WORDS = {
1175
+ runtime_commitment_contract_unavailable: 'its Agent runs on the cloud Agent Worker, which cannot enforce a bounded Commitment; it needs a Hosted Machine or a local harness',
1176
+ };
1177
+ function operationReasonWords(reason) {
1178
+ return typeof reason === 'string' ? OPERATION_REASON_WORDS[reason] : undefined;
1179
+ }
1114
1180
  function describeOperation(operation, reason) {
1115
1181
  // "Cannot tell" travels as `blocked` + this reason (the server's `storedOperation`: no status
1116
1182
  // recorded yet for this version of the contract, or the recorded one expired). A Commitment that
@@ -1119,8 +1185,10 @@ function describeOperation(operation, reason) {
1119
1185
  if (reason === 'operation_read_unavailable')
1120
1186
  return 'not read yet — no status is recorded for the current contract, which is not a failure; `skrr commitments show` reads it live';
1121
1187
  const lifecycle = typeof reason === 'string' ? /^lifecycle_([a-z_]+)$/.exec(reason) : null;
1122
- if (!lifecycle)
1123
- return `${operation ?? 'blocked'}${reason ? ` — ${reason}` : ''}`;
1188
+ if (!lifecycle) {
1189
+ const words = operationReasonWords(reason);
1190
+ return `${operation ?? 'blocked'}${reason ? ` — ${reason}${words ? `: ${words}` : ''}` : ''}`;
1191
+ }
1124
1192
  const status = lifecycle[1];
1125
1193
  const meaning = {
1126
1194
  paused: 'paused, it will not run until it is resumed',
@@ -1374,6 +1442,11 @@ scheduleIssues) {
1374
1442
  if (commitment.target?.deadlineAt)
1375
1443
  log(`Deadline: ${commitment.target.deadlineAt}`);
1376
1444
  log(`Cadence: ${cadenceLabel(commitment)}`);
1445
+ // `event+1d` abbreviates a guarantee: events make a check come sooner, they are not a delivery
1446
+ // receipt. Say what the interval does and does not recover (OSK-21747).
1447
+ if (commitment.cadence?.mode === 'event_plus_interval') {
1448
+ log(` ${eventBackstopNote(commitment.cadence.intervalMs)}`);
1449
+ }
1377
1450
  for (const line of scheduleIssueLines(scheduleIssues))
1378
1451
  log(line);
1379
1452
  log(`Delivery: ${(0, commitment_product_1.deliveryLabel)(commitment.delivery?.mode)}${commitment.delivery?.repo ? ` · ${commitment.delivery.repo}` : ''}${commitment.delivery?.baseBranch ? ` → ${commitment.delivery.baseBranch}` : ''}`);
@@ -279,7 +279,7 @@ function renderEffectivePolicy(policy, log) {
279
279
  // The Gateway reads one Compass per agent for the agent's own messages; this one may not be it.
280
280
  const gateway = record(policy.messageGateway);
281
281
  if (gateway.readsThisCompass === false && typeof gateway.canonicalCompassId === 'string') {
282
- log(`Agent messages: the Gateway reads ${gateway.canonicalCompassId} for this agent, not this Compass, so its communication defaults do not change those messages. They apply to Commitments bound to it.`);
282
+ log(`Agent messages: the Gateway reads ${gateway.canonicalCompassId} for this agent's communication defaults. From this Compass only a stricter mode counts for those messages (the strictest mode across active Compasses governs); its other defaults apply to Commitments bound to it.`);
283
283
  }
284
284
  const autonomy = record(policy.autonomy);
285
285
  log('Autonomy');
@@ -38,6 +38,7 @@ const prompt_1 = require("./prompt");
38
38
  const daemon_command_hint_1 = require("./daemon-command-hint");
39
39
  const daemon_binding_1 = require("./daemon-binding");
40
40
  const daemon_handoff_opt_out_1 = require("./daemon-handoff-opt-out");
41
+ const keychain_1 = require("./keychain");
41
42
  const exec_runtime_binary_1 = require("./exec-runtime-binary");
42
43
  const daemon_installer_1 = require("./daemon-installer");
43
44
  const ssh_detect_1 = require("./ssh-detect");
@@ -91,12 +92,17 @@ async function offerDaemonSetup(opts = {}) {
91
92
  // step. Say which command does it instead.
92
93
  return {
93
94
  status: 'skipped',
94
- detail: 'no terminal to ask — run `skrr daemon install` to set this machine up',
95
+ detail: `no terminal to ask — run \`${(0, daemon_command_hint_1.daemonCommandHint)('install')}\` to set this machine up`,
95
96
  };
96
97
  }
97
98
  const confirmImpl = opts.confirmImpl ?? prompt_1.confirm;
98
99
  log('');
99
- log(` This computer has no ${data_provider_1.BRAND.displayName} background service. It is what lets your agents work here —`);
100
+ // A named profile is a second service on a computer that may already run one,
101
+ // so "this computer has none" would be false there (OSK-22309).
102
+ const profile = (0, keychain_1.getActiveProfile)();
103
+ log(profile && profile !== keychain_1.DEFAULT_PROFILE
104
+ ? ` Profile "${profile}" has no ${data_provider_1.BRAND.displayName} background service on this computer yet. It is what lets your agents work here —`
105
+ : ` This computer has no ${data_provider_1.BRAND.displayName} background service. It is what lets your agents work here —`);
100
106
  log(' running commands, editing files, and driving a browser on this machine.');
101
107
  // Disclose both the safe new-profile default and upgrade compatibility at
102
108
  // the point where the person consents to a persistent local service.
@@ -113,7 +119,7 @@ async function offerDaemonSetup(opts = {}) {
113
119
  if (!yes) {
114
120
  return {
115
121
  status: 'declined',
116
- detail: 'run `skrr daemon install` when you want it',
122
+ detail: `run \`${(0, daemon_command_hint_1.daemonCommandHint)('install')}\` when you want it`,
117
123
  };
118
124
  }
119
125
  // Fetch the signed binary only when there is none. When the binary is already
@@ -89,6 +89,13 @@ export interface DaemonBrokerResult {
89
89
  * the file.
90
90
  */
91
91
  storedIn?: Exclude<AuthBackend, 'none'>;
92
+ /**
93
+ * The descriptor file of the daemon that minted this credential. Which
94
+ * profile's daemon that was is read from it (`daemonIslandProfile.ts`):
95
+ * the broker borrows whichever daemon is running, so it is not always the
96
+ * profile being signed in (OSK-22309).
97
+ */
98
+ descriptorPath?: string;
92
99
  /**
93
100
  * False on the legacy durable-mint shape so `outcome.brokered === true`
94
101
  * narrows the outcome union. A durable mint is never brokered.
@@ -538,6 +538,11 @@ async function attemptDaemonBrokerLoginOnce(opts) {
538
538
  let outcome = null;
539
539
  for (const { bootstrap, sourcePath } of usable) {
540
540
  outcome = await brokerThrough(bootstrap, opts, sourcePath);
541
+ if (outcome.ok && !outcome.descriptorPath) {
542
+ // Which daemon minted it: the caller decides from this whether that daemon
543
+ // is the one the login is for (OSK-22309).
544
+ outcome = { ...outcome, descriptorPath: sourcePath };
545
+ }
541
546
  if (!outcome.ok) {
542
547
  // Say which daemon answered: a guest's refusal has a different repair.
543
548
  outcome = {
@@ -47,6 +47,8 @@ export interface DaemonHandoffOutcome {
47
47
  }
48
48
  export declare function handOffToLocalDaemon(env?: NodeJS.ProcessEnv, opts?: {
49
49
  loginFlow?: string;
50
+ /** With `loginFlow: 'daemon-broker'`: whose daemon brokered it (`CliLoginResult.brokerProfile`). */
51
+ brokerProfile?: string;
50
52
  }): Promise<DaemonHandoffOutcome>;
51
53
  /**
52
54
  * Ask the installed daemon which machine identity it will register `profile`
@@ -197,7 +197,16 @@ async function handOffToLocalDaemon(env = process.env, opts = {}) {
197
197
  // authenticated with, and restarts the process — killing whatever sessions it
198
198
  // was running. `skrr login` on a healthy machine is the path where the least
199
199
  // should happen, and it was the path where the most did.
200
- if (opts.loginFlow === 'daemon-broker') {
200
+ //
201
+ // Only when the daemon that brokered it is THIS profile's (OSK-22309). The
202
+ // broker borrows whichever daemon is running, so `skrr login --profile work`
203
+ // on a computer whose default daemon is up is brokered by `default`: that
204
+ // proves nothing about `work`'s daemon, which usually does not exist yet.
205
+ // Skipping it there meant the command the web gives for "add another profile"
206
+ // signed the CLI in and never set the profile's daemon up. A broker whose
207
+ // descriptor names no profile (a guest's) keeps the old answer.
208
+ if (opts.loginFlow === 'daemon-broker' &&
209
+ (!opts.brokerProfile || opts.brokerProfile === (0, keychain_1.profileForChildProcess)())) {
201
210
  return {
202
211
  status: 'skipped',
203
212
  reason: 'brokered',
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The daemon profile an island descriptor belongs to, read from its path, or
3
+ * null when the path names none (a Dedicated Runtime or Hosted Machine hand-off
4
+ * descriptor, which serves the guest's one daemon).
5
+ *
6
+ * The paths are the ones `resolveBootstrapCandidatePaths` reads:
7
+ * `daemon-island.<profile>.json` on macOS (both config directories),
8
+ * `~/.skrr/profiles/<profile>/daemon-island.json` elsewhere, and
9
+ * `~/.skrr/daemon-island.json` from before profiles had directories.
10
+ *
11
+ * Why it matters: the login broker asks the default profile's candidate list,
12
+ * which falls through to ANY running profile, so a brokered
13
+ * `skrr login --profile work` is usually brokered by `default`. That proves
14
+ * `default`'s daemon is signed in and says nothing about `work`'s (OSK-22309).
15
+ *
16
+ * Its own module, not part of `daemonBroker.ts`, because thirty specs replace
17
+ * that module with a stub and `login.ts` reads this on every brokered login.
18
+ */
19
+ export declare function bootstrapDescriptorProfile(descriptorPath: string | undefined): string | null;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.bootstrapDescriptorProfile = bootstrapDescriptorProfile;
7
+ const node_os_1 = __importDefault(require("node:os"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ /**
10
+ * The daemon profile an island descriptor belongs to, read from its path, or
11
+ * null when the path names none (a Dedicated Runtime or Hosted Machine hand-off
12
+ * descriptor, which serves the guest's one daemon).
13
+ *
14
+ * The paths are the ones `resolveBootstrapCandidatePaths` reads:
15
+ * `daemon-island.<profile>.json` on macOS (both config directories),
16
+ * `~/.skrr/profiles/<profile>/daemon-island.json` elsewhere, and
17
+ * `~/.skrr/daemon-island.json` from before profiles had directories.
18
+ *
19
+ * Why it matters: the login broker asks the default profile's candidate list,
20
+ * which falls through to ANY running profile, so a brokered
21
+ * `skrr login --profile work` is usually brokered by `default`. That proves
22
+ * `default`'s daemon is signed in and says nothing about `work`'s (OSK-22309).
23
+ *
24
+ * Its own module, not part of `daemonBroker.ts`, because thirty specs replace
25
+ * that module with a stub and `login.ts` reads this on every brokered login.
26
+ */
27
+ function bootstrapDescriptorProfile(descriptorPath) {
28
+ if (!descriptorPath)
29
+ return null;
30
+ const base = node_path_1.default.basename(descriptorPath);
31
+ const named = /^daemon-island\.([^.]+)\.json$/.exec(base);
32
+ if (named)
33
+ return named[1];
34
+ if (base !== 'daemon-island.json')
35
+ return null;
36
+ const dir = node_path_1.default.dirname(descriptorPath);
37
+ if (node_path_1.default.basename(node_path_1.default.dirname(dir)) === 'profiles')
38
+ return node_path_1.default.basename(dir);
39
+ const legacy = node_path_1.default.join(node_os_1.default.homedir(), '.skrr', 'daemon-island.json');
40
+ return node_path_1.default.resolve(descriptorPath) === node_path_1.default.resolve(legacy) ? 'default' : null;
41
+ }
@@ -312,7 +312,7 @@ function describePowerSummary(summary, when = {}) {
312
312
  if (power.keepAwakeUntil)
313
313
  lines.push(`Keep awake until: ${(0, format_1.formatWhen)(power.keepAwakeUntil, when)}`);
314
314
  if (power.budgetHoursPerMonth !== null)
315
- lines.push(`Budget: ${power.budgetHoursPerMonth} hours per month`);
315
+ lines.push(`Budget: ${power.budgetHoursPerMonth} ${power.budgetHoursPerMonth === 1 ? 'hour' : 'hours'} per month`);
316
316
  if (summary.decision) {
317
317
  const d = describePowerDecisionLines(summary.decision);
318
318
  lines.push(`Decision: ${d.headline}`);
@@ -344,8 +344,15 @@ function describePowerSummary(summary, when = {}) {
344
344
  lines.push(` - ${formatHolder(h, when)}`);
345
345
  }
346
346
  lines.push(`This month: ${formatUsage(summary.usage)}`);
347
- lines.push(`Next expected wake: ${(summary.nextExpectedWake ? (0, format_1.formatWhen)(summary.nextExpectedWake, when) : null) ??
348
- (summary.nextExpectedWakeUnavailable ? 'unavailable' : 'none scheduled')}`);
347
+ if (power.policy === 'manual' && summary.nextExpectedWake) {
348
+ // A manual machine is started only by its owner, so a scheduled firing is work that will wait for
349
+ // that start, not a wake (OSK-22556). The value is the same one; only its label changes.
350
+ lines.push(`Next scheduled work: ${(0, format_1.formatWhen)(summary.nextExpectedWake, when)} (waits until you start the machine)`);
351
+ }
352
+ else {
353
+ lines.push(`Next expected wake: ${(summary.nextExpectedWake ? (0, format_1.formatWhen)(summary.nextExpectedWake, when) : null) ??
354
+ (summary.nextExpectedWakeUnavailable ? 'unavailable' : 'none scheduled')}`);
355
+ }
349
356
  lines.push(`Last wake: ${summary.lastWake
350
357
  ? `${summary.lastWake.at ? (0, format_1.formatWhen)(summary.lastWake.at, when) : 'unknown time'}${summary.lastWake.source ? ` (${summary.lastWake.source})` : ''}`
351
358
  : 'none'}`);
@@ -22,6 +22,14 @@ export declare function pad(s: string, width: number): string;
22
22
  * surrogate pair is never split down the middle into two replacement glyphs.
23
23
  */
24
24
  export declare function truncate(s: string, max: number): string;
25
+ /**
26
+ * Truncate in the MIDDLE, keeping both ends: `[df-261102-trig…tion-tc01] text-out`.
27
+ *
28
+ * For a cell whose two ends both carry meaning. A trigger label starts with a run tag and the tag's
29
+ * last characters are what tell two runs apart, so cutting the tail (`truncate`) kept the part they
30
+ * share and dropped the part that differs (OSK-22493).
31
+ */
32
+ export declare function truncateMiddle(s: string, max: number): string;
25
33
  /**
26
34
  * `truncate`, but never in the middle of a word.
27
35
  *
@@ -77,6 +85,8 @@ export type TableColumn<T> = {
77
85
  maxWidth?: number;
78
86
  /** Never clip: the value has to survive intact to be useful. */
79
87
  verbatim?: boolean;
88
+ /** Where a clipped cell loses its text: the end (default) or the middle, keeping both ends. */
89
+ truncate?: 'end' | 'middle';
80
90
  };
81
91
  export declare function renderTable<T extends Record<string, string>>(rows: T[], columns: Array<TableColumn<T>>, log: (line: string) => void): void;
82
92
  /**
@@ -109,6 +119,43 @@ export declare function localTime(value: unknown): string;
109
119
  * rather than print an empty parenthesis.
110
120
  */
111
121
  export declare function localZone(at?: Date): string;
122
+ /**
123
+ * `PST` / `PDT` / `GMT+8` — the short name of `timeZone` at `at`, or an empty
124
+ * string when the runtime cannot name it. Used to label a time that is shown in
125
+ * a zone the reader did not necessarily choose (a plan's own zone).
126
+ */
127
+ export declare function zoneAbbreviation(timeZone: string, at?: Date): string;
128
+ /**
129
+ * One instant rendered in an EXPLICIT IANA zone, with the zone named:
130
+ * `2026-11-02 17:13:40 PST`.
131
+ *
132
+ * `localTime` renders in the machine's zone. A Smart Schedule plan has its own
133
+ * zone, and the instants a plan prints (expiry at the plan day's local midnight,
134
+ * the suggested next run, a trace row) are only readable in THAT zone: printed as
135
+ * raw UTC, `Expires: 2026-11-03T08:00:00.000Z` makes the reader work out that
136
+ * 08:00Z is local midnight, and a trace row at 01:13 UTC reads as an event from
137
+ * tomorrow under a header naming today (OSK-22397). `--json` keeps the raw UTC
138
+ * instant; this is for text only. Never throws: an unparseable value comes back
139
+ * as given, and an unknown zone falls back to UTC, labelled.
140
+ */
141
+ export declare function zonedTime(value: unknown, timeZone: string, options?: {
142
+ seconds?: boolean;
143
+ }): string;
144
+ /**
145
+ * Rewrite the full ISO-8601 instants inside a sentence into `timeZone`, named:
146
+ * `Next planning run scheduled for 2026-11-04T08:00:00.000Z` becomes
147
+ * `... for 2026-11-04 00:00 PST`.
148
+ *
149
+ * The server writes its own summary strings, and some of them embed an instant
150
+ * (a scheduled run, a prompt that quotes a time). Printed as they arrive, the
151
+ * rest of the output is in the plan's zone while these stay in UTC, so the same
152
+ * moment reads two ways on one screen (OSK-22588). This touches ONLY a complete
153
+ * instant with an explicit zone, never a bare date, a time of day or an ID that
154
+ * merely looks like one, so it cannot reword a sentence it does not understand.
155
+ * Seconds are shown only when the instant has them. Text only: `--json` keeps
156
+ * the server's string untouched. Never throws.
157
+ */
158
+ export declare function localizeIsoInstants(text: string, timeZone: string): string;
112
159
  export type WhenOptions = {
113
160
  /** The reference instant; injectable so output is deterministic in tests. */
114
161
  now?: Date;