agent-nuvira 3.3.3 → 3.3.5
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.
- package/README.md +13 -5
- package/dist/agent-sdk/src/agent.d.ts +2 -0
- package/dist/agent-sdk/src/agent.d.ts.map +1 -1
- package/dist/agent-sdk/src/define.d.ts +64 -0
- package/dist/agent-sdk/src/define.d.ts.map +1 -0
- package/dist/agent-sdk/src/define.js +76 -0
- package/dist/agent-sdk/src/define.js.map +1 -0
- package/dist/agent-sdk/src/index.d.ts +9 -0
- package/dist/agent-sdk/src/index.d.ts.map +1 -1
- package/dist/agent-sdk/src/index.js +9 -0
- package/dist/agent-sdk/src/index.js.map +1 -1
- package/dist/agent-sdk/src/scaffold.d.ts +11 -0
- package/dist/agent-sdk/src/scaffold.d.ts.map +1 -1
- package/dist/agent-sdk/src/scaffold.js +16 -6
- package/dist/agent-sdk/src/scaffold.js.map +1 -1
- package/dist/agents/long-form-plan.d.ts.map +1 -1
- package/dist/agents/long-form-plan.js +2 -1
- package/dist/agents/long-form-plan.js.map +1 -1
- package/dist/agents/orchestrator.d.ts.map +1 -1
- package/dist/agents/orchestrator.js +5 -4
- package/dist/agents/orchestrator.js.map +1 -1
- package/dist/cli/agent.d.ts +2 -2
- package/dist/cli/agent.js +10 -10
- package/dist/cli/chat.d.ts +94 -0
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +354 -20
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/cli-program.d.ts.map +1 -1
- package/dist/cli/cli-program.js +5 -0
- package/dist/cli/cli-program.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +9 -1
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +3 -2
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/edit.js +2 -2
- package/dist/cli/eval.d.ts +17 -0
- package/dist/cli/eval.d.ts.map +1 -1
- package/dist/cli/eval.js +105 -2
- package/dist/cli/eval.js.map +1 -1
- package/dist/cli/execute.d.ts +16 -1
- package/dist/cli/execute.d.ts.map +1 -1
- package/dist/cli/execute.js +192 -22
- package/dist/cli/execute.js.map +1 -1
- package/dist/cli/loop-executor.d.ts +55 -0
- package/dist/cli/loop-executor.d.ts.map +1 -1
- package/dist/cli/loop-executor.js +212 -13
- package/dist/cli/loop-executor.js.map +1 -1
- package/dist/cli/model.d.ts.map +1 -1
- package/dist/cli/model.js +9 -8
- package/dist/cli/model.js.map +1 -1
- package/dist/cli/models.d.ts +1 -1
- package/dist/cli/models.js +4 -4
- package/dist/cli/parity.d.ts +85 -0
- package/dist/cli/parity.d.ts.map +1 -0
- package/dist/cli/parity.js +506 -0
- package/dist/cli/parity.js.map +1 -0
- package/dist/cli/plan.d.ts.map +1 -1
- package/dist/cli/plan.js +2 -1
- package/dist/cli/plan.js.map +1 -1
- package/dist/cli/retrieval.d.ts.map +1 -1
- package/dist/cli/retrieval.js +5 -4
- package/dist/cli/retrieval.js.map +1 -1
- package/dist/cli/sdk.js +4 -4
- package/dist/cli/sdk.js.map +1 -1
- package/dist/cli/trace.d.ts.map +1 -1
- package/dist/cli/trace.js +2 -1
- package/dist/cli/trace.js.map +1 -1
- package/dist/cli/workflow.js +2 -2
- package/dist/cli/workflow.js.map +1 -1
- package/dist/config/process-env.d.ts +136 -0
- package/dist/config/process-env.d.ts.map +1 -0
- package/dist/config/process-env.js +217 -0
- package/dist/config/process-env.js.map +1 -0
- package/dist/config/types.d.ts +44 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/findings/verdicts.d.ts +241 -0
- package/dist/findings/verdicts.d.ts.map +1 -0
- package/dist/findings/verdicts.js +284 -0
- package/dist/findings/verdicts.js.map +1 -0
- package/dist/gateway/adapters.d.ts +65 -0
- package/dist/gateway/adapters.d.ts.map +1 -1
- package/dist/gateway/adapters.js +216 -10
- package/dist/gateway/adapters.js.map +1 -1
- package/dist/gateway/channel-directory.d.ts +31 -0
- package/dist/gateway/channel-directory.d.ts.map +1 -1
- package/dist/gateway/channel-directory.js +40 -0
- package/dist/gateway/channel-directory.js.map +1 -1
- package/dist/gateway/gateway-log.d.ts +1 -1
- package/dist/gateway/gateway-log.d.ts.map +1 -1
- package/dist/gateway/gateway-log.js.map +1 -1
- package/dist/gateway/hooks.d.ts +87 -19
- package/dist/gateway/hooks.d.ts.map +1 -1
- package/dist/gateway/hooks.js +62 -23
- package/dist/gateway/hooks.js.map +1 -1
- package/dist/gateway/inbound-media.d.ts +147 -0
- package/dist/gateway/inbound-media.d.ts.map +1 -0
- package/dist/gateway/inbound-media.js +317 -0
- package/dist/gateway/inbound-media.js.map +1 -0
- package/dist/gateway/inbox.d.ts +8 -1
- package/dist/gateway/inbox.d.ts.map +1 -1
- package/dist/gateway/inbox.js.map +1 -1
- package/dist/gateway/platform-config.d.ts +14 -0
- package/dist/gateway/platform-config.d.ts.map +1 -1
- package/dist/gateway/platform-config.js +26 -8
- package/dist/gateway/platform-config.js.map +1 -1
- package/dist/gateway/realtime.d.ts +114 -0
- package/dist/gateway/realtime.d.ts.map +1 -0
- package/dist/gateway/realtime.js +402 -0
- package/dist/gateway/realtime.js.map +1 -0
- package/dist/gateway/registry.d.ts +31 -0
- package/dist/gateway/registry.d.ts.map +1 -1
- package/dist/gateway/registry.js +224 -4
- package/dist/gateway/registry.js.map +1 -1
- package/dist/gateway/whatsapp/baileys-bridge.d.ts +11 -1
- package/dist/gateway/whatsapp/baileys-bridge.d.ts.map +1 -1
- package/dist/gateway/whatsapp/baileys-bridge.js +123 -4
- package/dist/gateway/whatsapp/baileys-bridge.js.map +1 -1
- package/dist/gateway/whatsapp/bridge.d.ts +6 -2
- package/dist/gateway/whatsapp/bridge.d.ts.map +1 -1
- package/dist/gateway/whatsapp/bridge.js.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/inference/factory.d.ts +14 -0
- package/dist/inference/factory.d.ts.map +1 -1
- package/dist/inference/factory.js +17 -0
- package/dist/inference/factory.js.map +1 -1
- package/dist/inference/groq-adapter.d.ts +2 -0
- package/dist/inference/groq-adapter.d.ts.map +1 -1
- package/dist/inference/groq-adapter.js +16 -6
- package/dist/inference/groq-adapter.js.map +1 -1
- package/dist/inference/tools.d.ts.map +1 -1
- package/dist/inference/tools.js +29 -0
- package/dist/inference/tools.js.map +1 -1
- package/dist/learning/benchmark.d.ts.map +1 -1
- package/dist/learning/benchmark.js +3 -2
- package/dist/learning/benchmark.js.map +1 -1
- package/dist/learning/continuation.d.ts.map +1 -1
- package/dist/learning/continuation.js +2 -1
- package/dist/learning/continuation.js.map +1 -1
- package/dist/learning/cost-tracker.d.ts.map +1 -1
- package/dist/learning/cost-tracker.js +2 -1
- package/dist/learning/cost-tracker.js.map +1 -1
- package/dist/learning/deferred-task.d.ts.map +1 -1
- package/dist/learning/deferred-task.js +13 -4
- package/dist/learning/deferred-task.js.map +1 -1
- package/dist/learning/eval-framework.d.ts.map +1 -1
- package/dist/learning/eval-framework.js +2 -1
- package/dist/learning/eval-framework.js.map +1 -1
- package/dist/learning/long-form.d.ts.map +1 -1
- package/dist/learning/long-form.js +2 -1
- package/dist/learning/long-form.js.map +1 -1
- package/dist/learning/model-reachability.d.ts +95 -0
- package/dist/learning/model-reachability.d.ts.map +1 -0
- package/dist/learning/model-reachability.js +111 -0
- package/dist/learning/model-reachability.js.map +1 -0
- package/dist/learning/model-registry.d.ts +22 -0
- package/dist/learning/model-registry.d.ts.map +1 -1
- package/dist/learning/model-registry.js +26 -1
- package/dist/learning/model-registry.js.map +1 -1
- package/dist/learning/model-verify-job.d.ts +131 -0
- package/dist/learning/model-verify-job.d.ts.map +1 -0
- package/dist/learning/model-verify-job.js +221 -0
- package/dist/learning/model-verify-job.js.map +1 -0
- package/dist/learning/reasoning-cache.d.ts.map +1 -1
- package/dist/learning/reasoning-cache.js +2 -1
- package/dist/learning/reasoning-cache.js.map +1 -1
- package/dist/learning/reasoning-trace.d.ts +37 -1
- package/dist/learning/reasoning-trace.d.ts.map +1 -1
- package/dist/learning/reasoning-trace.js +66 -0
- package/dist/learning/reasoning-trace.js.map +1 -1
- package/dist/learning/resilient-call.d.ts.map +1 -1
- package/dist/learning/resilient-call.js +2 -1
- package/dist/learning/resilient-call.js.map +1 -1
- package/dist/learning/retrieval.d.ts.map +1 -1
- package/dist/learning/retrieval.js +2 -1
- package/dist/learning/retrieval.js.map +1 -1
- package/dist/learning/seeded-benchmark.d.ts +160 -0
- package/dist/learning/seeded-benchmark.d.ts.map +1 -0
- package/dist/learning/seeded-benchmark.js +321 -0
- package/dist/learning/seeded-benchmark.js.map +1 -0
- package/dist/learning/seeded-bugs.d.ts +142 -0
- package/dist/learning/seeded-bugs.d.ts.map +1 -0
- package/dist/learning/seeded-bugs.js +535 -0
- package/dist/learning/seeded-bugs.js.map +1 -0
- package/dist/learning/step-checkpoint.d.ts +127 -0
- package/dist/learning/step-checkpoint.d.ts.map +1 -0
- package/dist/learning/step-checkpoint.js +244 -0
- package/dist/learning/step-checkpoint.js.map +1 -0
- package/dist/nlu/intent-confirm.d.ts +23 -1
- package/dist/nlu/intent-confirm.d.ts.map +1 -1
- package/dist/nlu/intent-confirm.js +85 -2
- package/dist/nlu/intent-confirm.js.map +1 -1
- package/dist/nlu/learnings.d.ts +7 -0
- package/dist/nlu/learnings.d.ts.map +1 -1
- package/dist/nlu/learnings.js +7 -0
- package/dist/nlu/learnings.js.map +1 -1
- package/dist/observability/debug-log.d.ts +250 -0
- package/dist/observability/debug-log.d.ts.map +1 -0
- package/dist/observability/debug-log.js +500 -0
- package/dist/observability/debug-log.js.map +1 -0
- package/dist/observability/event-bus.d.ts.map +1 -1
- package/dist/observability/event-bus.js +4 -1
- package/dist/observability/event-bus.js.map +1 -1
- package/dist/observability/otel.d.ts +278 -0
- package/dist/observability/otel.d.ts.map +1 -0
- package/dist/observability/otel.js +590 -0
- package/dist/observability/otel.js.map +1 -0
- package/dist/parity/drivers.d.ts +99 -0
- package/dist/parity/drivers.d.ts.map +1 -0
- package/dist/parity/drivers.js +1362 -0
- package/dist/parity/drivers.js.map +1 -0
- package/dist/parity/graph.d.ts +73 -0
- package/dist/parity/graph.d.ts.map +1 -0
- package/dist/parity/graph.js +162 -0
- package/dist/parity/graph.js.map +1 -0
- package/dist/parity/matrix.d.ts +105 -0
- package/dist/parity/matrix.d.ts.map +1 -0
- package/dist/parity/matrix.js +352 -0
- package/dist/parity/matrix.js.map +1 -0
- package/dist/parity/observation.d.ts +444 -0
- package/dist/parity/observation.d.ts.map +1 -0
- package/dist/parity/observation.js +333 -0
- package/dist/parity/observation.js.map +1 -0
- package/dist/parity/scenarios.d.ts +229 -0
- package/dist/parity/scenarios.d.ts.map +1 -0
- package/dist/parity/scenarios.js +175 -0
- package/dist/parity/scenarios.js.map +1 -0
- package/dist/parity/surfaces.d.ts +122 -0
- package/dist/parity/surfaces.d.ts.map +1 -0
- package/dist/parity/surfaces.js +190 -0
- package/dist/parity/surfaces.js.map +1 -0
- package/dist/runtime/fault-injection.d.ts +173 -0
- package/dist/runtime/fault-injection.d.ts.map +1 -0
- package/dist/runtime/fault-injection.js +281 -0
- package/dist/runtime/fault-injection.js.map +1 -0
- package/dist/tools/child-agent-entry.d.ts +23 -0
- package/dist/tools/child-agent-entry.d.ts.map +1 -0
- package/dist/tools/child-agent-entry.js +129 -0
- package/dist/tools/child-agent-entry.js.map +1 -0
- package/dist/tools/child-agent-runtime.d.ts +124 -0
- package/dist/tools/child-agent-runtime.d.ts.map +1 -0
- package/dist/tools/child-agent-runtime.js +704 -0
- package/dist/tools/child-agent-runtime.js.map +1 -0
- package/dist/tools/coding-tools.d.ts.map +1 -1
- package/dist/tools/coding-tools.js +82 -10
- package/dist/tools/coding-tools.js.map +1 -1
- package/dist/tools/delegation-system.d.ts +31 -0
- package/dist/tools/delegation-system.d.ts.map +1 -1
- package/dist/tools/delegation-system.js +70 -9
- package/dist/tools/delegation-system.js.map +1 -1
- package/dist/tools/extract/docx.d.ts +27 -0
- package/dist/tools/extract/docx.d.ts.map +1 -0
- package/dist/tools/extract/docx.js +48 -0
- package/dist/tools/extract/docx.js.map +1 -0
- package/dist/tools/extract/html-text.d.ts +27 -0
- package/dist/tools/extract/html-text.d.ts.map +1 -0
- package/dist/tools/extract/html-text.js +86 -0
- package/dist/tools/extract/html-text.js.map +1 -0
- package/dist/tools/extract/pdf-ocr.d.ts +58 -0
- package/dist/tools/extract/pdf-ocr.d.ts.map +1 -0
- package/dist/tools/extract/pdf-ocr.js +116 -0
- package/dist/tools/extract/pdf-ocr.js.map +1 -0
- package/dist/tools/extract/pdf.d.ts +65 -0
- package/dist/tools/extract/pdf.d.ts.map +1 -0
- package/dist/tools/extract/pdf.js +197 -0
- package/dist/tools/extract/pdf.js.map +1 -0
- package/dist/tools/extract/pptx.d.ts +32 -0
- package/dist/tools/extract/pptx.d.ts.map +1 -0
- package/dist/tools/extract/pptx.js +77 -0
- package/dist/tools/extract/pptx.js.map +1 -0
- package/dist/tools/extract/xlsx.d.ts +47 -0
- package/dist/tools/extract/xlsx.d.ts.map +1 -0
- package/dist/tools/extract/xlsx.js +111 -0
- package/dist/tools/extract/xlsx.js.map +1 -0
- package/dist/tools/finding-tool.d.ts +76 -0
- package/dist/tools/finding-tool.d.ts.map +1 -0
- package/dist/tools/finding-tool.js +125 -0
- package/dist/tools/finding-tool.js.map +1 -0
- package/dist/tools/messaging-tools.d.ts +41 -11
- package/dist/tools/messaging-tools.d.ts.map +1 -1
- package/dist/tools/messaging-tools.js +104 -55
- package/dist/tools/messaging-tools.js.map +1 -1
- package/dist/tools/neutts-synth.d.ts +27 -3
- package/dist/tools/neutts-synth.d.ts.map +1 -1
- package/dist/tools/neutts-synth.js +57 -13
- package/dist/tools/neutts-synth.js.map +1 -1
- package/dist/tools/pipeline-tool.d.ts +43 -1
- package/dist/tools/pipeline-tool.d.ts.map +1 -1
- package/dist/tools/pipeline-tool.js +13 -2
- package/dist/tools/pipeline-tool.js.map +1 -1
- package/dist/tools/read-extract.d.ts +116 -45
- package/dist/tools/read-extract.d.ts.map +1 -1
- package/dist/tools/read-extract.js +494 -158
- package/dist/tools/read-extract.js.map +1 -1
- package/dist/tools/registry.d.ts +2 -2
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +152 -23
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/subagent-refusal.d.ts +15 -0
- package/dist/tools/subagent-refusal.d.ts.map +1 -0
- package/dist/tools/subagent-refusal.js +18 -0
- package/dist/tools/subagent-refusal.js.map +1 -0
- package/dist/tools/subagent-spawner.d.ts +122 -0
- package/dist/tools/subagent-spawner.d.ts.map +1 -1
- package/dist/tools/subagent-spawner.js +249 -28
- package/dist/tools/subagent-spawner.js.map +1 -1
- package/dist/tools/tool-hooks.d.ts +177 -0
- package/dist/tools/tool-hooks.d.ts.map +1 -0
- package/dist/tools/tool-hooks.js +427 -0
- package/dist/tools/tool-hooks.js.map +1 -0
- package/dist/tools/tool-loop.d.ts +82 -0
- package/dist/tools/tool-loop.d.ts.map +1 -1
- package/dist/tools/tool-loop.js +167 -9
- package/dist/tools/tool-loop.js.map +1 -1
- package/dist/tools/tool-refusal.d.ts +68 -0
- package/dist/tools/tool-refusal.d.ts.map +1 -0
- package/dist/tools/tool-refusal.js +78 -0
- package/dist/tools/tool-refusal.js.map +1 -0
- package/dist/tools/toolsets.d.ts +8 -0
- package/dist/tools/toolsets.d.ts.map +1 -1
- package/dist/tools/toolsets.js +12 -2
- package/dist/tools/toolsets.js.map +1 -1
- package/dist/tools/vision-tools.d.ts +88 -83
- package/dist/tools/vision-tools.d.ts.map +1 -1
- package/dist/tools/vision-tools.js +134 -103
- package/dist/tools/vision-tools.js.map +1 -1
- package/dist/tools/worktree.d.ts +210 -0
- package/dist/tools/worktree.d.ts.map +1 -0
- package/dist/tools/worktree.js +374 -0
- package/dist/tools/worktree.js.map +1 -0
- package/dist/utils/format.d.ts +3 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +32 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/web-dashboard/attachment-extract.d.ts +64 -0
- package/dist/web-dashboard/attachment-extract.d.ts.map +1 -0
- package/dist/web-dashboard/attachment-extract.js +154 -0
- package/dist/web-dashboard/attachment-extract.js.map +1 -0
- package/dist/web-dashboard/chat-console.d.ts +108 -1
- package/dist/web-dashboard/chat-console.d.ts.map +1 -1
- package/dist/web-dashboard/chat-console.js +36 -0
- package/dist/web-dashboard/chat-console.js.map +1 -1
- package/dist/web-dashboard/hub-data.d.ts +37 -0
- package/dist/web-dashboard/hub-data.d.ts.map +1 -1
- package/dist/web-dashboard/hub-data.js +61 -1
- package/dist/web-dashboard/hub-data.js.map +1 -1
- package/dist/web-dashboard/process-env-inventory.d.ts +57 -0
- package/dist/web-dashboard/process-env-inventory.d.ts.map +1 -0
- package/dist/web-dashboard/process-env-inventory.js +96 -0
- package/dist/web-dashboard/process-env-inventory.js.map +1 -0
- package/dist/web-dashboard/server.d.ts +14 -0
- package/dist/web-dashboard/server.d.ts.map +1 -1
- package/dist/web-dashboard/server.js +493 -30
- package/dist/web-dashboard/server.js.map +1 -1
- package/dist/web-dashboard/src/types.d.ts +261 -48
- package/dist/web-dashboard/src/types.d.ts.map +1 -1
- package/package.json +18 -3
- package/src/web-dashboard/public/assets/{index-Cyd6tIew.css → index-CIJ6FHHZ.css} +1 -1
- package/src/web-dashboard/public/assets/index-CsySzR41.js +207 -0
- package/src/web-dashboard/public/assets/index-CsySzR41.js.map +1 -0
- package/src/web-dashboard/public/index.html +2 -2
- package/dist/tools/child-agent-worker.js +0 -212
- package/src/web-dashboard/public/assets/index-CxDj7p6i.js +0 -207
- package/src/web-dashboard/public/assets/index-CxDj7p6i.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
|
+
//# sour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