@skrr-ai/cli 0.1.142 → 0.1.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +8 -0
  2. package/dist/base-command.d.ts +4 -2
  3. package/dist/base-command.js +46 -13
  4. package/dist/commands/agenda/trigger/create.js +4 -2
  5. package/dist/commands/agenda/trigger/list.js +7 -7
  6. package/dist/commands/agent/message/approve.d.ts +17 -0
  7. package/dist/commands/agent/message/approve.js +72 -0
  8. package/dist/commands/agent/message/decline.d.ts +17 -0
  9. package/dist/commands/agent/message/decline.js +72 -0
  10. package/dist/commands/agent/message/pending.d.ts +18 -0
  11. package/dist/commands/agent/message/pending.js +79 -0
  12. package/dist/commands/agents/always-on/disable.js +9 -1
  13. package/dist/commands/agents/always-on/enable.js +9 -1
  14. package/dist/commands/agents/always-on/status.js +14 -1
  15. package/dist/commands/agents/create.js +10 -1
  16. package/dist/commands/agents/delete.d.ts +51 -0
  17. package/dist/commands/agents/delete.js +163 -2
  18. package/dist/commands/agents/intuitions/list.js +1 -1
  19. package/dist/commands/agents/plan-day.d.ts +39 -7
  20. package/dist/commands/agents/plan-day.js +254 -65
  21. package/dist/commands/agents/proactive-audit.d.ts +22 -0
  22. package/dist/commands/agents/proactive-audit.js +86 -0
  23. package/dist/commands/agents/schedule-overview.d.ts +7 -0
  24. package/dist/commands/agents/schedule-overview.js +43 -5
  25. package/dist/commands/agents/schedule-trace.js +30 -19
  26. package/dist/commands/agents/spawn.d.ts +51 -0
  27. package/dist/commands/agents/spawn.js +212 -9
  28. package/dist/commands/agents/todos/cancel.js +3 -0
  29. package/dist/commands/agents/todos/edit.js +1 -1
  30. package/dist/commands/agents/todos/list.d.ts +5 -0
  31. package/dist/commands/agents/todos/list.js +19 -5
  32. package/dist/commands/agents/triggers/create.js +1 -1
  33. package/dist/commands/agents/triggers/policy.js +7 -0
  34. package/dist/commands/agents/triggers/update.js +1 -1
  35. package/dist/commands/commitments/create.js +13 -3
  36. package/dist/commands/commitments/preflight.js +31 -5
  37. package/dist/commands/daemon/index.js +1 -0
  38. package/dist/commands/daemon/logs.d.ts +8 -1
  39. package/dist/commands/daemon/logs.js +32 -22
  40. package/dist/commands/daemon/profile.d.ts +15 -0
  41. package/dist/commands/daemon/profile.js +51 -0
  42. package/dist/commands/goals/briefing/status.js +1 -1
  43. package/dist/commands/initiatives/worker/deactivate.d.ts +23 -0
  44. package/dist/commands/initiatives/worker/deactivate.js +78 -0
  45. package/dist/commands/login.js +8 -2
  46. package/dist/commands/logout.d.ts +20 -0
  47. package/dist/commands/logout.js +110 -5
  48. package/dist/commands/machines/profiles/disconnect.d.ts +23 -0
  49. package/dist/commands/machines/profiles/disconnect.js +102 -0
  50. package/dist/commands/machines/profiles/index.d.ts +15 -0
  51. package/dist/commands/machines/profiles/index.js +33 -0
  52. package/dist/commands/machines/profiles/label.d.ts +24 -0
  53. package/dist/commands/machines/profiles/label.js +85 -0
  54. package/dist/commands/machines/profiles/list.d.ts +16 -0
  55. package/dist/commands/machines/profiles/list.js +87 -0
  56. package/dist/commands/memory/maintain.js +16 -2
  57. package/dist/commands/profiles/list.js +17 -2
  58. package/dist/commands/spaces/delete.js +6 -1
  59. package/dist/commands/spaces/workflows/archive.js +6 -1
  60. package/dist/commands/spaces/workflows/publish.js +3 -1
  61. package/dist/commands/spaces/workflows/run.d.ts +1 -0
  62. package/dist/commands/spaces/workflows/run.js +17 -1
  63. package/dist/commands/spaces/workflows/triggers/create.js +3 -1
  64. package/dist/commands/tasks/workflow-context.js +3 -1
  65. package/dist/commands/triggers/authorization.js +1 -1
  66. package/dist/commands/triggers/capabilities.js +17 -1
  67. package/dist/commands/triggers/create.d.ts +2 -0
  68. package/dist/commands/triggers/create.js +23 -7
  69. package/dist/commands/triggers/fire-detail.js +12 -3
  70. package/dist/commands/triggers/list.d.ts +1 -0
  71. package/dist/commands/triggers/list.js +13 -1
  72. package/dist/commands/triggers/preflight.js +18 -0
  73. package/dist/commands/triggers/prune.js +9 -5
  74. package/dist/commands/triggers/update.js +13 -4
  75. package/dist/generated/agent-guides.json +35 -35
  76. package/dist/lib/agent-guides.js +1 -1
  77. package/dist/lib/agent-proactive-baseline.d.ts +6 -0
  78. package/dist/lib/agent-proactive-baseline.js +32 -3
  79. package/dist/lib/always-on-command-result.d.ts +18 -0
  80. package/dist/lib/always-on-command-result.js +52 -0
  81. package/dist/lib/always-on-runtime.d.ts +31 -0
  82. package/dist/lib/always-on-runtime.js +39 -0
  83. package/dist/lib/auth-diagnostics.d.ts +10 -1
  84. package/dist/lib/auth-diagnostics.js +16 -8
  85. package/dist/lib/commitments.d.ts +16 -9
  86. package/dist/lib/commitments.js +65 -4
  87. package/dist/lib/compasses.js +5 -0
  88. package/dist/lib/daemon-binding.js +6 -3
  89. package/dist/lib/daemon-command-hint.d.ts +10 -5
  90. package/dist/lib/daemon-command-hint.js +11 -6
  91. package/dist/lib/daemon-setup.js +9 -3
  92. package/dist/lib/daemonBroker.d.ts +7 -0
  93. package/dist/lib/daemonBroker.js +5 -0
  94. package/dist/lib/daemonHandoff.d.ts +2 -0
  95. package/dist/lib/daemonHandoff.js +16 -3
  96. package/dist/lib/daemonIslandProfile.d.ts +19 -0
  97. package/dist/lib/daemonIslandProfile.js +41 -0
  98. package/dist/lib/drain-stdio.d.ts +22 -0
  99. package/dist/lib/drain-stdio.js +46 -0
  100. package/dist/lib/format.d.ts +32 -0
  101. package/dist/lib/format.js +105 -1
  102. package/dist/lib/initiatives-worker.d.ts +25 -0
  103. package/dist/lib/initiatives-worker.js +13 -0
  104. package/dist/lib/keychain.d.ts +22 -1
  105. package/dist/lib/keychain.js +40 -1
  106. package/dist/lib/local-daemon-readiness.js +4 -6
  107. package/dist/lib/local-skills.js +4 -1
  108. package/dist/lib/login.d.ts +7 -0
  109. package/dist/lib/login.js +5 -0
  110. package/dist/lib/machines.d.ts +68 -0
  111. package/dist/lib/machines.js +67 -0
  112. package/dist/lib/proactive-audit.d.ts +52 -0
  113. package/dist/lib/proactive-audit.js +67 -0
  114. package/dist/lib/proactiveApi.d.ts +23 -0
  115. package/dist/lib/refresh.d.ts +20 -6
  116. package/dist/lib/refresh.js +27 -9
  117. package/dist/lib/roles.d.ts +1 -1
  118. package/dist/lib/runtime-start-verification.js +3 -6
  119. package/dist/lib/schedule.d.ts +189 -9
  120. package/dist/lib/schedule.js +283 -22
  121. package/dist/lib/triggers.d.ts +134 -3
  122. package/dist/lib/triggers.js +370 -17
  123. package/dist/lib/workflow-node-control.js +8 -0
  124. package/dist/lib/workflow-run-view.js +9 -0
  125. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.d.ts +12 -0
  126. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.js +10 -2
  127. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.d.ts +8 -0
  128. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +22 -0
  129. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.d.ts +133 -0
  130. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.js +180 -0
  131. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +5 -3
  132. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +50 -0
  133. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.d.ts +137 -0
  134. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.js +328 -0
  135. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.d.ts +63 -0
  136. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.js +174 -0
  137. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.d.ts +22 -0
  138. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +15 -4
  139. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.d.ts +12 -0
  140. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.js +14 -0
  141. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.d.ts +8 -0
  142. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +27 -0
  143. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.d.ts +133 -0
  144. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.js +183 -0
  145. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +5 -3
  146. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +11 -3
  147. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.d.ts +137 -0
  148. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.js +333 -0
  149. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.d.ts +63 -0
  150. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.js +212 -0
  151. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.d.ts +22 -0
  152. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +22 -4
  153. package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
  154. package/dist/node_modules/@skrr-ai/data-provider/index.js +7446 -7378
  155. package/oclif.manifest.json +844 -47
  156. package/package.json +1 -1
@@ -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);
@@ -1014,6 +1027,21 @@ function renderCommitmentList(commitments, log) {
1014
1027
  // 40-character ids and would break on the next longer prefix.
1015
1028
  { key: 'id', header: 'ID', verbatim: true },
1016
1029
  ], log);
1030
+ // The OPERATION column says `blocked` and no more; the reason was only in `--json` and `show`.
1031
+ // Name each reason we can put in words once, with how many rows it covers (OSK-22417).
1032
+ const blockedByReason = new Map();
1033
+ for (const commitment of commitments) {
1034
+ const assessment = commitment.assessment;
1035
+ if (assessment?.operation !== 'blocked' || !operationReasonWords(assessment.operationReason)) {
1036
+ continue;
1037
+ }
1038
+ const reason = assessment.operationReason;
1039
+ blockedByReason.set(reason, (blockedByReason.get(reason) ?? 0) + 1);
1040
+ }
1041
+ for (const [reason, count] of blockedByReason) {
1042
+ log('');
1043
+ log(`${count} blocked (${reason}): ${operationReasonWords(reason)}. \`skrr commitments show <id>\` names the fix.`);
1044
+ }
1017
1045
  }
1018
1046
  /**
1019
1047
  * A `commitment_standstill` policyTrace entry, extracted from the latest
@@ -1099,10 +1127,24 @@ function describeExecutorBlocked(commitment) {
1099
1127
  : reason === 'offline'
1100
1128
  ? 'executor runtime offline'
1101
1129
  : reason === 'waiting_for_machine'
1102
- ? 'executor machine is stopped and will be started for the work'
1130
+ ? describeStoppedMachine(b.wake)
1103
1131
  : reason || 'blocked';
1104
1132
  return `${label}${until ? ` until ${until}` : ''}`;
1105
1133
  }
1134
+ /**
1135
+ * What happens next to a stopped Dedicated machine, said only as far as the
1136
+ * server told us (OSK-22392). `wake: 'owner'` is a `manual` power policy:
1137
+ * automation never starts such a machine, so promising a start sent people to
1138
+ * wait for one that never came. An older server sends no `wake`, and then the
1139
+ * honest sentence makes no promise.
1140
+ */
1141
+ function describeStoppedMachine(wake) {
1142
+ if (wake === 'owner')
1143
+ return 'executor machine is stopped and its power policy is manual, so it waits until you start it';
1144
+ if (wake === 'automatic')
1145
+ return 'executor machine is stopped and will be started for the work';
1146
+ return 'executor machine is stopped';
1147
+ }
1106
1148
  /**
1107
1149
  * The Operation line's wording for a Commitment that is not running because of its lifecycle.
1108
1150
  *
@@ -1111,6 +1153,18 @@ function describeExecutorBlocked(commitment) {
1111
1153
  * raw code, indistinguishable from one waiting on a machine or an approval (OSK-15423). Any other
1112
1154
  * operation and reason is printed as it always was.
1113
1155
  */
1156
+ /**
1157
+ * A blocked-operation reason in words. `blocked — runtime_commitment_contract_unavailable` was all a
1158
+ * list or `show` said about the system loops of an Agent on the cloud Agent Worker, and nothing in it
1159
+ * names what is wrong or what to change (OSK-22417). Only reasons whose meaning is certain are here;
1160
+ * any other reason is printed as the code, as before.
1161
+ */
1162
+ const OPERATION_REASON_WORDS = {
1163
+ 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',
1164
+ };
1165
+ function operationReasonWords(reason) {
1166
+ return typeof reason === 'string' ? OPERATION_REASON_WORDS[reason] : undefined;
1167
+ }
1114
1168
  function describeOperation(operation, reason) {
1115
1169
  // "Cannot tell" travels as `blocked` + this reason (the server's `storedOperation`: no status
1116
1170
  // recorded yet for this version of the contract, or the recorded one expired). A Commitment that
@@ -1119,8 +1173,10 @@ function describeOperation(operation, reason) {
1119
1173
  if (reason === 'operation_read_unavailable')
1120
1174
  return 'not read yet — no status is recorded for the current contract, which is not a failure; `skrr commitments show` reads it live';
1121
1175
  const lifecycle = typeof reason === 'string' ? /^lifecycle_([a-z_]+)$/.exec(reason) : null;
1122
- if (!lifecycle)
1123
- return `${operation ?? 'blocked'}${reason ? ` — ${reason}` : ''}`;
1176
+ if (!lifecycle) {
1177
+ const words = operationReasonWords(reason);
1178
+ return `${operation ?? 'blocked'}${reason ? ` — ${reason}${words ? `: ${words}` : ''}` : ''}`;
1179
+ }
1124
1180
  const status = lifecycle[1];
1125
1181
  const meaning = {
1126
1182
  paused: 'paused, it will not run until it is resumed',
@@ -1374,6 +1430,11 @@ scheduleIssues) {
1374
1430
  if (commitment.target?.deadlineAt)
1375
1431
  log(`Deadline: ${commitment.target.deadlineAt}`);
1376
1432
  log(`Cadence: ${cadenceLabel(commitment)}`);
1433
+ // `event+1d` abbreviates a guarantee: events make a check come sooner, they are not a delivery
1434
+ // receipt. Say what the interval does and does not recover (OSK-21747).
1435
+ if (commitment.cadence?.mode === 'event_plus_interval') {
1436
+ log(` ${eventBackstopNote(commitment.cadence.intervalMs)}`);
1437
+ }
1377
1438
  for (const line of scheduleIssueLines(scheduleIssues))
1378
1439
  log(line);
1379
1440
  log(`Delivery: ${(0, commitment_product_1.deliveryLabel)(commitment.delivery?.mode)}${commitment.delivery?.repo ? ` · ${commitment.delivery.repo}` : ''}${commitment.delivery?.baseBranch ? ` → ${commitment.delivery.baseBranch}` : ''}`);
@@ -276,6 +276,11 @@ const record = (value) => value && typeof value === 'object' && !Array.isArray(v
276
276
  function renderEffectivePolicy(policy, log) {
277
277
  log(`Compass ${scalar(policy.compassId)}, revision ${scalar(policy.compassVersion)}: ${scalar(policy.status)}`);
278
278
  log(`Applies to runtime: ${policy.appliesToRuntime === true ? 'yes' : 'no'}`);
279
+ // The Gateway reads one Compass per agent for the agent's own messages; this one may not be it.
280
+ const gateway = record(policy.messageGateway);
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.`);
283
+ }
279
284
  const autonomy = record(policy.autonomy);
280
285
  log('Autonomy');
281
286
  const source = typeof autonomy.modeSource === 'string' ? autonomy.modeSource : undefined;
@@ -4,6 +4,7 @@ exports.hasFlag = hasFlag;
4
4
  exports.bindToCliSession = bindToCliSession;
5
5
  const config_1 = require("./config");
6
6
  const exec_runtime_binary_1 = require("./exec-runtime-binary");
7
+ const auth_core_1 = require("@skrr-ai/auth-core");
7
8
  const keychain_1 = require("./keychain");
8
9
  /**
9
10
  * Defaults for the flags that decide WHICH deployment and WHICH profile a
@@ -56,9 +57,11 @@ function bindToCliSession(argv) {
56
57
  // is already inside a BaseCommand; fall back to that process's resolved
57
58
  // active profile so it cannot silently install the default service after
58
59
  // `skrr login --profile <name>`.
59
- const profile = (0, keychain_1.resolveProfileFromArgv)(argv) ?? process.env.OVERSKY_PROFILE ?? (0, keychain_1.getActiveProfile)() ?? null;
60
- if (profile && profile !== keychain_1.DEFAULT_PROFILE)
61
- extra.push('--profile', profile);
60
+ //
61
+ // Always explicit, `default` included (OSK-22298): omitting it for the
62
+ // default left `skrrd` to resolve on its own, and its own rule reads
63
+ // `profile.lock`, so a default-profile command could act on the pinned one.
64
+ extra.push(...(0, auth_core_1.explicitProfileArgs)((0, keychain_1.profileForChildProcess)(argv)));
62
65
  }
63
66
  return (0, exec_runtime_binary_1.normalizeRuntimeGlobalArgs)([...argv, ...extra]);
64
67
  }
@@ -2,14 +2,19 @@
2
2
  * `skrr daemon <verb> [args]` as a person can paste it for THIS profile.
3
3
  *
4
4
  * `skrr daemon login` with no `--profile` acts on whichever profile the shell it
5
- * is typed in resolves, which is the default one unless something says
6
- * otherwise. So a hint printed after `skrr login --profile expd` that said only
7
- * `skrr daemon login` sent people to sign a different daemon in and leave the
8
- * one they had just set up exactly as it was (OSK-16435). The profile is named
9
- * only when it is not the default, the way every other hint here spells it.
5
+ * is typed in resolves. So a hint printed after `skrr login --profile expd` that
6
+ * said only `skrr daemon login` sent people to sign a different daemon in and
7
+ * leave the one they had just set up exactly as it was (OSK-16435).
8
+ *
9
+ * The flag is left out only when the command typed without it would resolve to
10
+ * the same profile (`profileIsImplicit`: no environment override and no
11
+ * `profile.lock` pointing elsewhere). Comparing with the literal `default` was
12
+ * not enough: with a lock naming `work`, a hint for `default` read as
13
+ * `skrr daemon login` and signed `work` in instead (OSK-22299).
10
14
  */
11
15
  export declare function daemonCommandHint(verb: string, options?: {
12
16
  bin?: string;
13
17
  extraArgs?: string;
14
18
  profile?: string;
19
+ env?: NodeJS.ProcessEnv;
15
20
  }): string;
@@ -1,21 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.daemonCommandHint = daemonCommandHint;
4
+ const auth_core_1 = require("@skrr-ai/auth-core");
4
5
  const keychain_1 = require("./keychain");
5
6
  /**
6
7
  * `skrr daemon <verb> [args]` as a person can paste it for THIS profile.
7
8
  *
8
9
  * `skrr daemon login` with no `--profile` acts on whichever profile the shell it
9
- * is typed in resolves, which is the default one unless something says
10
- * otherwise. So a hint printed after `skrr login --profile expd` that said only
11
- * `skrr daemon login` sent people to sign a different daemon in and leave the
12
- * one they had just set up exactly as it was (OSK-16435). The profile is named
13
- * only when it is not the default, the way every other hint here spells it.
10
+ * is typed in resolves. So a hint printed after `skrr login --profile expd` that
11
+ * said only `skrr daemon login` sent people to sign a different daemon in and
12
+ * leave the one they had just set up exactly as it was (OSK-16435).
13
+ *
14
+ * The flag is left out only when the command typed without it would resolve to
15
+ * the same profile (`profileIsImplicit`: no environment override and no
16
+ * `profile.lock` pointing elsewhere). Comparing with the literal `default` was
17
+ * not enough: with a lock naming `work`, a hint for `default` read as
18
+ * `skrr daemon login` and signed `work` in instead (OSK-22299).
14
19
  */
15
20
  function daemonCommandHint(verb, options = {}) {
16
21
  const bin = options.bin ?? 'skrr';
17
22
  const profile = options.profile ?? (0, keychain_1.getActiveProfile)();
18
- const scoped = profile && profile !== keychain_1.DEFAULT_PROFILE ? ` --profile ${profile}` : '';
23
+ const scoped = profile && !(0, auth_core_1.profileIsImplicit)(profile, options.env) ? ` --profile ${profile}` : '';
19
24
  const extra = options.extraArgs ? ` ${options.extraArgs}` : '';
20
25
  return `${bin} daemon ${verb}${scoped}${extra}`;
21
26
  }
@@ -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`
@@ -9,6 +9,7 @@ const daemon_handoff_opt_out_1 = require("./daemon-handoff-opt-out");
9
9
  const daemon_machine_identity_1 = require("./daemon-machine-identity");
10
10
  const dedicated_service_1 = require("./dedicated-service");
11
11
  const exec_runtime_binary_1 = require("./exec-runtime-binary");
12
+ const auth_core_1 = require("@skrr-ai/auth-core");
12
13
  const keychain_1 = require("./keychain");
13
14
  /**
14
15
  * Ceilings, not expectations. Both calls finish in milliseconds when anything is
@@ -100,8 +101,11 @@ function runOversky(binary, args, opts) {
100
101
  * this is the same rule for the path that runs without being asked.
101
102
  */
102
103
  function profileArgs() {
103
- const profile = (0, keychain_1.getActiveProfile)();
104
- return profile && profile !== keychain_1.DEFAULT_PROFILE ? ['--profile', profile] : [];
104
+ // Explicit for `default` too (OSK-22298). Leaving it out for the default
105
+ // profile kept exactly the gap described above: `skrrd` then resolved from
106
+ // its lock, so a lock naming `work` sent a default-profile `skrr login`'s
107
+ // daemon credential to `work`.
108
+ return (0, auth_core_1.explicitProfileArgs)((0, keychain_1.profileForChildProcess)());
105
109
  }
106
110
  /**
107
111
  * Parse the machine-readable line `accept-handoff --print-id` writes to stderr.
@@ -193,7 +197,16 @@ async function handOffToLocalDaemon(env = process.env, opts = {}) {
193
197
  // authenticated with, and restarts the process — killing whatever sessions it
194
198
  // was running. `skrr login` on a healthy machine is the path where the least
195
199
  // should happen, and it was the path where the most did.
196
- 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)())) {
197
210
  return {
198
211
  status: 'skipped',
199
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
+ }
@@ -0,0 +1,22 @@
1
+ import type { Writable } from 'node:stream';
2
+ /**
3
+ * Resolve once everything this process has already written to stdout and
4
+ * stderr has been handed to the operating system (OSK-22165).
5
+ *
6
+ * Node writes a pipe asynchronously on macOS: a write larger than the pipe's
7
+ * free kernel buffer is only partly accepted, and Node queues the rest to send
8
+ * as the reader drains. `process.exit()` throws that queue away. oclif turns
9
+ * every `this.exit(n)` into exactly that call (`handle` -> `Exit.exit`), so a
10
+ * command that printed its `--json` document and then chose a nonzero status
11
+ * sent a piped reader the first 64 KiB and nothing else: a document cut
12
+ * mid-string under an exit status that looked like an ordinary refusal. A
13
+ * terminal is written synchronously, which is why the same command looked
14
+ * complete when run by hand.
15
+ *
16
+ * A zero-length write is queued behind every earlier one, so its callback runs
17
+ * only after they have all completed. A reader that has gone away (`| head -1`)
18
+ * makes the write fail, which resolves too: there is nobody left to lose
19
+ * output for.
20
+ */
21
+ export declare function drainStdio(streams?: ReadonlyArray<Writable | undefined>): Promise<void>;
22
+ export declare function drainWritable(stream: Writable | undefined): Promise<void>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.drainStdio = drainStdio;
4
+ exports.drainWritable = drainWritable;
5
+ /**
6
+ * Resolve once everything this process has already written to stdout and
7
+ * stderr has been handed to the operating system (OSK-22165).
8
+ *
9
+ * Node writes a pipe asynchronously on macOS: a write larger than the pipe's
10
+ * free kernel buffer is only partly accepted, and Node queues the rest to send
11
+ * as the reader drains. `process.exit()` throws that queue away. oclif turns
12
+ * every `this.exit(n)` into exactly that call (`handle` -> `Exit.exit`), so a
13
+ * command that printed its `--json` document and then chose a nonzero status
14
+ * sent a piped reader the first 64 KiB and nothing else: a document cut
15
+ * mid-string under an exit status that looked like an ordinary refusal. A
16
+ * terminal is written synchronously, which is why the same command looked
17
+ * complete when run by hand.
18
+ *
19
+ * A zero-length write is queued behind every earlier one, so its callback runs
20
+ * only after they have all completed. A reader that has gone away (`| head -1`)
21
+ * makes the write fail, which resolves too: there is nobody left to lose
22
+ * output for.
23
+ */
24
+ async function drainStdio(streams = [process.stdout, process.stderr]) {
25
+ await Promise.all(streams.map(drainWritable));
26
+ }
27
+ function drainWritable(stream) {
28
+ if (!stream || stream.destroyed || !stream.writable || stream.writableLength === 0) {
29
+ return Promise.resolve();
30
+ }
31
+ return new Promise((resolve) => {
32
+ const done = () => {
33
+ stream.off('close', done);
34
+ stream.off('error', done);
35
+ resolve();
36
+ };
37
+ stream.once('close', done);
38
+ stream.once('error', done);
39
+ try {
40
+ stream.write('', () => done());
41
+ }
42
+ catch {
43
+ done();
44
+ }
45
+ });
46
+ }
@@ -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,28 @@ 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;
112
144
  export type WhenOptions = {
113
145
  /** The reference instant; injectable so output is deterministic in tests. */
114
146
  now?: Date;