eve 0.78.0 → 0.79.1
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/CHANGELOG.md +43 -0
- package/dist/src/approval/definition.d.ts +42 -0
- package/dist/src/chunks/{use-eve-agent-BSYe_Re7.js → use-eve-agent-Ch-Q-s12.js} +43 -13
- package/dist/src/chunks/{use-eve-agent-B8brxCk-.js → use-eve-agent-Vsl-S0yI.js} +43 -13
- package/dist/src/cli/commands/trace-detail.d.ts +2 -2
- package/dist/src/cli/commands/trace-detail.js +1 -1
- package/dist/src/cli/commands/trace.d.ts +1 -1
- package/dist/src/cli/commands/trace.js +1 -1
- package/dist/src/cli/dev/tui/traces/trace-conversation.d.ts +1 -1
- package/dist/src/cli/dev/tui/traces/trace-conversation.js +1 -1
- package/dist/src/cli/dev/tui/traces/trace-store.d.ts +1 -1
- package/dist/src/cli/dev/tui/traces/trace-store.js +1 -1
- package/dist/src/cli/dev/tui/traces/trace-view.d.ts +1 -1
- package/dist/src/cli/dev/tui/traces/trace-view.js +1 -1
- package/dist/src/cli/dev/tui/traces/trace-viewer-state.d.ts +1 -1
- package/dist/src/client/abort-signal.d.ts +2 -0
- package/dist/src/client/abort-signal.js +1 -0
- package/dist/src/client/conversation-client.d.ts +2 -0
- package/dist/src/client/conversation-client.js +1 -1
- package/dist/src/client/eve-agent-store-state.d.ts +9 -0
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/ndjson.js +1 -1
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session-turn-dispatch.js +1 -1
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +3 -1
- package/dist/src/compiled/@eve/tracing/adapters/agent-transport.d.ts +8 -0
- package/dist/src/compiled/@eve/tracing/adapters/ai-sdk-payload.d.ts +15 -0
- package/dist/src/compiled/@eve/tracing/adapters/ai-sdk-telemetry.d.ts +14 -0
- package/dist/src/{tracing/agent-span-id-generator.d.ts → compiled/@eve/tracing/adapters/otel-ids.d.ts} +1 -1
- package/dist/src/compiled/@eve/tracing/adapters/otel.d.ts +33 -0
- package/dist/src/{tracing/agent-otel-content.d.ts → compiled/@eve/tracing/adapters/serialization.d.ts} +9 -3
- package/dist/src/compiled/@eve/tracing/agent-tracing.d.ts +84 -0
- package/dist/src/compiled/@eve/tracing/ai-sdk.d.ts +7 -0
- package/dist/src/compiled/@eve/tracing/ai-sdk.js +1 -0
- package/dist/src/compiled/@eve/tracing/capture.d.ts +5 -0
- package/dist/src/compiled/@eve/tracing/core/activation.d.ts +3 -0
- package/dist/src/compiled/@eve/tracing/core/attributes.d.ts +14 -0
- package/dist/src/{tracing/content-attributes.d.ts → compiled/@eve/tracing/core/content-policy.d.ts} +1 -1
- package/dist/src/compiled/@eve/tracing/core/context.d.ts +3 -0
- package/dist/src/compiled/@eve/tracing/core/delegation.d.ts +13 -0
- package/dist/src/compiled/@eve/tracing/core/mcp.d.ts +24 -0
- package/dist/src/compiled/@eve/tracing/core/scopes.d.ts +59 -0
- package/dist/src/compiled/@eve/tracing/core/snapshot.d.ts +7 -0
- package/dist/src/compiled/@eve/tracing/core/span-kinds.d.ts +12 -0
- package/dist/src/compiled/@eve/tracing/core/types.d.ts +297 -0
- package/dist/src/compiled/@eve/tracing/core/writer.d.ts +15 -0
- package/dist/src/compiled/@eve/tracing/delegation.d.ts +2 -0
- package/dist/src/compiled/@eve/tracing/delegation.js +1 -0
- package/dist/src/compiled/@eve/tracing/index.d.ts +6 -0
- package/dist/src/compiled/@eve/tracing/index.js +1 -0
- package/dist/src/compiled/@eve/tracing/operations.d.ts +96 -0
- package/dist/src/compiled/@eve/tracing/otel.d.ts +12 -0
- package/dist/src/compiled/@eve/tracing/otel.js +1 -0
- package/dist/src/compiled/@opentelemetry/api/index.d.ts +4 -0
- package/dist/src/compiled/@workflow/world-vercel/index.js +7 -7
- package/dist/src/compiled/_chunks/workflow/delegation-BqhZ398D.js +1 -0
- package/dist/src/compiled/_chunks/workflow/mcp-C01bDEX-.js +5 -0
- package/dist/src/compiler/extension-compatibility.d.ts +6 -6
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/project-sources.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/memory-tools.js +1 -1
- package/dist/src/evals/assertions/collector.d.ts +4 -1
- package/dist/src/evals/assertions/collector.js +1 -1
- package/dist/src/evals/context.js +1 -1
- package/dist/src/evals/index.d.ts +1 -1
- package/dist/src/evals/runner/artifacts.js +1 -1
- package/dist/src/evals/runner/reporters/assertion-diagnostics.js +2 -2
- package/dist/src/evals/runner/reporters/assertion-scores.d.ts +13 -2
- package/dist/src/evals/runner/reporters/assertion-scores.js +1 -1
- package/dist/src/evals/runner/reporters/braintrust.js +1 -1
- package/dist/src/evals/runner/reporters/console.js +1 -1
- package/dist/src/evals/runner/reporters/datadog.js +2 -2
- package/dist/src/evals/runner/reporters/junit.js +1 -1
- package/dist/src/evals/runner/verdict.d.ts +2 -2
- package/dist/src/evals/runner/verdict.js +1 -1
- package/dist/src/evals/types.d.ts +22 -6
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.js +1 -1
- package/dist/src/eve-channel/stream-headers.d.ts +1 -0
- package/dist/src/eve-channel/stream-headers.js +1 -0
- package/dist/src/execution/agent-sessions/context.d.ts +1 -1
- package/dist/src/execution/agent-sessions/context.js +1 -1
- package/dist/src/execution/agent-sessions/remote.js +1 -1
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/authorization-callback-match.d.ts +2 -2
- package/dist/src/execution/authorization-callback-match.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/catalog/connection-entry.js +1 -1
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/eve-workflow-attributes.js +1 -1
- package/dist/src/execution/forward-session-input.js +1 -1
- package/dist/src/execution/invoke-tool.d.ts +1 -1
- package/dist/src/execution/invoke-tool.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/publish-session-events.d.ts +13 -2
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-create-sdk.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-credentials.d.ts +2 -0
- package/dist/src/execution/sandbox/bindings/vercel-credentials.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-lifecycle.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-lookup.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +3 -6
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +1 -1
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +13 -6
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/pending-turn-state.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +4 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/tasks/steps.d.ts +1 -1
- package/dist/src/execution/tasks/steps.js +1 -1
- package/dist/src/execution/tool-auth.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/workflow/answer.d.ts +1 -1
- package/dist/src/execution/tools/workflow/withdraw-step.d.ts +2 -2
- package/dist/src/execution/tools/workflow/withdraw-step.js +1 -1
- package/dist/src/execution/workflow-callback-url.d.ts +10 -1
- package/dist/src/execution/workflow-callback-url.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/authorization.d.ts +3 -13
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/compaction/step.d.ts +1 -0
- package/dist/src/harness/compaction/step.js +1 -1
- package/dist/src/harness/coordination.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +2 -2
- package/dist/src/harness/hitl/approvals.d.ts +1 -1
- package/dist/src/harness/hitl/approvals.js +1 -1
- package/dist/src/harness/hitl/approved-calls.d.ts +3 -0
- package/dist/src/harness/hitl/approved-calls.js +1 -1
- package/dist/src/harness/hitl/candidates.d.ts +13 -0
- package/dist/src/harness/hitl/candidates.js +1 -1
- package/dist/src/harness/hitl/coordinator.js +1 -1
- package/dist/src/harness/hitl/index.d.ts +2 -5
- package/dist/src/harness/hitl/index.js +1 -1
- package/dist/src/harness/hitl/intake.js +1 -1
- package/dist/src/harness/{proxy-input-requests.d.ts → hitl/relays.d.ts} +3 -39
- package/dist/src/harness/hitl/relays.js +1 -0
- package/dist/src/harness/hitl/requests.d.ts +64 -0
- package/dist/src/harness/hitl/requests.js +1 -0
- package/dist/src/harness/hitl/sign-ins.d.ts +9 -0
- package/dist/src/harness/hitl/sign-ins.js +1 -0
- package/dist/src/harness/inline-tool-authorization.js +1 -1
- package/dist/src/harness/input-extraction.js +1 -1
- package/dist/src/harness/model-call/call.js +1 -1
- package/dist/src/harness/model-call/model.d.ts +3 -1
- package/dist/src/harness/model-call/model.js +1 -1
- package/dist/src/harness/session-machine/commit.d.ts +14 -3
- package/dist/src/harness/session-machine/commit.js +1 -1
- package/dist/src/harness/session-machine/transitions.d.ts +16 -0
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/instrumentation/dispatch.js +1 -1
- package/dist/src/instrumentation/memory.d.ts +1 -4
- package/dist/src/instrumentation/memory.js +1 -1
- package/dist/src/instrumentation/principal-summary.js +1 -1
- package/dist/src/instrumentation/providers.js +1 -1
- package/dist/src/instrumentation/runtime-context.d.ts +1 -1
- package/dist/src/instrumentation/runtime.d.ts +4 -3
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/instrumentation/session-init.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/authored-definition/approval.d.ts +3 -1
- package/dist/src/internal/authored-definition/approval.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/authored-definition/source-identity.d.ts +6 -0
- package/dist/src/internal/authored-definition/source-identity.js +1 -1
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/helpers/markdown.js +1 -1
- package/dist/src/internal/logging.js +1 -1
- package/dist/src/internal/nitro/host/local-tracing-runtime-plugin.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-request-instrumentation.d.ts +10 -31
- package/dist/src/internal/nitro/routes/channel-request-instrumentation.js +1 -1
- package/dist/src/internal/nitro/routes/route-invoke-tool.d.ts +1 -1
- package/dist/src/internal/workflow/is-inactive-workflow-run-error.d.ts +2 -0
- package/dist/src/internal/workflow/is-inactive-workflow-run-error.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +1 -1
- package/dist/src/protocol/baggage.d.ts +1 -0
- package/dist/src/protocol/baggage.js +1 -1
- package/dist/src/public/channels/slack/hitl.js +1 -1
- package/dist/src/public/definitions/approval.d.ts +1 -1
- package/dist/src/public/definitions/connections/mcp.js +1 -1
- package/dist/src/public/definitions/connections/openapi.js +1 -1
- package/dist/src/public/instrumentation/otel.d.ts +2 -2
- package/dist/src/public/instrumentation/otel.js +1 -1
- package/dist/src/public/sandbox/vercel.d.ts +2 -0
- package/dist/src/public/tools/approval/index.d.ts +1 -1
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/public/tools/result.d.ts +10 -7
- package/dist/src/react/use-eve-agent.d.ts +6 -0
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/runtime/authorization-context.d.ts +5 -0
- package/dist/src/runtime/authorization-context.js +1 -1
- package/dist/src/runtime/connections/mcp-tracing.d.ts +10 -18
- package/dist/src/runtime/connections/mcp-tracing.js +1 -1
- package/dist/src/runtime/connections/openapi-operations.js +1 -1
- package/dist/src/runtime/connections/scoped-authorization.d.ts +6 -0
- package/dist/src/runtime/connections/scoped-authorization.js +1 -1
- package/dist/src/runtime/resolve-connection.js +1 -1
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/runtime/types.d.ts +2 -2
- package/dist/src/self-modification/extension/subagents/agent/tools/inspect_trace.d.ts +12 -12
- package/dist/src/self-modification/extension/subagents/agent/tools/inspect_trace.js +1 -1
- package/dist/src/self-modification/extension/subagents/agent/tools/search_traces.d.ts +1 -1
- package/dist/src/self-modification/extension/subagents/agent/tools/search_traces.js +1 -1
- package/dist/src/self-modification/extension/trace-inspection.d.ts +1 -1
- package/dist/src/self-modification/extension/trace-inspection.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +18 -10
- package/dist/src/shared/git.js +1 -1
- package/dist/src/shared/instrumentation-content.d.ts +1 -1
- package/dist/src/shared/instrumentation-content.js +1 -1
- package/dist/src/shared/instrumentation-decision.d.ts +3 -0
- package/dist/src/shared/instrumentation-decision.js +1 -1
- package/dist/src/shared/skill-package.js +1 -1
- package/dist/src/shared/trace-policy.d.ts +3 -0
- package/dist/src/shared/trace-policy.js +1 -1
- package/dist/src/subagents/adapter.js +1 -1
- package/dist/src/subagents/event-proxy-step.d.ts +1 -1
- package/dist/src/subagents/event-proxy-step.js +1 -1
- package/dist/src/subagents/hitl-proxy.d.ts +1 -1
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +6 -0
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/definition.d.ts +41 -4
- package/dist/src/tools/durable-callbacks.d.ts +5 -3
- package/dist/src/tools/durable-callbacks.js +1 -1
- package/dist/src/tools/dynamic.d.ts +2 -2
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +2 -2
- package/dist/src/tracing/eve/agent-approval-instrumentation.d.ts +8 -0
- package/dist/src/tracing/eve/agent-approval-instrumentation.js +1 -0
- package/dist/src/tracing/{agent-channel-delivery-instrumentation.d.ts → eve/agent-channel-delivery-instrumentation.d.ts} +1 -1
- package/dist/src/tracing/{agent-channel-delivery-instrumentation.js → eve/agent-channel-delivery-instrumentation.js} +1 -1
- package/dist/src/tracing/eve/agent-invocation-coordinator.js +1 -0
- package/dist/src/tracing/eve/agent-memory-instrumentation.d.ts +12 -0
- package/dist/src/tracing/eve/agent-memory-instrumentation.js +1 -0
- package/dist/src/tracing/{agent-otel-provider.d.ts → eve/agent-otel-provider.d.ts} +6 -8
- package/dist/src/tracing/eve/agent-otel-provider.js +1 -0
- package/dist/src/tracing/eve/agent-tool-instrumentation.d.ts +44 -0
- package/dist/src/tracing/eve/agent-tool-instrumentation.js +1 -0
- package/dist/src/tracing/{agent-trace-context-store.d.ts → eve/agent-trace-context-store.d.ts} +8 -16
- package/dist/src/tracing/eve/agent-trace-context-store.js +1 -0
- package/dist/src/tracing/eve/agent-trace-context.js +1 -0
- package/dist/src/tracing/eve/agent-trace-state.d.ts +75 -0
- package/dist/src/tracing/{batch-span-processor.d.ts → eve/batch-span-processor.d.ts} +5 -1
- package/dist/src/tracing/eve/batch-span-processor.js +1 -0
- package/dist/src/tracing/{content-span-processor.d.ts → eve/content-span-processor.d.ts} +1 -1
- package/dist/src/tracing/eve/content-span-processor.js +1 -0
- package/dist/src/tracing/eve/delegation.d.ts +20 -0
- package/dist/src/tracing/eve/delegation.js +1 -0
- package/dist/src/tracing/eve/gateway.d.ts +17 -0
- package/dist/src/tracing/eve/gateway.js +1 -0
- package/dist/src/tracing/{install-instrumentation-runtime.d.ts → eve/install-instrumentation-runtime.d.ts} +1 -1
- package/dist/src/tracing/eve/install-instrumentation-runtime.js +1 -0
- package/dist/src/tracing/eve/invoke-tool-span.js +1 -0
- package/dist/src/tracing/eve/mcp.d.ts +29 -0
- package/dist/src/tracing/eve/mcp.js +1 -0
- package/dist/src/tracing/eve/metadata.d.ts +7 -0
- package/dist/src/tracing/eve/metadata.js +1 -0
- package/dist/src/tracing/eve/operation-input.d.ts +30 -0
- package/dist/src/tracing/eve/operation-input.js +1 -0
- package/dist/src/tracing/eve/otel-configuration.d.ts +70 -0
- package/dist/src/tracing/eve/otel-configuration.js +1 -0
- package/dist/src/tracing/{otel-declaration.d.ts → eve/otel-declaration.d.ts} +13 -19
- package/dist/src/tracing/eve/otel-declaration.js +1 -0
- package/dist/src/tracing/{otel-registration.d.ts → eve/otel-registration.d.ts} +12 -5
- package/dist/src/tracing/eve/otel-registration.js +1 -0
- package/dist/src/tracing/eve/policy.d.ts +15 -0
- package/dist/src/tracing/eve/policy.js +1 -0
- package/dist/src/tracing/eve/profile.d.ts +7 -0
- package/dist/src/tracing/eve/profile.js +1 -0
- package/dist/src/tracing/eve/session.d.ts +27 -0
- package/dist/src/tracing/eve/session.js +1 -0
- package/dist/src/tracing/{vercel-runtime-span-exporter.d.ts → eve/vercel-runtime-span-exporter.d.ts} +1 -1
- package/dist/src/tracing/local/agent-trace-span-processor.js +1 -0
- package/dist/src/tracing/local/inspection.d.ts +15 -0
- package/dist/src/tracing/local/inspection.js +1 -0
- package/dist/src/tracing/{local-instrumentation-runtime.d.ts → local/instrumentation-runtime.d.ts} +1 -1
- package/dist/src/tracing/local/instrumentation-runtime.js +1 -0
- package/dist/src/tracing/{local-trace-analysis.d.ts → local/trace-analysis.d.ts} +2 -2
- package/dist/src/tracing/{local-trace-analysis.js → local/trace-analysis.js} +1 -1
- package/dist/src/tracing/{local-trace-operations.d.ts → local/trace-operations.d.ts} +1 -1
- package/dist/src/tracing/{local-trace-query.d.ts → local/trace-query.d.ts} +1 -1
- package/dist/src/tracing/local/trace-reader.js +1 -0
- package/dist/src/tracing/{local-trace-retention.js → local/trace-retention.js} +1 -1
- package/dist/src/tracing/{local-trace-span-processor.js → local/trace-span-processor.js} +1 -1
- package/dist/src/tracing/{local-trace-summary.d.ts → local/trace-summary.d.ts} +1 -1
- package/dist/src/tracing/local/trace-summary.js +1 -0
- package/dist/src/tracing/{local-traces.d.ts → local/traces.d.ts} +1 -1
- package/dist/src/tracing/local/traces.js +1 -0
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +6 -0
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +48 -0
- package/docs/channels/eve.mdx +2 -0
- package/docs/connections/mcp.mdx +22 -1
- package/docs/connections/overview.mdx +9 -6
- package/docs/evals/assertions.mdx +50 -3
- package/docs/evals/overview.mdx +2 -1
- package/docs/evals/reporters.mdx +3 -1
- package/docs/guides/frontend/overview.mdx +10 -1
- package/docs/guides/hooks.md +2 -2
- package/docs/guides/instrumentation/otel.mdx +3 -0
- package/docs/reference/cli.md +1 -1
- package/docs/reference/typescript-api.md +7 -6
- package/docs/sandbox/vercel.mdx +9 -0
- package/docs/skills.mdx +1 -1
- package/docs/tools/human-in-the-loop.md +44 -1
- package/package.json +2 -1
- package/dist/src/harness/proxy-input-requests.js +0 -1
- package/dist/src/tracing/agent-approval-instrumentation.d.ts +0 -11
- package/dist/src/tracing/agent-approval-instrumentation.js +0 -1
- package/dist/src/tracing/agent-invocation-coordinator.js +0 -1
- package/dist/src/tracing/agent-memory-instrumentation.d.ts +0 -16
- package/dist/src/tracing/agent-memory-instrumentation.js +0 -1
- package/dist/src/tracing/agent-otel-attributes.d.ts +0 -10
- package/dist/src/tracing/agent-otel-attributes.js +0 -1
- package/dist/src/tracing/agent-otel-content.js +0 -4
- package/dist/src/tracing/agent-otel-provider.js +0 -2
- package/dist/src/tracing/agent-otel-runtime-context.d.ts +0 -36
- package/dist/src/tracing/agent-otel-runtime-context.js +0 -1
- package/dist/src/tracing/agent-otel-session-context.d.ts +0 -22
- package/dist/src/tracing/agent-otel-session-context.js +0 -1
- package/dist/src/tracing/agent-otel-turn-state.d.ts +0 -6
- package/dist/src/tracing/agent-otel-turn-state.js +0 -1
- package/dist/src/tracing/agent-otel-usage.d.ts +0 -10
- package/dist/src/tracing/agent-otel-usage.js +0 -1
- package/dist/src/tracing/agent-span-contract.d.ts +0 -34
- package/dist/src/tracing/agent-span-contract.js +0 -1
- package/dist/src/tracing/agent-span-error.js +0 -1
- package/dist/src/tracing/agent-span-id-generator.js +0 -1
- package/dist/src/tracing/agent-span-naming.d.ts +0 -1
- package/dist/src/tracing/agent-span-naming.js +0 -1
- package/dist/src/tracing/agent-tool-instrumentation.d.ts +0 -40
- package/dist/src/tracing/agent-tool-instrumentation.js +0 -1
- package/dist/src/tracing/agent-tool-span-context.d.ts +0 -16
- package/dist/src/tracing/agent-tool-span-context.js +0 -1
- package/dist/src/tracing/agent-trace-context-codec.d.ts +0 -15
- package/dist/src/tracing/agent-trace-context-codec.js +0 -1
- package/dist/src/tracing/agent-trace-context-store.js +0 -1
- package/dist/src/tracing/agent-trace-context.js +0 -1
- package/dist/src/tracing/agent-trace-span-processor.js +0 -1
- package/dist/src/tracing/agent-trace-state.d.ts +0 -91
- package/dist/src/tracing/batch-span-processor.js +0 -1
- package/dist/src/tracing/bounded-error.d.ts +0 -1
- package/dist/src/tracing/bounded-error.js +0 -1
- package/dist/src/tracing/content-attributes.js +0 -1
- package/dist/src/tracing/content-span-processor.js +0 -1
- package/dist/src/tracing/error-content-context.d.ts +0 -3
- package/dist/src/tracing/error-content-context.js +0 -1
- package/dist/src/tracing/install-instrumentation-runtime.js +0 -1
- package/dist/src/tracing/invoke-tool-span.js +0 -1
- package/dist/src/tracing/local-instrumentation-runtime.js +0 -1
- package/dist/src/tracing/local-trace-reader.js +0 -1
- package/dist/src/tracing/local-trace-summary.js +0 -1
- package/dist/src/tracing/local-traces.js +0 -1
- package/dist/src/tracing/otel-declaration.js +0 -1
- package/dist/src/tracing/otel-registration.js +0 -1
- package/dist/src/tracing/sampled-trace.d.ts +0 -4
- package/dist/src/tracing/sampled-trace.js +0 -1
- package/dist/src/tracing/suppress-tracing.d.ts +0 -2
- package/dist/src/tracing/suppress-tracing.js +0 -1
- package/dist/src/tracing/telemetry-budget.d.ts +0 -3
- package/dist/src/tracing/telemetry-budget.js +0 -1
- /package/dist/src/{tracing/agent-span-error.d.ts → compiled/@eve/tracing/adapters/otel-error.d.ts} +0 -0
- /package/dist/src/tracing/{agent-invocation-coordinator.d.ts → eve/agent-invocation-coordinator.d.ts} +0 -0
- /package/dist/src/tracing/{agent-trace-context.d.ts → eve/agent-trace-context.d.ts} +0 -0
- /package/dist/src/tracing/{agent-trace-state.js → eve/agent-trace-state.js} +0 -0
- /package/dist/src/tracing/{channel-audience-context.d.ts → eve/channel-audience-context.d.ts} +0 -0
- /package/dist/src/tracing/{channel-audience-context.js → eve/channel-audience-context.js} +0 -0
- /package/dist/src/tracing/{conversation-context.d.ts → eve/conversation-context.d.ts} +0 -0
- /package/dist/src/tracing/{conversation-context.js → eve/conversation-context.js} +0 -0
- /package/dist/src/tracing/{invoke-tool-span.d.ts → eve/invoke-tool-span.d.ts} +0 -0
- /package/dist/src/tracing/{span-export-policy.d.ts → eve/span-export-policy.d.ts} +0 -0
- /package/dist/src/tracing/{span-export-policy.js → eve/span-export-policy.js} +0 -0
- /package/dist/src/tracing/{vercel-runtime-span-exporter.js → eve/vercel-runtime-span-exporter.js} +0 -0
- /package/dist/src/tracing/{agent-trace-span-processor.d.ts → local/agent-trace-span-processor.d.ts} +0 -0
- /package/dist/src/tracing/{local-trace-discovery-index.d.ts → local/trace-discovery-index.d.ts} +0 -0
- /package/dist/src/tracing/{local-trace-discovery-index.js → local/trace-discovery-index.js} +0 -0
- /package/dist/src/tracing/{local-trace-operations.js → local/trace-operations.js} +0 -0
- /package/dist/src/tracing/{local-trace-query.js → local/trace-query.js} +0 -0
- /package/dist/src/tracing/{local-trace-reader.d.ts → local/trace-reader.d.ts} +0 -0
- /package/dist/src/tracing/{local-trace-retention.d.ts → local/trace-retention.d.ts} +0 -0
- /package/dist/src/tracing/{local-trace-span-processor.d.ts → local/trace-span-processor.d.ts} +0 -0
|
@@ -104,6 +104,12 @@ export interface UseEveAgentOptions<TData> extends EveAgentStoreCallbacks<TData>
|
|
|
104
104
|
readonly optimistic?: boolean;
|
|
105
105
|
/** Follow each subagent call's session into `conversation.agents` while mounted. @default false */
|
|
106
106
|
readonly followSubagents?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Keep the session stream open between turns to show events that arrive from schedules,
|
|
109
|
+
* channels, or other clients. Set to false to close it once the session is idle and reopen it
|
|
110
|
+
* on the next send, answer, or resume. @default true
|
|
111
|
+
*/
|
|
112
|
+
readonly followIdle?: boolean;
|
|
107
113
|
/** Prewarm an owned session on mount and after reset. @default false */
|
|
108
114
|
readonly prewarm?: boolean;
|
|
109
115
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ModelMessage, ToolExecutionOptions } from "ai";
|
|
2
2
|
import type { StandardJSONSchemaV1, StandardSchemaV1 } from "#compiled/@standard-schema/spec/index.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ToolApproval } from "#approval/definition.js";
|
|
4
|
+
import type { SessionAuthContext } from "#channel/types.js";
|
|
4
5
|
import type { SessionContext } from "#context/session-context.js";
|
|
5
6
|
import type { JsonObject } from "#shared/json.js";
|
|
6
7
|
import type { TokenResult } from "#shared/connection-types.js";
|
|
@@ -10,7 +11,12 @@ import type { ToolModelOutput } from "#tools/model-output.js";
|
|
|
10
11
|
type ApprovalContextInput<TInput> = unknown extends TInput ? Record<string, unknown> : TInput;
|
|
11
12
|
export type { ToolAuthDefinition, ToolAuthOptions, ToolAuthProvider } from "#tools/auth.js";
|
|
12
13
|
export type { ToolModelOutput, ToolModelOutputPart } from "#tools/model-output.js";
|
|
13
|
-
export type ToolExecuteOptions = Omit<ToolExecutionOptions<unknown>, "context"
|
|
14
|
+
export type ToolExecuteOptions = Omit<ToolExecutionOptions<unknown>, "context"> & {
|
|
15
|
+
/** Who approved the call, when it runs after a person approved it. */
|
|
16
|
+
readonly approval?: {
|
|
17
|
+
readonly responder: SessionAuthContext;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
14
20
|
export type ToolExecuteFn<TInput = unknown, TOutput = unknown> = (input: TInput, options: ToolExecuteOptions) => Promise<TOutput> | TOutput | AsyncIterable<TOutput>;
|
|
15
21
|
interface ToolDefinitionBase {
|
|
16
22
|
/** Whether delegated agent sessions receive this tool. Defaults to `true`. */
|
|
@@ -176,7 +182,38 @@ export type ToolContext = SessionContext & {
|
|
|
176
182
|
* token returned by {@link getToken}.
|
|
177
183
|
*/
|
|
178
184
|
requireAuth(provider: ToolAuthProvider, options?: ToolAuthOptions): never;
|
|
185
|
+
/**
|
|
186
|
+
* The person who approved this call. Present only when the call runs after a
|
|
187
|
+
* person approved it; absent for calls that needed no approval.
|
|
188
|
+
*/
|
|
189
|
+
readonly approval?: ApprovedCall;
|
|
179
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* The approval behind an approved tool call. The call still runs as the
|
|
193
|
+
* requester, `ctx.session.auth.current`; this only lets it read who approved
|
|
194
|
+
* it and act with their credentials where the tool chooses to.
|
|
195
|
+
*/
|
|
196
|
+
export interface ApprovedCall {
|
|
197
|
+
/** Who approved the call: the same principal its response policy saw. */
|
|
198
|
+
readonly responder: ApprovalResponder;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The person who approved a call, with access to their own credentials. A
|
|
202
|
+
* transient object built for each approved call: its identity fields are the
|
|
203
|
+
* stored responder record, and `getToken` is not serialized with them.
|
|
204
|
+
*/
|
|
205
|
+
export interface ApprovalResponder extends SessionAuthContext {
|
|
206
|
+
/**
|
|
207
|
+
* Resolves the responder's token for an inline provider, as
|
|
208
|
+
* {@link ToolContext.getToken} does for the requester. It never starts a
|
|
209
|
+
* sign-in: when the responder has no token, it throws a non-retryable
|
|
210
|
+
* `ConnectionAuthorizationFailedError` with
|
|
211
|
+
* `reason: "approver_authorization_required"`. It shares the call's
|
|
212
|
+
* providers with `ctx.getToken`, so two inline providers without provider
|
|
213
|
+
* metadata need `options.authKey` across both getters too.
|
|
214
|
+
*/
|
|
215
|
+
getToken(provider: ToolAuthProvider, options?: ToolAuthOptions): Promise<TokenResult>;
|
|
216
|
+
}
|
|
180
217
|
/**
|
|
181
218
|
* Public tool definition authored in `agent/tools/*.ts`.
|
|
182
219
|
*
|
|
@@ -214,7 +251,7 @@ export interface ToolDefinition<TInput = unknown, TOutput = unknown> extends Pub
|
|
|
214
251
|
* - {@link never}: never require approval
|
|
215
252
|
* - {@link once}: require approval only the first time per session
|
|
216
253
|
*/
|
|
217
|
-
approval?:
|
|
254
|
+
approval?: ToolApproval<ApprovalContextInput<TInput>>;
|
|
218
255
|
/**
|
|
219
256
|
* Optional projection controlling what the model sees as the tool result.
|
|
220
257
|
* Receives the full `TOutput` from {@link execute} and returns the
|
|
@@ -289,7 +326,7 @@ export declare function stampToolDefinition<T extends {
|
|
|
289
326
|
readonly outputSchema?: unknown;
|
|
290
327
|
readonly execute?: (...args: never[]) => unknown;
|
|
291
328
|
readonly label?: ToolLabelDefinition;
|
|
292
|
-
readonly approval?:
|
|
329
|
+
readonly approval?: ToolApproval<never>;
|
|
293
330
|
readonly approvalKey?: (...args: never[]) => unknown;
|
|
294
331
|
readonly toModelOutput?: (...args: never[]) => unknown;
|
|
295
332
|
}>(definition: T, definer: "defineTool" | "defineWorkflowTool"): T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToolApproval } from "#approval/definition.js";
|
|
2
2
|
import type { JsonObject, JsonPrimitive } from "#shared/json.js";
|
|
3
|
-
export type DurableDynamicCallbackPhase = "labelComplete" | "labelDelta" | "labelStart" | "approvalKey" | "approvalRequest" | "approvalResponse" | "execute" | "toModelOutput" | "inputSchema" | "outputSchema";
|
|
3
|
+
export type DurableDynamicCallbackPhase = "labelComplete" | "labelDelta" | "labelStart" | "approvalKey" | "approvalPrompt" | "approvalRequest" | "approvalResponse" | "execute" | "toModelOutput" | "inputSchema" | "outputSchema";
|
|
4
4
|
export type DurableDynamicCallbackFn = (closure: JsonObject, ...args: never[]) => unknown;
|
|
5
5
|
/**
|
|
6
6
|
* Persisted binding for one callback phase. Identity is
|
|
@@ -22,6 +22,7 @@ export interface DurableDynamicToolCallbacks {
|
|
|
22
22
|
readonly start?: DurableDynamicCallbackReference;
|
|
23
23
|
};
|
|
24
24
|
readonly approvalKey?: DurableDynamicCallbackReference;
|
|
25
|
+
readonly approvalPrompt?: DurableDynamicCallbackReference;
|
|
25
26
|
readonly approvalRequest?: DurableDynamicCallbackReference;
|
|
26
27
|
readonly approvalResponse?: DurableDynamicCallbackReference;
|
|
27
28
|
readonly toModelOutput?: DurableDynamicCallbackReference;
|
|
@@ -41,6 +42,7 @@ type LiveDurableDynamicToolCallbacks = Partial<{
|
|
|
41
42
|
readonly start?: StampedDurableDynamicCallback;
|
|
42
43
|
};
|
|
43
44
|
approvalKey: StampedDurableDynamicCallback;
|
|
45
|
+
approvalPrompt: StampedDurableDynamicCallback;
|
|
44
46
|
approvalRequest: StampedDurableDynamicCallback;
|
|
45
47
|
approvalResponse: StampedDurableDynamicCallback;
|
|
46
48
|
toModelOutput: StampedDurableDynamicCallback;
|
|
@@ -103,7 +105,7 @@ export declare function collectDurableDynamicToolCallbacks(input: {
|
|
|
103
105
|
readonly delta?: (...args: never[]) => unknown;
|
|
104
106
|
readonly start?: (...args: never[]) => unknown;
|
|
105
107
|
};
|
|
106
|
-
readonly approval?:
|
|
108
|
+
readonly approval?: ToolApproval<never>;
|
|
107
109
|
readonly approvalKey?: (...args: never[]) => unknown;
|
|
108
110
|
readonly execute?: (...args: never[]) => unknown;
|
|
109
111
|
readonly toModelOutput?: (...args: never[]) => unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readDurableSchema}from"#tools/durable-schema.js";import{resolveApprovalPolicy}from"#approval/definition.js";const STAMPED_CALLBACK=Symbol.for(`eve:durable-dynamic-callback`),DURABLE_DYNAMIC_TOOL_CALLBACKS=Symbol.for(`eve:durable-dynamic-tool-callbacks`),REGISTRY=Symbol.for(`eve:scoped-dynamic-tool-callbacks`);function getRegistry(){let e=globalThis;return e[REGISTRY]??=new Map}function getSessionBindings(e){let t=getRegistry(),n=t.get(e);return n!==void 0&&(t.delete(e),t.set(e,n)),n}function callbackKey(e,t){return JSON.stringify([e.scope,e.resolverSlug,e.entryKey,e.name,t])}function registerDurableDynamicCallback(e){let t=getRegistry(),n=getSessionBindings(e.owner.sessionId);n===void 0&&(n=new Map,t.set(e.owner.sessionId,n),t.size>1024&&t.delete(t.keys().next().value)),n.set(callbackKey(e.owner,e.phase),e.callback)}function lookupDurableDynamicCallback(e,t){return getSessionBindings(e.sessionId)?.get(callbackKey(e,t))}function clearDurableDynamicCallbacks(e,t){if(t===void 0){getRegistry().delete(e);return}let n=getSessionBindings(e);if(n===void 0)return;let r=JSON.stringify([t.scope,t.resolverSlug]).slice(0,-1)+`,`;for(let e of n.keys())e.startsWith(r)&&n.delete(e)}function callDurableDynamicCallback(e,t,...n){return e(t,...n)}function hasUnregisteredDurableDynamicCallbacks(e,t){return e.some(e=>durableCallbackPhases(e.callbacks).some(n=>lookupDurableDynamicCallback({...e,...t},n)===void 0))}function durableCallbackPhases(e){return[[`execute`,e.execute],[`inputSchema`,e.inputSchema],[`outputSchema`,e.outputSchema],[`labelComplete`,e.label?.complete],[`labelDelta`,e.label?.delta],[`labelStart`,e.label?.start],[`approvalKey`,e.approvalKey],[`approvalRequest`,e.approvalRequest],[`approvalResponse`,e.approvalResponse],[`toModelOutput`,e.toModelOutput]].flatMap(([e,t])=>t===void 0?[]:[e])}function defineDurableCallback(e){return stampDurableDynamicCallback((...t)=>e.callback(e.closure,...t),{callback:(t,...n)=>Reflect.apply(e.callback,void 0,[t,...n]),closure:e.closure})}function stampDurableDynamicCallback(e,t){return Object.defineProperty(e,STAMPED_CALLBACK,{configurable:!0,value:t}),e}function readDurableDynamicCallback(e){if(typeof e==`function`)return Reflect.get(e,STAMPED_CALLBACK)}function stampDurableDynamicToolCallbacks(e,t){Object.defineProperty(e,DURABLE_DYNAMIC_TOOL_CALLBACKS,{configurable:!0,value:t})}function collectDurableDynamicToolCallbacks(e){let t=readDurableDynamicCallback(e.label?.complete),n=readDurableDynamicCallback(e.label?.delta),r=readDurableDynamicCallback(e.label?.start),i=e.approval===void 0?void 0:readDurableDynamicCallback(resolveApprovalPolicy(e.approval)),a=e.approval===void 0||typeof e.approval==`function`?void 0:readDurableDynamicCallback(e.approval.response),o=readDurableDynamicCallback(e.approvalKey),s=readDurableDynamicCallback(e.
|
|
1
|
+
import{readDurableSchema}from"#tools/durable-schema.js";import{resolveApprovalPolicy}from"#approval/definition.js";const STAMPED_CALLBACK=Symbol.for(`eve:durable-dynamic-callback`),DURABLE_DYNAMIC_TOOL_CALLBACKS=Symbol.for(`eve:durable-dynamic-tool-callbacks`),REGISTRY=Symbol.for(`eve:scoped-dynamic-tool-callbacks`);function getRegistry(){let e=globalThis;return e[REGISTRY]??=new Map}function getSessionBindings(e){let t=getRegistry(),n=t.get(e);return n!==void 0&&(t.delete(e),t.set(e,n)),n}function callbackKey(e,t){return JSON.stringify([e.scope,e.resolverSlug,e.entryKey,e.name,t])}function registerDurableDynamicCallback(e){let t=getRegistry(),n=getSessionBindings(e.owner.sessionId);n===void 0&&(n=new Map,t.set(e.owner.sessionId,n),t.size>1024&&t.delete(t.keys().next().value)),n.set(callbackKey(e.owner,e.phase),e.callback)}function lookupDurableDynamicCallback(e,t){return getSessionBindings(e.sessionId)?.get(callbackKey(e,t))}function clearDurableDynamicCallbacks(e,t){if(t===void 0){getRegistry().delete(e);return}let n=getSessionBindings(e);if(n===void 0)return;let r=JSON.stringify([t.scope,t.resolverSlug]).slice(0,-1)+`,`;for(let e of n.keys())e.startsWith(r)&&n.delete(e)}function callDurableDynamicCallback(e,t,...n){return e(t,...n)}function hasUnregisteredDurableDynamicCallbacks(e,t){return e.some(e=>durableCallbackPhases(e.callbacks).some(n=>lookupDurableDynamicCallback({...e,...t},n)===void 0))}function durableCallbackPhases(e){return[[`execute`,e.execute],[`inputSchema`,e.inputSchema],[`outputSchema`,e.outputSchema],[`labelComplete`,e.label?.complete],[`labelDelta`,e.label?.delta],[`labelStart`,e.label?.start],[`approvalKey`,e.approvalKey],[`approvalPrompt`,e.approvalPrompt],[`approvalRequest`,e.approvalRequest],[`approvalResponse`,e.approvalResponse],[`toModelOutput`,e.toModelOutput]].flatMap(([e,t])=>t===void 0?[]:[e])}function defineDurableCallback(e){return stampDurableDynamicCallback((...t)=>e.callback(e.closure,...t),{callback:(t,...n)=>Reflect.apply(e.callback,void 0,[t,...n]),closure:e.closure})}function stampDurableDynamicCallback(e,t){return Object.defineProperty(e,STAMPED_CALLBACK,{configurable:!0,value:t}),e}function readDurableDynamicCallback(e){if(typeof e==`function`)return Reflect.get(e,STAMPED_CALLBACK)}function stampDurableDynamicToolCallbacks(e,t){Object.defineProperty(e,DURABLE_DYNAMIC_TOOL_CALLBACKS,{configurable:!0,value:t})}function collectDurableDynamicToolCallbacks(e){let t=readDurableDynamicCallback(e.label?.complete),n=readDurableDynamicCallback(e.label?.delta),r=readDurableDynamicCallback(e.label?.start),i=e.approval===void 0?void 0:readDurableDynamicCallback(resolveApprovalPolicy(e.approval)),a=e.approval===void 0||typeof e.approval==`function`?void 0:readDurableDynamicCallback(e.approval.response),o=readDurableDynamicCallback(e.approvalKey),s=readDurableDynamicCallback(e.approval===void 0||typeof e.approval==`function`?void 0:e.approval.prompt),c=readDurableDynamicCallback(e.execute),l=readDurableDynamicCallback(e.toModelOutput),u={},d=readDurableSchema(e.inputSchema),f=readDurableSchema(e.outputSchema);return d!==void 0&&(u.inputSchema=d),f!==void 0&&(u.outputSchema=f),c!==void 0&&(u.execute=c),(t!==void 0||n!==void 0||r!==void 0)&&(u.label={complete:t,delta:n,start:r}),o!==void 0&&(u.approvalKey=o),s!==void 0&&(u.approvalPrompt=s),i!==void 0&&(u.approvalRequest=i),a!==void 0&&(u.approvalResponse=a),l!==void 0&&(u.toModelOutput=l),u}function readDurableDynamicToolCallbacks(e){return e[DURABLE_DYNAMIC_TOOL_CALLBACKS]}export{callDurableDynamicCallback,clearDurableDynamicCallbacks,collectDurableDynamicToolCallbacks,defineDurableCallback,hasUnregisteredDurableDynamicCallbacks,lookupDurableDynamicCallback,readDurableDynamicCallback,readDurableDynamicToolCallbacks,registerDurableDynamicCallback,stampDurableDynamicCallback,stampDurableDynamicToolCallbacks};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToolApproval } from "#approval/definition.js";
|
|
2
2
|
import type { DynamicResolveContext, DynamicToolEventName } from "#dynamic/definition.js";
|
|
3
3
|
import type { PublicToolInputSchema, PublicToolOutputSchema, ToolLabelDefinition, ToolContext } from "#tools/definition.js";
|
|
4
4
|
import type { ToolModelOutput } from "#tools/model-output.js";
|
|
@@ -37,7 +37,7 @@ export interface DynamicToolEntry<TInput = Record<string, unknown>, TOutput = an
|
|
|
37
37
|
* before the call executes. Dynamic approval request and response callbacks
|
|
38
38
|
* use the same durable descriptor boundary as `execute` and `toModelOutput`.
|
|
39
39
|
*/
|
|
40
|
-
readonly approval?:
|
|
40
|
+
readonly approval?: ToolApproval<TInput>;
|
|
41
41
|
/** Derives the input-scoped key recorded when this tool is approved. */
|
|
42
42
|
readonly approvalKey?: (toolInput: Readonly<Record<string, unknown>>) => string;
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function executeAskQuestionTool(e,t){"use workflow";return toAskQuestionOutput(await t.ask(toAskQuestionRequest(e)))}function toAskQuestionRequest(e){let t=e.options?.map(e=>({description:e.description,id:e.label,label:e.label}));return{allowFreeform:!0,display:t===void 0?`text`:`select`,prompt:e.question,...t!==void 0&&{options:t}}}function toAskQuestionOutput(e){switch(e.status){case`answered`:return{answer:e.optionId??e.text??``,status:`answered`};case`cancelled`:return{interrupted:!0};case`unavailable`:return{status:`unavailable`}}}executeAskQuestionTool.workflowId=`workflow//eve@0.
|
|
1
|
+
async function executeAskQuestionTool(e,t){"use workflow";return toAskQuestionOutput(await t.ask(toAskQuestionRequest(e)))}function toAskQuestionRequest(e){let t=e.options?.map(e=>({description:e.description,id:e.label,label:e.label}));return{allowFreeform:!0,display:t===void 0?`text`:`select`,prompt:e.question,...t!==void 0&&{options:t}}}function toAskQuestionOutput(e){switch(e.status){case`answered`:return{answer:e.optionId??e.text??``,status:`answered`};case`cancelled`:return{interrupted:!0};case`unavailable`:return{status:`unavailable`}}}executeAskQuestionTool.workflowId=`workflow//eve@0.79.1//executeAskQuestionTool`;export{executeAskQuestionTool,toAskQuestionOutput,toAskQuestionRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e,t){"use workflow";let n=new Promise(e=>t.abortSignal.addEventListener(`abort`,()=>e(`interrupted`),{once:!0})),r=sleep(Math.ceil(e.seconds*1e3)).then(()=>`elapsed`);return await Promise.race([r,n])===`elapsed`?{waitedSeconds:e.seconds}:{interrupted:!0}}executeSleepTool.workflowId=`workflow//eve@0.
|
|
1
|
+
import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e,t){"use workflow";let n=new Promise(e=>t.abortSignal.addEventListener(`abort`,()=>e(`interrupted`),{once:!0})),r=sleep(Math.ceil(e.seconds*1e3)).then(()=>`elapsed`);return await Promise.race([r,n])===`elapsed`?{waitedSeconds:e.seconds}:{interrupted:!0}}executeSleepTool.workflowId=`workflow//eve@0.79.1//executeSleepTool`;export{executeSleepTool};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StandardJSONSchemaV1, StandardSchemaV1 } from "#compiled/@standard-schema/spec/index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ToolApproval } from "#approval/definition.js";
|
|
3
3
|
import type { MessageResult, SendTurnOptions } from "#client/types.js";
|
|
4
4
|
import type { JsonObject } from "#shared/json.js";
|
|
5
5
|
import { type PublicToolDefinition, type ToolContext, type ToolInputRequest, type ToolInputRequestOptions, type ToolInputResponse } from "#tools/definition.js";
|
|
@@ -128,7 +128,7 @@ export type WorkflowServeContext<TOutput = unknown> = WorkflowSharedContext & {
|
|
|
128
128
|
declare const WORKFLOW_TOOL_BRAND: unique symbol;
|
|
129
129
|
interface WorkflowToolDefinitionBase<TInput, TOutput> extends PublicToolDefinition<TInput, TOutput> {
|
|
130
130
|
readonly [WORKFLOW_TOOL_BRAND]: true;
|
|
131
|
-
approval?:
|
|
131
|
+
approval?: ToolApproval<unknown extends TInput ? Record<string, unknown> : TInput>;
|
|
132
132
|
toModelOutput?: (output: TOutput) => ToolModelOutput | Promise<ToolModelOutput>;
|
|
133
133
|
}
|
|
134
134
|
/** A workflow tool whose calls are ordinary tool calls: the turn waits until each settles. */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InstrumentationProviderDefinition } from "#instrumentation/lifecycle.js";
|
|
2
|
+
import type { AgentActionTraceState } from "#tracing/eve/agent-trace-state.js";
|
|
3
|
+
import type { AgentTracing } from "#compiled/@eve/tracing/index.js";
|
|
4
|
+
/** Approval spans live under their tool call; hook state keeps only the locator. */
|
|
5
|
+
export declare function createAgentApprovalInstrumentation(input: {
|
|
6
|
+
readonly tracing: AgentTracing;
|
|
7
|
+
readonly actionStateFor: (sessionId: string, turnId: string, callId: string) => Promise<AgentActionTraceState | undefined>;
|
|
8
|
+
}): Pick<NonNullable<InstrumentationProviderDefinition["events"]>, "input.requested" | "input.resolved">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resumeTool}from"#tracing/eve/agent-tool-instrumentation.js";function createAgentApprovalInstrumentation(e){async function toolFor(t,n,r){let i=await e.actionStateFor(t,n,r);return i===void 0?void 0:resumeTool(e.tracing,i)}async function onRequested(e,t){e.kind===`tool-approval`&&t.state.get()===void 0&&await(await toolFor(e.scope.sessionId,e.scope.turnId,e.action.callId))?.approval({requestId:e.requestId,request:e.request})!==void 0&&t.state.set({callId:e.action.callId,sessionId:e.scope.sessionId,turnId:e.scope.turnId})}async function onResolved(e,t){let n=t.state.get();if(typeof n!=`object`||!n||Array.isArray(n))return;let{callId:r,sessionId:i,turnId:a}=n;if(typeof r!=`string`||typeof i!=`string`||typeof a!=`string`)return;let o=(await toolFor(i,a,r))?.findApproval(e.requestId);o!==void 0&&(e.outcome===`failed`?await o.fail(e.error):await o.complete({outcome:e.outcome,response:e.response}))}return{"input.requested":onRequested,"input.resolved":onResolved}}export{createAgentApprovalInstrumentation};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InstrumentationProviderDefinition } from "#instrumentation/lifecycle.js";
|
|
2
|
-
import type { AgentTraceStateStore } from "#tracing/agent-trace-state.js";
|
|
2
|
+
import type { AgentTraceStateStore } from "#tracing/eve/agent-trace-state.js";
|
|
3
3
|
/** Captures one-to-one channel delivery metadata on the activation that consumes it. */
|
|
4
4
|
export declare function createAgentChannelDeliveryInstrumentation(input: {
|
|
5
5
|
readonly recordInputs: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contextStorage}from"#context/container.js";import{ActiveChannelDeliveriesKey}from"#context/keys.js";import{isSampledTrace}from"#
|
|
1
|
+
import{contextStorage}from"#context/container.js";import{ActiveChannelDeliveriesKey}from"#context/keys.js";import{isSampledTrace}from"#shared/trace-policy.js";import{contentAttribute}from"#compiled/@eve/tracing/otel.js";function createAgentChannelDeliveryInstrumentation(e){let onStarted=async(t,n)=>{let r=await e.stateStore.get(`session`,t.sessionId),i=(t.turnId===void 0||t.sequence===void 0?void 0:await e.stateStore.get(`turn`,JSON.stringify([t.sessionId,t.turnId])))?.context??r?.context;if(i===void 0||!isSampledTrace(i))return;let a=e.recordInputs?contentAttribute(t.input):void 0,o={};a!==void 0&&(o.inputAttribute=a),t.delivery.requestTraceContext!==void 0&&(o.requestTraceContext={spanId:t.delivery.requestTraceContext.spanId,traceFlags:t.delivery.requestTraceContext.traceFlags,traceId:t.delivery.requestTraceContext.traceId}),n.state.set(o)},onTerminal=async(t,n)=>{let r=readState(n.state.get());if(r===void 0||t.turnId===void 0)return;let i=await e.stateStore.get(`turn`,JSON.stringify([t.sessionId,t.turnId]));i!==void 0&&isSampledTrace(i.context)&&isOnlyActiveDelivery(t.sessionId,t.turnId,t.delivery.deliveryId)&&await e.stateStore.update(`turn`,JSON.stringify([t.sessionId,t.turnId]),e=>({...e,channelDelivery:{channelKind:t.delivery.channelKind,channelName:t.delivery.channelName,deliveryId:t.delivery.deliveryId,...r.inputAttribute===void 0?void 0:{inputAttribute:r.inputAttribute},...t.delivery.requestId===void 0?void 0:{requestId:t.delivery.requestId},...r.requestTraceContext===void 0?void 0:{requestTraceContext:r.requestTraceContext}}}))};return{"channel.delivery.cancelled":onTerminal,"channel.delivery.completed":onTerminal,"channel.delivery.failed":onTerminal,"channel.delivery.started":onStarted}}function isOnlyActiveDelivery(e,t,n){let r=contextStorage.getStore()?.get(ActiveChannelDeliveriesKey),i=r?.[0];return r?.length===1&&i?.sessionId===e&&i.turnId===t&&i.delivery.deliveryId===n}function readState(e){if(!isRecord(e))return;let t=isSpanContext(e.requestTraceContext)?e.requestTraceContext:void 0;return{inputAttribute:typeof e.inputAttribute==`string`?e.inputAttribute:void 0,requestTraceContext:t}}function isSpanContext(e){return isRecord(e)&&typeof e.spanId==`string`&&typeof e.traceFlags==`number`&&typeof e.traceId==`string`}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{createAgentChannelDeliveryInstrumentation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{applyLiveDeliveryAudienceCeiling,readForwardedTraceAssertion}from"#shared/forwarded-trace-policy.js";import{ConversationIdKey}from"#context/keys.js";import{readConversationId}from"#shared/conversation-identity.js";import{readActionTraceContext,readTurnTraceContext}from"#tracing/eve/agent-trace-context-store.js";function resolveToolCallAgentTrace(e){let{serializedContext:t,sessionId:n,turnId:r}=e,i=readActionTraceContext(t,n,r,e.callId)??readTurnTraceContext(t,n,r),a=e.conversation?.audience??`unknown`,o=e.conversation?.environment??`production`,s=readForwardedTraceAssertion(i?.forwardedTracePolicy),c=i?.decision===void 0?i:{...i,decision:applyLiveDeliveryAudienceCeiling(i.decision,a,s,o)};return{conversationId:readConversationId(t[ConversationIdKey.name]),originAudience:s?.originAudience??a,parentTraceContext:c}}export{resolveToolCallAgentTrace};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InstrumentationMemoryExecutionOperation } from "#instrumentation/memory.js";
|
|
2
|
+
import type { ConversationEnvironment } from "#shared/conversation-context.js";
|
|
3
|
+
import type { AgentTraceStateStore } from "#tracing/eve/agent-trace-state.js";
|
|
4
|
+
import { type AgentTracing } from "#compiled/@eve/tracing/index.js";
|
|
5
|
+
export declare function createAgentMemoryInstrumentation(input: {
|
|
6
|
+
tracing: AgentTracing;
|
|
7
|
+
environment: ConversationEnvironment;
|
|
8
|
+
recordOutputs?: boolean;
|
|
9
|
+
stateStore: AgentTraceStateStore;
|
|
10
|
+
}): {
|
|
11
|
+
runInContext<T>(operation: InstrumentationMemoryExecutionOperation, execute: () => PromiseLike<T>): Promise<T>;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalizeChannelAudience}from"#shared/channel-audience.js";import{applyLiveDeliveryAudienceCeiling,resolveForwardedTraceSeed}from"#shared/forwarded-trace-policy.js";import{contextStorage}from"#context/container.js";import{SessionTraceSeedKey}from"#context/keys.js";import{ROOT_CONTEXT,context,trace}from"#compiled/@opentelemetry/api/index.js";import{activeTraceOperation}from"#compiled/@eve/tracing/otel.js";import"#compiled/@eve/tracing/index.js";import{withChannelAudience}from"#tracing/eve/channel-audience-context.js";import{eveTurnIdentity}from"#tracing/eve/operation-input.js";function createAgentMemoryInstrumentation(e){return{async runInContext(t,n){let r=await e.stateStore.get(`session`,t.sessionId),i=t.turnId===void 0?void 0:await e.stateStore.get(`turn`,JSON.stringify([t.sessionId,t.turnId])),a=activeTraceOperation(),o=a?.reference??i?.context??r?.context;if(o===void 0)return await n();let s=a===void 0?withChannelAudience(trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext(o)),r?.channelAudience):context.active(),c=resolveForwardedTraceSeed(contextStorage.getStore()?.get(SessionTraceSeedKey)),l=c?.decision??r?.decision,u=l===void 0?void 0:applyLiveDeliveryAudienceCeiling(l,normalizeChannelAudience(r?.channelAudience),c?.forwardedTracePolicy,e.environment),d={emit:!!(o.traceFlags&1),recordInputs:u?.action===`record`&&u.recordInputs,recordOutputs:e.recordOutputs===!0&&u?.action===`record`&&u.recordOutputs},f={identity:eveTurnIdentity({...t,turnId:t.turnId??``}),parent:o,context:s,capture:d,phase:t.phase,slot:t.slot,storeId:t.storeId,describe(e){let t=e;return{recordCount:t.recordCount,records:t.outputRecords}}},p=e.tracing.memory;return t.operationName===`search_memory`?await p.search(f,n):await p.write(f,n)}}}export{createAgentMemoryInstrumentation};
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import type { AgentSpanIdGenerator } from "#tracing/agent-span-id-generator.js";
|
|
4
|
-
import type { TraceCapturePolicy } from "#tracing/otel-declaration.js";
|
|
1
|
+
import type { AgentTraceStateStore } from "#tracing/eve/agent-trace-state.js";
|
|
2
|
+
import type { TraceCapturePolicy } from "#tracing/eve/otel-declaration.js";
|
|
5
3
|
import type { InstrumentationContextRunner, InstrumentationProviderDefinition, InstrumentationSessionStartedEvent, InstrumentationTraceSeed, InstrumentationTurnStartedEvent } from "#instrumentation/lifecycle.js";
|
|
6
|
-
import { type AgentSamplingOperation } from "#tracing/agent-span-contract.js";
|
|
7
4
|
import type { ConversationEnvironment } from "#shared/conversation-context.js";
|
|
5
|
+
import type { AgentSpanIdGenerator, AgentTelemetry } from "#compiled/@eve/tracing/index.js";
|
|
8
6
|
export interface AgentOtelInstrumentationInput {
|
|
7
|
+
/** Span output for eve's agent spans; its `ids` make turns durable across workers. */
|
|
8
|
+
readonly telemetry: AgentTelemetry;
|
|
9
|
+
readonly idGenerator: AgentSpanIdGenerator;
|
|
9
10
|
readonly environment?: ConversationEnvironment;
|
|
10
11
|
/** Whether any destination records model and tool inputs. */
|
|
11
12
|
readonly recordInputs?: boolean;
|
|
12
13
|
/** Whether any destination records model and tool outputs. */
|
|
13
14
|
readonly recordOutputs?: boolean;
|
|
14
15
|
readonly frameworkVersion: string;
|
|
15
|
-
readonly idGenerator: AgentSpanIdGenerator;
|
|
16
|
-
readonly samplesTrace?: (traceId: string, operation?: AgentSamplingOperation) => boolean;
|
|
17
16
|
readonly stateStore: AgentTraceStateStore;
|
|
18
|
-
readonly tracer: Tracer;
|
|
19
17
|
readonly tracePolicy?: TraceCapturePolicy;
|
|
20
18
|
}
|
|
21
19
|
/** OTel event definition and its trusted framework context runner. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject}from"#shared/guards.js";import{isUserMessageKind}from"#harness/messages.js";import{resolveInstrumentationEnvironment}from"#internal/application/dev-environment.js";import{isSampledTrace}from"#shared/trace-policy.js";import{ROOT_CONTEXT,context,trace}from"#compiled/@opentelemetry/api/index.js";import{gatewayCostAttributes,readGatewayCostData}from"#tracing/eve/gateway.js";import{createAgentToolInstrumentation}from"#tracing/eve/agent-tool-instrumentation.js";import{withChannelAudience}from"#tracing/eve/channel-audience-context.js";import{createEveTracing}from"#tracing/eve/operation-input.js";import{createAgentApprovalInstrumentation}from"#tracing/eve/agent-approval-instrumentation.js";import{createAgentChannelDeliveryInstrumentation}from"#tracing/eve/agent-channel-delivery-instrumentation.js";import{eveActivationMetadata}from"#tracing/eve/metadata.js";import{createAgentMemoryInstrumentation}from"#tracing/eve/agent-memory-instrumentation.js";import{createEveSessionTracing}from"#tracing/eve/session.js";import{createEveCapturePolicy}from"#tracing/eve/policy.js";function createAgentOtelInstrumentation(e){let t=e.environment??resolveInstrumentationEnvironment(),n=e.recordInputs??!1,r=e.recordOutputs??!1,i=createEveTracing(e),a=new Map,o=new Map,s=createEveSessionTracing({...e,environment:t,tracing:i}),{prepareSessionTrace:c,prepareTurnTrace:l}=s;async function attemptFor(e){let t=a.get(e.attemptId);if(t!==void 0)return t;let n=await s.turnFor(e.sessionId,e.turnId,withChannelAudience(ROOT_CONTEXT,e.channelAudience)),r={stepIndex:e.stepIndex,attempt:e.attemptIndex};return n?.findAttempt(r)??(n?.finished===!1?n.attempt(r):void 0)}let u=createAgentToolInstrumentation({tracing:i,attemptFor,stepFor:e=>a.get(e.attemptId),recordInputs:n,recordOutputs:r,stateStore:e.stateStore}),d=createAgentApprovalInstrumentation({tracing:i,actionStateFor:u.stateFor}),f=createAgentMemoryInstrumentation({...e,environment:t,tracing:i}),p=createEveCapturePolicy({stateStore:e.stateStore,environment:t,recordInputs:n,recordOutputs:r});function turnState(t){return e.stateStore.get(`turn`,JSON.stringify([t.sessionId,t.turnId]))}let onSessionStarted=async e=>{await c(e)},onTurnStarted=async e=>{await l(e)},onStepStarted=async t=>{let n=await turnState(t.scope);if(n===void 0||!isSampledTrace(n.context))return;let r=await e.stateStore.get(`session`,t.scope.sessionId),i=await s.turnFor(t.scope.sessionId,t.scope.turnId,withChannelAudience(ROOT_CONTEXT,t.scope.channelAudience));if(i===void 0||i.finished)return;let o=trace.getSpan(context.active())?.spanContext(),c=await i.attempt({stepIndex:t.scope.stepIndex,attempt:t.scope.attemptIndex,runtimeContext:t.runtimeContext,channel:eveActivationMetadata({session:r,turn:n,sessionId:t.scope.sessionId}).channel,links:o===void 0||o.traceId===n.context.traceId?void 0:[{relationship:`execution.delivery`,context:o}]});a.set(t.scope.attemptId,c)},onStepTerminal=async e=>{let t=e.type===`step.attempt.failed`?{error:e.error}:void 0;await drainOpenSpans(e),await u.drain(e.scope.attemptId,t);let n=a.get(e.scope.attemptId)??await attemptFor(e.scope);a.delete(e.scope.attemptId),t===void 0?await n?.complete():(await n?.fail(t.error),await u.forgetAttempt(e.scope))},onSessionTransition=async t=>{await s.sessionTransition(t),(t.type===`session.completed`||t.type===`session.failed`)&&(await u.deleteForSession(t.sessionId),await e.stateStore.delete(`session`,t.sessionId))},onModelCallStarted=async e=>{let t=a.get(e.scope.attemptId);if(t===void 0)return;let r=await t.modelCall({provider:e.model.provider,modelId:e.model.modelId,messages:n?e.input?.messages.map(e=>isObject(e)&&e.role===`user`?{...e,kind:isUserMessageKind(e.kind)?e.kind:void 0}:e):void 0,instructions:n?e.input?.instructions:void 0,tools:n?e.input?.tools:void 0,runtimeContext:e.runtimeContext},e.idempotencyKey),i=o.get(e.scope.attemptId);i===void 0&&o.set(e.scope.attemptId,i=new Map),i.set(e.idempotencyKey,r)},onModelCallTerminal=async e=>{let t=o.get(e.scope.attemptId),n=t?.get(e.idempotencyKey);t?.delete(e.idempotencyKey),n!==void 0&&(e.type===`model.call.failed`?await n.fail(e.error):await n.complete({outcome:`completed`,result:{...e,content:r?e.content:void 0}}))},m=createAgentChannelDeliveryInstrumentation({recordInputs:n,stateStore:e.stateStore}),onStepMetadata=e=>{let t=a.get(e.scope.attemptId);if(t===void 0)return;let n=readGatewayCostData(e.providerMetadata);n!==void 0&&t.attributes(gatewayCostAttributes(n))};return{hook:{events:{...m,...d,"step.attempt.completed":onStepTerminal,"step.attempt.failed":onStepTerminal,"step.attempt.metadata":onStepMetadata,"step.attempt.started":onStepStarted,"model.call.completed":onModelCallTerminal,"model.call.failed":onModelCallTerminal,"model.call.started":onModelCallStarted,"session.completed":onSessionTransition,"session.failed":onSessionTransition,"session.started":onSessionStarted,"session.waiting":onSessionTransition,...u.events,"turn.cancelled":s.turnTerminal,"turn.completed":s.turnTerminal,"turn.failed":s.turnTerminal,"turn.started":onTurnStarted},name:`eve.otel`,projectEvent:p.projectEvent,tracePolicy:()=>({emit:!0,recordInputs:n,recordOutputs:r})},prepareSessionTrace:c,prepareTurnTrace:l,async runInContext(t,n){if(t.type===`memory.operation`)return f.runInContext(t,n);let r={emit:!0,...await p.forOperation(t.scope)},inTurn=async()=>{let i=await s.turnFor(t.scope.sessionId,t.scope.turnId,withChannelAudience(ROOT_CONTEXT,t.scope.channelAudience));if(i!==void 0&&!i.finished)return i.run(n,r);let{sessionId:a,turnId:o}=t.scope;return e.telemetry.suppressed!==void 0&&await s.dropped(a,o)?e.telemetry.suppressed(n):n()};if(t.type===`tool.call`)return u.runInContext(t,n,r,inTurn);let i=o.get(t.scope.attemptId)?.get(t.idempotencyKey);return i!==void 0&&!i.finished?i.run(n,r):inTurn()}};async function drainOpenSpans(e){for(let t of o.get(e.scope.attemptId)?.values()??[])e.type===`step.attempt.failed`?await t.fail(e.error):await t.complete({outcome:`completed`,result:{finishReason:`unknown`,usage:{}}});o.delete(e.scope.attemptId)}}export{createAgentOtelInstrumentation};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Context, type SpanContext } from "#compiled/@opentelemetry/api/index.js";
|
|
2
|
+
import type { InstrumentationAttemptScope, InstrumentationExecutionOperation, InstrumentationToolCallStartedEvent, InstrumentationToolCallTerminalEvent } from "#instrumentation/lifecycle.js";
|
|
3
|
+
import type { AgentActionTraceState, AgentTraceStateStore } from "#tracing/eve/agent-trace-state.js";
|
|
4
|
+
import type { AgentTracing, AttemptOperation, CaptureDecision, ToolOperation } from "#compiled/@eve/tracing/index.js";
|
|
5
|
+
export interface AgentToolContext {
|
|
6
|
+
readonly context: Context;
|
|
7
|
+
readonly spanContext: SpanContext;
|
|
8
|
+
}
|
|
9
|
+
type ToolExecution = Extract<InstrumentationExecutionOperation, {
|
|
10
|
+
type: "tool.call";
|
|
11
|
+
}>;
|
|
12
|
+
/** Finds an open tool call in its turn's trace tree, in this or a later process. */
|
|
13
|
+
export declare function resumeTool(tracing: AgentTracing, state: AgentActionTraceState): Promise<ToolOperation | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* One `execute_tool` span per call. eve's tool loop reports the durable
|
|
16
|
+
* dispatch through `tool.call.*` events; the SDK reports the run through the
|
|
17
|
+
* execution context. Both name the same call ID, so they share one span. A run
|
|
18
|
+
* without a dispatch closes under its step when the step ends.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createAgentToolInstrumentation(input: {
|
|
21
|
+
readonly tracing: AgentTracing;
|
|
22
|
+
readonly attemptFor: (scope: InstrumentationAttemptScope) => Promise<AttemptOperation | undefined>;
|
|
23
|
+
readonly stepFor: (scope: InstrumentationAttemptScope) => AttemptOperation | undefined;
|
|
24
|
+
readonly recordInputs: boolean;
|
|
25
|
+
readonly recordOutputs: boolean;
|
|
26
|
+
readonly stateStore: AgentTraceStateStore;
|
|
27
|
+
}): {
|
|
28
|
+
stateFor: (sessionId: string, turnId: string, callId: string) => Promise<AgentActionTraceState | undefined>;
|
|
29
|
+
contextFor(sessionId: string, turnId: string, callId: string): Promise<AgentToolContext | undefined>;
|
|
30
|
+
deleteForSession(sessionId: string): Promise<void>;
|
|
31
|
+
forgetAttempt(scope: InstrumentationAttemptScope): Promise<void>;
|
|
32
|
+
/** Closes SDK runs that no dispatch claimed before their step ended. */
|
|
33
|
+
drain(attemptId: string, failure?: {
|
|
34
|
+
readonly error: unknown;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
/** Runs the SDK's tool call inside its span, or calls `fallback` when it has none. */
|
|
37
|
+
runInContext<T>(operation: ToolExecution, execute: () => PromiseLike<T>, ceiling: CaptureDecision, fallback: () => Promise<T>): Promise<T>;
|
|
38
|
+
events: {
|
|
39
|
+
"tool.call.completed": (event: InstrumentationToolCallTerminalEvent) => Promise<void>;
|
|
40
|
+
"tool.call.failed": (event: InstrumentationToolCallTerminalEvent) => Promise<void>;
|
|
41
|
+
"tool.call.started": (event: InstrumentationToolCallStartedEvent) => Promise<void>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalizeChannelAudience}from"#shared/channel-audience.js";import{ROOT_CONTEXT,trace}from"#compiled/@opentelemetry/api/index.js";import{actionIdempotencyKey}from"#instrumentation/lifecycle.js";import{withChannelAudience}from"#tracing/eve/channel-audience-context.js";import{eveTurnIdentity}from"#tracing/eve/operation-input.js";async function resumeTool(e,t){return(await e.resume({identity:eveTurnIdentity(t),context:withChannelAudience(ROOT_CONTEXT,t.channelAudience)}))?.findTool(t.callId)}function createAgentToolInstrumentation(e){let t=new Map,callKey=(e,t)=>actionIdempotencyKey(e.sessionId,e.turnId,t);async function stateFor(t,n,r){let i=await e.stateStore.get(`action`,actionIdempotencyKey(t,n,r));return i===void 0?(await e.stateStore.entries(`action`)).find(([,e])=>e.sessionId===t&&e.callId===r)?.[1]:i}async function reenter(t,n){let r=await e.tracing.resume({identity:eveTurnIdentity(t),context:withChannelAudience(ROOT_CONTEXT,t.channelAudience)});if(r?.findTool(t.callId)===void 0)return;let i=r.findAttempt({stepIndex:t.stepIndex,attempt:t.attemptIndex});return i===void 0?r.findTool(t.callId):i.tool(n)}async function settleExecution(n,r){let i=n.terminal;i!==void 0&&(t.delete(n.idempotencyKey),i.failed?n.tool.recordError(i.error):i.durationMs!==void 0&&n.tool.attributes({"gen_ai.execute_tool.duration":i.durationMs/1e3}),await e.stateStore.set(`action`,n.idempotencyKey,{...r,toolEndTimeMs:i.completedAtMs}))}async function onDispatchStarted(n){let r=await e.stateStore.get(`action`,n.idempotencyKey);if(r===void 0){let i=await e.attemptFor(n.scope);if(i===void 0)return;let a=await i.tool({callId:n.callId,name:n.toolName,kind:n.kind??`tool-call`,arguments:e.recordInputs?n.input:void 0,startTimeMs:n.startedAtMs});a.attributes({"agent.tool.is_framework":n.frameworkTool===!0}),r={attemptId:n.scope.attemptId,attemptIndex:n.scope.attemptIndex,callId:n.callId,channelAudience:normalizeChannelAudience(n.scope.channelAudience),context:{...a.reference,isRemote:!1},rootSessionId:n.scope.rootSessionId,sessionId:n.scope.sessionId,stepIndex:n.scope.stepIndex,turnId:n.scope.turnId},await e.stateStore.set(`action`,n.idempotencyKey,r);let o=t.get(n.idempotencyKey);o!==void 0&&await settleExecution(o,r)}n.isWorkflowTool===!0&&await e.stateStore.set(`anchor`,n.idempotencyKey,r)}async function onDispatchTerminal(t){let n=await e.stateStore.get(`action`,t.idempotencyKey);if(n!==void 0)try{let r=await resumeTool(e.tracing,n),i=t.type===`tool.call.failed`?t.error:t.output.type===`error`?t.output.error:void 0;await r?.complete({outcome:t.outcome??(t.type===`tool.call.failed`?`failed`:`completed`),failed:t.type===`tool.call.failed`||t.output.type===`error`,errorType:t.type===`tool.call.failed`?t.errorCode:void 0,error:i,output:e.recordOutputs&&t.type===`tool.call.completed`&&t.output.type===`result`?t.output.output:void 0,usage:t.usage,endTimeMs:t.acceptedAtMs??n.toolEndTimeMs})}finally{await e.stateStore.delete(`action`,t.idempotencyKey)}}async function executionFor(n,r){let i=callKey(n.scope,n.callId),a=t.get(i);if(a!==void 0)return a;let o=await stateFor(n.scope.sessionId,n.scope.turnId,n.callId),s={callId:n.callId,name:n.toolName,arguments:e.recordInputs&&r.recordInputs?n.input:void 0,startTimeMs:n.startedAtMs},c=o===void 0?await e.stepFor(n.scope)?.tool(s):await reenter(o,s);if(c===void 0||t.size>=1e4)return;let l={attemptId:n.scope.attemptId,idempotencyKey:i,tool:c};return t.set(i,l),l}async function finishExecution(t,n){t.terminal=n;let r=t.idempotencyKey,i=await e.stateStore.get(`action`,r);i!==void 0&&await settleExecution(t,i)}return{stateFor,async contextFor(e,t,n){let r=await stateFor(e,t,n);return r===void 0?void 0:toolContext(r)},async deleteForSession(t){for(let n of[`action`,`anchor`])for(let[r,i]of await e.stateStore.entries(n))i.sessionId===t&&await e.stateStore.delete(n,r)},async forgetAttempt(t){for(let[n,r]of await e.stateStore.entries(`action`))r.attemptId===t.attemptId&&await e.stateStore.delete(`action`,n)},async drain(n,r){for(let[i,a]of t){if(a.attemptId!==n||(t.delete(i),await e.stateStore.get(`action`,i)!==void 0))continue;let o=a.terminal;if(r!==void 0){await a.tool.fail(r.error);continue}o?.durationMs!==void 0&&!o.failed&&a.tool.attributes({"gen_ai.execute_tool.duration":o.durationMs/1e3}),await a.tool.complete({failed:o?.failed,error:o?.error,output:o?.output,endTimeMs:o?.completedAtMs})}},async runInContext(t,n,r,i){if(t.callId===void 0||t.toolName===void 0)return i();let a=await executionFor({...t,callId:t.callId,toolName:t.toolName},r);if(a===void 0||a.tool.finished)return i();a.tool.attributes({"agent.tool.is_framework":t.frameworkTool===!0});let o=t.startedAtMs??Date.now();try{let i=await a.tool.run(n,r),s=t.completedAtMs??Date.now();return await finishExecution(a,{completedAtMs:s,durationMs:s-o,failed:t.failed===!0,output:e.recordOutputs&&r.recordOutputs?i:void 0}),i}catch(e){throw await finishExecution(a,{completedAtMs:Date.now(),failed:!0,error:r.recordOutputs?e:void 0}),e}},events:{"tool.call.completed":onDispatchTerminal,"tool.call.failed":onDispatchTerminal,"tool.call.started":onDispatchStarted}}}function toolContext(e){return{context:withChannelAudience(trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext(e.context)),e.channelAudience),spanContext:e.context}}export{createAgentToolInstrumentation,resumeTool};
|
package/dist/src/tracing/{agent-trace-context-store.d.ts → eve/agent-trace-context-store.d.ts}
RENAMED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { SessionTraceContext } from "#channel/types.js";
|
|
2
2
|
import type { ContextAccessor } from "#context/key.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { AgentTraceStateStore, AgentTraceValues } from "#tracing/eve/agent-trace-state.js";
|
|
4
4
|
import type { SessionStateMap } from "#harness/types.js";
|
|
5
5
|
import type { InstrumentationDecision } from "#shared/instrumentation-decision.js";
|
|
6
|
+
export declare const AGENT_TRACE_CONTEXT_KEY = "eve.harness.agentTrace";
|
|
7
|
+
export declare function currentTraceSessionId(runId: string): string | undefined;
|
|
6
8
|
/** Run after task-provider commits, so a pending workflow tool call keeps its anchor. */
|
|
7
9
|
export declare function pruneAgentTraceState(context: ContextAccessor, sessionId: string, sessionState: SessionStateMap | undefined): void;
|
|
8
10
|
export declare function readSessionTraceDecision(context: ContextAccessor, sessionId: string): InstrumentationDecision | undefined;
|
|
@@ -14,19 +16,9 @@ export declare function readTurnTraceContext(serializedContext: Readonly<Record<
|
|
|
14
16
|
export declare function readActionTraceContext(serializedContext: Readonly<Record<string, unknown>>, sessionId: string, turnId: string, callId: string): SessionTraceContext | undefined;
|
|
15
17
|
/** Durable trace state backed by eve's serialized Workflow context. */
|
|
16
18
|
export declare class ContextAgentTraceStateStore implements AgentTraceStateStore {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
findAction(sessionId: string, callId: string): AgentActionTraceState | undefined;
|
|
23
|
-
findActionAnchor(sessionId: string, turnId: string, callId: string): AgentActionTraceState | undefined;
|
|
24
|
-
getAction(idempotencyKey: string): AgentActionTraceState | undefined;
|
|
25
|
-
getSession(sessionId: string): AgentSessionTraceState | undefined;
|
|
26
|
-
getTurn(sessionId: string, turnId: string): AgentTurnTraceState | undefined;
|
|
27
|
-
setAction(idempotencyKey: string, value: AgentActionTraceState): void;
|
|
28
|
-
setActionAnchor(idempotencyKey: string, value: AgentActionTraceState): void;
|
|
29
|
-
setSession(sessionId: string, value: AgentSessionTraceState): void;
|
|
30
|
-
setTurn(sessionId: string, turnId: string, value: AgentTurnTraceState): void;
|
|
31
|
-
updateTurn(sessionId: string, turnId: string, update: (state: AgentTurnTraceState) => AgentTurnTraceState): void;
|
|
19
|
+
get<K extends keyof AgentTraceValues>(kind: K, key: string): AgentTraceValues[K] | undefined;
|
|
20
|
+
set<K extends keyof AgentTraceValues>(kind: K, key: string, value: AgentTraceValues[K]): void;
|
|
21
|
+
delete(kind: keyof AgentTraceValues, key: string): void;
|
|
22
|
+
update<K extends keyof AgentTraceValues>(kind: K, key: string, update: (value: AgentTraceValues[K]) => AgentTraceValues[K]): void;
|
|
23
|
+
entries<K extends keyof AgentTraceValues>(kind: K): [string, AgentTraceValues[K]][];
|
|
32
24
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{decisionToTraceContentCeiling,resolveForwardedTraceSeed}from"#shared/forwarded-trace-policy.js";import{contextStorage,loadContext}from"#context/container.js";import{SessionTraceSeedKey}from"#context/keys.js";import{parseJsonObject}from"#shared/json.js";import{ContextKey}from"#context/key.js";import{getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{actionIdempotencyKey}from"#instrumentation/lifecycle.js";const AGENT_TRACE_CONTEXT_KEY=`eve.harness.agentTrace`,traceStateKey=(e,t)=>JSON.stringify([e,t]);function traceStateValue(e,t,n){return e?.entries[traceStateKey(t,n)]?.value}const emptyAgentTraceContextState=()=>({entries:{}});function deserializeAgentTraceContextState(e){try{let t=parseJsonObject(e);if(typeof t.entries!=`object`||t.entries===null||Array.isArray(t.entries))return emptyAgentTraceContextState();let n={};for(let[e,r]of Object.entries(t.entries)){if(typeof r!=`object`||!r||Array.isArray(r))continue;let t=r;(t.kind===`session`||t.kind===`turn`||t.kind===`checkpoint`||t.kind===`action`)&&(t.value===null||typeof t.value!=`object`||Array.isArray(t.value)||(n[e]=r))}return{entries:n}}catch{return emptyAgentTraceContextState()}}const AgentTraceContextKey=new ContextKey(AGENT_TRACE_CONTEXT_KEY,{codec:{deserialize:deserializeAgentTraceContextState,serialize:e=>e}});function currentTraceSessionId(e){return traceStateValue(contextStorage.getStore()?.get(AgentTraceContextKey),`session`,e)?.traceSessionId}function pruneAgentTraceState(e,t,n){try{pruneTraceOwnership(e,t,n)}catch(e){createLogger(`tracing.retention`).warn(`could not reconcile trace ownership; preserving trace state`,{error:e})}}function pruneTraceOwnership(e,t,n){let r=e.get(AgentTraceContextKey);if(r===void 0)return;let i=new Set(getBlockingWorkflowToolRuns(n).map(e=>e.callId)),a=Object.fromEntries(Object.entries(r.entries).filter(([,e])=>e.kind!==`action`||e.value.sessionId!==t||e.active||i.has(e.value.callId)));e.set(AgentTraceContextKey,{...r,entries:a})}function readSessionTraceDecision(e,t){return traceStateValue(e.get(AgentTraceContextKey),`session`,t)?.decision}function preserveSerializedAgentTraceState(e,t){let n=t[AgentTraceContextKey.name];return n===void 0?e:{...e,[AgentTraceContextKey.name]:n}}function readTurnTraceContext(e,t,n){let r=e[AgentTraceContextKey.name];if(r===void 0)return;let i=deserializeAgentTraceContextState(r),a=traceStateValue(i,`turn`,JSON.stringify([t,n]));return a===void 0?void 0:withTraceDecision(e,a.context,traceStateValue(i,`session`,t)?.decision)}function readActionTraceContext(e,t,n,r){let i=e[AgentTraceContextKey.name];if(i===void 0)return;let a=deserializeAgentTraceContextState(i),o=traceStateValue(a,`action`,actionIdempotencyKey(t,n,r));if(o!==void 0)return withTraceDecision(e,{...o.context,isRemote:!1},traceStateValue(a,`session`,o.sessionId)?.decision)}function withTraceDecision(e,t,n){let r=e[SessionTraceSeedKey.name],i=resolveForwardedTraceSeed({decision:n??r?.decision,forwardedTracePolicy:r?.forwardedTracePolicy,traceFlags:t.traceFlags}),a=i.decision,o=i.forwardedTracePolicy,s=decisionToTraceContentCeiling(a),c={...t,traceFlags:i.traceFlags};if(o===void 0)return a===void 0?c:{...c,decision:a};let l=s===void 0?o:{...o,ceiling:s};return a===void 0?{...c,forwardedTracePolicy:l}:{...c,decision:a,forwardedTracePolicy:l}}var ContextAgentTraceStateStore=class{get(e,t){let n=contextStorage.getStore()?.get(AgentTraceContextKey)?.entries[traceStateKey(e===`anchor`?`action`:e,t)];if(!(n===void 0||n.kind===`action`&&!(e===`anchor`?n.retained:n.active)))return n.value}set(e,t,n){updateState(r=>{let i=traceStateKey(e===`anchor`?`action`:e,t),a=r.entries[i],o=e===`action`||e===`anchor`?{kind:`action`,value:n,active:e===`action`||a?.kind===`action`&&a.active,retained:e===`anchor`||a?.kind===`action`&&a.retained}:{kind:e,value:n};return{...r,entries:{...r.entries,[i]:o}}})}delete(e,t){updateState(n=>{let r=traceStateKey(e===`anchor`?`action`:e,t),i=n.entries[r],a={...n.entries};return i?.kind===`action`&&e===`action`&&i.retained?a[r]={...i,active:!1}:i?.kind===`action`&&e===`anchor`&&i.active?a[r]={...i,retained:!1}:delete a[r],{...n,entries:a}})}update(e,t,n){let r=this.get(e,t);r!==void 0&&this.set(e,t,n(r))}entries(e){return Object.entries(contextStorage.getStore()?.get(AgentTraceContextKey)?.entries??{}).flatMap(([t,n])=>n.kind===(e===`anchor`?`action`:e)&&(n.kind!==`action`||(e===`anchor`?n.retained:n.active))?[[JSON.parse(t)[1],n.value]]:[])}};function updateState(e){loadContext().set(AgentTraceContextKey,t=>e(t??emptyAgentTraceContextState()))}export{AGENT_TRACE_CONTEXT_KEY,ContextAgentTraceStateStore,currentTraceSessionId,preserveSerializedAgentTraceState,pruneAgentTraceState,readActionTraceContext,readSessionTraceDecision,readTurnTraceContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContextKey}from"#compiled/@opentelemetry/api/index.js";import{activeTraceOperation}from"#compiled/@eve/tracing/otel.js";const AGENT_TRACE_KEY=createContextKey(`eve.agent.trace`);function isAgentTraceContext(e){if(typeof e!=`object`||!e)return!1;if(activeTraceOperation(e)!==void 0)return!0;let t=Reflect.get(e,`getValue`);return typeof t==`function`&&Reflect.apply(t,e,[AGENT_TRACE_KEY])===!0}function markAgentTraceContext(e){return e.setValue(AGENT_TRACE_KEY,!0)}export{isAgentTraceContext,markAgentTraceContext};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { SpanContext } from "#compiled/@opentelemetry/api/index.js";
|
|
2
|
+
import type { InstrumentationParentLineage, InstrumentationPrincipalSummary } from "#instrumentation/lifecycle.js";
|
|
3
|
+
import type { ChannelAudience } from "#shared/channel-audience.js";
|
|
4
|
+
import type { InstrumentationDecision } from "#shared/instrumentation-decision.js";
|
|
5
|
+
import type { TraceSnapshot } from "#compiled/@eve/tracing/index.js";
|
|
6
|
+
export interface AgentSessionTraceState {
|
|
7
|
+
readonly traceSessionId: string;
|
|
8
|
+
readonly channelAudience?: ChannelAudience;
|
|
9
|
+
readonly agentName?: string;
|
|
10
|
+
readonly channelKind?: string;
|
|
11
|
+
readonly channelType?: string;
|
|
12
|
+
readonly context: SpanContext;
|
|
13
|
+
readonly decision?: InstrumentationDecision;
|
|
14
|
+
readonly parentLineage?: InstrumentationParentLineage;
|
|
15
|
+
readonly rootSessionId: string;
|
|
16
|
+
readonly scheduleId?: string;
|
|
17
|
+
readonly title?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface AgentTurnTraceState {
|
|
20
|
+
readonly agentName?: string;
|
|
21
|
+
/** Recorded at the turn's terminal event; the span ends at the session transition. */
|
|
22
|
+
readonly terminal?: {
|
|
23
|
+
readonly outcome: "cancelled" | "completed" | "failed";
|
|
24
|
+
readonly errorName?: string;
|
|
25
|
+
readonly errorMessage?: string;
|
|
26
|
+
};
|
|
27
|
+
readonly traceSessionId: string;
|
|
28
|
+
readonly caller?: SpanContext;
|
|
29
|
+
readonly channelDelivery?: AgentTurnChannelDeliveryTraceState;
|
|
30
|
+
readonly context: SpanContext;
|
|
31
|
+
readonly currentPrincipal?: InstrumentationPrincipalSummary;
|
|
32
|
+
readonly initiatorPrincipal?: InstrumentationPrincipalSummary;
|
|
33
|
+
readonly parentLineage?: InstrumentationParentLineage;
|
|
34
|
+
readonly rootSessionId: string;
|
|
35
|
+
readonly sequence: number;
|
|
36
|
+
readonly startTimeMs: number;
|
|
37
|
+
readonly subagentName?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface AgentTurnChannelDeliveryTraceState {
|
|
40
|
+
readonly channelKind: string;
|
|
41
|
+
readonly channelName: string;
|
|
42
|
+
readonly deliveryId: string;
|
|
43
|
+
readonly inputAttribute?: string;
|
|
44
|
+
readonly requestId?: string;
|
|
45
|
+
readonly requestTraceContext?: SpanContext;
|
|
46
|
+
}
|
|
47
|
+
/** Locates a dispatched tool call in its turn's trace tree, after the turn's own state is gone. */
|
|
48
|
+
export interface AgentActionTraceState {
|
|
49
|
+
readonly attemptId?: string;
|
|
50
|
+
readonly attemptIndex: number;
|
|
51
|
+
readonly callId: string;
|
|
52
|
+
readonly channelAudience?: ChannelAudience;
|
|
53
|
+
readonly context: SpanContext;
|
|
54
|
+
readonly rootSessionId?: string;
|
|
55
|
+
readonly sessionId: string;
|
|
56
|
+
readonly stepIndex: number;
|
|
57
|
+
/** When the SDK execution finished, for dispatches that report no acceptance time. */
|
|
58
|
+
readonly toolEndTimeMs?: number;
|
|
59
|
+
readonly turnId: string;
|
|
60
|
+
}
|
|
61
|
+
/** Provider-owned serializable storage for durable agent trace state. */
|
|
62
|
+
export interface AgentTraceStateStore {
|
|
63
|
+
get<K extends keyof AgentTraceValues>(kind: K, key: string): AgentTraceValues[K] | undefined | PromiseLike<AgentTraceValues[K] | undefined>;
|
|
64
|
+
set<K extends keyof AgentTraceValues>(kind: K, key: string, value: AgentTraceValues[K]): void | PromiseLike<void>;
|
|
65
|
+
delete(kind: keyof AgentTraceValues, key: string): void | PromiseLike<void>;
|
|
66
|
+
update<K extends keyof AgentTraceValues>(kind: K, key: string, update: (value: AgentTraceValues[K]) => AgentTraceValues[K]): void | PromiseLike<void>;
|
|
67
|
+
entries<K extends keyof AgentTraceValues>(kind: K): readonly [string, AgentTraceValues[K]][] | PromiseLike<readonly [string, AgentTraceValues[K]][]>;
|
|
68
|
+
}
|
|
69
|
+
export interface AgentTraceValues {
|
|
70
|
+
session: AgentSessionTraceState;
|
|
71
|
+
turn: AgentTurnTraceState;
|
|
72
|
+
action: AgentActionTraceState;
|
|
73
|
+
anchor: AgentActionTraceState;
|
|
74
|
+
checkpoint: TraceSnapshot;
|
|
75
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { SpanExporter, SpanProcessor } from "
|
|
1
|
+
import type { SpanExporter, SpanProcessor } from "./otel-configuration.js";
|
|
2
2
|
/** @internal — exposed for tests; authors get the defaults. */
|
|
3
3
|
interface BatchSpanProcessorOptions {
|
|
4
|
+
readonly diagnostic?: (message: string, details: {
|
|
5
|
+
error?: unknown;
|
|
6
|
+
timeoutMillis?: number;
|
|
7
|
+
}) => void;
|
|
4
8
|
readonly exportTimeoutMillis?: number;
|
|
5
9
|
readonly maxExportBatchSize?: number;
|
|
6
10
|
readonly maxQueueSize?: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{TraceFlags,context,createContextKey}from"#compiled/@opentelemetry/api/index.js";const SUPPRESS_TRACING_KEY=createContextKey(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`),DEFAULTS={exportTimeoutMillis:3e4,maxExportBatchSize:512,maxQueueSize:2048,scheduledDelayMillis:5e3};function batchSpanProcessor(e,t={}){let report=(e,n)=>{try{t.diagnostic?.(e,n)}catch{}},n=t.exportTimeoutMillis??DEFAULTS.exportTimeoutMillis,r=t.maxExportBatchSize??DEFAULTS.maxExportBatchSize,i=t.maxQueueSize??DEFAULTS.maxQueueSize,a=t.scheduledDelayMillis??DEFAULTS.scheduledDelayMillis,o=[],s,c=Promise.resolve(),l=!1;function cancelTimer(){s!==void 0&&(clearTimeout(s),s=void 0)}function scheduleDrain(){s===void 0&&(s=setTimeout(()=>{s=void 0,drain()},a),s.unref?.())}function drain(){return waitForExporter(pendingDrain(),`span export`).then(()=>void 0)}async function exportBatch(t){try{await new Promise((n,r)=>{try{context.with(context.active().setValue(SUPPRESS_TRACING_KEY,!0),()=>{e.export(t,e=>{if(e.code===0){n();return}r(e.error??Error(`Span export failed.`))})})}catch(e){r(e instanceof Error?e:Error(String(e)))}})}catch(e){report(`span export failed`,{error:e})}}return{async forceFlush(){!l&&await waitForExporter(pendingDrain(),`span export`)&&e.forceFlush!==void 0&&await waitForExporter(settleExporter(`exporter flush`,e.forceFlush),`exporter flush`)},onEnd(e){if(!l&&isSampled(e)&&!(o.length>=i)){if(o.push(e),o.length>=r){drain();return}scheduleDrain()}},onStart(){},async shutdown(){l=!0;let t=pendingDrain();if(!await waitForExporter(t,`span export`)){t.then(()=>settleExporter(`exporter shutdown`,e.shutdown));return}await waitForExporter(settleExporter(`exporter shutdown`,e.shutdown),`exporter shutdown`)}};function pendingDrain(){return cancelTimer(),c=c.then(async()=>{for(;o.length>0;)await exportBatch(o.splice(0,r))}),c}async function waitForExporter(e,t){let r,i=new Promise(e=>{r=setTimeout(()=>{report(`${t} timed out; preserving exporter serialization`,{timeoutMillis:n}),e(!1)},n),r.unref?.()}),a=e.then(()=>!0);try{return await Promise.race([a,i])}finally{clearTimeout(r)}}async function settleExporter(t,n){try{await n.call(e)}catch(e){report(`${t} failed`,{error:e})}}}function isSampled(e){if(typeof e!=`object`||!e||!(`spanContext`in e))return!1;let t=e.spanContext;if(typeof t!=`function`)return!1;let n=Reflect.apply(t,e,[]);return typeof n.traceFlags==`number`&&(n.traceFlags&TraceFlags.SAMPLED)===TraceFlags.SAMPLED}export{batchSpanProcessor};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SpanProcessor } from "#compiled/@vercel/otel/index.js";
|
|
2
|
-
import { type SpanExportPolicy } from "#tracing/span-export-policy.js";
|
|
2
|
+
import { type SpanExportPolicy } from "#tracing/eve/span-export-policy.js";
|
|
3
3
|
/**
|
|
4
4
|
* Puts one destination's content policy in front of it.
|
|
5
5
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalizeChannelAudience}from"#shared/channel-audience.js";import{withoutDeclinedContent}from"#compiled/@eve/tracing/otel.js";import{hasConversationRelease}from"#tracing/local/traces.js";import{channelAudienceFromContext}from"#tracing/eve/channel-audience-context.js";import{normalizeSpanExportPolicies}from"#tracing/eve/span-export-policy.js";function contentFilteringProcessor(e,t){let n=normalizeSpanExportPolicies(t);if(n.length===0)return e;let r=e;for(let e of n.toReversed())r=policyFilteringProcessor(r,e);return r}function policyFilteringProcessor(e,t){let n=new WeakMap,r=new WeakSet,i={forceFlush:()=>e.forceFlush(),onEnd:i=>{if(typeof i!=`object`||!i)return;let a=facadeFor(i,t,n);if(r.has(i)||!a.exported){r.delete(i),n.delete(i);return}a.refresh();try{e.onEnd(a.value)}finally{n.delete(i)}},onStart:(i,a)=>{if(typeof i!=`object`||!i)return;let o=facadeFor(i,t,n,channelAudienceFromContext(a));if(!o.exported){r.add(i);return}e.onStart(o.value,a)},shutdown:()=>e.shutdown()};return hasConversationRelease(e)?{...i,releaseConversation:t=>e.releaseConversation(t)}:i}function facadeFor(e,t,n,r){let i=n.get(e);if(i!==void 0)return i;let a=spanExportContext(e,r),o=spanExportDecision(a,t),s={recordInputs:!o.redactInputs,recordOutputs:!o.redactOutputs},c={},l=[],u={},d=Object.create(Reflect.getPrototypeOf(e)),f=new Map,refresh=()=>{refreshAttributes(c,e,s,a,t),refreshEvents(l,e,s),refreshStatus(u,e,s)},p,readOriginal=t=>{let n=Reflect.get(e,t,e);if(typeof n!=`function`||t===`constructor`)return n;let r=f.get(t);if(r!==void 0)return r;let created=(...t)=>{let r=Reflect.apply(n,e,t);return refresh(),r===e?p:r};return f.set(t,created),created};Object.defineProperty(d,"attributes",{configurable:!0,enumerable:!0,value:c}),Object.defineProperty(d,"events",{configurable:!0,enumerable:!0,value:l}),Object.defineProperty(d,"status",{configurable:!0,enumerable:!0,value:u});for(let t of Reflect.ownKeys(e)){if(t===`attributes`||t===`events`||t===`status`)continue;let n=Reflect.getOwnPropertyDescriptor(e,t);Object.defineProperty(d,t,{configurable:!0,enumerable:n?.enumerable??!1,get:()=>readOriginal(t)})}p=new Proxy(d,{get:(e,t,n)=>Object.hasOwn(e,t)?Reflect.get(e,t,n):readOriginal(t)});let m={context:a,exported:o.exported,refresh,value:p};return m.refresh(),n.set(e,m),m}function refreshAttributes(e,t,n,r,i){for(let t of Object.keys(e))delete e[t];let a=t.attributes;if(typeof a!=`object`||!a)return;let o=withoutDeclinedContent(a,n)??a;for(let[t,n]of Object.entries(o)){let a=attributeDecision(i,{key:t,span:r,value:n});typeof a==`object`&&a&&(`emit`in a&&`replace`in a||(`replace`in a&&a.replace===!0?a.value!==void 0&&(e[t]=a.value):`emit`in a&&a.emit===!0&&(e[t]=n)))}}function spanExportContext(e,t=`unknown`){let n=e.attributes,r=typeof n==`object`&&n?n:{},i=[r[`agent.channel.audience`],r[`ai.settings.context.eve.channel.audience`]].filter(e=>e!==void 0).map(normalizeChannelAudience),a=i.length>0&&i.every(e=>e===i[0])?i[0]:i.length>0?`unknown`:t,o=e.spanContext?.(),s=typeof o==`object`&&o?o:{},c=e.name;return{attributes:r,audience:a,name:typeof c==`string`?c:``,spanId:typeof s.spanId==`string`?s.spanId:``,traceId:typeof s.traceId==`string`?s.traceId:``}}function spanExportDecision(e,t){let n;try{n=t.span?.(e)??{emit:!0}}catch{return{exported:!1,redactInputs:!1,redactOutputs:!1}}if(typeof n!=`object`||!n)return{exported:!1,redactInputs:!1,redactOutputs:!1};if(`emit`in n)return`redact`in n?{exported:!1,redactInputs:!1,redactOutputs:!1}:{exported:typeof n.emit==`boolean`&&n.emit,redactInputs:!1,redactOutputs:!1};if(n.redact!==!0)return{exported:!1,redactInputs:!1,redactOutputs:!1};let r=n.inputs===!0,i=n.outputs===!0;return!r&&!i?{exported:!1,redactInputs:!1,redactOutputs:!1}:{exported:!0,redactInputs:r,redactOutputs:i}}function attributeDecision(e,t){if(e?.attribute===void 0)return{emit:!0};try{return e.attribute(t)}catch{return{emit:!1}}}function refreshEvents(e,t,n){e.length=0;let r=t.events;if(Array.isArray(r)){if(n.recordOutputs){e.push(...r);return}for(let t of r){if(typeof t!=`object`||!t)continue;let n=t;n.name!==`exception`&&e.push({...n,attributes:void 0})}}}function refreshStatus(e,t,n){for(let t of Object.keys(e))delete e[t];let r=t.status;if(typeof r!=`object`||!r)return;let i=r;i.code!==void 0&&(e.code=i.code),n.recordOutputs&&i.message!==void 0&&(e.message=i.message)}export{contentFilteringProcessor};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AgentSessionContext } from "#execution/agent-sessions/context.js";
|
|
2
|
+
import type { SessionParent, SessionTraceContext } from "#channel/types.js";
|
|
3
|
+
export declare const agentDelegation: {
|
|
4
|
+
fetch: typeof fetch;
|
|
5
|
+
resume<T>(input: {
|
|
6
|
+
context: Pick<AgentSessionContext, "trace" | "parent">;
|
|
7
|
+
agentName: string;
|
|
8
|
+
}, execute: () => T): T;
|
|
9
|
+
receive<T>(input: {
|
|
10
|
+
headers: Headers;
|
|
11
|
+
delegated: boolean;
|
|
12
|
+
trusted: boolean;
|
|
13
|
+
parent?: SessionParent;
|
|
14
|
+
callerTrace?: SessionTraceContext;
|
|
15
|
+
parentTraceContext?: SessionTraceContext;
|
|
16
|
+
}, execute: (context: {
|
|
17
|
+
conversationId?: string;
|
|
18
|
+
parentTraceContext?: SessionTraceContext;
|
|
19
|
+
}) => T): T;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readConversationBaggage}from"#tracing/eve/conversation-context.js";import{resolveConversationId}from"#shared/conversation-identity.js";import{intersectInstrumentationDecisions}from"#shared/instrumentation-decision.js";import{createAgentDelegationTransport}from"#compiled/@eve/tracing/delegation.js";const transport=createAgentDelegationTransport(),agentDelegation={fetch:transport.fetch,resume(e,t){let{context:n}=e,r=n.trace.parentTraceContext;if(r===void 0)return t();let i=r.decision;return transport.resume({caller:r,conversationId:n.trace.conversationId??resolveConversationId(n.parent.rootSessionId),parentRunId:n.parent.sessionId,parentCallId:n.parent.callId,agentName:e.agentName,capture:{emit:r.traceFlags===1&&i?.action!==`drop`,recordInputs:i?.action===`record`&&i.recordInputs,recordOutputs:i?.action===`record`&&i.recordOutputs}},t)},receive(e,t){return transport.receive(e.headers,t=>e.delegated&&e.trusted&&e.parent!==void 0&&t.parentRunId===e.parent.sessionId&&t.parentCallId===e.parent.callId&&e.callerTrace?.traceId===t.caller.traceId&&e.callerTrace.spanId===t.caller.spanId,n=>{let r=e.parentTraceContext,i=n?.capture.emit?{action:`record`,recordInputs:n.capture.recordInputs,recordOutputs:n.capture.recordOutputs}:{action:`drop`},a=n===void 0||r===void 0?r:{...r,decision:r.decision===void 0?i:intersectInstrumentationDecisions(r.decision,i),traceFlags:n.capture.emit?r.traceFlags:0};return t({conversationId:e.delegated?n?.conversationId??readConversationBaggage(e.headers.get(`baggage`)):void 0,parentTraceContext:a})})}};export{agentDelegation};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Attributes } from "#compiled/@eve/tracing/index.js";
|
|
2
|
+
export declare function createGatewayTraceContextHeaders(): Record<string, string> | undefined;
|
|
3
|
+
/** Converts Gateway response metadata to cost data. */
|
|
4
|
+
export declare function gatewayCostAttributes(input: {
|
|
5
|
+
cost?: number;
|
|
6
|
+
gatewayCost?: number;
|
|
7
|
+
inputCost?: number;
|
|
8
|
+
outputCost?: number;
|
|
9
|
+
generationId?: string;
|
|
10
|
+
}): Attributes;
|
|
11
|
+
export declare function readGatewayCostData(providerMetadata: Readonly<Record<string, unknown>> | undefined): {
|
|
12
|
+
cost: number | undefined;
|
|
13
|
+
gatewayCost: number | undefined;
|
|
14
|
+
inputCost: number | undefined;
|
|
15
|
+
outputCost: number | undefined;
|
|
16
|
+
generationId: string | undefined;
|
|
17
|
+
} | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{stripEveTraceBaggage}from"#protocol/baggage.js";import{context,createContextKey,propagation,trace}from"#compiled/@opentelemetry/api/index.js";const SUPPRESS_TRACING_KEY=createContextKey(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`),traceContextSetter={set(e,t,n){e[t]=n}};function createGatewayTraceContextHeaders(){let e=context.active();if(e.getValue(SUPPRESS_TRACING_KEY)===!0||trace.getSpan(e)===void 0)return;let t={};return propagation.inject(e,t,traceContextSetter),stripEveTraceBaggage(t),Object.keys(t).length===0?void 0:t}function gatewayCostAttributes(e){return{"gen_ai.usage.cost":e.cost,"gen_ai.usage.gateway_cost":e.gatewayCost,"gen_ai.usage.input_cost":e.inputCost,"gen_ai.usage.output_cost":e.outputCost,"gen_ai.generation.id":e.generationId}}function readGatewayCostData(e){if(e===void 0)return;let t=e.gateway;if(typeof t!=`object`||!t||Array.isArray(t))return;let n=t;return{cost:readUsd(n.cost),gatewayCost:readUsd(n.gatewayCost),inputCost:readUsd(n.inputInferenceCost),outputCost:readUsd(n.outputInferenceCost),generationId:typeof n.generationId==`string`&&n.generationId.length>0?n.generationId:void 0}}function readUsd(e){if(typeof e!=`string`||e.trim()===``)return;let t=Number(e);return Number.isFinite(t)?t:void 0}export{createGatewayTraceContextHeaders,gatewayCostAttributes,readGatewayCostData};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InstrumentationProviderDefinition } from "#instrumentation/lifecycle.js";
|
|
2
2
|
import { type InstrumentationRuntime } from "#instrumentation/runtime.js";
|
|
3
|
-
import type { CollectedOtel, RuntimeContextResolver } from "#tracing/otel-declaration.js";
|
|
3
|
+
import type { CollectedOtel, RuntimeContextResolver } from "#tracing/eve/otel-declaration.js";
|
|
4
4
|
/**
|
|
5
5
|
* Installs the process instrumentation runtime around a collected pipeline.
|
|
6
6
|
*
|