experimental-ash 0.2.0-alpha.2 → 0.2.0-alpha.21
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/dist/src/channel/http-channel.d.ts +26 -0
- package/dist/src/channel/http-channel.d.ts.map +1 -0
- package/dist/src/channel/http-channel.js +24 -0
- package/dist/src/channel/http-channel.js.map +1 -0
- package/dist/src/channel/resolve-text.d.ts +20 -0
- package/dist/src/channel/resolve-text.d.ts.map +1 -0
- package/dist/src/channel/resolve-text.js +60 -0
- package/dist/src/channel/resolve-text.js.map +1 -0
- package/dist/src/channel/schedule-channel.d.ts +16 -0
- package/dist/src/channel/schedule-channel.d.ts.map +1 -0
- package/dist/src/channel/schedule-channel.js +20 -0
- package/dist/src/channel/schedule-channel.js.map +1 -0
- package/dist/src/channel/schedule.d.ts +4 -6
- package/dist/src/channel/schedule.d.ts.map +1 -1
- package/dist/src/channel/schedule.js +6 -9
- package/dist/src/channel/schedule.js.map +1 -1
- package/dist/src/channel/slack-channel.d.ts +125 -0
- package/dist/src/channel/slack-channel.d.ts.map +1 -0
- package/dist/src/channel/slack-channel.js +320 -0
- package/dist/src/channel/slack-channel.js.map +1 -0
- package/dist/src/channel/subagent-channel.d.ts +41 -0
- package/dist/src/channel/subagent-channel.d.ts.map +1 -0
- package/dist/src/channel/{subagent-emitter.js → subagent-channel.js} +15 -19
- package/dist/src/channel/subagent-channel.js.map +1 -0
- package/dist/src/channel/types.d.ts +157 -90
- package/dist/src/channel/types.d.ts.map +1 -1
- package/dist/src/channel/types.js +64 -1
- package/dist/src/channel/types.js.map +1 -1
- package/dist/src/cli/dev/input-requests.d.ts +4 -4
- package/dist/src/cli/dev/input-requests.d.ts.map +1 -1
- package/dist/src/cli/dev/input-requests.js +34 -65
- package/dist/src/cli/dev/input-requests.js.map +1 -1
- package/dist/src/cli/dev/repl.d.ts.map +1 -1
- package/dist/src/cli/dev/repl.js +41 -24
- package/dist/src/cli/dev/repl.js.map +1 -1
- package/dist/src/client/index.d.ts +3 -2
- package/dist/src/client/index.d.ts.map +1 -1
- package/dist/src/client/index.js +1 -0
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/client/message-response.d.ts +5 -5
- package/dist/src/client/message-response.d.ts.map +1 -1
- package/dist/src/client/message-response.js +6 -6
- package/dist/src/client/message-response.js.map +1 -1
- package/dist/src/client/open-stream.d.ts +1 -1
- package/dist/src/client/open-stream.d.ts.map +1 -1
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/open-stream.js.map +1 -1
- package/dist/src/client/session-utils.d.ts +3 -3
- package/dist/src/client/session-utils.d.ts.map +1 -1
- package/dist/src/client/session-utils.js +4 -4
- package/dist/src/client/session-utils.js.map +1 -1
- package/dist/src/client/session.d.ts +5 -5
- package/dist/src/client/session.js +28 -28
- package/dist/src/client/session.js.map +1 -1
- package/dist/src/client/types.d.ts +8 -8
- package/dist/src/client/types.d.ts.map +1 -1
- package/dist/src/compiler/channel-url.d.ts +1 -1
- package/dist/src/compiler/channel-url.js +1 -1
- package/dist/src/compiler/manifest.d.ts +38 -5
- package/dist/src/compiler/manifest.d.ts.map +1 -1
- package/dist/src/compiler/manifest.js +15 -1
- package/dist/src/compiler/manifest.js.map +1 -1
- package/dist/src/compiler/module-map.js +8 -0
- package/dist/src/compiler/module-map.js.map +1 -1
- package/dist/src/compiler/normalize-channel.d.ts +1 -1
- package/dist/src/compiler/normalize-channel.js +3 -3
- package/dist/src/compiler/normalize-channel.js.map +1 -1
- package/dist/src/compiler/normalize-connection.d.ts +14 -0
- package/dist/src/compiler/normalize-connection.d.ts.map +1 -0
- package/dist/src/compiler/normalize-connection.js +29 -0
- package/dist/src/compiler/normalize-connection.js.map +1 -0
- package/dist/src/compiler/normalize-manifest.d.ts.map +1 -1
- package/dist/src/compiler/normalize-manifest.js +2 -0
- package/dist/src/compiler/normalize-manifest.js.map +1 -1
- package/dist/src/context/accessors.d.ts +13 -12
- package/dist/src/context/accessors.d.ts.map +1 -1
- package/dist/src/context/accessors.js +16 -17
- package/dist/src/context/accessors.js.map +1 -1
- package/dist/src/context/container.d.ts +17 -19
- package/dist/src/context/container.d.ts.map +1 -1
- package/dist/src/context/container.js +21 -14
- package/dist/src/context/container.js.map +1 -1
- package/dist/src/context/durable-context.d.ts +18 -0
- package/dist/src/context/durable-context.d.ts.map +1 -0
- package/dist/src/context/durable-context.js +49 -0
- package/dist/src/context/durable-context.js.map +1 -0
- package/dist/src/context/key.d.ts +43 -83
- package/dist/src/context/key.d.ts.map +1 -1
- package/dist/src/context/key.js +58 -80
- package/dist/src/context/key.js.map +1 -1
- package/dist/src/context/keys.d.ts +8 -20
- package/dist/src/context/keys.d.ts.map +1 -1
- package/dist/src/context/keys.js +20 -34
- package/dist/src/context/keys.js.map +1 -1
- package/dist/src/context/provider.d.ts +2 -2
- package/dist/src/context/provider.d.ts.map +1 -1
- package/dist/src/context/providers/connection.d.ts +4 -0
- package/dist/src/context/providers/connection.d.ts.map +1 -0
- package/dist/src/context/providers/connection.js +18 -0
- package/dist/src/context/providers/connection.js.map +1 -0
- package/dist/src/context/providers/session.d.ts.map +1 -1
- package/dist/src/context/providers/session.js +1 -2
- package/dist/src/context/providers/session.js.map +1 -1
- package/dist/src/context/providers/skill.d.ts.map +1 -1
- package/dist/src/context/providers/skill.js +2 -15
- package/dist/src/context/providers/skill.js.map +1 -1
- package/dist/src/context/run-step.d.ts +6 -8
- package/dist/src/context/run-step.d.ts.map +1 -1
- package/dist/src/context/run-step.js +15 -17
- package/dist/src/context/run-step.js.map +1 -1
- package/dist/src/context/seed-keys.d.ts +21 -0
- package/dist/src/context/seed-keys.d.ts.map +1 -0
- package/dist/src/context/seed-keys.js +31 -0
- package/dist/src/context/seed-keys.js.map +1 -0
- package/dist/src/context/serialize.d.ts +8 -9
- package/dist/src/context/serialize.d.ts.map +1 -1
- package/dist/src/context/serialize.js +38 -15
- package/dist/src/context/serialize.js.map +1 -1
- package/dist/src/discover/connections.d.ts +48 -0
- package/dist/src/discover/connections.d.ts.map +1 -0
- package/dist/src/discover/connections.js +169 -0
- package/dist/src/discover/connections.js.map +1 -0
- package/dist/src/discover/discover-agent.d.ts +1 -0
- package/dist/src/discover/discover-agent.d.ts.map +1 -1
- package/dist/src/discover/discover-agent.js +8 -0
- package/dist/src/discover/discover-agent.js.map +1 -1
- package/dist/src/discover/discover-subagent.js +7 -0
- package/dist/src/discover/discover-subagent.js.map +1 -1
- package/dist/src/discover/filesystem.d.ts +3 -3
- package/dist/src/discover/filesystem.d.ts.map +1 -1
- package/dist/src/discover/filesystem.js +7 -0
- package/dist/src/discover/filesystem.js.map +1 -1
- package/dist/src/discover/grammar.d.ts +20 -4
- package/dist/src/discover/grammar.d.ts.map +1 -1
- package/dist/src/discover/grammar.js +31 -5
- package/dist/src/discover/grammar.js.map +1 -1
- package/dist/src/discover/manifest.d.ts +28 -1
- package/dist/src/discover/manifest.d.ts.map +1 -1
- package/dist/src/discover/manifest.js +11 -1
- package/dist/src/discover/manifest.js.map +1 -1
- package/dist/src/evals/runner/artifacts.js +1 -1
- package/dist/src/evals/runner/artifacts.js.map +1 -1
- package/dist/src/evals/runner/derive-run-facts.js +5 -5
- package/dist/src/evals/runner/derive-run-facts.js.map +1 -1
- package/dist/src/evals/runner/execute-case.js +4 -4
- package/dist/src/evals/runner/execute-case.js.map +1 -1
- package/dist/src/evals/runner/execute-suite.js +1 -1
- package/dist/src/evals/runner/execute-suite.js.map +1 -1
- package/dist/src/evals/runner/reporters/braintrust.js +2 -2
- package/dist/src/evals/runner/reporters/braintrust.js.map +1 -1
- package/dist/src/evals/types.d.ts +4 -4
- package/dist/src/evals/types.d.ts.map +1 -1
- package/dist/src/execution/continuous-entry.d.ts +18 -9
- package/dist/src/execution/continuous-entry.d.ts.map +1 -1
- package/dist/src/execution/continuous-entry.js +62 -18
- package/dist/src/execution/continuous-entry.js.map +1 -1
- package/dist/src/execution/continuous-runtime.d.ts +1 -1
- package/dist/src/execution/continuous-runtime.d.ts.map +1 -1
- package/dist/src/execution/continuous-runtime.js +14 -10
- package/dist/src/execution/continuous-runtime.js.map +1 -1
- package/dist/src/execution/node-step.d.ts +1 -2
- package/dist/src/execution/node-step.d.ts.map +1 -1
- package/dist/src/execution/node-step.js +42 -55
- package/dist/src/execution/node-step.js.map +1 -1
- package/dist/src/execution/runtime-context.d.ts +3 -0
- package/dist/src/execution/runtime-context.d.ts.map +1 -1
- package/dist/src/execution/runtime-context.js +6 -4
- package/dist/src/execution/runtime-context.js.map +1 -1
- package/dist/src/execution/session.d.ts +2 -1
- package/dist/src/execution/session.d.ts.map +1 -1
- package/dist/src/execution/session.js +1 -0
- package/dist/src/execution/session.js.map +1 -1
- package/dist/src/execution/skills/access.d.ts.map +1 -1
- package/dist/src/execution/skills/instructions.d.ts +6 -6
- package/dist/src/execution/skills/instructions.d.ts.map +1 -1
- package/dist/src/execution/skills/instructions.js +15 -15
- package/dist/src/execution/skills/instructions.js.map +1 -1
- package/dist/src/execution/skills/types.d.ts +4 -4
- package/dist/src/execution/skills/types.d.ts.map +1 -1
- package/dist/src/execution/step-context.d.ts +27 -0
- package/dist/src/execution/step-context.d.ts.map +1 -0
- package/dist/src/execution/step-context.js +54 -0
- package/dist/src/execution/step-context.js.map +1 -0
- package/dist/src/execution/subagent-tool.d.ts +1 -1
- package/dist/src/execution/subagent-tool.d.ts.map +1 -1
- package/dist/src/execution/subagent-tool.js +3 -4
- package/dist/src/execution/subagent-tool.js.map +1 -1
- package/dist/src/execution/tool-compaction.d.ts +1 -3
- package/dist/src/execution/tool-compaction.d.ts.map +1 -1
- package/dist/src/execution/tool-compaction.js +6 -20
- package/dist/src/execution/tool-compaction.js.map +1 -1
- package/dist/src/execution/types.d.ts +1 -1
- package/dist/src/execution/types.d.ts.map +1 -1
- package/dist/src/execution/workflow-entry.d.ts +4 -5
- package/dist/src/execution/workflow-entry.d.ts.map +1 -1
- package/dist/src/execution/workflow-entry.js +7 -2
- package/dist/src/execution/workflow-entry.js.map +1 -1
- package/dist/src/execution/workflow-runtime.d.ts.map +1 -1
- package/dist/src/execution/workflow-runtime.js +10 -5
- package/dist/src/execution/workflow-runtime.js.map +1 -1
- package/dist/src/execution/workflow-steps.d.ts +13 -6
- package/dist/src/execution/workflow-steps.d.ts.map +1 -1
- package/dist/src/execution/workflow-steps.js +24 -19
- package/dist/src/execution/workflow-steps.js.map +1 -1
- package/dist/src/harness/emission.d.ts +36 -27
- package/dist/src/harness/emission.d.ts.map +1 -1
- package/dist/src/harness/emission.js +130 -84
- package/dist/src/harness/emission.js.map +1 -1
- package/dist/src/harness/execute-tool.d.ts +52 -0
- package/dist/src/harness/execute-tool.d.ts.map +1 -0
- package/dist/src/harness/execute-tool.js +59 -0
- package/dist/src/harness/execute-tool.js.map +1 -0
- package/dist/src/harness/input-extraction.d.ts +3 -3
- package/dist/src/harness/input-extraction.d.ts.map +1 -1
- package/dist/src/harness/input-extraction.js +15 -8
- package/dist/src/harness/input-extraction.js.map +1 -1
- package/dist/src/harness/input-requests.d.ts +46 -40
- package/dist/src/harness/input-requests.d.ts.map +1 -1
- package/dist/src/harness/input-requests.js +169 -245
- package/dist/src/harness/input-requests.js.map +1 -1
- package/dist/src/harness/messages.d.ts +10 -9
- package/dist/src/harness/messages.d.ts.map +1 -1
- package/dist/src/harness/messages.js +23 -20
- package/dist/src/harness/messages.js.map +1 -1
- package/dist/src/harness/provider-tools.d.ts +2 -2
- package/dist/src/harness/provider-tools.d.ts.map +1 -1
- package/dist/src/harness/provider-tools.js +7 -3
- package/dist/src/harness/provider-tools.js.map +1 -1
- package/dist/src/harness/step-hooks.d.ts +77 -0
- package/dist/src/harness/step-hooks.d.ts.map +1 -0
- package/dist/src/harness/step-hooks.js +192 -0
- package/dist/src/harness/step-hooks.js.map +1 -0
- package/dist/src/harness/tool-loop.d.ts +4 -2
- package/dist/src/harness/tool-loop.d.ts.map +1 -1
- package/dist/src/harness/tool-loop.js +130 -181
- package/dist/src/harness/tool-loop.js.map +1 -1
- package/dist/src/harness/tools.d.ts +12 -16
- package/dist/src/harness/tools.d.ts.map +1 -1
- package/dist/src/harness/tools.js +39 -33
- package/dist/src/harness/tools.js.map +1 -1
- package/dist/src/harness/types.d.ts +44 -28
- package/dist/src/harness/types.d.ts.map +1 -1
- package/dist/src/harness/types.js +6 -1
- package/dist/src/harness/types.js.map +1 -1
- package/dist/src/internal/application/compiled-artifacts.d.ts +5 -3
- package/dist/src/internal/application/compiled-artifacts.d.ts.map +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +19 -40
- package/dist/src/internal/application/compiled-artifacts.js.map +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/channel.d.ts +3 -3
- package/dist/src/internal/authored-definition/channel.d.ts.map +1 -1
- package/dist/src/internal/authored-definition/channel.js +28 -4
- package/dist/src/internal/authored-definition/channel.js.map +1 -1
- package/dist/src/internal/authored-definition/connection.d.ts +10 -0
- package/dist/src/internal/authored-definition/connection.d.ts.map +1 -0
- package/dist/src/internal/authored-definition/connection.js +134 -0
- package/dist/src/internal/authored-definition/connection.js.map +1 -0
- package/dist/src/internal/authored-module.js +1 -1
- package/dist/src/internal/authored-module.js.map +1 -1
- package/dist/src/internal/message/builder.d.ts +1 -2
- package/dist/src/internal/message/builder.d.ts.map +1 -1
- package/dist/src/internal/message/builder.js +4 -12
- package/dist/src/internal/message/builder.js.map +1 -1
- package/dist/src/internal/nitro/host/configure-message-routes.d.ts +3 -1
- package/dist/src/internal/nitro/host/configure-message-routes.d.ts.map +1 -1
- package/dist/src/internal/nitro/host/configure-message-routes.js +124 -25
- package/dist/src/internal/nitro/host/configure-message-routes.js.map +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts.map +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +63 -21
- package/dist/src/internal/nitro/host/create-application-nitro.js.map +1 -1
- package/dist/src/internal/nitro/host/load-home-page-web-assets.d.ts +13 -0
- package/dist/src/internal/nitro/host/load-home-page-web-assets.d.ts.map +1 -0
- package/dist/src/internal/nitro/host/load-home-page-web-assets.js +35 -0
- package/dist/src/internal/nitro/host/load-home-page-web-assets.js.map +1 -0
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/internal/nitro/host/prepare-application-host.js.map +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.d.ts +10 -18
- package/dist/src/internal/nitro/routes/channel-dispatch.d.ts.map +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +16 -45
- package/dist/src/internal/nitro/routes/channel-dispatch.js.map +1 -1
- package/dist/src/internal/nitro/routes/home-page/build-home-page-response.d.ts +88 -0
- package/dist/src/internal/nitro/routes/home-page/build-home-page-response.d.ts.map +1 -0
- package/dist/src/internal/nitro/routes/home-page/build-home-page-response.js +175 -0
- package/dist/src/internal/nitro/routes/home-page/build-home-page-response.js.map +1 -0
- package/dist/src/internal/nitro/routes/home.d.ts +7 -0
- package/dist/src/internal/nitro/routes/home.d.ts.map +1 -0
- package/dist/src/internal/nitro/routes/home.js +22 -0
- package/dist/src/internal/nitro/routes/home.js.map +1 -0
- package/dist/src/internal/nitro/routes/index.d.ts +3 -8
- package/dist/src/internal/nitro/routes/index.d.ts.map +1 -1
- package/dist/src/internal/nitro/routes/index.js +18 -36
- package/dist/src/internal/nitro/routes/index.js.map +1 -1
- package/dist/src/internal/nitro/routes/runtime-artifacts.d.ts +10 -3
- package/dist/src/internal/nitro/routes/runtime-artifacts.d.ts.map +1 -1
- package/dist/src/internal/nitro/routes/runtime-artifacts.js +2 -9
- package/dist/src/internal/nitro/routes/runtime-artifacts.js.map +1 -1
- package/dist/src/internal/nitro/routes/runtime-stack.d.ts +8 -7
- package/dist/src/internal/nitro/routes/runtime-stack.d.ts.map +1 -1
- package/dist/src/internal/nitro/routes/runtime-stack.js +10 -10
- package/dist/src/internal/nitro/routes/runtime-stack.js.map +1 -1
- package/dist/src/internal/nitro/routes/schedule-task.d.ts +7 -7
- package/dist/src/internal/nitro/routes/schedule-task.d.ts.map +1 -1
- package/dist/src/internal/nitro/routes/schedule-task.js +22 -30
- package/dist/src/internal/nitro/routes/schedule-task.js.map +1 -1
- package/dist/src/internal/nitro/routes/web-ui/assets/index.js +10 -0
- package/dist/src/internal/nitro/routes/web-ui/assets/style.css +2 -0
- package/dist/src/internal/nitro/routes/web-ui/index.html +17 -0
- package/dist/src/internal/nitro/routes/workflow-data.d.ts +32 -0
- package/dist/src/internal/nitro/routes/workflow-data.d.ts.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-data.js +142 -0
- package/dist/src/internal/nitro/routes/workflow-data.js.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-route-helpers.d.ts +46 -0
- package/dist/src/internal/nitro/routes/workflow-route-helpers.d.ts.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-route-helpers.js +137 -0
- package/dist/src/internal/nitro/routes/workflow-route-helpers.js.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-run-events.d.ts +14 -0
- package/dist/src/internal/nitro/routes/workflow-run-events.d.ts.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-run-events.js +42 -0
- package/dist/src/internal/nitro/routes/workflow-run-events.js.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-run-steps.d.ts +14 -0
- package/dist/src/internal/nitro/routes/workflow-run-steps.d.ts.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-run-steps.js +42 -0
- package/dist/src/internal/nitro/routes/workflow-run-steps.js.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-run.d.ts +13 -0
- package/dist/src/internal/nitro/routes/workflow-run.d.ts.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-run.js +35 -0
- package/dist/src/internal/nitro/routes/workflow-run.js.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-runs.d.ts +11 -0
- package/dist/src/internal/nitro/routes/workflow-runs.d.ts.map +1 -0
- package/dist/src/internal/nitro/routes/workflow-runs.js +29 -0
- package/dist/src/internal/nitro/routes/workflow-runs.js.map +1 -0
- package/dist/src/protocol/message.d.ts +160 -76
- package/dist/src/protocol/message.d.ts.map +1 -1
- package/dist/src/protocol/message.js +92 -36
- package/dist/src/protocol/message.js.map +1 -1
- package/dist/src/protocol/routes.d.ts +11 -3
- package/dist/src/protocol/routes.d.ts.map +1 -1
- package/dist/src/protocol/routes.js +12 -4
- package/dist/src/protocol/routes.js.map +1 -1
- package/dist/src/public/channels/auth.d.ts +32 -81
- package/dist/src/public/channels/auth.d.ts.map +1 -1
- package/dist/src/public/channels/auth.js +23 -86
- package/dist/src/public/channels/auth.js.map +1 -1
- package/dist/src/public/channels/http.d.ts +66 -26
- package/dist/src/public/channels/http.d.ts.map +1 -1
- package/dist/src/public/channels/http.js +88 -78
- package/dist/src/public/channels/http.js.map +1 -1
- package/dist/src/public/channels/index.d.ts +9 -10
- package/dist/src/public/channels/index.d.ts.map +1 -1
- package/dist/src/public/channels/index.js +9 -9
- package/dist/src/public/channels/index.js.map +1 -1
- package/dist/src/public/channels/slack/index.d.ts +104 -37
- package/dist/src/public/channels/slack/index.d.ts.map +1 -1
- package/dist/src/public/channels/slack/index.js +168 -47
- package/dist/src/public/channels/slack/index.js.map +1 -1
- package/dist/src/public/channels/slack/lowlevel.d.ts +5 -5
- package/dist/src/public/channels/slack/lowlevel.d.ts.map +1 -1
- package/dist/src/public/channels/slack/lowlevel.js +4 -4
- package/dist/src/public/channels/slack/lowlevel.js.map +1 -1
- package/dist/src/public/connections/index.d.ts +25 -0
- package/dist/src/public/connections/index.d.ts.map +1 -0
- package/dist/src/public/connections/index.js +24 -0
- package/dist/src/public/connections/index.js.map +1 -0
- package/dist/src/public/definitions/channel.d.ts +89 -60
- package/dist/src/public/definitions/channel.d.ts.map +1 -1
- package/dist/src/public/definitions/channel.js +42 -24
- package/dist/src/public/definitions/channel.js.map +1 -1
- package/dist/src/public/definitions/connections/mcp.d.ts +60 -0
- package/dist/src/public/definitions/connections/mcp.d.ts.map +1 -0
- package/dist/src/public/definitions/connections/mcp.js +7 -0
- package/dist/src/public/definitions/connections/mcp.js.map +1 -0
- package/dist/src/public/definitions/tool.d.ts +14 -7
- package/dist/src/public/definitions/tool.d.ts.map +1 -1
- package/dist/src/public/definitions/tool.js.map +1 -1
- package/dist/src/public/index.d.ts +10 -9
- package/dist/src/public/index.d.ts.map +1 -1
- package/dist/src/public/index.js +7 -6
- package/dist/src/public/index.js.map +1 -1
- package/dist/src/public/sandboxes/internal.d.ts +1 -1
- package/dist/src/public/sandboxes/internal.js +1 -1
- package/dist/src/public/tools/defaults.d.ts +6 -6
- package/dist/src/public/tools/defaults.d.ts.map +1 -1
- package/dist/src/public/tools/defaults.js +6 -6
- package/dist/src/public/tools/defaults.js.map +1 -1
- package/dist/src/public/tools/internal.d.ts +1 -1
- package/dist/src/public/tools/internal.js +1 -1
- package/dist/src/runtime/actions/types.d.ts +21 -18
- package/dist/src/runtime/actions/types.d.ts.map +1 -1
- package/dist/src/runtime/actions/types.js +22 -19
- package/dist/src/runtime/actions/types.js.map +1 -1
- package/dist/src/runtime/agent/bootstrap-model-utils.d.ts +37 -0
- package/dist/src/runtime/agent/bootstrap-model-utils.d.ts.map +1 -0
- package/dist/src/runtime/agent/bootstrap-model-utils.js +149 -0
- package/dist/src/runtime/agent/bootstrap-model-utils.js.map +1 -0
- package/dist/src/runtime/agent/bootstrap-model.d.ts.map +1 -1
- package/dist/src/runtime/agent/bootstrap-model.js +11 -80
- package/dist/src/runtime/agent/bootstrap-model.js.map +1 -1
- package/dist/src/runtime/agent/bootstrap.d.ts.map +1 -1
- package/dist/src/runtime/agent/bootstrap.js +4 -1
- package/dist/src/runtime/agent/bootstrap.js.map +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.d.ts.map +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +72 -134
- package/dist/src/runtime/agent/mock-model-adapter.js.map +1 -1
- package/dist/src/runtime/channels/registry.d.ts +21 -0
- package/dist/src/runtime/channels/registry.d.ts.map +1 -0
- package/dist/src/runtime/channels/registry.js +65 -0
- package/dist/src/runtime/channels/registry.js.map +1 -0
- package/dist/src/runtime/connections/mcp-client.d.ts +48 -0
- package/dist/src/runtime/connections/mcp-client.d.ts.map +1 -0
- package/dist/src/runtime/connections/mcp-client.js +182 -0
- package/dist/src/runtime/connections/mcp-client.js.map +1 -0
- package/dist/src/runtime/connections/registry.d.ts +33 -0
- package/dist/src/runtime/connections/registry.d.ts.map +1 -0
- package/dist/src/runtime/connections/registry.js +54 -0
- package/dist/src/runtime/connections/registry.js.map +1 -0
- package/dist/src/runtime/connections/types.d.ts +75 -0
- package/dist/src/runtime/connections/types.d.ts.map +1 -0
- package/dist/src/runtime/connections/types.js +9 -0
- package/dist/src/runtime/connections/types.js.map +1 -0
- package/dist/src/runtime/framework-channels/index.d.ts +6 -6
- package/dist/src/runtime/framework-channels/index.d.ts.map +1 -1
- package/dist/src/runtime/framework-channels/index.js +16 -14
- package/dist/src/runtime/framework-channels/index.js.map +1 -1
- package/dist/src/runtime/framework-tools/ask-question.js +4 -4
- package/dist/src/runtime/framework-tools/ask-question.js.map +1 -1
- package/dist/src/runtime/framework-tools/connection-execute.d.ts +10 -0
- package/dist/src/runtime/framework-tools/connection-execute.d.ts.map +1 -0
- package/dist/src/runtime/framework-tools/connection-execute.js +50 -0
- package/dist/src/runtime/framework-tools/connection-execute.js.map +1 -0
- package/dist/src/runtime/framework-tools/connection-search.d.ts +43 -0
- package/dist/src/runtime/framework-tools/connection-search.d.ts.map +1 -0
- package/dist/src/runtime/framework-tools/connection-search.js +135 -0
- package/dist/src/runtime/framework-tools/connection-search.js.map +1 -0
- package/dist/src/runtime/framework-tools/file-state.d.ts +5 -5
- package/dist/src/runtime/framework-tools/file-state.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/file-state.js +6 -8
- package/dist/src/runtime/framework-tools/file-state.js.map +1 -1
- package/dist/src/runtime/framework-tools/index.d.ts +3 -1
- package/dist/src/runtime/framework-tools/index.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/index.js +10 -1
- package/dist/src/runtime/framework-tools/index.js.map +1 -1
- package/dist/src/runtime/framework-tools/skill.d.ts +4 -4
- package/dist/src/runtime/framework-tools/skill.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/skill.js +14 -11
- package/dist/src/runtime/framework-tools/skill.js.map +1 -1
- package/dist/src/runtime/framework-tools/todo.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/todo.js +2 -4
- package/dist/src/runtime/framework-tools/todo.js.map +1 -1
- package/dist/src/runtime/input/types.d.ts +40 -115
- package/dist/src/runtime/input/types.d.ts.map +1 -1
- package/dist/src/runtime/input/types.js +28 -66
- package/dist/src/runtime/input/types.js.map +1 -1
- package/dist/src/runtime/loaders/module-map.js +8 -0
- package/dist/src/runtime/loaders/module-map.js.map +1 -1
- package/dist/src/runtime/prompt/compose.d.ts +4 -1
- package/dist/src/runtime/prompt/compose.d.ts.map +1 -1
- package/dist/src/runtime/prompt/compose.js +18 -1
- package/dist/src/runtime/prompt/compose.js.map +1 -1
- package/dist/src/runtime/prompt/connections.d.ts +10 -0
- package/dist/src/runtime/prompt/connections.d.ts.map +1 -0
- package/dist/src/runtime/prompt/connections.js +25 -0
- package/dist/src/runtime/prompt/connections.js.map +1 -0
- package/dist/src/runtime/resolve-agent-graph.d.ts.map +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +29 -7
- package/dist/src/runtime/resolve-agent-graph.js.map +1 -1
- package/dist/src/runtime/resolve-agent.d.ts.map +1 -1
- package/dist/src/runtime/resolve-agent.js +3 -0
- package/dist/src/runtime/resolve-agent.js.map +1 -1
- package/dist/src/runtime/resolve-channel.d.ts.map +1 -1
- package/dist/src/runtime/resolve-channel.js +1 -0
- package/dist/src/runtime/resolve-channel.js.map +1 -1
- package/dist/src/runtime/resolve-connection.d.ts +16 -0
- package/dist/src/runtime/resolve-connection.d.ts.map +1 -0
- package/dist/src/runtime/resolve-connection.js +69 -0
- package/dist/src/runtime/resolve-connection.js.map +1 -0
- package/dist/src/runtime/resolve-tool.d.ts.map +1 -1
- package/dist/src/runtime/resolve-tool.js +8 -0
- package/dist/src/runtime/resolve-tool.js.map +1 -1
- package/dist/src/runtime/sessions/auth.d.ts +1 -1
- package/dist/src/runtime/sessions/compiled-agent-cache.d.ts +2 -0
- package/dist/src/runtime/sessions/compiled-agent-cache.d.ts.map +1 -1
- package/dist/src/runtime/sessions/compiled-agent-cache.js +14 -0
- package/dist/src/runtime/sessions/compiled-agent-cache.js.map +1 -1
- package/dist/src/runtime/skills/fragment-context.d.ts +2 -2
- package/dist/src/runtime/skills/fragment-context.d.ts.map +1 -1
- package/dist/src/runtime/skills/fragment-context.js +2 -2
- package/dist/src/runtime/skills/fragment-context.js.map +1 -1
- package/dist/src/runtime/standard-schema.d.ts +28 -0
- package/dist/src/runtime/standard-schema.d.ts.map +1 -0
- package/dist/src/runtime/standard-schema.js +65 -0
- package/dist/src/runtime/standard-schema.js.map +1 -0
- package/dist/src/runtime/types.d.ts +29 -3
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/services/dev-client/send-message.d.ts +2 -2
- package/dist/src/services/dev-client/send-message.d.ts.map +1 -1
- package/dist/src/services/dev-client/send-message.js +21 -22
- package/dist/src/services/dev-client/send-message.js.map +1 -1
- package/dist/src/services/dev-client/session.d.ts +5 -5
- package/dist/src/services/dev-client/session.d.ts.map +1 -1
- package/dist/src/services/dev-client/session.js +2 -2
- package/dist/src/services/dev-client/session.js.map +1 -1
- package/dist/src/services/dev-client.d.ts +6 -6
- package/dist/src/services/dev-client.d.ts.map +1 -1
- package/dist/src/services/dev-client.js +3 -3
- package/dist/src/services/dev-client.js.map +1 -1
- package/docs/external-agent-protocol.md +37 -34
- package/docs/internals/channels.md +15 -12
- package/docs/internals/context.md +81 -161
- package/docs/internals/message-runtime.md +28 -26
- package/docs/public/README.md +22 -20
- package/docs/public/auth-and-route-protection.md +15 -12
- package/docs/public/channels/README.md +16 -11
- package/docs/public/cli-build-and-debugging.md +1 -1
- package/docs/public/context-control.md +7 -3
- package/docs/public/evals.md +3 -3
- package/docs/public/getting-started.md +15 -12
- package/docs/public/human-in-the-loop.md +45 -57
- package/docs/public/migration-guide.md +71 -0
- package/docs/public/project-layout.md +5 -0
- package/docs/public/runs-and-streaming.md +32 -25
- package/docs/public/schedules.md +4 -4
- package/docs/public/session-context.md +131 -15
- package/docs/public/skills.md +27 -3
- package/docs/public/subagents.md +2 -2
- package/docs/public/tools.md +23 -30
- package/docs/public/typescript-api.md +16 -12
- package/docs/public/vercel-deployment.md +3 -4
- package/docs/public/workspace.md +11 -11
- package/package.json +18 -11
- package/dist/src/channel/emitter-registry.d.ts +0 -34
- package/dist/src/channel/emitter-registry.d.ts.map +0 -1
- package/dist/src/channel/emitter-registry.js +0 -63
- package/dist/src/channel/emitter-registry.js.map +0 -1
- package/dist/src/channel/http-emitter.d.ts +0 -16
- package/dist/src/channel/http-emitter.d.ts.map +0 -1
- package/dist/src/channel/http-emitter.js +0 -22
- package/dist/src/channel/http-emitter.js.map +0 -1
- package/dist/src/channel/schedule-emitter.d.ts +0 -15
- package/dist/src/channel/schedule-emitter.d.ts.map +0 -1
- package/dist/src/channel/schedule-emitter.js +0 -21
- package/dist/src/channel/schedule-emitter.js.map +0 -1
- package/dist/src/channel/slack-emitter.d.ts +0 -56
- package/dist/src/channel/slack-emitter.d.ts.map +0 -1
- package/dist/src/channel/slack-emitter.js +0 -235
- package/dist/src/channel/slack-emitter.js.map +0 -1
- package/dist/src/channel/subagent-emitter.d.ts +0 -41
- package/dist/src/channel/subagent-emitter.d.ts.map +0 -1
- package/dist/src/channel/subagent-emitter.js.map +0 -1
- package/dist/src/context/state.d.ts +0 -27
- package/dist/src/context/state.d.ts.map +0 -1
- package/dist/src/context/state.js +0 -53
- package/dist/src/context/state.js.map +0 -1
- package/dist/src/internal/message/nitro-route-shims.d.ts +0 -6
- package/dist/src/internal/message/nitro-route-shims.d.ts.map +0 -1
- package/dist/src/internal/message/nitro-route-shims.js +0 -38
- package/dist/src/internal/message/nitro-route-shims.js.map +0 -1
- package/dist/src/internal/message/rewrite-generated-imports.d.ts +0 -15
- package/dist/src/internal/message/rewrite-generated-imports.d.ts.map +0 -1
- package/dist/src/internal/message/rewrite-generated-imports.js +0 -59
- package/dist/src/internal/message/rewrite-generated-imports.js.map +0 -1
- package/dist/src/internal/nitro/host/channel-url-matcher.d.ts +0 -35
- package/dist/src/internal/nitro/host/channel-url-matcher.d.ts.map +0 -1
- package/dist/src/internal/nitro/host/channel-url-matcher.js +0 -57
- package/dist/src/internal/nitro/host/channel-url-matcher.js.map +0 -1
- package/dist/src/internal/nitro/routes/home-page/build-home-page-view-model.d.ts +0 -11
- package/dist/src/internal/nitro/routes/home-page/build-home-page-view-model.d.ts.map +0 -1
- package/dist/src/internal/nitro/routes/home-page/build-home-page-view-model.js +0 -264
- package/dist/src/internal/nitro/routes/home-page/build-home-page-view-model.js.map +0 -1
- package/dist/src/internal/nitro/routes/home-page/render-home-page.d.ts +0 -9
- package/dist/src/internal/nitro/routes/home-page/render-home-page.d.ts.map +0 -1
- package/dist/src/internal/nitro/routes/home-page/render-home-page.js +0 -15
- package/dist/src/internal/nitro/routes/home-page/render-home-page.js.map +0 -1
- package/dist/src/internal/nitro/routes/index.html +0 -525
- package/dist/src/internal/nitro/runtime-configuration.d.ts +0 -16
- package/dist/src/internal/nitro/runtime-configuration.d.ts.map +0 -1
- package/dist/src/internal/nitro/runtime-configuration.js +0 -23
- package/dist/src/internal/nitro/runtime-configuration.js.map +0 -1
- package/dist/src/internal/nitro/shims/runtime-configuration-plugin.d.ts +0 -10
- package/dist/src/internal/nitro/shims/runtime-configuration-plugin.d.ts.map +0 -1
- package/dist/src/internal/nitro/shims/runtime-configuration-plugin.js +0 -17
- package/dist/src/internal/nitro/shims/runtime-configuration-plugin.js.map +0 -1
- package/dist/src/runtime/tools/execute-tool.d.ts +0 -20
- package/dist/src/runtime/tools/execute-tool.d.ts.map +0 -1
- package/dist/src/runtime/tools/execute-tool.js +0 -69
- package/dist/src/runtime/tools/execute-tool.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { stepCountIs, ToolLoopAgent
|
|
2
|
-
import {
|
|
1
|
+
import { stepCountIs, ToolLoopAgent } from "ai";
|
|
2
|
+
import { createInputRequestedEvent } from "../protocol/message.js";
|
|
3
3
|
import { ASK_QUESTION_TOOL_NAME } from "../runtime/framework-tools/ask-question.js";
|
|
4
|
-
import {
|
|
5
|
-
import { emitCompletedStepOutput, emitToolCallActionsAndResults, emitTurnEpilogue, emitTurnPreamble, getHarnessEmissionState, setHarnessEmissionState, } from "./emission.js";
|
|
4
|
+
import { advanceStep, emitFailedStep, emitStreamContent, emitTurnEpilogue, emitTurnPreamble, getHarnessEmissionState, setHarnessEmissionState, } from "./emission.js";
|
|
6
5
|
import { extractQuestionInputRequests, extractToolApprovalInputRequests, } from "./input-extraction.js";
|
|
7
|
-
import {
|
|
6
|
+
import { consumeDeferredStepInput, getApprovedTools, hasDeferredStepInput, hasStepInput, resolvePendingInput, setPendingInputBatch, } from "./input-requests.js";
|
|
8
7
|
import { resolveAssistantStepText } from "./messages.js";
|
|
9
|
-
import { applyLastToolCacheBreakpoint,
|
|
8
|
+
import { applyLastToolCacheBreakpoint, detectPromptCachePath, getAnthropicCacheMarker, } from "./prompt-cache.js";
|
|
9
|
+
import { buildStepHooks, emitStepActions } from "./step-hooks.js";
|
|
10
10
|
import { buildToolSetWithProviderTools } from "./tools.js";
|
|
11
11
|
/**
|
|
12
12
|
* Creates a tool-loop harness step function backed by AI SDK `ToolLoopAgent`.
|
|
@@ -17,220 +17,169 @@ import { buildToolSetWithProviderTools } from "./tools.js";
|
|
|
17
17
|
* and let the agent execute any tool calls. Returns the updated session and a
|
|
18
18
|
* `next` instruction telling the runtime what to do.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* Step-internal work (step.started emission, compaction, prompt caching,
|
|
21
|
+
* action emission, step.completed) is delegated to `ToolLoopAgent` hooks
|
|
22
|
+
* via {@link buildStepHooks}. The harness itself owns only turn-level
|
|
23
|
+
* bookends, input resolution, and the continuation decision.
|
|
22
24
|
*/
|
|
23
25
|
export function createToolLoopHarness(config) {
|
|
24
26
|
const emit = config.emit;
|
|
25
27
|
async function runStep(initialSession, input) {
|
|
26
28
|
let session = initialSession;
|
|
27
29
|
let emissionState = getHarnessEmissionState(session);
|
|
30
|
+
// --- Input resolution ---------------------------------------------------
|
|
31
|
+
const stepInput = consumeDeferredStepInput({ input, session });
|
|
32
|
+
session = stepInput.session;
|
|
33
|
+
const pending = resolvePendingInput({ session, stepInput: stepInput.input });
|
|
34
|
+
if (pending.outcome === "unresolved") {
|
|
35
|
+
return { next: null, session: pending.session };
|
|
36
|
+
}
|
|
37
|
+
// --- Turn preamble ------------------------------------------------------
|
|
28
38
|
if (emit && hasStepInput(input)) {
|
|
29
39
|
emissionState = await emitTurnPreamble(emit, input ?? {}, emissionState, config.runtimeIdentity);
|
|
30
40
|
session = setHarnessEmissionState(session, emissionState);
|
|
31
41
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
// results when the session has a pending input batch (e.g. Slack
|
|
39
|
-
// user replies "yes" to approve a tool call).
|
|
40
|
-
const resolvedInput = resolveEmitterInput({
|
|
41
|
-
channelEmitter: config.channelEmitter,
|
|
42
|
-
session,
|
|
43
|
-
stepInput: stepInput.input,
|
|
44
|
-
});
|
|
45
|
-
session = recordApprovedTools({
|
|
46
|
-
inputResults: resolvedInput?.inputResults ?? [],
|
|
47
|
-
session,
|
|
48
|
-
});
|
|
49
|
-
const preparedInput = applyStepInputToMessages({ input: resolvedInput, session });
|
|
50
|
-
let messages = preparedInput.messages;
|
|
51
|
-
session = preparedInput.session;
|
|
42
|
+
session = pending.session;
|
|
43
|
+
const messages = pending.messages;
|
|
44
|
+
if (stepInput.input?.message !== undefined && !pending.deferredMessage) {
|
|
45
|
+
messages.push({ content: stepInput.input.message, role: "user" });
|
|
46
|
+
}
|
|
47
|
+
// --- Model + tools ------------------------------------------------------
|
|
52
48
|
const model = await config.resolveModel(session.agent.modelReference);
|
|
53
49
|
const cachePath = detectPromptCachePath(model);
|
|
54
|
-
const
|
|
55
|
-
? mergeGatewayAutoCaching(session.agent.modelReference.providerOptions)
|
|
56
|
-
: session.agent.modelReference.providerOptions);
|
|
57
|
-
if (shouldCompact(messages, session.compaction)) {
|
|
58
|
-
const compaction = await resolveCompactionModel({
|
|
59
|
-
compactionModelReference: session.agent.compactionModelReference,
|
|
60
|
-
model,
|
|
61
|
-
modelReference: session.agent.modelReference,
|
|
62
|
-
resolveModel: config.resolveModel,
|
|
63
|
-
});
|
|
64
|
-
if (emit) {
|
|
65
|
-
await emit(createCompactionRequestedEvent({
|
|
66
|
-
modelId: formatModelId(compaction.model),
|
|
67
|
-
runId: "",
|
|
68
|
-
sequence: emissionState.sequence,
|
|
69
|
-
sessionId: "",
|
|
70
|
-
thresholdPercent: 0,
|
|
71
|
-
turnId: emissionState.turnId,
|
|
72
|
-
usageInputTokens: getInputTokenCount(messages, session.compaction),
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
messages = await compactMessages(messages, compaction.model, session.compaction, compaction.providerOptions);
|
|
76
|
-
if (config.onCompaction) {
|
|
77
|
-
const compacted = await config.onCompaction(session);
|
|
78
|
-
session = compacted.session;
|
|
79
|
-
for (const msg of compacted.messages) {
|
|
80
|
-
messages.push(msg);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (emit) {
|
|
84
|
-
await emit(createCompactionCompletedEvent({
|
|
85
|
-
lastCompactionIndex: 0,
|
|
86
|
-
modelId: formatModelId(compaction.model),
|
|
87
|
-
runId: "",
|
|
88
|
-
sequence: emissionState.sequence,
|
|
89
|
-
sessionId: "",
|
|
90
|
-
turnId: emissionState.turnId,
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
50
|
+
const marker = cachePath.kind === "anthropic-direct" ? getAnthropicCacheMarker() : undefined;
|
|
94
51
|
const tools = await buildToolSetWithProviderTools({
|
|
95
52
|
approvedTools: getApprovedTools(session),
|
|
96
|
-
definitions: session.agent.tools,
|
|
97
|
-
executors: config.toolExecutors,
|
|
98
53
|
isRoot: session.agent.isRoot,
|
|
99
54
|
modelReference: session.agent.modelReference,
|
|
100
|
-
|
|
55
|
+
tools: config.tools,
|
|
101
56
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
57
|
+
const effectiveTools = marker ? applyLastToolCacheBreakpoint(tools, marker) : tools;
|
|
58
|
+
// --- Build hooks --------------------------------------------------------
|
|
59
|
+
const hooks = buildStepHooks({
|
|
60
|
+
cachePath,
|
|
61
|
+
emit,
|
|
62
|
+
emissionState,
|
|
63
|
+
marker,
|
|
64
|
+
model,
|
|
65
|
+
onCompaction: config.onCompaction,
|
|
66
|
+
resolveModel: config.resolveModel,
|
|
67
|
+
session,
|
|
68
|
+
});
|
|
69
|
+
// --- Execute via ToolLoopAgent ------------------------------------------
|
|
109
70
|
const agent = new ToolLoopAgent({
|
|
110
71
|
instructions: session.agent.system || undefined,
|
|
111
72
|
model,
|
|
112
|
-
|
|
113
|
-
|
|
73
|
+
onStepFinish: hooks.onStepFinish,
|
|
74
|
+
prepareStep: hooks.prepareStep,
|
|
114
75
|
stopWhen: stepCountIs(1),
|
|
115
76
|
tools: effectiveTools,
|
|
116
77
|
});
|
|
117
78
|
let result;
|
|
118
79
|
try {
|
|
119
|
-
|
|
80
|
+
if (emit) {
|
|
81
|
+
const streamResult = await agent.stream({ messages });
|
|
82
|
+
await emitStreamContent(emit, emissionState, streamResult.fullStream);
|
|
83
|
+
result = await hooks.stepResult;
|
|
84
|
+
await emitStepActions(emit, emissionState, result, {
|
|
85
|
+
excludedActionToolNames: new Set([ASK_QUESTION_TOOL_NAME]),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
await agent.generate({ messages });
|
|
90
|
+
result = await hooks.stepResult;
|
|
91
|
+
}
|
|
120
92
|
}
|
|
121
93
|
catch (error) {
|
|
122
94
|
if (emit) {
|
|
123
|
-
await emit
|
|
95
|
+
await emitFailedStep(emit, emissionState, {
|
|
124
96
|
code: "MODEL_CALL_FAILED",
|
|
125
97
|
message: error instanceof Error ? error.message : String(error),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}));
|
|
98
|
+
sessionId: session.sessionId,
|
|
99
|
+
});
|
|
129
100
|
}
|
|
130
101
|
throw error;
|
|
131
102
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
103
|
+
session = hooks.getSession();
|
|
104
|
+
// --- Handle result ------------------------------------------------------
|
|
105
|
+
return handleStepResult({
|
|
106
|
+
config,
|
|
107
|
+
emit,
|
|
108
|
+
emissionState,
|
|
109
|
+
messages,
|
|
110
|
+
result,
|
|
111
|
+
runStep,
|
|
112
|
+
session,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return runStep;
|
|
116
|
+
}
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
// Post-step result handling
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
/**
|
|
121
|
+
* Processes the step result: extracts input requests, decides whether to
|
|
122
|
+
* park, continue the tool loop, or terminate.
|
|
123
|
+
*/
|
|
124
|
+
async function handleStepResult(input) {
|
|
125
|
+
const { config, emit, messages, result, runStep } = input;
|
|
126
|
+
let { emissionState, session } = input;
|
|
127
|
+
const responseMessages = result.response.messages;
|
|
128
|
+
const stepOutput = resolveAssistantStepText(responseMessages, result.text);
|
|
129
|
+
const approvalRequests = extractToolApprovalInputRequests({ content: result.content ?? [] });
|
|
130
|
+
const approvalRequestCallIds = new Set(approvalRequests.map((request) => request.action.callId));
|
|
131
|
+
const questionRequests = extractQuestionInputRequests({
|
|
132
|
+
toolCalls: result.toolCalls,
|
|
133
|
+
excludedCallIds: approvalRequestCallIds,
|
|
134
|
+
});
|
|
135
|
+
const inputRequests = [...approvalRequests, ...questionRequests];
|
|
136
|
+
const baseSession = {
|
|
137
|
+
...session,
|
|
138
|
+
compaction: {
|
|
139
|
+
...session.compaction,
|
|
140
|
+
lastKnownInputTokens: result.usage?.inputTokens,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
// --- Park on input requests -----------------------------------------------
|
|
144
|
+
if (inputRequests.length > 0) {
|
|
145
|
+
let parkedSession = setPendingInputBatch({
|
|
146
|
+
requests: inputRequests,
|
|
147
|
+
responseMessages,
|
|
148
|
+
session: { ...baseSession, history: messages },
|
|
139
149
|
});
|
|
140
|
-
const runtimeInputRequests = [...approvalRequests, ...questionRequests];
|
|
141
|
-
const runtimeActionToolCalls = result.toolCalls.filter((call) => call.toolName !== ASK_QUESTION_TOOL_NAME && !approvalRequestCallIds.has(call.toolCallId));
|
|
142
|
-
const baseSession = {
|
|
143
|
-
...session,
|
|
144
|
-
compaction: {
|
|
145
|
-
...session.compaction,
|
|
146
|
-
lastKnownInputTokens: result.usage?.inputTokens,
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
const completedStepOutput = {
|
|
150
|
-
finishReason: normalizeAssistantStepFinishReason(result.finishReason),
|
|
151
|
-
message: stepOutput,
|
|
152
|
-
reasoning: result.reasoningText,
|
|
153
|
-
};
|
|
154
|
-
if (runtimeInputRequests.length > 0) {
|
|
155
|
-
let parkedSession = setPendingRuntimeInputBatch({
|
|
156
|
-
requests: runtimeInputRequests,
|
|
157
|
-
responseMessages,
|
|
158
|
-
session: {
|
|
159
|
-
...baseSession,
|
|
160
|
-
history: messages,
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
if (emit) {
|
|
164
|
-
await emitCompletedStepOutput(emit, emissionState, completedStepOutput);
|
|
165
|
-
if (runtimeActionToolCalls.length > 0) {
|
|
166
|
-
await emitToolCallActionsAndResults(emit, emissionState, {
|
|
167
|
-
toolCalls: runtimeActionToolCalls,
|
|
168
|
-
toolResults: result.toolResults,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
await emit(createInputRequestedEvent({
|
|
172
|
-
requests: runtimeInputRequests,
|
|
173
|
-
sequence: emissionState.sequence,
|
|
174
|
-
turnId: emissionState.turnId,
|
|
175
|
-
}));
|
|
176
|
-
if (config.mode === "conversation") {
|
|
177
|
-
emissionState = await emitTurnEpilogue(emit, emissionState, config.mode, result.usage);
|
|
178
|
-
parkedSession = setHarnessEmissionState(parkedSession, emissionState);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
next: null,
|
|
183
|
-
session: parkedSession,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
const updatedHistory = [...messages, ...responseMessages];
|
|
187
|
-
let nextSession = {
|
|
188
|
-
...baseSession,
|
|
189
|
-
history: updatedHistory,
|
|
190
|
-
};
|
|
191
|
-
const continueLoop = runtimeActionToolCalls.length > 0 || hasDeferredStepInput(nextSession);
|
|
192
150
|
if (emit) {
|
|
193
|
-
await
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
151
|
+
await emit(createInputRequestedEvent({
|
|
152
|
+
requests: inputRequests,
|
|
153
|
+
sequence: emissionState.sequence,
|
|
154
|
+
stepIndex: emissionState.stepIndex,
|
|
155
|
+
turnId: emissionState.turnId,
|
|
156
|
+
}));
|
|
157
|
+
if (config.mode === "conversation") {
|
|
158
|
+
emissionState = await emitTurnEpilogue(emit, emissionState, config.mode);
|
|
159
|
+
parkedSession = setHarnessEmissionState(parkedSession, emissionState);
|
|
199
160
|
}
|
|
200
|
-
if (!continueLoop) {
|
|
201
|
-
emissionState = await emitTurnEpilogue(emit, emissionState, config.mode, result.usage);
|
|
202
|
-
}
|
|
203
|
-
nextSession = setHarnessEmissionState(nextSession, emissionState);
|
|
204
|
-
}
|
|
205
|
-
if (continueLoop) {
|
|
206
|
-
return { next: runStep, session: nextSession };
|
|
207
161
|
}
|
|
208
|
-
return {
|
|
209
|
-
next: config.mode === "task" ? { done: true, output: stepOutput ?? "" } : null,
|
|
210
|
-
session: nextSession,
|
|
211
|
-
};
|
|
162
|
+
return { next: null, session: parkedSession };
|
|
212
163
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
164
|
+
// --- Continue or terminate ------------------------------------------------
|
|
165
|
+
const updatedHistory = [...messages, ...responseMessages];
|
|
166
|
+
let nextSession = { ...baseSession, history: updatedHistory };
|
|
167
|
+
const continueLoop = responseMessages.at(-1)?.role === "tool" || hasDeferredStepInput(nextSession);
|
|
168
|
+
if (emit) {
|
|
169
|
+
if (!continueLoop) {
|
|
170
|
+
emissionState = await emitTurnEpilogue(emit, emissionState, config.mode);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
emissionState = advanceStep(emissionState);
|
|
174
|
+
}
|
|
175
|
+
nextSession = setHarnessEmissionState(nextSession, emissionState);
|
|
218
176
|
}
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
function toToolLoopProviderOptions(value) {
|
|
222
|
-
return value;
|
|
223
|
-
}
|
|
224
|
-
function normalizeAssistantStepFinishReason(value) {
|
|
225
|
-
switch (value) {
|
|
226
|
-
case "content-filter":
|
|
227
|
-
case "error":
|
|
228
|
-
case "length":
|
|
229
|
-
case "stop":
|
|
230
|
-
case "tool-calls":
|
|
231
|
-
return value;
|
|
232
|
-
default:
|
|
233
|
-
return "other";
|
|
177
|
+
if (continueLoop) {
|
|
178
|
+
return { next: runStep, session: nextSession };
|
|
234
179
|
}
|
|
180
|
+
return {
|
|
181
|
+
next: config.mode === "task" ? { done: true, output: stepOutput ?? "" } : null,
|
|
182
|
+
session: nextSession,
|
|
183
|
+
};
|
|
235
184
|
}
|
|
236
185
|
//# sourceMappingURL=tool-loop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-loop.js","sourceRoot":"","sources":["../../../src/harness/tool-loop.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"tool-loop.js","sourceRoot":"","sources":["../../../src/harness/tool-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,WAAW,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAEnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF,OAAO,EACL,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,eAAe,EAA0B,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAS3D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA6B;IACjE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAEzB,KAAK,UAAU,OAAO,CACpB,cAA+C,EAC/C,KAAiB;QAEjB,IAAI,OAAO,GAAG,cAAc,CAAC;QAC7B,IAAI,aAAa,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAErD,2EAA2E;QAE3E,MAAM,SAAS,GAAG,wBAAwB,CAAC,EAAE,KAAK,EAA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AAE,aAAa,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IAChD,CAAC;IAED,6EAA6E;IAE7E,MAAM,cAAc,GAAmB,CAAC,GAAG,QAAQ,EAAE,GAAG,gBAAgB,CAAC,CAAC;IAC1E,IAAI,WAAW,GAAmB,EAAE,GAAG,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IAE9E,MAAM,YAAY,GAChB,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM,IAAI,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAEhF,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,aAAa,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3E,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;QAC7C,CAAC;QACD,WAAW,GAAG,uBAAuB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IACjD,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;QAC9E,OAAO,EAAE,WAAW;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { type ToolSet } from "ai";
|
|
2
|
-
import type { NeedsApprovalContext } from "../public/definitions/tool.js";
|
|
3
2
|
import type { RuntimeModelReference } from "../runtime/agent/bootstrap.js";
|
|
4
|
-
import type {
|
|
3
|
+
import type { HarnessToolMap } from "./types.js";
|
|
5
4
|
/**
|
|
6
|
-
* Builds an AI SDK `ToolSet` from
|
|
7
|
-
*
|
|
5
|
+
* Builds an AI SDK `ToolSet` from unified harness tool definitions.
|
|
6
|
+
*
|
|
7
|
+
* Each tool's schema, execute function, and approval gate are read from
|
|
8
|
+
* the same {@link HarnessToolDefinition}. Tools without `execute` are
|
|
9
|
+
* surfaced to the model as client-side tools (no server execution).
|
|
8
10
|
*/
|
|
9
11
|
export declare function buildToolSet(input: {
|
|
10
12
|
readonly approvedTools?: ReadonlySet<string>;
|
|
11
|
-
readonly definitions: readonly SessionToolDefinition[];
|
|
12
|
-
readonly executors: ToolExecutorMap;
|
|
13
13
|
readonly isRoot?: boolean;
|
|
14
|
-
readonly
|
|
14
|
+
readonly tools: HarnessToolMap;
|
|
15
15
|
}): ToolSet;
|
|
16
16
|
/**
|
|
17
17
|
* Builds the AI SDK ToolSet for one harness step.
|
|
18
18
|
*
|
|
19
|
-
* Most tools have local executors
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* detects the gap in the executor map and injects the real AI SDK provider
|
|
24
|
-
* tool in their place.
|
|
19
|
+
* Most tools have local executors and are assembled by {@link buildToolSet}.
|
|
20
|
+
* Provider-managed tools (e.g. web_search) have no local `execute` — the
|
|
21
|
+
* execution layer intentionally omits it. This function detects the gap and
|
|
22
|
+
* injects the real AI SDK provider tool in their place.
|
|
25
23
|
*
|
|
26
24
|
* When a user overrides a provider-managed tool via `defineTool()`, their
|
|
27
25
|
* tool has a real executor and flows through the normal path — no
|
|
@@ -29,10 +27,8 @@ export declare function buildToolSet(input: {
|
|
|
29
27
|
*/
|
|
30
28
|
export declare function buildToolSetWithProviderTools(input: {
|
|
31
29
|
readonly approvedTools?: ReadonlySet<string>;
|
|
32
|
-
readonly definitions: readonly SessionToolDefinition[];
|
|
33
|
-
readonly executors: ToolExecutorMap;
|
|
34
30
|
readonly isRoot?: boolean;
|
|
35
31
|
readonly modelReference: RuntimeModelReference;
|
|
36
|
-
readonly
|
|
32
|
+
readonly tools: HarnessToolMap;
|
|
37
33
|
}): Promise<ToolSet>;
|
|
38
34
|
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/harness/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,OAAO,EAAQ,MAAM,IAAI,CAAC;AACpD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/harness/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,OAAO,EAAQ,MAAM,IAAI,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAK3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAmCV;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,6BAA6B,CAAC,KAAK,EAAE;IACzD,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBnB"}
|
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
import { jsonSchema, tool } from "ai";
|
|
2
2
|
import { WEB_SEARCH_TOOL_DEFINITION } from "../runtime/framework-tools/web-search.js";
|
|
3
|
+
import { executeAuthoredTool } from "./execute-tool.js";
|
|
3
4
|
import { resolveWebSearchBackend, resolveWebSearchProviderTool } from "./provider-tools.js";
|
|
4
5
|
import { normalizeToolInputSchema } from "./tool-schema.js";
|
|
5
6
|
/**
|
|
6
|
-
* Builds an AI SDK `ToolSet` from
|
|
7
|
-
*
|
|
7
|
+
* Builds an AI SDK `ToolSet` from unified harness tool definitions.
|
|
8
|
+
*
|
|
9
|
+
* Each tool's schema, execute function, and approval gate are read from
|
|
10
|
+
* the same {@link HarnessToolDefinition}. Tools without `execute` are
|
|
11
|
+
* surfaced to the model as client-side tools (no server execution).
|
|
8
12
|
*/
|
|
9
13
|
export function buildToolSet(input) {
|
|
10
14
|
const tools = {};
|
|
11
|
-
for (const definition of input.
|
|
15
|
+
for (const definition of input.tools.values()) {
|
|
12
16
|
const baseToolDefinition = {
|
|
13
17
|
description: definition.description,
|
|
14
|
-
inputSchema: jsonSchema(normalizeToolInputSchema(definition.
|
|
15
|
-
needsApproval:
|
|
16
|
-
const toolFn = input.needsApprovalFns?.get(definition.name);
|
|
17
|
-
const required = toolFn !== undefined
|
|
18
|
-
? toolFn({
|
|
19
|
-
approvedTools: input.approvedTools ?? new Set(),
|
|
20
|
-
toolName: definition.name,
|
|
21
|
-
})
|
|
22
|
-
: false;
|
|
23
|
-
if (required && input.isRoot === false) {
|
|
24
|
-
throw new Error(`Tool approval is currently not supported for subagent runs. Remove the needsApproval override on "${definition.name}" for the subagent or use never().`);
|
|
25
|
-
}
|
|
26
|
-
return required;
|
|
27
|
-
},
|
|
18
|
+
inputSchema: jsonSchema(normalizeToolInputSchema(definition.inputSchema)),
|
|
19
|
+
needsApproval: buildNeedsApprovalFn(definition, input),
|
|
28
20
|
};
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
if (definition.execute !== undefined) {
|
|
22
|
+
const executableDefinition = definition;
|
|
31
23
|
tools[definition.name] = tool({
|
|
32
24
|
...baseToolDefinition,
|
|
33
25
|
execute: async (rawInput) => {
|
|
34
|
-
|
|
26
|
+
const result = await executeAuthoredTool(executableDefinition, rawInput);
|
|
27
|
+
if (!result.ok) {
|
|
28
|
+
return { code: result.code, message: result.message };
|
|
29
|
+
}
|
|
30
|
+
return result.output;
|
|
35
31
|
},
|
|
36
32
|
});
|
|
37
33
|
continue;
|
|
@@ -43,12 +39,10 @@ export function buildToolSet(input) {
|
|
|
43
39
|
/**
|
|
44
40
|
* Builds the AI SDK ToolSet for one harness step.
|
|
45
41
|
*
|
|
46
|
-
* Most tools have local executors
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* detects the gap in the executor map and injects the real AI SDK provider
|
|
51
|
-
* tool in their place.
|
|
42
|
+
* Most tools have local executors and are assembled by {@link buildToolSet}.
|
|
43
|
+
* Provider-managed tools (e.g. web_search) have no local `execute` — the
|
|
44
|
+
* execution layer intentionally omits it. This function detects the gap and
|
|
45
|
+
* injects the real AI SDK provider tool in their place.
|
|
52
46
|
*
|
|
53
47
|
* When a user overrides a provider-managed tool via `defineTool()`, their
|
|
54
48
|
* tool has a real executor and flows through the normal path — no
|
|
@@ -58,16 +52,14 @@ export async function buildToolSetWithProviderTools(input) {
|
|
|
58
52
|
const tools = {
|
|
59
53
|
...buildToolSet({
|
|
60
54
|
approvedTools: input.approvedTools,
|
|
61
|
-
definitions: input.definitions,
|
|
62
|
-
executors: input.executors,
|
|
63
55
|
isRoot: input.isRoot,
|
|
64
|
-
|
|
56
|
+
tools: input.tools,
|
|
65
57
|
}),
|
|
66
58
|
};
|
|
67
|
-
// Inject the real provider tool for web_search when the
|
|
68
|
-
//
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
59
|
+
// Inject the real provider tool for web_search when the definition has
|
|
60
|
+
// no local execute (i.e. the framework definition uses the provider sentinel).
|
|
61
|
+
const webSearchTool = input.tools.get(WEB_SEARCH_TOOL_DEFINITION.name);
|
|
62
|
+
if (webSearchTool !== undefined && webSearchTool.execute === undefined) {
|
|
71
63
|
const backend = resolveWebSearchBackend(input.modelReference);
|
|
72
64
|
if (backend !== null) {
|
|
73
65
|
tools[WEB_SEARCH_TOOL_DEFINITION.name] = await resolveWebSearchProviderTool(backend);
|
|
@@ -75,4 +67,18 @@ export async function buildToolSetWithProviderTools(input) {
|
|
|
75
67
|
}
|
|
76
68
|
return tools;
|
|
77
69
|
}
|
|
70
|
+
function buildNeedsApprovalFn(definition, input) {
|
|
71
|
+
return async () => {
|
|
72
|
+
if (definition.needsApproval === undefined)
|
|
73
|
+
return false;
|
|
74
|
+
const required = definition.needsApproval({
|
|
75
|
+
approvedTools: input.approvedTools ?? new Set(),
|
|
76
|
+
toolName: definition.name,
|
|
77
|
+
});
|
|
78
|
+
if (required && input.isRoot === false) {
|
|
79
|
+
throw new Error(`Tool approval is currently not supported for subagent runs. Remove the needsApproval override on "${definition.name}" for the subagent or use never().`);
|
|
80
|
+
}
|
|
81
|
+
return required;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
78
84
|
//# sourceMappingURL=tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/harness/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,IAAI,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/harness/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,IAAI,EAAE,MAAM,IAAI,CAAC;AAEpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAA8B,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAG5D;;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