eve 0.71.2 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +22 -6
- package/dist/src/acp/adapter.js +1 -1
- package/dist/src/ai/decide.d.ts +7 -0
- package/dist/src/ai/decide.js +1 -0
- package/dist/src/channel/conversation-context.d.ts +4 -1
- package/dist/src/channel/invoke-tool.d.ts +41 -0
- package/dist/src/channel/invoke-tool.js +1 -0
- package/dist/src/channel/routes.d.ts +3 -0
- package/dist/src/chunks/{use-eve-agent-CFCaYnrI.js → use-eve-agent-C1GYGCtb.js} +698 -388
- package/dist/src/chunks/{use-eve-agent-DcDhXNv1.js → use-eve-agent-hZJ7CB8t.js} +698 -388
- package/dist/src/cli/commands/integration-setup.js +1 -1
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/commands/trace-detail.d.ts +1 -1
- package/dist/src/cli/commands/trace-detail.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-flow.d.ts +1 -0
- package/dist/src/cli/dev/tui/setup-panel.d.ts +1 -0
- package/dist/src/cli/dev/tui/setup-panel.js +2 -1
- package/dist/src/cli/dev/tui/traces/trace-conversation.d.ts +2 -2
- package/dist/src/cli/dev/tui/traces/trace-conversation.js +2 -2
- package/dist/src/cli/dev/tui/transcript-parts.d.ts +2 -1
- package/dist/src/cli/dev/tui/transcript-parts.js +1 -1
- package/dist/src/cli/dev/tui/transcript.js +1 -1
- package/dist/src/cli/dev/tui/tui-prompter.js +1 -1
- package/dist/src/client/conversation-projection.d.ts +4 -0
- package/dist/src/client/conversation-projection.js +1 -0
- package/dist/src/client/conversation-reducer.js +1 -1
- package/dist/src/client/conversation-state.d.ts +5 -26
- package/dist/src/client/conversation-state.js +1 -1
- package/dist/src/client/index.d.ts +1 -0
- package/dist/src/client/index.js +1 -1
- package/dist/src/client/message-action-parts.d.ts +1 -11
- package/dist/src/client/message-action-parts.js +1 -1
- package/dist/src/client/message-reducer.d.ts +3 -1
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/tool-call-state.d.ts +23 -0
- package/dist/src/client/tool-call-state.js +1 -0
- package/dist/src/client/tool-part-state.d.ts +7 -0
- package/dist/src/client/tool-part-state.js +1 -0
- package/dist/src/compiled/.vendor-stamp.json +10 -10
- package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +1453 -1358
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +1 -2
- package/dist/src/compiled/@ai-sdk/code-mode/index.d.ts +172 -163
- package/dist/src/compiled/@ai-sdk/code-mode/index.js +15 -20
- package/dist/src/compiled/@ai-sdk/google/index.d.ts +772 -733
- package/dist/src/compiled/@ai-sdk/google/index.js +6 -8
- package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +887 -790
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.d.ts +1722 -1691
- package/dist/src/compiled/@ai-sdk/openai/index.js +3 -14
- package/dist/src/compiled/@ai-sdk/otel/index.d.ts +216 -159
- package/dist/src/compiled/@ai-sdk/otel/index.js +3 -3
- package/dist/src/compiled/@ai-sdk/provider/index.d.ts +7542 -7271
- package/dist/src/compiled/@ai-sdk/provider/index.js +1 -3
- package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +1799 -1600
- package/dist/src/compiled/@eve/catalog/index.js +1 -1
- package/dist/src/compiled/_chunks/workflow/dist-DXLdlucM.js +15 -0
- package/dist/src/compiled/_chunks/workflow/experimental-decision-BrfWf6-n.js +3 -0
- package/dist/src/compiler/extension-compatibility.d.ts +36 -20
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/caller-scope.d.ts +7 -0
- package/dist/src/context/caller-scope.js +1 -0
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-metadata.d.ts +1 -0
- package/dist/src/context/providers/session.js +1 -1
- package/dist/src/evals/define-eval.d.ts +1 -1
- package/dist/src/evals/judge.d.ts +1 -1
- package/dist/src/evals/judge.js +2 -2
- package/dist/src/evals/types.d.ts +8 -8
- package/dist/src/execution/cancel-descendant-turns-step.d.ts +1 -0
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +2 -1
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/durable-session-read.d.ts +5 -0
- package/dist/src/execution/durable-session-read.js +1 -0
- package/dist/src/execution/durable-session-store.d.ts +4 -10
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-connections.d.ts +3 -3
- package/dist/src/execution/dynamic-connections.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/invoke-tool.d.ts +35 -0
- package/dist/src/execution/invoke-tool.js +1 -0
- package/dist/src/execution/legacy-session/interrupt-step.js +1 -1
- package/dist/src/execution/legacy-session/snapshot.d.ts +3 -0
- package/dist/src/execution/legacy-session/snapshot.js +1 -1
- package/dist/src/execution/model-call-batching.js +1 -1
- package/dist/src/execution/node-step.d.ts +2 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/publish-session-events.d.ts +8 -0
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/sandbox/active-handles.d.ts +6 -0
- package/dist/src/execution/sandbox/active-handles.js +1 -1
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/answer-caller.d.ts +15 -0
- package/dist/src/execution/session/answer-caller.js +1 -0
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/finalization.js +1 -1
- package/dist/src/execution/session/handoff-steps.d.ts +3 -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/pending-turn-state.d.ts +8 -3
- package/dist/src/execution/session/pending-turn-state.js +1 -1
- package/dist/src/execution/session/task-tool-tracing-step.d.ts +5 -0
- package/dist/src/execution/session/task-tool-tracing-step.js +1 -0
- package/dist/src/execution/session/turn-step-result.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn-waiting-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +1 -0
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +4 -6
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/tasks/start.d.ts +3 -3
- package/dist/src/execution/tasks/start.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/terminal-session-completion-step.d.ts +7 -0
- package/dist/src/execution/terminal-session-completion-step.js +1 -1
- package/dist/src/execution/terminal-session-failure-step.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/connection-tools.js +1 -1
- package/dist/src/execution/tools/workflow/authorization-completion.js +1 -1
- package/dist/src/execution/tools/workflow/harness-definition.js +1 -1
- package/dist/src/execution/tools/workflow/step-execution.js +1 -1
- package/dist/src/execution/tools/workflow/step.js +1 -1
- package/dist/src/execution/tools/workflow/withdraw-step.d.ts +7 -9
- package/dist/src/execution/tools/workflow/withdraw-step.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-trace-context.d.ts +2 -2
- package/dist/src/harness/authorization.d.ts +4 -2
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/{compaction.js → compaction/engine.js} +1 -1
- package/dist/src/harness/compaction/step.d.ts +46 -0
- package/dist/src/harness/compaction/step.js +1 -0
- package/dist/src/harness/coordination.d.ts +32 -64
- package/dist/src/harness/coordination.js +1 -1
- package/dist/src/harness/current-messages.d.ts +1 -3
- package/dist/src/harness/current-messages.js +1 -1
- package/dist/src/harness/emission.d.ts +4 -52
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +1 -0
- package/dist/src/harness/final-output.d.ts +5 -0
- package/dist/src/harness/final-output.js +1 -1
- package/dist/src/harness/hitl/approvals.d.ts +115 -0
- package/dist/src/harness/hitl/approvals.js +1 -0
- package/dist/src/harness/hitl/approved-call-callers.d.ts +14 -0
- package/dist/src/harness/hitl/approved-call-callers.js +1 -0
- package/dist/src/harness/hitl/approved-calls.d.ts +37 -0
- package/dist/src/harness/hitl/approved-calls.js +1 -0
- package/dist/src/harness/{session-limit-continuation.d.ts → hitl/budget-request.d.ts} +3 -1
- package/dist/src/harness/hitl/budget-request.js +1 -0
- package/dist/src/harness/hitl/budget.d.ts +21 -0
- package/dist/src/harness/hitl/budget.js +1 -0
- package/dist/src/harness/{approval-candidates.d.ts → hitl/candidates.d.ts} +13 -18
- package/dist/src/harness/hitl/candidates.js +1 -0
- package/dist/src/harness/hitl/coordinator.js +1 -0
- package/dist/src/harness/hitl/delivery.d.ts +37 -0
- package/dist/src/harness/hitl/delivery.js +1 -0
- package/dist/src/harness/hitl/index.d.ts +49 -0
- package/dist/src/harness/hitl/index.js +1 -0
- package/dist/src/harness/hitl/intake.d.ts +67 -0
- package/dist/src/harness/hitl/intake.js +1 -0
- package/dist/src/harness/{stale-input-responses.d.ts → hitl/stale-responses.d.ts} +5 -3
- package/dist/src/harness/hitl/stale-responses.js +3 -0
- package/dist/src/harness/inline-tool-authorization.d.ts +4 -0
- package/dist/src/harness/inline-tool-authorization.js +1 -1
- package/dist/src/harness/input-extraction.d.ts +1 -10
- package/dist/src/harness/input-extraction.js +1 -1
- package/dist/src/harness/input-request-resolution.d.ts +1 -5
- package/dist/src/harness/input-request-resolution.js +1 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/model-call/call.d.ts +78 -0
- package/dist/src/harness/model-call/call.js +1 -0
- package/dist/src/harness/{model-call-error.d.ts → model-call/errors.d.ts} +1 -1
- package/dist/src/harness/model-call/failure.d.ts +52 -0
- package/dist/src/harness/model-call/failure.js +1 -0
- package/dist/src/harness/model-call/model.d.ts +18 -0
- package/dist/src/harness/model-call/model.js +1 -0
- package/dist/src/harness/model-call/recovery.d.ts +52 -0
- package/dist/src/harness/model-call/recovery.js +1 -0
- package/dist/src/harness/model-call/request.d.ts +30 -0
- package/dist/src/harness/model-call/request.js +3 -0
- package/dist/src/harness/model-call/response.d.ts +39 -0
- package/dist/src/harness/model-call/response.js +1 -0
- package/dist/src/harness/model-call/retry.d.ts +11 -0
- package/dist/src/harness/model-call/retry.js +1 -0
- package/dist/src/harness/model-call/run.d.ts +38 -0
- package/dist/src/harness/model-call/run.js +1 -0
- package/dist/src/harness/model-call/tools.d.ts +48 -0
- package/dist/src/harness/model-call/tools.js +1 -0
- package/dist/src/harness/model-call/usage.d.ts +23 -0
- package/dist/src/harness/model-call/usage.js +1 -0
- package/dist/src/harness/nested-actions.d.ts +2 -2
- package/dist/src/harness/provider-tools.d.ts +7 -3
- package/dist/src/harness/provider-tools.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +4 -12
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/session-machine/commit.d.ts +28 -0
- package/dist/src/harness/session-machine/commit.js +1 -0
- package/dist/src/harness/session-machine/current.d.ts +29 -0
- package/dist/src/harness/session-machine/current.js +1 -0
- package/dist/src/harness/session-machine/events.d.ts +6 -0
- package/dist/src/harness/session-machine/events.js +1 -0
- package/dist/src/harness/session-machine/resolver-events.d.ts +12 -0
- package/dist/src/harness/session-machine/resolver-events.js +1 -0
- package/dist/src/harness/session-machine/state.d.ts +47 -0
- package/dist/src/harness/session-machine/state.js +1 -0
- package/dist/src/harness/session-machine/transitions.d.ts +188 -0
- package/dist/src/harness/session-machine/transitions.js +1 -0
- package/dist/src/harness/session-machine/view.d.ts +58 -0
- package/dist/src/harness/session-machine/view.js +1 -0
- package/dist/src/harness/step/after-model.d.ts +7 -0
- package/dist/src/harness/step/after-model.js +1 -0
- package/dist/src/harness/step/context.d.ts +59 -0
- package/dist/src/harness/step/context.js +1 -0
- package/dist/src/harness/step/intake.d.ts +34 -0
- package/dist/src/harness/step/intake.js +1 -0
- package/dist/src/harness/step/prompt.d.ts +37 -0
- package/dist/src/harness/step/prompt.js +1 -0
- package/dist/src/harness/step-hooks.d.ts +8 -13
- package/dist/src/harness/step-hooks.js +1 -1
- package/dist/src/harness/tool-call-io.d.ts +25 -0
- package/dist/src/harness/tool-call-io.js +1 -0
- package/dist/src/harness/tool-loop.d.ts +7 -22
- package/dist/src/harness/tool-loop.js +1 -3
- package/dist/src/harness/tool-model-output.d.ts +1 -2
- package/dist/src/harness/tools.d.ts +14 -0
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +1 -1
- package/dist/src/harness/types.d.ts +6 -0
- package/dist/src/instrumentation/ai-sdk-hook-bridge.d.ts +1 -1
- package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/instrumentation/content.js +1 -1
- package/dist/src/instrumentation/dispatch.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +28 -52
- package/dist/src/instrumentation/native-events.d.ts +2 -1
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/provider.d.ts +1 -1
- package/dist/src/instrumentation/runtime-context.d.ts +2 -3
- package/dist/src/instrumentation/runtime-context.js +1 -1
- package/dist/src/instrumentation/runtime.d.ts +11 -1
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/instrumentation/state.d.ts +6 -1
- package/dist/src/instrumentation/state.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/attachments/limited-read.d.ts +16 -0
- package/dist/src/internal/attachments/limited-read.js +1 -0
- package/dist/src/internal/authored-definition/schema-backed.d.ts +2 -1
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/gateway.d.ts +2 -0
- package/dist/src/internal/gateway.js +1 -1
- package/dist/src/internal/mcp/published-tools.d.ts +13 -0
- package/dist/src/internal/mcp/published-tools.js +1 -0
- package/dist/src/internal/mcp/request-trace-context.d.ts +12 -0
- package/dist/src/internal/mcp/request-trace-context.js +1 -0
- package/dist/src/internal/mcp/streamable-http-server.d.ts +7 -3
- package/dist/src/internal/mcp/streamable-http-server.js +1 -1
- package/dist/src/internal/model-auth/transport.d.ts +3 -3
- package/dist/src/internal/model-auth/transport.js +1 -1
- package/dist/src/internal/nitro/host/instrumentation-entry.js +2 -2
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-request-instrumentation.js +1 -1
- package/dist/src/internal/nitro/routes/route-invoke-tool.d.ts +24 -0
- package/dist/src/internal/nitro/routes/route-invoke-tool.js +1 -0
- package/dist/src/models/auto.d.ts +5 -5
- package/dist/src/models/auto.js +2 -2
- package/dist/src/protocol/message.d.ts +7 -0
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/protocol/session-projection.d.ts +159 -0
- package/dist/src/protocol/session-projection.js +1 -0
- package/dist/src/public/ai/index.d.ts +1 -1
- package/dist/src/public/ai/index.js +1 -1
- package/dist/src/public/channels/chat-sdk/attachment-refs.d.ts +15 -0
- package/dist/src/public/channels/chat-sdk/attachment-refs.js +1 -0
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
- package/dist/src/public/channels/chat-sdk/messageToUserContent.d.ts +11 -5
- package/dist/src/public/channels/chat-sdk/messageToUserContent.js +1 -1
- package/dist/src/public/channels/discord/attachments.d.ts +15 -0
- package/dist/src/public/channels/discord/attachments.js +1 -0
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/discord/inbound.d.ts +13 -0
- package/dist/src/public/channels/discord/inbound.js +1 -1
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/linear/inbound-uploads.d.ts +21 -0
- package/dist/src/public/channels/linear/inbound-uploads.js +1 -0
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/channels/linq/inboundContent.d.ts +7 -1
- package/dist/src/public/channels/linq/inboundContent.js +1 -1
- package/dist/src/public/channels/linq/linqChannel.js +1 -1
- package/dist/src/public/channels/mcp.d.ts +17 -2
- package/dist/src/public/channels/mcp.js +1 -1
- package/dist/src/public/channels/photon/attachments.d.ts +21 -0
- package/dist/src/public/channels/photon/attachments.js +1 -0
- package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
- package/dist/src/public/channels/slack/attachments.d.ts +3 -1
- package/dist/src/public/channels/slack/attachments.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/attachments.d.ts +4 -4
- package/dist/src/public/channels/teams/attachments.js +1 -1
- package/dist/src/public/channels/telegram/attachments.js +1 -1
- package/dist/src/public/channels/twilio/api.d.ts +7 -0
- package/dist/src/public/channels/twilio/api.js +1 -1
- package/dist/src/public/channels/twilio/inbound.d.ts +7 -0
- package/dist/src/public/channels/twilio/inbound.js +2 -2
- package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +1 -0
- package/dist/src/public/definitions/connections/mcp.d.ts +1 -1
- package/dist/src/public/definitions/connections/openapi.d.ts +1 -1
- package/dist/src/public/models/openai/chatgpt/model.js +1 -1
- package/dist/src/react/index.d.ts +1 -0
- package/dist/src/react/index.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +2 -2
- package/dist/src/runtime/connections/mcp-client.js +1 -1
- package/dist/src/runtime/connections/scoped-authorization.js +1 -1
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/setup/boxes/resolve-provisioning.d.ts +2 -0
- package/dist/src/setup/boxes/resolve-provisioning.js +1 -1
- package/dist/src/setup/cli/prompt-ui.d.ts +3 -0
- package/dist/src/setup/cli/prompt-ui.js +3 -1
- package/dist/src/setup/cli/select-component.d.ts +1 -0
- package/dist/src/setup/cli/select-component.js +1 -1
- package/dist/src/setup/flows/ensure-vercel-project.d.ts +2 -0
- package/dist/src/setup/flows/ensure-vercel-project.js +1 -1
- package/dist/src/setup/integrations/discord/api.js +1 -1
- package/dist/src/setup/integrations/web/auth-options.d.ts +4 -0
- package/dist/src/setup/integrations/web/auth-options.js +1 -0
- package/dist/src/setup/integrations/web/auth-scaffold.d.ts +7 -0
- package/dist/src/setup/integrations/web/auth-scaffold.js +1 -0
- package/dist/src/setup/integrations/web/provision-auth.d.ts +3 -0
- package/dist/src/setup/integrations/web/provision-auth.js +1 -0
- package/dist/src/setup/integrations/web/setup.d.ts +11 -6
- package/dist/src/setup/integrations/web/setup.js +3 -3
- package/dist/src/setup/prompter.d.ts +2 -0
- package/dist/src/setup/prompter.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/create/web-template.d.ts +3 -3
- package/dist/src/setup/scaffold/create/web-template.js +26 -8
- package/dist/src/setup/scaffold/update/web-options.js +1 -1
- package/dist/src/setup/vercel-project-api.d.ts +9 -0
- package/dist/src/setup/vercel-project-api.js +1 -1
- package/dist/src/setup/vercel-project.d.ts +4 -2
- package/dist/src/setup/vercel-project.js +0 -0
- package/dist/src/shared/web-search.d.ts +1 -1
- package/dist/src/subagents/adapter.js +1 -1
- package/dist/src/subagents/event-proxy-step.js +1 -1
- package/dist/src/subagents/hitl-proxy.d.ts +4 -28
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/svelte/index.d.ts +2 -0
- package/dist/src/svelte/index.js +39 -2
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/approval/policies.d.ts +5 -5
- package/dist/src/tools/approval/policies.js +1 -1
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/provided/agent-router.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/ask-question.js +2 -2
- package/dist/src/tools/provided/bash.js +1 -1
- package/dist/src/tools/provided/framework-tool.d.ts +3 -0
- package/dist/src/tools/provided/framework-tool.js +1 -0
- package/dist/src/tools/provided/glob.js +2 -2
- package/dist/src/tools/provided/grep.js +2 -2
- package/dist/src/tools/provided/load-skill.js +1 -1
- package/dist/src/tools/provided/no-reply.js +1 -1
- package/dist/src/tools/provided/read-file.js +2 -2
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tools/provided/sleep.js +1 -1
- package/dist/src/tools/provided/task-cancel.js +1 -1
- package/dist/src/tools/provided/task-wait.js +1 -1
- package/dist/src/tools/provided/web-fetch.js +2 -2
- package/dist/src/tools/provided/web-search.js +1 -1
- package/dist/src/tools/provided/workflow.js +1 -1
- package/dist/src/tools/provided/write-file.js +2 -2
- package/dist/src/tracing/agent-approval-instrumentation.d.ts +2 -2
- package/dist/src/tracing/agent-approval-instrumentation.js +1 -1
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-usage.d.ts +1 -1
- package/dist/src/tracing/agent-otel-usage.js +1 -1
- package/dist/src/tracing/agent-span-contract.d.ts +8 -1
- package/dist/src/tracing/agent-span-contract.js +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.d.ts +16 -5
- package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
- package/dist/src/tracing/agent-trace-context-codec.js +1 -1
- package/dist/src/tracing/agent-trace-span-processor.js +1 -1
- package/dist/src/tracing/agent-trace-state.d.ts +8 -3
- package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
- package/dist/src/tracing/invoke-tool-span.d.ts +61 -0
- package/dist/src/tracing/invoke-tool-span.js +1 -0
- package/dist/src/tracing/local-trace-analysis.js +1 -1
- package/dist/src/vue/index.d.ts +2 -0
- package/dist/src/vue/index.js +39 -2
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +2 -2
- package/docs/channels/chat-sdk.mdx +3 -1
- package/docs/channels/custom.mdx +3 -0
- package/docs/channels/discord.mdx +5 -4
- package/docs/channels/eve.mdx +65 -0
- package/docs/channels/linear.mdx +1 -1
- package/docs/channels/linq.mdx +2 -0
- package/docs/channels/mcp.mdx +39 -1
- package/docs/channels/photon.mdx +5 -0
- package/docs/channels/teams.mdx +4 -7
- package/docs/channels/twilio.mdx +1 -1
- package/docs/concepts/built-in-tools.md +12 -0
- package/docs/concepts/sessions-runs-and-streaming.md +3 -3
- package/docs/connections/overview.mdx +1 -1
- package/docs/dynamic-configuration/meta.json +1 -1
- package/docs/evals/judge.mdx +16 -16
- package/docs/evals/overview.mdx +1 -1
- package/docs/guides/{evaluate.md → decide.md} +35 -35
- package/docs/guides/dynamic-capabilities.md +1 -1
- package/docs/guides/frontend/overview.mdx +3 -1
- package/docs/guides/hooks.md +1 -1
- package/docs/guides/instrumentation/instrumentation.mdx +23 -22
- package/docs/guides/instrumentation/otel.mdx +13 -2
- package/docs/reference/cli.md +4 -2
- package/docs/reference/typescript-api.md +4 -2
- package/docs/tools/human-in-the-loop.md +8 -4
- package/docs/tools/workflows.mdx +4 -4
- package/package.json +13 -11
- package/dist/src/ai/evaluate.d.ts +0 -7
- package/dist/src/ai/evaluate.js +0 -1
- package/dist/src/client/message-task-parts.d.ts +0 -8
- package/dist/src/client/message-task-parts.js +0 -1
- package/dist/src/compiled/_chunks/workflow/dist-C3ZE62yI.js +0 -25
- package/dist/src/compiled/_chunks/workflow/experimental-evaluation-Dm32egEG.js +0 -5
- package/dist/src/harness/active-turn-id.d.ts +0 -11
- package/dist/src/harness/active-turn-id.js +0 -1
- package/dist/src/harness/approval-candidates.js +0 -1
- package/dist/src/harness/approval-delivery-coordinator.js +0 -1
- package/dist/src/harness/cancelled-turn-emission.d.ts +0 -12
- package/dist/src/harness/cancelled-turn-emission.js +0 -1
- package/dist/src/harness/emission-state.d.ts +0 -26
- package/dist/src/harness/emission-state.js +0 -1
- package/dist/src/harness/held-requests.d.ts +0 -18
- package/dist/src/harness/held-requests.js +0 -1
- package/dist/src/harness/hitl/approval-input-requests.d.ts +0 -27
- package/dist/src/harness/hitl/approval-input-requests.js +0 -1
- package/dist/src/harness/hitl/pending-input-resolution.d.ts +0 -54
- package/dist/src/harness/hitl/pending-input-resolution.js +0 -1
- package/dist/src/harness/hitl/session-limit-input-requests.d.ts +0 -12
- package/dist/src/harness/hitl/session-limit-input-requests.js +0 -1
- package/dist/src/harness/input-requests.d.ts +0 -31
- package/dist/src/harness/input-requests.js +0 -1
- package/dist/src/harness/pending-input-batches.d.ts +0 -81
- package/dist/src/harness/pending-input-batches.js +0 -1
- package/dist/src/harness/session-limit-continuation.js +0 -1
- package/dist/src/harness/session-limit-enforcement.d.ts +0 -45
- package/dist/src/harness/session-limit-enforcement.js +0 -1
- package/dist/src/harness/stale-input-responses.js +0 -3
- package/dist/src/harness/workflow-dispatch.d.ts +0 -30
- package/dist/src/harness/workflow-dispatch.js +0 -1
- package/dist/src/public/channels/linear/inbound-images.d.ts +0 -19
- package/dist/src/public/channels/linear/inbound-images.js +0 -1
- package/dist/src/tracing/agent-action-instrumentation.d.ts +0 -25
- package/dist/src/tracing/agent-action-instrumentation.js +0 -1
- /package/dist/src/harness/{compaction.d.ts → compaction/engine.d.ts} +0 -0
- /package/dist/src/harness/{compaction-prompt.d.ts → compaction/prompt.d.ts} +0 -0
- /package/dist/src/harness/{compaction-prompt.js → compaction/prompt.js} +0 -0
- /package/dist/src/harness/{approval-delivery-coordinator.d.ts → hitl/coordinator.d.ts} +0 -0
- /package/dist/src/harness/{model-call-error.js → model-call/errors.js} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { LanguageModel } from "ai";
|
|
2
|
+
import type { HarnessSession, ToolLoopHarnessConfig } from "#harness/types.js";
|
|
3
|
+
import { contextStorage } from "#context/container.js";
|
|
4
|
+
/**
|
|
5
|
+
* Builds AI Gateway app attribution headers when the model is gateway-routed.
|
|
6
|
+
*
|
|
7
|
+
* Bare model ids and `gateway.*` model instances route through AI Gateway.
|
|
8
|
+
* Direct-provider model instances receive no Gateway-specific headers.
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildGatewayAttributionHeaders(model: LanguageModel, runtimeIdentity: ToolLoopHarnessConfig["runtimeIdentity"]): Record<string, string> | undefined;
|
|
11
|
+
export declare function resolveEffectiveRuntimeModel(input: {
|
|
12
|
+
readonly config: ToolLoopHarnessConfig;
|
|
13
|
+
readonly ctx: ReturnType<typeof contextStorage.getStore>;
|
|
14
|
+
readonly session: HarnessSession;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
readonly model: LanguageModel;
|
|
17
|
+
readonly session: HarnessSession;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"#context/container.js";import{resolveProviderHeaders}from"#internal/gateway.js";import{getEffectiveModelSelection}from"#context/effective-model.js";function buildGatewayAttributionHeaders(e,t){let n=resolveProviderHeaders(e);if(n===void 0)return;let r=t?.agentName??t?.agentId,i=process.env.VERCEL_PROJECT_PRODUCTION_URL||process.env.VERCEL_URL,a=i?`https://${i}`:void 0,o={...n};return r&&(o[`x-title`]=r),a&&(o[`http-referer`]=a),o}async function resolveEffectiveRuntimeModel(e){if(e.ctx===void 0){let t=e.session.agent.modelReference;if(t===void 0)throw Error(`Dynamic model selection is unavailable outside an eve runtime context.`);return{model:await e.config.resolveModel(t),session:e.session}}let t=getEffectiveModelSelection(e.ctx);if(t===null)throw Error(`Dynamic model selection is required before model-dependent work begins. Add a matching resolver handler that returns a concrete model.`);return{model:t.model===void 0?await e.config.resolveModel(t.reference):t.model,session:updateSessionModelReference(e.session,t.reference)}}function updateSessionModelReference(e,t){return e.agent.modelReference===t?e:{...e,agent:{...e.agent,modelReference:t},compaction:updateCompactionThresholdForModelReference({compaction:e.compaction,modelReference:t})}}function updateCompactionThresholdForModelReference(e){return e.modelReference.contextWindowTokens===void 0?e.compaction:{...e.compaction,threshold:Math.max(1,Math.floor(e.modelReference.contextWindowTokens*(e.compaction.thresholdPercent??.9)))}}export{buildGatewayAttributionHeaders,resolveEffectiveRuntimeModel};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HarnessStepResult } from "#harness/step-hooks.js";
|
|
2
|
+
/** How a recovery reissues the call. */
|
|
3
|
+
type RecoveryCall = (options: {
|
|
4
|
+
readonly disabledProviderTools?: ReadonlySet<string>;
|
|
5
|
+
readonly extraSystemNote?: string;
|
|
6
|
+
readonly retryReason?: "empty-response";
|
|
7
|
+
readonly suppressStepStartedEmission?: boolean;
|
|
8
|
+
readonly trailingUserNote?: string;
|
|
9
|
+
}) => Promise<HarnessStepResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Recovers a failed model call, each recovery at most once and within the current step, so the
|
|
12
|
+
* reissue suppresses a second `step.started`:
|
|
13
|
+
*
|
|
14
|
+
* 1. AI Gateway rejected a provider-specific tool a fallback provider can't serve ("tool type 'X'
|
|
15
|
+
* is not supported"): the call is reissued without it, and a system note tells the model which
|
|
16
|
+
* capability went away. Only known provider tools are dropped, never an authored one.
|
|
17
|
+
* 2. The response was empty (see {@link EmptyModelResponseError}), including the first
|
|
18
|
+
* recovery's: the call is reissued with {@link EMPTY_RESPONSE_NUDGE}, repeating what the first
|
|
19
|
+
* recovery removed.
|
|
20
|
+
*
|
|
21
|
+
* Each reissue goes through `call` so it gets fresh step hooks: the failed attempt's one-shot
|
|
22
|
+
* `stepResult` already resolved. Returns the error that remains when nothing recovered.
|
|
23
|
+
*/
|
|
24
|
+
export declare function recoverModelCall(input: {
|
|
25
|
+
readonly error: unknown;
|
|
26
|
+
readonly call: RecoveryCall;
|
|
27
|
+
readonly sessionId: string;
|
|
28
|
+
readonly turnId: string;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
readonly result: HarnessStepResult;
|
|
31
|
+
} | {
|
|
32
|
+
readonly error: unknown;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* True when a step produced no assistant text and no tool calls. A blank
|
|
36
|
+
* response is ambiguous and must be retried instead of silently dropping a
|
|
37
|
+
* HITL reply.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isEmptyModelResponse(step: HarnessStepResult): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Rethrows the AI SDK's `NoOutputGeneratedError` as
|
|
42
|
+
* {@link EmptyModelResponseError}. Since `ai@7.0.0-canary.169`
|
|
43
|
+
* (vercel/ai#15938) a stream that closes after metadata without output or
|
|
44
|
+
* a finish chunk rejects — the SDK enqueues the error onto `fullStream`
|
|
45
|
+
* (so `emitStreamContent` throws it) and never emits `finish-step`, so
|
|
46
|
+
* `onStepEnd` does not fire and the step hooks' `stepResult` promise
|
|
47
|
+
* would never settle. The same condition previously completed as an empty
|
|
48
|
+
* step caught by {@link isEmptyModelResponse}; normalizing here funnels
|
|
49
|
+
* both shapes into the one-shot empty-response reissue.
|
|
50
|
+
*/
|
|
51
|
+
export declare function rethrowNoOutputAsEmptyResponse(error: unknown): never;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{resolveAssistantStepText}from"#harness/messages.js";import{EmptyModelResponseError,extractUnsupportedProviderToolTypes,isNoOutputGeneratedError}from"#harness/model-call/errors.js";import{resolveFrameworkToolFromUpstreamType}from"#harness/provider-tools.js";const log=createLogger(`harness.tool-loop`);async function recoverModelCall(e){let{error:t}=e,n={sessionId:e.sessionId,turnId:e.turnId},r={},i=extractUnsupportedProviderToolTypes(t),a=[...new Set(i.flatMap(e=>resolveFrameworkToolFromUpstreamType(e)??[]))];if(a.length>0){log.warn(`disabling unsupported provider tool(s); retrying step once`,{...n,disabled:a,upstreamTypes:i}),r={disabledProviderTools:new Set(a),extraSystemNote:buildDisabledToolNote(a)};try{return{result:await e.call({...r,suppressStepStartedEmission:!0})}}catch(e){t=e}}if(t instanceof EmptyModelResponseError){log.warn(`empty model response; reissuing the model call once`,n);try{return{result:await e.call({...r,retryReason:`empty-response`,suppressStepStartedEmission:!0,trailingUserNote:EMPTY_RESPONSE_NUDGE})}}catch(e){t=e}}return{error:t}}function buildDisabledToolNote(e){let t=e.join(`, `);return`The following ${e.length===1?`tool is`:`tools are`} not available with the current model and has been removed: ${t}. Proceed using the remaining tools or your training knowledge.`}function isEmptyModelResponse(e){return e.toolCalls.length===0&&e.toolResults.length===0&&resolveAssistantStepText(e.response.messages,e.text)===null}function rethrowNoOutputAsEmptyResponse(e){throw isNoOutputGeneratedError(e)?new EmptyModelResponseError({cause:e}):e}const EMPTY_RESPONSE_NUDGE=`Your previous reply was empty and was not delivered. Continue the current user request. Reuse completed results when they satisfy the request. If existing results are stale or insufficient, use the appropriate read tools to get fresh results. Do not repeat writes or other side effects that already completed. Do not mention this notice.`;export{isEmptyModelResponse,recoverModelCall,rethrowNoOutputAsEmptyResponse};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ModelMessage, SystemModelMessage } from "ai";
|
|
2
|
+
import { createCurrentMessages } from "#harness/current-messages.js";
|
|
3
|
+
import { type HarnessModelMessage, type UserModelMessage } from "#harness/messages.js";
|
|
4
|
+
import { type AnthropicCacheMarker } from "#harness/prompt-cache.js";
|
|
5
|
+
import type { Step } from "#harness/step/context.js";
|
|
6
|
+
import type { HarnessSession, HarnessToolMap } from "#harness/types.js";
|
|
7
|
+
export type RequestMessages = ReturnType<typeof createCurrentMessages>;
|
|
8
|
+
/**
|
|
9
|
+
* The messages one model call sends: the durable prompt, then the step's system instructions and
|
|
10
|
+
* announcements. Announcements persist ahead of the new input, or after earlier tool results on a
|
|
11
|
+
* continuation, so later requests keep the full prefix.
|
|
12
|
+
*/
|
|
13
|
+
export declare function requestMessages(step: Step, input: {
|
|
14
|
+
readonly messages: readonly HarnessModelMessage[];
|
|
15
|
+
readonly projectedMessages: readonly HarnessModelMessage[];
|
|
16
|
+
readonly turnMessages: readonly UserModelMessage[];
|
|
17
|
+
readonly coordinationTools: HarnessToolMap;
|
|
18
|
+
readonly hidesHeldText: boolean;
|
|
19
|
+
readonly pendingApprovalsNote: string | undefined;
|
|
20
|
+
}): RequestMessages;
|
|
21
|
+
/** The call's system instructions: a retry's note, the agent's system prompt, then the step's. */
|
|
22
|
+
export declare function modelInstructions(input: {
|
|
23
|
+
readonly session: HarnessSession;
|
|
24
|
+
readonly systemMessages: readonly SystemModelMessage[];
|
|
25
|
+
readonly marker: AnthropicCacheMarker | undefined;
|
|
26
|
+
readonly extraSystemNote?: string;
|
|
27
|
+
}): SystemModelMessage | string | undefined;
|
|
28
|
+
/** A retry's note, trailing the call's messages. */
|
|
29
|
+
export declare function withTrailingUserNote(messages: readonly ModelMessage[], note?: string): ModelMessage[];
|
|
30
|
+
export declare function mergeSystemInstructions(instructions: readonly SystemModelMessage[]): SystemModelMessage | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{HistoryStateKey}from"#context/keys.js";import{createFrameworkUserMessage}from"#harness/messages.js";import{getPendingAnnouncements}from"#harness/announcements.js";import{buildDynamicInstructionMessages}from"#context/dynamic-instruction-lifecycle.js";import{PendingSkillAnnouncementKey}from"#context/dynamic-skill-lifecycle.js";import{taskSystemMessages}from"#execution/tasks/model-step.js";import{applySystemCacheBreakpoint}from"#harness/prompt-cache.js";import{createCurrentMessages}from"#harness/current-messages.js";function requestMessages(e,t){let{ctx:n}=e,r=createCurrentMessages(t.messages,{historyState:n?.get(HistoryStateKey),currentTurnMessages:t.turnMessages,projectedMessages:t.projectedMessages});return n!==void 0&&r.addSystem(buildDynamicInstructionMessages(n)),r.addSystem(taskSystemMessages(t.coordinationTools,{finalReplyOnly:t.hidesHeldText})),r.addAnnouncements({availableSkills:n?.get(PendingSkillAnnouncementKey),keyed:getPendingAnnouncements(n)}),t.pendingApprovalsNote!==void 0&&r.add(t.pendingApprovalsNote,`context.state`,{cacheFriendly:!1}),r}function modelInstructions(e){let{session:t}=e,n=e.extraSystemNote?[{role:`system`,content:e.extraSystemNote}]:[];if(e.systemMessages.length===0&&n.length===0)return t.agent.system??void 0;let r=t.agent.system?[{role:`system`,content:t.agent.system}]:[],i=[...n,...r,...e.systemMessages];return mergeSystemInstructions(e.marker?applySystemCacheBreakpoint(i,e.marker):i)}function withTrailingUserNote(e,t){return t?[...e,createFrameworkUserMessage(`execution.retry`,t)]:[...e]}function mergeSystemInstructions(e){if(e.length===0)return;if(e.length===1)return{...e[0]};let t;for(let n of e)n.providerOptions!==void 0&&(t={...t,...n.providerOptions});let n={role:`system`,content:e.map(e=>e.content).join(`
|
|
2
|
+
|
|
3
|
+
`)};return t!==void 0&&(n.providerOptions=t),n}export{mergeSystemInstructions,modelInstructions,requestMessages,withTrailingUserNote};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ModelMessage, ToolSet, TypedToolResult } from "ai";
|
|
2
|
+
import type { HarnessStepResult } from "#harness/step-hooks.js";
|
|
3
|
+
type StepResponseMessage = HarnessStepResult["response"]["messages"][number];
|
|
4
|
+
type ToolResponsePart = Extract<ModelMessage, {
|
|
5
|
+
role: "tool";
|
|
6
|
+
}>["content"][number];
|
|
7
|
+
type ToolResultPart = Extract<ToolResponsePart, {
|
|
8
|
+
type: "tool-result";
|
|
9
|
+
}>;
|
|
10
|
+
export declare function withAccumulatedResponseMessages(input: {
|
|
11
|
+
readonly invalidInputToolCallIds?: ReadonlySet<string>;
|
|
12
|
+
readonly responseMessages: readonly StepResponseMessage[];
|
|
13
|
+
readonly stepResult: HarnessStepResult;
|
|
14
|
+
readonly toolResults?: readonly TypedToolResult<ToolSet>[];
|
|
15
|
+
}): HarnessStepResult;
|
|
16
|
+
/** True when provider history still owes a result for any assistant tool call. */
|
|
17
|
+
export declare function hasUnansweredToolCall(messages: readonly ModelMessage[]): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Appends synthesized tool results for calls that have no result anywhere in
|
|
20
|
+
* the step's response messages. Exported for its dedupe contract: a call
|
|
21
|
+
* already answered — including provider-executed results the SDK keeps
|
|
22
|
+
* inline in the assistant message — must never receive a second
|
|
23
|
+
* `tool-result`, or the next Anthropic call rejects the history with
|
|
24
|
+
* "each tool_use must have a single result".
|
|
25
|
+
*/
|
|
26
|
+
export declare function appendMissingToolResultMessages(input: {
|
|
27
|
+
readonly append: readonly ToolResultPart[];
|
|
28
|
+
readonly responseMessages: readonly StepResponseMessage[];
|
|
29
|
+
}): StepResponseMessage[];
|
|
30
|
+
/**
|
|
31
|
+
* CallIds answered anywhere in the response messages. Scans every message
|
|
32
|
+
* role: provider-executed tool results arrive inline in the *assistant*
|
|
33
|
+
* message (the SDK only moves them to a `tool` message during provider
|
|
34
|
+
* history normalization, which runs after the backfill paths), so a
|
|
35
|
+
* tool-message-only scan would let a synthesized result duplicate them.
|
|
36
|
+
*/
|
|
37
|
+
export declare function extractToolResultCallIds(messages: readonly ModelMessage[]): ReadonlySet<string>;
|
|
38
|
+
export declare function answerSkippedToolCalls(step: HarnessStepResult, tools: ToolSet): ToolResultPart[];
|
|
39
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getInvalidToolCallInputError,isInvalidToolCall}from"#harness/tool-call-input-errors.js";function withAccumulatedResponseMessages(e){let{stepResult:t}=e;return{content:t.content,finishReason:t.finishReason,...e.invalidInputToolCallIds===void 0?{}:{invalidInputToolCallIds:e.invalidInputToolCallIds},providerMetadata:t.providerMetadata,response:{...t.response,messages:[...e.responseMessages]},text:t.text,toolCalls:t.toolCalls,toolResults:e.toolResults===void 0?t.toolResults:[...e.toolResults],usage:t.usage}}function hasUnansweredToolCall(e){let t=new Set,n=new Set;for(let r of e)if(Array.isArray(r.content))for(let e of r.content)typeof e==`object`&&e&&(e.type===`tool-call`&&t.add(e.toolCallId),e.type===`tool-result`&&n.add(e.toolCallId));for(let e of t)if(!n.has(e))return!0;return!1}function appendMissingToolResultMessages(e){let t=extractToolResultCallIds(e.responseMessages),n=e.append.filter(e=>!t.has(e.toolCallId));return[...e.responseMessages,...n.length>0?[{role:`tool`,content:[...n]}]:[]]}function extractToolResultCallIds(e){let t=new Set;for(let n of e)if(Array.isArray(n.content))for(let e of n.content)typeof e==`object`&&e&&e.type===`tool-result`&&t.add(e.toolCallId);return t}function answerSkippedToolCalls(e,t){let{finishReason:n}=e;if(n===`stop`||n===`tool-calls`)return[];let r=extractToolResultCallIds(e.response.messages),i=new Set((e.content??[]).flatMap(e=>e.type===`tool-approval-request`&&e.isAutomatic!==!0?[e.toolCall.toolCallId]:[])),a=`The tool did not run because the model response ended early (finish reason: ${n}). Call the tool again if you still need its result.`;return(e.toolCalls??[]).filter(e=>t[e.toolName]?.execute!==void 0&&e.providerExecuted!==!0&&!isInvalidToolCall(e)&&getInvalidToolCallInputError({toolCall:e})===void 0&&!r.has(e.toolCallId)&&!i.has(e.toolCallId)).map(e=>({output:{type:`error-text`,value:a},toolCallId:e.toolCallId,toolName:e.toolName,type:`tool-result`}))}export{answerSkippedToolCalls,appendMissingToolResultMessages,extractToolResultCallIds,hasUnansweredToolCall,withAccumulatedResponseMessages};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retries `fn` with exponential backoff while the thrown error is
|
|
3
|
+
* classified as `"retry"`. Rethrows the last error once attempts are
|
|
4
|
+
* exhausted or the error is classified as something other than
|
|
5
|
+
* transient.
|
|
6
|
+
*/
|
|
7
|
+
export declare function runModelCallWithRetries<T>(fn: (attempt: number) => Promise<T>, diag: {
|
|
8
|
+
readonly sessionId: string;
|
|
9
|
+
readonly turnId: string;
|
|
10
|
+
readonly canRetry?: () => boolean;
|
|
11
|
+
}, signal: AbortSignal): Promise<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{setTimeout}from"node:timers/promises";import{classifyModelCallError}from"#harness/model-call/errors.js";const log=createLogger(`harness.tool-loop`);async function runModelCallWithRetries(e,t,n){for(let r=1;;r++){n.throwIfAborted();try{return await e(r)}catch(e){if(n.throwIfAborted(),t.canRetry?.()===!1||r===3||classifyModelCallError(e)!==`retry`)throw e;let i=500*2**(r-1)+Math.floor(Math.random()*250);log.warn(`model call failed transiently — retrying`,{attempt:r,delayMs:i,sessionId:t.sessionId,turnId:t.turnId,error:e}),await setTimeout(i,void 0,{signal:n})}}}export{runModelCallWithRetries};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { GenerationSteering } from "#harness/generation-steering.js";
|
|
2
|
+
import { type HarnessModelMessage } from "#harness/messages.js";
|
|
3
|
+
import { type ApprovedWork } from "#harness/hitl/index.js";
|
|
4
|
+
import { type Step } from "#harness/step/context.js";
|
|
5
|
+
import type { TurnInput } from "#harness/step/intake.js";
|
|
6
|
+
import type { HarnessStepResult } from "#harness/step-hooks.js";
|
|
7
|
+
import { type HarnessToolMap, type StepResult } from "#harness/types.js";
|
|
8
|
+
import type { InstrumentationAttempt } from "#instrumentation/runtime.js";
|
|
9
|
+
import type { EndsTurnTools } from "./tools.js";
|
|
10
|
+
/** A model step's response, for the session to act on. */
|
|
11
|
+
export interface ModelResponse {
|
|
12
|
+
readonly coordinationTools: HarnessToolMap;
|
|
13
|
+
/** How many prompt messages the model read, when no client context was spliced in. */
|
|
14
|
+
readonly durableModelPromptMessageCount?: number;
|
|
15
|
+
/** Tools that can end the turn in this step, with their `endsTurn` option. */
|
|
16
|
+
readonly endsTurnTools: EndsTurnTools;
|
|
17
|
+
readonly promptMessages: readonly HarnessModelMessage[];
|
|
18
|
+
readonly requestEnvelopeTokens?: number;
|
|
19
|
+
readonly result: HarnessStepResult;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* One model step of the open turn: the prompt it reads, the model that serves it, and the call
|
|
23
|
+
* with its retries and recoveries. `onResponse` decides what the session does with the response.
|
|
24
|
+
*
|
|
25
|
+
* Approved work runs where the AI SDK ran it, between the step's start and the model call:
|
|
26
|
+
* approved workflow calls join their runs, the budget gate passes, then approved local calls run
|
|
27
|
+
* and the model reads their results.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runModelStep(step: Step, input: {
|
|
30
|
+
readonly onResponse: (response: ModelResponse) => Promise<StepResult>;
|
|
31
|
+
readonly turn: TurnInput;
|
|
32
|
+
readonly approved: ApprovedWork;
|
|
33
|
+
readonly generation: GenerationSteering;
|
|
34
|
+
/** A child's caller and a schedule hear only the turn's real end. */
|
|
35
|
+
readonly hidesHeldText: boolean;
|
|
36
|
+
/** The attempt the step's events belong to, for instrumentation. */
|
|
37
|
+
readonly setAttemptScope: (scope: InstrumentationAttempt | undefined) => void;
|
|
38
|
+
}): Promise<StepResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveEffectiveRuntimeModel}from"./model.js";import{recoverModelCall}from"./recovery.js";import{recordModelUsage}from"./usage.js";import{ModelCaller}from"./call.js";import{reportModelCallFailure}from"./failure.js";import{HistoryStateKey}from"#context/keys.js";import{validateHarnessModelMessages}from"#harness/messages.js";import{activeTurnId}from"#harness/session-machine/view.js";import{startStep}from"#harness/session-machine/transitions.js";import{stepStartedForResolvers}from"#harness/session-machine/resolver-events.js";import{throwIfTurnAborted}from"#harness/turn-cancellation.js";import{dispatchApprovedWorkflows,enforceBudget,hasApprovedWork,humanInputContext,runApprovedLocalCalls}from"#harness/hitl/index.js";import{requireSessionModelReference}from"#harness/types.js";import{failBoundaryEvent,failModelSelection}from"#harness/step/context.js";import{buildPrompt,previewPrompt,projectPrompt,withClientContext}from"#harness/step/prompt.js";async function runModelStep(e,t){let{generation:n}=t,r=hasApprovedWork(e),i=r?previewPrompt(e,t.turn):await buildPrompt(e,t.turn),a=await selectModel(e,i);if(!(`model`in a))return a.failed;let start=t=>e.apply(startStep(e.view(),{modelId:requireSessionModelReference(e.session).id}),t),o=projectPrompt(e,i);try{await start(o)}catch(t){return failBoundaryEvent(e,t)}if(r&&await dispatchApprovedWorkflows(e,t.approved))return{next:null,session:e.session};let s=await enforceBudget(e,i.messages);if(s!==void 0)return s;if(r){let n=await runApprovedLocalCalls(e,t.approved,t.setAttemptScope);if(n!==void 0)return n;i=await buildPrompt(e,t.turn),o=projectPrompt(e,i)}let{approvedTools:c,pendingApprovalsNote:l}=humanInputContext(e),u=new ModelCaller(e,i,{approvedTools:c,generation:n,hidesHeldText:t.hidesHeldText,model:a.model,pendingApprovalsNote:l,projectedMessages:o,setAttemptScope:t.setAttemptScope,startStep:start,turnMessages:t.turn.messages}),d;try{d=await u.call({suppressStepStartedEmission:!0})}catch(t){if(u.throwIfCompactionFailed(),throwIfTurnAborted(e.config.abortSignal),n.interrupted)return u.steered();let r=await recoverModelCall({call:e=>u.call(e),error:t,sessionId:e.session.sessionId,turnId:e.position().turnId});if(u.throwIfCompactionFailed(),throwIfTurnAborted(e.config.abortSignal),n.interrupted)return u.steered();if(!(`result`in r))return reportModelCallFailure(e,r.error);d=r.result}await recordModelUsage(e,{model:a.model,result:d}),u.clearInterruptedUsage();let f;try{n.check(),f=await t.onResponse({coordinationTools:u.tools?.coordinationTools??e.config.tools,durableModelPromptMessageCount:i.clientContext===void 0||i.clientContext.messages.length===0?u.modelMessages.length:void 0,endsTurnTools:u.tools?.endsTurnTools??new Map,promptMessages:u.request.history,requestEnvelopeTokens:u.requestEnvelopeTokens,result:d})}catch(t){if(throwIfTurnAborted(e.config.abortSignal),n.interrupted)return u.steered();throw t}return e.ctx?.set(HistoryStateKey,u.request.historyState),f}async function selectModel(e,t){let{config:n,ctx:r}=e;try{if(r!==void 0&&n.dispatchDynamicModelEvent!==void 0){let i=e.position();await n.dispatchDynamicModelEvent({ctx:r,event:stepStartedForResolvers({modelId:e.session.agent.modelReference?.id??`dynamic`,sequence:i.sequence,stepIndex:i.stepIndex,turnId:activeTurnId(i)}),messages:validateHarnessModelMessages(e.projectHistory(withClientContext(t)))})}let i=await resolveEffectiveRuntimeModel({config:n,ctx:r,session:e.session});return e.session=i.session,{model:i.model}}catch(t){return{failed:await failModelSelection(e,t)}}}export{runModelStep};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ToolSet } from "ai";
|
|
2
|
+
import type { HarnessToolDefinition } from "#harness/execute-tool.js";
|
|
3
|
+
import type { GenerationSteering } from "#harness/generation-steering.js";
|
|
4
|
+
import { type AnthropicCacheMarker } from "#harness/prompt-cache.js";
|
|
5
|
+
import type { Step } from "#harness/step/context.js";
|
|
6
|
+
import { type HarnessToolMap } from "#harness/types.js";
|
|
7
|
+
/** The tools one model call offers, and the views of them the step reads afterwards. */
|
|
8
|
+
export interface ModelTools {
|
|
9
|
+
/** What the AI SDK receives. */
|
|
10
|
+
readonly effectiveTools: ToolSet;
|
|
11
|
+
readonly modelTools: ToolSet;
|
|
12
|
+
/** Every tool the model can call, by name, for presenting its calls. */
|
|
13
|
+
readonly presentationTools: HarnessToolMap;
|
|
14
|
+
/** The advertised harness tools; they decide which calls defer to the runtime. */
|
|
15
|
+
readonly coordinationTools: HarnessToolMap;
|
|
16
|
+
/** Tools that can end the turn, with their `endsTurn` option. */
|
|
17
|
+
readonly endsTurnTools: EndsTurnTools;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Assembles the tools one model call offers: authored and dynamic subagent tools, task tools,
|
|
21
|
+
* provider tools, dynamic tools (which override a same-named authored tool), and `final_output`
|
|
22
|
+
* when the turn asks for a structured result.
|
|
23
|
+
*/
|
|
24
|
+
export declare function prepareModelTools(step: Step, input: {
|
|
25
|
+
readonly approvedTools: ReadonlySet<string>;
|
|
26
|
+
readonly model: import("ai").LanguageModel;
|
|
27
|
+
readonly disabledProviderTools?: ReadonlySet<string>;
|
|
28
|
+
readonly generation: GenerationSteering;
|
|
29
|
+
readonly marker: AnthropicCacheMarker | undefined;
|
|
30
|
+
}): Promise<ModelTools>;
|
|
31
|
+
/**
|
|
32
|
+
* Wired as the agent's `onToolExecutionEnd`. On the `tool-error` branch
|
|
33
|
+
* the `error` is still the original throwable (stack/cause intact),
|
|
34
|
+
* unlike the message-only `tool-error` part the model later sees.
|
|
35
|
+
*/
|
|
36
|
+
export declare function logToolExecutionError(event: {
|
|
37
|
+
readonly toolCall: {
|
|
38
|
+
readonly toolName: string;
|
|
39
|
+
readonly toolCallId: string;
|
|
40
|
+
};
|
|
41
|
+
readonly toolOutput: {
|
|
42
|
+
readonly type: string;
|
|
43
|
+
readonly error?: unknown;
|
|
44
|
+
};
|
|
45
|
+
}): void;
|
|
46
|
+
/** Appended to the model-facing description of every tool with `endsTurn: true`. */
|
|
47
|
+
export declare const ENDS_TURN_TOOL_NOTE = "Calling this tool ends your turn once it succeeds: do not write a reply or call other tools in the same step. If it fails, you will see the error and can continue.";
|
|
48
|
+
export type EndsTurnTools = ReadonlyMap<string, NonNullable<HarnessToolDefinition["endsTurn"]>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{toModelSchema}from"#tools/schema.js";import{resolveModelProvider}from"#internal/gateway.js";import{buildDynamicSubagentTools}from"#context/dynamic-subagent-lifecycle.js";import{isTurnCancellation}from"#harness/turn-cancellation.js";import{requireSessionModelReference}from"#harness/types.js";import{withTaskTools}from"#execution/tasks/model-step.js";import{buildToolSetFromDefinitions,buildToolSetWithProviderTools}from"#harness/tools.js";import{buildDynamicTools}from"#context/build-dynamic-tools.js";import{FINAL_OUTPUT_TOOL_NAME,buildFinalOutputTool}from"#harness/final-output.js";import{applyLastToolCacheBreakpoint}from"#harness/prompt-cache.js";import{getAdvertisedTools}from"#harness/advertised-tools.js";const log=createLogger(`harness.tool-loop`);async function prepareModelTools(e,t){let{ctx:n}=e,{approvedTools:r,disabledProviderTools:i,marker:a}=t,o=withTaskTools(getAdvertisedTools({session:e.session,tools:buildHarnessToolsWithDynamicSubagents(e.config.tools,n)})),s=await buildToolSetWithProviderTools({approvedTools:r,disabledProviderTools:i,modelProvider:resolveModelProvider(t.model),modelReference:requireSessionModelReference(e.session),tools:o}),c=new Map(o);if(n!==void 0){let t=getAdvertisedTools({session:e.session,tools:buildDynamicTools(n)}),a=buildToolSetFromDefinitions({approvedTools:r,disabledProviderTools:i,tools:t});for(let[e,t]of Object.entries(a)){if(o.get(e)?.workflowId!==void 0)throw Error(`Dynamic tool "${e}" collides with a coordination-visible deferred tool.`);s[e]=t}let l=new Set;for(let e of t)l.has(e.name)||(l.add(e.name),c.set(e.name,e))}e.session.outputSchema!==void 0&&(s[FINAL_OUTPUT_TOOL_NAME]=buildFinalOutputTool(e.session.outputSchema));let l=await getAdvertisedTools({modelTools:s,session:e.session,tools:o});e.session=l.session;let{modelTools:u}=l,d=new Map;if(!e.hasDelegatedCaller&&e.session.outputSchema===void 0)for(let[e,t]of Object.entries(u)){let n=c.get(e)?.endsTurn;t.type!==`provider`&&n!==void 0&&n!==!1&&(d.set(e,n),n===!0&&(t.description=`${t.description??``}\n\n${ENDS_TURN_TOOL_NOTE}`.trimStart()))}let f=a?applyLastToolCacheBreakpoint(u,a):u;for(let e of Object.values(f)){e.inputSchema=toModelSchema(e.inputSchema,`input`),e.outputSchema!==void 0&&(e.outputSchema=toModelSchema(e.outputSchema,`output`));let n=e.execute;n!==void 0&&(e.execute=(...e)=>(t.generation.protectToolExecution(),n(...e)))}return e.frameworkToolNames=new Set([...c].filter(([,e])=>e.frameworkTool===!0).map(([e])=>e)),{coordinationTools:o,effectiveTools:f,endsTurnTools:d,modelTools:u,presentationTools:c}}function logToolExecutionError(e){e.toolOutput.type!==`tool-error`||isTurnCancellation(e.toolOutput.error)||logError(log,`tool execution failed`,e.toolOutput.error,{toolName:e.toolCall.toolName,toolCallId:e.toolCall.toolCallId})}function buildHarnessToolsWithDynamicSubagents(e,t){let n=new Map(e);if(t===void 0)return n;for(let e of buildDynamicSubagentTools(t)){if(n.has(e.name))throw Error(`Dynamic subagent "${e.name}" collides with another runtime-visible tool name.`);n.set(e.name,e)}return n}const ENDS_TURN_TOOL_NOTE=`Calling this tool ends your turn once it succeeds: do not write a reply or call other tools in the same step. If it fails, you will see the error and can continue.`;export{ENDS_TURN_TOOL_NOTE,logToolExecutionError,prepareModelTools};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LanguageModel, ProviderMetadata } from "ai";
|
|
2
|
+
import type { HarnessStepResult } from "#harness/step-hooks.js";
|
|
3
|
+
import { type TokenUsageDelta } from "#harness/turn-tag-state.js";
|
|
4
|
+
import type { Step } from "#harness/step/context.js";
|
|
5
|
+
/**
|
|
6
|
+
* The model's gateway id, or `undefined` for a model without a string `provider`, such as a
|
|
7
|
+
* test double, so a missing field never throws into the tool loop.
|
|
8
|
+
*/
|
|
9
|
+
export declare function gatewayModelId(model: LanguageModel): string | undefined;
|
|
10
|
+
export declare function extractTokenUsageDelta(input: {
|
|
11
|
+
readonly costUsd: number | undefined;
|
|
12
|
+
readonly usage: HarnessStepResult["usage"] | undefined;
|
|
13
|
+
}): TokenUsageDelta | undefined;
|
|
14
|
+
export declare function extractGatewayCostUsd(providerMetadata: ProviderMetadata | undefined): number | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Tags the turn's workflow run with the model and the turn's running token totals. Each model
|
|
17
|
+
* step is its own workflow step and attributes are last-write-wins, so the running total, kept in
|
|
18
|
+
* session state, is what reaches the dashboard. Best-effort: tagging never breaks the loop.
|
|
19
|
+
*/
|
|
20
|
+
export declare function recordModelUsage(step: Step, input: {
|
|
21
|
+
readonly model: LanguageModel;
|
|
22
|
+
readonly result: HarnessStepResult;
|
|
23
|
+
}): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{accumulateTurnUsage,getTurnUsageState,setTurnUsageState}from"#harness/turn-tag-state.js";import{setEveAttributes}from"#runtime/attributes/emit.js";function gatewayModelId(e){try{return formatLanguageModelGatewayId(e)}catch{return}}function extractTokenUsageDelta(e){let t=e.usage;if(t!==void 0||e.costUsd!==void 0)return{cacheReadTokens:t?.inputTokenDetails?.cacheReadTokens,cacheWriteTokens:t?.inputTokenDetails?.cacheWriteTokens,costUsd:e.costUsd,inputTokens:t?.inputTokens,outputTokens:t?.outputTokens}}function extractGatewayCostUsd(e){let t=readGatewayMetadata(e)?.cost;if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`){let e=Number(t);return Number.isFinite(e)?e:void 0}}function readGatewayMetadata(e){let t=e?.gateway;return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}async function recordModelUsage(e,t){let n=accumulateTurnUsage({previous:getTurnUsageState(e.session.state),turnId:e.position().turnId,usage:extractTokenUsageDelta({costUsd:extractGatewayCostUsd(t.result.providerMetadata),usage:t.result.usage})});e.session=setTurnUsageState(e.session,n),await setEveAttributes({"$eve.model":gatewayModelId(t.model),"$eve.input_tokens":n.inputTokens,"$eve.output_tokens":n.outputTokens,"$eve.cache_read_tokens":n.cacheReadTokens,"$eve.cache_write_tokens":n.cacheWriteTokens,"$eve.cost_usd":n.sawCost?n.costUsd:void 0,"$eve.tool_count":e.config.tools.size})}export{extractGatewayCostUsd,extractTokenUsageDelta,gatewayModelId,recordModelUsage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TurnPosition } from "#harness/session-machine/view.js";
|
|
2
2
|
import type { HarnessEmitFn } from "#harness/types.js";
|
|
3
3
|
import type { JsonObject } from "#shared/json.js";
|
|
4
4
|
/**
|
|
@@ -20,4 +20,4 @@ export declare function reportNestedToolAction(parentCallId: string, action: Nes
|
|
|
20
20
|
* `actions.requested` and `action.result` pair. Call ids derive from the
|
|
21
21
|
* parent's, so a re-run step reports the same ids.
|
|
22
22
|
*/
|
|
23
|
-
export declare function emitNestedToolActions(emitFn: HarnessEmitFn, state: Pick<
|
|
23
|
+
export declare function emitNestedToolActions(emitFn: HarnessEmitFn, state: Pick<TurnPosition, "sequence" | "stepIndex" | "turnId">, parentCallId: string): Promise<void>;
|
|
@@ -5,7 +5,7 @@ import type { WebSearchProvider } from "#shared/web-search.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* The provider backend resolved for one web search tool invocation.
|
|
7
7
|
*/
|
|
8
|
-
type WebSearchBackend = "anthropic" | "exa" | "google" | "openai" | "parallel";
|
|
8
|
+
type WebSearchBackend = "anthropic" | "exa" | "google" | "openai" | "parallel" | "browserbase";
|
|
9
9
|
/**
|
|
10
10
|
* Returns the framework tool name that produced an upstream provider tool
|
|
11
11
|
* `type`, or `null` when the type is not one we know how to remove.
|
|
@@ -19,7 +19,7 @@ export declare function resolveFrameworkToolFromUpstreamType(type: string): stri
|
|
|
19
19
|
* Returns the output schema for the provider-managed web search tool that
|
|
20
20
|
* will be injected for `backend`.
|
|
21
21
|
*/
|
|
22
|
-
export declare function resolveWebSearchOutputSchema(backend: WebSearchBackend): JsonObject;
|
|
22
|
+
export declare function resolveWebSearchOutputSchema(backend: Exclude<WebSearchBackend, "browserbase">): JsonObject;
|
|
23
23
|
/**
|
|
24
24
|
* Determines the web search backend for a model reference.
|
|
25
25
|
*
|
|
@@ -28,8 +28,12 @@ export declare function resolveWebSearchOutputSchema(backend: WebSearchBackend):
|
|
|
28
28
|
* - Direct/BYO Anthropic models: native Anthropic search
|
|
29
29
|
* - Direct/BYO Google models: native Google search grounding
|
|
30
30
|
* - Other BYO models: not available (returns `null`)
|
|
31
|
+
*
|
|
32
|
+
* `modelProvider` is the provider of the resolved AI SDK model. It is needed
|
|
33
|
+
* for live dynamic selections because their runtime reference has no source
|
|
34
|
+
* metadata to distinguish a direct provider from AI Gateway.
|
|
31
35
|
*/
|
|
32
|
-
export declare function resolveWebSearchBackend(modelRef: RuntimeModelReference, gatewayProvider?: WebSearchProvider): WebSearchBackend | null;
|
|
36
|
+
export declare function resolveWebSearchBackend(modelRef: RuntimeModelReference, gatewayProvider?: WebSearchProvider, modelProvider?: string): WebSearchBackend | null;
|
|
33
37
|
/**
|
|
34
38
|
* Constructs the AI SDK provider tool for web search based on the resolved
|
|
35
39
|
* backend. Called once per harness step when web search is enabled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsonSchema}from"ai";import{WEB_SEARCH_ANTHROPIC_OUTPUT_SCHEMA,WEB_SEARCH_EXA_OUTPUT_SCHEMA,WEB_SEARCH_GOOGLE_OUTPUT_SCHEMA,WEB_SEARCH_OPENAI_OUTPUT_SCHEMA,WEB_SEARCH_PARALLEL_OUTPUT_SCHEMA,WEB_SEARCH_TOOL_NAME}from"#harness/provider-tool-schemas.js";const UPSTREAM_TOOL_TYPE_TO_FRAMEWORK_NAME={web_search_20250305:WEB_SEARCH_TOOL_NAME};function resolveFrameworkToolFromUpstreamType(e){return UPSTREAM_TOOL_TYPE_TO_FRAMEWORK_NAME[e]??null}function resolveWebSearchOutputSchema(e){switch(e){case`anthropic`:return WEB_SEARCH_ANTHROPIC_OUTPUT_SCHEMA;case`exa`:return WEB_SEARCH_EXA_OUTPUT_SCHEMA;case`google`:return WEB_SEARCH_GOOGLE_OUTPUT_SCHEMA;case`openai`:return WEB_SEARCH_OPENAI_OUTPUT_SCHEMA;case`parallel`:return WEB_SEARCH_PARALLEL_OUTPUT_SCHEMA}}function resolveWebSearchBackend(e,t=`exa
|
|
1
|
+
import{jsonSchema}from"ai";import{WEB_SEARCH_ANTHROPIC_OUTPUT_SCHEMA,WEB_SEARCH_EXA_OUTPUT_SCHEMA,WEB_SEARCH_GOOGLE_OUTPUT_SCHEMA,WEB_SEARCH_OPENAI_OUTPUT_SCHEMA,WEB_SEARCH_PARALLEL_OUTPUT_SCHEMA,WEB_SEARCH_TOOL_NAME}from"#harness/provider-tool-schemas.js";const UPSTREAM_TOOL_TYPE_TO_FRAMEWORK_NAME={web_search_20250305:WEB_SEARCH_TOOL_NAME};function resolveFrameworkToolFromUpstreamType(e){return UPSTREAM_TOOL_TYPE_TO_FRAMEWORK_NAME[e]??null}function resolveWebSearchOutputSchema(e){switch(e){case`anthropic`:return WEB_SEARCH_ANTHROPIC_OUTPUT_SCHEMA;case`exa`:return WEB_SEARCH_EXA_OUTPUT_SCHEMA;case`google`:return WEB_SEARCH_GOOGLE_OUTPUT_SCHEMA;case`openai`:return WEB_SEARCH_OPENAI_OUTPUT_SCHEMA;case`parallel`:return WEB_SEARCH_PARALLEL_OUTPUT_SCHEMA}}function resolveWebSearchBackend(e,t=`exa`,n){let r=n?.split(`.`)[0]??(e.source===void 0?`gateway`:e.id.split(`/`)[0]??``);return r===`gateway`?t:r===`openai`||r.startsWith(`openai.`)?`openai`:r===`anthropic`||r.startsWith(`anthropic.`)?`anthropic`:r===`google`||r.startsWith(`google.`)?`google`:null}async function resolveWebSearchProviderTool(e){switch(e){case`browserbase`:{let{gateway:e}=await import(`ai`);return e.tools.browserbaseSearch()}case`openai`:{let{openai:t}=await import(`#compiled/@ai-sdk/openai/index.js`);return attachWebSearchOutputSchema(t.tools.webSearch({}),e)}case`anthropic`:{let{anthropic:t}=await import(`#compiled/@ai-sdk/anthropic/index.js`);return attachWebSearchOutputSchema(t.tools.webSearch_20250305(),e)}case`google`:{let{google:t}=await import(`#compiled/@ai-sdk/google/index.js`);return attachWebSearchOutputSchema(t.tools.googleSearch({}),e)}case`exa`:{let{gateway:t}=await import(`ai`);return attachWebSearchOutputSchema(t.tools.exaSearch({contents:{highlights:{maxCharacters:1e3}},numResults:10}),e)}case`parallel`:{let{gateway:t}=await import(`ai`);return attachWebSearchOutputSchema(t.tools.parallelSearch(),e)}}}function attachWebSearchOutputSchema(e,t){return{...e,outputSchema:jsonSchema(resolveWebSearchOutputSchema(t))}}export{resolveFrameworkToolFromUpstreamType,resolveWebSearchBackend,resolveWebSearchOutputSchema,resolveWebSearchProviderTool};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { SubagentInputRequestHookPayload } from "#channel/types.js";
|
|
2
|
-
import type { PendingInputBatchEvent } from "#harness/
|
|
2
|
+
import type { StepCoordinates as PendingInputBatchEvent } from "#harness/session-machine/view.js";
|
|
3
3
|
import type { HarnessSessionBase, SessionStateMap } from "#harness/types.js";
|
|
4
4
|
import { type InputOption, type InputRequestKind } from "#shared/input.js";
|
|
5
5
|
import { type SessionInboxAddress } from "#execution/session-inbox/address.js";
|
|
6
6
|
import type { RemoteAgentBinding } from "#eve-channel/support.js";
|
|
7
|
-
import { type InputResolvedStreamEvent } from "#protocol/message.js";
|
|
8
7
|
/**
|
|
9
8
|
* Marks a request as a workflow tool run's `ctx.ask()` question, rather than a
|
|
10
9
|
* child session's. Its answer goes to the run's control hook, which carries
|
|
@@ -79,17 +78,10 @@ export declare function upsertProxyInputRequestState(input: {
|
|
|
79
78
|
readonly forChildContinuationToken: string;
|
|
80
79
|
readonly state: SessionStateMap | undefined;
|
|
81
80
|
}): SessionStateMap | undefined;
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
* returns the `input.resolved` events that report them `cancelled` so
|
|
85
|
-
* channels stop offering them. Publish the events as relayed.
|
|
86
|
-
*/
|
|
87
|
-
export declare function withdrawProxyInputRequests<T extends {
|
|
81
|
+
/** Removes every proxy route the predicate selects. */
|
|
82
|
+
export declare function clearProxyInputRequestsWhere<T extends {
|
|
88
83
|
readonly state?: SessionStateMap;
|
|
89
|
-
}>(session: T, select: (
|
|
90
|
-
readonly events: readonly InputResolvedStreamEvent[];
|
|
91
|
-
readonly session: T;
|
|
92
|
-
};
|
|
84
|
+
}>(session: T, select: (route: ProxyInputRequest, requestId: string) => boolean): T;
|
|
93
85
|
/** Removes only the request IDs whose responses were successfully forwarded. */
|
|
94
86
|
export declare function retireProxyInputRequests<T extends {
|
|
95
87
|
readonly state?: SessionStateMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isSessionInboxAddress}from"#execution/session-inbox/address.js";import{inputOptionSchema}from"#shared/input.js";
|
|
1
|
+
import{isSessionInboxAddress}from"#execution/session-inbox/address.js";import{inputOptionSchema}from"#shared/input.js";const PROXY_INPUT_REQUESTS_KEY=`eve.runtime.proxyInputRequests`,PROXY_INPUT_REQUEST_KINDS={question:!0,"session-limit":!0,"tool-approval":!0};function getProxyInputRequests(e){return new Map(Object.entries(readMap(e)))}function hasProxyInputRequests(e){for(let t of Object.keys(readMap(e)))return!0;return!1}function upsertProxyInputRequests(e){return{...e.session,state:upsertProxyInputRequestState({entries:e.entries,forChildContinuationToken:e.forChildContinuationToken,inputSource:e.inputSource,state:e.session.state})}}function upsertProxyInputRequestState(e){let t={};for(let[n,r]of Object.entries(readMap(e.state)))(r.childContinuationToken!==e.forChildContinuationToken||r.inputSource!==e.inputSource)&&(t[n]=r);for(let[n,r]of e.entries)t[n]=r;let n={...e.state};return Object.keys(t).length===0?delete n[PROXY_INPUT_REQUESTS_KEY]:n[PROXY_INPUT_REQUESTS_KEY]=t,Object.keys(n).length>0?n:void 0}function clearProxyInputRequestsWhere(e,t){return retireProxyInputRequests(e,Object.entries(readMap(e.state)).filter(([e,n])=>t(n,e)).map(([e])=>e))}function retireProxyInputRequests(e,t){let n={...readMap(e.state)},r=!1;for(let e of t)Object.hasOwn(n,e)&&(delete n[e],r=!0);return r?writeMap(e,n):e}function toProxyInputRequestEntries(e){let t={approvalRequestIds:e.event.requests.flatMap(e=>e.kind===`tool-approval`?[e.requestId]:[]),requestIds:e.event.requests.map(e=>e.requestId)},n={sequence:e.event.sequence,stepIndex:e.event.stepIndex,turnId:e.event.turnId};return e.event.requests.map(r=>{let i={batch:t,childContinuationToken:e.childContinuationToken,...e.inputSource!==void 0&&{inputSource:e.inputSource},...e.remote!==void 0&&{remote:e.remote},event:n,kind:r.kind};return r.kind===`question`&&(i.question={...r.allowFreeform!==void 0&&{allowFreeform:r.allowFreeform},...r.options!==void 0&&{options:[...r.options]}}),e.childSessionInbox?.sessionId===e.childSessionId&&(i.childSessionInbox=e.childSessionInbox),[r.requestId,i]})}function readMap(e){let t=e?.[PROXY_INPUT_REQUESTS_KEY];if(typeof t!=`object`||!t||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){let t=parseProxyInputRequest(r,e);t!==void 0&&(n[e]=t)}return n}function writeMap(e,t){let n={...e.state};return Object.keys(t).length===0?(delete n[PROXY_INPUT_REQUESTS_KEY],{...e,state:Object.keys(n).length>0?n:void 0}):(n[PROXY_INPUT_REQUESTS_KEY]=t,{...e,state:n})}function parseProxyInputRequest(e,t){if(typeof e!=`object`||!e||Array.isArray(e)||!(`childContinuationToken`in e)||!(`kind`in e)||typeof e.childContinuationToken!=`string`||!isInputRequestKind(e.kind))return;let n=`remote`in e?parseRemoteAgentBinding(e.remote):void 0;if(`remote`in e&&n===void 0)return;let r=`inputSource`in e?e.inputSource:void 0;if(r!==void 0&&(typeof r!=`string`||r.length===0))return;let i=`event`in e?parseInputRequestEvent(e.event):void 0;if(i===void 0)return;let a=`batch`in e?parseProxyInputRequestBatch(e.batch):void 0,o=`workflowAsk`in e?parseWorkflowAskRoute(e.workflowAsk):void 0;if(`workflowAsk`in e&&o===void 0)return;let s=`runId`in e?e.runId:void 0;if(s!==void 0&&(typeof s!=`string`||s.length===0))return;let c=`question`in e?parseProxyInputQuestion(e.question):void 0;if(`question`in e&&c===void 0)return;let l=`childSessionInbox`in e?e.childSessionInbox:void 0;if(l!==void 0&&!isSessionInboxAddress(l))return;let u={childContinuationToken:e.childContinuationToken,event:i,kind:e.kind};return typeof r==`string`&&(u.inputSource=r),n!==void 0&&(u.remote=n),o!==void 0&&(u.workflowAsk=o),typeof s==`string`&&(u.runId=s),l!==void 0&&(u.childSessionInbox=l),a!==void 0&&a.requestIds.includes(t)&&(u.batch=a),c!==void 0&&(u.question=c),u}function parseInputRequestEvent(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`sequence`),n=Reflect.get(e,`stepIndex`),r=Reflect.get(e,`turnId`);if(typeof t==`number`&&typeof n==`number`&&typeof r==`string`)return{sequence:t,stepIndex:n,turnId:r}}function parseWorkflowAskRoute(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`control`);if(typeof t!=`string`||t.length===0)return;let n=parseProxyInputQuestion(Reflect.get(e,`question`));if(n!==void 0)return{control:t,question:n}}function parseRemoteAgentBinding(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`name`),n=Reflect.get(e,`url`),r=Reflect.get(e,`resolverId`),i=Reflect.get(e,`forwardPrincipal`),a=Reflect.get(e,`sessionId`);if(typeof t==`string`&&t&&typeof n==`string`&&n&&typeof a==`string`&&a&&(r===void 0||typeof r==`string`&&r)&&(i===void 0||typeof i==`boolean`))return{name:t,url:n,sessionId:a,...r!==void 0&&{resolverId:r},...i!==void 0&&{forwardPrincipal:i}}}function parseProxyInputQuestion(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t={},n=Reflect.get(e,`allowFreeform`);if(n!==void 0){if(typeof n!=`boolean`)return;t.allowFreeform=n}let r=Reflect.get(e,`options`);if(r!==void 0){let e=inputOptionSchema.array().safeParse(r);if(!e.success)return;t.options=e.data}return t}function parseProxyInputRequestBatch(e){if(typeof e!=`object`||!e||Array.isArray(e)||!(`approvalRequestIds`in e)||!(`requestIds`in e)||!isStringArray(e.approvalRequestIds)||!isStringArray(e.requestIds))return;let t=new Set(e.requestIds);if(!(t.size!==e.requestIds.length||e.approvalRequestIds.some(e=>!t.has(e))))return{approvalRequestIds:e.approvalRequestIds,requestIds:e.requestIds}}function isStringArray(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function isInputRequestKind(e){return typeof e==`string`&&Object.hasOwn(PROXY_INPUT_REQUEST_KINDS,e)}export{clearProxyInputRequestsWhere,getProxyInputRequests,hasProxyInputRequests,retireProxyInputRequests,toProxyInputRequestEntries,upsertProxyInputRequestState,upsertProxyInputRequests};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ModelMessage } from "ai";
|
|
2
|
+
import { type AuthorizationChallenge } from "#harness/authorization.js";
|
|
3
|
+
import type { HarnessSessionBase, SessionStateMap } from "#harness/types.js";
|
|
4
|
+
import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
5
|
+
import type { SessionProjection } from "#protocol/session-projection.js";
|
|
6
|
+
import { type TurnState } from "./state.js";
|
|
7
|
+
import type { SessionView } from "./view.js";
|
|
8
|
+
/** What a transition returns. Nothing else changes session state. */
|
|
9
|
+
export interface Transition {
|
|
10
|
+
readonly turn: TurnState;
|
|
11
|
+
readonly events: readonly UnstampedMessageStreamEvent[];
|
|
12
|
+
/** Messages the transition commits to the end of history. */
|
|
13
|
+
readonly commit?: readonly ModelMessage[];
|
|
14
|
+
/** The transition empties history, as `clear` does. */
|
|
15
|
+
readonly clearsHistory?: true;
|
|
16
|
+
/** Every sign-in the session waits on once the transition applies; `[]` withdraws them all. */
|
|
17
|
+
readonly signIns?: readonly AuthorizationChallenge[];
|
|
18
|
+
}
|
|
19
|
+
/** Publishes one event; `messages` is the conversation hooks see with it. */
|
|
20
|
+
export type Publish = (event: UnstampedMessageStreamEvent, messages?: readonly ModelMessage[]) => Promise<void>;
|
|
21
|
+
export declare function sessionView(projection: SessionProjection, state: SessionStateMap | undefined): SessionView;
|
|
22
|
+
/**
|
|
23
|
+
* Publishes a transition's events, then saves what it changed. A transition that changes history
|
|
24
|
+
* needs a session restored with it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function applyTransition<T extends HarnessSessionBase>(session: T, transition: Transition, publish: Publish, messages?: readonly ModelMessage[]): Promise<T>;
|
|
27
|
+
/** Drops the private records whose owner the projection shows closed. */
|
|
28
|
+
export declare function dropClosedRecords<T extends HarnessSessionBase>(session: T, projection: SessionProjection): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readTurnState,writeTurnState}from"./state.js";import{validateHarnessModelMessages}from"#harness/messages.js";import{getSessionUsage}from"#harness/turn-tag-state.js";import{clearProxyInputRequestsWhere,getProxyInputRequests}from"#harness/proxy-input-requests.js";import{clearPendingAuthorization,getPendingAuthorization,setPendingAuthorization}from"#harness/authorization.js";function sessionView(e,t){return{projection:e,relayedRequestIds:new Set(getProxyInputRequests(t).keys()),signIns:getPendingAuthorization(t)?.challenges??[],turn:readTurnState(t),usage:getSessionUsage({state:t})}}const READS_HISTORY=new Set([`turn.started`,`step.started`,`turn.completed`]);async function applyTransition(e,t,n,r){for(let e of t.events)await n(e,READS_HISTORY.has(e.type)?r:void 0);let i=t.signIns===void 0?e.state:t.signIns.length===0?clearPendingAuthorization(e.state):setPendingAuthorization(clearPendingAuthorization(e.state),{challenges:t.signIns}),a=writeTurnState({...e,state:i},t.turn),o=t.commit??[];if(t.clearsHistory!==!0&&o.length===0)return a;if(!(`history`in e))throw Error(`A transition that changes history needs the session's history.`);let{history:s}=e,c=t.clearsHistory?[]:validateHarnessModelMessages([...s,...o]);return{...a,history:c}}function dropClosedRecords(e,t){return clearProxyInputRequestsWhere(e,(e,n)=>{let r=t.inputs[n];return r===void 0||r.status===`settled`})}export{applyTransition,dropClosedRecords,sessionView};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ContextReader } from "#context/key.js";
|
|
2
|
+
import type { HarnessSessionBase, SessionStateMap } from "#harness/types.js";
|
|
3
|
+
import { type SessionProjection } from "#protocol/session-projection.js";
|
|
4
|
+
import type { MessageStreamEvent, UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
5
|
+
export declare function enterSessionProjection(ctx: ContextReader, state: SessionStateMap | undefined): void;
|
|
6
|
+
/** Enters the stored projection unless this step already did. */
|
|
7
|
+
export declare function ensureSessionProjection(ctx: ContextReader, state: SessionStateMap | undefined): void;
|
|
8
|
+
/** The projection as of the last event the current step published. */
|
|
9
|
+
export declare function currentProjection(ctx?: ContextReader | undefined): SessionProjection;
|
|
10
|
+
/** The step's live projection, or the session's stored one when no step entered it. */
|
|
11
|
+
export declare function projectionFor(ctx: ContextReader, state: SessionStateMap | undefined): SessionProjection;
|
|
12
|
+
export declare function recordPublishedEvent(ctx: ContextReader, event: MessageStreamEvent | UnstampedMessageStreamEvent): void;
|
|
13
|
+
export declare function saveSessionProjection<T extends HarnessSessionBase>(session: T, ctx: ContextReader): T;
|
|
14
|
+
/**
|
|
15
|
+
* The session saves the lifecycle its steps read. Calls and tasks are for the stream's readers,
|
|
16
|
+
* which fold them from the events, and their outputs can be large, so the checkpoint omits them.
|
|
17
|
+
*/
|
|
18
|
+
export declare function saveProjection<T extends HarnessSessionBase>(session: T, projection: SessionProjection): T;
|
|
19
|
+
/** The projection one step reads and folds what it publishes into. */
|
|
20
|
+
export interface StepProjection {
|
|
21
|
+
read(): SessionProjection;
|
|
22
|
+
/** Folds an event no publish sink folded: the step runs without one. */
|
|
23
|
+
record(event: UnstampedMessageStreamEvent): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A step's projection: the context's live one, which the publish sink folds, or, for a step
|
|
27
|
+
* that runs without a context, a detached one the step folds itself.
|
|
28
|
+
*/
|
|
29
|
+
export declare function stepProjection(ctx: ContextReader | undefined, state: SessionStateMap | undefined): StepProjection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SESSION_PROJECTION_STATE_KEY,storedProjection}from"./view.js";import{foldSession,pruneSessionProjection}from"#protocol/session-projection.js";import{contextStorage}from"#context/container.js";const liveProjections=new WeakMap;function enterSessionProjection(e,t){liveProjections.set(e,{projection:storedProjection(t)})}function ensureSessionProjection(e,t){liveProjections.has(e)||enterSessionProjection(e,t)}function currentProjection(e=contextStorage.getStore()){let t=e===void 0?void 0:liveProjections.get(e);if(t===void 0)throw Error(`Session lifecycle requires an initialized projection.`);return t.projection}function projectionFor(e,t){return liveProjections.get(e)?.projection??storedProjection(t)}function recordPublishedEvent(e,t){let n=liveProjections.get(e);if(n===void 0)throw Error(`Session publication requires an initialized projection.`);let r=foldSession(n.projection,t);n.projection=t.type===`session.waiting`?pruneSessionProjection(r):r}function saveSessionProjection(e,t){return saveProjection(e,currentProjection(t))}function saveProjection(e,t){let n={...t,calls:{},tasks:{}};return{...e,state:{...e.state,[SESSION_PROJECTION_STATE_KEY]:n}}}function stepProjection(e,t){if(e!==void 0)return ensureSessionProjection(e,t),{read:()=>currentProjection(e),record:t=>recordPublishedEvent(e,t)};let n=storedProjection(t);return{read:()=>n,record(e){let t=foldSession(n,e);n=e.type===`session.waiting`?pruneSessionProjection(t):t}}}export{currentProjection,ensureSessionProjection,enterSessionProjection,projectionFor,recordPublishedEvent,saveProjection,saveSessionProjection,stepProjection};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AuthorizationCompletedStreamEvent, type InputResolvedStreamEvent } from "#protocol/message.js";
|
|
2
|
+
import type { SessionAuthorization, SessionInput } from "#protocol/session-projection.js";
|
|
3
|
+
/** Reports an open request withdrawn: nobody may answer it anymore. */
|
|
4
|
+
export declare function inputWithdrawn(input: SessionInput): InputResolvedStreamEvent;
|
|
5
|
+
/** Reports an open sign-in withdrawn, as declined: its callback no longer resumes anything. */
|
|
6
|
+
export declare function signInWithdrawn(attempt: SessionAuthorization, reason: string): AuthorizationCompletedStreamEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createAuthorizationCompletedEvent,createInputResolvedEvent}from"#protocol/message.js";function inputWithdrawn(e){return createInputResolvedEvent({resolutions:[{kind:e.request.kind,outcome:`cancelled`,requestId:e.request.requestId}],sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId})}function signInWithdrawn(e,t){return createAuthorizationCompletedEvent({attemptId:e.attemptId,candidateId:e.candidateId,name:e.name,outcome:`declined`,principalId:e.principalId,reason:t,sequence:e.sequence,stepIndex:e.stepIndex,taskId:e.taskId,turnId:e.turnId})}export{inputWithdrawn,signInWithdrawn};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type RuntimeIdentity } from "#protocol/message.js";
|
|
2
|
+
export declare function sessionStartedForResolvers(runtime?: RuntimeIdentity): import("#protocol/message.js").SessionStartedStreamEvent;
|
|
3
|
+
export declare function turnStartedForResolvers(turn: {
|
|
4
|
+
readonly sequence: number;
|
|
5
|
+
readonly turnId: string;
|
|
6
|
+
}): import("#protocol/message.js").TurnStartedStreamEvent;
|
|
7
|
+
export declare function stepStartedForResolvers(step: {
|
|
8
|
+
readonly modelId: string;
|
|
9
|
+
readonly sequence: number;
|
|
10
|
+
readonly stepIndex: number;
|
|
11
|
+
readonly turnId: string;
|
|
12
|
+
}): import("#protocol/message.js").StepStartedStreamEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSessionStartedEvent,createStepStartedEvent,createTurnStartedEvent}from"#protocol/message.js";function sessionStartedForResolvers(e){return createSessionStartedEvent({runtime:e})}function turnStartedForResolvers(e){return createTurnStartedEvent(e)}function stepStartedForResolvers(e){return createStepStartedEvent(e)}export{sessionStartedForResolvers,stepStartedForResolvers,turnStartedForResolvers};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ModelMessage } from "ai";
|
|
2
|
+
import type { SessionAuthContext } from "#channel/types.js";
|
|
3
|
+
import type { SessionStateMap, StepInput } from "#harness/types.js";
|
|
4
|
+
import type { RuntimeWorkflowTaskRequest } from "#shared/action-types.js";
|
|
5
|
+
import type { InputRequest } from "#shared/input.js";
|
|
6
|
+
/** The coordinates of the model step a suspended step parked from. */
|
|
7
|
+
export interface StepCoordinates {
|
|
8
|
+
readonly sequence: number;
|
|
9
|
+
readonly stepIndex: number;
|
|
10
|
+
readonly turnId: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A model step whose calls can't all settle yet: some await an approval, others the runtime.
|
|
14
|
+
* Its response stays out of history until every call it made has a result there, so a call
|
|
15
|
+
* never reaches the model without its result.
|
|
16
|
+
*/
|
|
17
|
+
export interface SuspendedStep {
|
|
18
|
+
readonly event: StepCoordinates;
|
|
19
|
+
/** The withheld response. Results join it as they arrive. */
|
|
20
|
+
readonly messages: readonly ModelMessage[];
|
|
21
|
+
/** Approvals the step still waits on. */
|
|
22
|
+
readonly requests: readonly InputRequest[];
|
|
23
|
+
/**
|
|
24
|
+
* Calls a person approved that haven't run. They run when the turn next calls the model, after
|
|
25
|
+
* its step starts and its budget allows it, as calls the model makes do.
|
|
26
|
+
*/
|
|
27
|
+
readonly approved?: readonly InputRequest[];
|
|
28
|
+
/** Workflow and agent calls the runtime runs for the step. */
|
|
29
|
+
readonly tasks: readonly RuntimeWorkflowTaskRequest[];
|
|
30
|
+
/** Who approved each task an approval started, by call id: the task runs as them. */
|
|
31
|
+
readonly approvers?: Readonly<Record<string, SessionAuthContext>>;
|
|
32
|
+
readonly responseAuthRequiredRequestIds?: readonly string[];
|
|
33
|
+
/** The caller whose turn parked the step; `null` when unauthenticated. */
|
|
34
|
+
readonly requester?: SessionAuthContext | null;
|
|
35
|
+
}
|
|
36
|
+
export interface TurnState {
|
|
37
|
+
/** Input that arrived before it could run: a partial answer, or input behind a policy pass. */
|
|
38
|
+
readonly queued?: StepInput;
|
|
39
|
+
readonly suspended: readonly SuspendedStep[];
|
|
40
|
+
/** Approval keys a `once()` approval granted for the rest of the session. */
|
|
41
|
+
readonly grants: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
export declare const EMPTY_TURN_STATE: TurnState;
|
|
44
|
+
export declare function readTurnState(state: SessionStateMap | undefined): TurnState;
|
|
45
|
+
export declare function writeTurnState<T extends {
|
|
46
|
+
readonly state?: SessionStateMap;
|
|
47
|
+
}>(session: T, turn: TurnState): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const TURN_STATE_KEY=`eve.harness.turnState`,EMPTY_TURN_STATE={grants:[],suspended:[]};function readTurnState(e){return e?.[TURN_STATE_KEY]??EMPTY_TURN_STATE}function writeTurnState(e,t){let n={...e.state};return t.suspended.length===0&&t.queued===void 0&&t.grants.length===0?delete n[TURN_STATE_KEY]:n[TURN_STATE_KEY]=t,{...e,state:Object.keys(n).length===0?void 0:n}}export{EMPTY_TURN_STATE,readTurnState,writeTurnState};
|