agent-nuvira 3.3.1 → 3.3.4

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 (466) hide show
  1. package/README.md +18 -13
  2. package/dist/agent-sdk/src/agent.d.ts +2 -0
  3. package/dist/agent-sdk/src/agent.d.ts.map +1 -1
  4. package/dist/agent-sdk/src/define.d.ts +64 -0
  5. package/dist/agent-sdk/src/define.d.ts.map +1 -0
  6. package/dist/agent-sdk/src/define.js +76 -0
  7. package/dist/agent-sdk/src/define.js.map +1 -0
  8. package/dist/agent-sdk/src/index.d.ts +9 -0
  9. package/dist/agent-sdk/src/index.d.ts.map +1 -1
  10. package/dist/agent-sdk/src/index.js +9 -0
  11. package/dist/agent-sdk/src/index.js.map +1 -1
  12. package/dist/agent-sdk/src/scaffold.d.ts +11 -0
  13. package/dist/agent-sdk/src/scaffold.d.ts.map +1 -1
  14. package/dist/agent-sdk/src/scaffold.js +16 -6
  15. package/dist/agent-sdk/src/scaffold.js.map +1 -1
  16. package/dist/agents/agents/runner.d.ts +9 -0
  17. package/dist/agents/agents/runner.d.ts.map +1 -1
  18. package/dist/agents/agents/runner.js +34 -12
  19. package/dist/agents/agents/runner.js.map +1 -1
  20. package/dist/agents/agents/writer-tool-calling.d.ts.map +1 -1
  21. package/dist/agents/agents/writer-tool-calling.js +7 -2
  22. package/dist/agents/agents/writer-tool-calling.js.map +1 -1
  23. package/dist/agents/agents/writer.d.ts.map +1 -1
  24. package/dist/agents/agents/writer.js +7 -1
  25. package/dist/agents/agents/writer.js.map +1 -1
  26. package/dist/agents/artifact-verification.d.ts +102 -0
  27. package/dist/agents/artifact-verification.d.ts.map +1 -0
  28. package/dist/agents/artifact-verification.js +216 -0
  29. package/dist/agents/artifact-verification.js.map +1 -0
  30. package/dist/agents/checkpoint-store.d.ts +73 -0
  31. package/dist/agents/checkpoint-store.d.ts.map +1 -1
  32. package/dist/agents/checkpoint-store.js +161 -0
  33. package/dist/agents/checkpoint-store.js.map +1 -1
  34. package/dist/agents/credential-store.d.ts +120 -0
  35. package/dist/agents/credential-store.d.ts.map +1 -1
  36. package/dist/agents/credential-store.js +358 -19
  37. package/dist/agents/credential-store.js.map +1 -1
  38. package/dist/agents/long-form-plan.d.ts.map +1 -1
  39. package/dist/agents/long-form-plan.js +2 -1
  40. package/dist/agents/long-form-plan.js.map +1 -1
  41. package/dist/agents/orchestrator.d.ts +10 -1
  42. package/dist/agents/orchestrator.d.ts.map +1 -1
  43. package/dist/agents/orchestrator.js +239 -79
  44. package/dist/agents/orchestrator.js.map +1 -1
  45. package/dist/agents/phase-engine.d.ts +61 -0
  46. package/dist/agents/phase-engine.d.ts.map +1 -1
  47. package/dist/agents/phase-engine.js +68 -2
  48. package/dist/agents/phase-engine.js.map +1 -1
  49. package/dist/agents/prompt-assembly.d.ts +11 -0
  50. package/dist/agents/prompt-assembly.d.ts.map +1 -1
  51. package/dist/agents/prompt-assembly.js +17 -0
  52. package/dist/agents/prompt-assembly.js.map +1 -1
  53. package/dist/agents/release-preflight.d.ts +121 -0
  54. package/dist/agents/release-preflight.d.ts.map +1 -0
  55. package/dist/agents/release-preflight.js +259 -0
  56. package/dist/agents/release-preflight.js.map +1 -0
  57. package/dist/agents/release-runner.d.ts +157 -0
  58. package/dist/agents/release-runner.d.ts.map +1 -0
  59. package/dist/agents/release-runner.js +719 -0
  60. package/dist/agents/release-runner.js.map +1 -0
  61. package/dist/agents/step-handoff.d.ts +190 -0
  62. package/dist/agents/step-handoff.d.ts.map +1 -0
  63. package/dist/agents/step-handoff.js +443 -0
  64. package/dist/agents/step-handoff.js.map +1 -0
  65. package/dist/cli/agent.d.ts +2 -2
  66. package/dist/cli/agent.js +10 -10
  67. package/dist/cli/benchmark.d.ts.map +1 -1
  68. package/dist/cli/benchmark.js +11 -4
  69. package/dist/cli/benchmark.js.map +1 -1
  70. package/dist/cli/chat.d.ts +94 -0
  71. package/dist/cli/chat.d.ts.map +1 -1
  72. package/dist/cli/chat.js +379 -24
  73. package/dist/cli/chat.js.map +1 -1
  74. package/dist/cli/cli-program.d.ts.map +1 -1
  75. package/dist/cli/cli-program.js +8 -0
  76. package/dist/cli/cli-program.js.map +1 -1
  77. package/dist/cli/config.d.ts.map +1 -1
  78. package/dist/cli/config.js +9 -1
  79. package/dist/cli/config.js.map +1 -1
  80. package/dist/cli/credentials.d.ts +28 -0
  81. package/dist/cli/credentials.d.ts.map +1 -0
  82. package/dist/cli/credentials.js +213 -0
  83. package/dist/cli/credentials.js.map +1 -0
  84. package/dist/cli/doctor.d.ts.map +1 -1
  85. package/dist/cli/doctor.js +3 -2
  86. package/dist/cli/doctor.js.map +1 -1
  87. package/dist/cli/edit.js +2 -2
  88. package/dist/cli/eval.d.ts +17 -0
  89. package/dist/cli/eval.d.ts.map +1 -1
  90. package/dist/cli/eval.js +105 -2
  91. package/dist/cli/eval.js.map +1 -1
  92. package/dist/cli/execute.d.ts +16 -1
  93. package/dist/cli/execute.d.ts.map +1 -1
  94. package/dist/cli/execute.js +192 -22
  95. package/dist/cli/execute.js.map +1 -1
  96. package/dist/cli/failover-runner.d.ts.map +1 -1
  97. package/dist/cli/failover-runner.js +9 -3
  98. package/dist/cli/failover-runner.js.map +1 -1
  99. package/dist/cli/loop-executor.d.ts +55 -0
  100. package/dist/cli/loop-executor.d.ts.map +1 -1
  101. package/dist/cli/loop-executor.js +285 -19
  102. package/dist/cli/loop-executor.js.map +1 -1
  103. package/dist/cli/model.d.ts.map +1 -1
  104. package/dist/cli/model.js +9 -8
  105. package/dist/cli/model.js.map +1 -1
  106. package/dist/cli/models.d.ts +1 -1
  107. package/dist/cli/models.js +4 -4
  108. package/dist/cli/nlu.d.ts.map +1 -1
  109. package/dist/cli/nlu.js +8 -2
  110. package/dist/cli/nlu.js.map +1 -1
  111. package/dist/cli/parity.d.ts +85 -0
  112. package/dist/cli/parity.d.ts.map +1 -0
  113. package/dist/cli/parity.js +506 -0
  114. package/dist/cli/parity.js.map +1 -0
  115. package/dist/cli/plan.d.ts.map +1 -1
  116. package/dist/cli/plan.js +2 -1
  117. package/dist/cli/plan.js.map +1 -1
  118. package/dist/cli/publish.d.ts +22 -0
  119. package/dist/cli/publish.d.ts.map +1 -1
  120. package/dist/cli/publish.js +109 -13
  121. package/dist/cli/publish.js.map +1 -1
  122. package/dist/cli/retrieval.d.ts.map +1 -1
  123. package/dist/cli/retrieval.js +5 -4
  124. package/dist/cli/retrieval.js.map +1 -1
  125. package/dist/cli/sdk.js +4 -4
  126. package/dist/cli/sdk.js.map +1 -1
  127. package/dist/cli/trace.d.ts.map +1 -1
  128. package/dist/cli/trace.js +2 -1
  129. package/dist/cli/trace.js.map +1 -1
  130. package/dist/cli/workflow.js +2 -2
  131. package/dist/cli/workflow.js.map +1 -1
  132. package/dist/config/live-credentials.d.ts +57 -0
  133. package/dist/config/live-credentials.d.ts.map +1 -0
  134. package/dist/config/live-credentials.js +126 -0
  135. package/dist/config/live-credentials.js.map +1 -0
  136. package/dist/config/paths.d.ts +18 -0
  137. package/dist/config/paths.d.ts.map +1 -1
  138. package/dist/config/paths.js +25 -0
  139. package/dist/config/paths.js.map +1 -1
  140. package/dist/config/types.d.ts +44 -0
  141. package/dist/config/types.d.ts.map +1 -1
  142. package/dist/federation/a2a-types.js +1 -1
  143. package/dist/federation/a2a-types.js.map +1 -1
  144. package/dist/findings/verdicts.d.ts +241 -0
  145. package/dist/findings/verdicts.d.ts.map +1 -0
  146. package/dist/findings/verdicts.js +284 -0
  147. package/dist/findings/verdicts.js.map +1 -0
  148. package/dist/gateway/adapters.d.ts +65 -0
  149. package/dist/gateway/adapters.d.ts.map +1 -1
  150. package/dist/gateway/adapters.js +216 -10
  151. package/dist/gateway/adapters.js.map +1 -1
  152. package/dist/gateway/channel-directory.d.ts +31 -0
  153. package/dist/gateway/channel-directory.d.ts.map +1 -1
  154. package/dist/gateway/channel-directory.js +40 -0
  155. package/dist/gateway/channel-directory.js.map +1 -1
  156. package/dist/gateway/gateway-log.d.ts +1 -1
  157. package/dist/gateway/gateway-log.d.ts.map +1 -1
  158. package/dist/gateway/gateway-log.js.map +1 -1
  159. package/dist/gateway/hooks.d.ts +87 -19
  160. package/dist/gateway/hooks.d.ts.map +1 -1
  161. package/dist/gateway/hooks.js +62 -23
  162. package/dist/gateway/hooks.js.map +1 -1
  163. package/dist/gateway/inbound-media.d.ts +147 -0
  164. package/dist/gateway/inbound-media.d.ts.map +1 -0
  165. package/dist/gateway/inbound-media.js +317 -0
  166. package/dist/gateway/inbound-media.js.map +1 -0
  167. package/dist/gateway/inbox.d.ts +8 -1
  168. package/dist/gateway/inbox.d.ts.map +1 -1
  169. package/dist/gateway/inbox.js.map +1 -1
  170. package/dist/gateway/platform-config.d.ts +14 -0
  171. package/dist/gateway/platform-config.d.ts.map +1 -1
  172. package/dist/gateway/platform-config.js +26 -8
  173. package/dist/gateway/platform-config.js.map +1 -1
  174. package/dist/gateway/realtime.d.ts +114 -0
  175. package/dist/gateway/realtime.d.ts.map +1 -0
  176. package/dist/gateway/realtime.js +402 -0
  177. package/dist/gateway/realtime.js.map +1 -0
  178. package/dist/gateway/registry.d.ts +31 -0
  179. package/dist/gateway/registry.d.ts.map +1 -1
  180. package/dist/gateway/registry.js +224 -4
  181. package/dist/gateway/registry.js.map +1 -1
  182. package/dist/gateway/whatsapp/baileys-bridge.d.ts +11 -1
  183. package/dist/gateway/whatsapp/baileys-bridge.d.ts.map +1 -1
  184. package/dist/gateway/whatsapp/baileys-bridge.js +123 -4
  185. package/dist/gateway/whatsapp/baileys-bridge.js.map +1 -1
  186. package/dist/gateway/whatsapp/bridge.d.ts +6 -2
  187. package/dist/gateway/whatsapp/bridge.d.ts.map +1 -1
  188. package/dist/gateway/whatsapp/bridge.js.map +1 -1
  189. package/dist/index.js +8 -0
  190. package/dist/index.js.map +1 -1
  191. package/dist/inference/factory.d.ts +14 -0
  192. package/dist/inference/factory.d.ts.map +1 -1
  193. package/dist/inference/factory.js +17 -0
  194. package/dist/inference/factory.js.map +1 -1
  195. package/dist/inference/groq-adapter.d.ts +2 -0
  196. package/dist/inference/groq-adapter.d.ts.map +1 -1
  197. package/dist/inference/groq-adapter.js +16 -6
  198. package/dist/inference/groq-adapter.js.map +1 -1
  199. package/dist/inference/model-validator.d.ts +6 -1
  200. package/dist/inference/model-validator.d.ts.map +1 -1
  201. package/dist/inference/model-validator.js +7 -2
  202. package/dist/inference/model-validator.js.map +1 -1
  203. package/dist/inference/route-resolver.d.ts +116 -0
  204. package/dist/inference/route-resolver.d.ts.map +1 -0
  205. package/dist/inference/route-resolver.js +159 -0
  206. package/dist/inference/route-resolver.js.map +1 -0
  207. package/dist/inference/tools.d.ts.map +1 -1
  208. package/dist/inference/tools.js +29 -0
  209. package/dist/inference/tools.js.map +1 -1
  210. package/dist/learning/autonomy-policy.d.ts +18 -0
  211. package/dist/learning/autonomy-policy.d.ts.map +1 -1
  212. package/dist/learning/autonomy-policy.js +35 -0
  213. package/dist/learning/autonomy-policy.js.map +1 -1
  214. package/dist/learning/benchmark.d.ts.map +1 -1
  215. package/dist/learning/benchmark.js +3 -2
  216. package/dist/learning/benchmark.js.map +1 -1
  217. package/dist/learning/continuation.d.ts.map +1 -1
  218. package/dist/learning/continuation.js +2 -1
  219. package/dist/learning/continuation.js.map +1 -1
  220. package/dist/learning/cost-tracker.d.ts.map +1 -1
  221. package/dist/learning/cost-tracker.js +2 -1
  222. package/dist/learning/cost-tracker.js.map +1 -1
  223. package/dist/learning/deferred-task.d.ts.map +1 -1
  224. package/dist/learning/deferred-task.js +13 -4
  225. package/dist/learning/deferred-task.js.map +1 -1
  226. package/dist/learning/eval-framework.d.ts.map +1 -1
  227. package/dist/learning/eval-framework.js +2 -1
  228. package/dist/learning/eval-framework.js.map +1 -1
  229. package/dist/learning/long-form.d.ts.map +1 -1
  230. package/dist/learning/long-form.js +2 -1
  231. package/dist/learning/long-form.js.map +1 -1
  232. package/dist/learning/model-registry.d.ts.map +1 -1
  233. package/dist/learning/model-registry.js +2 -1
  234. package/dist/learning/model-registry.js.map +1 -1
  235. package/dist/learning/reasoning-cache.d.ts.map +1 -1
  236. package/dist/learning/reasoning-cache.js +2 -1
  237. package/dist/learning/reasoning-cache.js.map +1 -1
  238. package/dist/learning/reasoning-trace.d.ts +38 -2
  239. package/dist/learning/reasoning-trace.d.ts.map +1 -1
  240. package/dist/learning/reasoning-trace.js +91 -1
  241. package/dist/learning/reasoning-trace.js.map +1 -1
  242. package/dist/learning/resilient-call.d.ts.map +1 -1
  243. package/dist/learning/resilient-call.js +31 -18
  244. package/dist/learning/resilient-call.js.map +1 -1
  245. package/dist/learning/retrieval.d.ts.map +1 -1
  246. package/dist/learning/retrieval.js +2 -1
  247. package/dist/learning/retrieval.js.map +1 -1
  248. package/dist/learning/seeded-benchmark.d.ts +160 -0
  249. package/dist/learning/seeded-benchmark.d.ts.map +1 -0
  250. package/dist/learning/seeded-benchmark.js +321 -0
  251. package/dist/learning/seeded-benchmark.js.map +1 -0
  252. package/dist/learning/seeded-bugs.d.ts +142 -0
  253. package/dist/learning/seeded-bugs.d.ts.map +1 -0
  254. package/dist/learning/seeded-bugs.js +535 -0
  255. package/dist/learning/seeded-bugs.js.map +1 -0
  256. package/dist/learning/skill-store.d.ts.map +1 -1
  257. package/dist/learning/skill-store.js +30 -9
  258. package/dist/learning/skill-store.js.map +1 -1
  259. package/dist/learning/step-checkpoint.d.ts +127 -0
  260. package/dist/learning/step-checkpoint.d.ts.map +1 -0
  261. package/dist/learning/step-checkpoint.js +244 -0
  262. package/dist/learning/step-checkpoint.js.map +1 -0
  263. package/dist/mcp/catalog.js +2 -3
  264. package/dist/mcp/catalog.js.map +1 -1
  265. package/dist/mcp/manager.d.ts.map +1 -1
  266. package/dist/mcp/manager.js +5 -3
  267. package/dist/mcp/manager.js.map +1 -1
  268. package/dist/nlu/intent-confirm.d.ts +23 -1
  269. package/dist/nlu/intent-confirm.d.ts.map +1 -1
  270. package/dist/nlu/intent-confirm.js +85 -2
  271. package/dist/nlu/intent-confirm.js.map +1 -1
  272. package/dist/nlu/learnings.d.ts +7 -0
  273. package/dist/nlu/learnings.d.ts.map +1 -1
  274. package/dist/nlu/learnings.js +7 -0
  275. package/dist/nlu/learnings.js.map +1 -1
  276. package/dist/observability/debug-log.d.ts +250 -0
  277. package/dist/observability/debug-log.d.ts.map +1 -0
  278. package/dist/observability/debug-log.js +500 -0
  279. package/dist/observability/debug-log.js.map +1 -0
  280. package/dist/observability/event-bus.d.ts.map +1 -1
  281. package/dist/observability/event-bus.js +4 -1
  282. package/dist/observability/event-bus.js.map +1 -1
  283. package/dist/observability/otel.d.ts +278 -0
  284. package/dist/observability/otel.d.ts.map +1 -0
  285. package/dist/observability/otel.js +590 -0
  286. package/dist/observability/otel.js.map +1 -0
  287. package/dist/parity/drivers.d.ts +99 -0
  288. package/dist/parity/drivers.d.ts.map +1 -0
  289. package/dist/parity/drivers.js +1362 -0
  290. package/dist/parity/drivers.js.map +1 -0
  291. package/dist/parity/graph.d.ts +73 -0
  292. package/dist/parity/graph.d.ts.map +1 -0
  293. package/dist/parity/graph.js +162 -0
  294. package/dist/parity/graph.js.map +1 -0
  295. package/dist/parity/matrix.d.ts +105 -0
  296. package/dist/parity/matrix.d.ts.map +1 -0
  297. package/dist/parity/matrix.js +352 -0
  298. package/dist/parity/matrix.js.map +1 -0
  299. package/dist/parity/observation.d.ts +444 -0
  300. package/dist/parity/observation.d.ts.map +1 -0
  301. package/dist/parity/observation.js +333 -0
  302. package/dist/parity/observation.js.map +1 -0
  303. package/dist/parity/scenarios.d.ts +229 -0
  304. package/dist/parity/scenarios.d.ts.map +1 -0
  305. package/dist/parity/scenarios.js +175 -0
  306. package/dist/parity/scenarios.js.map +1 -0
  307. package/dist/parity/surfaces.d.ts +122 -0
  308. package/dist/parity/surfaces.d.ts.map +1 -0
  309. package/dist/parity/surfaces.js +190 -0
  310. package/dist/parity/surfaces.js.map +1 -0
  311. package/dist/runtime/fault-injection.d.ts +173 -0
  312. package/dist/runtime/fault-injection.d.ts.map +1 -0
  313. package/dist/runtime/fault-injection.js +281 -0
  314. package/dist/runtime/fault-injection.js.map +1 -0
  315. package/dist/skills/secret-capture.d.ts.map +1 -1
  316. package/dist/skills/secret-capture.js +9 -4
  317. package/dist/skills/secret-capture.js.map +1 -1
  318. package/dist/tools/child-agent-entry.d.ts +23 -0
  319. package/dist/tools/child-agent-entry.d.ts.map +1 -0
  320. package/dist/tools/child-agent-entry.js +129 -0
  321. package/dist/tools/child-agent-entry.js.map +1 -0
  322. package/dist/tools/child-agent-runtime.d.ts +124 -0
  323. package/dist/tools/child-agent-runtime.d.ts.map +1 -0
  324. package/dist/tools/child-agent-runtime.js +704 -0
  325. package/dist/tools/child-agent-runtime.js.map +1 -0
  326. package/dist/tools/coding-tools.d.ts.map +1 -1
  327. package/dist/tools/coding-tools.js +82 -10
  328. package/dist/tools/coding-tools.js.map +1 -1
  329. package/dist/tools/credentials-tool.d.ts +24 -0
  330. package/dist/tools/credentials-tool.d.ts.map +1 -0
  331. package/dist/tools/credentials-tool.js +125 -0
  332. package/dist/tools/credentials-tool.js.map +1 -0
  333. package/dist/tools/delegation-system.d.ts +31 -0
  334. package/dist/tools/delegation-system.d.ts.map +1 -1
  335. package/dist/tools/delegation-system.js +70 -9
  336. package/dist/tools/delegation-system.js.map +1 -1
  337. package/dist/tools/extract/docx.d.ts +27 -0
  338. package/dist/tools/extract/docx.d.ts.map +1 -0
  339. package/dist/tools/extract/docx.js +48 -0
  340. package/dist/tools/extract/docx.js.map +1 -0
  341. package/dist/tools/extract/html-text.d.ts +27 -0
  342. package/dist/tools/extract/html-text.d.ts.map +1 -0
  343. package/dist/tools/extract/html-text.js +86 -0
  344. package/dist/tools/extract/html-text.js.map +1 -0
  345. package/dist/tools/extract/pdf-ocr.d.ts +58 -0
  346. package/dist/tools/extract/pdf-ocr.d.ts.map +1 -0
  347. package/dist/tools/extract/pdf-ocr.js +116 -0
  348. package/dist/tools/extract/pdf-ocr.js.map +1 -0
  349. package/dist/tools/extract/pdf.d.ts +65 -0
  350. package/dist/tools/extract/pdf.d.ts.map +1 -0
  351. package/dist/tools/extract/pdf.js +197 -0
  352. package/dist/tools/extract/pdf.js.map +1 -0
  353. package/dist/tools/extract/pptx.d.ts +32 -0
  354. package/dist/tools/extract/pptx.d.ts.map +1 -0
  355. package/dist/tools/extract/pptx.js +77 -0
  356. package/dist/tools/extract/pptx.js.map +1 -0
  357. package/dist/tools/extract/xlsx.d.ts +47 -0
  358. package/dist/tools/extract/xlsx.d.ts.map +1 -0
  359. package/dist/tools/extract/xlsx.js +111 -0
  360. package/dist/tools/extract/xlsx.js.map +1 -0
  361. package/dist/tools/finding-tool.d.ts +76 -0
  362. package/dist/tools/finding-tool.d.ts.map +1 -0
  363. package/dist/tools/finding-tool.js +125 -0
  364. package/dist/tools/finding-tool.js.map +1 -0
  365. package/dist/tools/git-tool.d.ts +25 -7
  366. package/dist/tools/git-tool.d.ts.map +1 -1
  367. package/dist/tools/git-tool.js +155 -15
  368. package/dist/tools/git-tool.js.map +1 -1
  369. package/dist/tools/loop-project-context.d.ts.map +1 -1
  370. package/dist/tools/loop-project-context.js +16 -0
  371. package/dist/tools/loop-project-context.js.map +1 -1
  372. package/dist/tools/loop-route-feed.d.ts +57 -0
  373. package/dist/tools/loop-route-feed.d.ts.map +1 -0
  374. package/dist/tools/loop-route-feed.js +101 -0
  375. package/dist/tools/loop-route-feed.js.map +1 -0
  376. package/dist/tools/messaging-tools.d.ts +41 -11
  377. package/dist/tools/messaging-tools.d.ts.map +1 -1
  378. package/dist/tools/messaging-tools.js +104 -55
  379. package/dist/tools/messaging-tools.js.map +1 -1
  380. package/dist/tools/neutts-synth.d.ts +27 -3
  381. package/dist/tools/neutts-synth.d.ts.map +1 -1
  382. package/dist/tools/neutts-synth.js +57 -13
  383. package/dist/tools/neutts-synth.js.map +1 -1
  384. package/dist/tools/pipeline-tool.d.ts +43 -1
  385. package/dist/tools/pipeline-tool.d.ts.map +1 -1
  386. package/dist/tools/pipeline-tool.js +21 -4
  387. package/dist/tools/pipeline-tool.js.map +1 -1
  388. package/dist/tools/publish-tool.d.ts.map +1 -1
  389. package/dist/tools/publish-tool.js +76 -10
  390. package/dist/tools/publish-tool.js.map +1 -1
  391. package/dist/tools/read-extract.d.ts +116 -45
  392. package/dist/tools/read-extract.d.ts.map +1 -1
  393. package/dist/tools/read-extract.js +494 -158
  394. package/dist/tools/read-extract.js.map +1 -1
  395. package/dist/tools/registry.d.ts +23 -3
  396. package/dist/tools/registry.d.ts.map +1 -1
  397. package/dist/tools/registry.js +196 -29
  398. package/dist/tools/registry.js.map +1 -1
  399. package/dist/tools/run-terminal.d.ts +9 -0
  400. package/dist/tools/run-terminal.d.ts.map +1 -1
  401. package/dist/tools/run-terminal.js +80 -2
  402. package/dist/tools/run-terminal.js.map +1 -1
  403. package/dist/tools/subagent-refusal.d.ts +15 -0
  404. package/dist/tools/subagent-refusal.d.ts.map +1 -0
  405. package/dist/tools/subagent-refusal.js +18 -0
  406. package/dist/tools/subagent-refusal.js.map +1 -0
  407. package/dist/tools/subagent-spawner.d.ts +122 -0
  408. package/dist/tools/subagent-spawner.d.ts.map +1 -1
  409. package/dist/tools/subagent-spawner.js +249 -28
  410. package/dist/tools/subagent-spawner.js.map +1 -1
  411. package/dist/tools/tool-hooks.d.ts +177 -0
  412. package/dist/tools/tool-hooks.d.ts.map +1 -0
  413. package/dist/tools/tool-hooks.js +427 -0
  414. package/dist/tools/tool-hooks.js.map +1 -0
  415. package/dist/tools/tool-loop.d.ts +94 -5
  416. package/dist/tools/tool-loop.d.ts.map +1 -1
  417. package/dist/tools/tool-loop.js +315 -9
  418. package/dist/tools/tool-loop.js.map +1 -1
  419. package/dist/tools/tool-refusal.d.ts +68 -0
  420. package/dist/tools/tool-refusal.d.ts.map +1 -0
  421. package/dist/tools/tool-refusal.js +78 -0
  422. package/dist/tools/tool-refusal.js.map +1 -0
  423. package/dist/tools/toolsets.d.ts +8 -0
  424. package/dist/tools/toolsets.d.ts.map +1 -1
  425. package/dist/tools/toolsets.js +14 -4
  426. package/dist/tools/toolsets.js.map +1 -1
  427. package/dist/tools/vision-tools.d.ts +88 -83
  428. package/dist/tools/vision-tools.d.ts.map +1 -1
  429. package/dist/tools/vision-tools.js +134 -103
  430. package/dist/tools/vision-tools.js.map +1 -1
  431. package/dist/tools/worktree.d.ts +210 -0
  432. package/dist/tools/worktree.d.ts.map +1 -0
  433. package/dist/tools/worktree.js +374 -0
  434. package/dist/tools/worktree.js.map +1 -0
  435. package/dist/utils/format.d.ts +3 -0
  436. package/dist/utils/format.d.ts.map +1 -0
  437. package/dist/utils/format.js +32 -0
  438. package/dist/utils/format.js.map +1 -0
  439. package/dist/web-dashboard/attachment-extract.d.ts +64 -0
  440. package/dist/web-dashboard/attachment-extract.d.ts.map +1 -0
  441. package/dist/web-dashboard/attachment-extract.js +154 -0
  442. package/dist/web-dashboard/attachment-extract.js.map +1 -0
  443. package/dist/web-dashboard/chat-console.d.ts +108 -1
  444. package/dist/web-dashboard/chat-console.d.ts.map +1 -1
  445. package/dist/web-dashboard/chat-console.js +36 -0
  446. package/dist/web-dashboard/chat-console.js.map +1 -1
  447. package/dist/web-dashboard/hub-data.d.ts +37 -0
  448. package/dist/web-dashboard/hub-data.d.ts.map +1 -1
  449. package/dist/web-dashboard/hub-data.js +61 -1
  450. package/dist/web-dashboard/hub-data.js.map +1 -1
  451. package/dist/web-dashboard/server.d.ts +14 -0
  452. package/dist/web-dashboard/server.d.ts.map +1 -1
  453. package/dist/web-dashboard/server.js +247 -13
  454. package/dist/web-dashboard/server.js.map +1 -1
  455. package/dist/web-dashboard/src/types.d.ts +196 -48
  456. package/dist/web-dashboard/src/types.d.ts.map +1 -1
  457. package/dist/workflow/registry.js +1 -1
  458. package/dist/workflow/registry.js.map +1 -1
  459. package/package.json +22 -6
  460. package/src/web-dashboard/public/assets/{index-Cyd6tIew.css → index-XJjj2cBX.css} +1 -1
  461. package/src/web-dashboard/public/assets/index-YWF9FpwQ.js +207 -0
  462. package/src/web-dashboard/public/assets/index-YWF9FpwQ.js.map +1 -0
  463. package/src/web-dashboard/public/index.html +2 -2
  464. package/dist/tools/child-agent-worker.js +0 -212
  465. package/src/web-dashboard/public/assets/index-CjvoBhlz.js +0 -207
  466. package/src/web-dashboard/public/assets/index-CjvoBhlz.js.map +0 -1
@@ -0,0 +1,241 @@
1
+ /**
2
+ * WS1 (#23) — a finding, its verdict, and the gate that keeps the two honest.
3
+ *
4
+ * WHY THIS EXISTS. This repository has already paid for the bug this closes: a
5
+ * claim that was true-looking and unverified reached a user as fact. The tool
6
+ * descriptions reported success for work that had not happened
7
+ * (`docs/TOOL_TRUTHFULNESS_TRACKER.md`), the dashboard shipped a bundle that did
8
+ * not contain a tab that had been written and reviewed, and a WhatsApp task
9
+ * reported completion while the deliverable was never authored
10
+ * (`docs/rca_false_success_and_no_resume.md`). Every one of those is the same
11
+ * defect in a different costume: something was ASSERTED, nothing was CHECKED,
12
+ * and the assertion travelled as if it had been.
13
+ *
14
+ * The codebase already knows the right shape for this and uses it in one place.
15
+ * `src/nlu/learnings.ts` documents that "a learning is written ONLY when a
16
+ * misreading has been CONFIRMED by the model", and `src/nlu/intent-confirm.ts`
17
+ * is the probe that produces that confirmation. But the confirmation it produced
18
+ * was the model saying so — an assertion about an assertion, with no evidence
19
+ * attached. That is the gap: a verdict two-valued enough to be checked, and an
20
+ * evidence requirement strong enough that "CONFIRMED" cannot be typed in.
21
+ *
22
+ * THE MODEL. A finding is a CLAIM plus a VERDICT plus an OUTCOME plus EVIDENCE:
23
+ *
24
+ * claim — what is being asserted, in the words the reader will see.
25
+ * verdict — CONFIRMED (something was produced that a second party could
26
+ * check) or PLAUSIBLE (a reasoned guess). Binary on purpose: a
27
+ * 0.7 confidence invites arithmetic on a number nobody calibrated,
28
+ * and the interesting question is only ever "can this be checked".
29
+ * outcome — what became of it (kept, corrected, dropped, not persisted). A
30
+ * finding with no outcome is a status report, not a finding.
31
+ * evidence — the concrete things that were checked: a verbatim line, a command
32
+ * and its real output, a path. Never a restatement of the claim.
33
+ *
34
+ * THE GATE, and why it is enforced in code rather than by convention. A rule
35
+ * that lives in a comment is a rule the next contributor is free to be
36
+ * enthusiastic about. `confirmFinding` refuses a promotion with no usable
37
+ * evidence and returns the finding STILL PLAUSIBLE with the reason attached —
38
+ * a refusal, not a throw, because "we could not verify this" is a normal outcome
39
+ * of a probe and must not take down the turn that asked. `enforceVerdicts` then
40
+ * applies the same rule to a whole batch on the way OUT, so no code path —
41
+ * including one written later by someone who never read this file — can emit a
42
+ * CONFIRMED finding that carries nothing.
43
+ *
44
+ * TWO DELIBERATE LIMITS.
45
+ * 1. This module does not decide what a finding MEANS or who may produce one.
46
+ * It is the vocabulary and the gate, so every surface can report the same
47
+ * shape and a reader can compare them (that is the parity requirement WS0
48
+ * exists to measure).
49
+ * 2. It never invents evidence, and never treats its absence as failure of the
50
+ * finding: a PLAUSIBLE finding is a legitimate, useful, honest object. The
51
+ * only thing this module refuses is the promotion.
52
+ */
53
+ /**
54
+ * What a finding is worth, in the only two amounts that matter.
55
+ *
56
+ * - `CONFIRMED` — something was produced that a second party could check.
57
+ * - `PLAUSIBLE` — reasoned, not verified. The default, and never a failure.
58
+ */
59
+ export type Verdict = 'CONFIRMED' | 'PLAUSIBLE';
60
+ /**
61
+ * The kinds of check that can produce evidence.
62
+ *
63
+ * `quote` is a verbatim span of the input (the part of a request a reading
64
+ * depends on); `command` is a command line and its REAL output; `file` is a path
65
+ * that was read; `observation` is a value a probe actually returned. Kept as a
66
+ * closed set so a reader can tell how strong a piece of evidence is without
67
+ * parsing prose — and so `describeFinding` can render it uniformly.
68
+ */
69
+ export type EvidenceKind = 'quote' | 'command' | 'file' | 'observation';
70
+ /**
71
+ * One check that was actually performed.
72
+ *
73
+ * `ref` is the evidence itself — the line, the command, the path — never a
74
+ * summary of it. A blank `ref` is not evidence: it is the type satisfied and the
75
+ * work skipped, which is precisely the defect this module exists to refuse.
76
+ */
77
+ export interface Evidence {
78
+ kind: EvidenceKind;
79
+ ref: string;
80
+ /** Optional context: the output, the surrounding line, the reason. */
81
+ detail?: string;
82
+ }
83
+ /** A claim, its verdict, what became of it, and what was checked. */
84
+ export interface Finding {
85
+ /** What is asserted, in the words the reader will see. */
86
+ claim: string;
87
+ verdict: Verdict;
88
+ /** What became of the finding. Required: a finding with no outcome is a status report. */
89
+ outcome: string;
90
+ /** The checks behind a CONFIRMED verdict. Empty is legal — for a PLAUSIBLE one. */
91
+ evidence: readonly Evidence[];
92
+ /** Where the finding came from, so a reader can weigh it (`intent-confirm`, `review`, …). */
93
+ source: string;
94
+ /** When it was recorded. Volatile: never part of a comparison between surfaces. */
95
+ at?: number;
96
+ }
97
+ /** The result of asking for a promotion, including the refusal. */
98
+ export interface Promotion {
99
+ /** The finding AFTER the attempt — PLAUSIBLE and unchanged when refused. */
100
+ finding: Finding;
101
+ promoted: boolean;
102
+ /** Why it was refused. Present exactly when `promoted` is false. */
103
+ reason?: string;
104
+ }
105
+ /** What `plausibleFinding` needs. Everything else has a defensible default. */
106
+ export interface FindingInput {
107
+ claim: string;
108
+ outcome: string;
109
+ source: string;
110
+ evidence?: readonly Evidence[];
111
+ at?: number;
112
+ }
113
+ /**
114
+ * True when this finding carries anything that was actually checked.
115
+ *
116
+ * Exported because the question "is this checkable" is asked in more places than
117
+ * the gate: a report renderer may want to group a batch by it, and a caller
118
+ * deciding whether to spend a model call on verification wants it before, not
119
+ * after.
120
+ */
121
+ export declare function hasEvidence(finding: Finding): boolean;
122
+ /**
123
+ * The usable evidence on a finding, in order.
124
+ *
125
+ * A finding is normalised on the way in, so this is not a filter a caller must
126
+ * remember to apply — it exists so a renderer can show the evidence and never
127
+ * the blanks.
128
+ */
129
+ export declare function evidenceOf(finding: Finding): Evidence[];
130
+ /**
131
+ * Record a claim that has NOT been checked.
132
+ *
133
+ * Deliberately the constructor: a finding cannot be BORN confirmed. Evidence can
134
+ * only arrive through `confirmFinding`, so the gate cannot be bypassed by a
135
+ * caller that helpfully knew the answer all along — the only way to a CONFIRMED
136
+ * verdict is the function that requires the evidence.
137
+ *
138
+ * Evidence passed here is KEPT (a caller that did check something should not lose
139
+ * it) but does not by itself promote the verdict; promotion is a separate,
140
+ * explicit act. That keeps "what we know" and "what we decided" from collapsing
141
+ * into one step that no one can audit.
142
+ */
143
+ export declare function plausibleFinding(input: FindingInput): Finding;
144
+ /**
145
+ * Promote a PLAUSIBLE finding to CONFIRMED — or refuse, and say why.
146
+ *
147
+ * The refusal is the point of the module. It returns the finding UNCHANGED and
148
+ * PLAUSIBLE rather than throwing, because "we could not check this" is the
149
+ * ordinary outcome of a probe against a world that may be offline, and a probe
150
+ * must never be able to take down the turn that asked it. Callers that need to
151
+ * branch on the answer read `promoted`.
152
+ *
153
+ * A CONFIRMED finding cannot be promoted again (nothing to do), and a CONFIRMED
154
+ * finding whose evidence is IMPOSSIBLE cannot exist: `enforceVerdicts` demotes
155
+ * it. Both cases are reported rather than silently accepted.
156
+ */
157
+ export declare function confirmFinding(finding: Finding, evidence?: readonly Evidence[], options?: {
158
+ outcome?: string;
159
+ at?: number;
160
+ }): Promotion;
161
+ /** Force a finding back to PLAUSIBLE, keeping why. The inverse of a promotion. */
162
+ export declare function demoteFinding(finding: Finding, why: string): Finding;
163
+ /**
164
+ * The gate applied to a batch, on the way out.
165
+ *
166
+ * This is what makes the rule unfalsifiable-by-accident: ANY batch of findings
167
+ * about to be reported, logged or persisted can be passed through here, and a
168
+ * CONFIRMED verdict that carries nothing is demoted with the reason recorded in
169
+ * its own outcome. `confirmFinding` protects the direct path; this protects the
170
+ * paths nobody has written yet, including a finding assembled by hand in a
171
+ * module that never imported `confirmFinding`.
172
+ *
173
+ * Returns the repaired findings AND the claims that were demoted, because a
174
+ * silent repair would hide the wiring bug that produced the claim — the demotion
175
+ * is correct behaviour, and its CAUSE is still something a caller should see.
176
+ */
177
+ export declare function enforceVerdicts(findings: readonly Finding[], why?: string): {
178
+ findings: Finding[];
179
+ demoted: string[];
180
+ };
181
+ /**
182
+ * Claims carrying a CONFIRMED verdict and no usable evidence.
183
+ *
184
+ * The assertion form of `enforceVerdicts`, for a caller that would rather fail
185
+ * than repair — a test, or a check that is about the producing code rather than
186
+ * the report.
187
+ */
188
+ export declare function unsupportedConfirmations(findings: readonly Finding[]): string[];
189
+ /**
190
+ * The wire form: plain JSON a surface can log, return over IPC or write to a
191
+ * report.
192
+ *
193
+ * Present so the five surfaces report a finding IDENTICALLY (the WS0 requirement)
194
+ * rather than each inventing a shape — a gateway log line and a child's IPC frame
195
+ * that disagree about a verdict are a parity failure nobody would notice until a
196
+ * user compared two outputs. `at` is deliberately excluded: it differs on every
197
+ * invocation, so comparing it would fail for surfaces that behave identically,
198
+ * the same reason `observation.ts` keeps timing out of the compared projection.
199
+ */
200
+ export interface WireFinding {
201
+ claim: string;
202
+ verdict: Verdict;
203
+ outcome: string;
204
+ evidence: Array<{
205
+ kind: EvidenceKind;
206
+ ref: string;
207
+ detail?: string;
208
+ }>;
209
+ source: string;
210
+ }
211
+ /** One finding, reduced to the comparable wire form. */
212
+ export declare function toWire(finding: Finding): WireFinding;
213
+ /**
214
+ * Read a finding back off the wire, defensively.
215
+ *
216
+ * Returns `undefined` for anything malformed rather than guessing, and — the
217
+ * part that matters — a payload claiming CONFIRMED with no usable evidence comes
218
+ * back PLAUSIBLE. A reader on the other side of an IPC boundary or a log file
219
+ * cannot trust the producer, so the gate is re-applied on the way in rather than
220
+ * assumed to have been applied on the way out.
221
+ */
222
+ export declare function fromWire(value: unknown): Finding | undefined;
223
+ /**
224
+ * One line a person reads, used everywhere so two surfaces cannot render the
225
+ * same finding two ways.
226
+ *
227
+ * The evidence is shown for a CONFIRMED verdict and the reason for a PLAUSIBLE
228
+ * one, because those are the two things a reader needs to decide whether to
229
+ * trust the line — and printing a confidence number neither of them can act on
230
+ * is how a report starts lying politely.
231
+ */
232
+ export declare function describeFinding(finding: Finding): string;
233
+ /**
234
+ * A batch, summarised: how many are confirmed, and how many are still guesses.
235
+ *
236
+ * Exists so a caller cannot report a total without also having to look at the
237
+ * split. "12 findings" reads as twelve facts; "12 findings (3 confirmed, 9
238
+ * plausible)" cannot.
239
+ */
240
+ export declare function summarizeVerdicts(findings: readonly Finding[]): string;
241
+ //# sourceMappingURL=verdicts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdicts.d.ts","sourceRoot":"","sources":["../../src/findings/verdicts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,aAAa,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qEAAqE;AACrE,MAAM,WAAW,OAAO;IACtB,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,QAAQ,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC9B,6FAA6F;IAC7F,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,mEAAmE;AACnE,MAAM,WAAW,SAAS;IACxB,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MA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AAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wDAAwD;AACxD,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAYpD;AAID;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAiC5D;AAUD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAOxD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAItE"}
@@ -0,0 +1,284 @@
1
+ /**
2
+ * WS1 (#23) — a finding, its verdict, and the gate that keeps the two honest.
3
+ *
4
+ * WHY THIS EXISTS. This repository has already paid for the bug this closes: a
5
+ * claim that was true-looking and unverified reached a user as fact. The tool
6
+ * descriptions reported success for work that had not happened
7
+ * (`docs/TOOL_TRUTHFULNESS_TRACKER.md`), the dashboard shipped a bundle that did
8
+ * not contain a tab that had been written and reviewed, and a WhatsApp task
9
+ * reported completion while the deliverable was never authored
10
+ * (`docs/rca_false_success_and_no_resume.md`). Every one of those is the same
11
+ * defect in a different costume: something was ASSERTED, nothing was CHECKED,
12
+ * and the assertion travelled as if it had been.
13
+ *
14
+ * The codebase already knows the right shape for this and uses it in one place.
15
+ * `src/nlu/learnings.ts` documents that "a learning is written ONLY when a
16
+ * misreading has been CONFIRMED by the model", and `src/nlu/intent-confirm.ts`
17
+ * is the probe that produces that confirmation. But the confirmation it produced
18
+ * was the model saying so — an assertion about an assertion, with no evidence
19
+ * attached. That is the gap: a verdict two-valued enough to be checked, and an
20
+ * evidence requirement strong enough that "CONFIRMED" cannot be typed in.
21
+ *
22
+ * THE MODEL. A finding is a CLAIM plus a VERDICT plus an OUTCOME plus EVIDENCE:
23
+ *
24
+ * claim — what is being asserted, in the words the reader will see.
25
+ * verdict — CONFIRMED (something was produced that a second party could
26
+ * check) or PLAUSIBLE (a reasoned guess). Binary on purpose: a
27
+ * 0.7 confidence invites arithmetic on a number nobody calibrated,
28
+ * and the interesting question is only ever "can this be checked".
29
+ * outcome — what became of it (kept, corrected, dropped, not persisted). A
30
+ * finding with no outcome is a status report, not a finding.
31
+ * evidence — the concrete things that were checked: a verbatim line, a command
32
+ * and its real output, a path. Never a restatement of the claim.
33
+ *
34
+ * THE GATE, and why it is enforced in code rather than by convention. A rule
35
+ * that lives in a comment is a rule the next contributor is free to be
36
+ * enthusiastic about. `confirmFinding` refuses a promotion with no usable
37
+ * evidence and returns the finding STILL PLAUSIBLE with the reason attached —
38
+ * a refusal, not a throw, because "we could not verify this" is a normal outcome
39
+ * of a probe and must not take down the turn that asked. `enforceVerdicts` then
40
+ * applies the same rule to a whole batch on the way OUT, so no code path —
41
+ * including one written later by someone who never read this file — can emit a
42
+ * CONFIRMED finding that carries nothing.
43
+ *
44
+ * TWO DELIBERATE LIMITS.
45
+ * 1. This module does not decide what a finding MEANS or who may produce one.
46
+ * It is the vocabulary and the gate, so every surface can report the same
47
+ * shape and a reader can compare them (that is the parity requirement WS0
48
+ * exists to measure).
49
+ * 2. It never invents evidence, and never treats its absence as failure of the
50
+ * finding: a PLAUSIBLE finding is a legitimate, useful, honest object. The
51
+ * only thing this module refuses is the promotion.
52
+ */
53
+ /**
54
+ * A usable piece of evidence: a non-blank `ref`.
55
+ *
56
+ * Whitespace-only is rejected rather than trimmed to "": a caller that passed
57
+ * `' '` passed nothing, and accepting it would make the gate trivially avoidable.
58
+ */
59
+ function isUsable(evidence) {
60
+ return Boolean(evidence) && typeof evidence.ref === 'string' && evidence.ref.trim().length > 0;
61
+ }
62
+ /**
63
+ * True when this finding carries anything that was actually checked.
64
+ *
65
+ * Exported because the question "is this checkable" is asked in more places than
66
+ * the gate: a report renderer may want to group a batch by it, and a caller
67
+ * deciding whether to spend a model call on verification wants it before, not
68
+ * after.
69
+ */
70
+ export function hasEvidence(finding) {
71
+ return finding.evidence.some(isUsable);
72
+ }
73
+ /**
74
+ * The usable evidence on a finding, in order.
75
+ *
76
+ * A finding is normalised on the way in, so this is not a filter a caller must
77
+ * remember to apply — it exists so a renderer can show the evidence and never
78
+ * the blanks.
79
+ */
80
+ export function evidenceOf(finding) {
81
+ return finding.evidence.filter(isUsable);
82
+ }
83
+ /**
84
+ * Record a claim that has NOT been checked.
85
+ *
86
+ * Deliberately the constructor: a finding cannot be BORN confirmed. Evidence can
87
+ * only arrive through `confirmFinding`, so the gate cannot be bypassed by a
88
+ * caller that helpfully knew the answer all along — the only way to a CONFIRMED
89
+ * verdict is the function that requires the evidence.
90
+ *
91
+ * Evidence passed here is KEPT (a caller that did check something should not lose
92
+ * it) but does not by itself promote the verdict; promotion is a separate,
93
+ * explicit act. That keeps "what we know" and "what we decided" from collapsing
94
+ * into one step that no one can audit.
95
+ */
96
+ export function plausibleFinding(input) {
97
+ return {
98
+ claim: input.claim,
99
+ verdict: 'PLAUSIBLE',
100
+ outcome: input.outcome,
101
+ evidence: [...(input.evidence ?? [])],
102
+ source: input.source,
103
+ ...(input.at !== undefined ? { at: input.at } : {}),
104
+ };
105
+ }
106
+ /**
107
+ * Promote a PLAUSIBLE finding to CONFIRMED — or refuse, and say why.
108
+ *
109
+ * The refusal is the point of the module. It returns the finding UNCHANGED and
110
+ * PLAUSIBLE rather than throwing, because "we could not check this" is the
111
+ * ordinary outcome of a probe against a world that may be offline, and a probe
112
+ * must never be able to take down the turn that asked it. Callers that need to
113
+ * branch on the answer read `promoted`.
114
+ *
115
+ * A CONFIRMED finding cannot be promoted again (nothing to do), and a CONFIRMED
116
+ * finding whose evidence is IMPOSSIBLE cannot exist: `enforceVerdicts` demotes
117
+ * it. Both cases are reported rather than silently accepted.
118
+ */
119
+ export function confirmFinding(finding, evidence = [], options = {}) {
120
+ const combined = [...finding.evidence, ...evidence];
121
+ const outcome = options.outcome ?? finding.outcome;
122
+ if (finding.verdict === 'CONFIRMED' && hasEvidence(finding)) {
123
+ return {
124
+ finding: { ...finding, outcome, ...(options.at !== undefined ? { at: options.at } : {}) },
125
+ promoted: false,
126
+ reason: 'already CONFIRMED — a verdict is recorded once, and the evidence that earned it is on the finding',
127
+ };
128
+ }
129
+ if (!combined.some(isUsable)) {
130
+ return {
131
+ finding: { ...finding, outcome, evidence: combined, ...(options.at !== undefined ? { at: options.at } : {}) },
132
+ promoted: false,
133
+ reason: 'no usable evidence — a CONFIRMED verdict means something was CHECKED, so it needs a command ' +
134
+ 'and its output, a path that was read, a quote from the input, or a value a probe returned. ' +
135
+ 'A restatement of the claim is not evidence, and a blank reference is not a check.',
136
+ };
137
+ }
138
+ return {
139
+ finding: {
140
+ ...finding,
141
+ verdict: 'CONFIRMED',
142
+ outcome,
143
+ evidence: combined,
144
+ ...(options.at !== undefined ? { at: options.at } : {}),
145
+ },
146
+ promoted: true,
147
+ };
148
+ }
149
+ /** Force a finding back to PLAUSIBLE, keeping why. The inverse of a promotion. */
150
+ export function demoteFinding(finding, why) {
151
+ if (finding.verdict === 'PLAUSIBLE')
152
+ return finding;
153
+ const note = finding.outcome.includes(why) ? finding.outcome : `${finding.outcome} — ${why}`;
154
+ return { ...finding, verdict: 'PLAUSIBLE', outcome: note };
155
+ }
156
+ /**
157
+ * The gate applied to a batch, on the way out.
158
+ *
159
+ * This is what makes the rule unfalsifiable-by-accident: ANY batch of findings
160
+ * about to be reported, logged or persisted can be passed through here, and a
161
+ * CONFIRMED verdict that carries nothing is demoted with the reason recorded in
162
+ * its own outcome. `confirmFinding` protects the direct path; this protects the
163
+ * paths nobody has written yet, including a finding assembled by hand in a
164
+ * module that never imported `confirmFinding`.
165
+ *
166
+ * Returns the repaired findings AND the claims that were demoted, because a
167
+ * silent repair would hide the wiring bug that produced the claim — the demotion
168
+ * is correct behaviour, and its CAUSE is still something a caller should see.
169
+ */
170
+ export function enforceVerdicts(findings, why = 'not promoted: no usable evidence') {
171
+ const demoted = [];
172
+ const repaired = findings.map((finding) => {
173
+ if (finding.verdict !== 'CONFIRMED' || hasEvidence(finding))
174
+ return finding;
175
+ demoted.push(finding.claim);
176
+ return demoteFinding(finding, why);
177
+ });
178
+ return { findings: repaired, demoted };
179
+ }
180
+ /**
181
+ * Claims carrying a CONFIRMED verdict and no usable evidence.
182
+ *
183
+ * The assertion form of `enforceVerdicts`, for a caller that would rather fail
184
+ * than repair — a test, or a check that is about the producing code rather than
185
+ * the report.
186
+ */
187
+ export function unsupportedConfirmations(findings) {
188
+ return findings
189
+ .filter((finding) => finding.verdict === 'CONFIRMED' && !hasEvidence(finding))
190
+ .map((finding) => finding.claim);
191
+ }
192
+ /** One finding, reduced to the comparable wire form. */
193
+ export function toWire(finding) {
194
+ return {
195
+ claim: finding.claim,
196
+ verdict: finding.verdict,
197
+ outcome: finding.outcome,
198
+ evidence: evidenceOf(finding).map((e) => ({
199
+ kind: e.kind,
200
+ ref: e.ref,
201
+ ...(e.detail ? { detail: e.detail } : {}),
202
+ })),
203
+ source: finding.source,
204
+ };
205
+ }
206
+ const EVIDENCE_KINDS = ['quote', 'command', 'file', 'observation'];
207
+ /**
208
+ * Read a finding back off the wire, defensively.
209
+ *
210
+ * Returns `undefined` for anything malformed rather than guessing, and — the
211
+ * part that matters — a payload claiming CONFIRMED with no usable evidence comes
212
+ * back PLAUSIBLE. A reader on the other side of an IPC boundary or a log file
213
+ * cannot trust the producer, so the gate is re-applied on the way in rather than
214
+ * assumed to have been applied on the way out.
215
+ */
216
+ export function fromWire(value) {
217
+ if (!value || typeof value !== 'object')
218
+ return undefined;
219
+ const raw = value;
220
+ if (typeof raw.claim !== 'string' || !raw.claim.trim())
221
+ return undefined;
222
+ if (typeof raw.outcome !== 'string')
223
+ return undefined;
224
+ if (typeof raw.source !== 'string')
225
+ return undefined;
226
+ if (raw.verdict !== 'CONFIRMED' && raw.verdict !== 'PLAUSIBLE')
227
+ return undefined;
228
+ const evidence = Array.isArray(raw.evidence)
229
+ ? raw.evidence
230
+ .filter((e) => Boolean(e) &&
231
+ typeof e === 'object' &&
232
+ EVIDENCE_KINDS.includes(e.kind) &&
233
+ typeof e.ref === 'string')
234
+ .map((e) => ({
235
+ kind: e.kind,
236
+ ref: e.ref,
237
+ ...(typeof e.detail === 'string' && e.detail ? { detail: e.detail } : {}),
238
+ }))
239
+ : [];
240
+ const finding = {
241
+ claim: raw.claim,
242
+ verdict: raw.verdict,
243
+ outcome: raw.outcome,
244
+ evidence,
245
+ source: raw.source,
246
+ };
247
+ // Re-applied, not trusted: see the docstring.
248
+ return enforceVerdicts([finding]).findings[0];
249
+ }
250
+ /** How one piece of evidence reads. */
251
+ function describeEvidence(evidence) {
252
+ const label = evidence.kind === 'command' ? 'ran' : evidence.kind === 'file' ? 'read' : evidence.kind;
253
+ return `${label} ${evidence.kind === 'quote' ? `"${evidence.ref}"` : evidence.ref}${evidence.detail ? ` (${evidence.detail})` : ''}`;
254
+ }
255
+ /**
256
+ * One line a person reads, used everywhere so two surfaces cannot render the
257
+ * same finding two ways.
258
+ *
259
+ * The evidence is shown for a CONFIRMED verdict and the reason for a PLAUSIBLE
260
+ * one, because those are the two things a reader needs to decide whether to
261
+ * trust the line — and printing a confidence number neither of them can act on
262
+ * is how a report starts lying politely.
263
+ */
264
+ export function describeFinding(finding) {
265
+ const head = `${finding.verdict === 'CONFIRMED' ? '✅' : '🔎'} ${finding.claim} — ${finding.outcome}`;
266
+ const evidence = evidenceOf(finding);
267
+ if (finding.verdict === 'CONFIRMED' && evidence.length > 0) {
268
+ return `${head}\n evidence: ${evidence.map(describeEvidence).join('; ')}`;
269
+ }
270
+ return `${head}\n no evidence — reported as PLAUSIBLE, not verified.`;
271
+ }
272
+ /**
273
+ * A batch, summarised: how many are confirmed, and how many are still guesses.
274
+ *
275
+ * Exists so a caller cannot report a total without also having to look at the
276
+ * split. "12 findings" reads as twelve facts; "12 findings (3 confirmed, 9
277
+ * plausible)" cannot.
278
+ */
279
+ export function summarizeVerdicts(findings) {
280
+ const confirmed = findings.filter((f) => f.verdict === 'CONFIRMED' && hasEvidence(f)).length;
281
+ const plausible = findings.length - confirmed;
282
+ return `${findings.length} finding(s): ${confirmed} confirmed, ${plausible} plausible`;
283
+ }
284
+ //# sourceMappingURL=verdicts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdicts.js","sourceRoot":"","sources":["../../src/findings/verdicts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAoEH;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,QAA8B;IAC9C,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,QAAS,CAAC,GAAG,KAAK,QAAQ,IAAI,QAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AACnG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAmB;IAClD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,WAAW;QACpB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;QACrC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpD,CAAC;AACJ,CA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
  import type { Platform } from './channel-directory.js';
16
16
  import type { WhatsAppBridge } from './whatsapp/bridge.js';
17
+ import { type InboundMedia } from './inbound-media.js';
17
18
  export interface InboundMessage {
18
19
  platform: Platform;
19
20
  /** Channel id (chat id / webhook channel id) to REPLY to. */
@@ -38,6 +39,13 @@ export interface InboundMessage {
38
39
  * every delivery is treated as new (content dedup is opt-in — see dedup.ts).
39
40
  */
40
41
  messageId?: string;
42
+ /**
43
+ * A document/image attachment that rode in on this message, already
44
+ * downloaded by the transport. `handleInbound` hydrates it through the same
45
+ * `read_extract` the agent uses, so a document is TEXT by the time routing
46
+ * happens instead of a message with empty text that gets dropped.
47
+ */
48
+ media?: InboundMedia;
41
49
  }
42
50
  /** The handler an adapter calls for every inbound message. */
43
51
  export type MessageHandler = (msg: InboundMessage) => void | Promise<void>;
@@ -100,6 +108,17 @@ export declare class TelegramAdapter implements ChannelAdapter {
100
108
  describe(): string;
101
109
  private api;
102
110
  start(onMessage: MessageHandler): Promise<void>;
111
+ /**
112
+ * Download an inbound attachment's bytes via `getFile` + the file endpoint.
113
+ * Never throws — returns null on any failure (or when the file is larger than
114
+ * the extraction cap), so the turn still runs with its caption text.
115
+ */
116
+ private downloadFile;
117
+ /**
118
+ * Build the inbound media payload from a Telegram message, or null when it
119
+ * carries none. Photos arrive as several sizes — the largest is used.
120
+ */
121
+ private inboundMedia;
103
122
  stop(): Promise<void>;
104
123
  send(channelId: string, text: string): Promise<boolean>;
105
124
  /**
@@ -138,7 +157,16 @@ export declare class DiscordAdapter extends WebhookChannelAdapter {
138
157
  readonly tokenEnvVar = "BUFF_DISCORD_BOT_TOKEN";
139
158
  readonly configured: boolean;
140
159
  constructor();
160
+ /** The real-time Gateway connection, when a bot token is configured. */
161
+ private gateway;
141
162
  describe(): string;
163
+ /**
164
+ * Inbound Discord messages arrive over the Gateway WebSocket (a bot cannot
165
+ * own the Discord webhook), so a bot token starts the real-time source. The
166
+ * shared webhook receiver still serves outbound-only webhook setups.
167
+ */
168
+ start(onMessage: MessageHandler): Promise<void>;
169
+ stop(): Promise<void>;
142
170
  protected sendUrl(channelId: string): string;
143
171
  protected payloadFor(_channelId: string, text: string): unknown;
144
172
  /**
@@ -156,7 +184,16 @@ export declare class SlackAdapter extends WebhookChannelAdapter {
156
184
  readonly tokenEnvVar = "BUFF_SLACK_BOT_TOKEN";
157
185
  readonly configured: boolean;
158
186
  constructor();
187
+ /** The Socket Mode connection, when an app-level token is configured. */
188
+ private socketMode;
159
189
  describe(): string;
190
+ /**
191
+ * Slack Events API inbound needs a public HTTPS endpoint; apps that cannot
192
+ * expose one use Socket Mode, which carries the same `event_callback`
193
+ * envelopes. Enabled by an app-level token (`SLACK_APP_TOKEN`, `xapp-…`).
194
+ */
195
+ start(onMessage: MessageHandler): Promise<void>;
196
+ stop(): Promise<void>;
160
197
  protected sendUrl(channelId: string): string;
161
198
  protected payloadFor(channelId: string, text: string): unknown;
162
199
  }
@@ -636,6 +673,15 @@ export declare class HomeAssistantAdapter implements ChannelAdapter {
636
673
  stop(): Promise<void>;
637
674
  send(channelId: string, text: string): Promise<boolean>;
638
675
  }
676
+ /** An inbound webhook attachment that must be downloaded before extraction. */
677
+ export interface WebhookAttachment {
678
+ url: string;
679
+ filename?: string;
680
+ mimetype?: string;
681
+ size?: number;
682
+ /** True when fetching the URL needs the platform bot token (Slack files). */
683
+ authenticated?: boolean;
684
+ }
639
685
  /** Payload parsers: extract {channelId, text, from} from each platform's webhook body. */
640
686
  export interface WebhookPayload {
641
687
  channelId: string;
@@ -647,7 +693,20 @@ export interface WebhookPayload {
647
693
  isGroup?: boolean;
648
694
  /** The platform's message id, when the webhook body carries one (dedup). */
649
695
  messageId?: string;
696
+ /** An attachment that rode in on the message (Discord CDN / Slack file). */
697
+ media?: {
698
+ type: InboundMedia['type'];
699
+ attachment: WebhookAttachment;
700
+ caption?: string;
701
+ };
650
702
  }
703
+ /**
704
+ * Classify an attachment by MIME type, falling back to its filename extension.
705
+ * Exported for the real-time transports (`realtime.ts`), which receive Discord
706
+ * `content_type` / Slack `mimetype` on a live gateway event rather than a
707
+ * webhook body.
708
+ */
709
+ export declare function mediaKindFromMime(mimetype?: string, filename?: string): InboundMedia['type'];
651
710
  /**
652
711
  * Parse platform-specific webhook bodies into a normal InboundMessage.
653
712
  * Returns null when the payload isn't a user message (e.g. Slack challenge).
@@ -665,6 +724,12 @@ export declare class WebhookReceiver {
665
724
  * When the platform secret is set, unsigned POSTs are rejected (401).
666
725
  */
667
726
  start(onMessage: MessageHandler, port?: number, host?: string): Promise<void>;
727
+ /**
728
+ * Download a webhook attachment's bytes. Never throws — returns null on any
729
+ * failure, so the text turn still runs. Slack's `url_private*` endpoints need
730
+ * the bot token; Discord's CDN URL is public.
731
+ */
732
+ private downloadWebhookMedia;
668
733
  /**
669
734
  * Verify a webhook POST's platform signature. Returns true when the
670
735
  * platform has NO secret configured (local/trusted setup) or the signature