@useorgx/openclaw-plugin 0.4.8 → 0.7.0

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 (284) hide show
  1. package/README.md +35 -0
  2. package/dashboard/dist/assets/BJgZIVUQ.js +53 -0
  3. package/dashboard/dist/assets/BJgZIVUQ.js.br +0 -0
  4. package/dashboard/dist/assets/BJgZIVUQ.js.gz +0 -0
  5. package/dashboard/dist/assets/BXWDRGm-.js +1 -0
  6. package/dashboard/dist/assets/BXWDRGm-.js.br +0 -0
  7. package/dashboard/dist/assets/BXWDRGm-.js.gz +0 -0
  8. package/dashboard/dist/assets/BgOYB78t.js +4 -0
  9. package/dashboard/dist/assets/BgOYB78t.js.br +0 -0
  10. package/dashboard/dist/assets/BgOYB78t.js.gz +0 -0
  11. package/dashboard/dist/assets/C-KIc3Wc.js.br +0 -0
  12. package/dashboard/dist/assets/C-KIc3Wc.js.gz +0 -0
  13. package/dashboard/dist/assets/CE38zU4U.js +1 -0
  14. package/dashboard/dist/assets/CE38zU4U.js.br +0 -0
  15. package/dashboard/dist/assets/CE38zU4U.js.gz +0 -0
  16. package/dashboard/dist/assets/CFGKRAzG.js +1 -0
  17. package/dashboard/dist/assets/CFGKRAzG.js.br +0 -0
  18. package/dashboard/dist/assets/CFGKRAzG.js.gz +0 -0
  19. package/dashboard/dist/assets/CGGR2GZh.js +1 -0
  20. package/dashboard/dist/assets/CGGR2GZh.js.br +0 -0
  21. package/dashboard/dist/assets/CGGR2GZh.js.gz +0 -0
  22. package/dashboard/dist/assets/CL_wXqR7.js +1 -0
  23. package/dashboard/dist/assets/CL_wXqR7.js.br +0 -0
  24. package/dashboard/dist/assets/CL_wXqR7.js.gz +0 -0
  25. package/dashboard/dist/assets/CPFiTmlw.js +8 -0
  26. package/dashboard/dist/assets/CPFiTmlw.js.br +0 -0
  27. package/dashboard/dist/assets/CPFiTmlw.js.gz +0 -0
  28. package/dashboard/dist/assets/CZZTvkQZ.js +1 -0
  29. package/dashboard/dist/assets/CZZTvkQZ.js.br +0 -0
  30. package/dashboard/dist/assets/CZZTvkQZ.js.gz +0 -0
  31. package/dashboard/dist/assets/{CpJsfbXo.js → CxQ08qFN.js} +2 -2
  32. package/dashboard/dist/assets/CxQ08qFN.js.br +0 -0
  33. package/dashboard/dist/assets/CxQ08qFN.js.gz +0 -0
  34. package/dashboard/dist/assets/D-bf6hEI.js +213 -0
  35. package/dashboard/dist/assets/D-bf6hEI.js.br +0 -0
  36. package/dashboard/dist/assets/D-bf6hEI.js.gz +0 -0
  37. package/dashboard/dist/assets/DG6y9wJI.js +2 -0
  38. package/dashboard/dist/assets/DG6y9wJI.js.br +0 -0
  39. package/dashboard/dist/assets/DG6y9wJI.js.gz +0 -0
  40. package/dashboard/dist/assets/DNxKz-GV.js +1 -0
  41. package/dashboard/dist/assets/DNxKz-GV.js.br +0 -0
  42. package/dashboard/dist/assets/DNxKz-GV.js.gz +0 -0
  43. package/dashboard/dist/assets/DW_rKUic.js +11 -0
  44. package/dashboard/dist/assets/DW_rKUic.js.br +0 -0
  45. package/dashboard/dist/assets/DW_rKUic.js.gz +0 -0
  46. package/dashboard/dist/assets/DbNoijHm.js +1 -0
  47. package/dashboard/dist/assets/DbNoijHm.js.br +0 -0
  48. package/dashboard/dist/assets/DbNoijHm.js.gz +0 -0
  49. package/dashboard/dist/assets/DjcdE6jC.js +2 -0
  50. package/dashboard/dist/assets/DjcdE6jC.js.br +0 -0
  51. package/dashboard/dist/assets/DjcdE6jC.js.gz +0 -0
  52. package/dashboard/dist/assets/FZYuCDnt.js +1 -0
  53. package/dashboard/dist/assets/FZYuCDnt.js.br +0 -0
  54. package/dashboard/dist/assets/FZYuCDnt.js.gz +0 -0
  55. package/dashboard/dist/assets/PAUiij_z.js +1 -0
  56. package/dashboard/dist/assets/PAUiij_z.js.br +0 -0
  57. package/dashboard/dist/assets/PAUiij_z.js.gz +0 -0
  58. package/dashboard/dist/assets/cNrhgGc1.js +8 -0
  59. package/dashboard/dist/assets/cNrhgGc1.js.br +0 -0
  60. package/dashboard/dist/assets/cNrhgGc1.js.gz +0 -0
  61. package/dashboard/dist/assets/h5biQs2I.css +1 -0
  62. package/dashboard/dist/assets/h5biQs2I.css.br +0 -0
  63. package/dashboard/dist/assets/h5biQs2I.css.gz +0 -0
  64. package/dashboard/dist/assets/ic2FaMnh.js +1 -0
  65. package/dashboard/dist/assets/ic2FaMnh.js.br +0 -0
  66. package/dashboard/dist/assets/ic2FaMnh.js.gz +0 -0
  67. package/dashboard/dist/assets/nByHNHoW.js +1 -0
  68. package/dashboard/dist/assets/nByHNHoW.js.br +0 -0
  69. package/dashboard/dist/assets/nByHNHoW.js.gz +0 -0
  70. package/dashboard/dist/assets/qm8xLgv-.css +1 -0
  71. package/dashboard/dist/assets/qm8xLgv-.css.br +0 -0
  72. package/dashboard/dist/assets/qm8xLgv-.css.gz +0 -0
  73. package/dashboard/dist/assets/tS9mbYZi.js +1 -0
  74. package/dashboard/dist/assets/tS9mbYZi.js.br +0 -0
  75. package/dashboard/dist/assets/tS9mbYZi.js.gz +0 -0
  76. package/dashboard/dist/brand/anthropic-mark.svg.br +0 -0
  77. package/dashboard/dist/brand/anthropic-mark.svg.gz +0 -0
  78. package/dashboard/dist/brand/openai-mark.svg.br +0 -0
  79. package/dashboard/dist/brand/openai-mark.svg.gz +0 -0
  80. package/dashboard/dist/brand/openclaw-mark.svg.br +0 -0
  81. package/dashboard/dist/brand/openclaw-mark.svg.gz +0 -0
  82. package/dashboard/dist/brand/xandy-orchestrator.png +0 -0
  83. package/dashboard/dist/index.html +7 -5
  84. package/dashboard/dist/index.html.br +0 -0
  85. package/dashboard/dist/index.html.gz +0 -0
  86. package/dist/activity-actor-fields.js +26 -4
  87. package/dist/activity-store.js +38 -26
  88. package/dist/agent-context-store.js +84 -42
  89. package/dist/agent-run-store.js +49 -28
  90. package/dist/agent-suite.d.ts +9 -0
  91. package/dist/agent-suite.js +150 -17
  92. package/dist/artifacts/artifact-domain-schemas.d.ts +66 -0
  93. package/dist/artifacts/artifact-domain-schemas.js +357 -0
  94. package/dist/artifacts/register-artifact.d.ts +4 -3
  95. package/dist/artifacts/register-artifact.js +170 -57
  96. package/dist/auth/flows.d.ts +47 -0
  97. package/dist/auth/flows.js +169 -0
  98. package/dist/auth-store.js +6 -26
  99. package/dist/byok-store.js +5 -19
  100. package/dist/chat-store.d.ts +157 -0
  101. package/dist/chat-store.js +586 -0
  102. package/dist/cli/orgx.d.ts +66 -0
  103. package/dist/cli/orgx.js +102 -0
  104. package/dist/config/refresh.d.ts +32 -0
  105. package/dist/config/refresh.js +55 -0
  106. package/dist/config/resolution.d.ts +37 -0
  107. package/dist/config/resolution.js +178 -0
  108. package/dist/contracts/client.d.ts +43 -3
  109. package/dist/contracts/client.js +159 -30
  110. package/dist/contracts/retro-schema.d.ts +81 -0
  111. package/dist/contracts/retro-schema.js +80 -0
  112. package/dist/contracts/shared-types.d.ts +306 -0
  113. package/dist/contracts/shared-types.js +179 -0
  114. package/dist/contracts/skill-pack-schema.d.ts +192 -0
  115. package/dist/contracts/skill-pack-schema.js +180 -0
  116. package/dist/contracts/types.d.ts +224 -132
  117. package/dist/contracts/types.js +5 -0
  118. package/dist/entities/auto-assignment.d.ts +36 -0
  119. package/dist/entities/auto-assignment.js +141 -0
  120. package/dist/entity-comment-store.js +5 -25
  121. package/dist/event-sanitization.d.ts +11 -0
  122. package/dist/event-sanitization.js +113 -0
  123. package/dist/fs-utils.js +13 -1
  124. package/dist/gateway-watchdog.d.ts +5 -0
  125. package/dist/gateway-watchdog.js +50 -0
  126. package/dist/hash-utils.d.ts +2 -0
  127. package/dist/hash-utils.js +12 -0
  128. package/dist/hooks/post-reporting-event.mjs +1 -5
  129. package/dist/http/helpers/activity-headline.d.ts +10 -0
  130. package/dist/http/helpers/activity-headline.js +73 -0
  131. package/dist/http/helpers/artifact-fallback.d.ts +13 -0
  132. package/dist/http/helpers/artifact-fallback.js +148 -0
  133. package/dist/http/helpers/auto-continue-engine.d.ts +486 -0
  134. package/dist/http/helpers/auto-continue-engine.js +3563 -0
  135. package/dist/http/helpers/autopilot-operations.d.ts +176 -0
  136. package/dist/http/helpers/autopilot-operations.js +554 -0
  137. package/dist/http/helpers/autopilot-runtime.d.ts +43 -0
  138. package/dist/http/helpers/autopilot-runtime.js +607 -0
  139. package/dist/http/helpers/autopilot-slice-utils.d.ts +56 -0
  140. package/dist/http/helpers/autopilot-slice-utils.js +899 -0
  141. package/dist/http/helpers/decision-mapper.d.ts +52 -0
  142. package/dist/http/helpers/decision-mapper.js +260 -0
  143. package/dist/http/helpers/dispatch-lifecycle.d.ts +119 -0
  144. package/dist/http/helpers/dispatch-lifecycle.js +809 -0
  145. package/dist/http/helpers/hash-utils.d.ts +1 -0
  146. package/dist/http/helpers/hash-utils.js +1 -0
  147. package/dist/http/helpers/kickoff-context.d.ts +12 -0
  148. package/dist/http/helpers/kickoff-context.js +228 -0
  149. package/dist/http/helpers/llm-client.d.ts +47 -0
  150. package/dist/http/helpers/llm-client.js +256 -0
  151. package/dist/http/helpers/mission-control.d.ts +193 -0
  152. package/dist/http/helpers/mission-control.js +1383 -0
  153. package/dist/http/helpers/openclaw-cli.d.ts +37 -0
  154. package/dist/http/helpers/openclaw-cli.js +283 -0
  155. package/dist/http/helpers/runtime-sse.d.ts +20 -0
  156. package/dist/http/helpers/runtime-sse.js +110 -0
  157. package/dist/http/helpers/sentinel-catalog.d.ts +23 -0
  158. package/dist/http/helpers/sentinel-catalog.js +193 -0
  159. package/dist/http/helpers/session-classification.d.ts +9 -0
  160. package/dist/http/helpers/session-classification.js +564 -0
  161. package/dist/http/helpers/slice-experience-v2.d.ts +137 -0
  162. package/dist/http/helpers/slice-experience-v2.js +677 -0
  163. package/dist/http/helpers/slice-run-projections.d.ts +72 -0
  164. package/dist/http/helpers/slice-run-projections.js +860 -0
  165. package/dist/http/helpers/triage-mapper.d.ts +43 -0
  166. package/dist/http/helpers/triage-mapper.js +549 -0
  167. package/dist/http/helpers/value-utils.d.ts +6 -0
  168. package/dist/http/helpers/value-utils.js +72 -0
  169. package/dist/http/helpers/workspace-scope.d.ts +15 -0
  170. package/dist/http/helpers/workspace-scope.js +170 -0
  171. package/dist/http/index.d.ts +88 -0
  172. package/dist/http/index.js +3610 -0
  173. package/dist/http/router.d.ts +23 -0
  174. package/dist/http/router.js +23 -0
  175. package/dist/http/routes/agent-control.d.ts +79 -0
  176. package/dist/http/routes/agent-control.js +684 -0
  177. package/dist/http/routes/agent-suite.d.ts +38 -0
  178. package/dist/http/routes/agent-suite.js +397 -0
  179. package/dist/http/routes/agents-catalog.d.ts +40 -0
  180. package/dist/http/routes/agents-catalog.js +128 -0
  181. package/dist/http/routes/billing.d.ts +23 -0
  182. package/dist/http/routes/billing.js +55 -0
  183. package/dist/http/routes/chat.d.ts +19 -0
  184. package/dist/http/routes/chat.js +522 -0
  185. package/dist/http/routes/debug.d.ts +14 -0
  186. package/dist/http/routes/debug.js +21 -0
  187. package/dist/http/routes/decision-actions.d.ts +20 -0
  188. package/dist/http/routes/decision-actions.js +103 -0
  189. package/dist/http/routes/delegation.d.ts +19 -0
  190. package/dist/http/routes/delegation.js +32 -0
  191. package/dist/http/routes/dispatch-gateway-envelope.d.ts +25 -0
  192. package/dist/http/routes/dispatch-gateway-envelope.js +26 -0
  193. package/dist/http/routes/entities.d.ts +63 -0
  194. package/dist/http/routes/entities.js +440 -0
  195. package/dist/http/routes/entity-dynamic.d.ts +25 -0
  196. package/dist/http/routes/entity-dynamic.js +191 -0
  197. package/dist/http/routes/health.d.ts +22 -0
  198. package/dist/http/routes/health.js +49 -0
  199. package/dist/http/routes/live-legacy.d.ts +115 -0
  200. package/dist/http/routes/live-legacy.js +112 -0
  201. package/dist/http/routes/live-misc.d.ts +81 -0
  202. package/dist/http/routes/live-misc.js +426 -0
  203. package/dist/http/routes/live-snapshot.d.ts +136 -0
  204. package/dist/http/routes/live-snapshot.js +916 -0
  205. package/dist/http/routes/live-terminal.d.ts +11 -0
  206. package/dist/http/routes/live-terminal.js +261 -0
  207. package/dist/http/routes/live-triage.d.ts +61 -0
  208. package/dist/http/routes/live-triage.js +248 -0
  209. package/dist/http/routes/mission-control-actions.d.ts +131 -0
  210. package/dist/http/routes/mission-control-actions.js +1791 -0
  211. package/dist/http/routes/mission-control-read.d.ts +73 -0
  212. package/dist/http/routes/mission-control-read.js +1640 -0
  213. package/dist/http/routes/onboarding.d.ts +34 -0
  214. package/dist/http/routes/onboarding.js +101 -0
  215. package/dist/http/routes/realtime-orchestrator.d.ts +10 -0
  216. package/dist/http/routes/realtime-orchestrator.js +74 -0
  217. package/dist/http/routes/run-control.d.ts +27 -0
  218. package/dist/http/routes/run-control.js +96 -0
  219. package/dist/http/routes/runtime-hooks.d.ts +69 -0
  220. package/dist/http/routes/runtime-hooks.js +437 -0
  221. package/dist/http/routes/sentinels-catalog.d.ts +7 -0
  222. package/dist/http/routes/sentinels-catalog.js +24 -0
  223. package/dist/http/routes/settings-byok.d.ts +23 -0
  224. package/dist/http/routes/settings-byok.js +163 -0
  225. package/dist/http/routes/summary.d.ts +18 -0
  226. package/dist/http/routes/summary.js +49 -0
  227. package/dist/http/routes/usage.d.ts +24 -0
  228. package/dist/http/routes/usage.js +362 -0
  229. package/dist/http/routes/work-artifacts.d.ts +9 -0
  230. package/dist/http/routes/work-artifacts.js +55 -0
  231. package/dist/http/shared-state.d.ts +16 -0
  232. package/dist/http/shared-state.js +1 -0
  233. package/dist/http-handler.d.ts +1 -88
  234. package/dist/http-handler.js +1 -10605
  235. package/dist/index.js +287 -2284
  236. package/dist/json-utils.d.ts +1 -0
  237. package/dist/json-utils.js +8 -0
  238. package/dist/local-openclaw.js +29 -6
  239. package/dist/mcp-client-setup.js +3 -3
  240. package/dist/mcp-http-handler.js +33 -59
  241. package/dist/next-up-queue-store.d.ts +16 -1
  242. package/dist/next-up-queue-store.js +93 -25
  243. package/dist/outbox.d.ts +5 -0
  244. package/dist/outbox.js +113 -9
  245. package/dist/paths.js +24 -5
  246. package/dist/reporting/rollups.d.ts +53 -0
  247. package/dist/reporting/rollups.js +148 -0
  248. package/dist/retro/domain-templates.d.ts +45 -0
  249. package/dist/retro/domain-templates.js +297 -0
  250. package/dist/retro/quality-rubric.d.ts +33 -0
  251. package/dist/retro/quality-rubric.js +213 -0
  252. package/dist/runtime-cleanup.d.ts +18 -0
  253. package/dist/runtime-cleanup.js +87 -0
  254. package/dist/runtime-instance-store.js +5 -31
  255. package/dist/services/background.d.ts +34 -0
  256. package/dist/services/background.js +45 -0
  257. package/dist/services/experiment-randomization.d.ts +21 -0
  258. package/dist/services/experiment-randomization.js +63 -0
  259. package/dist/services/instrumentation.d.ts +29 -0
  260. package/dist/services/instrumentation.js +136 -0
  261. package/dist/skill-pack-state.d.ts +36 -5
  262. package/dist/skill-pack-state.js +273 -29
  263. package/dist/snapshot-store.js +5 -25
  264. package/dist/stores/json-store.d.ts +11 -0
  265. package/dist/stores/json-store.js +42 -0
  266. package/dist/sync/local-agent-telemetry.d.ts +13 -0
  267. package/dist/sync/local-agent-telemetry.js +128 -0
  268. package/dist/sync/outbox-replay.d.ts +55 -0
  269. package/dist/sync/outbox-replay.js +621 -0
  270. package/dist/team-context-store.d.ts +23 -0
  271. package/dist/team-context-store.js +116 -0
  272. package/dist/telemetry/posthog.js +4 -2
  273. package/dist/tools/core-tools.d.ts +72 -0
  274. package/dist/tools/core-tools.js +2270 -0
  275. package/dist/types.d.ts +2 -0
  276. package/dist/types.js +2 -0
  277. package/dist/worker-supervisor.js +23 -0
  278. package/package.json +14 -4
  279. package/dashboard/dist/assets/B3ziCA02.js +0 -8
  280. package/dashboard/dist/assets/BNeJ0kpF.js +0 -1
  281. package/dashboard/dist/assets/BzkiMPmM.js +0 -215
  282. package/dashboard/dist/assets/CUV9IHHi.js +0 -1
  283. package/dashboard/dist/assets/Ie7d9Iq2.css +0 -1
  284. package/dashboard/dist/assets/sAhvFnpk.js +0 -4
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Deterministic failure → triage item mapper.
3
+ *
4
+ * Takes raw activity/blocker/decision events and produces canonical
5
+ * `LiveTriageItem` objects with proof bundles and recommended actions.
6
+ */
7
+ import type { LiveTriageItem, LiveDecision } from "../../contracts/shared-types.js";
8
+ /**
9
+ * Map a raw failure event to a LiveTriageItem.
10
+ *
11
+ * Known failure types are mapped deterministically. Unknown types are
12
+ * classified via LLM with a safe heuristic fallback.
13
+ */
14
+ export declare function mapFailureToTriageItem(input: {
15
+ id: string;
16
+ failureType: string;
17
+ reason?: string | null;
18
+ provider?: string | null;
19
+ initiativeId?: string | null;
20
+ initiativeTitle?: string | null;
21
+ workstreamId?: string | null;
22
+ workstreamTitle?: string | null;
23
+ taskId?: string | null;
24
+ taskTitle?: string | null;
25
+ agentId?: string | null;
26
+ domain?: string | null;
27
+ sourceSystem?: string | null;
28
+ runId?: string | null;
29
+ logPath?: string | null;
30
+ outputPath?: string | null;
31
+ metadata?: Record<string, unknown>;
32
+ timestamp?: string;
33
+ }): Promise<LiveTriageItem>;
34
+ /**
35
+ * Map an existing LiveDecision to a LiveTriageItem for unified display.
36
+ */
37
+ export declare function mapDecisionToTriageItem(decision: LiveDecision): LiveTriageItem;
38
+ /**
39
+ * Deduplicate triage items by dedupeKey, merging occurrence counts.
40
+ */
41
+ export declare function deduplicateTriageItems(items: LiveTriageItem[]): LiveTriageItem[];
42
+ /** Supported failure types for triage mapping. */
43
+ export declare const SUPPORTED_FAILURE_TYPES: string[];
@@ -0,0 +1,549 @@
1
+ /**
2
+ * Deterministic failure → triage item mapper.
3
+ *
4
+ * Takes raw activity/blocker/decision events and produces canonical
5
+ * `LiveTriageItem` objects with proof bundles and recommended actions.
6
+ */
7
+ import { callLlmJson } from "./llm-client.js";
8
+ const FAILURE_MAPPINGS = {
9
+ credential_missing: {
10
+ kind: "blocked_intervention",
11
+ severity: "high",
12
+ recommendedAction: "Configure credentials for the required provider",
13
+ defaultTitle: (ctx) => `Credential required${ctx.provider ? ` for ${ctx.provider}` : ""}`,
14
+ defaultSummary: (ctx) => `${ctx.workstreamTitle ?? "A workstream"} is blocked because ${ctx.provider ?? "a provider"} credentials are missing or expired.`,
15
+ actions: (ctx) => [
16
+ {
17
+ action: "autofix",
18
+ label: "Configure credentials",
19
+ description: `Open credential settings for ${ctx.provider ?? "the provider"}`,
20
+ consequences: "Will open credential configuration. Autopilot resumes after setup.",
21
+ requiresNote: false,
22
+ available: true,
23
+ },
24
+ {
25
+ action: "snooze",
26
+ label: "Snooze 1 hour",
27
+ description: "Hide for 1 hour",
28
+ consequences: "Item reappears if credentials still missing after snooze period.",
29
+ requiresNote: false,
30
+ available: true,
31
+ },
32
+ {
33
+ action: "dismiss",
34
+ label: "Dismiss",
35
+ description: "Do not re-raise until root cause changes",
36
+ consequences: "Will not reappear unless a new credential failure occurs.",
37
+ requiresNote: true,
38
+ available: true,
39
+ },
40
+ ],
41
+ },
42
+ spawn_guard_blocked: {
43
+ kind: "blocked_intervention",
44
+ severity: "high",
45
+ recommendedAction: "Review quality gate or adjust domain limits",
46
+ defaultTitle: (ctx) => `Spawn guard blocked${ctx.workstreamTitle ? `: ${ctx.workstreamTitle}` : ""}`,
47
+ defaultSummary: (ctx) => `${ctx.workstreamTitle ?? "A workstream"} failed spawn guard checks. ${ctx.reason ?? "Quality gate threshold not met."}`,
48
+ actions: () => [
49
+ {
50
+ action: "approve",
51
+ label: "Approve exception",
52
+ description: "Allow this dispatch to proceed",
53
+ consequences: "Will re-dispatch to the agent, bypassing the quality gate for this run.",
54
+ requiresNote: false,
55
+ available: true,
56
+ },
57
+ {
58
+ action: "reject",
59
+ label: "Reassign",
60
+ description: "Reassign to a different agent or domain",
61
+ consequences: "Task returns to the queue for reassignment.",
62
+ requiresNote: false,
63
+ available: true,
64
+ },
65
+ {
66
+ action: "snooze",
67
+ label: "Pause and investigate",
68
+ description: "Snooze while investigating quality gate",
69
+ consequences: "Item reappears after snooze period.",
70
+ requiresNote: false,
71
+ available: true,
72
+ },
73
+ ],
74
+ },
75
+ spawn_guard_rate_limited: {
76
+ kind: "blocked_intervention",
77
+ severity: "medium",
78
+ recommendedAction: "Wait for rate limit recovery or override",
79
+ defaultTitle: (ctx) => `Rate limited${ctx.workstreamTitle ? `: ${ctx.workstreamTitle}` : ""}`,
80
+ defaultSummary: (ctx) => `${ctx.workstreamTitle ?? "A workstream"} is rate-limited by spawn guard. ${ctx.reason ?? "Will auto-recover."}`,
81
+ actions: () => [
82
+ {
83
+ action: "retry",
84
+ label: "Override and retry",
85
+ description: "Bypass rate limit for this dispatch",
86
+ consequences: "Will attempt dispatch immediately, ignoring rate limit.",
87
+ requiresNote: false,
88
+ available: true,
89
+ },
90
+ {
91
+ action: "snooze",
92
+ label: "Wait for recovery",
93
+ description: "Let rate limit recover naturally",
94
+ consequences: "Item reappears when rate limit window resets.",
95
+ requiresNote: false,
96
+ available: true,
97
+ },
98
+ ],
99
+ },
100
+ mcp_handshake_failure: {
101
+ kind: "failure_diagnostic",
102
+ severity: "high",
103
+ recommendedAction: "Check MCP server connectivity",
104
+ defaultTitle: () => "MCP connection failed",
105
+ defaultSummary: (ctx) => `The agent connection handshake failed. ${ctx.reason ?? "Check server connectivity and retry."}`,
106
+ actions: () => [
107
+ {
108
+ action: "retry",
109
+ label: "Retry connection",
110
+ description: "Attempt to reconnect to MCP server",
111
+ consequences: "Will retry the MCP handshake. Autopilot resumes if successful.",
112
+ requiresNote: false,
113
+ available: true,
114
+ },
115
+ {
116
+ action: "dismiss",
117
+ label: "Pause autopilot",
118
+ description: "Stop autopilot until connectivity is restored",
119
+ consequences: "Autopilot will stop. Manual restart required.",
120
+ requiresNote: false,
121
+ available: true,
122
+ },
123
+ ],
124
+ },
125
+ worker_exit_no_output: {
126
+ kind: "failure_diagnostic",
127
+ severity: "medium",
128
+ recommendedAction: "Review agent logs for crash cause",
129
+ defaultTitle: (ctx) => `Agent exited without output${ctx.workstreamTitle ? `: ${ctx.workstreamTitle}` : ""}`,
130
+ defaultSummary: (ctx) => `An agent run ended before returning a structured result. ${ctx.reason ?? "Check logs for the underlying cause."}`,
131
+ actions: () => [
132
+ {
133
+ action: "retry",
134
+ label: "Retry",
135
+ description: "Re-dispatch the task to the agent",
136
+ consequences: "Will re-dispatch to the engineering agent.",
137
+ requiresNote: false,
138
+ available: true,
139
+ },
140
+ {
141
+ action: "reject",
142
+ label: "Reassign",
143
+ description: "Reassign to a different agent",
144
+ consequences: "Task returns to the queue for reassignment.",
145
+ requiresNote: false,
146
+ available: true,
147
+ },
148
+ {
149
+ action: "dismiss",
150
+ label: "Dismiss",
151
+ description: "Mark as non-actionable",
152
+ consequences: "Will not reappear unless a new failure occurs.",
153
+ requiresNote: true,
154
+ available: true,
155
+ },
156
+ ],
157
+ },
158
+ workspace_conflict: {
159
+ kind: "decision_required",
160
+ severity: "high",
161
+ recommendedAction: "Resolve workspace conflict",
162
+ defaultTitle: () => "Workspace conflict detected",
163
+ defaultSummary: (ctx) => `A workspace conflict requires human resolution. ${ctx.reason ?? "Review and choose the correct workspace scope."}`,
164
+ actions: () => [
165
+ {
166
+ action: "approve",
167
+ label: "Resolve conflict",
168
+ description: "Choose the correct workspace and continue",
169
+ consequences: "Will apply workspace resolution and resume.",
170
+ requiresNote: true,
171
+ available: true,
172
+ },
173
+ {
174
+ action: "snooze",
175
+ label: "Snooze",
176
+ description: "Defer resolution",
177
+ consequences: "Item reappears after snooze period.",
178
+ requiresNote: false,
179
+ available: true,
180
+ },
181
+ ],
182
+ },
183
+ budget_exhausted: {
184
+ kind: "blocked_intervention",
185
+ severity: "critical",
186
+ recommendedAction: "Increase token budget or stop autopilot",
187
+ defaultTitle: () => "Token budget exhausted",
188
+ defaultSummary: (ctx) => `Autopilot has used the entire token budget. ${ctx.reason ?? "Increase budget or stop autopilot."}`,
189
+ actions: () => [
190
+ {
191
+ action: "autofix",
192
+ label: "Increase budget",
193
+ description: "Double the current token budget",
194
+ consequences: "Will increase budget and resume autopilot.",
195
+ requiresNote: false,
196
+ available: true,
197
+ },
198
+ {
199
+ action: "dismiss",
200
+ label: "Stop autopilot",
201
+ description: "Stop autopilot permanently",
202
+ consequences: "Autopilot will stop. Manual restart required.",
203
+ requiresNote: false,
204
+ available: true,
205
+ },
206
+ ],
207
+ },
208
+ stale_blocked_workstream: {
209
+ kind: "review_required",
210
+ severity: "medium",
211
+ recommendedAction: "Unblock or reassign workstream",
212
+ defaultTitle: (ctx) => `Stale blocked workstream${ctx.workstreamTitle ? `: ${ctx.workstreamTitle}` : ""}`,
213
+ defaultSummary: (ctx) => `${ctx.workstreamTitle ?? "A workstream"} has been blocked for an extended period. ${ctx.reason ?? "Review and unblock or reassign."}`,
214
+ actions: () => [
215
+ {
216
+ action: "retry",
217
+ label: "Unblock and retry",
218
+ description: "Clear block status and re-dispatch",
219
+ consequences: "Will clear the block and re-dispatch to the agent.",
220
+ requiresNote: false,
221
+ available: true,
222
+ },
223
+ {
224
+ action: "reject",
225
+ label: "Reassign",
226
+ description: "Reassign to a different workstream or agent",
227
+ consequences: "Task returns to the queue for reassignment.",
228
+ requiresNote: false,
229
+ available: true,
230
+ },
231
+ {
232
+ action: "dismiss",
233
+ label: "Archive",
234
+ description: "Archive this workstream",
235
+ consequences: "Workstream will be archived and removed from the queue.",
236
+ requiresNote: true,
237
+ available: true,
238
+ },
239
+ ],
240
+ },
241
+ };
242
+ const VALID_KINDS = new Set([
243
+ "blocked_intervention",
244
+ "decision_required",
245
+ "failure_diagnostic",
246
+ "review_required",
247
+ ]);
248
+ const VALID_SEVERITIES = new Set(["critical", "high", "medium", "low"]);
249
+ function parseLlmClassification(raw) {
250
+ try {
251
+ const obj = JSON.parse(raw);
252
+ if (typeof obj.kind !== "string" ||
253
+ typeof obj.severity !== "string" ||
254
+ typeof obj.title !== "string" ||
255
+ typeof obj.summary !== "string" ||
256
+ typeof obj.recommendedAction !== "string")
257
+ return null;
258
+ if (!VALID_KINDS.has(obj.kind) || !VALID_SEVERITIES.has(obj.severity))
259
+ return null;
260
+ return obj;
261
+ }
262
+ catch {
263
+ return null;
264
+ }
265
+ }
266
+ const LLM_CACHE_TTL_MS = 6 * 60 * 60_000; // 6 hours
267
+ /**
268
+ * Map a raw failure event to a LiveTriageItem.
269
+ *
270
+ * Known failure types are mapped deterministically. Unknown types are
271
+ * classified via LLM with a safe heuristic fallback.
272
+ */
273
+ export async function mapFailureToTriageItem(input) {
274
+ const mapping = FAILURE_MAPPINGS[input.failureType];
275
+ const ctx = {
276
+ failureType: input.failureType,
277
+ reason: input.reason,
278
+ provider: input.provider,
279
+ workstreamTitle: input.workstreamTitle,
280
+ workstreamId: input.workstreamId,
281
+ initiativeTitle: input.initiativeTitle,
282
+ initiativeId: input.initiativeId,
283
+ taskTitle: input.taskTitle,
284
+ taskId: input.taskId,
285
+ agentId: input.agentId,
286
+ domain: input.domain,
287
+ sourceSystem: input.sourceSystem,
288
+ metadata: input.metadata,
289
+ };
290
+ const now = input.timestamp ?? new Date().toISOString();
291
+ const proofBundle = {
292
+ artifactRefs: [],
293
+ fileChanges: [],
294
+ prRefs: [],
295
+ logRefs: input.logPath ? [input.logPath] : [],
296
+ decisionRefs: [],
297
+ };
298
+ if (input.outputPath) {
299
+ proofBundle.artifactRefs.push(input.outputPath);
300
+ }
301
+ const impact = {
302
+ initiativeCount: input.initiativeId ? 1 : 0,
303
+ workstreamCount: input.workstreamId ? 1 : 0,
304
+ downstreamBlockedCount: 0,
305
+ };
306
+ // --- Resolve kind / severity / title / summary / recommendedAction / actions ---
307
+ let kind;
308
+ let severity;
309
+ let title;
310
+ let summary;
311
+ let recommendedAction;
312
+ let actionContract;
313
+ if (mapping) {
314
+ // Deterministic path for known failure types
315
+ kind = mapping.kind;
316
+ severity = mapping.severity;
317
+ title = mapping.defaultTitle(ctx);
318
+ summary = mapping.defaultSummary(ctx);
319
+ recommendedAction = mapping.recommendedAction;
320
+ actionContract = mapping.actions(ctx);
321
+ }
322
+ else {
323
+ // LLM classification for unknown failure types
324
+ const genericFallback = () => ({
325
+ kind: "review_required",
326
+ severity: "medium",
327
+ title: "Unclassified issue",
328
+ summary: input.reason || "An issue occurred that requires review.",
329
+ recommendedAction: "Review the failure details and take appropriate action",
330
+ });
331
+ const llmResult = await callLlmJson({
332
+ taskId: "triage_unknown",
333
+ systemPrompt: 'Classify this operational failure for a triage queue. Return JSON: {"kind": "blocked_intervention" | "decision_required" | "review_required" | "failure_diagnostic", "severity": "critical" | "high" | "medium" | "low", "title": "...", "summary": "...", "recommendedAction": "..."}. Be concise and actionable.',
334
+ userPrompt: [
335
+ `Failure type: ${input.failureType}`,
336
+ input.reason ? `Reason: ${input.reason}` : null,
337
+ input.workstreamTitle
338
+ ? `Workstream: ${input.workstreamTitle}`
339
+ : null,
340
+ input.agentId ? `Agent: ${input.agentId}` : null,
341
+ input.domain ? `Domain: ${input.domain}` : null,
342
+ ]
343
+ .filter(Boolean)
344
+ .join("\n"),
345
+ model: "openai/gpt-4.1-mini",
346
+ maxTokens: 256,
347
+ cacheTtlMs: LLM_CACHE_TTL_MS,
348
+ }, parseLlmClassification, genericFallback);
349
+ const classified = llmResult.result;
350
+ kind = classified.kind;
351
+ severity = classified.severity;
352
+ title = classified.title;
353
+ summary = classified.summary;
354
+ recommendedAction = classified.recommendedAction;
355
+ // Generic action set for LLM-classified items
356
+ actionContract = [
357
+ {
358
+ action: "retry",
359
+ label: "Retry",
360
+ description: "Retry the failed operation",
361
+ consequences: "Will re-attempt the operation.",
362
+ requiresNote: false,
363
+ available: true,
364
+ },
365
+ {
366
+ action: "snooze",
367
+ label: "Snooze",
368
+ description: "Defer for later review",
369
+ consequences: "Item reappears after snooze period.",
370
+ requiresNote: false,
371
+ available: true,
372
+ },
373
+ {
374
+ action: "dismiss",
375
+ label: "Dismiss",
376
+ description: "Dismiss this item",
377
+ consequences: "Will not reappear unless a new failure occurs.",
378
+ requiresNote: true,
379
+ available: true,
380
+ },
381
+ ];
382
+ }
383
+ return {
384
+ id: input.id,
385
+ kind,
386
+ status: "open",
387
+ title,
388
+ summary,
389
+ initiativeId: input.initiativeId ?? null,
390
+ initiativeTitle: input.initiativeTitle ?? null,
391
+ workstreamId: input.workstreamId ?? null,
392
+ workstreamTitle: input.workstreamTitle ?? null,
393
+ taskId: input.taskId ?? null,
394
+ taskTitle: input.taskTitle ?? null,
395
+ sourceSystem: input.sourceSystem ?? "openclaw",
396
+ conflictSource: input.failureType,
397
+ dedupeKey: [
398
+ input.initiativeId ?? "",
399
+ input.failureType,
400
+ input.provider ?? "",
401
+ input.workstreamId ?? "",
402
+ ]
403
+ .filter(Boolean)
404
+ .join(":"),
405
+ occurrenceCount: 1,
406
+ severity,
407
+ blocking: kind === "blocked_intervention" || kind === "decision_required",
408
+ recommendedAction,
409
+ agentId: input.agentId ?? null,
410
+ impact,
411
+ proofBundle,
412
+ actionContract,
413
+ createdAt: now,
414
+ updatedAt: now,
415
+ firstSeenAt: now,
416
+ lastSeenAt: now,
417
+ snoozedUntil: null,
418
+ sourceDecisionId: null,
419
+ sourceActivityId: null,
420
+ };
421
+ }
422
+ /**
423
+ * Map an existing LiveDecision to a LiveTriageItem for unified display.
424
+ */
425
+ export function mapDecisionToTriageItem(decision) {
426
+ const now = new Date().toISOString();
427
+ const decisionType = decision.decisionType ?? "decision_required";
428
+ const mapping = FAILURE_MAPPINGS[decisionType];
429
+ const actions = [
430
+ {
431
+ action: "approve",
432
+ label: "Approve",
433
+ description: decision.recommendedAction ?? "Approve this decision",
434
+ consequences: "Will proceed with the recommended action.",
435
+ requiresNote: false,
436
+ available: true,
437
+ },
438
+ {
439
+ action: "reject",
440
+ label: "Reject",
441
+ description: "Reject and provide alternative direction",
442
+ consequences: "Agent will pause and await new instructions.",
443
+ requiresNote: true,
444
+ available: true,
445
+ },
446
+ {
447
+ action: "snooze",
448
+ label: "Snooze",
449
+ description: "Defer this decision",
450
+ consequences: "Item reappears after snooze period.",
451
+ requiresNote: false,
452
+ available: true,
453
+ },
454
+ ];
455
+ const proofBundle = {
456
+ artifactRefs: [],
457
+ fileChanges: [],
458
+ prRefs: [],
459
+ logRefs: [],
460
+ decisionRefs: [decision.id],
461
+ };
462
+ if (decision.evidenceRefs) {
463
+ for (const ref of decision.evidenceRefs) {
464
+ if (ref.sourceUrl)
465
+ proofBundle.artifactRefs.push(ref.sourceUrl);
466
+ }
467
+ }
468
+ return {
469
+ id: `triage-decision-${decision.id}`,
470
+ kind: mapping?.kind ?? "decision_required",
471
+ status: decision.status === "pending" ? "open" : decision.status === "resolved" ? "resolved" : "open",
472
+ title: decision.title,
473
+ summary: decision.context ?? decision.title,
474
+ initiativeId: decision.initiativeId ?? null,
475
+ initiativeTitle: null,
476
+ workstreamId: decision.workstreamId ?? null,
477
+ workstreamTitle: null,
478
+ taskId: null,
479
+ taskTitle: null,
480
+ sourceSystem: decision.sourceSystem ?? null,
481
+ conflictSource: decision.conflictSource ?? null,
482
+ dedupeKey: decision.dedupeKey ?? null,
483
+ occurrenceCount: decision.occurrenceCount ?? 1,
484
+ severity: decision.priority === "urgent" ? "critical" : decision.priority === "high" ? "high" : "medium",
485
+ blocking: true,
486
+ recommendedAction: decision.recommendedAction ?? null,
487
+ agentId: decision.agentId ?? null,
488
+ impact: {
489
+ initiativeCount: decision.initiativeId ? 1 : 0,
490
+ workstreamCount: decision.workstreamId ? 1 : 0,
491
+ downstreamBlockedCount: 0,
492
+ },
493
+ proofBundle,
494
+ actionContract: actions,
495
+ createdAt: decision.requestedAt ?? now,
496
+ updatedAt: decision.updatedAt ?? now,
497
+ firstSeenAt: decision.firstSeenAt ?? decision.requestedAt ?? now,
498
+ lastSeenAt: decision.lastSeenAt ?? decision.updatedAt ?? now,
499
+ snoozedUntil: null,
500
+ sourceDecisionId: decision.id,
501
+ sourceActivityId: null,
502
+ };
503
+ }
504
+ /**
505
+ * Deduplicate triage items by dedupeKey, merging occurrence counts.
506
+ */
507
+ export function deduplicateTriageItems(items) {
508
+ const byKey = new Map();
509
+ for (const item of items) {
510
+ const key = item.dedupeKey;
511
+ if (!key) {
512
+ byKey.set(item.id, item);
513
+ continue;
514
+ }
515
+ const existing = byKey.get(key);
516
+ if (!existing) {
517
+ byKey.set(key, { ...item });
518
+ continue;
519
+ }
520
+ // Merge: increment count, update lastSeenAt, combine impacts
521
+ existing.occurrenceCount += item.occurrenceCount;
522
+ if (item.lastSeenAt > existing.lastSeenAt) {
523
+ existing.lastSeenAt = item.lastSeenAt;
524
+ existing.updatedAt = item.updatedAt;
525
+ }
526
+ if (item.firstSeenAt < existing.firstSeenAt) {
527
+ existing.firstSeenAt = item.firstSeenAt;
528
+ }
529
+ existing.impact = {
530
+ initiativeCount: Math.max(existing.impact.initiativeCount, item.impact.initiativeCount),
531
+ workstreamCount: existing.impact.workstreamCount + item.impact.workstreamCount,
532
+ downstreamBlockedCount: existing.impact.downstreamBlockedCount + item.impact.downstreamBlockedCount,
533
+ };
534
+ // Merge proof bundles
535
+ for (const ref of item.proofBundle.logRefs) {
536
+ if (!existing.proofBundle.logRefs.includes(ref)) {
537
+ existing.proofBundle.logRefs.push(ref);
538
+ }
539
+ }
540
+ for (const ref of item.proofBundle.decisionRefs) {
541
+ if (!existing.proofBundle.decisionRefs.includes(ref)) {
542
+ existing.proofBundle.decisionRefs.push(ref);
543
+ }
544
+ }
545
+ }
546
+ return Array.from(byKey.values());
547
+ }
548
+ /** Supported failure types for triage mapping. */
549
+ export const SUPPORTED_FAILURE_TYPES = Object.keys(FAILURE_MAPPINGS);
@@ -0,0 +1,6 @@
1
+ export declare function pickString(record: Record<string, unknown>, keys: string[]): string | null;
2
+ export declare function pickNumber(record: Record<string, unknown>, keys: string[]): number | null;
3
+ export declare function pickHeaderString(headers: Record<string, string | string[] | undefined>, keys: string[]): string | null;
4
+ export declare function toIsoString(value: string | null): string | null;
5
+ export declare function parsePositiveInt(raw: string | null, fallback: number): number;
6
+ export declare function parseBooleanQuery(raw: string | null): boolean;
@@ -0,0 +1,72 @@
1
+ export function pickString(record, keys) {
2
+ for (const key of keys) {
3
+ const value = record[key];
4
+ if (typeof value === "string") {
5
+ const trimmed = value.trim();
6
+ if (trimmed.length > 0)
7
+ return trimmed;
8
+ }
9
+ }
10
+ return null;
11
+ }
12
+ export function pickNumber(record, keys) {
13
+ for (const key of keys) {
14
+ const value = record[key];
15
+ if (typeof value === "number" && Number.isFinite(value)) {
16
+ return value;
17
+ }
18
+ if (typeof value === "string" && value.trim().length > 0) {
19
+ const parsed = Number(value);
20
+ if (Number.isFinite(parsed))
21
+ return parsed;
22
+ }
23
+ }
24
+ return null;
25
+ }
26
+ export function pickHeaderString(headers, keys) {
27
+ for (const key of keys) {
28
+ const candidates = [key, key.toLowerCase(), key.toUpperCase()];
29
+ for (const candidate of candidates) {
30
+ const raw = headers[candidate];
31
+ if (typeof raw === "string" && raw.trim().length > 0) {
32
+ return raw.trim();
33
+ }
34
+ if (Array.isArray(raw)) {
35
+ const first = raw.find((value) => typeof value === "string" && value.trim().length > 0);
36
+ if (first)
37
+ return first.trim();
38
+ }
39
+ }
40
+ }
41
+ return null;
42
+ }
43
+ export function toIsoString(value) {
44
+ if (!value)
45
+ return null;
46
+ const parsed = Date.parse(value);
47
+ if (!Number.isFinite(parsed))
48
+ return null;
49
+ return new Date(parsed).toISOString();
50
+ }
51
+ export function parsePositiveInt(raw, fallback) {
52
+ if (!raw)
53
+ return fallback;
54
+ const normalized = raw.trim();
55
+ if (!normalized)
56
+ return fallback;
57
+ const parsed = Number(normalized);
58
+ if (!Number.isFinite(parsed))
59
+ return fallback;
60
+ // Offset-like parameters may intentionally allow zero when fallback is zero.
61
+ const minimum = fallback <= 0 ? 0 : 1;
62
+ return Math.max(minimum, Math.floor(parsed));
63
+ }
64
+ export function parseBooleanQuery(raw) {
65
+ if (!raw)
66
+ return false;
67
+ const normalized = raw.trim().toLowerCase();
68
+ return (normalized === "1" ||
69
+ normalized === "true" ||
70
+ normalized === "yes" ||
71
+ normalized === "on");
72
+ }
@@ -0,0 +1,15 @@
1
+ type ResolveOptions = {
2
+ allowProjectScope?: boolean;
3
+ };
4
+ type ScopeResolution = {
5
+ workspaceId: string | null;
6
+ error?: string;
7
+ usedLegacyProjectScope?: boolean;
8
+ isAll?: boolean;
9
+ };
10
+ export declare function workspaceScopeFromHeaders(headers: Record<string, unknown> | null | undefined): Record<string, unknown> | null;
11
+ export declare function resolveWorkspaceScope(query: URLSearchParams, payload?: Record<string, unknown> | null, options?: ResolveOptions): ScopeResolution;
12
+ export declare function setCanonicalWorkspaceScopeParams(params: URLSearchParams, workspaceId: string | null | undefined, options?: {
13
+ allTokenWhenMissing?: boolean;
14
+ }): void;
15
+ export {};