@skrr-ai/cli 0.1.146 → 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 (282) hide show
  1. package/dist/base-command.js +38 -21
  2. package/dist/commands/agent/message/send.d.ts +11 -0
  3. package/dist/commands/agent/message/send.js +34 -8
  4. package/dist/commands/agent-worker.js +2 -1
  5. package/dist/commands/agents/activity.js +2 -1
  6. package/dist/commands/agents/badge.js +10 -5
  7. package/dist/commands/agents/categories/index.js +2 -1
  8. package/dist/commands/agents/chat.d.ts +1 -0
  9. package/dist/commands/agents/chat.js +29 -1
  10. package/dist/commands/agents/create.js +4 -1
  11. package/dist/commands/agents/overview.js +2 -1
  12. package/dist/commands/agents/releases/create.js +2 -1
  13. package/dist/commands/agents/schedule-overview.js +3 -1
  14. package/dist/commands/agents/schedule.js +2 -1
  15. package/dist/commands/agents/spawn.js +9 -6
  16. package/dist/commands/agents/tools/auth.js +2 -1
  17. package/dist/commands/agents/tools/calls.js +2 -1
  18. package/dist/commands/agents/visibility.js +2 -1
  19. package/dist/commands/balance/show.js +17 -2
  20. package/dist/commands/balance/statement.js +2 -1
  21. package/dist/commands/commands.js +2 -1
  22. package/dist/commands/commitments/create.js +2 -1
  23. package/dist/commands/commitments/delivery.js +2 -1
  24. package/dist/commands/commitments/doctor.js +2 -1
  25. package/dist/commands/commitments/observations.js +2 -2
  26. package/dist/commands/commitments/operating-review.js +2 -1
  27. package/dist/commands/commitments/pack/preflight.js +2 -1
  28. package/dist/commands/commitments/trigger-status.js +2 -1
  29. package/dist/commands/convos/messages.js +2 -1
  30. package/dist/commands/daemon/logs.js +18 -9
  31. package/dist/commands/daemon/usage.js +2 -1
  32. package/dist/commands/dm/messages.js +2 -1
  33. package/dist/commands/dm/thread/messages.js +2 -1
  34. package/dist/commands/dm/threads.js +2 -1
  35. package/dist/commands/doctor.js +2 -1
  36. package/dist/commands/goals/key-results/assess.js +2 -1
  37. package/dist/commands/goals/key-results/history.js +2 -1
  38. package/dist/commands/harnesses/forget.js +2 -1
  39. package/dist/commands/harnesses/show.js +12 -6
  40. package/dist/commands/inbox/index.js +4 -3
  41. package/dist/commands/initiatives/decide.js +2 -1
  42. package/dist/commands/instructions/diff.js +2 -1
  43. package/dist/commands/instructions/show.js +2 -1
  44. package/dist/commands/login.js +4 -2
  45. package/dist/commands/machines/dedicated/cp.js +2 -1
  46. package/dist/commands/machines/dedicated/power/set.js +2 -1
  47. package/dist/commands/machines/show.js +2 -1
  48. package/dist/commands/memory/maintain.js +2 -1
  49. package/dist/commands/memory/read.js +2 -1
  50. package/dist/commands/memory/rebuild-index.js +2 -1
  51. package/dist/commands/memory/rebuild.js +2 -1
  52. package/dist/commands/memory/search.js +2 -1
  53. package/dist/commands/messages/list.js +2 -1
  54. package/dist/commands/revoke-daemon.js +2 -1
  55. package/dist/commands/revoke-token.js +2 -1
  56. package/dist/commands/search/all.js +14 -7
  57. package/dist/commands/search/workspace.js +2 -1
  58. package/dist/commands/set-capabilities.js +2 -1
  59. package/dist/commands/skills/browse.js +8 -2
  60. package/dist/commands/spaces/auto-executor/preview.js +3 -2
  61. package/dist/commands/spaces/auto-executor/runs.js +4 -1
  62. package/dist/commands/spaces/workflow-templates/extract.d.ts +1 -0
  63. package/dist/commands/spaces/workflow-templates/extract.js +9 -1
  64. package/dist/commands/spaces/workflows/events.js +6 -3
  65. package/dist/commands/spaces/workflows/run.js +5 -3
  66. package/dist/commands/spaces/workflows/update.js +2 -1
  67. package/dist/commands/store/gallery-admissions/preview.js +2 -1
  68. package/dist/commands/store/publishers/profile/handle.js +2 -1
  69. package/dist/commands/tasks/comments/anchor.js +23 -9
  70. package/dist/commands/tasks/complete.js +4 -2
  71. package/dist/commands/tasks/create-tree.js +7 -3
  72. package/dist/commands/tasks/create.js +2 -1
  73. package/dist/commands/tasks/deliverable/add.js +2 -1
  74. package/dist/commands/tasks/deliverable/archive.js +2 -1
  75. package/dist/commands/tasks/deliverable/list.js +2 -1
  76. package/dist/commands/tasks/expectations/assess.js +2 -1
  77. package/dist/commands/tasks/labels/create.js +2 -1
  78. package/dist/commands/tasks/preflight.js +4 -2
  79. package/dist/commands/tasks/ready.js +2 -1
  80. package/dist/commands/tasks/result/submit.js +2 -1
  81. package/dist/commands/tasks/updates/add.js +2 -1
  82. package/dist/commands/tasks/wait.js +2 -1
  83. package/dist/commands/token/list.js +2 -1
  84. package/dist/commands/token/mint.js +2 -1
  85. package/dist/commands/wiki/write.js +14 -7
  86. package/dist/hooks/command-not-found.js +2 -1
  87. package/dist/lib/agent-chat-start.d.ts +77 -0
  88. package/dist/lib/agent-chat-start.js +169 -0
  89. package/dist/lib/agent-config.js +2 -1
  90. package/dist/lib/agent-endpoints.js +4 -2
  91. package/dist/lib/agent-evals.js +2 -1
  92. package/dist/lib/agent-guide-reference-gate.js +22 -11
  93. package/dist/lib/agent-guides.js +4 -1
  94. package/dist/lib/agent-instructions.js +5 -1
  95. package/dist/lib/agent-ref.js +8 -4
  96. package/dist/lib/agent-trigger-listing.js +2 -1
  97. package/dist/lib/agentic-stream.js +8 -5
  98. package/dist/lib/api-error-reason.js +2 -1
  99. package/dist/lib/api-fetch.js +5 -3
  100. package/dist/lib/appData.js +6 -6
  101. package/dist/lib/appInstallations.js +10 -5
  102. package/dist/lib/appsCheck.js +2 -1
  103. package/dist/lib/auth-failure.js +2 -1
  104. package/dist/lib/auth-storage.js +2 -1
  105. package/dist/lib/balance.js +6 -3
  106. package/dist/lib/capability-matrix.js +4 -2
  107. package/dist/lib/cli-runtime.js +2 -1
  108. package/dist/lib/code-handover.js +8 -3
  109. package/dist/lib/command-hygiene.js +28 -12
  110. package/dist/lib/command-manifest.js +6 -3
  111. package/dist/lib/commitment-attention-copy.js +2 -1
  112. package/dist/lib/commitment-event-wakes.js +9 -0
  113. package/dist/lib/commitment-product.js +5 -3
  114. package/dist/lib/commitment-terms.js +2 -1
  115. package/dist/lib/commitments.d.ts +8 -0
  116. package/dist/lib/commitments.js +8 -4
  117. package/dist/lib/compasses.js +2 -1
  118. package/dist/lib/completion-index.js +2 -1
  119. package/dist/lib/computer-files.js +8 -6
  120. package/dist/lib/config.js +11 -5
  121. package/dist/lib/conversation-search.js +4 -2
  122. package/dist/lib/daemon-installer.js +6 -2
  123. package/dist/lib/daemon-maintenance.js +2 -1
  124. package/dist/lib/daemon-ref.js +2 -1
  125. package/dist/lib/daemonBroker.js +6 -3
  126. package/dist/lib/daemonBrokerRefusal.js +4 -2
  127. package/dist/lib/daemonHandoff.js +14 -7
  128. package/dist/lib/daemonIslandProfile.js +2 -1
  129. package/dist/lib/dedicated-copy.js +9 -3
  130. package/dist/lib/dedicated-exec.js +2 -1
  131. package/dist/lib/dedicated-keep-awake.js +2 -1
  132. package/dist/lib/dedicated-machines.js +9 -5
  133. package/dist/lib/dedicated-service.js +2 -1
  134. package/dist/lib/dedicated-ssh.js +5 -3
  135. package/dist/lib/deployed-build.js +2 -1
  136. package/dist/lib/device-code.js +4 -3
  137. package/dist/lib/dpop-auth.js +2 -1
  138. package/dist/lib/earnings.js +2 -1
  139. package/dist/lib/exec-runtime-binary.js +5 -3
  140. package/dist/lib/first-party-harness-broker.js +4 -3
  141. package/dist/lib/first-party-harness-managed.js +2 -1
  142. package/dist/lib/first-party-harness-startup-update.js +8 -4
  143. package/dist/lib/first-party-harness-update.js +2 -1
  144. package/dist/lib/first-party-harness.js +2 -1
  145. package/dist/lib/format.js +8 -4
  146. package/dist/lib/git-task.js +10 -5
  147. package/dist/lib/github-tools.js +6 -3
  148. package/dist/lib/harnesses.js +4 -2
  149. package/dist/lib/hosted-machines.js +2 -1
  150. package/dist/lib/html-text.js +33 -16
  151. package/dist/lib/instruction-blocks.js +2 -1
  152. package/dist/lib/iso-instant.js +5 -3
  153. package/dist/lib/keychain.js +15 -5
  154. package/dist/lib/label-scope.js +2 -1
  155. package/dist/lib/live-runtime-binary.js +10 -7
  156. package/dist/lib/local-skills.js +10 -6
  157. package/dist/lib/login.js +3 -2
  158. package/dist/lib/machine-audit.js +2 -1
  159. package/dist/lib/machine-daemon-log.js +2 -1
  160. package/dist/lib/machine-services.js +2 -1
  161. package/dist/lib/memory-history-session.js +2 -1
  162. package/dist/lib/memory-sync.js +6 -2
  163. package/dist/lib/message-intent.d.ts +10 -0
  164. package/dist/lib/node-adapter.js +4 -2
  165. package/dist/lib/northstars.js +4 -2
  166. package/dist/lib/oauthLogin.js +16 -7
  167. package/dist/lib/open-target.js +8 -4
  168. package/dist/lib/option-hint.js +2 -4
  169. package/dist/lib/outbox.js +2 -1
  170. package/dist/lib/planOutcome.d.ts +5 -3
  171. package/dist/lib/planOutcome.js +7 -4
  172. package/dist/lib/platform-update-local.js +2 -3
  173. package/dist/lib/rate-limit-retry.js +2 -1
  174. package/dist/lib/reflection.js +2 -1
  175. package/dist/lib/request-field-flags.js +2 -1
  176. package/dist/lib/runtime-start-verification.js +2 -1
  177. package/dist/lib/schedule.js +2 -1
  178. package/dist/lib/scoped-memory-command.js +7 -3
  179. package/dist/lib/search-display.js +11 -4
  180. package/dist/lib/skill-store-pagination.js +2 -1
  181. package/dist/lib/space-notebook.js +5 -3
  182. package/dist/lib/store-listing.js +2 -1
  183. package/dist/lib/task-agent-context-capabilities.js +2 -1
  184. package/dist/lib/task-asset-upload.js +7 -3
  185. package/dist/lib/task-closure.js +2 -1
  186. package/dist/lib/task-economics.js +2 -1
  187. package/dist/lib/task-execution.js +16 -8
  188. package/dist/lib/task-extras.js +4 -2
  189. package/dist/lib/task-operation-watch.js +2 -1
  190. package/dist/lib/task-preflight.js +3 -2
  191. package/dist/lib/task-recurrence-summary.js +4 -2
  192. package/dist/lib/task-runtime-headers.js +10 -5
  193. package/dist/lib/task-transcript.js +3 -2
  194. package/dist/lib/task-transfer.js +9 -5
  195. package/dist/lib/tasks.js +2 -1
  196. package/dist/lib/triggers.d.ts +15 -0
  197. package/dist/lib/triggers.js +32 -3
  198. package/dist/lib/update-check.js +12 -7
  199. package/dist/lib/usage-discovery.js +2 -1
  200. package/dist/lib/usd-micros.js +2 -1
  201. package/dist/lib/web-url.js +2 -1
  202. package/dist/lib/widgetCheck.js +15 -9
  203. package/dist/lib/widgetStaticScan.js +26 -14
  204. package/dist/lib/workflow-run-view.js +5 -3
  205. package/dist/lib/workflow-templates.d.ts +10 -0
  206. package/dist/lib/workflow-templates.js +47 -0
  207. package/dist/lib/write-target.js +4 -5
  208. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/authHelper.js +2 -1
  209. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/commitmentExecutionContract.js +22 -12
  210. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/computerUse.js +4 -1
  211. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelope.js +7 -2
  212. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -3
  213. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonConsentProof.js +2 -1
  214. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonPair.js +16 -7
  215. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +4 -1
  216. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/desktopDaemonProof.js +4 -3
  217. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/desktopWire.js +2 -1
  218. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +11 -7
  219. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceKey.js +7 -2
  220. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dpop.js +8 -3
  221. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +2 -1
  222. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessChannels.js +4 -3
  223. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.js +2 -1
  224. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/githubPushRefusal.js +4 -3
  225. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/guidedUpdate.js +2 -1
  226. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/independentMachineReservation.js +8 -3
  227. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/kek/macos.js +4 -2
  228. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/liveState.js +4 -2
  229. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/loginWithLocalhost.js +2 -1
  230. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/loopbackHttp.js +2 -1
  231. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/machineUuid.js +4 -2
  232. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileStateDir.js +2 -1
  233. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/recoveryCode.js +2 -1
  234. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +3 -2
  235. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releasePolicy.js +2 -1
  236. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releaseVersions.js +6 -4
  237. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/restartArtifact.js +2 -1
  238. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/spawnEnv.js +2 -1
  239. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/telemetryRedaction.js +7 -4
  240. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.js +2 -1
  241. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/authHelper.js +2 -1
  242. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/commitmentExecutionContract.js +27 -18
  243. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/computerUse.js +6 -3
  244. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelope.js +11 -2
  245. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +6 -3
  246. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonConsentProof.js +2 -1
  247. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonPair.js +20 -8
  248. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +5 -4
  249. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/desktopDaemonProof.js +4 -3
  250. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/desktopWire.js +2 -1
  251. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +11 -7
  252. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceKey.js +11 -2
  253. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dpop.js +12 -3
  254. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +2 -1
  255. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessChannels.js +4 -3
  256. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.js +2 -1
  257. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/githubPushRefusal.js +4 -3
  258. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/guidedUpdate.js +5 -1
  259. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/independentMachineReservation.js +10 -5
  260. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/kek/macos.js +4 -2
  261. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/liveState.js +4 -2
  262. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/loginWithLocalhost.js +2 -1
  263. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/loopbackHttp.js +2 -1
  264. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/machineUuid.js +4 -2
  265. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileStateDir.js +2 -1
  266. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/recoveryCode.js +2 -1
  267. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +3 -2
  268. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releasePolicy.js +2 -1
  269. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releaseVersions.js +6 -4
  270. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/restartArtifact.js +2 -1
  271. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/spawnEnv.js +2 -1
  272. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/telemetryRedaction.js +11 -5
  273. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.js +2 -1
  274. package/dist/node_modules/@skrr-ai/auth-core/package.json +1 -1
  275. package/dist/node_modules/@skrr-ai/data-provider/index.js +20519 -20130
  276. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.js +4 -2
  277. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +10 -6
  278. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.js +4 -2
  279. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +10 -6
  280. package/dist/node_modules/@skrr-ai/inference-broker/package.json +1 -1
  281. package/oclif.manifest.json +17 -2
  282. package/package.json +1 -1
@@ -40,6 +40,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
40
40
  const base_command_1 = require("../../../base-command");
41
41
  const task_resolver_1 = require("../../../lib/task-resolver");
42
42
  const task_asset_upload_1 = require("../../../lib/task-asset-upload");
43
+ const CLASSIFY_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
43
44
  /**
44
45
  * `skrr tasks deliverable archive <task>`
45
46
  *
@@ -178,7 +179,7 @@ function classify(row, maxBytes) {
178
179
  if (!identity) {
179
180
  return { ...base, reason: 'no coordinate to resolve' };
180
181
  }
181
- if (/^[a-z][a-z0-9+.-]*:\/\//i.test(row.location || identity)) {
182
+ if (CLASSIFY_RE.test(row.location || identity)) {
182
183
  return { ...base, reason: 'remote locator — nothing local to archive' };
183
184
  }
184
185
  for (const candidate of [row.location, identity]) {
@@ -6,6 +6,7 @@ const core_1 = require("@oclif/core");
6
6
  const data_provider_1 = require("@skrr-ai/data-provider");
7
7
  const base_command_1 = require("../../../base-command");
8
8
  const task_resolver_1 = require("../../../lib/task-resolver");
9
+ const VERSION_LABEL_RE = /^wrv_/;
9
10
  /**
10
11
  * `locator_only` is the storage word, and it appeared on nearly every row with
11
12
  * nothing saying what it meant. It is not a defect — it is the honest statement
@@ -36,7 +37,7 @@ function versionLabel(item) {
36
37
  const [algo, hex] = item.contentDigest.split(':');
37
38
  return `digest ${algo}:${(hex || '').slice(0, 12)}`;
38
39
  }
39
- const id = (item.resourceVersionId || '').replace(/^wrv_/, '');
40
+ const id = (item.resourceVersionId || '').replace(VERSION_LABEL_RE, '');
40
41
  return id ? `version ${id.slice(0, 12)}` : 'version unpinned';
41
42
  }
42
43
  /**
@@ -8,6 +8,7 @@ const task_resolver_1 = require("../../../lib/task-resolver");
8
8
  const api_fetch_1 = require("../../../lib/api-fetch");
9
9
  const session_task_write_1 = require("../../../lib/session-task-write");
10
10
  const task_write_attribution_1 = require("../../../lib/task-write-attribution");
11
+ const RUN_RE = /^https?:|^file:/;
11
12
  class TasksExpectationsAssess extends base_command_1.BaseCommand {
12
13
  static description = 'Assess one current Task Expectation with evidence and a reason';
13
14
  // Both positionals are declared optional because oclif REJECTS an args table
@@ -114,7 +115,7 @@ class TasksExpectationsAssess extends base_command_1.BaseCommand {
114
115
  this.error('--evidence must be <kind>:<id-or-uri>', { exit: 1 });
115
116
  const kind = raw.slice(0, split);
116
117
  const value = raw.slice(split + 1);
117
- return /^https?:|^file:/.test(value) ? { kind, uri: value } : { kind, id: value };
118
+ return RUN_RE.test(value) ? { kind, uri: value } : { kind, id: value };
118
119
  });
119
120
  const payload = {
120
121
  decision: flags.decision,
@@ -5,6 +5,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const base_command_1 = require("../../../base-command");
6
6
  const prompt_1 = require("../../../lib/prompt");
7
7
  const label_scope_1 = require("../../../lib/label-scope");
8
+ const RUN_RE = /^#/;
8
9
  // Accept both `#e11d48` and `e11d48` forms; the server's Zod regex
9
10
  // (`api/server/routes/tasks.js:206`) is `/^[0-9a-fA-F]{6}$/` — NO leading
10
11
  // `#`. We normalize before sending so users can pass either form.
@@ -52,7 +53,7 @@ class TasksLabelsCreate extends base_command_1.BaseCommand {
52
53
  this.error(`Invalid color "${String(payload.color)}". Must be a 6-digit hex color, e.g. e11d48.`, { exit: 1 });
53
54
  }
54
55
  // Strip the optional leading '#' — server Zod rejects it.
55
- payload.color = payload.color.replace(/^#/, '');
56
+ payload.color = payload.color.replace(RUN_RE, '');
56
57
  }
57
58
  let result;
58
59
  try {
@@ -5,6 +5,8 @@ const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const base_command_1 = require("../../base-command");
6
6
  const task_resolver_1 = require("../../lib/task-resolver");
7
7
  const task_preflight_1 = require("../../lib/task-preflight");
8
+ const RUN_RE = /^[A-Z]+-\d+$/i;
9
+ const RUN_RE_2 = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
8
10
  class TasksPreflight extends base_command_1.BaseCommand {
9
11
  static description = 'Inspect workflow blockers and execution prerequisites without starting work or probing a machine';
10
12
  static args = {
@@ -40,7 +42,7 @@ class TasksPreflight extends base_command_1.BaseCommand {
40
42
  // Native endpoints accept identifiers, so BaseCommand intentionally keeps
41
43
  // OSK-123 unchanged. Correlating two diagnostic records needs the returned
42
44
  // canonical identity; UUID/title-resolved callers keep their request count.
43
- if (/^[A-Z]+-\d+$/i.test(taskId)) {
45
+ if (RUN_RE.test(taskId)) {
44
46
  let task;
45
47
  try {
46
48
  task = await data_provider_1.dataService.getTask(taskId, { enrich: false });
@@ -48,7 +50,7 @@ class TasksPreflight extends base_command_1.BaseCommand {
48
50
  catch (error) {
49
51
  this.handleApiError(error);
50
52
  }
51
- if (typeof task?.id !== 'string' || !/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i.test(task.id) ||
53
+ if (typeof task?.id !== 'string' || !RUN_RE_2.test(task.id) ||
52
54
  (task.identifier !== undefined && (typeof task.identifier !== 'string' || task.identifier.toUpperCase() !== taskId.toUpperCase()))) {
53
55
  this.failWithCliError({
54
56
  code: 'TASK_PREFLIGHT_IDENTITY_UNCONFIRMED',
@@ -6,6 +6,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
6
6
  const base_command_1 = require("../../base-command");
7
7
  const format_1 = require("../../lib/format");
8
8
  const web_url_1 = require("../../lib/web-url");
9
+ const CLARIFY_MISSING_REQUIRED_FLAG_RE = /Missing required flag ([A-Za-z0-9][\w-]*)$/gm;
9
10
  /**
10
11
  * Repair oclif's required-flag copy for a flag named after a preposition. (S4 dogfood finding)
11
12
  *
@@ -29,7 +30,7 @@ const web_url_1 = require("../../lib/web-url");
29
30
  * actually harmful.
30
31
  */
31
32
  function clarifyMissingRequiredFlag(message) {
32
- return message.replace(/Missing required flag ([A-Za-z0-9][\w-]*)$/gm, (_full, name) => `Missing required flag --${name}`);
33
+ return message.replace(CLARIFY_MISSING_REQUIRED_FLAG_RE, (_full, name) => `Missing required flag --${name}`);
33
34
  }
34
35
  class TasksReady extends base_command_1.BaseCommand {
35
36
  static description = 'List tasks ready for a Human or Agent, using server-owned readiness';
@@ -10,6 +10,7 @@ const api_fetch_1 = require("../../../lib/api-fetch");
10
10
  const task_closure_1 = require("../../../lib/task-closure");
11
11
  const session_task_write_1 = require("../../../lib/session-task-write");
12
12
  const task_write_attribution_1 = require("../../../lib/task-write-attribution");
13
+ const RUN_RE = /^https?:|^file:/;
13
14
  function parseJson(value, label) {
14
15
  if (!value)
15
16
  return undefined;
@@ -93,7 +94,7 @@ class TasksResultSubmit extends base_command_1.BaseCommand {
93
94
  this.error('--evidence must be <kind>:<id-or-uri>', { exit: 1 });
94
95
  const kind = raw.slice(0, split);
95
96
  const value = raw.slice(split + 1);
96
- return /^https?:|^file:/.test(value) ? { kind, uri: value } : { kind, id: value };
97
+ return RUN_RE.test(value) ? { kind, uri: value } : { kind, id: value };
97
98
  });
98
99
  // --attach: upload first so the Result cites real asset ids. Uploads land
99
100
  // before the idempotency key is derived, so a retry sees the same refs.
@@ -7,6 +7,7 @@ const base_command_1 = require("../../../base-command");
7
7
  const task_resolver_1 = require("../../../lib/task-resolver");
8
8
  const api_fetch_1 = require("../../../lib/api-fetch");
9
9
  const session_task_write_1 = require("../../../lib/session-task-write");
10
+ const RUN_RE = /^https?:|^file:/;
10
11
  function parseJsonObject(value, label) {
11
12
  if (!value)
12
13
  return undefined;
@@ -104,7 +105,7 @@ class TasksUpdatesAdd extends base_command_1.BaseCommand {
104
105
  this.error('--reference must be <kind>:<id-or-uri>', { exit: 1 });
105
106
  const kind = raw.slice(0, split);
106
107
  const value = raw.slice(split + 1);
107
- return /^https?:|^file:/.test(value) ? { kind, uri: value } : { kind, id: value };
108
+ return RUN_RE.test(value) ? { kind, uri: value } : { kind, id: value };
108
109
  });
109
110
  // --attach: upload first so the Update can cite the asset ids. For
110
111
  // finding/verification the citation lands in data.evidenceRefs where the
@@ -4,6 +4,7 @@ const core_1 = require("@oclif/core");
4
4
  const base_command_1 = require("../../base-command");
5
5
  const task_resolver_1 = require("../../lib/task-resolver");
6
6
  const task_execution_1 = require("../../lib/task-execution");
7
+ const PARSE_DURATION_MS_RE = /^(\d+)(ms|s|m|h)?$/i;
7
8
  class TasksWait extends base_command_1.BaseCommand {
8
9
  static description = 'Wait for task executions to reach a target status';
9
10
  static examples = [
@@ -129,7 +130,7 @@ function formatProgress(snapshot) {
129
130
  function parseDurationMs(value) {
130
131
  if (!value)
131
132
  return null;
132
- const match = value.trim().match(/^(\d+)(ms|s|m|h)?$/i);
133
+ const match = value.trim().match(PARSE_DURATION_MS_RE);
133
134
  if (!match)
134
135
  throw new Error(`Invalid --timeout value: ${value}`);
135
136
  const amount = Number(match[1]);
@@ -5,6 +5,7 @@ const core_1 = require("@oclif/core");
5
5
  const base_command_1 = require("../../base-command");
6
6
  const api_fetch_1 = require("../../lib/api-fetch");
7
7
  const format_1 = require("../../lib/format");
8
+ const RUN_RE = /^[a-fA-F0-9]{24}$/;
8
9
  const SESSION_KINDS = ['web', 'daemon', 'cli', 'ci'];
9
10
  /**
10
11
  * `skrr token list`
@@ -83,7 +84,7 @@ class TokenList extends base_command_1.BaseCommand {
83
84
  break;
84
85
  const next = page?.nextCursor;
85
86
  if (typeof next !== 'string' ||
86
- !/^[a-fA-F0-9]{24}$/.test(next) ||
87
+ !RUN_RE.test(next) ||
87
88
  seenCursors.has(next) ||
88
89
  rows.length === 0) {
89
90
  cannotPage = true;
@@ -4,6 +4,7 @@ const core_1 = require("@oclif/core");
4
4
  const base_command_1 = require("../../base-command");
5
5
  const api_fetch_1 = require("../../lib/api-fetch");
6
6
  const device_id_1 = require("../../lib/device-id");
7
+ const RUN_RE = /'/g;
7
8
  /**
8
9
  * `skrr token mint`
9
10
  *
@@ -117,7 +118,7 @@ class TokenMint extends base_command_1.BaseCommand {
117
118
  }
118
119
  // shell
119
120
  for (const [k, v] of pairs) {
120
- const escaped = v.replace(/'/g, "'\\''");
121
+ const escaped = v.replace(RUN_RE, "'\\''");
121
122
  this.log(`export ${k}='${escaped}'`);
122
123
  }
123
124
  }
@@ -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. */