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
|
@@ -681,6 +681,464 @@ function isTurnFailureEvent(event) {
|
|
|
681
681
|
return event.type === "session.failed" || event.type === "step.failed" || event.type === "turn.failed";
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/protocol/session-projection.ts
|
|
686
|
+
function initialSessionProjection() {
|
|
687
|
+
return {
|
|
688
|
+
authorizations: {},
|
|
689
|
+
calls: {},
|
|
690
|
+
candidates: {},
|
|
691
|
+
inputs: {},
|
|
692
|
+
nextSequence: 0,
|
|
693
|
+
tasks: {},
|
|
694
|
+
turns: {}
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function updateTurn(state, turnId, update) {
|
|
698
|
+
const turn = state.turns[turnId];
|
|
699
|
+
if (turn === void 0) return state;
|
|
700
|
+
const next = update(turn);
|
|
701
|
+
return next === turn ? state : {
|
|
702
|
+
...state,
|
|
703
|
+
turns: {
|
|
704
|
+
...state.turns,
|
|
705
|
+
[turnId]: next
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
function putTask(state, task) {
|
|
710
|
+
return state.tasks[task.taskId] === task ? state : {
|
|
711
|
+
...state,
|
|
712
|
+
tasks: {
|
|
713
|
+
...state.tasks,
|
|
714
|
+
[task.taskId]: task
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
function putTaskCall(task, call) {
|
|
719
|
+
return task.calls[call.callId] === call ? task : {
|
|
720
|
+
...task,
|
|
721
|
+
calls: {
|
|
722
|
+
...task.calls,
|
|
723
|
+
[call.callId]: call
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
function putCall(state, call) {
|
|
728
|
+
return state.calls[call.callId] === call ? state : {
|
|
729
|
+
...state,
|
|
730
|
+
calls: {
|
|
731
|
+
...state.calls,
|
|
732
|
+
[call.callId]: call
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
function updateTask(state, taskId, update) {
|
|
737
|
+
const task = state.tasks[taskId];
|
|
738
|
+
if (task === void 0) return state;
|
|
739
|
+
return putTask(state, update(task));
|
|
740
|
+
}
|
|
741
|
+
function updateCall(state, callId, update) {
|
|
742
|
+
const call = state.calls[callId];
|
|
743
|
+
if (call === void 0) return state;
|
|
744
|
+
return putCall(state, update(call));
|
|
745
|
+
}
|
|
746
|
+
const SETTLED_CALL_STATUSES = /* @__PURE__ */ new Set([
|
|
747
|
+
"completed",
|
|
748
|
+
"failed",
|
|
749
|
+
"rejected",
|
|
750
|
+
"cancelled"
|
|
751
|
+
]);
|
|
752
|
+
function isSettledCallStatus(status) {
|
|
753
|
+
return SETTLED_CALL_STATUSES.has(status);
|
|
754
|
+
}
|
|
755
|
+
function settleCall(call, status, error) {
|
|
756
|
+
if (call.taskId !== void 0 || isSettledCallStatus(call.status)) return call;
|
|
757
|
+
const { requestId: _requestId, error: _error, ...rest } = call;
|
|
758
|
+
const settled = {
|
|
759
|
+
...rest,
|
|
760
|
+
status
|
|
761
|
+
};
|
|
762
|
+
if (call.requestId !== void 0) settled.requestId = call.requestId;
|
|
763
|
+
if (error !== void 0) settled.error = error;
|
|
764
|
+
return settled;
|
|
765
|
+
}
|
|
766
|
+
function actionName(action) {
|
|
767
|
+
switch (action.kind) {
|
|
768
|
+
case "load-skill": return "load_skill";
|
|
769
|
+
case "subagent-call":
|
|
770
|
+
case "remote-agent-call": return action.name;
|
|
771
|
+
case "tool-call":
|
|
772
|
+
case "workflow-tool-call": return action.toolName;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
function resultName(result) {
|
|
776
|
+
switch (result.kind) {
|
|
777
|
+
case "load-skill-result": return "load_skill";
|
|
778
|
+
case "subagent-result": return result.subagentName;
|
|
779
|
+
default: return result.toolName;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
function callStatusAfterApproval(outcome) {
|
|
783
|
+
switch (outcome) {
|
|
784
|
+
case "approved": return "running";
|
|
785
|
+
case "denied": return "rejected";
|
|
786
|
+
case "cancelled": return "cancelled";
|
|
787
|
+
default: return;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
const TOOL_EXECUTION_DENIED = "TOOL_EXECUTION_DENIED";
|
|
791
|
+
function foldSession(state, event) {
|
|
792
|
+
const typed = event;
|
|
793
|
+
switch (typed.type) {
|
|
794
|
+
case "session.started": return state.started ? state : {
|
|
795
|
+
...state,
|
|
796
|
+
started: true
|
|
797
|
+
};
|
|
798
|
+
case "turn.started": {
|
|
799
|
+
const { sequence, turnId } = typed.data;
|
|
800
|
+
const turn = {
|
|
801
|
+
turnId,
|
|
802
|
+
sequence,
|
|
803
|
+
status: "active"
|
|
804
|
+
};
|
|
805
|
+
return {
|
|
806
|
+
...state,
|
|
807
|
+
activeTurnId: turnId,
|
|
808
|
+
nextSequence: Math.max(state.nextSequence, sequence + 1),
|
|
809
|
+
turns: {
|
|
810
|
+
...state.turns,
|
|
811
|
+
[turnId]: turn
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
case "step.started": return updateTurn(state, typed.data.turnId, (turn) => {
|
|
816
|
+
if (!turn.waiting && turn.stepIndex === typed.data.stepIndex) return turn;
|
|
817
|
+
const { waiting: _waiting, ...rest } = turn;
|
|
818
|
+
return {
|
|
819
|
+
...rest,
|
|
820
|
+
stepIndex: typed.data.stepIndex
|
|
821
|
+
};
|
|
822
|
+
});
|
|
823
|
+
case "turn.waiting": return updateTurn(state, typed.data.turnId, (turn) => turn.status === "active" && !turn.waiting ? {
|
|
824
|
+
...turn,
|
|
825
|
+
waiting: true
|
|
826
|
+
} : turn);
|
|
827
|
+
case "message.appended":
|
|
828
|
+
case "message.completed":
|
|
829
|
+
case "result.completed":
|
|
830
|
+
if (!(typed.type === "message.appended" ? typed.data.messageDelta.length > 0 : typed.type === "message.completed" ? (typed.data.message?.length ?? 0) > 0 : true)) return state;
|
|
831
|
+
return updateTurn(state, typed.data.turnId, (turn) => turn.outputStarted ? turn : {
|
|
832
|
+
...turn,
|
|
833
|
+
outputStarted: true
|
|
834
|
+
});
|
|
835
|
+
case "turn.completed":
|
|
836
|
+
case "turn.cancelled":
|
|
837
|
+
case "turn.failed": {
|
|
838
|
+
const { turnId } = typed.data;
|
|
839
|
+
const status = typed.type === "turn.completed" ? "completed" : typed.type === "turn.failed" ? "failed" : "cancelled";
|
|
840
|
+
const { waiting: _waiting, ...rest } = state.turns[turnId] ?? {
|
|
841
|
+
turnId,
|
|
842
|
+
sequence: typed.data.sequence
|
|
843
|
+
};
|
|
844
|
+
return {
|
|
845
|
+
...state,
|
|
846
|
+
activeTurnId: state.activeTurnId === turnId ? void 0 : state.activeTurnId,
|
|
847
|
+
turns: {
|
|
848
|
+
...state.turns,
|
|
849
|
+
[turnId]: {
|
|
850
|
+
...rest,
|
|
851
|
+
status
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
case "context.cleared": return {
|
|
857
|
+
...state,
|
|
858
|
+
calls: Object.fromEntries(Object.entries(state.calls).filter(([, call]) => call.taskId !== void 0))
|
|
859
|
+
};
|
|
860
|
+
case "session.waiting": return state.activeTurnId === void 0 ? state : {
|
|
861
|
+
...state,
|
|
862
|
+
activeTurnId: void 0
|
|
863
|
+
};
|
|
864
|
+
case "session.completed":
|
|
865
|
+
case "session.failed": {
|
|
866
|
+
const { activeTurnId: _activeTurnId, ...rest } = state;
|
|
867
|
+
return {
|
|
868
|
+
...rest,
|
|
869
|
+
ended: true
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
case "actions.requested": {
|
|
873
|
+
let calls;
|
|
874
|
+
for (const action of typed.data.actions) {
|
|
875
|
+
if (state.calls[action.callId] !== void 0) continue;
|
|
876
|
+
calls ??= { ...state.calls };
|
|
877
|
+
calls[action.callId] = {
|
|
878
|
+
callId: action.callId,
|
|
879
|
+
name: actionName(action),
|
|
880
|
+
turnId: typed.data.turnId,
|
|
881
|
+
stepIndex: typed.data.stepIndex,
|
|
882
|
+
status: "running"
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
return calls === void 0 ? state : {
|
|
886
|
+
...state,
|
|
887
|
+
calls
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
case "action.result": {
|
|
891
|
+
const { result, status, error } = typed.data;
|
|
892
|
+
const call = state.calls[result.callId];
|
|
893
|
+
if (call?.taskId !== void 0) return state;
|
|
894
|
+
const settled = status === "rejected" || error?.code === TOOL_EXECUTION_DENIED ? "rejected" : status === "failed" || result.isError === true ? "failed" : "completed";
|
|
895
|
+
if (call === void 0) {
|
|
896
|
+
const unannounced = {
|
|
897
|
+
callId: result.callId,
|
|
898
|
+
name: resultName(result),
|
|
899
|
+
turnId: typed.data.turnId,
|
|
900
|
+
stepIndex: typed.data.stepIndex,
|
|
901
|
+
status: settled
|
|
902
|
+
};
|
|
903
|
+
if (error !== void 0) unannounced.error = error;
|
|
904
|
+
return putCall(state, unannounced);
|
|
905
|
+
}
|
|
906
|
+
return updateCall(state, result.callId, (current) => settleCall(current, settled, error));
|
|
907
|
+
}
|
|
908
|
+
case "task.started": {
|
|
909
|
+
const { callId, kind, name, taskId, turnId } = typed.data;
|
|
910
|
+
const task = state.tasks[taskId] ?? {
|
|
911
|
+
taskId,
|
|
912
|
+
name,
|
|
913
|
+
kind,
|
|
914
|
+
calls: {}
|
|
915
|
+
};
|
|
916
|
+
let next = state;
|
|
917
|
+
if (task.calls[callId] === void 0) next = putTask(next, putTaskCall(task, {
|
|
918
|
+
callId,
|
|
919
|
+
turnId,
|
|
920
|
+
status: "working"
|
|
921
|
+
}));
|
|
922
|
+
const call = next.calls[callId];
|
|
923
|
+
if (call?.taskId === taskId) return next;
|
|
924
|
+
const linked = {
|
|
925
|
+
callId,
|
|
926
|
+
name: call?.name ?? name,
|
|
927
|
+
stepIndex: call?.stepIndex ?? 0,
|
|
928
|
+
taskId,
|
|
929
|
+
turnId: call?.turnId ?? turnId
|
|
930
|
+
};
|
|
931
|
+
if (call?.requestId !== void 0) linked.requestId = call.requestId;
|
|
932
|
+
return putCall(next, linked);
|
|
933
|
+
}
|
|
934
|
+
case "task.settled": {
|
|
935
|
+
const { callId, error, output, status, taskId } = typed.data;
|
|
936
|
+
return updateTask(state, taskId, (task) => {
|
|
937
|
+
const call = task.calls[callId];
|
|
938
|
+
if (call === void 0 || call.status !== "working") return task;
|
|
939
|
+
const settled = {
|
|
940
|
+
callId,
|
|
941
|
+
turnId: call.turnId,
|
|
942
|
+
status
|
|
943
|
+
};
|
|
944
|
+
return putTaskCall(task, status === "completed" && output !== void 0 ? {
|
|
945
|
+
...settled,
|
|
946
|
+
output
|
|
947
|
+
} : status === "failed" && error !== void 0 ? {
|
|
948
|
+
...settled,
|
|
949
|
+
error
|
|
950
|
+
} : settled);
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
case "input.requested": {
|
|
954
|
+
const inputs = { ...state.inputs };
|
|
955
|
+
let calls;
|
|
956
|
+
for (const request of typed.data.requests) {
|
|
957
|
+
if (inputs[request.requestId] !== void 0) continue;
|
|
958
|
+
const input = {
|
|
959
|
+
request,
|
|
960
|
+
sequence: typed.data.sequence,
|
|
961
|
+
turnId: typed.data.turnId,
|
|
962
|
+
stepIndex: typed.data.stepIndex,
|
|
963
|
+
status: "open"
|
|
964
|
+
};
|
|
965
|
+
if (typed.data.taskId !== void 0) input.taskId = typed.data.taskId;
|
|
966
|
+
if (typed.data.callId !== void 0) input.callId = typed.data.callId;
|
|
967
|
+
inputs[request.requestId] = input;
|
|
968
|
+
if (request.kind !== "tool-approval" || isRelayed(typed.data)) continue;
|
|
969
|
+
const { callId, toolName } = request.action;
|
|
970
|
+
calls ??= { ...state.calls };
|
|
971
|
+
const call = calls[callId];
|
|
972
|
+
if (call?.taskId !== void 0) continue;
|
|
973
|
+
if (call !== void 0 && isSettledCallStatus(call.status)) continue;
|
|
974
|
+
calls[callId] = {
|
|
975
|
+
...call ?? {
|
|
976
|
+
callId,
|
|
977
|
+
name: toolName,
|
|
978
|
+
turnId: typed.data.turnId,
|
|
979
|
+
stepIndex: typed.data.stepIndex
|
|
980
|
+
},
|
|
981
|
+
requestId: request.requestId,
|
|
982
|
+
status: "awaiting-input"
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
return calls === void 0 ? {
|
|
986
|
+
...state,
|
|
987
|
+
inputs
|
|
988
|
+
} : {
|
|
989
|
+
...state,
|
|
990
|
+
calls,
|
|
991
|
+
inputs
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
case "approval.candidate": {
|
|
995
|
+
const { candidateId, outcome, requestId } = typed.data;
|
|
996
|
+
state = {
|
|
997
|
+
...state,
|
|
998
|
+
candidates: {
|
|
999
|
+
...state.candidates,
|
|
1000
|
+
[candidateId]: {
|
|
1001
|
+
candidateId,
|
|
1002
|
+
outcome,
|
|
1003
|
+
requestId
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
const current = state.inputs[typed.data.requestId];
|
|
1008
|
+
if (current === void 0 || current.status === "settled") return state;
|
|
1009
|
+
if (typed.data.outcome === "pending" || current.status === "open") return state;
|
|
1010
|
+
const { response: _response, ...rest } = current;
|
|
1011
|
+
return {
|
|
1012
|
+
...state,
|
|
1013
|
+
inputs: {
|
|
1014
|
+
...state.inputs,
|
|
1015
|
+
[typed.data.requestId]: {
|
|
1016
|
+
...rest,
|
|
1017
|
+
status: "open"
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
case "approval.settled": {
|
|
1023
|
+
const current = state.inputs[typed.data.requestId];
|
|
1024
|
+
if (current === void 0 || current.status === "settled") return state;
|
|
1025
|
+
const outcome = typed.data.outcome === "approved" ? "approved" : "denied";
|
|
1026
|
+
return settleApprovalCall({
|
|
1027
|
+
...state,
|
|
1028
|
+
inputs: {
|
|
1029
|
+
...state.inputs,
|
|
1030
|
+
[typed.data.requestId]: {
|
|
1031
|
+
...current,
|
|
1032
|
+
status: "settled",
|
|
1033
|
+
outcome
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}, current, outcome);
|
|
1037
|
+
}
|
|
1038
|
+
case "input.resolved": {
|
|
1039
|
+
let next = state;
|
|
1040
|
+
for (const resolution of typed.data.resolutions) {
|
|
1041
|
+
const current = next.inputs[resolution.requestId];
|
|
1042
|
+
if (current === void 0 || current.status === "settled") continue;
|
|
1043
|
+
const response = resolution.response ?? current.response;
|
|
1044
|
+
const settled = {
|
|
1045
|
+
...current,
|
|
1046
|
+
status: "settled",
|
|
1047
|
+
outcome: resolution.outcome
|
|
1048
|
+
};
|
|
1049
|
+
if (response !== void 0) settled.response = response;
|
|
1050
|
+
next = {
|
|
1051
|
+
...next,
|
|
1052
|
+
inputs: {
|
|
1053
|
+
...next.inputs,
|
|
1054
|
+
[resolution.requestId]: settled
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
next = settleApprovalCall(next, current, resolution.outcome);
|
|
1058
|
+
}
|
|
1059
|
+
return next;
|
|
1060
|
+
}
|
|
1061
|
+
case "authorization.required": {
|
|
1062
|
+
const attemptId = typed.data.attemptId ?? typed.data.name;
|
|
1063
|
+
const authorization = {
|
|
1064
|
+
attemptId,
|
|
1065
|
+
name: typed.data.name,
|
|
1066
|
+
sequence: typed.data.sequence,
|
|
1067
|
+
turnId: typed.data.turnId,
|
|
1068
|
+
stepIndex: typed.data.stepIndex,
|
|
1069
|
+
status: "required"
|
|
1070
|
+
};
|
|
1071
|
+
if (typed.data.taskId !== void 0) authorization.taskId = typed.data.taskId;
|
|
1072
|
+
if (typed.data.principalId !== void 0) authorization.principalId = typed.data.principalId;
|
|
1073
|
+
if (typed.data.candidateId !== void 0) authorization.candidateId = typed.data.candidateId;
|
|
1074
|
+
if (typed.data.webhookUrl !== void 0) authorization.awaitsCallback = true;
|
|
1075
|
+
return {
|
|
1076
|
+
...state,
|
|
1077
|
+
authorizations: {
|
|
1078
|
+
...state.authorizations,
|
|
1079
|
+
[attemptId]: authorization
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
case "authorization.completed": {
|
|
1084
|
+
const attemptId = typed.data.attemptId ?? typed.data.name;
|
|
1085
|
+
const completed = {
|
|
1086
|
+
...state.authorizations[attemptId] ?? {
|
|
1087
|
+
attemptId,
|
|
1088
|
+
name: typed.data.name,
|
|
1089
|
+
sequence: typed.data.sequence,
|
|
1090
|
+
turnId: typed.data.turnId,
|
|
1091
|
+
stepIndex: typed.data.stepIndex
|
|
1092
|
+
},
|
|
1093
|
+
status: typed.data.outcome
|
|
1094
|
+
};
|
|
1095
|
+
return {
|
|
1096
|
+
...state,
|
|
1097
|
+
authorizations: {
|
|
1098
|
+
...state.authorizations,
|
|
1099
|
+
[attemptId]: completed
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
default: return state;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function isRelayed(request) {
|
|
1107
|
+
return request.callId !== void 0 || request.taskId !== void 0;
|
|
1108
|
+
}
|
|
1109
|
+
function settleApprovalCall(state, input, outcome) {
|
|
1110
|
+
if (input.request.kind !== "tool-approval" || isRelayed(input)) return state;
|
|
1111
|
+
const status = callStatusAfterApproval(outcome);
|
|
1112
|
+
if (status === void 0) return state;
|
|
1113
|
+
return updateCall(state, input.request.action.callId, (call) => {
|
|
1114
|
+
if (call.status !== "awaiting-input" || call.requestId !== input.request.requestId) return call;
|
|
1115
|
+
return status === "running" ? {
|
|
1116
|
+
...call,
|
|
1117
|
+
status
|
|
1118
|
+
} : settleCall(call, status);
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
function openInputs(state) {
|
|
1122
|
+
return Object.values(state.inputs).filter((input) => input.status !== "settled");
|
|
1123
|
+
}
|
|
1124
|
+
function openSignIns(state) {
|
|
1125
|
+
return Object.values(state.authorizations).filter((attempt) => attempt.status === "required");
|
|
1126
|
+
}
|
|
1127
|
+
function callStatus(state, callId, options = {}) {
|
|
1128
|
+
const call = state.calls[callId];
|
|
1129
|
+
if (call === void 0) return void 0;
|
|
1130
|
+
const status = reportedCallStatus(state, call);
|
|
1131
|
+
if (status !== "running" || call.taskId !== void 0) return status;
|
|
1132
|
+
const turn = state.turns[call.turnId];
|
|
1133
|
+
if (options.streaming === false || turn !== void 0 && turn.status !== "active") return "interrupted";
|
|
1134
|
+
return status;
|
|
1135
|
+
}
|
|
1136
|
+
function reportedCallStatus(state, call) {
|
|
1137
|
+
if (call.taskId === void 0) return call.status;
|
|
1138
|
+
const status = state.tasks[call.taskId]?.calls[call.callId]?.status;
|
|
1139
|
+
return status === void 0 || status === "working" ? "running" : status;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
684
1142
|
//#endregion
|
|
685
1143
|
//#region src/client/session-utils.ts
|
|
686
1144
|
function summarizeTurnEvents(events) {
|
|
@@ -713,46 +1171,30 @@ function endsTurnSegment(event, open) {
|
|
|
713
1171
|
return isCurrentTurnBoundaryEvent(event) && (event.type !== "session.waiting" || !open.callbacks);
|
|
714
1172
|
}
|
|
715
1173
|
var TurnSegment = class {
|
|
1174
|
+
#projection = initialSessionProjection();
|
|
716
1175
|
#authorizations = /* @__PURE__ */ new Map();
|
|
717
1176
|
#followCallbacks;
|
|
718
|
-
#requests = /* @__PURE__ */ new Map();
|
|
719
1177
|
constructor(options = {}) {
|
|
720
1178
|
this.#followCallbacks = options.followCallbacks === true;
|
|
721
1179
|
}
|
|
722
1180
|
get inputRequests() {
|
|
723
|
-
return
|
|
1181
|
+
return openInputs(this.#projection).map((input) => input.request);
|
|
724
1182
|
}
|
|
725
1183
|
get pendingAuthorizations() {
|
|
726
|
-
return
|
|
1184
|
+
return openSignIns(this.#projection).flatMap((attempt) => this.#authorizations.get(attempt.attemptId) ?? []);
|
|
727
1185
|
}
|
|
728
1186
|
observe(event) {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
for (const request of event.data.requests) this.#requests.set(request.requestId, request);
|
|
732
|
-
break;
|
|
733
|
-
case "approval.settled":
|
|
734
|
-
this.#requests.delete(event.data.requestId);
|
|
735
|
-
break;
|
|
736
|
-
case "input.resolved":
|
|
737
|
-
for (const resolution of event.data.resolutions) this.#requests.delete(resolution.requestId);
|
|
738
|
-
break;
|
|
739
|
-
case "authorization.required":
|
|
740
|
-
this.#authorizations.set(authorizationKey(event.data), event.data);
|
|
741
|
-
break;
|
|
742
|
-
case "authorization.completed": this.#authorizations.delete(authorizationKey(event.data));
|
|
743
|
-
}
|
|
1187
|
+
this.#projection = foldSession(this.#projection, event);
|
|
1188
|
+
if (event.type === "authorization.required") this.#authorizations.set(event.data.attemptId ?? event.data.name, event.data);
|
|
744
1189
|
return endsTurnSegment(event, {
|
|
745
|
-
callbacks: this.#followCallbacks &&
|
|
746
|
-
requests: this.#
|
|
1190
|
+
callbacks: this.#followCallbacks && openSignIns(this.#projection).some((attempt) => attempt.awaitsCallback === true),
|
|
1191
|
+
requests: openInputs(this.#projection).length > 0
|
|
747
1192
|
});
|
|
748
1193
|
}
|
|
749
1194
|
};
|
|
750
1195
|
function isFinalMessageCompleted(event) {
|
|
751
1196
|
return event.type === "message.completed" && event.data.finishReason !== "tool-calls";
|
|
752
1197
|
}
|
|
753
|
-
function authorizationKey(data) {
|
|
754
|
-
return data.attemptId === void 0 ? `name:${data.name}` : `attempt:${data.attemptId}`;
|
|
755
|
-
}
|
|
756
1198
|
|
|
757
1199
|
//#endregion
|
|
758
1200
|
//#region src/protocol/message-version.ts
|
|
@@ -1929,7 +2371,8 @@ var ClientSession = class ClientSession {
|
|
|
1929
2371
|
const terminal = event.type === "session.failed" || event.type === "session.completed";
|
|
1930
2372
|
if (!matches && terminal && (!started || event.type === "session.completed")) throw new Error("The session ended before the accepted message reached its turn boundary.");
|
|
1931
2373
|
if (!started && !matches) continue;
|
|
1932
|
-
|
|
2374
|
+
const attributed = event.meta?.deliveryIds !== void 0;
|
|
2375
|
+
if (!terminal && attributed && !matches) continue;
|
|
1933
2376
|
started = true;
|
|
1934
2377
|
}
|
|
1935
2378
|
reachedBoundary = segment.observe(event);
|
|
@@ -2239,16 +2682,24 @@ var EveAgentProjection = class {
|
|
|
2239
2682
|
}
|
|
2240
2683
|
};
|
|
2241
2684
|
|
|
2685
|
+
//#endregion
|
|
2686
|
+
//#region src/client/conversation-projection.ts
|
|
2687
|
+
const projectionKey = Symbol("eve.conversationProjection");
|
|
2688
|
+
function conversationProjection(state) {
|
|
2689
|
+
return state[projectionKey] ?? initialSessionProjection();
|
|
2690
|
+
}
|
|
2691
|
+
function withConversationProjection(state, projection) {
|
|
2692
|
+
if (state[projectionKey] === projection) return state;
|
|
2693
|
+
return Object.defineProperty({ ...state }, projectionKey, { value: projection });
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2242
2696
|
//#endregion
|
|
2243
2697
|
//#region src/client/conversation-state.ts
|
|
2244
2698
|
function openConversationInputs(state) {
|
|
2245
2699
|
return Object.values(state.inputs).filter((input) => input.status === "open");
|
|
2246
2700
|
}
|
|
2247
|
-
function conversationAuthorizations(state) {
|
|
2248
|
-
return state.messages.flatMap((message) => message.role === "assistant" ? message.parts.filter((part) => part.type === "authorization") : []);
|
|
2249
|
-
}
|
|
2250
2701
|
function hasPendingAuthorizations(state) {
|
|
2251
|
-
return
|
|
2702
|
+
return openSignIns(conversationProjection(state)).some((attempt) => attempt.awaitsCallback === true);
|
|
2252
2703
|
}
|
|
2253
2704
|
function agentToolTask(state, agent) {
|
|
2254
2705
|
const task = agent.taskId === void 0 ? void 0 : state.tasks[agent.taskId];
|
|
@@ -2655,15 +3106,6 @@ function mergeToolMetadata(current, next) {
|
|
|
2655
3106
|
name
|
|
2656
3107
|
} };
|
|
2657
3108
|
}
|
|
2658
|
-
function approvedApproval(part) {
|
|
2659
|
-
if (!part?.approval?.id) return;
|
|
2660
|
-
return {
|
|
2661
|
-
approved: true,
|
|
2662
|
-
id: part.approval.id,
|
|
2663
|
-
isAutomatic: part.approval.isAutomatic,
|
|
2664
|
-
reason: part.approval.reason
|
|
2665
|
-
};
|
|
2666
|
-
}
|
|
2667
3109
|
function normalizeActionRequest(action) {
|
|
2668
3110
|
const name = actionRequestName(action);
|
|
2669
3111
|
switch (action.kind) {
|
|
@@ -2802,33 +3244,104 @@ function transition(message, input) {
|
|
|
2802
3244
|
const messageRun = { transition };
|
|
2803
3245
|
|
|
2804
3246
|
//#endregion
|
|
2805
|
-
//#region src/client/
|
|
2806
|
-
function
|
|
2807
|
-
const
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
3247
|
+
//#region src/client/tool-part-state.ts
|
|
3248
|
+
function toolPartState(data, part) {
|
|
3249
|
+
const content = part;
|
|
3250
|
+
const projection = conversationProjection(data);
|
|
3251
|
+
const call = projection.calls[part.toolCallId];
|
|
3252
|
+
const requestId = content.approval?.id;
|
|
3253
|
+
const input = requestId === void 0 ? void 0 : projection.inputs[requestId];
|
|
3254
|
+
const base = {
|
|
3255
|
+
input: part.input,
|
|
3256
|
+
stepIndex: part.stepIndex,
|
|
3257
|
+
toolCallId: part.toolCallId,
|
|
3258
|
+
toolMetadata: part.toolMetadata,
|
|
3259
|
+
toolName: part.toolName,
|
|
2814
3260
|
type: "dynamic-tool"
|
|
2815
3261
|
};
|
|
2816
|
-
|
|
3262
|
+
const requested = requestId === void 0 ? void 0 : {
|
|
3263
|
+
id: requestId,
|
|
3264
|
+
...content.approval?.isAutomatic !== void 0 && { isAutomatic: content.approval.isAutomatic }
|
|
3265
|
+
};
|
|
3266
|
+
const responded = (approved, reason) => ({
|
|
3267
|
+
...base,
|
|
3268
|
+
approval: {
|
|
3269
|
+
...requested,
|
|
3270
|
+
...approved && { approved: true },
|
|
3271
|
+
...reason !== void 0 && { reason }
|
|
3272
|
+
},
|
|
3273
|
+
state: "approval-responded"
|
|
3274
|
+
});
|
|
3275
|
+
const approvedTrue = requested === void 0 ? void 0 : {
|
|
3276
|
+
...requested,
|
|
3277
|
+
approved: true
|
|
3278
|
+
};
|
|
3279
|
+
if (requested !== void 0 && input !== void 0 && input.status !== "settled" && (call === void 0 || !isSettledCallStatus(reportedCallStatus(projection, call)))) return {
|
|
3280
|
+
...base,
|
|
3281
|
+
approval: requested,
|
|
3282
|
+
state: "approval-requested"
|
|
3283
|
+
};
|
|
3284
|
+
const task = call?.taskId === void 0 ? void 0 : projection.tasks[call.taskId]?.calls[part.toolCallId];
|
|
3285
|
+
if (call === void 0) {
|
|
3286
|
+
if (input === void 0) return part;
|
|
3287
|
+
return input.response === void 0 ? {
|
|
3288
|
+
...base,
|
|
3289
|
+
output: { status: input.outcome },
|
|
3290
|
+
state: "output-available"
|
|
3291
|
+
} : responded(input.outcome === "approved", input.response.text);
|
|
3292
|
+
}
|
|
3293
|
+
switch (reportedCallStatus(projection, call)) {
|
|
3294
|
+
case "running":
|
|
3295
|
+
case "awaiting-input":
|
|
3296
|
+
if (content.partial === true) return {
|
|
3297
|
+
...base,
|
|
3298
|
+
approval: approvedTrue,
|
|
3299
|
+
output: content.output,
|
|
3300
|
+
partial: true,
|
|
3301
|
+
state: "output-available"
|
|
3302
|
+
};
|
|
3303
|
+
if (input !== void 0 && (input.outcome === "approved" || input.response !== void 0)) return responded(input.outcome === "approved", input.response?.text);
|
|
3304
|
+
return {
|
|
3305
|
+
...base,
|
|
3306
|
+
state: "input-available"
|
|
3307
|
+
};
|
|
2817
3308
|
case "completed": return {
|
|
2818
|
-
...
|
|
2819
|
-
|
|
3309
|
+
...base,
|
|
3310
|
+
approval: approvedTrue,
|
|
3311
|
+
output: task?.output ?? content.output,
|
|
2820
3312
|
state: "output-available"
|
|
2821
3313
|
};
|
|
2822
3314
|
case "failed": return {
|
|
2823
|
-
...
|
|
2824
|
-
|
|
3315
|
+
...base,
|
|
3316
|
+
approval: approvedTrue,
|
|
3317
|
+
errorText: task?.error?.message ?? content.errorText ?? call.error?.message ?? (call.taskId === void 0 ? "Action failed." : "Task failed."),
|
|
2825
3318
|
state: "output-error"
|
|
2826
3319
|
};
|
|
2827
|
-
case "
|
|
2828
|
-
...
|
|
2829
|
-
|
|
2830
|
-
|
|
3320
|
+
case "rejected": return {
|
|
3321
|
+
...base,
|
|
3322
|
+
approval: {
|
|
3323
|
+
id: requestId ?? part.toolCallId,
|
|
3324
|
+
approved: false,
|
|
3325
|
+
reason: call.error?.message ?? content.errorText
|
|
3326
|
+
},
|
|
3327
|
+
state: "output-denied"
|
|
2831
3328
|
};
|
|
3329
|
+
case "cancelled":
|
|
3330
|
+
if (requestId !== void 0 && input?.outcome === "cancelled") return {
|
|
3331
|
+
...base,
|
|
3332
|
+
approval: {
|
|
3333
|
+
id: requestId,
|
|
3334
|
+
approved: false,
|
|
3335
|
+
reason: "Tool execution was cancelled."
|
|
3336
|
+
},
|
|
3337
|
+
state: "output-denied"
|
|
3338
|
+
};
|
|
3339
|
+
return {
|
|
3340
|
+
...base,
|
|
3341
|
+
approval: approvedTrue,
|
|
3342
|
+
errorText: call.taskId === void 0 ? content.errorText ?? call.error?.message ?? "Action was cancelled." : "Task was cancelled.",
|
|
3343
|
+
state: "output-error"
|
|
3344
|
+
};
|
|
2832
3345
|
}
|
|
2833
3346
|
}
|
|
2834
3347
|
|
|
@@ -2840,7 +3353,7 @@ function receivedMessageEventId(event) {
|
|
|
2840
3353
|
function defaultMessageReducer() {
|
|
2841
3354
|
return {
|
|
2842
3355
|
initial() {
|
|
2843
|
-
return { messages: [] };
|
|
3356
|
+
return withConversationProjection({ messages: [] }, initialSessionProjection());
|
|
2844
3357
|
},
|
|
2845
3358
|
reduce(data, event) {
|
|
2846
3359
|
return reduceMessageData(data, event);
|
|
@@ -2848,6 +3361,12 @@ function defaultMessageReducer() {
|
|
|
2848
3361
|
};
|
|
2849
3362
|
}
|
|
2850
3363
|
function reduceMessageData(data, event) {
|
|
3364
|
+
const projection = foldSession(conversationProjection(data), event);
|
|
3365
|
+
const content = withConversationProjection(reduceContent(data, event), projection);
|
|
3366
|
+
const callIds = toolCallIds(content, event);
|
|
3367
|
+
return withConversationProjection(callIds.length === 0 ? content : withToolPartStates(content, callIds), projection);
|
|
3368
|
+
}
|
|
3369
|
+
function reduceContent(data, event) {
|
|
2851
3370
|
switch (event.type) {
|
|
2852
3371
|
case "client.message.submitted":
|
|
2853
3372
|
case "client.message.failed": return upsertMessage(data, {
|
|
@@ -2862,11 +3381,6 @@ function reduceMessageData(data, event) {
|
|
|
2862
3381
|
}],
|
|
2863
3382
|
role: "user"
|
|
2864
3383
|
}, event.data.turnId);
|
|
2865
|
-
case "input.resolved": {
|
|
2866
|
-
let next = data;
|
|
2867
|
-
for (const resolution of event.data.resolutions) next = resolveInputRequest(next, resolution);
|
|
2868
|
-
return next;
|
|
2869
|
-
}
|
|
2870
3384
|
case "message.received": return upsertMessage(data, {
|
|
2871
3385
|
id: `${receivedMessageEventId(event)}:user`,
|
|
2872
3386
|
metadata: {
|
|
@@ -2900,9 +3414,10 @@ function reduceMessageData(data, event) {
|
|
|
2900
3414
|
case "action.input.appended": {
|
|
2901
3415
|
const existing = findToolPart(data, event.data.callId);
|
|
2902
3416
|
if (existing !== void 0 && existing.state !== "input-streaming") return data;
|
|
2903
|
-
const
|
|
3417
|
+
const inputText = (existing?.state === "input-streaming" ? existing.inputText : "") + event.data.inputTextDelta;
|
|
3418
|
+
return upsertToolPart(data, event.data.turnId, event.data.stepIndex, {
|
|
2904
3419
|
input: void 0,
|
|
2905
|
-
inputText
|
|
3420
|
+
inputText,
|
|
2906
3421
|
state: "input-streaming",
|
|
2907
3422
|
stepIndex: event.data.stepIndex,
|
|
2908
3423
|
toolCallId: event.data.callId,
|
|
@@ -2912,8 +3427,7 @@ function reduceMessageData(data, event) {
|
|
|
2912
3427
|
} },
|
|
2913
3428
|
toolName: event.data.toolName,
|
|
2914
3429
|
type: "dynamic-tool"
|
|
2915
|
-
};
|
|
2916
|
-
return upsertToolPart(data, event.data.turnId, event.data.stepIndex, nextPart);
|
|
3430
|
+
});
|
|
2917
3431
|
}
|
|
2918
3432
|
case "actions.requested": {
|
|
2919
3433
|
let next = data;
|
|
@@ -2940,10 +3454,11 @@ function reduceMessageData(data, event) {
|
|
|
2940
3454
|
if (existing?.approval?.id === request.requestId || existing !== void 0 && isSettledToolPart(existing)) continue;
|
|
2941
3455
|
const descriptor = normalizeActionRequest(request.action);
|
|
2942
3456
|
next = updateAssistantMessage(next, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
|
|
3457
|
+
...existing,
|
|
2943
3458
|
approval: { id: request.requestId },
|
|
2944
3459
|
input: request.action.input,
|
|
2945
3460
|
state: "approval-requested",
|
|
2946
|
-
stepIndex: event.data.stepIndex,
|
|
3461
|
+
stepIndex: existing?.stepIndex ?? event.data.stepIndex,
|
|
2947
3462
|
toolCallId: request.action.callId,
|
|
2948
3463
|
toolMetadata: createToolMetadata(descriptor, { inputRequest: toMessageInputRequest(request) }),
|
|
2949
3464
|
toolName: descriptor.toolName,
|
|
@@ -2952,97 +3467,75 @@ function reduceMessageData(data, event) {
|
|
|
2952
3467
|
}
|
|
2953
3468
|
return next;
|
|
2954
3469
|
}
|
|
2955
|
-
case "approval.candidate": return data;
|
|
2956
|
-
case "approval.settled": {
|
|
2957
|
-
const existing = findToolPartByApprovalId(data, event.data.requestId);
|
|
2958
|
-
if (existing === void 0) return data;
|
|
2959
|
-
if (event.data.outcome === "approved") {
|
|
2960
|
-
const approval = {
|
|
2961
|
-
approved: true,
|
|
2962
|
-
id: event.data.requestId,
|
|
2963
|
-
reason: void 0
|
|
2964
|
-
};
|
|
2965
|
-
return updateToolPart(data, existing.toolCallId, existing.state === "output-available" ? {
|
|
2966
|
-
...existing,
|
|
2967
|
-
approval
|
|
2968
|
-
} : {
|
|
2969
|
-
...toolPartIdentity(existing),
|
|
2970
|
-
approval,
|
|
2971
|
-
state: "approval-responded"
|
|
2972
|
-
});
|
|
2973
|
-
}
|
|
2974
|
-
if (existing.state === "output-available") return data;
|
|
2975
|
-
return updateToolPart(data, existing.toolCallId, {
|
|
2976
|
-
...toolPartIdentity(existing),
|
|
2977
|
-
approval: {
|
|
2978
|
-
approved: false,
|
|
2979
|
-
id: event.data.requestId,
|
|
2980
|
-
reason: "Tool execution was cancelled."
|
|
2981
|
-
},
|
|
2982
|
-
state: "output-denied"
|
|
2983
|
-
});
|
|
2984
|
-
}
|
|
2985
3470
|
case "action.result": {
|
|
2986
|
-
|
|
3471
|
+
if (conversationProjection(data).calls[event.data.result.callId]?.taskId !== void 0) return data;
|
|
2987
3472
|
const existing = findToolPart(data, event.data.result.callId);
|
|
2988
|
-
const
|
|
2989
|
-
const
|
|
2990
|
-
const
|
|
2991
|
-
|
|
2992
|
-
const resultPartBase = {
|
|
3473
|
+
const descriptor = normalizeActionResult(event.data.result);
|
|
3474
|
+
const succeeded = event.data.status === void 0 || event.data.status === "completed" ? event.data.result.isError !== true && event.data.error === void 0 : false;
|
|
3475
|
+
const part = {
|
|
3476
|
+
...existing,
|
|
2993
3477
|
input: existing?.input,
|
|
2994
|
-
stepIndex: event.data.stepIndex,
|
|
3478
|
+
stepIndex: existing?.stepIndex ?? event.data.stepIndex,
|
|
2995
3479
|
toolCallId: event.data.result.callId,
|
|
2996
|
-
toolMetadata,
|
|
3480
|
+
toolMetadata: mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor)),
|
|
2997
3481
|
toolName: existing?.toolName ?? descriptor.toolName,
|
|
2998
3482
|
type: "dynamic-tool"
|
|
2999
3483
|
};
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
approved: false,
|
|
3005
|
-
id: approvalId,
|
|
3006
|
-
reason: event.data.error?.message
|
|
3007
|
-
},
|
|
3008
|
-
state: "output-denied"
|
|
3009
|
-
};
|
|
3010
|
-
else if (failed) nextPart = {
|
|
3011
|
-
...resultPartBase,
|
|
3012
|
-
approval: approvedApproval(existing),
|
|
3484
|
+
const outcome = succeeded ? {
|
|
3485
|
+
errorText: void 0,
|
|
3486
|
+
output: event.data.result.output
|
|
3487
|
+
} : {
|
|
3013
3488
|
errorText: event.data.error?.message ?? stringifyUnknown(event.data.result.output),
|
|
3014
|
-
|
|
3489
|
+
output: void 0
|
|
3015
3490
|
};
|
|
3016
|
-
|
|
3017
|
-
...
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
};
|
|
3022
|
-
return upsertToolPart(data, event.data.turnId, event.data.stepIndex, nextPart);
|
|
3491
|
+
return upsertToolPart(data, event.data.turnId, event.data.stepIndex, {
|
|
3492
|
+
...part,
|
|
3493
|
+
...outcome,
|
|
3494
|
+
partial: void 0
|
|
3495
|
+
});
|
|
3023
3496
|
}
|
|
3024
3497
|
case "action.partial": {
|
|
3025
3498
|
const existing = findToolPart(data, event.data.result.callId);
|
|
3026
3499
|
if (existing !== void 0 && isSettledToolPart(existing)) return data;
|
|
3027
3500
|
const descriptor = normalizeActionResult(event.data.result);
|
|
3028
|
-
|
|
3029
|
-
|
|
3501
|
+
return upsertToolPart(data, event.data.turnId, event.data.stepIndex, {
|
|
3502
|
+
...existing,
|
|
3030
3503
|
input: existing?.input,
|
|
3031
3504
|
output: event.data.result.output,
|
|
3032
3505
|
partial: true,
|
|
3033
3506
|
state: "output-available",
|
|
3034
|
-
stepIndex: event.data.stepIndex,
|
|
3507
|
+
stepIndex: existing?.stepIndex ?? event.data.stepIndex,
|
|
3035
3508
|
toolCallId: event.data.result.callId,
|
|
3036
3509
|
toolMetadata: mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor)),
|
|
3037
3510
|
toolName: existing?.toolName ?? descriptor.toolName,
|
|
3038
3511
|
type: "dynamic-tool"
|
|
3039
|
-
};
|
|
3040
|
-
|
|
3512
|
+
});
|
|
3513
|
+
}
|
|
3514
|
+
case "input.resolved": {
|
|
3515
|
+
let next = data;
|
|
3516
|
+
for (const { requestId, response } of event.data.resolutions) {
|
|
3517
|
+
const existing = response === void 0 ? void 0 : findToolPartByApprovalId(next, requestId);
|
|
3518
|
+
if (existing === void 0) continue;
|
|
3519
|
+
next = replaceToolPart(next, {
|
|
3520
|
+
...existing,
|
|
3521
|
+
toolMetadata: mergeToolMetadata(existing.toolMetadata, { eve: {
|
|
3522
|
+
inputResponse: response,
|
|
3523
|
+
kind: existing.toolMetadata?.eve?.kind ?? "unknown",
|
|
3524
|
+
name: existing.toolMetadata?.eve?.name ?? existing.toolName
|
|
3525
|
+
} })
|
|
3526
|
+
});
|
|
3527
|
+
}
|
|
3528
|
+
return next;
|
|
3041
3529
|
}
|
|
3042
3530
|
case "task.settled": {
|
|
3043
3531
|
const existing = findToolPart(data, event.data.callId);
|
|
3044
3532
|
if (existing === void 0) return data;
|
|
3045
|
-
|
|
3533
|
+
const { error, output, status } = event.data;
|
|
3534
|
+
const outcome = status === "completed" ? { output } : { errorText: error?.message };
|
|
3535
|
+
return replaceToolPart(data, {
|
|
3536
|
+
...existing,
|
|
3537
|
+
...outcome
|
|
3538
|
+
});
|
|
3046
3539
|
}
|
|
3047
3540
|
case "authorization.required": return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), createAuthorizationRequiredPart(event)));
|
|
3048
3541
|
case "authorization.completed": return completeAuthorization(data, event);
|
|
@@ -3067,24 +3560,10 @@ function reduceMessageData(data, event) {
|
|
|
3067
3560
|
result: event.data.result
|
|
3068
3561
|
}
|
|
3069
3562
|
}));
|
|
3070
|
-
case "turn.completed":
|
|
3071
|
-
|
|
3072
|
-
metadata: {
|
|
3073
|
-
...message.metadata,
|
|
3074
|
-
status: "complete"
|
|
3075
|
-
},
|
|
3076
|
-
parts: removeStreamingToolParts(closeStreamingRuns(message.parts))
|
|
3077
|
-
}));
|
|
3078
|
-
case "turn.cancelled": return updateAssistantMessage(data, event.data.turnId, (message) => ({
|
|
3079
|
-
...message,
|
|
3080
|
-
metadata: {
|
|
3081
|
-
...message.metadata,
|
|
3082
|
-
status: "complete"
|
|
3083
|
-
},
|
|
3084
|
-
parts: removeStreamingToolParts(closeStreamingRuns(message.parts))
|
|
3085
|
-
}));
|
|
3563
|
+
case "turn.completed":
|
|
3564
|
+
case "turn.cancelled":
|
|
3086
3565
|
case "turn.failed":
|
|
3087
|
-
if (data.messages.
|
|
3566
|
+
if (event.type === "turn.failed" && !data.messages.some((message) => message.role === "assistant" && message.metadata?.turnId === event.data.turnId)) return data;
|
|
3088
3567
|
return updateAssistantMessage(data, event.data.turnId, (message) => ({
|
|
3089
3568
|
...message,
|
|
3090
3569
|
metadata: {
|
|
@@ -3093,10 +3572,33 @@ function reduceMessageData(data, event) {
|
|
|
3093
3572
|
},
|
|
3094
3573
|
parts: removeStreamingToolParts(closeStreamingRuns(message.parts))
|
|
3095
3574
|
}));
|
|
3096
|
-
case "session.failed": return data;
|
|
3097
3575
|
default: return data;
|
|
3098
3576
|
}
|
|
3099
3577
|
}
|
|
3578
|
+
function toolCallIds(data, event) {
|
|
3579
|
+
const byRequest = (requestId) => findToolPartByApprovalId(data, requestId)?.toolCallId ?? [];
|
|
3580
|
+
switch (event.type) {
|
|
3581
|
+
case "actions.requested": return event.data.actions.map((action) => action.callId);
|
|
3582
|
+
case "input.requested": return event.data.requests.map((request) => request.action.callId);
|
|
3583
|
+
case "action.result":
|
|
3584
|
+
case "action.partial": return [event.data.result.callId];
|
|
3585
|
+
case "task.started":
|
|
3586
|
+
case "task.settled": return [event.data.callId];
|
|
3587
|
+
case "input.resolved": return event.data.resolutions.flatMap((resolution) => byRequest(resolution.requestId));
|
|
3588
|
+
case "approval.settled": return [byRequest(event.data.requestId)].flat();
|
|
3589
|
+
default: return [];
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
function withToolPartStates(data, callIds) {
|
|
3593
|
+
let next = data;
|
|
3594
|
+
for (const callId of new Set(callIds)) {
|
|
3595
|
+
const part = findToolPart(next, callId);
|
|
3596
|
+
if (part === void 0) continue;
|
|
3597
|
+
const derived = toolPartState(next, part);
|
|
3598
|
+
if (derived !== part) next = withConversationProjection(replaceToolPart(next, derived), conversationProjection(data));
|
|
3599
|
+
}
|
|
3600
|
+
return next;
|
|
3601
|
+
}
|
|
3100
3602
|
function closeStreamingRuns(parts, stepIndex) {
|
|
3101
3603
|
return parts.map((part) => (part.type === "text" || part.type === "reasoning") && part.state === "streaming" && (stepIndex === void 0 || part.stepIndex === stepIndex) ? {
|
|
3102
3604
|
...part,
|
|
@@ -3106,50 +3608,6 @@ function closeStreamingRuns(parts, stepIndex) {
|
|
|
3106
3608
|
function removeStreamingToolParts(parts) {
|
|
3107
3609
|
return parts.filter((part) => part.type !== "dynamic-tool" || part.state !== "input-streaming");
|
|
3108
3610
|
}
|
|
3109
|
-
function respondToInputRequest(data, response) {
|
|
3110
|
-
const existing = findToolPartByApprovalId(data, response.requestId);
|
|
3111
|
-
if (!existing) return data;
|
|
3112
|
-
const approval = { id: response.requestId };
|
|
3113
|
-
if (response.text !== void 0) approval.reason = response.text;
|
|
3114
|
-
const toolMetadata = mergeToolMetadata(existing.toolMetadata, { eve: {
|
|
3115
|
-
inputResponse: response,
|
|
3116
|
-
kind: existing.toolMetadata?.eve?.kind ?? "unknown",
|
|
3117
|
-
name: existing.toolMetadata?.eve?.name ?? existing.toolName
|
|
3118
|
-
} });
|
|
3119
|
-
return updateToolPart(data, existing.toolCallId, existing.state === "output-available" ? {
|
|
3120
|
-
...existing,
|
|
3121
|
-
approval: {
|
|
3122
|
-
...approval,
|
|
3123
|
-
approved: true
|
|
3124
|
-
},
|
|
3125
|
-
toolMetadata
|
|
3126
|
-
} : {
|
|
3127
|
-
...toolPartIdentity(existing),
|
|
3128
|
-
approval,
|
|
3129
|
-
state: "approval-responded",
|
|
3130
|
-
toolMetadata
|
|
3131
|
-
});
|
|
3132
|
-
}
|
|
3133
|
-
function resolveInputRequest(data, resolution) {
|
|
3134
|
-
if (resolution.response !== void 0) return findToolPartByApprovalId(data, resolution.requestId)?.approval?.approved === void 0 ? respondToInputRequest(data, resolution.response) : data;
|
|
3135
|
-
const existing = findToolPartByApprovalId(data, resolution.requestId);
|
|
3136
|
-
if (!existing) return data;
|
|
3137
|
-
return updateToolPart(data, existing.toolCallId, {
|
|
3138
|
-
...toolPartIdentity(existing),
|
|
3139
|
-
output: { status: resolution.outcome },
|
|
3140
|
-
state: "output-available"
|
|
3141
|
-
});
|
|
3142
|
-
}
|
|
3143
|
-
function toolPartIdentity(part) {
|
|
3144
|
-
return {
|
|
3145
|
-
input: part.input,
|
|
3146
|
-
stepIndex: part.stepIndex,
|
|
3147
|
-
toolCallId: part.toolCallId,
|
|
3148
|
-
toolMetadata: part.toolMetadata,
|
|
3149
|
-
toolName: part.toolName,
|
|
3150
|
-
type: part.type
|
|
3151
|
-
};
|
|
3152
|
-
}
|
|
3153
3611
|
function updateAssistantMessage(data, turnId, update) {
|
|
3154
3612
|
const message = data.messages.find((message) => message.role === "assistant" && message.metadata?.turnId === turnId) ?? createAssistantMessage(turnId);
|
|
3155
3613
|
return upsertMessage(data, update(message));
|
|
@@ -3235,37 +3693,13 @@ function findToolPartByApprovalId(data, approvalId) {
|
|
|
3235
3693
|
//#endregion
|
|
3236
3694
|
//#region src/client/conversation-reducer.ts
|
|
3237
3695
|
function initialConversationState() {
|
|
3238
|
-
return {
|
|
3239
|
-
messages: [],
|
|
3696
|
+
return withConversationProjection({
|
|
3240
3697
|
turns: {},
|
|
3241
3698
|
inputs: {},
|
|
3242
3699
|
tasks: {},
|
|
3700
|
+
messages: [],
|
|
3243
3701
|
agents: {}
|
|
3244
|
-
};
|
|
3245
|
-
}
|
|
3246
|
-
function updateTurn(state, turnId, update) {
|
|
3247
|
-
const turn = state.turns[turnId];
|
|
3248
|
-
if (turn === void 0) return state;
|
|
3249
|
-
const next = update(turn);
|
|
3250
|
-
return next === turn ? state : {
|
|
3251
|
-
...state,
|
|
3252
|
-
turns: {
|
|
3253
|
-
...state.turns,
|
|
3254
|
-
[turnId]: next
|
|
3255
|
-
}
|
|
3256
|
-
};
|
|
3257
|
-
}
|
|
3258
|
-
function updateTask(state, taskId, update) {
|
|
3259
|
-
const task = state.tasks[taskId];
|
|
3260
|
-
if (task === void 0) return state;
|
|
3261
|
-
const next = update(task);
|
|
3262
|
-
return next === task ? state : {
|
|
3263
|
-
...state,
|
|
3264
|
-
tasks: {
|
|
3265
|
-
...state.tasks,
|
|
3266
|
-
[taskId]: next
|
|
3267
|
-
}
|
|
3268
|
-
};
|
|
3702
|
+
}, initialSessionProjection());
|
|
3269
3703
|
}
|
|
3270
3704
|
function updateObservation(state, sessionId, update) {
|
|
3271
3705
|
const agent = state.agents[sessionId];
|
|
@@ -3288,99 +3722,6 @@ function observedConversation(observation) {
|
|
|
3288
3722
|
}
|
|
3289
3723
|
function reduceConversationLifecycle(state, event) {
|
|
3290
3724
|
switch (event.type) {
|
|
3291
|
-
case "turn.started": return {
|
|
3292
|
-
...state,
|
|
3293
|
-
activeTurnId: event.data.turnId,
|
|
3294
|
-
turns: {
|
|
3295
|
-
...state.turns,
|
|
3296
|
-
[event.data.turnId]: {
|
|
3297
|
-
turnId: event.data.turnId,
|
|
3298
|
-
status: "active"
|
|
3299
|
-
}
|
|
3300
|
-
}
|
|
3301
|
-
};
|
|
3302
|
-
case "turn.waiting": return updateTurn(state, event.data.turnId, (turn) => turn.status === "active" && !turn.waiting ? {
|
|
3303
|
-
...turn,
|
|
3304
|
-
waiting: true
|
|
3305
|
-
} : turn);
|
|
3306
|
-
case "step.started": return updateTurn(state, event.data.turnId, (turn) => turn.waiting ? {
|
|
3307
|
-
turnId: turn.turnId,
|
|
3308
|
-
status: turn.status
|
|
3309
|
-
} : turn);
|
|
3310
|
-
case "turn.completed":
|
|
3311
|
-
case "turn.cancelled":
|
|
3312
|
-
case "turn.failed": {
|
|
3313
|
-
const { turnId } = event.data;
|
|
3314
|
-
return {
|
|
3315
|
-
...state,
|
|
3316
|
-
activeTurnId: state.activeTurnId === turnId ? void 0 : state.activeTurnId,
|
|
3317
|
-
turns: {
|
|
3318
|
-
...state.turns,
|
|
3319
|
-
[turnId]: {
|
|
3320
|
-
turnId,
|
|
3321
|
-
status: event.type === "turn.completed" ? "completed" : event.type === "turn.failed" ? "failed" : "cancelled"
|
|
3322
|
-
}
|
|
3323
|
-
}
|
|
3324
|
-
};
|
|
3325
|
-
}
|
|
3326
|
-
case "session.waiting":
|
|
3327
|
-
case "session.completed":
|
|
3328
|
-
case "session.failed": return state.activeTurnId === void 0 ? state : {
|
|
3329
|
-
...state,
|
|
3330
|
-
activeTurnId: void 0
|
|
3331
|
-
};
|
|
3332
|
-
case "task.started": {
|
|
3333
|
-
const { callId, kind, name, taskId, turnId } = event.data;
|
|
3334
|
-
const task = state.tasks[taskId] ?? {
|
|
3335
|
-
taskId,
|
|
3336
|
-
name,
|
|
3337
|
-
kind,
|
|
3338
|
-
calls: {}
|
|
3339
|
-
};
|
|
3340
|
-
if (task.calls[callId] !== void 0) return state;
|
|
3341
|
-
return {
|
|
3342
|
-
...state,
|
|
3343
|
-
tasks: {
|
|
3344
|
-
...state.tasks,
|
|
3345
|
-
[taskId]: {
|
|
3346
|
-
...task,
|
|
3347
|
-
calls: {
|
|
3348
|
-
...task.calls,
|
|
3349
|
-
[callId]: {
|
|
3350
|
-
callId,
|
|
3351
|
-
turnId,
|
|
3352
|
-
status: "working"
|
|
3353
|
-
}
|
|
3354
|
-
}
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3357
|
-
};
|
|
3358
|
-
}
|
|
3359
|
-
case "task.settled": {
|
|
3360
|
-
const { callId, error, output, status, taskId } = event.data;
|
|
3361
|
-
return updateTask(state, taskId, (task) => {
|
|
3362
|
-
const call = task.calls[callId];
|
|
3363
|
-
if (call === void 0 || call.status !== "working") return task;
|
|
3364
|
-
const settled = {
|
|
3365
|
-
callId,
|
|
3366
|
-
turnId: call.turnId,
|
|
3367
|
-
status
|
|
3368
|
-
};
|
|
3369
|
-
return {
|
|
3370
|
-
...task,
|
|
3371
|
-
calls: {
|
|
3372
|
-
...task.calls,
|
|
3373
|
-
[callId]: status === "completed" && output !== void 0 ? {
|
|
3374
|
-
...settled,
|
|
3375
|
-
output
|
|
3376
|
-
} : status === "failed" && error !== void 0 ? {
|
|
3377
|
-
...settled,
|
|
3378
|
-
error
|
|
3379
|
-
} : settled
|
|
3380
|
-
}
|
|
3381
|
-
};
|
|
3382
|
-
});
|
|
3383
|
-
}
|
|
3384
3725
|
case "agent.started": {
|
|
3385
3726
|
const { callId, name, sessionId, taskId, turnId } = event.data;
|
|
3386
3727
|
if (state.agents[sessionId] !== void 0) return state;
|
|
@@ -3392,31 +3733,13 @@ function reduceConversationLifecycle(state, event) {
|
|
|
3392
3733
|
observation: { status: "not-followed" }
|
|
3393
3734
|
};
|
|
3394
3735
|
if (taskId !== void 0) agent.taskId = taskId;
|
|
3395
|
-
return {
|
|
3736
|
+
return withConversationProjection({
|
|
3396
3737
|
...state,
|
|
3397
3738
|
agents: {
|
|
3398
3739
|
...state.agents,
|
|
3399
3740
|
[sessionId]: agent
|
|
3400
3741
|
}
|
|
3401
|
-
};
|
|
3402
|
-
}
|
|
3403
|
-
case "input.requested": {
|
|
3404
|
-
const inputs = { ...state.inputs };
|
|
3405
|
-
for (const request of event.data.requests) {
|
|
3406
|
-
if (inputs[request.requestId] !== void 0) continue;
|
|
3407
|
-
const input = {
|
|
3408
|
-
request,
|
|
3409
|
-
turnId: event.data.turnId,
|
|
3410
|
-
stepIndex: event.data.stepIndex,
|
|
3411
|
-
status: "open"
|
|
3412
|
-
};
|
|
3413
|
-
if (event.data.taskId !== void 0) input.taskId = event.data.taskId;
|
|
3414
|
-
inputs[request.requestId] = input;
|
|
3415
|
-
}
|
|
3416
|
-
return {
|
|
3417
|
-
...state,
|
|
3418
|
-
inputs
|
|
3419
|
-
};
|
|
3742
|
+
}, conversationProjection(state));
|
|
3420
3743
|
}
|
|
3421
3744
|
case "client.input.responded": {
|
|
3422
3745
|
const inputs = { ...state.inputs };
|
|
@@ -3429,64 +3752,33 @@ function reduceConversationLifecycle(state, event) {
|
|
|
3429
3752
|
status: "responded"
|
|
3430
3753
|
};
|
|
3431
3754
|
}
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
case "approval.candidate": {
|
|
3438
|
-
const current = state.inputs[event.data.requestId];
|
|
3439
|
-
if (current === void 0 || current.status === "settled") return state;
|
|
3440
|
-
if (event.data.outcome === "pending") return state;
|
|
3441
|
-
return {
|
|
3442
|
-
...state,
|
|
3443
|
-
inputs: {
|
|
3444
|
-
...state.inputs,
|
|
3445
|
-
[event.data.requestId]: {
|
|
3446
|
-
...current,
|
|
3447
|
-
status: "open",
|
|
3448
|
-
response: void 0
|
|
3449
|
-
}
|
|
3450
|
-
}
|
|
3451
|
-
};
|
|
3452
|
-
}
|
|
3453
|
-
case "approval.settled": {
|
|
3454
|
-
const current = state.inputs[event.data.requestId];
|
|
3455
|
-
if (current === void 0 || current.status === "settled") return state;
|
|
3456
|
-
return {
|
|
3457
|
-
...state,
|
|
3458
|
-
inputs: {
|
|
3459
|
-
...state.inputs,
|
|
3460
|
-
[event.data.requestId]: {
|
|
3461
|
-
...current,
|
|
3462
|
-
status: "settled",
|
|
3463
|
-
outcome: event.data.outcome
|
|
3464
|
-
}
|
|
3465
|
-
}
|
|
3466
|
-
};
|
|
3467
|
-
}
|
|
3468
|
-
case "input.resolved": {
|
|
3469
|
-
const inputs = { ...state.inputs };
|
|
3470
|
-
for (const resolution of event.data.resolutions) {
|
|
3471
|
-
const current = inputs[resolution.requestId];
|
|
3472
|
-
if (current === void 0 || current.status === "settled") continue;
|
|
3473
|
-
inputs[resolution.requestId] = {
|
|
3755
|
+
const projection = conversationProjection(state);
|
|
3756
|
+
const projectedInputs = { ...projection.inputs };
|
|
3757
|
+
for (const response of event.data.responses) {
|
|
3758
|
+
const current = projectedInputs[response.requestId];
|
|
3759
|
+
if (current?.status === "open") projectedInputs[response.requestId] = {
|
|
3474
3760
|
...current,
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
response: resolution.response ?? current.response
|
|
3761
|
+
response,
|
|
3762
|
+
status: "responded"
|
|
3478
3763
|
};
|
|
3479
3764
|
}
|
|
3480
|
-
return {
|
|
3765
|
+
return withConversationProjection({
|
|
3481
3766
|
...state,
|
|
3482
3767
|
inputs
|
|
3483
|
-
}
|
|
3768
|
+
}, {
|
|
3769
|
+
...projection,
|
|
3770
|
+
inputs: projectedInputs
|
|
3771
|
+
});
|
|
3484
3772
|
}
|
|
3485
3773
|
default: return state;
|
|
3486
3774
|
}
|
|
3487
3775
|
}
|
|
3488
3776
|
const messageReducer = defaultMessageReducer();
|
|
3489
3777
|
function reduceConversation(state, event) {
|
|
3778
|
+
const next = reduceConversationEvent(state, event);
|
|
3779
|
+
return event.type.startsWith("client.agent.") ? withConversationProjection(next, conversationProjection(state)) : next;
|
|
3780
|
+
}
|
|
3781
|
+
function reduceConversationEvent(state, event) {
|
|
3490
3782
|
switch (event.type) {
|
|
3491
3783
|
case "client.agent.following": return updateObservation(state, event.data.sessionId, (observation) => observation.status === "following" ? observation : {
|
|
3492
3784
|
status: "following",
|
|
@@ -3507,13 +3799,31 @@ function reduceConversation(state, event) {
|
|
|
3507
3799
|
conversation
|
|
3508
3800
|
};
|
|
3509
3801
|
});
|
|
3510
|
-
default:
|
|
3511
|
-
const
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3802
|
+
default:
|
|
3803
|
+
const messages = messageReducer.reduce(state, event);
|
|
3804
|
+
const projection = conversationProjection(messages);
|
|
3805
|
+
const { activeTurnId: _activeTurnId, ...rest } = state;
|
|
3806
|
+
const { activeTurnId: _messageTurnId, ...messageData } = messages;
|
|
3807
|
+
const conversation = {
|
|
3808
|
+
...rest,
|
|
3809
|
+
...messageData,
|
|
3810
|
+
turns: Object.fromEntries(Object.entries(projection.turns).map(([id, turn]) => {
|
|
3811
|
+
const { turnId, status, waiting } = turn;
|
|
3812
|
+
const publicTurn = {
|
|
3813
|
+
turnId,
|
|
3814
|
+
status
|
|
3815
|
+
};
|
|
3816
|
+
if (waiting !== void 0) publicTurn.waiting = waiting;
|
|
3817
|
+
return [id, publicTurn];
|
|
3818
|
+
})),
|
|
3819
|
+
inputs: Object.fromEntries(Object.entries(projection.inputs).map(([id, input]) => {
|
|
3820
|
+
const { sequence: _sequence, callId: _callId, ...publicInput } = input;
|
|
3821
|
+
return [id, publicInput];
|
|
3822
|
+
})),
|
|
3823
|
+
tasks: projection.tasks
|
|
3824
|
+
};
|
|
3825
|
+
if (projection.activeTurnId !== void 0) conversation.activeTurnId = projection.activeTurnId;
|
|
3826
|
+
return reduceConversationLifecycle(withConversationProjection(conversation, projection), event);
|
|
3517
3827
|
}
|
|
3518
3828
|
}
|
|
3519
3829
|
const canonicalConversationReducer = {
|
|
@@ -4369,4 +4679,4 @@ function useEveAgent(options = {}) {
|
|
|
4369
4679
|
}
|
|
4370
4680
|
|
|
4371
4681
|
//#endregion
|
|
4372
|
-
export { openConversationInputs as i, conversationReducer as n, defaultMessageReducer as r, useEveAgent as t };
|
|
4682
|
+
export { conversationProjection as a, openConversationInputs as i, conversationReducer as n, callStatus as o, defaultMessageReducer as r, useEveAgent as t };
|