@skrr-ai/cli 0.1.146 → 0.1.148

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 (289) 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/triggers/policy.js +11 -1
  19. package/dist/commands/agents/visibility.js +2 -1
  20. package/dist/commands/balance/show.js +28 -5
  21. package/dist/commands/balance/statement.js +2 -1
  22. package/dist/commands/commands.js +2 -1
  23. package/dist/commands/commitments/create.js +2 -1
  24. package/dist/commands/commitments/delivery.js +2 -1
  25. package/dist/commands/commitments/doctor.js +2 -1
  26. package/dist/commands/commitments/observations.js +2 -2
  27. package/dist/commands/commitments/operating-review.js +2 -1
  28. package/dist/commands/commitments/pack/preflight.js +2 -1
  29. package/dist/commands/commitments/preflight.js +5 -1
  30. package/dist/commands/commitments/trigger-status.js +2 -1
  31. package/dist/commands/commitments/wake-capabilities.d.ts +2 -0
  32. package/dist/commands/commitments/wake-capabilities.js +16 -0
  33. package/dist/commands/convos/messages.js +2 -1
  34. package/dist/commands/daemon/logs.js +18 -9
  35. package/dist/commands/daemon/usage.js +2 -1
  36. package/dist/commands/dm/messages.js +2 -1
  37. package/dist/commands/dm/thread/messages.js +2 -1
  38. package/dist/commands/dm/threads.js +2 -1
  39. package/dist/commands/doctor.js +2 -1
  40. package/dist/commands/goals/key-results/assess.js +2 -1
  41. package/dist/commands/goals/key-results/history.js +2 -1
  42. package/dist/commands/harnesses/forget.js +2 -1
  43. package/dist/commands/harnesses/show.js +12 -6
  44. package/dist/commands/inbox/index.js +4 -3
  45. package/dist/commands/initiatives/decide.js +2 -1
  46. package/dist/commands/instructions/diff.js +2 -1
  47. package/dist/commands/instructions/show.js +2 -1
  48. package/dist/commands/login.js +4 -2
  49. package/dist/commands/machines/dedicated/cp.js +2 -1
  50. package/dist/commands/machines/dedicated/power/set.js +2 -1
  51. package/dist/commands/machines/show.js +2 -1
  52. package/dist/commands/memory/maintain.js +2 -1
  53. package/dist/commands/memory/read.js +2 -1
  54. package/dist/commands/memory/rebuild-index.js +2 -1
  55. package/dist/commands/memory/rebuild.js +2 -1
  56. package/dist/commands/memory/search.js +2 -1
  57. package/dist/commands/messages/list.js +2 -1
  58. package/dist/commands/revoke-daemon.js +2 -1
  59. package/dist/commands/revoke-token.js +2 -1
  60. package/dist/commands/search/all.js +14 -7
  61. package/dist/commands/search/workspace.js +2 -1
  62. package/dist/commands/set-capabilities.js +2 -1
  63. package/dist/commands/skills/browse.js +8 -2
  64. package/dist/commands/spaces/auto-executor/preview.js +3 -2
  65. package/dist/commands/spaces/auto-executor/runs.js +4 -1
  66. package/dist/commands/spaces/workflow-templates/extract.d.ts +1 -0
  67. package/dist/commands/spaces/workflow-templates/extract.js +9 -1
  68. package/dist/commands/spaces/workflows/events.js +6 -3
  69. package/dist/commands/spaces/workflows/run.js +5 -3
  70. package/dist/commands/spaces/workflows/update.js +2 -1
  71. package/dist/commands/store/gallery-admissions/preview.js +2 -1
  72. package/dist/commands/store/publishers/profile/handle.js +2 -1
  73. package/dist/commands/tasks/comments/anchor.js +23 -9
  74. package/dist/commands/tasks/complete.js +4 -2
  75. package/dist/commands/tasks/create-tree.js +7 -3
  76. package/dist/commands/tasks/create.js +2 -1
  77. package/dist/commands/tasks/deliverable/add.js +2 -1
  78. package/dist/commands/tasks/deliverable/archive.js +2 -1
  79. package/dist/commands/tasks/deliverable/list.js +2 -1
  80. package/dist/commands/tasks/expectations/assess.js +2 -1
  81. package/dist/commands/tasks/labels/create.js +2 -1
  82. package/dist/commands/tasks/preflight.js +4 -2
  83. package/dist/commands/tasks/ready.js +2 -1
  84. package/dist/commands/tasks/result/submit.js +2 -1
  85. package/dist/commands/tasks/updates/add.js +2 -1
  86. package/dist/commands/tasks/wait.js +2 -1
  87. package/dist/commands/token/list.js +2 -1
  88. package/dist/commands/token/mint.js +2 -1
  89. package/dist/commands/wiki/write.js +14 -7
  90. package/dist/hooks/command-not-found.js +2 -1
  91. package/dist/lib/agent-chat-start.d.ts +77 -0
  92. package/dist/lib/agent-chat-start.js +169 -0
  93. package/dist/lib/agent-config.js +2 -1
  94. package/dist/lib/agent-endpoints.js +4 -2
  95. package/dist/lib/agent-evals.js +2 -1
  96. package/dist/lib/agent-guide-reference-gate.js +22 -11
  97. package/dist/lib/agent-guides.js +4 -1
  98. package/dist/lib/agent-instructions.js +5 -1
  99. package/dist/lib/agent-ref.js +8 -4
  100. package/dist/lib/agent-trigger-listing.js +2 -1
  101. package/dist/lib/agentic-stream.js +8 -5
  102. package/dist/lib/api-error-reason.js +2 -1
  103. package/dist/lib/api-fetch.js +5 -3
  104. package/dist/lib/appData.js +6 -6
  105. package/dist/lib/appInstallations.js +10 -5
  106. package/dist/lib/appsCheck.js +2 -1
  107. package/dist/lib/auth-failure.js +2 -1
  108. package/dist/lib/auth-storage.js +2 -1
  109. package/dist/lib/balance.d.ts +33 -3
  110. package/dist/lib/balance.js +39 -7
  111. package/dist/lib/capability-matrix.js +4 -2
  112. package/dist/lib/cli-runtime.js +2 -1
  113. package/dist/lib/code-handover.js +8 -3
  114. package/dist/lib/command-hygiene.js +28 -12
  115. package/dist/lib/command-manifest.js +6 -3
  116. package/dist/lib/commitment-attention-copy.js +2 -1
  117. package/dist/lib/commitment-event-wakes.js +9 -0
  118. package/dist/lib/commitment-product.js +5 -3
  119. package/dist/lib/commitment-terms.js +2 -1
  120. package/dist/lib/commitments.d.ts +13 -0
  121. package/dist/lib/commitments.js +24 -9
  122. package/dist/lib/compasses.js +2 -1
  123. package/dist/lib/completion-index.js +2 -1
  124. package/dist/lib/computer-files.js +8 -6
  125. package/dist/lib/config.js +11 -5
  126. package/dist/lib/conversation-search.js +4 -2
  127. package/dist/lib/daemon-installer.js +6 -2
  128. package/dist/lib/daemon-maintenance.js +2 -1
  129. package/dist/lib/daemon-ref.js +2 -1
  130. package/dist/lib/daemonBroker.js +6 -3
  131. package/dist/lib/daemonBrokerRefusal.js +4 -2
  132. package/dist/lib/daemonHandoff.js +14 -7
  133. package/dist/lib/daemonIslandProfile.js +2 -1
  134. package/dist/lib/dedicated-copy.js +9 -3
  135. package/dist/lib/dedicated-exec.js +2 -1
  136. package/dist/lib/dedicated-keep-awake.js +2 -1
  137. package/dist/lib/dedicated-machines.js +9 -5
  138. package/dist/lib/dedicated-service.js +2 -1
  139. package/dist/lib/dedicated-ssh.js +5 -3
  140. package/dist/lib/deployed-build.js +2 -1
  141. package/dist/lib/device-code.js +4 -3
  142. package/dist/lib/dpop-auth.js +2 -1
  143. package/dist/lib/earnings.js +2 -1
  144. package/dist/lib/exec-runtime-binary.js +5 -3
  145. package/dist/lib/first-party-harness-broker.js +4 -3
  146. package/dist/lib/first-party-harness-managed.js +2 -1
  147. package/dist/lib/first-party-harness-startup-update.js +8 -4
  148. package/dist/lib/first-party-harness-update.js +2 -1
  149. package/dist/lib/first-party-harness.js +2 -1
  150. package/dist/lib/format.js +8 -4
  151. package/dist/lib/git-task.js +10 -5
  152. package/dist/lib/github-tools.js +6 -3
  153. package/dist/lib/harnesses.js +4 -2
  154. package/dist/lib/hosted-machines.js +2 -1
  155. package/dist/lib/html-text.js +33 -16
  156. package/dist/lib/ingress.js +2 -1
  157. package/dist/lib/instruction-blocks.js +2 -1
  158. package/dist/lib/iso-instant.js +5 -3
  159. package/dist/lib/keychain.js +15 -5
  160. package/dist/lib/label-scope.js +2 -1
  161. package/dist/lib/live-runtime-binary.js +10 -7
  162. package/dist/lib/local-skills.js +10 -6
  163. package/dist/lib/login.js +3 -2
  164. package/dist/lib/machine-audit.js +2 -1
  165. package/dist/lib/machine-daemon-log.js +2 -1
  166. package/dist/lib/machine-services.js +2 -1
  167. package/dist/lib/memory-history-session.js +2 -1
  168. package/dist/lib/memory-sync.js +6 -2
  169. package/dist/lib/message-intent.d.ts +10 -0
  170. package/dist/lib/node-adapter.js +4 -2
  171. package/dist/lib/northstars.js +4 -2
  172. package/dist/lib/oauthLogin.js +16 -7
  173. package/dist/lib/open-target.js +8 -4
  174. package/dist/lib/option-hint.js +2 -4
  175. package/dist/lib/outbox.js +2 -1
  176. package/dist/lib/planOutcome.d.ts +5 -3
  177. package/dist/lib/planOutcome.js +7 -4
  178. package/dist/lib/platform-update-local.js +2 -3
  179. package/dist/lib/preflight-copy.js +31 -0
  180. package/dist/lib/rate-limit-retry.js +2 -1
  181. package/dist/lib/reflection.js +2 -1
  182. package/dist/lib/request-field-flags.js +2 -1
  183. package/dist/lib/runtime-start-verification.js +2 -1
  184. package/dist/lib/schedule.js +2 -1
  185. package/dist/lib/scoped-memory-command.js +7 -3
  186. package/dist/lib/search-display.js +11 -4
  187. package/dist/lib/skill-store-pagination.js +2 -1
  188. package/dist/lib/space-notebook.js +5 -3
  189. package/dist/lib/store-listing.js +2 -1
  190. package/dist/lib/task-agent-context-capabilities.js +2 -1
  191. package/dist/lib/task-asset-upload.js +7 -3
  192. package/dist/lib/task-closure.js +2 -1
  193. package/dist/lib/task-economics.js +2 -1
  194. package/dist/lib/task-execution.js +16 -8
  195. package/dist/lib/task-extras.js +4 -2
  196. package/dist/lib/task-operation-watch.js +2 -1
  197. package/dist/lib/task-preflight.js +3 -2
  198. package/dist/lib/task-recurrence-summary.js +4 -2
  199. package/dist/lib/task-runtime-headers.js +10 -5
  200. package/dist/lib/task-transcript.js +3 -2
  201. package/dist/lib/task-transfer.js +9 -5
  202. package/dist/lib/tasks.js +2 -1
  203. package/dist/lib/triggers.d.ts +21 -0
  204. package/dist/lib/triggers.js +41 -3
  205. package/dist/lib/update-check.js +12 -7
  206. package/dist/lib/usage-discovery.js +2 -1
  207. package/dist/lib/usd-micros.js +2 -1
  208. package/dist/lib/web-url.js +2 -1
  209. package/dist/lib/widgetCheck.js +15 -9
  210. package/dist/lib/widgetStaticScan.js +26 -14
  211. package/dist/lib/workflow-run-view.js +5 -3
  212. package/dist/lib/workflow-templates.d.ts +10 -0
  213. package/dist/lib/workflow-templates.js +47 -0
  214. package/dist/lib/write-target.js +4 -5
  215. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/authHelper.js +2 -1
  216. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/commitmentExecutionContract.js +22 -12
  217. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/computerUse.js +4 -1
  218. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelope.js +7 -2
  219. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -3
  220. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonConsentProof.js +2 -1
  221. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonPair.js +16 -7
  222. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +4 -1
  223. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/desktopDaemonProof.js +4 -3
  224. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/desktopWire.js +2 -1
  225. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +11 -7
  226. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceKey.js +7 -2
  227. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dpop.js +8 -3
  228. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +2 -1
  229. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessChannels.js +4 -3
  230. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.js +2 -1
  231. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/githubPushRefusal.js +4 -3
  232. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/guidedUpdate.js +2 -1
  233. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/independentMachineReservation.js +8 -3
  234. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/kek/macos.js +4 -2
  235. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/liveState.js +4 -2
  236. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/loginWithLocalhost.js +2 -1
  237. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/loopbackHttp.js +2 -1
  238. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/machineUuid.js +4 -2
  239. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileStateDir.js +2 -1
  240. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/recoveryCode.js +2 -1
  241. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +3 -2
  242. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releasePolicy.js +2 -1
  243. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releaseVersions.js +6 -4
  244. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/restartArtifact.js +2 -1
  245. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/spawnEnv.js +2 -1
  246. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/telemetryRedaction.js +7 -4
  247. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.js +2 -1
  248. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/authHelper.js +2 -1
  249. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/commitmentExecutionContract.js +27 -18
  250. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/computerUse.js +6 -3
  251. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelope.js +11 -2
  252. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +6 -3
  253. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonConsentProof.js +2 -1
  254. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonPair.js +20 -8
  255. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +5 -4
  256. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/desktopDaemonProof.js +4 -3
  257. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/desktopWire.js +2 -1
  258. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +11 -7
  259. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceKey.js +11 -2
  260. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dpop.js +12 -3
  261. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +2 -1
  262. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessChannels.js +4 -3
  263. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.js +2 -1
  264. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/githubPushRefusal.js +4 -3
  265. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/guidedUpdate.js +5 -1
  266. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/independentMachineReservation.js +10 -5
  267. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/kek/macos.js +4 -2
  268. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/liveState.js +4 -2
  269. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/loginWithLocalhost.js +2 -1
  270. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/loopbackHttp.js +2 -1
  271. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/machineUuid.js +4 -2
  272. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileStateDir.js +2 -1
  273. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/recoveryCode.js +2 -1
  274. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +3 -2
  275. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releasePolicy.js +2 -1
  276. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releaseVersions.js +6 -4
  277. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/restartArtifact.js +2 -1
  278. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/spawnEnv.js +2 -1
  279. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/telemetryRedaction.js +11 -5
  280. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.js +2 -1
  281. package/dist/node_modules/@skrr-ai/auth-core/package.json +1 -1
  282. package/dist/node_modules/@skrr-ai/data-provider/index.js +20519 -20130
  283. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.js +4 -2
  284. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +10 -6
  285. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.js +4 -2
  286. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +10 -6
  287. package/dist/node_modules/@skrr-ai/inference-broker/package.json +1 -1
  288. package/oclif.manifest.json +17 -2
  289. package/package.json +1 -1
@@ -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;
@@ -2,6 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withTaskRuntimeHeaders = withTaskRuntimeHeaders;
4
4
  exports.taskRuntimeRedirectOptions = taskRuntimeRedirectOptions;
5
+ const WITH_TASK_RUNTIME_HEADERS_RE = /^\/api\/tasks(?:\/|$)/;
6
+ const WITH_TASK_RUNTIME_HEADERS_RE_2 = /^\/api\/agents\/[^/]+\/agent-actions\/[^/]+\/run\/?$/;
7
+ const WITH_TASK_RUNTIME_HEADERS_RE_3 = /^\/api\/(?:shortcuts|task-templates)\/[^/]+\/(?:instantiate|trigger)\/?$/;
8
+ const WITH_TASK_RUNTIME_HEADERS_RE_4 = /^\/api\/templates\/[^/]+\/(?:instantiate|fork)\/?$/;
9
+ const WITH_TASK_RUNTIME_HEADERS_RE_5 = /^\/api\/store\/services\/[^/]+\/install\/?$/;
5
10
  /**
6
11
  * Account Authorization decides access; a separate server-issued session
7
12
  * credential proves Agent authorship. Environment ids are selectors only.
@@ -34,12 +39,12 @@ function withTaskRuntimeHeaders(headers, requestUrl, method, env = process.env)
34
39
  // Some platform operations materialize Tasks outside the Task router. Keep
35
40
  // their exact POST routes here; action/library edits, picker reads and other
36
41
  // integration routes must never receive the companion credential.
37
- const taskMutation = /^\/api\/tasks(?:\/|$)/.test(target.pathname);
42
+ const taskMutation = WITH_TASK_RUNTIME_HEADERS_RE.test(target.pathname);
38
43
  const taskCreation = method.toUpperCase() === 'POST' && [
39
- /^\/api\/agents\/[^/]+\/agent-actions\/[^/]+\/run\/?$/,
40
- /^\/api\/(?:shortcuts|task-templates)\/[^/]+\/(?:instantiate|trigger)\/?$/,
41
- /^\/api\/templates\/[^/]+\/(?:instantiate|fork)\/?$/,
42
- /^\/api\/store\/services\/[^/]+\/install\/?$/,
44
+ WITH_TASK_RUNTIME_HEADERS_RE_2,
45
+ WITH_TASK_RUNTIME_HEADERS_RE_3,
46
+ WITH_TASK_RUNTIME_HEADERS_RE_4,
47
+ WITH_TASK_RUNTIME_HEADERS_RE_5,
43
48
  ].some((route) => route.test(target.pathname));
44
49
  if (!taskMutation && !taskCreation)
45
50
  return sent;
@@ -20,6 +20,7 @@ exports.unverifiedOutcomeNote = unverifiedOutcomeNote;
20
20
  * functions below.
21
21
  */
22
22
  const data_provider_1 = require("@skrr-ai/data-provider");
23
+ const PARSE_TASK_OUTPUT_BLOCK_RE = /---TASK_OUTPUT---\s*([\s\S]*?)\s*---END_OUTPUT---/;
23
24
  const TASK_OUTPUT_FIELDS = ['status', 'summary', 'artifacts', 'verdict'];
24
25
  /**
25
26
  * Mirror of `api/server/services/taskCompletionFormatting.js:parseTaskOutputBlock`.
@@ -36,7 +37,7 @@ const TASK_OUTPUT_FIELDS = ['status', 'summary', 'artifacts', 'verdict'];
36
37
  function parseTaskOutputBlock(body) {
37
38
  if (!body)
38
39
  return null;
39
- const match = body.match(/---TASK_OUTPUT---\s*([\s\S]*?)\s*---END_OUTPUT---/);
40
+ const match = body.match(PARSE_TASK_OUTPUT_BLOCK_RE);
40
41
  if (!match)
41
42
  return null;
42
43
  const block = match[1];
@@ -60,7 +61,7 @@ function parseTaskOutputBlock(body) {
60
61
  function unattributedBlockLines(body) {
61
62
  if (!body)
62
63
  return [];
63
- const match = body.match(/---TASK_OUTPUT---\s*([\s\S]*?)\s*---END_OUTPUT---/);
64
+ const match = body.match(PARSE_TASK_OUTPUT_BLOCK_RE);
64
65
  if (!match)
65
66
  return [];
66
67
  const known = new RegExp(`^(?:${TASK_OUTPUT_FIELDS.join('|')}):`, 'i');
@@ -9,6 +9,10 @@ exports.parsePortableTaskExport = parsePortableTaskExport;
9
9
  exports.importExternalKey = importExternalKey;
10
10
  exports.importableTaskNode = importableTaskNode;
11
11
  const node_crypto_1 = require("node:crypto");
12
+ const CSV_CELL_RE = /[",\r\n]/;
13
+ const CSV_CELL_RE_2 = /"/g;
14
+ const PARSE_CSV_RE = /\r$/;
15
+ const IMPORT_EXTERNAL_KEY_RE = /\/+$/;
12
16
  const PORTABLE_FIELDS = [
13
17
  'identifier',
14
18
  'externalKey',
@@ -98,7 +102,7 @@ function csvCell(value) {
98
102
  let raw = '';
99
103
  if (value !== undefined && value !== null)
100
104
  raw = typeof value === 'string' ? value : JSON.stringify(value);
101
- return /[",\r\n]/.test(raw) ? `"${raw.replace(/"/g, '""')}"` : raw;
105
+ return CSV_CELL_RE.test(raw) ? `"${raw.replace(CSV_CELL_RE_2, '""')}"` : raw;
102
106
  }
103
107
  /** CSV intentionally keeps arrays as JSON cells: commas in tags and comments round-trip safely. */
104
108
  function portableTaskExportToCsv(exported) {
@@ -141,7 +145,7 @@ function parseCsv(text) {
141
145
  cell = '';
142
146
  }
143
147
  else if (char === '\n') {
144
- row.push(cell.replace(/\r$/, ''));
148
+ row.push(cell.replace(PARSE_CSV_RE, ''));
145
149
  rows.push(row);
146
150
  row = [];
147
151
  cell = '';
@@ -152,7 +156,7 @@ function parseCsv(text) {
152
156
  if (quoted)
153
157
  throw new Error('CSV has an unterminated quoted field');
154
158
  if (cell || row.length) {
155
- row.push(cell.replace(/\r$/, ''));
159
+ row.push(cell.replace(PARSE_CSV_RE, ''));
156
160
  rows.push(row);
157
161
  }
158
162
  return rows.filter((value) => value.some((cellValue) => cellValue.length > 0));
@@ -269,11 +273,11 @@ function importExternalKey(prefix, node) {
269
273
  : node.tempId;
270
274
  if (!prefix)
271
275
  return current === node.tempId && !node.externalKey ? undefined : current;
272
- const base = `${prefix.replace(/\/+$/, '')}/${current}`;
276
+ const base = `${prefix.replace(IMPORT_EXTERNAL_KEY_RE, '')}/${current}`;
273
277
  if (base.length <= 300)
274
278
  return base;
275
279
  const hash = (0, node_crypto_1.createHash)('sha256').update(current).digest('hex').slice(0, 16);
276
- const shortPrefix = prefix.replace(/\/+$/, '').slice(0, 280 - hash.length);
280
+ const shortPrefix = prefix.replace(IMPORT_EXTERNAL_KEY_RE, '').slice(0, 280 - hash.length);
277
281
  return `${shortPrefix}/${hash}`;
278
282
  }
279
283
  /** Remove unsupported/sensitive fields before passing a portable row to create-tree's planner. */
package/dist/lib/tasks.js CHANGED
@@ -46,6 +46,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
46
46
  const prompt_1 = require("./prompt");
47
47
  const projects_1 = require("./projects");
48
48
  const node_path_1 = require("node:path");
49
+ const NORMALIZE_VERDICT_RE = /[\s-]+/g;
49
50
  /**
50
51
  * `--goal` on `tasks update`. `none`, `null` and `clear` detach the goal: PATCH
51
52
  * sends `goalId: null`. Anything else names a goal. `clear` is accepted because
@@ -1228,7 +1229,7 @@ function normalizeVerdict(value) {
1228
1229
  return String(value ?? '')
1229
1230
  .trim()
1230
1231
  .toLowerCase()
1231
- .replace(/[\s-]+/g, '_');
1232
+ .replace(NORMALIZE_VERDICT_RE, '_');
1232
1233
  }
1233
1234
  /**
1234
1235
  * Does this verdict mean anything to the server?
@@ -111,6 +111,13 @@ export interface SchedulerLimits {
111
111
  triggerFireCount?: number;
112
112
  triggerFiresToday?: number;
113
113
  note?: string;
114
+ /** Slots the scheduler claimed whose trigger has not started yet (OSK-22638); a single-trigger read only. */
115
+ awaitingStart?: {
116
+ awaitingStart: number;
117
+ running: number;
118
+ oldestDueAt?: string;
119
+ oldestAgeMs?: number;
120
+ };
114
121
  }
115
122
  export interface TriggerDefinition {
116
123
  id?: string;
@@ -151,6 +158,8 @@ export interface TriggerDefinition {
151
158
  status?: string;
152
159
  lastError?: string;
153
160
  lastErrorAt?: string;
161
+ /** A process that cannot register schedules asked for this one; not a failure (OSK-22570). */
162
+ deferredAt?: string;
154
163
  };
155
164
  /**
156
165
  * Server-DERIVED: maintained by a managed producer, so the mutation routes
@@ -638,6 +647,10 @@ export declare function nextRunLabel(trigger: TriggerDefinition): string;
638
647
  * and nothing on the agent, trigger or schedule surfaces reported it — so
639
648
  * an operator looking at an enabled trigger had no reason to doubt it
640
649
  * (OSK-7727).
650
+ * `syncing` — `enabled: true`, `unscheduled`, with `deferredAt` and NO `lastError`. A process that
651
+ * cannot register a schedule (the worker that finishes a durable heartbeat) asked the scheduler
652
+ * leader to; nothing has failed. It reads as a state, not as `!unscheduled`, which tells an operator a
653
+ * healthy decision is a fault (OSK-22570). With a `lastError` it is a failure again.
641
654
  * `spent` — a `once` trigger that has fired. It has no next occurrence, so
642
655
  * `enabled` and "will fire again" diverge forever after the single fire; an
643
656
  * agent that has been used for a while accumulates a growing list of
@@ -689,6 +702,14 @@ export declare const TRIGGER_WINDOW_FLAG_HELP = "JSON object {\"enabled\":true,\
689
702
  * the limit is reached it drops every later slot without running or recording it (OSK-22526).
690
703
  */
691
704
  export declare function schedulerLimitSentence(limits: SchedulerLimits): string;
705
+ /**
706
+ * Slots the scheduler has claimed and charged to the run limit whose trigger has not started, once they
707
+ * are late enough to matter. The audit has no row for such a slot and `claimed` runs ahead of the fires
708
+ * counted, which reads like a lost claim; it is a durable outbox row the dispatcher keeps retrying
709
+ * (a rollout, a held admission gate or a dead dispatcher's lease makes it late). Undefined when there
710
+ * is nothing late to say, so a healthy trigger prints nothing.
711
+ */
712
+ export declare function claimsAwaitingStartLine(limits?: SchedulerLimits | null): string | undefined;
692
713
  /**
693
714
  * Human phrasing for a trigger's enabled state (OSK-4886).
694
715
  *
@@ -54,6 +54,7 @@ exports.renderTriggerList = renderTriggerList;
54
54
  exports.formatDuplicateSubscriptionWarning = formatDuplicateSubscriptionWarning;
55
55
  exports.windowAuthoringAdvice = windowAuthoringAdvice;
56
56
  exports.schedulerLimitSentence = schedulerLimitSentence;
57
+ exports.claimsAwaitingStartLine = claimsAwaitingStartLine;
57
58
  exports.armedStateLabel = armedStateLabel;
58
59
  exports.writeModeLabel = writeModeLabel;
59
60
  exports.webhookIngestUrl = webhookIngestUrl;
@@ -79,6 +80,9 @@ const node_fs_1 = require("node:fs");
79
80
  const http_error_1 = require("./http-error");
80
81
  const format_1 = require("./format");
81
82
  const planOutcome_1 = require("./planOutcome");
83
+ const PARSE_JSON_ARRAY_RE = /^[[{]/;
84
+ const ARMED_STATE_LABEL_RE = /^skipped:(.+)$/;
85
+ const WEBHOOK_INGEST_URL_RE = /\/+$/;
82
86
  exports.TRIGGER_KINDS = [
83
87
  'schedule',
84
88
  'once',
@@ -451,7 +455,7 @@ function parseJsonArray(raw, flagName) {
451
455
  return undefined;
452
456
  let text = raw;
453
457
  const trimmed = raw.trim();
454
- if (trimmed.startsWith('@') || (!/^[[{]/.test(trimmed) && (0, node_fs_1.existsSync)(trimmed))) {
458
+ if (trimmed.startsWith('@') || (!PARSE_JSON_ARRAY_RE.test(trimmed) && (0, node_fs_1.existsSync)(trimmed))) {
455
459
  const path = trimmed.startsWith('@') ? trimmed.slice(1) : trimmed;
456
460
  try {
457
461
  text = (0, node_fs_1.readFileSync)(path, 'utf8');
@@ -1250,6 +1254,10 @@ function nextRunLabel(trigger) {
1250
1254
  * and nothing on the agent, trigger or schedule surfaces reported it — so
1251
1255
  * an operator looking at an enabled trigger had no reason to doubt it
1252
1256
  * (OSK-7727).
1257
+ * `syncing` — `enabled: true`, `unscheduled`, with `deferredAt` and NO `lastError`. A process that
1258
+ * cannot register a schedule (the worker that finishes a durable heartbeat) asked the scheduler
1259
+ * leader to; nothing has failed. It reads as a state, not as `!unscheduled`, which tells an operator a
1260
+ * healthy decision is a fault (OSK-22570). With a `lastError` it is a failure again.
1253
1261
  * `spent` — a `once` trigger that has fired. It has no next occurrence, so
1254
1262
  * `enabled` and "will fire again" diverge forever after the single fire; an
1255
1263
  * agent that has been used for a while accumulates a growing list of
@@ -1260,6 +1268,11 @@ function armedLabel(trigger) {
1260
1268
  if (trigger.enabled === false)
1261
1269
  return 'no';
1262
1270
  const sync = trigger.scheduleSync?.status;
1271
+ if (sync === 'unscheduled' &&
1272
+ trigger.scheduleSync?.deferredAt &&
1273
+ !trigger.scheduleSync.lastError) {
1274
+ return 'syncing';
1275
+ }
1263
1276
  if (sync && sync !== 'ok')
1264
1277
  return `!${sync}`;
1265
1278
  if (trigger.kind === 'once' && trigger.once && trigger.once.firedAt) {
@@ -1426,6 +1439,28 @@ function schedulerLimitSentence(limits) {
1426
1439
  return (`the scheduler has used ${used} (the trigger itself has ${counted}), so it skips every slot` +
1427
1440
  `${lifetime ? '' : ' until the day rolls over'}; see \`skrr triggers preflight\``);
1428
1441
  }
1442
+ /** A claim younger than this is an ordinary dispatch in flight, not a late slot (OSK-22638). */
1443
+ const LATE_CLAIM_GRACE_MS = 2 * 60 * 1000;
1444
+ /**
1445
+ * Slots the scheduler has claimed and charged to the run limit whose trigger has not started, once they
1446
+ * are late enough to matter. The audit has no row for such a slot and `claimed` runs ahead of the fires
1447
+ * counted, which reads like a lost claim; it is a durable outbox row the dispatcher keeps retrying
1448
+ * (a rollout, a held admission gate or a dead dispatcher's lease makes it late). Undefined when there
1449
+ * is nothing late to say, so a healthy trigger prints nothing.
1450
+ */
1451
+ function claimsAwaitingStartLine(limits) {
1452
+ const waiting = limits?.awaitingStart;
1453
+ const age = waiting?.oldestAgeMs;
1454
+ if (!waiting || !waiting.awaitingStart || age === undefined || age < LATE_CLAIM_GRACE_MS) {
1455
+ return undefined;
1456
+ }
1457
+ const count = waiting.awaitingStart;
1458
+ const minutes = Math.round(age / 60_000);
1459
+ const late = minutes >= 120 ? `${Math.round(minutes / 60)} h` : `${minutes} min`;
1460
+ return (`Claimed: ${count} slot${count === 1 ? '' : 's'} the scheduler claimed ${count === 1 ? 'has' : 'have'} ` +
1461
+ `not started: the oldest was due ${waiting.oldestDueAt ?? '-'} (${late} ago). Each is charged to the run ` +
1462
+ `limit and the dispatcher keeps retrying it, so it is late, not lost`);
1463
+ }
1429
1464
  /**
1430
1465
  * Human phrasing for a trigger's enabled state (OSK-4886).
1431
1466
  *
@@ -1477,7 +1512,7 @@ windowVerdict) {
1477
1512
  // "Will fire" is the row's intent. A platform-managed row whose owner is fenced (Always-On off) ticks on
1478
1513
  // schedule and is skipped every time, and the same screen's `Fires:` line says so; the first line a reader
1479
1514
  // meets must not say the opposite (dogfood df-261031-commitment-authoring, OSK-21103).
1480
- const skipped = typeof lastResult === 'string' ? /^skipped:(.+)$/.exec(lastResult) : null;
1515
+ const skipped = typeof lastResult === 'string' ? ARMED_STATE_LABEL_RE.exec(lastResult) : null;
1481
1516
  return skipped
1482
1517
  ? `yes — but its last tick was skipped (${skipped[1]}), so it did not run`
1483
1518
  : 'yes — will fire';
@@ -1514,7 +1549,7 @@ const WEBHOOK_INGEST_KINDS = new Set(['on_demand', 'form', 'chat_message']);
1514
1549
  * the configured base URL rather than guessed.
1515
1550
  */
1516
1551
  function webhookIngestUrl(baseURL, triggerId) {
1517
- return `${String(baseURL).replace(/\/+$/, '')}/api/triggers/webhook/${encodeURIComponent(triggerId)}`;
1552
+ return `${String(baseURL).replace(WEBHOOK_INGEST_URL_RE, '')}/api/triggers/webhook/${encodeURIComponent(triggerId)}`;
1518
1553
  }
1519
1554
  /** An id or token that is short and plain, so it is safe in a command a person will paste. */
1520
1555
  const PLAIN_TOKEN = /^[A-Za-z0-9_.-]{1,64}$/;
@@ -1830,6 +1865,9 @@ function renderTriggerSummary(trigger, log, options = {}) {
1830
1865
  log(`${upcoming ? (dropped || windowed ? 'Next slot:' : 'Next run:') : 'Last run:'}${next.length > 0 ? ` ${next}` : ''}` +
1831
1866
  `${dropped ? ' (will be skipped: the scheduler\'s run limit is reached)' : windowNote}`);
1832
1867
  }
1868
+ const lateClaims = claimsAwaitingStartLine(trigger.schedulerLimits);
1869
+ if (lateClaims)
1870
+ log(lateClaims);
1833
1871
  /*
1834
1872
  * What actually happened when it fired.
1835
1873
  *
@@ -55,6 +55,12 @@ const path = __importStar(require("node:path"));
55
55
  const node_crypto_1 = require("node:crypto");
56
56
  const node_util_1 = require("node:util");
57
57
  const auth_core_1 = require("@skrr-ai/auth-core");
58
+ const NORMALIZE_BASE_URL_RE = /\/+$/;
59
+ const CLASSIFY_CLI_INSTALL_RE = /[/\\]Cellar[/\\]/;
60
+ const CLI_UPDATE_COMMAND_RE = /'/g;
61
+ const UPDATER_ENVIRONMENT_RE = /(?:TOKEN|SECRET|PASSWORD|CREDENTIAL|API_KEY|PRIVATE_KEY|AUTH_FD|AUTH_SOCK)/i;
62
+ const UPDATER_ENVIRONMENT_RE_2 = /^(?:SKRR_|OVERSKY_|OPENAI_|ANTHROPIC_|CODEX_|CLAUDE_|NODE_OPTIONS$)/i;
63
+ const SHOULD_CHECK_CLI_UPDATE_AT_STARTUP_RE = /^(?:--json(?:=|$)|--help$|-h$|--version$|-v$|--headless$|--print$|-p$|--non-interactive$|--no-interactive$)/;
58
64
  /** One update owner and one startup advisory. npm continues to own npm bytes;
59
65
  * the durable worker waits for cooperating CLI sessions before replacing them.
60
66
  * All update decisions are observable, and checking never schedules a change. */
@@ -69,7 +75,7 @@ function cacheFilePath(env = process.env) {
69
75
  return path.join((0, auth_core_1.resolveConfigRoot)(env), 'cli-update-check.json');
70
76
  }
71
77
  function normalizeBaseUrl(url) {
72
- return url.trim().replace(/\/+$/, '').toLowerCase();
78
+ return url.trim().replace(NORMALIZE_BASE_URL_RE, '').toLowerCase();
73
79
  }
74
80
  function isTruthyEnv(value) {
75
81
  return !!value && ['1', 'true', 'on', 'yes'].includes(value.trim().toLowerCase());
@@ -179,7 +185,7 @@ function classifyCliInstall(env, argv, npmGlobalRoot, probeWritable = true) {
179
185
  return { kind: 'bundled' };
180
186
  const entry = argv[1];
181
187
  try {
182
- if (entry && /[/\\]Cellar[/\\]/.test(fs.realpathSync(entry)))
188
+ if (entry && CLASSIFY_CLI_INSTALL_RE.test(fs.realpathSync(entry)))
183
189
  return { kind: 'homebrew' };
184
190
  }
185
191
  catch {
@@ -285,7 +291,7 @@ function cliUpdateCommand(owner, npmPrefix) {
285
291
  switch (owner) {
286
292
  case 'npm-global':
287
293
  return npmPrefix
288
- ? `npm install --global --prefix '${npmPrefix.replace(/'/g, "'\\''")}' ${CLI_PACKAGE}@latest`
294
+ ? `npm install --global --prefix '${npmPrefix.replace(CLI_UPDATE_COMMAND_RE, "'\\''")}' ${CLI_PACKAGE}@latest`
289
295
  : `npm install -g ${CLI_PACKAGE}@latest`;
290
296
  case 'npm-local':
291
297
  return `Use npm in the project that owns ${CLI_PACKAGE}`;
@@ -503,7 +509,7 @@ async function checkCliUpdate(opts) {
503
509
  // Independent probes share the same 1.5-second bound rather than adding
504
510
  // an npm probe after the network timeout on every first invocation.
505
511
  const [response, npmRoot] = await Promise.all([
506
- fetch(`${opts.baseURL.replace(/\/+$/, '')}/api/config/cli-version`, {
512
+ fetch(`${opts.baseURL.replace(NORMALIZE_BASE_URL_RE, '')}/api/config/cli-version`, {
507
513
  signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
508
514
  headers: { accept: 'application/json' },
509
515
  }),
@@ -557,8 +563,7 @@ function npmExecutable(env) {
557
563
  }
558
564
  function updaterEnvironment(env) {
559
565
  // The public npm package update does not require application credentials.
560
- return Object.fromEntries(Object.entries(env).filter(([key]) => !/(?:TOKEN|SECRET|PASSWORD|CREDENTIAL|API_KEY|PRIVATE_KEY|AUTH_FD|AUTH_SOCK)/i.test(key) &&
561
- !/^(?:SKRR_|OVERSKY_|OPENAI_|ANTHROPIC_|CODEX_|CLAUDE_|NODE_OPTIONS$)/i.test(key)));
566
+ return Object.fromEntries(Object.entries(env).filter(([key]) => !UPDATER_ENVIRONMENT_RE.test(key) && !UPDATER_ENVIRONMENT_RE_2.test(key)));
562
567
  }
563
568
  function startWorker(directory, env) {
564
569
  const sourceDir = path.resolve(__dirname, '..', '..', 'bin');
@@ -704,7 +709,7 @@ async function maybeWarnOutdatedCli(opts) {
704
709
  function shouldCheckCliUpdateAtStartup(argv, isTTY, env = process.env) {
705
710
  if (!isTTY || isNudgeSuppressed(env) || isTruthyEnv(env.CI))
706
711
  return false;
707
- if (argv.some((arg) => /^(?:--json(?:=|$)|--help$|-h$|--version$|-v$|--headless$|--print$|-p$|--non-interactive$|--no-interactive$)/.test(arg)))
712
+ if (argv.some((arg) => SHOULD_CHECK_CLI_UPDATE_AT_STARTUP_RE.test(arg)))
708
713
  return false;
709
714
  const command = argv
710
715
  .filter((arg) => !arg.startsWith('-'))
@@ -10,6 +10,7 @@ exports.renderUsageOverview = renderUsageOverview;
10
10
  exports.renderUsageReference = renderUsageReference;
11
11
  exports.auditUsageBudgets = auditUsageBudgets;
12
12
  const command_manifest_1 = require("./command-manifest");
13
+ const COMPACT_RE = /\s+/g;
13
14
  /**
14
15
  * `skrr commands --json` is intentionally exhaustive. That makes it the right
15
16
  * source of truth, but a bad first read for an agent: loading several hundred
@@ -236,7 +237,7 @@ function exampleFor(entry, bin) {
236
237
  return compact(raw || `${bin} ${entry.command}`, 96);
237
238
  }
238
239
  function compact(value, maxCharacters) {
239
- const normalized = value.replace(/\s+/g, ' ').trim();
240
+ const normalized = value.replace(COMPACT_RE, ' ').trim();
240
241
  if (normalized.length <= maxCharacters)
241
242
  return normalized;
242
243
  return `${normalized.slice(0, Math.max(0, maxCharacters - 1)).trimEnd()}…`;
@@ -6,6 +6,7 @@ exports.expectedPriceFlagMicros = expectedPriceFlagMicros;
6
6
  exports.expectedPriceMismatchMessage = expectedPriceMismatchMessage;
7
7
  exports.withUsdPrices = withUsdPrices;
8
8
  const data_provider_1 = require("@skrr-ai/data-provider");
9
+ const PARSE_USD_CENTS_RE = /^\d+(\.\d{1,2})?$/;
9
10
  /**
10
11
  * Parse a user-typed USD amount ("5", "2.50") into integer micros.
11
12
  *
@@ -30,7 +31,7 @@ function usdToMicrosOrZero(amount) {
30
31
  }
31
32
  function parseUsdCents(amount) {
32
33
  const trimmed = amount.trim();
33
- if (!/^\d+(\.\d{1,2})?$/.test(trimmed))
34
+ if (!PARSE_USD_CENTS_RE.test(trimmed))
34
35
  return null;
35
36
  const [whole, frac = ''] = trimmed.split('.');
36
37
  const cents = Number(whole) * 100 + Number(frac.padEnd(2, '0'));