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,590 @@
1
+ /**
2
+ * WS3 (#25) — the turn's span tree, exported over OTLP when an operator asks.
3
+ *
4
+ * WHY THIS EXISTS. WS2 gave a run a log you can attach to a bug report; that is
5
+ * one run on one machine. What it cannot do is show a turn's SHAPE across many
6
+ * runs — which step is slow, which tool is the one that fails, whether the
7
+ * subagent a turn spawned is where the time went. That is a tracing problem, and
8
+ * the answer everyone's tooling already speaks is OTLP.
9
+ *
10
+ * WHY THE OFFICIAL SDK, here of all places. This repository hand-rolls its
11
+ * observability on purpose (the debug log, the gateway log, `generateZip`) — and
12
+ * a native OTLP writer was the obvious first instinct. It was rejected for a
13
+ * specific reason: the parts hardest to get right are the ones nobody notices
14
+ * until a collector shows nothing. 64-bit nanosecond timestamps as strings, the
15
+ * sampled bit in `traceFlags`, an empty-versus-omitted `parentSpanId`, header
16
+ * parsing, retries, gzip — each is a silent failure mode, and none of them is
17
+ * this project's problem to own. `@opentelemetry/*` already ships them correct,
18
+ * and anything that speaks OTLP accepts what it produces.
19
+ *
20
+ * THREE RULES, each closing a way tracing makes a product worse:
21
+ *
22
+ * 1. OFF UNLESS ASKED. `NUVIRA_OTEL=1` turns it on. With it off the SDK is
23
+ * never even imported (`ensureProvider` is the only place that loads it), so
24
+ * an ordinary run pays no startup cost and no span object is ever built. The
25
+ * API package is a static import because that is exactly its design: with no
26
+ * provider registered, every call through it is a no-op.
27
+ *
28
+ * 2. IT CAN NEVER BREAK THE RUN. Provider setup, attribute rendering and the
29
+ * final flush are each best-effort, and the flush is BOUNDED — an
30
+ * unreachable collector costs a turn at most one export timeout, once, and
31
+ * never an exception. A tracer that can fail the turn it observes is worse
32
+ * than no tracer. The bound is not a private constant: the standard
33
+ * `OTEL_BSP_*` variables (`MAX_QUEUE_SIZE`, `SCHEDULE_DELAY`,
34
+ * `MAX_EXPORT_BATCH_SIZE`, `EXPORT_TIMEOUT`) set both the batch processor and
35
+ * the flush, with this module's defaults filling in the rest — see
36
+ * {@link otelBatchSettings}.
37
+ *
38
+ * 3. IT CARRIES WHAT THE OTHER SINKS CARRY. Attribute values are previewed and
39
+ * scrubbed with the SAME `scrubSecrets` the gateway log and the debug log
40
+ * use, because a span is shipped to a third party by definition. Two regex
41
+ * lists drift, and the one that drifts is the one that leaks.
42
+ *
43
+ * THE TREE, and what is deliberately not in it. A turn span (`nuvira.turn`) with
44
+ * one child per tool call that actually ran (`nuvira.tool.<name>`), plus the
45
+ * findings the turn recorded as span EVENTS — a finding has no duration, so it
46
+ * is a point-in-time fact rather than a span. There is no model-call span, and
47
+ * that is a measurement rather than an omission: the loop's event taxonomy
48
+ * (`tool`, `gate`, `refusal`, `decision`) has no model kind, so a model span
49
+ * could only be produced on some surfaces, and a tree that differs per surface
50
+ * is a tracing feature that lies. The missing span is the honest version; it is
51
+ * recorded here so the next person does not "fix" it by inventing one in
52
+ * `chat.ts` alone.
53
+ *
54
+ * PROPAGATION ACROSS THE FORK. A subagent is a separate process with its own
55
+ * provider, so its spans would be a second, unrelated trace by default. The
56
+ * spawner injects the ambient W3C `traceparent` into the child's environment
57
+ * (`childTraceEnv`) and the child resumes from it (`parentContextFromEnv`), so
58
+ * the child's turn span hangs off the tool call that spawned it and the whole
59
+ * thing is ONE trace. The parent comes from the ACTIVE context, never from
60
+ * module state: the loop makes the tool span active around the tool's execution,
61
+ * so two turns interleaving in one server process cannot hand each other's trace
62
+ * ids to a child. The turn's own parent is passed in explicitly for the same
63
+ * reason — reading it from `process.env` inside `startTurnSpan` would make every
64
+ * in-process surface inherit whatever a parent process happened to leave there.
65
+ */
66
+ import { readFileSync } from 'node:fs';
67
+ import { context, defaultTextMapGetter, defaultTextMapSetter, SpanKind, SpanStatusCode, trace, } from '@opentelemetry/api';
68
+ // The W3C trace-context propagator, taken EXPLICITLY rather than through the
69
+ // global one, and that choice is load-bearing. MEASURED: a forked child resolves
70
+ // its parent BEFORE it registers a provider, and with nothing registered the API's
71
+ // global propagator is the NOOP one — which returns the input context unchanged
72
+ // and silently makes every child start a trace of its own. Using the same explicit
73
+ // propagator on both sides of the fork makes the header a matched pair.
74
+ import { W3CTraceContextPropagator } from '@opentelemetry/core';
75
+ import { scrubSecrets } from '../gateway/gateway-log.js';
76
+ /** The one propagator used to inject and extract the child's `traceparent`. */
77
+ const w3cTraceContext = new W3CTraceContextPropagator();
78
+ /** The env var suffix that turns span export on (`NUVIRA_OTEL=1`). */
79
+ export const OTEL_ENABLE_ENV = 'OTEL';
80
+ /**
81
+ * The env var a forked child is handed its parent's trace in.
82
+ *
83
+ * The VALUE is the W3C `traceparent` header, and the name is deliberately the
84
+ * conventional uppercase form of it — an environment variable, not a header.
85
+ */
86
+ export const TRACEPARENT_ENV = 'TRACEPARENT';
87
+ /**
88
+ * The W3C header name ITSELF, which is LOWERCASE, and that is not cosmetics.
89
+ *
90
+ * MEASURED: the propagator reads and writes the carrier by this exact key, so a
91
+ * carrier keyed `TRACEPARENT` is a carrier it cannot see — inject silently yields
92
+ * nothing and extract silently yields the input context, which is how every child
93
+ * ends up starting a trace of its own while everything still "works".
94
+ */
95
+ const TRACEPARENT_HEADER = 'traceparent';
96
+ /** The root span of a turn. One name on every surface, so a tree compares. */
97
+ export const TURN_SPAN_NAME = 'nuvira.turn';
98
+ /** Child span prefix for a tool call: `nuvira.tool.read_file`. */
99
+ export const TOOL_SPAN_PREFIX = 'nuvira.tool.';
100
+ /** The instrumentation scope name (what a collector shows as the source). */
101
+ export const INSTRUMENTATION_NAME = 'agent-nuvira';
102
+ /** Default `service.name`, overridable with `OTEL_SERVICE_NAME`. */
103
+ export const DEFAULT_SERVICE_NAME = 'agent-nuvira';
104
+ /** Attribute values are previews, not payloads — the longest line we ship. */
105
+ export const OTEL_ATTR_PREVIEW_CHARS = 300;
106
+ /**
107
+ * How long one export, and the flush that awaits it, may take.
108
+ *
109
+ * The DEFAULT for `OTEL_BSP_EXPORT_TIMEOUT` (which also bounds `flushSpans`), and
110
+ * the reason it is 3s rather than the SDK's 30s: a turn WAITS for its own spans to
111
+ * ship, and an unreachable collector must not hold an answer for half a minute.
112
+ * Raise the standard variable if a slow path to your collector needs longer.
113
+ */
114
+ export const OTEL_FLUSH_TIMEOUT_MS = 3_000;
115
+ /**
116
+ * Span queue bound, so a long-lived server cannot grow without limit.
117
+ *
118
+ * The DEFAULT for `OTEL_BSP_MAX_QUEUE_SIZE` (whose own spec default this is).
119
+ */
120
+ export const OTEL_MAX_QUEUE = 2_048;
121
+ /**
122
+ * How long the batch waits before shipping, in a process that keeps running.
123
+ *
124
+ * The DEFAULT for `OTEL_BSP_SCHEDULE_DELAY`. Faster than the SDK's 5s because a
125
+ * CLI turn is usually the whole process: the explicit flush at the end of a turn
126
+ * is what actually ships it, and this only bounds how long a long-running server
127
+ * holds a span it could have sent.
128
+ */
129
+ export const OTEL_SCHEDULE_DELAY_MS = 1_000;
130
+ /** The DEFAULT for `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` (the SDK's own default). */
131
+ export const OTEL_MAX_EXPORT_BATCH_SIZE = 512;
132
+ /**
133
+ * The standard batch-processor variables this module honours, by field.
134
+ *
135
+ * WHY WE RESOLVE THEM OURSELVES. The SDK's `BatchSpanProcessor` does implement
136
+ * these fallbacks — but only for a config key left `undefined`, and this module
137
+ * passes its own defaults for all of them, so a user setting
138
+ * `OTEL_BSP_EXPORT_TIMEOUT=30000` would have been silently IGNORED. Reading the
139
+ * variables here keeps one precedence rule instead of two: an explicit value from
140
+ * the environment wins, the module's default fills the gap, and the SDK's own
141
+ * fallback then has nothing left to do.
142
+ */
143
+ export const OTEL_BSP_VAR = {
144
+ maxQueueSize: 'OTEL_BSP_MAX_QUEUE_SIZE',
145
+ scheduledDelayMillis: 'OTEL_BSP_SCHEDULE_DELAY',
146
+ maxExportBatchSize: 'OTEL_BSP_MAX_EXPORT_BATCH_SIZE',
147
+ exportTimeoutMillis: 'OTEL_BSP_EXPORT_TIMEOUT',
148
+ };
149
+ /**
150
+ * One positive integer from the environment, or the fallback.
151
+ *
152
+ * A value that is set but unreadable (`abc`, `0`, `-5`, `1.5`) falls back rather
153
+ * than reaching the SDK: a queue of zero and a negative delay are both worse than
154
+ * the default, and neither is what the user meant to ask for.
155
+ */
156
+ function positiveInt(raw, fallback) {
157
+ if (raw === undefined)
158
+ return fallback;
159
+ const n = Number(raw.trim());
160
+ return Number.isInteger(n) && n > 0 ? n : fallback;
161
+ }
162
+ /**
163
+ * The batch settings for this process: the standard `OTEL_BSP_*` variables where
164
+ * they are set, this module's defaults everywhere else.
165
+ *
166
+ * Exported so the resolution is testable on its own — the wiring is one call
167
+ * site, and a test that only exercised the resolver through a live collector
168
+ * could not tell a misparsed variable from a value the SDK ignored.
169
+ */
170
+ export function otelBatchSettings(env = process.env) {
171
+ return {
172
+ maxQueueSize: positiveInt(env[OTEL_BSP_VAR.maxQueueSize], OTEL_MAX_QUEUE),
173
+ scheduledDelayMillis: positiveInt(env[OTEL_BSP_VAR.scheduledDelayMillis], OTEL_SCHEDULE_DELAY_MS),
174
+ maxExportBatchSize: positiveInt(env[OTEL_BSP_VAR.maxExportBatchSize], OTEL_MAX_EXPORT_BATCH_SIZE),
175
+ exportTimeoutMillis: positiveInt(env[OTEL_BSP_VAR.exportTimeoutMillis], OTEL_FLUSH_TIMEOUT_MS),
176
+ };
177
+ }
178
+ /** The variable a user sets to turn this on, spelled out for a message. */
179
+ export const otelEnableVarName = `NUVIRA_${OTEL_ENABLE_ENV}`;
180
+ /**
181
+ * Is span export on?
182
+ *
183
+ * `NUVIRA_OTEL` (or legacy `BUFF_OTEL`) set to anything other than the falsey
184
+ * words `0`, `false`, `off` or `no` enables it — the same rule the debug log
185
+ * uses, so `NUVIRA_OTEL=false` in an `.env` means off rather than "a non-empty
186
+ * string".
187
+ */
188
+ export function otelExportEnabled(env = process.env) {
189
+ const raw = env[otelEnableVarName] ?? env[`BUFF_${OTEL_ENABLE_ENV}`];
190
+ if (raw === undefined)
191
+ return false;
192
+ const value = raw.trim().toLowerCase();
193
+ return value !== '' && value !== '0' && value !== 'false' && value !== 'off' && value !== 'no';
194
+ }
195
+ /**
196
+ * Where spans will be shipped — for a notice, and so a user who enabled export
197
+ * without an endpoint is told their spans are being built and dropped.
198
+ *
199
+ * Per the OTLP spec the TRACES variable is used verbatim and the generic one
200
+ * gets the signal path appended. The SDK does that resolution for us; this only
201
+ * has to say it out loud.
202
+ */
203
+ export function otelEndpoint(env = process.env) {
204
+ const traces = env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT?.trim();
205
+ if (traces)
206
+ return traces;
207
+ const base = env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();
208
+ if (!base)
209
+ return null;
210
+ return `${base.replace(/\/+$/, '')}/v1/traces`;
211
+ }
212
+ /** Cut a string to `max` chars, marking the cut so a reader knows it happened. */
213
+ function cap(value, max) {
214
+ return value.length <= max ? value : `${value.slice(0, Math.max(0, max - 1))}…`;
215
+ }
216
+ /**
217
+ * One attribute value, safe to ship: flattened, cut, then redacted.
218
+ *
219
+ * OTLP accepts a scalar or an array of scalars, so anything else becomes a
220
+ * bounded JSON preview rather than being dropped — an attribute that silently
221
+ * vanishes is a debugging hole that only shows up when someone needs it. A
222
+ * circular structure returns a marker instead of throwing, because an
223
+ * instrument must never be the reason a turn fails.
224
+ */
225
+ function attrValue(value) {
226
+ if (value === undefined || value === null)
227
+ return undefined;
228
+ if (typeof value === 'number')
229
+ return Number.isFinite(value) ? value : String(value);
230
+ if (typeof value === 'boolean')
231
+ return value;
232
+ if (Array.isArray(value)) {
233
+ const items = value
234
+ .filter((v) => typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean')
235
+ .slice(0, 20)
236
+ .map((v) => scrubSecrets(cap(String(v), OTEL_ATTR_PREVIEW_CHARS)));
237
+ return items.length > 0 ? items : undefined;
238
+ }
239
+ if (typeof value === 'string') {
240
+ return scrubSecrets(cap(value.replace(/\s+/g, ' ').trim(), OTEL_ATTR_PREVIEW_CHARS));
241
+ }
242
+ try {
243
+ const json = JSON.stringify(value, (_key, v) => typeof v === 'string' && v.length > 120 ? `${v.slice(0, 119)}…` : v);
244
+ return json === undefined ? undefined : scrubSecrets(cap(json, OTEL_ATTR_PREVIEW_CHARS));
245
+ }
246
+ catch {
247
+ return '[unrenderable]';
248
+ }
249
+ }
250
+ /** Turn a record of attributes into what OTLP wants, dropping absent values. */
251
+ function attrRecord(attrs) {
252
+ const out = {};
253
+ for (const [key, value] of Object.entries(attrs)) {
254
+ const rendered = attrValue(value);
255
+ if (rendered !== undefined)
256
+ out[key] = rendered;
257
+ }
258
+ return out;
259
+ }
260
+ /** The real span wrapper. Private: callers program against {@link SpanHandle}. */
261
+ class OtelSpanHandle {
262
+ ended = false;
263
+ record;
264
+ /**
265
+ * The context this span hangs under — its own span set as the active one, so
266
+ * a child nests correctly without depending on what is ambient at the time.
267
+ */
268
+ ownContext;
269
+ constructor(record, baseContext) {
270
+ this.record = record;
271
+ this.ownContext = trace.setSpan(baseContext, record);
272
+ }
273
+ get traceId() {
274
+ return this.record.spanContext().traceId;
275
+ }
276
+ get spanId() {
277
+ return this.record.spanContext().spanId;
278
+ }
279
+ /** The underlying span, for {@link withSpanActive}. Not part of the contract. */
280
+ get spanRecord() {
281
+ return this.record;
282
+ }
283
+ attr(key, value) {
284
+ const rendered = attrValue(value);
285
+ if (rendered === undefined)
286
+ return;
287
+ try {
288
+ this.record.setAttribute(key, rendered);
289
+ }
290
+ catch {
291
+ /* best-effort: an attribute must never break the turn it describes */
292
+ }
293
+ }
294
+ event(name, attrs = {}) {
295
+ try {
296
+ this.record.addEvent(name, attrRecord(attrs));
297
+ }
298
+ catch {
299
+ /* best-effort */
300
+ }
301
+ }
302
+ child(name, attrs = {}) {
303
+ const record = trace.getTracer(INSTRUMENTATION_NAME).startSpan(name, { kind: SpanKind.INTERNAL, attributes: attrRecord(attrs) }, this.ownContext);
304
+ return new OtelSpanHandle(record, this.ownContext);
305
+ }
306
+ end(outcome = {}) {
307
+ if (this.ended)
308
+ return;
309
+ this.ended = true;
310
+ try {
311
+ if (outcome.ok === false) {
312
+ this.record.setStatus({
313
+ code: SpanStatusCode.ERROR,
314
+ ...(outcome.message ? { message: cap(outcome.message, OTEL_ATTR_PREVIEW_CHARS) } : {}),
315
+ });
316
+ }
317
+ else {
318
+ this.record.setStatus({ code: SpanStatusCode.OK });
319
+ }
320
+ this.record.end();
321
+ }
322
+ catch {
323
+ /* best-effort */
324
+ }
325
+ }
326
+ }
327
+ let runtime = null;
328
+ let starting = null;
329
+ /**
330
+ * Build and register the provider the first time a span is asked for.
331
+ *
332
+ * The SDK is imported HERE rather than at module load, so a run that never
333
+ * enables export never pays for it — which is why `NUVIRA_OTEL` is a gate and
334
+ * not merely a flag that produces no spans.
335
+ */
336
+ async function ensureProvider() {
337
+ if (!otelExportEnabled())
338
+ return null;
339
+ if (runtime)
340
+ return runtime;
341
+ if (!starting) {
342
+ starting = (async () => {
343
+ try {
344
+ const [{ NodeTracerProvider, BatchSpanProcessor }, { OTLPTraceExporter }, { resourceFromAttributes }] = await Promise.all([
345
+ import('@opentelemetry/sdk-trace-node'),
346
+ import('@opentelemetry/exporter-trace-otlp-http'),
347
+ import('@opentelemetry/resources'),
348
+ ]);
349
+ const provider = new NodeTracerProvider({
350
+ resource: resourceFromAttributes({
351
+ 'service.name': process.env.OTEL_SERVICE_NAME?.trim() || DEFAULT_SERVICE_NAME,
352
+ 'service.version': agentVersion() ?? 'unknown',
353
+ // A forked child is its own process, and that is the isolation
354
+ // boundary this project already documents — so a collector can tell
355
+ // the parent's spans from the child's by instance id.
356
+ 'service.instance.id': String(process.pid),
357
+ }),
358
+ spanProcessors: [
359
+ new BatchSpanProcessor(
360
+ // No explicit url, headers or compression: the exporter reads the
361
+ // standard `OTEL_EXPORTER_OTLP_*` variables itself, which is the
362
+ // whole reason for depending on the SDK instead of re-implementing
363
+ // its environment contract.
364
+ new OTLPTraceExporter(),
365
+ // The standard `OTEL_BSP_*` variables, resolved here rather than
366
+ // left to the SDK (whose fallbacks only fire for an ABSENT key).
367
+ otelBatchSettings()),
368
+ ],
369
+ });
370
+ provider.register();
371
+ runtime = { provider };
372
+ return runtime;
373
+ }
374
+ catch {
375
+ // A tracer that cannot start is a tracer that does not exist. The turn
376
+ // runs untraced, which is the honest degradation.
377
+ return null;
378
+ }
379
+ })();
380
+ }
381
+ return starting;
382
+ }
383
+ /**
384
+ * Start a turn's root span, or `null` when export is off.
385
+ *
386
+ * Async because the SDK loads on first use; every caller is already async.
387
+ */
388
+ export async function startTurnSpan(options) {
389
+ const otel = await ensureProvider();
390
+ if (!otel)
391
+ return null;
392
+ try {
393
+ const base = options.parent ?? context.active();
394
+ const record = trace.getTracer(INSTRUMENTATION_NAME).startSpan(TURN_SPAN_NAME, {
395
+ // INTERNAL on every surface on purpose: this span is the agent TURN, and
396
+ // a turn is an internal operation wherever it runs. The inbound HTTP
397
+ // request or messaging event that triggered it is a different span owned
398
+ // by whoever accepted it, and giving each surface its own kind would
399
+ // make the tree differ per surface for no reader's benefit.
400
+ kind: SpanKind.INTERNAL,
401
+ attributes: {
402
+ 'nuvira.surface': options.surface,
403
+ ...attrRecord({ 'nuvira.session': options.session, 'nuvira.goal': options.goal }),
404
+ },
405
+ }, base);
406
+ return new OtelSpanHandle(record, base);
407
+ }
408
+ catch {
409
+ return null;
410
+ }
411
+ }
412
+ /**
413
+ * The trace context a child process should continue, or `{}` when there is none.
414
+ *
415
+ * Read from the ACTIVE context, so the loop must have made the tool span active
416
+ * around the tool's execution. An empty object is the honest answer when nothing
417
+ * is active: a child handed a fabricated parent id would corrupt the trace it
418
+ * was supposed to join.
419
+ */
420
+ export function childTraceEnv(env = process.env) {
421
+ if (!otelExportEnabled(env))
422
+ return {};
423
+ const active = trace.getSpan(context.active());
424
+ if (!active)
425
+ return {};
426
+ if (!trace.isSpanContextValid(active.spanContext()))
427
+ return {};
428
+ const carrier = {};
429
+ try {
430
+ w3cTraceContext.inject(trace.setSpan(context.active(), active), carrier, defaultTextMapSetter);
431
+ }
432
+ catch {
433
+ return {};
434
+ }
435
+ const injected = carrier[TRACEPARENT_HEADER];
436
+ return injected ? { [TRACEPARENT_ENV]: injected } : {};
437
+ }
438
+ /**
439
+ * The context a child process resumes from, or `null` when it was not told.
440
+ *
441
+ * A malformed or absent `traceparent` yields null rather than a guess, so a
442
+ * child started by hand simply begins a trace of its own.
443
+ */
444
+ export function parentContextFromEnv(env = process.env) {
445
+ const traceparent = env[TRACEPARENT_ENV]?.trim();
446
+ if (!traceparent)
447
+ return null;
448
+ try {
449
+ const extracted = w3cTraceContext.extract(context.active(), { [TRACEPARENT_HEADER]: traceparent }, defaultTextMapGetter);
450
+ return trace.getSpanContext(extracted) ? extracted : null;
451
+ }
452
+ catch {
453
+ return null;
454
+ }
455
+ }
456
+ /**
457
+ * Run `fn` with `handle`'s span ACTIVE, so anything below it inherits the right
458
+ * parent — a tool that forks a subagent, or a library that is instrumented.
459
+ *
460
+ * Returns `fn`'s value unchanged, and a null handle simply runs `fn` with no
461
+ * added context: the disabled path costs one boolean.
462
+ */
463
+ export function withSpanActive(handle, fn) {
464
+ if (!handle)
465
+ return fn();
466
+ const record = handle instanceof OtelSpanHandle ? handle.spanRecord : null;
467
+ if (!record)
468
+ return fn();
469
+ try {
470
+ return context.with(trace.setSpan(context.active(), record), fn);
471
+ }
472
+ catch {
473
+ return fn();
474
+ }
475
+ }
476
+ /**
477
+ * Ship what is buffered — bounded, and never throwing.
478
+ *
479
+ * Called at the end of a turn rather than relying on the scheduler, so a
480
+ * one-shot process (and a test) can observe the spans it just produced.
481
+ */
482
+ export async function flushSpans() {
483
+ const otel = runtime;
484
+ if (!otel)
485
+ return;
486
+ try {
487
+ await Promise.race([
488
+ otel.provider.forceFlush(),
489
+ new Promise((resolve) => {
490
+ // A collector that accepted a request but never answered must not hold a
491
+ // turn open. Unref'd, so the timer itself cannot keep a CLI alive. The
492
+ // bound FOLLOWS the export timeout the user configured (`OTEL_BSP_
493
+ // EXPORT_TIMEOUT`) rather than being a second, independent number: a
494
+ // slower path to their collector must not be cut off by a limit they
495
+ // never set, and the flush can only ever wait as long as one export may.
496
+ const timer = setTimeout(resolve, otelBatchSettings().exportTimeoutMillis);
497
+ timer.unref?.();
498
+ }),
499
+ ]);
500
+ }
501
+ catch {
502
+ // Dropped spans are the correct outcome for an unreachable collector.
503
+ }
504
+ }
505
+ /**
506
+ * Tear the provider down — only for a process that is about to exit.
507
+ *
508
+ * Deliberately NOT called at the end of every turn: in the dashboard and the
509
+ * gateway the provider has to outlive the turn it just traced. The one-shot
510
+ * surfaces (a `nuvira execute`, a forked subagent) call it so a lingering
511
+ * exporter socket cannot keep the process alive after the answer is printed.
512
+ *
513
+ * IT ALSO RELEASES THE API'S GLOBAL REGISTRATION, and that part is load-bearing
514
+ * rather than tidiness — MEASURED, the hard way. `provider.register()` puts this
515
+ * provider behind the API's process-wide proxy, and a provider that has been
516
+ * shut down still HAS that slot: the next `register()` cannot take it over, so
517
+ * `trace.getTracer()` keeps handing out tracers from the dead provider and every
518
+ * span built afterwards is silently dropped (the spans exist, carry real trace
519
+ * ids, and are never exported — the worst failure shape, because nothing errors
520
+ * and a collector shows an empty trace). Disabling the global provider and the
521
+ * global context manager is what lets tracing start again in the same process,
522
+ * which is exactly what a test harness that points several surfaces at several
523
+ * collectors does.
524
+ */
525
+ export async function shutdownSpans() {
526
+ const otel = runtime;
527
+ if (!otel)
528
+ return;
529
+ runtime = null;
530
+ starting = null;
531
+ try {
532
+ await otel.provider.shutdown();
533
+ }
534
+ catch {
535
+ /* best-effort */
536
+ }
537
+ try {
538
+ trace.disable();
539
+ context.disable();
540
+ }
541
+ catch {
542
+ /* best-effort: an already-disabled global is not an error */
543
+ }
544
+ }
545
+ /**
546
+ * A one-line notice a surface can print, so a user knows spans are leaving.
547
+ *
548
+ * The no-endpoint case is the one worth printing: export is on, the tree is
549
+ * being built, and every span is being dropped — which looks exactly like a
550
+ * broken collector from the other side.
551
+ */
552
+ export function otelNotice(surface, env = process.env) {
553
+ if (!otelExportEnabled(env))
554
+ return null;
555
+ const endpoint = otelEndpoint(env);
556
+ return endpoint
557
+ ? `🔭 ${surface}: OTLP spans → ${endpoint} (unset ${otelEnableVarName} to stop)`
558
+ : `🔭 ${surface}: span export is ON but no OTEL_EXPORTER_OTLP_ENDPOINT is set — spans are built and dropped. Set the endpoint to ship them.`;
559
+ }
560
+ /** Surfaces whose notice has already been printed in this process. */
561
+ const noticesPrinted = new Set();
562
+ /**
563
+ * {@link otelNotice}, but only the first time for a surface.
564
+ *
565
+ * A long-running server prints this once per process rather than once per turn:
566
+ * the destination does not change between turns, and a line per turn is noise
567
+ * nobody can act on. The CLI, with one turn, sees it exactly once either way.
568
+ */
569
+ export function otelNoticeOnce(surface, env = process.env) {
570
+ const notice = otelNotice(surface, env);
571
+ if (!notice || noticesPrinted.has(surface))
572
+ return null;
573
+ noticesPrinted.add(surface);
574
+ return notice;
575
+ }
576
+ /** Running version, read the same best-effort way the debug log reads it. */
577
+ let cachedVersion;
578
+ function agentVersion() {
579
+ if (cachedVersion !== undefined)
580
+ return cachedVersion;
581
+ try {
582
+ const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf-8'));
583
+ cachedVersion = typeof pkg.version === 'string' && pkg.version.trim() ? pkg.version.trim() : null;
584
+ }
585
+ catch {
586
+ cachedVersion = null;
587
+ }
588
+ return cachedVersion;
589
+ }
590
+ //# sourceMappingURL=otel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.js","sourceRoot":"","sources":["../../src/observability/otel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAA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