@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
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.triggerApi = exports.TRIGGER_LIMIT_CEILING = exports.TRIGGER_MODE_FLAG_DESCRIPTION = exports.TRIGGER_WINDOW_FLAG_HELP = exports.AgentTriggerScopeError = exports.TRIGGER_MODE_REQUIRED_FLAGS = exports.TRIGGER_CREATE_FIELD_FLAGS = exports.FLAG_OWNER_KINDS = exports.SCOPE_IMPLIED_REF_KEY = exports.TRIGGER_EVENT_CATALOG = exports.TRIGGER_EVENT_ENTITY_TYPES = exports.TRIGGER_CHAT_AUTH_MODES = exports.TRIGGER_CHAT_RESPONSE_MODES = exports.TRIGGER_CHAT_MODES = exports.TRIGGER_FORM_RESPONSE_MODES = exports.TRIGGER_CONCURRENCY_POLICIES = exports.TRIGGER_EVENT_FILTER_MODES = exports.TRIGGER_EXECUTOR_MODES = exports.TRIGGER_SCOPE_KINDS = exports.TRIGGER_KINDS = void 0;
3
+ exports.triggerApi = exports.TRIGGER_LIMIT_CEILING = exports.TRIGGER_MODE_FLAG_DESCRIPTION = exports.TRIGGER_WINDOW_FLAG_HELP = exports.AgentTriggerScopeError = exports.FIRE_FOLLOW_MAX_WAIT_MS = exports.FIRE_FOLLOW_POLL_MS = exports.TRIGGER_MODE_REQUIRED_FLAGS = exports.TRIGGER_CREATE_FIELD_FLAGS = exports.FLAG_OWNER_KINDS = exports.SCOPE_IMPLIED_REF_KEY = exports.TRIGGER_EVENT_CATALOG = exports.TRIGGER_EVENT_ENTITY_TYPES = exports.TRIGGER_CHAT_AUTH_MODES = exports.TRIGGER_CHAT_RESPONSE_MODES = exports.TRIGGER_CHAT_MODES = exports.TRIGGER_FORM_RESPONSE_MODES = exports.TRIGGER_CONCURRENCY_POLICIES = exports.TRIGGER_EVENT_FILTER_MODES = exports.TRIGGER_EXECUTOR_MODES = exports.TRIGGER_SCOPE_KINDS = exports.TRIGGER_KINDS = void 0;
4
4
  exports.validateEventReference = validateEventReference;
5
5
  exports.validateEventFilter = validateEventFilter;
6
6
  exports.serverEventCatalogIncludes = serverEventCatalogIncludes;
@@ -27,6 +27,11 @@ exports.mergeTriggerKindConfig = mergeTriggerKindConfig;
27
27
  exports.assertKindFlagsApply = assertKindFlagsApply;
28
28
  exports.assertModeRequiredFlags = assertModeRequiredFlags;
29
29
  exports.describeScheduledFire = describeScheduledFire;
30
+ exports.isFireAccepted = isFireAccepted;
31
+ exports.fireRecordIsSettled = fireRecordIsSettled;
32
+ exports.followAcceptedFire = followAcceptedFire;
33
+ exports.settleFireAnswer = settleFireAnswer;
34
+ exports.fireFollowCommand = fireFollowCommand;
30
35
  exports.fireWasAccepted = fireWasAccepted;
31
36
  exports.describeStrictFireRefusal = describeStrictFireRefusal;
32
37
  exports.describeFireDetail = describeFireDetail;
@@ -49,6 +54,7 @@ exports.renderTriggerList = renderTriggerList;
49
54
  exports.formatDuplicateSubscriptionWarning = formatDuplicateSubscriptionWarning;
50
55
  exports.windowAuthoringAdvice = windowAuthoringAdvice;
51
56
  exports.schedulerLimitSentence = schedulerLimitSentence;
57
+ exports.claimsAwaitingStartLine = claimsAwaitingStartLine;
52
58
  exports.armedStateLabel = armedStateLabel;
53
59
  exports.writeModeLabel = writeModeLabel;
54
60
  exports.webhookIngestUrl = webhookIngestUrl;
@@ -60,16 +66,23 @@ exports.scheduleSummaryLine = scheduleSummaryLine;
60
66
  exports.builtinActionLine = builtinActionLine;
61
67
  exports.renderTriggerSummary = renderTriggerSummary;
62
68
  exports.renderLegacyRuns = renderLegacyRuns;
69
+ exports.windowVerdictLines = windowVerdictLines;
70
+ exports.lastResultLabel = lastResultLabel;
63
71
  exports.clockSkipAuditExplanation = clockSkipAuditExplanation;
64
72
  exports.coalescedAuditExplanation = coalescedAuditExplanation;
65
73
  exports.policyCardSentence = policyCardSentence;
66
74
  exports.policyAuditExplanation = policyAuditExplanation;
75
+ exports.fireReasonText = fireReasonText;
67
76
  exports.renderFireAudit = renderFireAudit;
68
77
  exports.describeTriggerBudget = describeTriggerBudget;
69
78
  const data_provider_1 = require("@skrr-ai/data-provider");
70
79
  const node_fs_1 = require("node:fs");
80
+ const http_error_1 = require("./http-error");
71
81
  const format_1 = require("./format");
72
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 = /\/+$/;
73
86
  exports.TRIGGER_KINDS = [
74
87
  'schedule',
75
88
  'once',
@@ -442,7 +455,7 @@ function parseJsonArray(raw, flagName) {
442
455
  return undefined;
443
456
  let text = raw;
444
457
  const trimmed = raw.trim();
445
- 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))) {
446
459
  const path = trimmed.startsWith('@') ? trimmed.slice(1) : trimmed;
447
460
  try {
448
461
  text = (0, node_fs_1.readFileSync)(path, 'utf8');
@@ -904,6 +917,85 @@ function describeScheduledFire(result) {
904
917
  }
905
918
  return undefined;
906
919
  }
920
+ function isFireAccepted(value) {
921
+ return (Boolean(value) &&
922
+ typeof value === 'object' &&
923
+ value.accepted === true &&
924
+ value.outcome === 'running');
925
+ }
926
+ /** A fire record still being worked: `pending` is the claim before the outcome is written. */
927
+ function fireRecordIsSettled(record) {
928
+ return Boolean(record) && typeof record.outcome === 'string' && record.outcome !== 'pending';
929
+ }
930
+ exports.FIRE_FOLLOW_POLL_MS = 3_000;
931
+ /** Long enough for the slowest fire seen (215 s) with room; then the poll command is printed instead. */
932
+ exports.FIRE_FOLLOW_MAX_WAIT_MS = 6 * 60 * 1000;
933
+ /**
934
+ * Follow a fire the server answered 202 for, by reading its record until the outcome is written.
935
+ * `result` is the record shaped like a synchronous fire answer (`outcome`, `reason`, ...), so the same
936
+ * strict check and detail lines apply. A record that does not exist yet is waited for: the claim is
937
+ * written a moment after the 202. Gives up after `maxWaitMs`, saying so rather than guessing.
938
+ */
939
+ async function followAcceptedFire(options) {
940
+ const { triggerId, accepted, fetchFire = async (id, fireId) => (await exports.triggerApi.fireDetail(id, fireId)), sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), now = Date.now, pollMs = exports.FIRE_FOLLOW_POLL_MS, maxWaitMs = exports.FIRE_FOLLOW_MAX_WAIT_MS, onWaiting, } = options;
941
+ const occurrenceId = accepted.occurrenceId;
942
+ if (!occurrenceId)
943
+ return { settled: false, occurrenceId: null };
944
+ const startedAt = now();
945
+ for (;;) {
946
+ let record = null;
947
+ try {
948
+ record = await fetchFire(triggerId, occurrenceId);
949
+ }
950
+ catch (error) {
951
+ // Not written yet (404) or a read that failed: keep waiting; the budget below bounds it.
952
+ const status = (0, http_error_1.httpStatusOf)(error);
953
+ if (status !== undefined && status !== 404 && status < 500)
954
+ throw error;
955
+ }
956
+ if (fireRecordIsSettled(record)) {
957
+ return { settled: true, result: { ...record, ok: true, occurrenceId } };
958
+ }
959
+ const elapsed = now() - startedAt;
960
+ if (elapsed >= maxWaitMs)
961
+ return { settled: false, occurrenceId };
962
+ onWaiting?.(elapsed);
963
+ await sleep(pollMs);
964
+ }
965
+ }
966
+ /**
967
+ * A fire answer in hand: a result passes through; a `202` is followed until its record settles. Says
968
+ * (on stderr, once) that it is waiting, because a fire that took 215 s looks like a hang otherwise.
969
+ * `running` is a fire still going when the CLI stopped waiting, with the command that reads it later.
970
+ */
971
+ async function settleFireAnswer(options) {
972
+ const { triggerId, agentId, bin, answer, follow = followAcceptedFire, note = () => { } } = options;
973
+ if (!isFireAccepted(answer))
974
+ return { running: false, result: answer };
975
+ let noted = false;
976
+ const followed = await follow({
977
+ triggerId,
978
+ accepted: answer,
979
+ onWaiting: () => {
980
+ if (noted)
981
+ return;
982
+ noted = true;
983
+ note(`The fire is still running on the server (occurrence ${answer.occurrenceId}); waiting for its result...`);
984
+ },
985
+ });
986
+ if (followed.settled)
987
+ return { running: false, result: followed.result };
988
+ return {
989
+ running: true,
990
+ answer,
991
+ command: fireFollowCommand(bin, agentId, triggerId, answer.occurrenceId),
992
+ };
993
+ }
994
+ /** The command that reads a fire later, for a fire still running when the CLI stopped waiting. */
995
+ function fireFollowCommand(bin, agentId, triggerId, occurrenceId) {
996
+ const target = agentId ? `agents triggers runs ${agentId} ${triggerId}` : `triggers runs ${triggerId}`;
997
+ return `${bin} ${target}${occurrenceId ? ` --fire ${occurrenceId}` : ''}`;
998
+ }
907
999
  /**
908
1000
  * Was the fire admitted? `in_progress` and `awaiting_runtime` are admissions whose terminal arrives
909
1001
  * later (every agent-turn fire answers `in_progress`), and a repeat of a fire that was admitted is
@@ -948,6 +1040,11 @@ function describeFireDetail(result) {
948
1040
  else if (typeof result.retryAt === 'string' && result.retryAt) {
949
1041
  lines.push(`Try again after ${result.retryAt}.`);
950
1042
  }
1043
+ // What a watcher said about itself (what it looked at, whether a cap cut the read, why each thing it
1044
+ // found was or was not surfaced), when the fire's record carries it (OSK-22414).
1045
+ const recordSummary = result.metadata?.summary;
1046
+ if (typeof recordSummary === 'string' && recordSummary.trim())
1047
+ lines.push(recordSummary.trim());
951
1048
  // A fire option the server does not read is named, because dropping it without a word left a caller
952
1049
  // unable to tell whether `--from-json` was honoured (OSK-15498).
953
1050
  if (Array.isArray(result.ignoredOptions) && result.ignoredOptions.length > 0) {
@@ -1333,6 +1430,28 @@ function schedulerLimitSentence(limits) {
1333
1430
  return (`the scheduler has used ${used} (the trigger itself has ${counted}), so it skips every slot` +
1334
1431
  `${lifetime ? '' : ' until the day rolls over'}; see \`skrr triggers preflight\``);
1335
1432
  }
1433
+ /** A claim younger than this is an ordinary dispatch in flight, not a late slot (OSK-22638). */
1434
+ const LATE_CLAIM_GRACE_MS = 2 * 60 * 1000;
1435
+ /**
1436
+ * Slots the scheduler has claimed and charged to the run limit whose trigger has not started, once they
1437
+ * are late enough to matter. The audit has no row for such a slot and `claimed` runs ahead of the fires
1438
+ * counted, which reads like a lost claim; it is a durable outbox row the dispatcher keeps retrying
1439
+ * (a rollout, a held admission gate or a dead dispatcher's lease makes it late). Undefined when there
1440
+ * is nothing late to say, so a healthy trigger prints nothing.
1441
+ */
1442
+ function claimsAwaitingStartLine(limits) {
1443
+ const waiting = limits?.awaitingStart;
1444
+ const age = waiting?.oldestAgeMs;
1445
+ if (!waiting || !waiting.awaitingStart || age === undefined || age < LATE_CLAIM_GRACE_MS) {
1446
+ return undefined;
1447
+ }
1448
+ const count = waiting.awaitingStart;
1449
+ const minutes = Math.round(age / 60_000);
1450
+ const late = minutes >= 120 ? `${Math.round(minutes / 60)} h` : `${minutes} min`;
1451
+ return (`Claimed: ${count} slot${count === 1 ? '' : 's'} the scheduler claimed ${count === 1 ? 'has' : 'have'} ` +
1452
+ `not started: the oldest was due ${waiting.oldestDueAt ?? '-'} (${late} ago). Each is charged to the run ` +
1453
+ `limit and the dispatcher keeps retrying it, so it is late, not lost`);
1454
+ }
1336
1455
  /**
1337
1456
  * Human phrasing for a trigger's enabled state (OSK-4886).
1338
1457
  *
@@ -1341,24 +1460,50 @@ function schedulerLimitSentence(limits) {
1341
1460
  * trigger did not plainly confirm it is live.
1342
1461
  */
1343
1462
  function armedStateLabel(enabled, lastResult,
1344
- /** Pass for a `once` trigger: how often its single fire ran. A spent one-shot is not waiting to be enabled (OSK-21509). */
1463
+ /**
1464
+ * Pass for a `once` trigger: how often its single fire ran, whether it has been consumed (`firedAt`, which a
1465
+ * skip sets too), and its id for the re-arm command. A spent one-shot is not waiting to be enabled (OSK-21509).
1466
+ */
1345
1467
  oneShot,
1346
1468
  /** The server's reading of the scheduler's run limits: a reached limit means no slot will run (OSK-22526). */
1347
- schedulerLimits) {
1469
+ schedulerLimits,
1470
+ /** The server's reading of what the trigger's window does to its next runs (OSK-22529). */
1471
+ windowVerdict) {
1348
1472
  if (enabled === false && oneShot && (oneShot.fires ?? 0) > 0) {
1349
1473
  return 'no — already fired (a one-shot trigger is spent once it fires)';
1350
1474
  }
1351
1475
  if (enabled === false && oneShot && (oneShot.failures ?? 0) > 0) {
1352
1476
  return 'no — its one fire already ran and did not succeed (a one-shot trigger is spent; see `skrr triggers audit`)';
1353
1477
  }
1478
+ // A one-shot has one occurrence, and a skip consumes it as a fire does: it is spent whether or not it is
1479
+ // enabled, and enabling it again re-arms nothing (OSK-22529).
1480
+ if (oneShot?.firedAt) {
1481
+ if ((oneShot.fires ?? 0) > 0)
1482
+ return 'no — already fired (a one-shot trigger is spent once it fires)';
1483
+ if ((oneShot.failures ?? 0) > 0) {
1484
+ return 'no — its one fire already ran and did not succeed (a one-shot trigger is spent; see `skrr triggers audit`)';
1485
+ }
1486
+ const id = oneShot.id ?? '<id>';
1487
+ const code = typeof lastResult === 'string' ? lastResult.split(':')[0] : '';
1488
+ const why = clockSkipAuditExplanation({ reason: code, outcome: code, source: 'once' })?.summary ??
1489
+ (lastResult ? `its one occurrence ended ${lastResult}` : 'its one occurrence is used up');
1490
+ return (`no — spent: ${why.charAt(0).toLowerCase()}${why.slice(1)}, and a one-shot does not retry. ` +
1491
+ `Re-arm it with \`skrr triggers update ${id} --at <time>\`${enabled === false ? ` and then \`skrr triggers enable ${id}\`` : ''}`);
1492
+ }
1354
1493
  if (enabled === false)
1355
1494
  return 'no — inert until enabled';
1356
1495
  if (schedulerLimits?.state === 'reached')
1357
1496
  return `no — ${schedulerLimitSentence(schedulerLimits)}`;
1497
+ if (windowVerdict?.state === 'blocks_all') {
1498
+ return `no — its ${windowVerdict.windows.map(windowSpan).join(' and ')} block every projected run, so nothing will fire (see \`skrr triggers preflight\`)`;
1499
+ }
1500
+ if (windowVerdict?.state === 'blocks_next') {
1501
+ return `yes — but its next run falls ${windowVerdict.reason === 'outside_working_hours' ? 'outside its working hours' : 'inside its quiet hours'} and will be skipped`;
1502
+ }
1358
1503
  // "Will fire" is the row's intent. A platform-managed row whose owner is fenced (Always-On off) ticks on
1359
1504
  // schedule and is skipped every time, and the same screen's `Fires:` line says so; the first line a reader
1360
1505
  // meets must not say the opposite (dogfood df-261031-commitment-authoring, OSK-21103).
1361
- const skipped = typeof lastResult === 'string' ? /^skipped:(.+)$/.exec(lastResult) : null;
1506
+ const skipped = typeof lastResult === 'string' ? ARMED_STATE_LABEL_RE.exec(lastResult) : null;
1362
1507
  return skipped
1363
1508
  ? `yes — but its last tick was skipped (${skipped[1]}), so it did not run`
1364
1509
  : 'yes — will fire';
@@ -1395,7 +1540,7 @@ const WEBHOOK_INGEST_KINDS = new Set(['on_demand', 'form', 'chat_message']);
1395
1540
  * the configured base URL rather than guessed.
1396
1541
  */
1397
1542
  function webhookIngestUrl(baseURL, triggerId) {
1398
- return `${String(baseURL).replace(/\/+$/, '')}/api/triggers/webhook/${encodeURIComponent(triggerId)}`;
1543
+ return `${String(baseURL).replace(WEBHOOK_INGEST_URL_RE, '')}/api/triggers/webhook/${encodeURIComponent(triggerId)}`;
1399
1544
  }
1400
1545
  /** An id or token that is short and plain, so it is safe in a command a person will paste. */
1401
1546
  const PLAIN_TOKEN = /^[A-Za-z0-9_.-]{1,64}$/;
@@ -1595,8 +1740,13 @@ function renderTriggerSummary(trigger, log, options = {}) {
1595
1740
  log(`ID: ${trigger.id ?? '-'}`);
1596
1741
  log(`Kind: ${trigger.kind ?? '-'}`);
1597
1742
  log(`Armed: ${armedStateLabel(trigger.enabled, trigger.audit?.lastResult, trigger.kind === 'once'
1598
- ? { fires: trigger.audit?.fireCount, failures: trigger.audit?.failureCount }
1599
- : undefined, trigger.schedulerLimits)}`);
1743
+ ? {
1744
+ fires: trigger.audit?.fireCount,
1745
+ failures: trigger.audit?.failureCount,
1746
+ firedAt: trigger.once?.firedAt,
1747
+ id: trigger.id,
1748
+ }
1749
+ : undefined, trigger.schedulerLimits, trigger.windowVerdict)}`);
1600
1750
  log(`Scope: ${scopeLabel(trigger)}`);
1601
1751
  /*
1602
1752
  * Say when the row is not yours to change.
@@ -1631,6 +1781,8 @@ function renderTriggerSummary(trigger, log, options = {}) {
1631
1781
  const schedule = scheduleSummaryLine(trigger);
1632
1782
  if (schedule)
1633
1783
  log(`Schedule: ${schedule}`);
1784
+ for (const line of windowVerdictLines(trigger))
1785
+ log(line);
1634
1786
  const debounceText = debounceSummaryLine(trigger);
1635
1787
  if (debounceText)
1636
1788
  log(`Debounce: ${debounceText}`);
@@ -1691,9 +1843,22 @@ function renderTriggerSummary(trigger, log, options = {}) {
1691
1843
  const upcoming = Boolean(scheduledRunAt(trigger));
1692
1844
  // A slot the scheduler will drop is not a run to wait for (OSK-22526).
1693
1845
  const dropped = upcoming && trigger.schedulerLimits?.state === 'reached';
1694
- log(`${upcoming ? (dropped ? 'Next slot:' : 'Next run:') : 'Last run:'}${next.length > 0 ? ` ${next}` : ''}` +
1695
- `${dropped ? ' (will be skipped: the scheduler\'s run limit is reached)' : ''}`);
1846
+ // The same for a slot the trigger's own window will skip (OSK-22529).
1847
+ const verdict = trigger.windowVerdict;
1848
+ const windowed = upcoming &&
1849
+ !dropped &&
1850
+ verdict !== undefined &&
1851
+ (verdict.state === 'blocks_all' || verdict.state === 'blocks_next') &&
1852
+ Date.parse(String(verdict.next)) === Date.parse(next);
1853
+ const windowNote = windowed
1854
+ ? ` (will be skipped: ${verdict?.reason === 'outside_working_hours' ? 'outside the working hours' : 'inside the quiet hours'})`
1855
+ : '';
1856
+ log(`${upcoming ? (dropped || windowed ? 'Next slot:' : 'Next run:') : 'Last run:'}${next.length > 0 ? ` ${next}` : ''}` +
1857
+ `${dropped ? ' (will be skipped: the scheduler\'s run limit is reached)' : windowNote}`);
1696
1858
  }
1859
+ const lateClaims = claimsAwaitingStartLine(trigger.schedulerLimits);
1860
+ if (lateClaims)
1861
+ log(lateClaims);
1697
1862
  /*
1698
1863
  * What actually happened when it fired.
1699
1864
  *
@@ -1717,8 +1882,9 @@ function renderTriggerSummary(trigger, log, options = {}) {
1717
1882
  const parts = [`${fires} succeeded`];
1718
1883
  if (failures !== undefined)
1719
1884
  parts.push(`${failures} failed`);
1720
- if (audit.lastResult)
1721
- parts.push(`last ${audit.lastResult}`);
1885
+ const last = lastResultLabel(trigger);
1886
+ if (last)
1887
+ parts.push(`last ${last}`);
1722
1888
  log(`Fires: ${parts.join(', ')}`);
1723
1889
  }
1724
1890
  // `last tools_refused:...` above is a success that held a refusal. Say what that means.
@@ -1775,15 +1941,60 @@ function skippedWindowClause(window, kind) {
1775
1941
  if (!window || window.kind !== kind || !window.start || !window.end)
1776
1942
  return null;
1777
1943
  const zone = window.timezone || 'UTC';
1778
- const label = kind === 'working_hours' ? 'working hours' : 'quiet hours';
1779
1944
  const judged = window.localTime
1780
1945
  ? `It was judged at ${window.localTime} ${zone}`
1781
1946
  : `It was judged at ${window.evaluatedAt ?? 'the time it came due'}`;
1782
1947
  const relation = kind === 'working_hours' ? 'outside' : 'inside';
1783
- const defaulted = window.timezoneDefaulted
1784
- ? ' The window sets no timezone, so it is read in UTC.'
1785
- : '';
1786
- return `${judged}, ${relation} the trigger's ${label} ${window.start}-${window.end} ${zone}.${defaulted}`;
1948
+ return `${judged}, ${relation} the trigger's ${windowSpan(window)}.${windowZoneNote(window)}`;
1949
+ }
1950
+ /** `working hours 09:00-17:00 UTC`: the window as the audit and `show` both name it. */
1951
+ function windowSpan(window) {
1952
+ const label = window.kind === 'working_hours' ? 'working hours' : 'quiet hours';
1953
+ return `${label} ${window.start}-${window.end} ${window.timezone || 'UTC'}`;
1954
+ }
1955
+ /** The sentence that says a window chose no zone, or nothing. */
1956
+ function windowZoneNote(window) {
1957
+ return window.timezoneDefaulted ? ' The window sets no timezone, so it is read in UTC.' : '';
1958
+ }
1959
+ /**
1960
+ * The window lines `triggers show` prints (OSK-22529): each enabled window with its zone, then what it does
1961
+ * to the next occurrences, in the server's reading. Empty for a trigger with no window, or when the server
1962
+ * did not send one (an older server): unknown is not printed as clear.
1963
+ */
1964
+ function windowVerdictLines(trigger) {
1965
+ const verdict = trigger.windowVerdict;
1966
+ if (!verdict?.windows?.length)
1967
+ return [];
1968
+ const lines = verdict.windows.map((window) => `Window: ${windowSpan(window)}.${windowZoneNote(window)}`);
1969
+ const relation = verdict.reason === 'outside_working_hours' ? 'outside the working hours' : 'inside the quiet hours';
1970
+ if (verdict.state === 'blocks_all') {
1971
+ lines.push(verdict.checked === 1
1972
+ ? ` The next run, ${verdict.next}, falls ${relation}: it will be skipped and nothing else is scheduled.`
1973
+ : ` Blocks every projected run (the next ${verdict.checked}, from ${verdict.next}, all ${relation}): none will run until the window or the schedule changes.`);
1974
+ }
1975
+ else if (verdict.state === 'blocks_next') {
1976
+ lines.push(` The next run, ${verdict.next}, falls ${relation} and will be skipped; ${verdict.firstClear} is the first that runs.`);
1977
+ }
1978
+ return lines;
1979
+ }
1980
+ /**
1981
+ * `Fires: ..., last <this>`. A window skip is recorded as `outcome:reason` with the same code on both sides,
1982
+ * so the line read `last outside_working_hours:outside_working_hours`; it says the sentence the audit says
1983
+ * (`clockSkipAuditExplanation`), and any other result is printed as recorded.
1984
+ */
1985
+ function lastResultLabel(trigger) {
1986
+ const last = trigger.audit?.lastResult;
1987
+ if (typeof last !== 'string' || !last)
1988
+ return undefined;
1989
+ const code = /^(outside_working_hours|inside_quiet_hours)(?::\1)?$/.exec(last)?.[1];
1990
+ if (!code)
1991
+ return last;
1992
+ const summary = clockSkipAuditExplanation({
1993
+ reason: code,
1994
+ outcome: code,
1995
+ source: trigger.kind === 'once' ? 'once' : 'schedule',
1996
+ })?.summary;
1997
+ return summary ? summary.charAt(0).toLowerCase() + summary.slice(1) : last;
1787
1998
  }
1788
1999
  /**
1789
2000
  * Why a fire was skipped by a working or quiet window, in words. Both trigger-level windows (Gate 5)
@@ -1829,13 +2040,31 @@ function clockSkipAuditExplanation(fire) {
1829
2040
  * (gate 7) finding an earlier fire still holding it: this occurrence was dropped, not queued, and an
1830
2041
  * occurrence that was dropped is consumed, so it is not retried (OSK-22509). The raw code alone read
1831
2042
  * as a fire that was still in progress.
2043
+ *
2044
+ * The server records who held the lane and when its lease lapses (`metadata.lane`, OSK-22625). A lane
2045
+ * is held by a lease its holder renews every minute, so `holdsUntil` is the latest the lane stays
2046
+ * busy if the holder has died; a live holder keeps extending it. A fire from before the server wrote
2047
+ * this keeps the general sentence.
1832
2048
  */
1833
2049
  function coalescedAuditExplanation(fire) {
1834
2050
  if (fire.outcome !== 'coalesced')
1835
2051
  return null;
2052
+ const lane = fire.metadata
2053
+ ?.lane;
2054
+ const holdsUntil = typeof lane?.holdsUntil === 'string' && Number.isFinite(Date.parse(lane.holdsUntil))
2055
+ ? lane.holdsUntil
2056
+ : null;
2057
+ const heldBy = typeof lane?.heldBy?.occurrenceId === 'string' ? lane.heldBy.occurrenceId : null;
2058
+ const holder = holdsUntil
2059
+ ? ` The lane was held${heldBy ? ` by occurrence ${heldBy}` : ' by an earlier fire'} and stays busy until ${holdsUntil} at the latest: its holder renews the lease every minute, so a run that is still alive keeps it and one that died (for example when the server task running it was replaced) releases it at that time.`
2060
+ : '';
1836
2061
  return {
1837
- summary: 'Not run: lane already busy',
1838
- detail: 'An earlier fire under the same concurrency lane was still running when this occurrence came due, so it was dropped, not queued, and will not retry automatically. `skrr triggers preflight <id> --json` shows the lane (concurrencyKey); a trigger that stores no key coalesces only against itself.',
2062
+ summary: holdsUntil
2063
+ ? `Not run: lane busy until ${holdsUntil.slice(11, 19)}Z`
2064
+ : 'Not run: lane already busy',
2065
+ detail: 'An earlier fire under the same concurrency lane was still running when this occurrence came due, so it was dropped, not queued, and will not retry automatically.' +
2066
+ holder +
2067
+ ' `skrr triggers preflight <id> --json` shows the lane (concurrencyKey); a trigger that stores no key coalesces only against itself.',
1839
2068
  };
1840
2069
  }
1841
2070
  /** Why no new inbox card was written, by the code the server records. Unknown codes are shown as they are. */
@@ -1894,14 +2123,35 @@ function policyAuditExplanation(fire) {
1894
2123
  detail: `The Agent policy prevented autonomous execution. Review the trigger preflight and Agent policy. ${card}`,
1895
2124
  };
1896
2125
  }
1897
- function renderFireAudit(fires, log) {
2126
+ /**
2127
+ * The words for the few fire reasons that are only ever a code (OSK-22643). A reason a person can act on
2128
+ * already has its own explanation above; these two are what the scheduler records when it finishes
2129
+ * normally or runs out of runs, and read as an error when printed bare. Anything else is left as the
2130
+ * server wrote it.
2131
+ */
2132
+ function fireReasonText(reason) {
2133
+ switch (reason) {
2134
+ case 'durable_execution_completed':
2135
+ return 'Completed';
2136
+ case 'max_runs_reached':
2137
+ return 'The maximum number of runs was reached';
2138
+ default:
2139
+ return reason;
2140
+ }
2141
+ }
2142
+ function renderFireAudit(fires, log, waiting, options = {}) {
2143
+ // An armed one-shot whose time passed has no fire record yet. "No records" alone reads as
2144
+ // "not yet", so say that it is late and what it is waiting for.
2145
+ if (waiting) {
2146
+ log(`This one-shot is ${waiting.message} (${(0, format_1.formatElapsed)(waiting.bySeconds)} past its time). It has not fired, so there is no fire record yet; one appears when the scheduler picks it up.`);
2147
+ }
1898
2148
  if (fires.length === 0) {
1899
2149
  log('No fire audit records.');
1900
2150
  return;
1901
2151
  }
1902
2152
  (0, format_1.renderTable)(fires.map((fire) => ({
1903
2153
  trigger: fire.triggerId ?? '',
1904
- firedAt: fire.firedAt ?? '-',
2154
+ firedAt: options.timeZone ? (0, format_1.zonedTime)(fire.firedAt, options.timeZone, { seconds: false }) : (fire.firedAt ?? '-'),
1905
2155
  outcome: fire.outcome ?? '-',
1906
2156
  source: fire.source ?? '-',
1907
2157
  reason: fire.metadata?.recordKind === 'schedule_end_marker'
@@ -1910,7 +2160,7 @@ function renderFireAudit(fires, log) {
1910
2160
  policyAuditExplanation(fire)?.summary ??
1911
2161
  coalescedAuditExplanation(fire)?.summary ??
1912
2162
  (0, planOutcome_1.fireAuditPlanOutcomeSummary)(fire) ??
1913
- fire.reason ??
2163
+ (fire.reason ? fireReasonText(fire.reason) : undefined) ??
1914
2164
  fire.errorMessage ??
1915
2165
  '',
1916
2166
  duration: fire.durationMs === undefined ? '-' : `${fire.durationMs}ms`,
@@ -1955,7 +2205,14 @@ exports.triggerApi = {
1955
2205
  }),
1956
2206
  setAuthorizationRevoked: (id, revoked) => data_provider_1.request.patch(`/api/triggers/${encodeURIComponent(id)}/authorization`, { revoked }),
1957
2207
  delete: (id) => data_provider_1.request.delete(`/api/triggers/${encodeURIComponent(id)}`),
1958
- fire: (id, body) => data_provider_1.request.post(`/api/triggers/${encodeURIComponent(id)}/fire-now`, body),
2208
+ fire: (id, body) =>
2209
+ // `Prefer: respond-async` (RFC 7240): a watcher fire can run for minutes and the edge gives up at
2210
+ // 60 s, so the server answers 202 with the occurrence to follow once the fire has outlived a short
2211
+ // wait, and the fast fires still answer with their result. A server that predates it ignores the
2212
+ // header and answers as it always did (OSK-22624).
2213
+ data_provider_1.request.postWithOptions(`/api/triggers/${encodeURIComponent(id)}/fire-now`, body, {
2214
+ headers: { Prefer: 'respond-async' },
2215
+ }),
1959
2216
  /**
1960
2217
  * Dry-run: per-gate verdicts, rendered prompt, resolved destination and the
1961
2218
  * next projected fires — without firing (gap analysis §A3).
@@ -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'));
@@ -46,6 +46,7 @@ exports.withDataUrls = withDataUrls;
46
46
  exports.workflowUrlFrom = workflowUrlFrom;
47
47
  const data_provider_1 = require("@skrr-ai/data-provider");
48
48
  const publicEndpoints_generated_1 = require("./publicEndpoints.generated");
49
+ const TRIM_TRAILING_SLASH_RE = /\/+$/;
49
50
  /**
50
51
  * Site-relative canonical path for an entity, or `null` when the required id is
51
52
  * missing. When a task/goal knows its hosting space we emit the canonical
@@ -430,5 +431,5 @@ function encodeId(value) {
430
431
  return raw ? encodeURIComponent(raw) : '';
431
432
  }
432
433
  function trimTrailingSlash(value) {
433
- return value.replace(/\/+$/, '');
434
+ return value.replace(TRIM_TRAILING_SLASH_RE, '');
434
435
  }