@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
@@ -94,6 +94,39 @@ export interface PlanProactiveAgentResponse {
94
94
  outputTokens: number;
95
95
  };
96
96
  }
97
+ /**
98
+ * The `202` a `Prefer: respond-async` spawn apply answers when the install outlived the server's short
99
+ * wait: the install is running and was not cut short. NOT a receipt. The edge gives up at 60 s and an
100
+ * install takes longer, so a caller that asks this way follows the operation instead of reading a 504
101
+ * for an install that completed (OSK-22623).
102
+ */
103
+ export interface SpawnAccepted {
104
+ accepted: true;
105
+ operation: {
106
+ id: string;
107
+ state: 'running';
108
+ startedAt?: string;
109
+ };
110
+ message?: string;
111
+ }
112
+ export declare function isSpawnAccepted(value: unknown): value is SpawnAccepted;
113
+ /** A spawn operation as `GET /api/initiatives/spawn/operations/:id` reads it. */
114
+ export interface SpawnOperation {
115
+ id: string;
116
+ state: 'running' | 'succeeded' | 'failed' | 'unknown';
117
+ startedAt?: string;
118
+ finishedAt?: string;
119
+ agentId?: string;
120
+ result?: ApplyProactiveAgentResponse;
121
+ failure?: {
122
+ status?: number;
123
+ body?: {
124
+ error?: string;
125
+ message?: string;
126
+ code?: string;
127
+ };
128
+ };
129
+ }
97
130
  /** One object a spec will install (`POST /api/initiatives/spawn/preview`). */
98
131
  export interface InstallPlanItem {
99
132
  kind: string;
@@ -335,7 +368,11 @@ export declare const proactiveApi: {
335
368
  minimal?: boolean;
336
369
  /** Decline one default by name (see `DECLINABLE_DEFAULTS`). */
337
370
  without?: string[];
338
- }) => Promise<ApplyProactiveAgentResponse>;
371
+ }) => Promise<ApplyProactiveAgentResponse | SpawnAccepted>;
372
+ /** The receipt (or failure) of a spawn that answered 202. */
373
+ spawnOperation: (operationId: string) => Promise<{
374
+ operation: SpawnOperation;
375
+ }>;
339
376
  /** Read-only: every object a spec will install, marked requested or default. Never writes. */
340
377
  previewProactiveAgentSpec: (body: {
341
378
  spec: ProactiveAgentSpec;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.proactiveApi = exports.DECLINABLE_DEFAULTS = void 0;
4
+ exports.isSpawnAccepted = isSpawnAccepted;
4
5
  /**
5
6
  * proactiveApi.ts — request-based client for the "spawn a proactive agent"
6
7
  * endpoints (`/api/initiatives/spawn/*`).
@@ -15,6 +16,13 @@ exports.proactiveApi = exports.DECLINABLE_DEFAULTS = void 0;
15
16
  * → review → `apply` (creates the agent + installs the chosen system[s]).
16
17
  */
17
18
  const data_provider_1 = require("@skrr-ai/data-provider");
19
+ function isSpawnAccepted(value) {
20
+ const candidate = value;
21
+ return (Boolean(candidate) &&
22
+ typeof candidate === 'object' &&
23
+ candidate.accepted === true &&
24
+ typeof candidate.operation?.id === 'string');
25
+ }
18
26
  /** The defaults `--without` can decline; the server refuses any other name. */
19
27
  exports.DECLINABLE_DEFAULTS = [
20
28
  'memory_watcher',
@@ -26,7 +34,15 @@ exports.proactiveApi = {
26
34
  /** Plan-only: turn a sentence into a spec draft. Never writes. */
27
35
  planProactiveAgent: (body) => data_provider_1.request.post('/api/initiatives/spawn/plan', body),
28
36
  /** Apply a (clamped, server-re-validated) spec: create + install. */
29
- applyProactiveAgentSpec: (body) => data_provider_1.request.post('/api/initiatives/spawn/apply', body),
37
+ applyProactiveAgentSpec: (body) =>
38
+ // `Prefer: respond-async` (RFC 7240): an install outlives the edge's 60 s, so once it has run a
39
+ // short while the server answers 202 with an operation to follow and keeps installing. A server
40
+ // that predates it ignores the header and answers as it always did.
41
+ data_provider_1.request.postWithOptions('/api/initiatives/spawn/apply', body, {
42
+ headers: { Prefer: 'respond-async' },
43
+ }),
44
+ /** The receipt (or failure) of a spawn that answered 202. */
45
+ spawnOperation: (operationId) => data_provider_1.request.get(`/api/initiatives/spawn/operations/${encodeURIComponent(operationId)}`),
30
46
  /** Read-only: every object a spec will install, marked requested or default. Never writes. */
31
47
  previewProactiveAgentSpec: (body) => data_provider_1.request.post('/api/initiatives/spawn/preview', body),
32
48
  /** Meta-agent path: plan and persist a reviewable recommendation. */
@@ -27,6 +27,7 @@ exports.rateLimitWaitMs = rateLimitWaitMs;
27
27
  exports.maxRateLimitRetries = maxRateLimitRetries;
28
28
  exports.isRateLimitRetrySafe = isRateLimitRetrySafe;
29
29
  exports.fetchWithRateLimitRetry = fetchWithRateLimitRetry;
30
+ const PARSE_RETRY_AFTER_MS_RE = /^\d+(\.\d+)?$/;
30
31
  exports.DEFAULT_MAX_RATE_LIMIT_RETRIES = 2;
31
32
  exports.MAX_RATE_LIMIT_WAIT_MS = 10_000;
32
33
  const MIN_WAIT_MS = 250;
@@ -35,7 +36,7 @@ function parseRetryAfterMs(value, now = Date.now()) {
35
36
  if (!value)
36
37
  return undefined;
37
38
  const trimmed = value.trim();
38
- if (/^\d+(\.\d+)?$/.test(trimmed))
39
+ if (PARSE_RETRY_AFTER_MS_RE.test(trimmed))
39
40
  return Math.round(Number(trimmed) * 1000);
40
41
  const at = Date.parse(trimmed);
41
42
  if (Number.isNaN(at))
@@ -36,6 +36,7 @@ exports.buildReflectionTriggerPayload = buildReflectionTriggerPayload;
36
36
  * reuse the exact same prompt, cadence bounds, and payload shape.
37
37
  */
38
38
  const triggers_1 = require("./triggers");
39
+ const PARSE_CADENCE_TO_MINUTES_RE = /^\d+(\.\d+)?$/;
39
40
  /** Stable label used to locate an agent's single self-reflection trigger. */
40
41
  exports.REFLECTION_LABEL = 'self-reflection';
41
42
  /** Default cadence: reflect every 6 hours. */
@@ -109,7 +110,7 @@ function parseCadenceToMinutes(input) {
109
110
  throw new InvalidCadenceError('Empty cadence. Use a form like "6h", "90m", "2h30m", or "360".');
110
111
  }
111
112
  // Bare number → minutes.
112
- if (/^\d+(\.\d+)?$/.test(raw)) {
113
+ if (PARSE_CADENCE_TO_MINUTES_RE.test(raw)) {
113
114
  return requirePositiveMinutes(Math.round(Number(raw)), raw);
114
115
  }
115
116
  if (!CADENCE_FULL.test(raw)) {
@@ -15,8 +15,9 @@
15
15
  */
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.translateRequestFieldPaths = translateRequestFieldPaths;
18
+ const ESCAPE_REG_EXP_RE = /[.*+?^${}()|[\]\\]/g;
18
19
  function escapeRegExp(value) {
19
- return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
20
+ return value.replace(ESCAPE_REG_EXP_RE, '\\$&');
20
21
  }
21
22
  /**
22
23
  * Replace every declared body path in `message` with its flag. Longest path first, so
@@ -7,6 +7,7 @@ exports.daemonLoginRecoveryCommand = daemonLoginRecoveryCommand;
7
7
  exports.verifyRuntimeStart = verifyRuntimeStart;
8
8
  const auth_core_1 = require("@skrr-ai/auth-core");
9
9
  const keychain_1 = require("./keychain");
10
+ const QUOTE_SHELL_ARG_RE = /^[A-Za-z0-9_./:@+=-]+$/;
10
11
  /** Matches the runtime's EX_CONFIG result for a permanent local configuration failure. */
11
12
  exports.DAEMON_START_REAUTH_EXIT = 78;
12
13
  /** Matches the runtime's EX_TEMPFAIL result when a service cannot remain running. */
@@ -23,7 +24,7 @@ function profileFromArgv(argv) {
23
24
  return (0, keychain_1.profileForChildProcess)(argv);
24
25
  }
25
26
  function quoteShellArg(value) {
26
- return /^[A-Za-z0-9_./:@+=-]+$/.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
27
+ return QUOTE_SHELL_ARG_RE.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
27
28
  }
28
29
  /**
29
30
  * The status probe must observe the same profile as the start request. A
@@ -17,6 +17,10 @@ export interface TodoCommitmentRef {
17
17
  versionSnapshot: number;
18
18
  actionReason?: string;
19
19
  }
20
+ export interface TodoLateness {
21
+ bySeconds: number;
22
+ message: string;
23
+ }
20
24
  export interface Todo {
21
25
  id: string;
22
26
  agentId: string;
@@ -26,6 +30,11 @@ export interface Todo {
26
30
  timezone?: string;
27
31
  durationMinutes: number;
28
32
  status: TodoStatus;
33
+ /**
34
+ * Present only on a `pending` To-Do that is more than a minute past its `runAt`: it is armed
35
+ * and the scheduler has not fired it yet (OSK-22619). `status` stays `pending`.
36
+ */
37
+ late?: TodoLateness;
29
38
  source: TodoSource;
30
39
  rationale?: string;
31
40
  confidence?: TodoConfidence;
@@ -379,6 +388,12 @@ export declare function describeNonProposal(value: unknown): string;
379
388
  export declare function describePlanRequest(request: SmartSchedulePlanRequest | null | undefined, now?: Date): string | null;
380
389
  /** Explain terminal policy outcomes without changing the machine-readable status. */
381
390
  export declare function todoPolicyBlockMessage(reason?: string): string | undefined;
391
+ /**
392
+ * One line for a pending To-Do the scheduler has not fired though its time passed, or undefined.
393
+ * The STATUS column keeps saying `pending` (it is the machine-readable state); this is the part a
394
+ * person needs, which is that "pending" here no longer means "not yet".
395
+ */
396
+ export declare function todoLateMessage(todo: Pick<Todo, 'status' | 'late'>): string | undefined;
382
397
  /** Print explanations alongside the trace rows that recorded policy blocks. */
383
398
  export declare function renderTodoPolicyTraceDetails(events: ScheduleTraceEvent[], log: (line: string) => void): void;
384
399
  /**
@@ -13,6 +13,7 @@ exports.isSmartScheduleProposal = isSmartScheduleProposal;
13
13
  exports.describeNonProposal = describeNonProposal;
14
14
  exports.describePlanRequest = describePlanRequest;
15
15
  exports.todoPolicyBlockMessage = todoPolicyBlockMessage;
16
+ exports.todoLateMessage = todoLateMessage;
16
17
  exports.renderTodoPolicyTraceDetails = renderTodoPolicyTraceDetails;
17
18
  exports.renderTodoList = renderTodoList;
18
19
  exports.renderCapacityWarning = renderCapacityWarning;
@@ -45,6 +46,7 @@ exports.formatStamp = formatStamp;
45
46
  const data_provider_1 = require("@skrr-ai/data-provider");
46
47
  const format_1 = require("./format");
47
48
  const triggers_1 = require("./triggers");
49
+ const RENDER_PROPOSAL_RE = / 00:00:00 /;
48
50
  function isPlanAccepted(value) {
49
51
  return (Boolean(value) &&
50
52
  typeof value === 'object' &&
@@ -243,6 +245,16 @@ function todoPolicyBlockMessage(reason) {
243
245
  return undefined;
244
246
  }
245
247
  }
248
+ /**
249
+ * One line for a pending To-Do the scheduler has not fired though its time passed, or undefined.
250
+ * The STATUS column keeps saying `pending` (it is the machine-readable state); this is the part a
251
+ * person needs, which is that "pending" here no longer means "not yet".
252
+ */
253
+ function todoLateMessage(todo) {
254
+ if (todo.status !== 'pending' || !todo.late)
255
+ return undefined;
256
+ return `${todo.late.message} (${(0, format_1.formatElapsed)(todo.late.bySeconds)} past its time)`;
257
+ }
246
258
  /** Print explanations alongside the trace rows that recorded policy blocks. */
247
259
  function renderTodoPolicyTraceDetails(events, log) {
248
260
  for (const event of events) {
@@ -282,6 +294,9 @@ function renderTodoList(todos, log, timeZone) {
282
294
  const message = todo.status === 'failed' ? todoPolicyBlockMessage(todo.result?.errorMessage) : undefined;
283
295
  if (message)
284
296
  log(` ${todo.id}: ${message}`);
297
+ const late = todoLateMessage(todo);
298
+ if (late)
299
+ log(` ${todo.id}: ${late}`);
285
300
  }
286
301
  }
287
302
  /**
@@ -369,7 +384,7 @@ function renderProposal(proposal, log) {
369
384
  log(`Task scope: ${taskScope}`);
370
385
  if (proposal.expiresAt) {
371
386
  const expires = (0, format_1.zonedTime)(proposal.expiresAt, zone);
372
- log(`Expires: ${expires}${/ 00:00:00 /.test(expires) ? ' (midnight at the end of the plan day)' : ''}`);
387
+ log(`Expires: ${expires}${RENDER_PROPOSAL_RE.test(expires) ? ' (midnight at the end of the plan day)' : ''}`);
373
388
  }
374
389
  renderCapacityWarning(proposal.capacity, log, proposal.agentId);
375
390
  if (proposal.nextRunSuggestion) {
@@ -13,6 +13,8 @@ const node_crypto_1 = require("node:crypto");
13
13
  const base_command_1 = require("../base-command");
14
14
  const api_fetch_1 = require("./api-fetch");
15
15
  const memory_history_session_1 = require("./memory-history-session");
16
+ const UNCERTAIN_MEMORY_MUTATION_RECOVERY_RE = /\/mutations\/[^/?]+$/;
17
+ const MEMORY_HISTORY_API_RE = /^(agent|space):[^:]+$/;
16
18
  function parseMemoryStoreResolutions(value) {
17
19
  if (value === undefined)
18
20
  return undefined;
@@ -194,7 +196,9 @@ function parseMemoryApiError(error) {
194
196
  }
195
197
  /** A gateway timeout can arrive after the canonical mutation committed. */
196
198
  function uncertainMemoryMutationRecovery(path, options, status) {
197
- if (status !== 504 || options.method !== 'POST' || !/\/mutations\/[^/?]+$/.test(path))
199
+ if (status !== 504 ||
200
+ options.method !== 'POST' ||
201
+ !UNCERTAIN_MEMORY_MUTATION_RECOVERY_RE.test(path))
198
202
  return null;
199
203
  const body = options.body;
200
204
  if (!body || body.dryRun === true || typeof body.idempotencyKey !== 'string' || typeof body.targetStoreId !== 'string')
@@ -227,7 +231,7 @@ class ScopedMemoryCommand extends base_command_1.BaseCommand {
227
231
  if (Boolean(flags.store) === Boolean(flags.scope)) {
228
232
  this.error('Pass exactly one of --store <id> or --scope agent:<id>|space:<id>.', { exit: 2 });
229
233
  }
230
- if (flags.scope && !/^(agent|space):[^:]+$/.test(flags.scope)) {
234
+ if (flags.scope && !MEMORY_HISTORY_API_RE.test(flags.scope)) {
231
235
  this.error('--scope must be agent:<id> or space:<id>.', { exit: 2 });
232
236
  }
233
237
  if (flags.scope?.startsWith('space:') && !flags.space) {
@@ -283,7 +287,7 @@ class ScopedMemoryCommand extends base_command_1.BaseCommand {
283
287
  if (!flags.scope) {
284
288
  this.error('Pass exactly one of --store <id> or --scope agent:<id>|space:<id>.', { exit: 2 });
285
289
  }
286
- if (!/^(agent|space):[^:]+$/.test(flags.scope)) {
290
+ if (!MEMORY_HISTORY_API_RE.test(flags.scope)) {
287
291
  this.error('--scope must be agent:<id> or space:<id>.', { exit: 2 });
288
292
  }
289
293
  const [kind, id] = flags.scope.split(':', 2);
@@ -5,19 +5,26 @@ exports.isPrintableSearchCursor = isPrintableSearchCursor;
5
5
  exports.shellSearchCursor = shellSearchCursor;
6
6
  exports.isSearchListPage = isSearchListPage;
7
7
  const node_util_1 = require("node:util");
8
+ const SEARCH_DISPLAY_TEXT_RE = /[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g;
9
+ const SEARCH_DISPLAY_TEXT_RE_2 = /\s+/g;
10
+ const IS_PRINTABLE_SEARCH_CURSOR_RE = /[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/;
11
+ const SHELL_SEARCH_CURSOR_RE = /^[A-Za-z0-9_@%+=:,./-]+$/;
12
+ const SHELL_SEARCH_CURSOR_RE_2 = /'/g;
8
13
  /** Keep untrusted search content from controlling or reordering a terminal. */
9
14
  function searchDisplayText(value) {
10
15
  return (0, node_util_1.stripVTControlCharacters)(value)
11
- .replace(/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, ' ')
12
- .replace(/\s+/g, ' ')
16
+ .replace(SEARCH_DISPLAY_TEXT_RE, ' ')
17
+ .replace(SEARCH_DISPLAY_TEXT_RE_2, ' ')
13
18
  .trim();
14
19
  }
15
20
  /** Cursor values stay opaque, but must be safe to print and copy into a shell. */
16
21
  function isPrintableSearchCursor(value) {
17
- return value.length > 0 && !/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/.test(value);
22
+ return value.length > 0 && !IS_PRINTABLE_SEARCH_CURSOR_RE.test(value);
18
23
  }
19
24
  function shellSearchCursor(value) {
20
- return /^[A-Za-z0-9_@%+=:,./-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
25
+ return SHELL_SEARCH_CURSOR_RE.test(value)
26
+ ? value
27
+ : `'${value.replace(SHELL_SEARCH_CURSOR_RE_2, `'\\''`)}'`;
21
28
  }
22
29
  /** A missing or malformed list is an error, not proof of zero matches. */
23
30
  function isSearchListPage(value) {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.skillStoreSearchIncomplete = skillStoreSearchIncomplete;
4
4
  exports.skillStorePageState = skillStorePageState;
5
5
  exports.reportSkillStorePage = reportSkillStorePage;
6
+ const SKILL_STORE_PAGE_STATE_RE = /^[A-Za-z0-9_+/=-]{1,4096}$/;
6
7
  /** The Store can return an empty page while more candidates remain to inspect. */
7
8
  function skillStoreSearchIncomplete(response) {
8
9
  if (!response || Array.isArray(response) || typeof response !== 'object')
@@ -19,7 +20,7 @@ function skillStorePageState(response, cursor) {
19
20
  return { hasMore: false, invalidCursor: false };
20
21
  // Server cursors are opaque base64 tokens. Do not print arbitrary terminal
21
22
  // control characters from a malformed response, or suggest a cursor loop.
22
- const next = typeof page.after === 'string' && /^[A-Za-z0-9_+/=-]{1,4096}$/.test(page.after)
23
+ const next = typeof page.after === 'string' && SKILL_STORE_PAGE_STATE_RE.test(page.after)
23
24
  ? page.after
24
25
  : undefined;
25
26
  if (!next || next === cursor)
@@ -17,6 +17,9 @@ exports.notebookLines = notebookLines;
17
17
  * removed, so a summary cannot forge a row of its own.
18
18
  */
19
19
  const data_provider_1 = require("@skrr-ai/data-provider");
20
+ // eslint-disable-next-line no-control-regex
21
+ const ONE_LINE_RE = /[\u0000-\u001f\u007f-\u009f‎‏‪-‮⁦-⁩]/g;
22
+ const ONE_LINE_RE_2 = /\s+/g;
20
23
  const KIND_TAG = {
21
24
  task_result: 'result',
22
25
  loop_cycle: 'cycle',
@@ -33,9 +36,8 @@ const VERDICT_WORD = {
33
36
  /** One printable line: no control or bidi characters, whitespace collapsed. */
34
37
  function oneLine(value, max = 240) {
35
38
  const text = String(value ?? '')
36
- // eslint-disable-next-line no-control-regex
37
- .replace(/[\u0000-\u001f\u007f-\u009f‎‏‪-‮⁦-⁩]/g, ' ')
38
- .replace(/\s+/g, ' ')
39
+ .replace(ONE_LINE_RE, ' ')
40
+ .replace(ONE_LINE_RE_2, ' ')
39
41
  .trim();
40
42
  return text.length > max ? `${text.slice(0, max - 1).trimEnd()}…` : text;
41
43
  }
@@ -13,6 +13,7 @@ exports.outcomesWindowLine = outcomesWindowLine;
13
13
  exports.suppressedCellsLine = suppressedCellsLine;
14
14
  exports.exclusionValue = exclusionValue;
15
15
  const data_provider_1 = require("@skrr-ai/data-provider");
16
+ const HUMANIZE_RE = /([a-z])([A-Z])/g;
16
17
  /**
17
18
  * Terminal wording for a Store listing (`skrr store show`) and its publisher
18
19
  * readouts (`skrr store stats`). Pure functions, so the commands only fetch
@@ -179,7 +180,7 @@ function suppressedCellsLine(cells, minimumCohort, unit) {
179
180
  return `Withheld rows (fewer than ${minimumCohort} ${unit} each): ${parts.join(', ')}.`;
180
181
  }
181
182
  function humanize(key) {
182
- return key.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase();
183
+ return key.replace(HUMANIZE_RE, '$1 $2').toLowerCase();
183
184
  }
184
185
  /** An exclusion count; `null` is "some, from too few buyers to say how many". */
185
186
  function exclusionValue(value) {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TASK_AGENT_CONTEXT_COMMAND_IDS = void 0;
4
4
  exports.taskAgentContextCommandCapability = taskAgentContextCommandCapability;
5
+ const TASK_AGENT_CONTEXT_COMMAND_CAPABILITY_RE = /:/g;
5
6
  /**
6
7
  * Semantic capabilities advertised by a CLI that can safely render Task Agent
7
8
  * Context recovery instructions. This ships with the CLI (unlike build-only
@@ -18,5 +19,5 @@ exports.TASK_AGENT_CONTEXT_COMMAND_IDS = [
18
19
  'tasks:retry-receipt',
19
20
  ];
20
21
  function taskAgentContextCommandCapability(commandId) {
21
- return `task-agent-context.command.${commandId.replace(/:/g, '-')}.v1`;
22
+ return `task-agent-context.command.${commandId.replace(TASK_AGENT_CONTEXT_COMMAND_CAPABILITY_RE, '-')}.v1`;
22
23
  }
@@ -74,6 +74,10 @@ const base_command_1 = require("../base-command");
74
74
  const file_mime_1 = require("./file-mime");
75
75
  const api_fetch_1 = require("./api-fetch");
76
76
  const session_task_write_1 = require("./session-task-write");
77
+ const TASK_ASSET_MARKDOWN_REF_RE = /[\\[\]]/g;
78
+ const QUOTED_HEADER_VALUE_RE = /[\r\n]/g;
79
+ const QUOTED_HEADER_VALUE_RE_2 = /"/g;
80
+ const POST_FILE_TO_STORAGE_RE = /<Code>([^<]+)<\/Code>/;
77
81
  function mb(bytes) {
78
82
  return `${Math.floor(bytes / (1024 * 1024))} MB`;
79
83
  }
@@ -213,7 +217,7 @@ async function attachTaskAssetFiles(opts) {
213
217
  * close the alt early and break the reference.
214
218
  */
215
219
  function taskAssetMarkdownRef(asset) {
216
- const alt = asset.filename.replace(/[\\[\]]/g, (ch) => `\\${ch}`);
220
+ const alt = asset.filename.replace(TASK_ASSET_MARKDOWN_REF_RE, (ch) => `\\${ch}`);
217
221
  return `![${alt}](task-asset:${asset.id})`;
218
222
  }
219
223
  /**
@@ -534,7 +538,7 @@ async function sha256OfFile(filePath) {
534
538
  }
535
539
  /** A form-data header value: no CR/LF, and quotes percent-encoded. */
536
540
  function quotedHeaderValue(value) {
537
- return value.replace(/[\r\n]/g, ' ').replace(/"/g, '%22');
541
+ return value.replace(QUOTED_HEADER_VALUE_RE, ' ').replace(QUOTED_HEADER_VALUE_RE_2, '%22');
538
542
  }
539
543
  /**
540
544
  * POST the file to the presigned URL as multipart/form-data, streamed from
@@ -595,7 +599,7 @@ async function postFileToStorage(p) {
595
599
  // S3 names the refusal in XML (`<Code>BadDigest</Code>`,
596
600
  // `EntityTooLarge`, `AccessDenied` once the POST policy expired).
597
601
  // The code is the only part a person can act on.
598
- const code = /<Code>([^<]+)<\/Code>/.exec(body)?.[1];
602
+ const code = POST_FILE_TO_STORAGE_RE.exec(body)?.[1];
599
603
  fail(new Error(`Storage rejected the upload (${status}${code ? ` ${code}` : ''})`));
600
604
  });
601
605
  });
@@ -5,6 +5,7 @@ exports.taskIsSettled = taskIsSettled;
5
5
  exports.closureReport = closureReport;
6
6
  exports.reopenRequiredLines = reopenRequiredLines;
7
7
  const data_provider_1 = require("@skrr-ai/data-provider");
8
+ const TRUNCATE_RE = /\s+/g;
8
9
  /**
9
10
  * Is this Task SETTLED — closed in a way that refuses a new Result until it is
10
11
  * reopened (`TASK_REOPEN_REQUIRED`)?
@@ -133,7 +134,7 @@ function reopenRequiredLines({ bin, task, command, }) {
133
134
  var data_provider_2 = require("@skrr-ai/data-provider");
134
135
  Object.defineProperty(exports, "describeAssessor", { enumerable: true, get: function () { return data_provider_2.describeAssessorKind; } });
135
136
  function truncate(value, max) {
136
- const flat = value.replace(/\s+/g, ' ').trim();
137
+ const flat = value.replace(TRUNCATE_RE, ' ').trim();
137
138
  return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
138
139
  }
139
140
  function capitalize(value) {
@@ -7,6 +7,7 @@ exports.scoreText = scoreText;
7
7
  exports.estimateUnchangedLine = estimateUnchangedLine;
8
8
  exports.describeEconomicsChange = describeEconomicsChange;
9
9
  const data_provider_1 = require("@skrr-ai/data-provider");
10
+ const AMOUNT_FLAG_RE = /,/;
10
11
  /**
11
12
  * A flag's amount as a number, or an error that names the flag and the value (OSK-15366). A raw
12
13
  * Zod issue array named internal paths (`savings.amount`, `effortHours`) and no flag, so a person
@@ -15,7 +16,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
15
16
  function amountFlag(flag, value) {
16
17
  const amount = Number(value);
17
18
  if (value.trim() === '' || !Number.isFinite(amount) || amount < 0) {
18
- const hint = /,/.test(value) ? ' Write it without a thousands separator.' : '';
19
+ const hint = AMOUNT_FLAG_RE.test(value) ? ' Write it without a thousands separator.' : '';
19
20
  throw new Error(`${flag} must be a non-negative number (got '${value}').${hint}`);
20
21
  }
21
22
  return amount;
@@ -28,6 +28,14 @@ exports.compactSnapshotSignature = compactSnapshotSignature;
28
28
  const data_provider_1 = require("@skrr-ai/data-provider");
29
29
  const tasks_1 = require("./tasks");
30
30
  const html_text_1 = require("./html-text");
31
+ const IS_RECOVERED_EXECUTION_TASK_RE = /\b(stuck|timeout|timed out|reaped|reset|lost|expired|usage|quota|rate limit|token)\b/i;
32
+ const RECOVERY_REASON_RE = /stuck|reaped|reset/i;
33
+ const RECOVERY_REASON_RE_2 = /usage|quota|rate limit|token/i;
34
+ const RECOVERY_REASON_RE_3 = /timeout|timed out/i;
35
+ const WORKSTREAM_KEY_RE = /\bWS[-\s]?(\d+)[.-](\d+)\b/i;
36
+ const DEPENDENCY_KEYS_RE = /\bdepends(?:\s+on)?\s*:\s*([^\n\r]+)/i;
37
+ const DEPENDENCY_KEYS_RE_2 = /^(none|—|-|n\/a)\b/i;
38
+ const DEPENDENCY_KEYS_RE_3 = /\bWS[-\s]?(\d+)[.-](\d+)\b/gi;
31
39
  /**
32
40
  * Statuses at which an execution is OVER — nothing further will move the task
33
41
  * without new input.
@@ -94,7 +102,7 @@ function isRecoveredExecutionTask(task) {
94
102
  const error = stringValue(task.executionError);
95
103
  if (!error)
96
104
  return false;
97
- return (/\b(stuck|timeout|timed out|reaped|reset|lost|expired|usage|quota|rate limit|token)\b/i.test(error) ||
105
+ return (IS_RECOVERED_EXECUTION_TASK_RE.test(error) ||
98
106
  isNonEmptyString(task.startedAt) ||
99
107
  isNonEmptyString(task.conversationId) ||
100
108
  Number(task.executionAttempts) > 0);
@@ -136,11 +144,11 @@ function recoveryReason(task) {
136
144
  const error = stringValue(task.executionError);
137
145
  if (!error)
138
146
  return 'recovered stale execution';
139
- if (/stuck|reaped|reset/i.test(error))
147
+ if (RECOVERY_REASON_RE.test(error))
140
148
  return 'reaped stale execution';
141
- if (/usage|quota|rate limit|token/i.test(error))
149
+ if (RECOVERY_REASON_RE_2.test(error))
142
150
  return 'execution limit/auth failure';
143
- if (/timeout|timed out/i.test(error))
151
+ if (RECOVERY_REASON_RE_3.test(error))
144
152
  return 'execution timeout';
145
153
  return 'previous execution failed to complete';
146
154
  }
@@ -242,7 +250,7 @@ function workstreamKey(task) {
242
250
  ...(Array.isArray(task.tags) ? task.tags.map((tag) => String(tag)) : []),
243
251
  ];
244
252
  for (const candidate of candidates) {
245
- const match = candidate.match(/\bWS[-\s]?(\d+)[.-](\d+)\b/i);
253
+ const match = candidate.match(WORKSTREAM_KEY_RE);
246
254
  if (match)
247
255
  return `ws-${match[1]}-${match[2]}`;
248
256
  }
@@ -250,13 +258,13 @@ function workstreamKey(task) {
250
258
  }
251
259
  function dependencyKeys(task) {
252
260
  const text = stripHtml(String(task.description ?? ''));
253
- const dependsMatch = text.match(/\bdepends(?:\s+on)?\s*:\s*([^\n\r]+)/i);
261
+ const dependsMatch = text.match(DEPENDENCY_KEYS_RE);
254
262
  if (!dependsMatch)
255
263
  return [];
256
264
  const line = dependsMatch[1];
257
- if (/^(none|—|-|n\/a)\b/i.test(line.trim()))
265
+ if (DEPENDENCY_KEYS_RE_2.test(line.trim()))
258
266
  return [];
259
- return Array.from(line.matchAll(/\bWS[-\s]?(\d+)[.-](\d+)\b/gi)).map((match) => `ws-${match[1]}-${match[2]}`);
267
+ return Array.from(line.matchAll(DEPENDENCY_KEYS_RE_3)).map((match) => `ws-${match[1]}-${match[2]}`);
260
268
  }
261
269
  function blockingDependencies(task, candidates) {
262
270
  const byKey = new Map();
@@ -24,6 +24,8 @@ exports.taskLabelSuggestion = taskLabelSuggestion;
24
24
  const data_provider_1 = require("@skrr-ai/data-provider");
25
25
  const triggers_1 = require("./triggers");
26
26
  const api_fetch_1 = require("./api-fetch");
27
+ const PARSE_EXECUTION_TARGET_REF_RE = /^hosted-machine:(.+)$/;
28
+ const PARSE_EXECUTION_TARGET_REF_RE_2 = /^harness:(.+)$/;
27
29
  const MOUNT = '/api/tasks';
28
30
  const base = (id) => `${MOUNT}/${encodeURIComponent(id)}`;
29
31
  exports.taskWorkflowApi = {
@@ -146,10 +148,10 @@ function parseExecutionTargetRef(value) {
146
148
  return { kind: 'agent-worker' };
147
149
  if (HOSTED_MACHINE_SELECTORS.has(trimmed))
148
150
  return { kind: 'hosted-machine' };
149
- const hosted = /^hosted-machine:(.+)$/.exec(trimmed);
151
+ const hosted = PARSE_EXECUTION_TARGET_REF_RE.exec(trimmed);
150
152
  if (hosted)
151
153
  return { kind: 'hosted-machine', ref: hosted[1] };
152
- const harness = /^harness:(.+)$/.exec(trimmed);
154
+ const harness = PARSE_EXECUTION_TARGET_REF_RE_2.exec(trimmed);
153
155
  return { kind: 'harness', ref: harness ? harness[1] : trimmed };
154
156
  }
155
157
  exports.taskChatApi = {
@@ -11,6 +11,7 @@ exports.parseTaskOperationWatchDuration = parseTaskOperationWatchDuration;
11
11
  exports.classifyTaskOperation = classifyTaskOperation;
12
12
  exports.watchTaskOperation = watchTaskOperation;
13
13
  exports.taskOperationCheckpointLine = taskOperationCheckpointLine;
14
+ const PARSE_TASK_OPERATION_WATCH_DURATION_RE = /^(\d+)(ms|s|m|h)?$/i;
14
15
  // These are operation outcomes, not Task-execution outcomes. A start can be
15
16
  // successfully accepted and a retry successfully admitted while its execution
16
17
  // Run is still active; waiting on the Operation must stop successfully at that
@@ -21,7 +22,7 @@ const FAILED_STATES = new Set(['failed', 'cancelled', 'canceled', 'abandoned', '
21
22
  function parseTaskOperationWatchDuration(value) {
22
23
  if (!value)
23
24
  return null;
24
- const match = value.trim().match(/^(\d+)(ms|s|m|h)?$/i);
25
+ const match = value.trim().match(PARSE_TASK_OPERATION_WATCH_DURATION_RE);
25
26
  if (!match)
26
27
  throw new Error(`Invalid --timeout value: ${value}`);
27
28
  const amount = Number(match[1]);
@@ -4,6 +4,7 @@ exports.readTaskPreflight = readTaskPreflight;
4
4
  exports.taskPreflightLines = taskPreflightLines;
5
5
  const task_admission_1 = require("./task-admission");
6
6
  const task_operations_1 = require("./task-operations");
7
+ const UNAVAILABLE_RE = /^[A-Z][A-Z0-9_]{0,100}$/;
7
8
  const LIMITS = [
8
9
  'Workflow and execution checks are separate server observations, not an atomic reservation.',
9
10
  'No Run, shell command, machine probe, or branch checkout was performed.',
@@ -13,13 +14,13 @@ const LIMITS = [
13
14
  function unavailable(error, label) {
14
15
  const row = error && typeof error === 'object' ? error : {};
15
16
  const status = typeof row.status === 'number' ? row.status : undefined;
16
- let code = typeof row.code === 'string' && /^[A-Z][A-Z0-9_]{0,100}$/.test(row.code) ? row.code : undefined;
17
+ let code = typeof row.code === 'string' && UNAVAILABLE_RE.test(row.code) ? row.code : undefined;
17
18
  // Keep the native typed refusal without echoing an arbitrary response body,
18
19
  // HTML proxy page, request URL, or credential into diagnostics.
19
20
  if (!code && typeof row.body === 'string') {
20
21
  try {
21
22
  const body = JSON.parse(row.body);
22
- if (typeof body?.code === 'string' && /^[A-Z][A-Z0-9_]{0,100}$/.test(body.code))
23
+ if (typeof body?.code === 'string' && UNAVAILABLE_RE.test(body.code))
23
24
  code = body.code;
24
25
  }
25
26
  catch {
@@ -15,6 +15,8 @@ exports.recurrenceSummaryLines = recurrenceSummaryLines;
15
15
  * the caller prints the raw pattern alone rather than a confident wrong sentence.
16
16
  */
17
17
  const iso_instant_1 = require("./iso-instant");
18
+ const TO_NUMBER_RE = /^\d+$/;
19
+ const DESCRIBE_CRON_PATTERN_RE = /\s+/;
18
20
  const WEEKDAYS = [
19
21
  'Sunday',
20
22
  'Monday',
@@ -64,7 +66,7 @@ function expandField(raw, domain) {
64
66
  if (!Number.isInteger(step) || step < 1)
65
67
  return null;
66
68
  const toNumber = (token) => {
67
- if (/^\d+$/.test(token))
69
+ if (TO_NUMBER_RE.test(token))
68
70
  return Number(token);
69
71
  const index = domain.names?.indexOf(token.toUpperCase()) ?? -1;
70
72
  return index >= 0 ? index + (domain.nameBase ?? 0) : null;
@@ -158,7 +160,7 @@ function describeWeekdays(values) {
158
160
  function describeCronPattern(pattern) {
159
161
  const fields = String(pattern ?? '')
160
162
  .trim()
161
- .split(/\s+/);
163
+ .split(DESCRIBE_CRON_PATTERN_RE);
162
164
  if (fields.length !== 5)
163
165
  return null;
164
166
  const [minute, hour, dayOfMonth, month, dayOfWeek] = fields;