@skrr-ai/cli 0.1.145 → 0.1.147

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 (296) hide show
  1. package/dist/base-command.js +38 -21
  2. package/dist/commands/agenda/plan.d.ts +14 -0
  3. package/dist/commands/agenda/plan.js +29 -0
  4. package/dist/commands/agent/message/approve.js +5 -1
  5. package/dist/commands/agent/message/decline.js +5 -1
  6. package/dist/commands/agent/message/send.d.ts +11 -0
  7. package/dist/commands/agent/message/send.js +34 -8
  8. package/dist/commands/agent-worker.js +2 -1
  9. package/dist/commands/agents/activity.js +2 -1
  10. package/dist/commands/agents/always-on/enable.js +1 -1
  11. package/dist/commands/agents/badge.js +10 -5
  12. package/dist/commands/agents/categories/index.js +2 -1
  13. package/dist/commands/agents/chat.d.ts +1 -0
  14. package/dist/commands/agents/chat.js +29 -1
  15. package/dist/commands/agents/create.js +4 -1
  16. package/dist/commands/agents/overview.js +2 -1
  17. package/dist/commands/agents/releases/create.js +2 -1
  18. package/dist/commands/agents/schedule-overview.js +12 -11
  19. package/dist/commands/agents/schedule.js +2 -1
  20. package/dist/commands/agents/spawn.d.ts +38 -1
  21. package/dist/commands/agents/spawn.js +112 -9
  22. package/dist/commands/agents/tools/auth.js +2 -1
  23. package/dist/commands/agents/tools/calls.js +2 -1
  24. package/dist/commands/agents/triggers/fire.js +20 -0
  25. package/dist/commands/agents/visibility.js +2 -1
  26. package/dist/commands/balance/show.js +17 -2
  27. package/dist/commands/balance/statement.js +2 -1
  28. package/dist/commands/commands.js +2 -1
  29. package/dist/commands/commitments/create.js +2 -1
  30. package/dist/commands/commitments/delivery.js +2 -1
  31. package/dist/commands/commitments/doctor.js +2 -1
  32. package/dist/commands/commitments/observations.js +2 -2
  33. package/dist/commands/commitments/operating-review.js +2 -1
  34. package/dist/commands/commitments/pack/preflight.js +2 -1
  35. package/dist/commands/commitments/trigger-status.js +2 -1
  36. package/dist/commands/convos/messages.js +2 -1
  37. package/dist/commands/daemon/logs.js +18 -9
  38. package/dist/commands/daemon/usage.js +2 -1
  39. package/dist/commands/dm/messages.js +2 -1
  40. package/dist/commands/dm/thread/messages.js +2 -1
  41. package/dist/commands/dm/threads.js +2 -1
  42. package/dist/commands/doctor.js +2 -1
  43. package/dist/commands/goals/key-results/assess.js +2 -1
  44. package/dist/commands/goals/key-results/history.js +2 -1
  45. package/dist/commands/harnesses/forget.js +2 -1
  46. package/dist/commands/harnesses/show.js +12 -6
  47. package/dist/commands/inbox/index.js +4 -3
  48. package/dist/commands/initiatives/decide.js +2 -1
  49. package/dist/commands/instructions/diff.js +2 -1
  50. package/dist/commands/instructions/show.js +2 -1
  51. package/dist/commands/login.js +4 -2
  52. package/dist/commands/machines/dedicated/cp.js +2 -1
  53. package/dist/commands/machines/dedicated/power/set.js +2 -1
  54. package/dist/commands/machines/show.js +2 -1
  55. package/dist/commands/memory/maintain.js +2 -1
  56. package/dist/commands/memory/read.js +2 -1
  57. package/dist/commands/memory/rebuild-index.js +2 -1
  58. package/dist/commands/memory/rebuild.js +2 -1
  59. package/dist/commands/memory/search.js +2 -1
  60. package/dist/commands/messages/list.js +2 -1
  61. package/dist/commands/revoke-daemon.js +2 -1
  62. package/dist/commands/revoke-token.js +2 -1
  63. package/dist/commands/search/all.js +14 -7
  64. package/dist/commands/search/workspace.js +2 -1
  65. package/dist/commands/set-capabilities.js +2 -1
  66. package/dist/commands/skills/browse.js +8 -2
  67. package/dist/commands/spaces/auto-executor/preview.js +3 -2
  68. package/dist/commands/spaces/auto-executor/runs.js +4 -1
  69. package/dist/commands/spaces/workflow-templates/extract.d.ts +1 -0
  70. package/dist/commands/spaces/workflow-templates/extract.js +9 -1
  71. package/dist/commands/spaces/workflows/events.js +6 -3
  72. package/dist/commands/spaces/workflows/run.js +5 -3
  73. package/dist/commands/spaces/workflows/update.js +2 -1
  74. package/dist/commands/store/gallery-admissions/preview.js +2 -1
  75. package/dist/commands/store/publishers/profile/handle.js +2 -1
  76. package/dist/commands/tasks/comments/anchor.js +23 -9
  77. package/dist/commands/tasks/complete.js +4 -2
  78. package/dist/commands/tasks/create-tree.js +7 -3
  79. package/dist/commands/tasks/create.js +2 -1
  80. package/dist/commands/tasks/deliverable/add.js +2 -1
  81. package/dist/commands/tasks/deliverable/archive.js +2 -1
  82. package/dist/commands/tasks/deliverable/list.js +2 -1
  83. package/dist/commands/tasks/expectations/assess.js +2 -1
  84. package/dist/commands/tasks/labels/create.js +2 -1
  85. package/dist/commands/tasks/preflight.js +4 -2
  86. package/dist/commands/tasks/ready.js +2 -1
  87. package/dist/commands/tasks/result/submit.js +2 -1
  88. package/dist/commands/tasks/updates/add.js +2 -1
  89. package/dist/commands/tasks/wait.js +2 -1
  90. package/dist/commands/token/list.js +2 -1
  91. package/dist/commands/token/mint.js +2 -1
  92. package/dist/commands/triggers/audit.js +1 -1
  93. package/dist/commands/triggers/fire.js +19 -0
  94. package/dist/commands/wiki/write.js +14 -7
  95. package/dist/hooks/command-not-found.js +2 -1
  96. package/dist/lib/agent-chat-start.d.ts +77 -0
  97. package/dist/lib/agent-chat-start.js +169 -0
  98. package/dist/lib/agent-config.js +2 -1
  99. package/dist/lib/agent-endpoints.js +4 -2
  100. package/dist/lib/agent-evals.js +2 -1
  101. package/dist/lib/agent-guide-reference-gate.js +22 -11
  102. package/dist/lib/agent-guides.js +4 -1
  103. package/dist/lib/agent-instructions.js +5 -1
  104. package/dist/lib/agent-ref.js +8 -4
  105. package/dist/lib/agent-trigger-listing.js +2 -1
  106. package/dist/lib/agentic-stream.d.ts +21 -0
  107. package/dist/lib/agentic-stream.js +75 -6
  108. package/dist/lib/api-error-reason.js +2 -1
  109. package/dist/lib/api-fetch.js +5 -3
  110. package/dist/lib/appData.js +6 -6
  111. package/dist/lib/appInstallations.js +10 -5
  112. package/dist/lib/appsCheck.js +2 -1
  113. package/dist/lib/auth-failure.js +2 -1
  114. package/dist/lib/auth-storage.js +2 -1
  115. package/dist/lib/balance.js +6 -3
  116. package/dist/lib/capability-matrix.js +4 -2
  117. package/dist/lib/cli-runtime.js +2 -1
  118. package/dist/lib/code-handover.js +8 -3
  119. package/dist/lib/command-hygiene.js +28 -12
  120. package/dist/lib/command-manifest.js +6 -3
  121. package/dist/lib/commitment-attention-copy.js +2 -1
  122. package/dist/lib/commitment-event-wakes.js +9 -0
  123. package/dist/lib/commitment-product.js +5 -3
  124. package/dist/lib/commitment-terms.js +2 -1
  125. package/dist/lib/commitments.d.ts +8 -0
  126. package/dist/lib/commitments.js +8 -4
  127. package/dist/lib/compasses.js +2 -1
  128. package/dist/lib/completion-index.js +2 -1
  129. package/dist/lib/computer-files.js +8 -6
  130. package/dist/lib/config.js +11 -5
  131. package/dist/lib/conversation-search.js +4 -2
  132. package/dist/lib/daemon-installer.js +6 -2
  133. package/dist/lib/daemon-maintenance.js +2 -1
  134. package/dist/lib/daemon-ref.js +2 -1
  135. package/dist/lib/daemonBroker.js +6 -3
  136. package/dist/lib/daemonBrokerRefusal.js +4 -2
  137. package/dist/lib/daemonHandoff.js +14 -7
  138. package/dist/lib/daemonIslandProfile.js +2 -1
  139. package/dist/lib/dedicated-copy.js +9 -3
  140. package/dist/lib/dedicated-exec.js +2 -1
  141. package/dist/lib/dedicated-keep-awake.js +2 -1
  142. package/dist/lib/dedicated-machines.js +9 -5
  143. package/dist/lib/dedicated-service.js +2 -1
  144. package/dist/lib/dedicated-ssh.js +5 -3
  145. package/dist/lib/deployed-build.js +2 -1
  146. package/dist/lib/device-code.js +4 -3
  147. package/dist/lib/dpop-auth.js +2 -1
  148. package/dist/lib/earnings.js +2 -1
  149. package/dist/lib/exec-runtime-binary.js +5 -3
  150. package/dist/lib/first-party-harness-broker.js +4 -3
  151. package/dist/lib/first-party-harness-managed.js +2 -1
  152. package/dist/lib/first-party-harness-startup-update.js +8 -4
  153. package/dist/lib/first-party-harness-update.js +2 -1
  154. package/dist/lib/first-party-harness.js +2 -1
  155. package/dist/lib/format.d.ts +5 -0
  156. package/dist/lib/format.js +24 -4
  157. package/dist/lib/git-task.js +10 -5
  158. package/dist/lib/github-tools.js +6 -3
  159. package/dist/lib/harnesses.js +4 -2
  160. package/dist/lib/hosted-machines.js +2 -1
  161. package/dist/lib/html-text.js +33 -16
  162. package/dist/lib/instruction-blocks.js +2 -1
  163. package/dist/lib/iso-instant.js +5 -3
  164. package/dist/lib/keychain.js +15 -5
  165. package/dist/lib/label-scope.js +2 -1
  166. package/dist/lib/live-runtime-binary.js +10 -7
  167. package/dist/lib/local-skills.js +10 -6
  168. package/dist/lib/login.js +3 -2
  169. package/dist/lib/machine-audit.js +2 -1
  170. package/dist/lib/machine-daemon-log.js +2 -1
  171. package/dist/lib/machine-services.js +2 -1
  172. package/dist/lib/memory-history-session.js +2 -1
  173. package/dist/lib/memory-sync.js +6 -2
  174. package/dist/lib/message-intent.d.ts +10 -0
  175. package/dist/lib/node-adapter.js +4 -2
  176. package/dist/lib/northstars.js +4 -2
  177. package/dist/lib/oauthLogin.js +16 -7
  178. package/dist/lib/open-target.js +8 -4
  179. package/dist/lib/option-hint.js +2 -4
  180. package/dist/lib/outbox.js +2 -1
  181. package/dist/lib/planOutcome.d.ts +5 -3
  182. package/dist/lib/planOutcome.js +7 -4
  183. package/dist/lib/platform-update-local.js +2 -3
  184. package/dist/lib/proactiveApi.d.ts +38 -1
  185. package/dist/lib/proactiveApi.js +17 -1
  186. package/dist/lib/rate-limit-retry.js +2 -1
  187. package/dist/lib/reflection.js +2 -1
  188. package/dist/lib/request-field-flags.js +2 -1
  189. package/dist/lib/runtime-start-verification.js +2 -1
  190. package/dist/lib/schedule.d.ts +15 -0
  191. package/dist/lib/schedule.js +16 -1
  192. package/dist/lib/scoped-memory-command.js +7 -3
  193. package/dist/lib/search-display.js +11 -4
  194. package/dist/lib/skill-store-pagination.js +2 -1
  195. package/dist/lib/space-notebook.js +5 -3
  196. package/dist/lib/store-listing.js +2 -1
  197. package/dist/lib/task-agent-context-capabilities.js +2 -1
  198. package/dist/lib/task-asset-upload.js +7 -3
  199. package/dist/lib/task-closure.js +2 -1
  200. package/dist/lib/task-economics.js +2 -1
  201. package/dist/lib/task-execution.js +16 -8
  202. package/dist/lib/task-extras.js +4 -2
  203. package/dist/lib/task-operation-watch.js +2 -1
  204. package/dist/lib/task-preflight.js +3 -2
  205. package/dist/lib/task-recurrence-summary.js +4 -2
  206. package/dist/lib/task-runtime-headers.js +10 -5
  207. package/dist/lib/task-transcript.js +3 -2
  208. package/dist/lib/task-transfer.js +9 -5
  209. package/dist/lib/tasks.js +2 -1
  210. package/dist/lib/triggers.d.ts +144 -3
  211. package/dist/lib/triggers.js +280 -23
  212. package/dist/lib/update-check.js +12 -7
  213. package/dist/lib/usage-discovery.js +2 -1
  214. package/dist/lib/usd-micros.js +2 -1
  215. package/dist/lib/web-url.js +2 -1
  216. package/dist/lib/widgetCheck.js +15 -9
  217. package/dist/lib/widgetStaticScan.js +26 -14
  218. package/dist/lib/workflow-run-view.js +5 -3
  219. package/dist/lib/workflow-templates.d.ts +10 -0
  220. package/dist/lib/workflow-templates.js +47 -0
  221. package/dist/lib/write-target.js +4 -5
  222. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/authHelper.js +2 -1
  223. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/commitmentExecutionContract.js +22 -12
  224. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/computerUse.js +4 -1
  225. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelope.js +7 -2
  226. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -3
  227. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonConsentProof.js +2 -1
  228. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonPair.js +16 -7
  229. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +4 -1
  230. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/desktopDaemonProof.js +4 -3
  231. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/desktopWire.js +2 -1
  232. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +11 -7
  233. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceKey.js +7 -2
  234. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dpop.js +8 -3
  235. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +2 -1
  236. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessChannels.js +4 -3
  237. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.js +2 -1
  238. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/githubPushRefusal.js +4 -3
  239. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/guidedUpdate.js +2 -1
  240. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/independentMachineReservation.js +8 -3
  241. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/kek/macos.js +4 -2
  242. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/liveState.js +4 -2
  243. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/loginWithLocalhost.js +2 -1
  244. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/loopbackHttp.js +2 -1
  245. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/machineUuid.js +4 -2
  246. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileStateDir.js +2 -1
  247. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/recoveryCode.js +2 -1
  248. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +3 -2
  249. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releasePolicy.js +2 -1
  250. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releaseVersions.js +6 -4
  251. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/restartArtifact.js +2 -1
  252. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/spawnEnv.js +2 -1
  253. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/telemetryRedaction.js +7 -4
  254. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.js +2 -1
  255. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/authHelper.js +2 -1
  256. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/commitmentExecutionContract.js +27 -18
  257. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/computerUse.js +6 -3
  258. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelope.js +11 -2
  259. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +6 -3
  260. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonConsentProof.js +2 -1
  261. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonPair.js +20 -8
  262. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +5 -4
  263. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/desktopDaemonProof.js +4 -3
  264. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/desktopWire.js +2 -1
  265. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +11 -7
  266. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceKey.js +11 -2
  267. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dpop.js +12 -3
  268. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +2 -1
  269. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessChannels.js +4 -3
  270. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.js +2 -1
  271. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/githubPushRefusal.js +4 -3
  272. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/guidedUpdate.js +5 -1
  273. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/independentMachineReservation.js +10 -5
  274. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/kek/macos.js +4 -2
  275. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/liveState.js +4 -2
  276. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/loginWithLocalhost.js +2 -1
  277. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/loopbackHttp.js +2 -1
  278. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/machineUuid.js +4 -2
  279. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileStateDir.js +2 -1
  280. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/recoveryCode.js +2 -1
  281. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +3 -2
  282. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releasePolicy.js +2 -1
  283. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releaseVersions.js +6 -4
  284. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/restartArtifact.js +2 -1
  285. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/spawnEnv.js +2 -1
  286. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/telemetryRedaction.js +11 -5
  287. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.js +2 -1
  288. package/dist/node_modules/@skrr-ai/auth-core/package.json +1 -1
  289. package/dist/node_modules/@skrr-ai/data-provider/index.js +20520 -20130
  290. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.js +4 -2
  291. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +10 -6
  292. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.js +4 -2
  293. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +10 -6
  294. package/dist/node_modules/@skrr-ai/inference-broker/package.json +1 -1
  295. package/oclif.manifest.json +24 -2
  296. package/package.json +1 -1
@@ -71,7 +71,7 @@ class TriggersAudit extends base_command_1.BaseCommand {
71
71
  this.log(JSON.stringify(response, null, 2));
72
72
  return;
73
73
  }
74
- (0, triggers_1.renderFireAudit)(response.fires ?? [], (line) => this.log(line));
74
+ (0, triggers_1.renderFireAudit)(response.fires ?? [], (line) => this.log(line), response.waiting);
75
75
  }
76
76
  }
77
77
  exports.default = TriggersAudit;
@@ -44,6 +44,25 @@ class TriggersFire extends base_command_1.BaseCommand {
44
44
  catch (err) {
45
45
  this.handleApiError(err);
46
46
  }
47
+ // A watcher fire can run for minutes; the server answers 202 with the occurrence once it has
48
+ // outlived a short wait, and the result is followed here (OSK-22624).
49
+ const settled = await (0, triggers_1.settleFireAnswer)({
50
+ triggerId: args.id,
51
+ bin: this.config.bin,
52
+ answer: result,
53
+ note: (line) => process.stderr.write(`${line}\n`),
54
+ });
55
+ if (settled.running) {
56
+ if (flags.json) {
57
+ this.printJsonResult({ ...settled.answer, ok: true });
58
+ }
59
+ else {
60
+ this.log(`Fire accepted and still running (occurrence ${settled.answer.occurrenceId ?? '-'}).`);
61
+ this.log(`Read its result later: ${settled.command}`);
62
+ }
63
+ return;
64
+ }
65
+ result = settled.result;
47
66
  const accepted = (0, triggers_1.fireWasAccepted)(result);
48
67
  if (flags.json) {
49
68
  // `ok` and the exit status are one answer: a strict refusal prints `ok: false` and why,
@@ -12,6 +12,14 @@ const http_error_1 = require("../../lib/http-error");
12
12
  const space_charter_1 = require("../../lib/space-charter");
13
13
  const web_url_1 = require("../../lib/web-url");
14
14
  const wiki_1 = require("../../lib/wiki");
15
+ const SLUGIFY_LIKE_SERVER_RE = /[/\\]+/g;
16
+ // eslint-disable-next-line no-control-regex
17
+ const SLUGIFY_LIKE_SERVER_RE_2 = /[\u0000-\u001f\u007f]/g;
18
+ const SLUGIFY_LIKE_SERVER_RE_3 = /\s+/g;
19
+ const SLUGIFY_LIKE_SERVER_RE_4 = /-{2,}/g;
20
+ const SLUGIFY_LIKE_SERVER_RE_5 = /^-+|-+$/g;
21
+ const CREATED_SLUG_COLLIDED_RE = /^\d+$/;
22
+ const CREATED_SLUG_COLLIDED_RE_2 = /^[0-9a-f]{8}$/;
15
23
  /**
16
24
  * The page lookup below goes through `dataService`, whose adapter throws a
17
25
  * plain `Error` carrying `status` — not an `ApiFetchError` and not an
@@ -54,12 +62,11 @@ function slugifyLikeServer(input) {
54
62
  const base = String(input || '')
55
63
  .trim()
56
64
  .toLowerCase()
57
- .replace(/[/\\]+/g, '-')
58
- // eslint-disable-next-line no-control-regex
59
- .replace(/[\u0000-\u001f\u007f]/g, '')
60
- .replace(/\s+/g, '-')
61
- .replace(/-{2,}/g, '-')
62
- .replace(/^-+|-+$/g, '')
65
+ .replace(SLUGIFY_LIKE_SERVER_RE, '-')
66
+ .replace(SLUGIFY_LIKE_SERVER_RE_2, '')
67
+ .replace(SLUGIFY_LIKE_SERVER_RE_3, '-')
68
+ .replace(SLUGIFY_LIKE_SERVER_RE_4, '-')
69
+ .replace(SLUGIFY_LIKE_SERVER_RE_5, '')
63
70
  .slice(0, MAX_SLUG_LENGTH);
64
71
  return base || 'untitled';
65
72
  }
@@ -90,7 +97,7 @@ function createdSlugCollided(requestedSlug, createdSlug) {
90
97
  const suffix = createdSlug.slice(base.length + 1);
91
98
  // `allocateSlug` appends either an ordinal (`-2`) or, in its pathological
92
99
  // fallback, an 8-char uuid head.
93
- return /^\d+$/.test(suffix) || /^[0-9a-f]{8}$/.test(suffix);
100
+ return CREATED_SLUG_COLLIDED_RE.test(suffix) || CREATED_SLUG_COLLIDED_RE_2.test(suffix);
94
101
  }
95
102
  /**
96
103
  * The warning for `--kind` on a write that landed in a page that already
@@ -5,6 +5,7 @@ const command_manifest_1 = require("../lib/command-manifest");
5
5
  const usage_discovery_1 = require("../lib/usage-discovery");
6
6
  const command_miss_1 = require("../lib/command-miss");
7
7
  const json_mode_1 = require("../lib/json-mode");
8
+ const VIRTUAL_USAGE_FLAGS_RE = /^--page=(.+)$/;
8
9
  /**
9
10
  * Turn "command not found" back into the truth when the command DOES exist.
10
11
  *
@@ -116,7 +117,7 @@ function virtualUsageFlags(argv) {
116
117
  json = true;
117
118
  continue;
118
119
  }
119
- const suppliedPage = token === '--page' ? argv[++index] : token.match(/^--page=(.+)$/)?.[1];
120
+ const suppliedPage = token === '--page' ? argv[++index] : token.match(VIRTUAL_USAGE_FLAGS_RE)?.[1];
120
121
  if (suppliedPage !== undefined) {
121
122
  const parsed = Number(suppliedPage);
122
123
  if (!Number.isInteger(parsed) || parsed < 1) {
@@ -0,0 +1,77 @@
1
+ /**
2
+ * agent-chat-start.ts — start an agent turn so that "no answer" never means "abandoned".
3
+ *
4
+ * `POST /api/agentic/chat` is an acceptance, not the turn: the server admits the
5
+ * request, reserves the balance for it, queues the run, and only then answers. When
6
+ * that answer is lost — the edge gives up with a 504, the API answers 503 while it is
7
+ * restarting, the socket drops — the CLI cannot tell "never admitted" from "admitted
8
+ * and running". Reporting it as a plain failure (`retryable: false`) is the wrong
9
+ * half of that ambiguity: the turn is usually live, its balance hold is open, and its
10
+ * permission prompts can no longer be answered because the process that would answer
11
+ * them has exited (OSK-22631).
12
+ *
13
+ * The server already has the right contract. A request that carries a
14
+ * `clientRequestId` is admitted exactly once per (user, id): a replay of an accepted
15
+ * request returns the original acceptance (`idempotentReplay: true`, same session and
16
+ * conversation), a replay of one still being admitted answers
17
+ * `409 agentic_request_in_progress` ("retry shortly with the same clientRequestId"),
18
+ * and a different message under the same id is refused. So the client's job is small:
19
+ * name the start, and when the outcome is unknown, send the SAME request again.
20
+ *
21
+ * What is NOT replayed: a refusal that says it cannot help (`retryable: false`, an
22
+ * unconfirmed previous admission, a changed release), any 4xx, and anything that is not
23
+ * an HTTP failure of the transport. Those describe a state the caller has to change
24
+ * first, and replaying them only repeats the refusal.
25
+ */
26
+ export declare const START_KEY_RULE = "1-128 characters: letters, numbers, dot, underscore, colon, hyphen";
27
+ /**
28
+ * Waits between replays. The first replay is quick because most unknown outcomes are a
29
+ * lost answer to a start that already succeeded; the later ones give a restarting API
30
+ * time to come back. Roughly 44 seconds of waiting in total, on top of each attempt.
31
+ */
32
+ export declare const DEFAULT_REPLAY_DELAYS_MS: readonly number[];
33
+ /** A fresh key for one invocation. Reused by every replay of that invocation, never across them. */
34
+ export declare function newStartKey(): string;
35
+ /** Whether a caller-supplied key is one the server will accept. */
36
+ export declare function isValidStartKey(value: string): boolean;
37
+ export type StartVerdict = 'replay' | 'surface';
38
+ /**
39
+ * Whether a failed start may be sent again under the same key.
40
+ *
41
+ * `replay` is exactly the set of failures where the outcome is unknown or the server
42
+ * said "still being admitted"; `surface` is everything the caller has to act on.
43
+ */
44
+ export declare function classifyStartFailure(err: unknown): StartVerdict;
45
+ /** Raised when every replay of a start ended without the server confirming the outcome. */
46
+ export declare class StartNotConfirmed extends Error {
47
+ readonly attempts: number;
48
+ readonly lastError: unknown;
49
+ constructor(lastError: unknown, attempts: number);
50
+ }
51
+ export interface ReplayInfo {
52
+ /** The replay about to be sent, 1-based. */
53
+ attempt: number;
54
+ /** How many replays this start will make at most. */
55
+ of: number;
56
+ waitMs: number;
57
+ error: unknown;
58
+ }
59
+ export interface StartReplayOptions {
60
+ delaysMs?: readonly number[];
61
+ sleep?: (ms: number) => Promise<void>;
62
+ onReplay?: (info: ReplayInfo) => void;
63
+ }
64
+ /**
65
+ * Run `start`; when it fails with an unknown outcome, run it again — the SAME call, so the
66
+ * same key — after a short wait, up to `delaysMs.length` more times.
67
+ *
68
+ * A failure that is not replayable is thrown untouched on whichever attempt it happens, so
69
+ * existing error handling (and its message) is unchanged. Only running out of replays turns
70
+ * into `StartNotConfirmed`, which carries the last transport error for the caller to render.
71
+ */
72
+ export declare function startWithReplay<T>(start: () => Promise<T>, options?: StartReplayOptions): Promise<T>;
73
+ /**
74
+ * What to tell a person when the server never confirmed the start. The turn may be running,
75
+ * so the advice is to re-attach with the same key rather than start a second turn.
76
+ */
77
+ export declare function startNotConfirmedHint(key: string, attempts: number): string;
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ /**
3
+ * agent-chat-start.ts — start an agent turn so that "no answer" never means "abandoned".
4
+ *
5
+ * `POST /api/agentic/chat` is an acceptance, not the turn: the server admits the
6
+ * request, reserves the balance for it, queues the run, and only then answers. When
7
+ * that answer is lost — the edge gives up with a 504, the API answers 503 while it is
8
+ * restarting, the socket drops — the CLI cannot tell "never admitted" from "admitted
9
+ * and running". Reporting it as a plain failure (`retryable: false`) is the wrong
10
+ * half of that ambiguity: the turn is usually live, its balance hold is open, and its
11
+ * permission prompts can no longer be answered because the process that would answer
12
+ * them has exited (OSK-22631).
13
+ *
14
+ * The server already has the right contract. A request that carries a
15
+ * `clientRequestId` is admitted exactly once per (user, id): a replay of an accepted
16
+ * request returns the original acceptance (`idempotentReplay: true`, same session and
17
+ * conversation), a replay of one still being admitted answers
18
+ * `409 agentic_request_in_progress` ("retry shortly with the same clientRequestId"),
19
+ * and a different message under the same id is refused. So the client's job is small:
20
+ * name the start, and when the outcome is unknown, send the SAME request again.
21
+ *
22
+ * What is NOT replayed: a refusal that says it cannot help (`retryable: false`, an
23
+ * unconfirmed previous admission, a changed release), any 4xx, and anything that is not
24
+ * an HTTP failure of the transport. Those describe a state the caller has to change
25
+ * first, and replaying them only repeats the refusal.
26
+ */
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.StartNotConfirmed = exports.DEFAULT_REPLAY_DELAYS_MS = exports.START_KEY_RULE = void 0;
29
+ exports.newStartKey = newStartKey;
30
+ exports.isValidStartKey = isValidStartKey;
31
+ exports.classifyStartFailure = classifyStartFailure;
32
+ exports.startWithReplay = startWithReplay;
33
+ exports.startNotConfirmedHint = startNotConfirmedHint;
34
+ const node_crypto_1 = require("node:crypto");
35
+ const http_error_1 = require("./http-error");
36
+ /** The server accepts 1-128 characters: letters, numbers, dot, underscore, colon, hyphen. */
37
+ const START_KEY_PATTERN = /^[A-Za-z0-9._:-]{1,128}$/;
38
+ exports.START_KEY_RULE = '1-128 characters: letters, numbers, dot, underscore, colon, hyphen';
39
+ /**
40
+ * Waits between replays. The first replay is quick because most unknown outcomes are a
41
+ * lost answer to a start that already succeeded; the later ones give a restarting API
42
+ * time to come back. Roughly 44 seconds of waiting in total, on top of each attempt.
43
+ */
44
+ exports.DEFAULT_REPLAY_DELAYS_MS = [2_000, 4_000, 8_000, 15_000, 15_000];
45
+ /** A fresh key for one invocation. Reused by every replay of that invocation, never across them. */
46
+ function newStartKey() {
47
+ return `cli-chat:${(0, node_crypto_1.randomUUID)()}`;
48
+ }
49
+ /** Whether a caller-supplied key is one the server will accept. */
50
+ function isValidStartKey(value) {
51
+ return START_KEY_PATTERN.test(value);
52
+ }
53
+ /** The JSON body of a failed response, when the transport kept it as text or as an object. */
54
+ function bodyOf(err) {
55
+ if (typeof err !== 'object' || err === null)
56
+ return undefined;
57
+ const raw = err.body;
58
+ if (raw && typeof raw === 'object')
59
+ return raw;
60
+ if (typeof raw !== 'string' || !raw.trim().startsWith('{'))
61
+ return undefined;
62
+ try {
63
+ const parsed = JSON.parse(raw);
64
+ return parsed && typeof parsed === 'object' ? parsed : undefined;
65
+ }
66
+ catch {
67
+ return undefined;
68
+ }
69
+ }
70
+ const NETWORK_CODES = new Set([
71
+ 'ECONNRESET',
72
+ 'ECONNABORTED',
73
+ 'ETIMEDOUT',
74
+ 'EPIPE',
75
+ 'EAI_AGAIN',
76
+ 'UND_ERR_SOCKET',
77
+ 'UND_ERR_CONNECT_TIMEOUT',
78
+ 'UND_ERR_HEADERS_TIMEOUT',
79
+ ]);
80
+ /** A request that never produced an HTTP response, from a transport that reports why. */
81
+ function isNetworkFailure(err) {
82
+ if (typeof err !== 'object' || err === null)
83
+ return false;
84
+ const record = err;
85
+ const code = typeof record.code === 'string' ? record.code : undefined;
86
+ if (code && NETWORK_CODES.has(code))
87
+ return true;
88
+ const causeCode = typeof record.cause === 'object' && record.cause !== null
89
+ ? record.cause.code
90
+ : undefined;
91
+ if (typeof causeCode === 'string' && NETWORK_CODES.has(causeCode))
92
+ return true;
93
+ return typeof record.message === 'string' && /fetch failed|socket hang up/i.test(record.message);
94
+ }
95
+ /**
96
+ * Whether a failed start may be sent again under the same key.
97
+ *
98
+ * `replay` is exactly the set of failures where the outcome is unknown or the server
99
+ * said "still being admitted"; `surface` is everything the caller has to act on.
100
+ */
101
+ function classifyStartFailure(err) {
102
+ const status = (0, http_error_1.httpStatusOf)(err);
103
+ if (status === undefined)
104
+ return isNetworkFailure(err) ? 'replay' : 'surface';
105
+ // The gateway or load balancer answered for the API: the server may have carried on.
106
+ if (status === 502 || status === 504)
107
+ return 'replay';
108
+ const body = bodyOf(err);
109
+ // The API answered itself. 503 says "try again" unless it declares that it cannot help
110
+ // (an unconfirmed earlier admission, `retryable: false`).
111
+ if (status === 503)
112
+ return body?.retryable === false ? 'surface' : 'replay';
113
+ // The same key is already being admitted: waiting and asking again is the documented move.
114
+ if (status === 409 && body?.errorType === 'agentic_request_in_progress')
115
+ return 'replay';
116
+ return 'surface';
117
+ }
118
+ /** Raised when every replay of a start ended without the server confirming the outcome. */
119
+ class StartNotConfirmed extends Error {
120
+ attempts;
121
+ lastError;
122
+ constructor(lastError, attempts) {
123
+ super(`The start was not confirmed after ${attempts} attempt${attempts === 1 ? '' : 's'}.`);
124
+ this.name = 'StartNotConfirmed';
125
+ this.attempts = attempts;
126
+ this.lastError = lastError;
127
+ }
128
+ }
129
+ exports.StartNotConfirmed = StartNotConfirmed;
130
+ const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
131
+ /**
132
+ * Run `start`; when it fails with an unknown outcome, run it again — the SAME call, so the
133
+ * same key — after a short wait, up to `delaysMs.length` more times.
134
+ *
135
+ * A failure that is not replayable is thrown untouched on whichever attempt it happens, so
136
+ * existing error handling (and its message) is unchanged. Only running out of replays turns
137
+ * into `StartNotConfirmed`, which carries the last transport error for the caller to render.
138
+ */
139
+ async function startWithReplay(start, options = {}) {
140
+ const delays = options.delaysMs ?? exports.DEFAULT_REPLAY_DELAYS_MS;
141
+ const sleep = options.sleep ?? defaultSleep;
142
+ let attempts = 0;
143
+ for (;;) {
144
+ attempts += 1;
145
+ try {
146
+ return await start();
147
+ }
148
+ catch (error) {
149
+ if (classifyStartFailure(error) !== 'replay')
150
+ throw error;
151
+ const replayIndex = attempts - 1;
152
+ if (replayIndex >= delays.length)
153
+ throw new StartNotConfirmed(error, attempts);
154
+ const waitMs = delays[replayIndex];
155
+ options.onReplay?.({ attempt: replayIndex + 1, of: delays.length, waitMs, error });
156
+ await sleep(waitMs);
157
+ }
158
+ }
159
+ }
160
+ /**
161
+ * What to tell a person when the server never confirmed the start. The turn may be running,
162
+ * so the advice is to re-attach with the same key rather than start a second turn.
163
+ */
164
+ function startNotConfirmedHint(key, attempts) {
165
+ return (`The server never confirmed this start after ${attempts} attempt${attempts === 1 ? '' : 's'}. ` +
166
+ `The turn may still have been accepted and be running. Re-run the same command with ` +
167
+ `--idempotency-key ${key} to attach to it if it was, or to start it once if it was not; ` +
168
+ `a new key could start a second turn.`);
169
+ }
@@ -7,6 +7,7 @@ exports.parseWorkingHoursFlag = parseWorkingHoursFlag;
7
7
  exports.mergeAgentConfigFlags = mergeAgentConfigFlags;
8
8
  const prompt_1 = require("./prompt");
9
9
  const agent_visual_refs_1 = require("./agent-visual-refs");
10
+ const PARSE_WORKING_HOURS_FLAG_RE = /^([0-2]\d:[0-5]\d)-([0-2]\d:[0-5]\d)$/;
10
11
  /**
11
12
  * The fields the server ignored and why, from a write's `deprecatedFields`
12
13
  * notice, one line each. Empty when the response carries none.
@@ -41,7 +42,7 @@ function parseWorkingHoursFlag(value) {
41
42
  if (trimmed.startsWith('{'))
42
43
  return JSON.parse(trimmed);
43
44
  const [window, timezone] = trimmed.split('@');
44
- const match = /^([0-2]\d:[0-5]\d)-([0-2]\d:[0-5]\d)$/.exec(window ?? '');
45
+ const match = PARSE_WORKING_HOURS_FLAG_RE.exec(window ?? '');
45
46
  if (!match) {
46
47
  throw new Error(`--todo-working-hours: cannot read "${value}". ` +
47
48
  'Write HH:MM-HH:MM, optionally @<IANA timezone> — for example ' +
@@ -8,6 +8,8 @@ exports.describeEndpointState = describeEndpointState;
8
8
  exports.endpointWillRun = endpointWillRun;
9
9
  exports.printAgentEndpoint = printAgentEndpoint;
10
10
  const api_fetch_1 = require("./api-fetch");
11
+ const MCP_CLIENT_COMMAND_RE = /[^A-Za-z0-9_-]/g;
12
+ const PRINT_AGENT_ENDPOINT_RE = /_/g;
11
13
  async function getAgentEndpoint(agentId) {
12
14
  return (0, api_fetch_1.apiFetch)(`/api/agent-endpoints/${encodeURIComponent(agentId)}`);
13
15
  }
@@ -25,7 +27,7 @@ exports.AGENT_ENDPOINT_SCOPE = 'agents:invoke';
25
27
  * header; any other client needs the same two facts (URL, bearer key).
26
28
  */
27
29
  function mcpClientCommand(endpoint, secret) {
28
- const name = `skrr-${endpoint.agent_id}`.replace(/[^A-Za-z0-9_-]/g, '-');
30
+ const name = `skrr-${endpoint.agent_id}`.replace(MCP_CLIENT_COMMAND_RE, '-');
29
31
  return `claude mcp add --transport http ${name} ${endpoint.url} --header "Authorization: Bearer ${secret}"`;
30
32
  }
31
33
  /** One human line for the state an endpoint is in. */
@@ -51,7 +53,7 @@ function endpointWillRun(endpoint) {
51
53
  /** The human rendering every `agents endpoint` command prints. */
52
54
  function printAgentEndpoint(cmd, endpoint) {
53
55
  cmd.log(`Agent ${endpoint.agent_id}${endpoint.agent_name ? ` (${endpoint.agent_name})` : ''}`);
54
- cmd.log(`Kind ${endpoint.kind.replace(/_/g, ' ')}`);
56
+ cmd.log(`Kind ${endpoint.kind.replace(PRINT_AGENT_ENDPOINT_RE, ' ')}`);
55
57
  cmd.log(`Endpoint ${describeEndpointState(endpoint)}`);
56
58
  if (endpoint.blocked_by?.remedy) {
57
59
  cmd.log(`Next step ${endpoint.blocked_by.remedy}`);
@@ -55,6 +55,7 @@ const fs = __importStar(require("node:fs"));
55
55
  const path = __importStar(require("node:path"));
56
56
  const data_provider_1 = require("@skrr-ai/data-provider");
57
57
  const http_error_1 = require("./http-error");
58
+ const PICK_RELEASE_RE = /^v/i;
58
59
  /** CLI spelling → API spelling. */
59
60
  exports.EVAL_BASELINE_FLAG_VALUES = {
60
61
  'no-agent': 'no_agent',
@@ -134,7 +135,7 @@ function pickRelease(releases, wanted) {
134
135
  if (!wanted) {
135
136
  return [...releases].sort((a, b) => (b.releaseNumber ?? 0) - (a.releaseNumber ?? 0))[0];
136
137
  }
137
- const label = wanted.replace(/^v/i, '');
138
+ const label = wanted.replace(PICK_RELEASE_RE, '');
138
139
  return releases.find((release) => release.id === wanted || release.versionLabel === label);
139
140
  }
140
141
  /** The planned trials that have no graded result yet, in run order. */
@@ -5,6 +5,15 @@ exports.assertMcpGuideToolReferences = assertMcpGuideToolReferences;
5
5
  const data_provider_1 = require("@skrr-ai/data-provider");
6
6
  const command_miss_1 = require("./command-miss");
7
7
  const command_manifest_1 = require("./command-manifest");
8
+ const COMMAND_WORDS_RE = /\s+/;
9
+ const COMMAND_WORDS_RE_2 = /^[a-z][a-z0-9-]*$/i;
10
+ const COMMAND_CATALOG_RE = /:/g;
11
+ const COMMAND_CATALOG_RE_2 = /^--/;
12
+ const ASSERT_CLI_GUIDE_REFERENCES_RE = /\bskrr(?:\s+[^\s`]+)*/g;
13
+ const IS_TOOL_REFERENCE_RE = /\b(?:call|use|invoke|run)\s*$/i;
14
+ const IS_TOOL_REFERENCE_RE_2 = /\b(?:MCP\s+)?tools?\s*$/i;
15
+ const IS_TOOL_REFERENCE_RE_3 = /^\s*(?:MCP\s+)?tool\b/i;
16
+ const IS_TOOL_REFERENCE_RE_4 = /^\s*(?:[-*]|\d+\.)\s*$/;
8
17
  const FENCE = /^ {0,3}(`{3,}|~{3,})(.*)$/;
9
18
  const INLINE_CODE = /`([^`\n]+)`/g;
10
19
  const FLAG = /(?<!-)--([a-z][a-z0-9-]*)\b/g;
@@ -16,10 +25,10 @@ function location(document, line, problem) {
16
25
  }
17
26
  function commandWords(text) {
18
27
  const words = [];
19
- for (const token of text.trim().split(/\s+/)) {
28
+ for (const token of text.trim().split(COMMAND_WORDS_RE)) {
20
29
  if (token.startsWith('--') || token.startsWith('<') || token.startsWith('['))
21
30
  break;
22
- if (!/^[a-z][a-z0-9-]*$/i.test(token))
31
+ if (!COMMAND_WORDS_RE_2.test(token))
23
32
  break;
24
33
  words.push(token.toLowerCase());
25
34
  }
@@ -59,7 +68,7 @@ function commandCatalog(manifest) {
59
68
  for (const entry of (0, command_manifest_1.visibleCommandEntries)(manifest)) {
60
69
  ids.push(entry.id);
61
70
  for (const name of [entry.command, ...entry.aliases]) {
62
- const words = commandWords(name.replace(/:/g, ' '));
71
+ const words = commandWords(name.replace(COMMAND_CATALOG_RE, ' '));
63
72
  if (words.length)
64
73
  spellings.push({ words, id: entry.id });
65
74
  }
@@ -72,7 +81,7 @@ function commandCatalog(manifest) {
72
81
  if (Array.isArray(aliases)) {
73
82
  for (const alias of aliases) {
74
83
  if (typeof alias === 'string')
75
- flags.add(alias.replace(/^--/, ''));
84
+ flags.add(alias.replace(COMMAND_CATALOG_RE_2, ''));
76
85
  }
77
86
  }
78
87
  }
@@ -83,12 +92,12 @@ function commandCatalog(manifest) {
83
92
  function assertCliGuideReferences(documents, manifest, globalFlags = []) {
84
93
  const catalog = commandCatalog(manifest);
85
94
  for (const flag of globalFlags)
86
- catalog.flags.add(flag.replace(/^--/, ''));
95
+ catalog.flags.add(flag.replace(COMMAND_CATALOG_RE_2, ''));
87
96
  for (const document of documents) {
88
97
  if (document.surface !== 'cli')
89
98
  continue;
90
99
  for (const span of codeSpans(document)) {
91
- for (const match of span.text.matchAll(/\bskrr(?:\s+[^\s`]+)*/g)) {
100
+ for (const match of span.text.matchAll(ASSERT_CLI_GUIDE_REFERENCES_RE)) {
92
101
  const typed = commandWords(match[0].slice('skrr'.length));
93
102
  if (!typed.length)
94
103
  continue;
@@ -103,7 +112,9 @@ function assertCliGuideReferences(documents, manifest, globalFlags = []) {
103
112
  if (catalog.ids.some((known) => known.startsWith(`${id}:`)))
104
113
  continue;
105
114
  const nearest = (0, command_miss_1.nearestCommands)(id, catalog.ids)[0];
106
- throw location(document, span.line, `unknown \`skrr ${typed.join(' ')}\` command${nearest ? `; nearest real command: \`skrr ${nearest.replace(/:/g, ' ')}\`` : ''}`);
115
+ throw location(document, span.line, `unknown \`skrr ${typed.join(' ')}\` command${nearest
116
+ ? `; nearest real command: \`skrr ${nearest.replace(COMMAND_CATALOG_RE, ' ')}\``
117
+ : ''}`);
107
118
  }
108
119
  }
109
120
  for (const source of document.lines) {
@@ -122,12 +133,12 @@ function isToolReference(line, start, end, name, known) {
122
133
  return true;
123
134
  const before = line.slice(0, start);
124
135
  const after = line.slice(end);
125
- return (/\b(?:call|use|invoke|run)\s*$/i.test(before) ||
136
+ return (IS_TOOL_REFERENCE_RE.test(before) ||
126
137
  // "the `x` tool" / "tool `x`": the word must sit beside the name, since a
127
138
  // line that mentions tools elsewhere often names an argument too.
128
- /\b(?:MCP\s+)?tools?\s*$/i.test(before) ||
129
- /^\s*(?:MCP\s+)?tool\b/i.test(after) ||
130
- /^\s*(?:[-*]|\d+\.)\s*$/.test(before));
139
+ IS_TOOL_REFERENCE_RE_2.test(before) ||
140
+ IS_TOOL_REFERENCE_RE_3.test(after) ||
141
+ IS_TOOL_REFERENCE_RE_4.test(before));
131
142
  }
132
143
  function nearestTool(name, names) {
133
144
  return (0, data_provider_1.nearestAgentGuideIds)(name, names, 1)[0] ?? '';
@@ -19,6 +19,7 @@ const http_error_1 = require("./http-error");
19
19
  const keychain_1 = require("./keychain");
20
20
  const config_1 = require("./config");
21
21
  const node_adapter_1 = require("./node-adapter");
22
+ const GUIDE_READ_TELEMETRY_HEADERS_RE = /[\r\n]/;
22
23
  const bundle = agent_guides_json_1.default;
23
24
  /**
24
25
  * An opaque correlation hint for guide-read telemetry. It is not
@@ -31,7 +32,9 @@ exports.GUIDE_READ_CONTEXT_HEADER = 'X-Oversky-Guide-Read-Context';
31
32
  const GUIDE_READ_CONTEXT_MAX_CHARS = 256;
32
33
  function guideReadTelemetryHeaders(env = process.env) {
33
34
  const context = (env.OVERSKY_GUIDE_READ_CONTEXT ?? env.OVERSKY_SESSION_ID ?? '').trim();
34
- if (!context || context.length > GUIDE_READ_CONTEXT_MAX_CHARS || /[\r\n]/.test(context)) {
35
+ if (!context ||
36
+ context.length > GUIDE_READ_CONTEXT_MAX_CHARS ||
37
+ GUIDE_READ_TELEMETRY_HEADERS_RE.test(context)) {
35
38
  return undefined;
36
39
  }
37
40
  return { [exports.GUIDE_READ_CONTEXT_HEADER]: context };
@@ -7,6 +7,7 @@ exports.renderCompositionLines = renderCompositionLines;
7
7
  const data_provider_1 = require("@skrr-ai/data-provider");
8
8
  const agent_resolver_1 = require("./agent-resolver");
9
9
  const instruction_blocks_1 = require("./instruction-blocks");
10
+ const RENDER_COMPOSITION_LINES_RE = /\s+/g;
10
11
  /** Positional and --agent forms agree with the existing `agents tone` UX. */
11
12
  async function resolveInstructionAgentId(argument, flag) {
12
13
  return (0, agent_resolver_1.resolveAgentId)((0, agent_resolver_1.mergeExplicitAgentInputs)([
@@ -36,7 +37,10 @@ function renderCompositionLines(composition) {
36
37
  return composition.entries.flatMap((entry, index) => {
37
38
  const state = entry.enabled ? 'on' : 'off';
38
39
  if (entry.source.kind === 'inline') {
39
- const preview = entry.source.body.trim().replace(/\s+/g, ' ').slice(0, 140);
40
+ const preview = entry.source.body
41
+ .trim()
42
+ .replace(RENDER_COMPOSITION_LINES_RE, ' ')
43
+ .slice(0, 140);
40
44
  return [
41
45
  `${index + 1}. ${state.padEnd(3)} inline ${entry.source.title} (${entry.instanceId})`,
42
46
  ` ${preview || '(empty)'}`,
@@ -9,6 +9,10 @@ exports.shellQuote = shellQuote;
9
9
  const data_provider_1 = require("@skrr-ai/data-provider");
10
10
  const http_error_1 = require("./http-error");
11
11
  const web_url_1 = require("./web-url");
12
+ const RESOLVE_BY_CODE_RE = /_/g;
13
+ const RESOLVE_AGENT_REF_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
14
+ const SHELL_QUOTE_RE = /^[A-Za-z0-9_@%+=:,./-]+$/;
15
+ const SHELL_QUOTE_RE_2 = /'/g;
12
16
  class AgentRefError extends Error {
13
17
  code;
14
18
  constructor(message, code) {
@@ -94,7 +98,7 @@ async function resolveByCode(value, attribution, options) {
94
98
  'unpublished, or the link was copied incompletely.', 'AGENT_REF_CODE_UNRESOLVED');
95
99
  }
96
100
  if (resolved.entity.kind !== 'agent') {
97
- throw new AgentRefError(`"${value}" is a link to a ${resolved.entity.kind.replace(/_/g, ' ')}, not an agent.`, 'AGENT_REF_NOT_AN_AGENT');
101
+ throw new AgentRefError(`"${value}" is a link to a ${resolved.entity.kind.replace(RESOLVE_BY_CODE_RE, ' ')}, not an agent.`, 'AGENT_REF_NOT_AN_AGENT');
98
102
  }
99
103
  return {
100
104
  agentId: resolved.entity.id,
@@ -115,7 +119,7 @@ async function resolveAgentRef(input, options = {}) {
115
119
  firstPartyHosts: cliFirstPartyHosts(options.baseURL),
116
120
  });
117
121
  if (!inspected) {
118
- throw /^[a-z][a-z0-9+.-]*:\/\//i.test(value)
122
+ throw RESOLVE_AGENT_REF_RE.test(value)
119
123
  ? new AgentRefError(`"${value}" is not a ${data_provider_1.BRAND.displayName} link, so it was not followed. Pass an agent ` +
120
124
  `id or a link on ${data_provider_1.BRAND.displayName}'s own site.`, 'AGENT_REF_FOREIGN')
121
125
  : unsupported(value);
@@ -137,7 +141,7 @@ async function resolveAgentRef(input, options = {}) {
137
141
  return resolveByCode(value, attribution, options);
138
142
  throw unsupported(value);
139
143
  default:
140
- throw new AgentRefError(`"${value}" is a link to a ${link.kind.replace(/_/g, ' ')}, not an agent.`, 'AGENT_REF_NOT_AN_AGENT');
144
+ throw new AgentRefError(`"${value}" is a link to a ${link.kind.replace(RESOLVE_BY_CODE_RE, ' ')}, not an agent.`, 'AGENT_REF_NOT_AN_AGENT');
141
145
  }
142
146
  }
143
147
  function unsupported(value) {
@@ -164,5 +168,5 @@ function installAttribution(attribution) {
164
168
  }
165
169
  /** Quote a URL for a POSIX shell: `?` and `&` in an attributed link are metacharacters. */
166
170
  function shellQuote(value) {
167
- return /^[A-Za-z0-9_@%+=:,./-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
171
+ return SHELL_QUOTE_RE.test(value) ? value : `'${value.replace(SHELL_QUOTE_RE_2, `'\\''`)}'`;
168
172
  }
@@ -17,6 +17,7 @@ exports.triggersMissingFromAgentList = triggersMissingFromAgentList;
17
17
  exports.isSuspended = isSuspended;
18
18
  exports.sourceLabel = sourceLabel;
19
19
  exports.systemManagedLegend = systemManagedLegend;
20
+ const IS_SYSTEM_MANAGED_RE = /^commitment-(check|reflect):/;
20
21
  function idOf(row) {
21
22
  return typeof row.id === 'string' ? row.id : '';
22
23
  }
@@ -26,7 +27,7 @@ function scopeKindOf(row) {
26
27
  }
27
28
  /** Created and run by the platform for a Commitment, not authored by the person. */
28
29
  function isSystemManaged(row) {
29
- return row.producerOwned === true || /^commitment-(check|reflect):/.test(idOf(row));
30
+ return row.producerOwned === true || IS_SYSTEM_MANAGED_RE.test(idOf(row));
30
31
  }
31
32
  /**
32
33
  * The universal-list rows the per-agent facade did not return, each tagged `systemManaged`.
@@ -354,6 +354,20 @@ export declare function projectDaemonToolEvents(envelopes: unknown[], namesByCal
354
354
  * fails here instead of silently reverting these calls to `[tool failed]`.
355
355
  */
356
356
  export declare const CODEX_DECLINED_TOOL_OUTPUTS: readonly string[];
357
+ /**
358
+ * The `tool.completed` status a typed operation receipt earns, for an end that names none
359
+ * (OSK-22614).
360
+ *
361
+ * A cloud run's `tool:end` has no `status` field; the daemon-routed path always sets one. So a
362
+ * call that FAILED on the cloud ended as `[tool completed]` here, and `--jsonl` carried the
363
+ * failure only inside `operationOutcome`, where a consumer reading `status` never looked. The
364
+ * receipt is the server's own statement of how the operation ended, so it is read the same way
365
+ * the daemon's status is: failed is failed, and an operation that never ran did not run.
366
+ *
367
+ * `unknown` earns nothing, because nothing is known: that call keeps whatever the end said, which is
368
+ * the status quo, not a claim it succeeded.
369
+ */
370
+ export declare function toolEndStatusFromOutcome(outcome: unknown): string | undefined;
357
371
  /**
358
372
  * The line printed when a tool call ends, in the words its status earns.
359
373
  *
@@ -610,6 +624,8 @@ export declare class AgenticStreamClient {
610
624
  * ran (OSK-22553).
611
625
  */
612
626
  private readonly deniedToolUseIds;
627
+ /** Calls whose denial the terminal already labelled, so the run's own end does not say it twice. */
628
+ private readonly deniedLabelled;
613
629
  private readonly permissionGenerations;
614
630
  private readonly permissionEpochs;
615
631
  /**
@@ -840,6 +856,11 @@ export declare class AgenticStreamClient {
840
856
  */
841
857
  private jsonlView;
842
858
  private emit;
859
+ /**
860
+ * `[tool denied] <tool> (it did not run)`, once per call (OSK-22553). The call's own end prints the
861
+ * same line when the run reports one; this is the line for the runs that never do.
862
+ */
863
+ private writeRefusalLabel;
843
864
  /**
844
865
  * Human-mode lines for the hand-over wait. Returns true when the event is
845
866
  * fully rendered here; false lets the ordinary rendering continue.