stitchkit 0.133.1 → 0.134.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 +121 -0
- package/README.md +14 -11
- package/dist/agent-executor/acp/v1-connect.d.ts +5 -0
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-map.d.ts +13 -3
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-probe.d.ts +3 -0
- package/dist/agent-executor/acp/v1-probe.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-protocol.d.ts +61 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts +3 -0
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/codex/connect.d.ts +2 -0
- package/dist/agent-executor/codex/connect.d.ts.map +1 -1
- package/dist/agent-executor/codex/driver.d.ts +3 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/contract.d.ts +42 -0
- package/dist/agent-executor/contract.d.ts.map +1 -1
- package/dist/agent-executor/engine-process.d.ts +20 -0
- package/dist/agent-executor/engine-process.d.ts.map +1 -1
- package/dist/agent-executor/executor-contract.d.ts +42 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -1
- package/dist/agent-executor/handoff-schemas.d.ts +30 -0
- package/dist/agent-executor/handoff-schemas.d.ts.map +1 -1
- package/dist/agent-executor/projection.d.ts.map +1 -1
- package/dist/agent-executor/session-primitives.d.ts +4 -1
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-executor/testing/consumer-stubs.d.ts.map +1 -1
- package/dist/agent-executor/vocabulary.d.ts +100 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -1
- package/dist/agent-parts/model.d.ts +1559 -0
- package/dist/agent-parts/model.d.ts.map +1 -0
- package/dist/agent-parts/parts.d.ts +21 -0
- package/dist/agent-parts/parts.d.ts.map +1 -1
- package/dist/agent-runtime/ai-sdk-convert.d.ts +15 -0
- package/dist/agent-runtime/ai-sdk-convert.d.ts.map +1 -0
- package/dist/agent-runtime/ai-sdk.d.ts +31 -0
- package/dist/agent-runtime/ai-sdk.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-media.d.ts +11 -0
- package/dist/agent-runtime/anthropic-media.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-messages.d.ts +24 -0
- package/dist/agent-runtime/anthropic-messages.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-options.d.ts +79 -0
- package/dist/agent-runtime/anthropic-options.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-response.d.ts +19 -0
- package/dist/agent-runtime/anthropic-response.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-sse.d.ts +4 -0
- package/dist/agent-runtime/anthropic-sse.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic.d.ts +27 -0
- package/dist/agent-runtime/anthropic.d.ts.map +1 -0
- package/dist/agent-runtime/branch-observations.d.ts +25 -25
- package/dist/agent-runtime/branch-provider.d.ts +86 -0
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-replay.d.ts +30 -0
- package/dist/agent-runtime/branch-replay.d.ts.map +1 -1
- package/dist/agent-runtime/browser-control-contract.d.ts +204 -0
- package/dist/agent-runtime/browser-control-contract.d.ts.map +1 -1
- package/dist/agent-runtime/browser-controller-view.d.ts +44 -0
- package/dist/agent-runtime/browser-controller-view.d.ts.map +1 -0
- package/dist/agent-runtime/browser-controller.d.ts +12 -8
- package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
- package/dist/agent-runtime/child-budget-policy.d.ts +2 -3
- package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts +27 -10
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/control-interaction-schema.d.ts +157 -0
- package/dist/agent-runtime/control-interaction-schema.d.ts.map +1 -0
- package/dist/agent-runtime/control-schema.d.ts +183 -27
- package/dist/agent-runtime/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/control-view.d.ts +64 -0
- package/dist/agent-runtime/control-view.d.ts.map +1 -0
- package/dist/agent-runtime/conversations.d.ts +10 -0
- package/dist/agent-runtime/conversations.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-selection.d.ts +2 -2
- package/dist/agent-runtime/deferred-tool-selection.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +2 -2
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools-internal.d.ts +8 -11
- package/dist/agent-runtime/deferred-tools-internal.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-schema.d.ts +80 -0
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/harness-contract.d.ts +2 -2
- package/dist/agent-runtime/harness-contract.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +2 -2
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/history.d.ts +25 -16
- package/dist/agent-runtime/history.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts +7 -3
- package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-payload.d.ts +13 -7
- package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-stream.d.ts +20 -0
- package/dist/agent-runtime/invocation-stream.d.ts.map +1 -0
- package/dist/agent-runtime/invocations.d.ts +2 -2
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/models-driver-step.d.ts +212 -0
- package/dist/agent-runtime/models-driver-step.d.ts.map +1 -0
- package/dist/agent-runtime/models-driver-telemetry.d.ts +42 -0
- package/dist/agent-runtime/models-driver-telemetry.d.ts.map +1 -0
- package/dist/agent-runtime/models-driver.d.ts +235 -0
- package/dist/agent-runtime/models-driver.d.ts.map +1 -0
- package/dist/agent-runtime/models.d.ts +3 -26
- package/dist/agent-runtime/models.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +64 -0
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openai-messages.d.ts +11 -0
- package/dist/agent-runtime/openai-messages.d.ts.map +1 -0
- package/dist/agent-runtime/openai-options.d.ts +91 -0
- package/dist/agent-runtime/openai-options.d.ts.map +1 -0
- package/dist/agent-runtime/openai-response.d.ts +77 -0
- package/dist/agent-runtime/openai-response.d.ts.map +1 -0
- package/dist/agent-runtime/openai-sse-state.d.ts +54 -0
- package/dist/agent-runtime/openai-sse-state.d.ts.map +1 -0
- package/dist/agent-runtime/openai-sse.d.ts +4 -0
- package/dist/agent-runtime/openai-sse.d.ts.map +1 -0
- package/dist/agent-runtime/openai.d.ts +31 -0
- package/dist/agent-runtime/openai.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-admission.d.ts +3 -0
- package/dist/agent-runtime/openrouter-admission.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-benchmarks.d.ts +17 -0
- package/dist/agent-runtime/openrouter-benchmarks.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog-cache.d.ts +70 -0
- package/dist/agent-runtime/openrouter-catalog-cache.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog-query.d.ts +57 -0
- package/dist/agent-runtime/openrouter-catalog-query.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts +189 -14
- package/dist/agent-runtime/openrouter-catalog.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-models.d.ts +168 -31
- package/dist/agent-runtime/openrouter-models.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-options.d.ts +45 -15
- package/dist/agent-runtime/openrouter-options.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-response.d.ts +22 -0
- package/dist/agent-runtime/openrouter-response.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter.d.ts +21 -24
- package/dist/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts +4 -4
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -1
- package/dist/agent-runtime/prompt.d.ts +3 -3
- package/dist/agent-runtime/prompt.d.ts.map +1 -1
- package/dist/agent-runtime/protocol.d.ts +28 -3
- package/dist/agent-runtime/protocol.d.ts.map +1 -1
- package/dist/agent-runtime/provider-cache.d.ts +30 -0
- package/dist/agent-runtime/provider-cache.d.ts.map +1 -0
- package/dist/agent-runtime/provider-content.d.ts +147 -0
- package/dist/agent-runtime/provider-content.d.ts.map +1 -1
- package/dist/agent-runtime/provider-failure.d.ts +51 -26
- package/dist/agent-runtime/provider-failure.d.ts.map +1 -1
- package/dist/agent-runtime/provider-history.d.ts +13 -0
- package/dist/agent-runtime/provider-history.d.ts.map +1 -0
- package/dist/agent-runtime/provider-http.d.ts +68 -0
- package/dist/agent-runtime/provider-http.d.ts.map +1 -0
- package/dist/agent-runtime/provider-journal.d.ts +149 -0
- package/dist/agent-runtime/provider-journal.d.ts.map +1 -1
- package/dist/agent-runtime/provider-json-schema-strip.d.ts +8 -0
- package/dist/agent-runtime/provider-json-schema-strip.d.ts.map +1 -0
- package/dist/agent-runtime/provider-json-schema.d.ts +28 -0
- package/dist/agent-runtime/provider-json-schema.d.ts.map +1 -0
- package/dist/agent-runtime/provider-media.d.ts +49 -0
- package/dist/agent-runtime/provider-media.d.ts.map +1 -0
- package/dist/agent-runtime/provider-openai-chat-helpers.d.ts +27 -0
- package/dist/agent-runtime/provider-openai-chat-helpers.d.ts.map +1 -0
- package/dist/agent-runtime/provider-openai-chat-sse.d.ts +25 -0
- package/dist/agent-runtime/provider-openai-chat-sse.d.ts.map +1 -0
- package/dist/agent-runtime/provider-openai-chat.d.ts +27 -0
- package/dist/agent-runtime/provider-openai-chat.d.ts.map +1 -0
- package/dist/agent-runtime/provider-origin.d.ts +3 -12
- package/dist/agent-runtime/provider-origin.d.ts.map +1 -1
- package/dist/agent-runtime/provider-sse.d.ts +30 -0
- package/dist/agent-runtime/provider-sse.d.ts.map +1 -0
- package/dist/agent-runtime/provider-stream-parts.d.ts +5 -0
- package/dist/agent-runtime/provider-stream-parts.d.ts.map +1 -0
- package/dist/agent-runtime/provider-stream-segments.d.ts +63 -0
- package/dist/agent-runtime/provider-stream-segments.d.ts.map +1 -0
- package/dist/agent-runtime/provider-usage.d.ts +24 -0
- package/dist/agent-runtime/provider-usage.d.ts.map +1 -0
- package/dist/agent-runtime/retry-policy.d.ts +19 -3
- package/dist/agent-runtime/retry-policy.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts +4 -4
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-approval.d.ts +82 -0
- package/dist/agent-runtime/run-approval.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-retry.d.ts +24 -0
- package/dist/agent-runtime/run-complete-retry.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-stream.d.ts +9 -0
- package/dist/agent-runtime/run-complete-stream.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-tools.d.ts +21 -0
- package/dist/agent-runtime/run-complete-tools.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-types.d.ts +168 -0
- package/dist/agent-runtime/run-complete-types.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete.d.ts +25 -0
- package/dist/agent-runtime/run-complete.d.ts.map +1 -0
- package/dist/agent-runtime/run-driver-compose.d.ts +21 -0
- package/dist/agent-runtime/run-driver-compose.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution-state.d.ts +23 -10
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts +2 -2
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts +2 -2
- package/dist/agent-runtime/run-failure.d.ts.map +1 -1
- package/dist/agent-runtime/run-history-parts.d.ts +14 -0
- package/dist/agent-runtime/run-history-parts.d.ts.map +1 -0
- package/dist/agent-runtime/run-loop-events.d.ts +126 -0
- package/dist/agent-runtime/run-loop-events.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-attempts.d.ts +2 -2
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
- package/dist/agent-runtime/run-model-messages.d.ts +9 -0
- package/dist/agent-runtime/run-model-messages.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-step.d.ts +43 -0
- package/dist/agent-runtime/run-model-step.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-stream.d.ts +27 -0
- package/dist/agent-runtime/run-model-stream.d.ts.map +1 -0
- package/dist/agent-runtime/run-operation-lifecycle.d.ts +8 -4
- package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/run-prompt-history.d.ts +8 -13
- package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -1
- package/dist/agent-runtime/run-provider-ledger.d.ts +7 -4
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-barriers.d.ts +58 -16
- package/dist/agent-runtime/run-step-barriers.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-helpers.d.ts +49 -0
- package/dist/agent-runtime/run-step-helpers.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-prepare.d.ts +34 -0
- package/dist/agent-runtime/run-step-prepare.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-spend.d.ts +85 -10
- package/dist/agent-runtime/run-step-spend.d.ts.map +1 -1
- package/dist/agent-runtime/run-stream-parts.d.ts +13 -9
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/run-stream-recorded.d.ts +8 -0
- package/dist/agent-runtime/run-stream-recorded.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-step-text.d.ts +29 -0
- package/dist/agent-runtime/run-stream-step-text.d.ts.map +1 -0
- package/dist/agent-runtime/run-terminal.d.ts +3 -3
- package/dist/agent-runtime/run-terminal.d.ts.map +1 -1
- package/dist/agent-runtime/run-tool-approval-flow.d.ts +36 -0
- package/dist/agent-runtime/run-tool-approval-flow.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-approval-records.d.ts +24 -0
- package/dist/agent-runtime/run-tool-approval-records.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-call.d.ts +73 -0
- package/dist/agent-runtime/run-tool-call.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-errors.d.ts +29 -0
- package/dist/agent-runtime/run-tool-errors.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-executor.d.ts +34 -0
- package/dist/agent-runtime/run-tool-executor.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-progress.d.ts +2 -2
- package/dist/agent-runtime/run-tool-progress.d.ts.map +1 -1
- package/dist/agent-runtime/run-turn-preparation.d.ts +7 -6
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -1
- package/dist/agent-runtime/run-unacquired.d.ts +2 -2
- package/dist/agent-runtime/run-unacquired.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-control.d.ts +4 -4
- package/dist/agent-runtime/runtime-control.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +35 -44
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-recovery.d.ts +3 -3
- package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-state.d.ts +3 -3
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-submit.d.ts +2 -2
- package/dist/agent-runtime/runtime-submit.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +51 -16
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-process-linux.d.ts +8 -0
- package/dist/agent-runtime/sandbox-process-linux.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-macos.d.ts +21 -0
- package/dist/agent-runtime/sandbox-process-macos.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-spec.d.ts +114 -0
- package/dist/agent-runtime/sandbox-process-spec.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-wrapper.d.ts +19 -0
- package/dist/agent-runtime/sandbox-process-wrapper.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-message.d.ts +10 -0
- package/dist/agent-runtime/schemas-message.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-provider.d.ts +2 -0
- package/dist/agent-runtime/schemas-provider.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-run.d.ts +10 -0
- package/dist/agent-runtime/schemas-run.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-usage-state.d.ts +6 -0
- package/dist/agent-runtime/schemas-usage-state.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-usage.d.ts +8 -0
- package/dist/agent-runtime/schemas-usage.d.ts.map +1 -1
- package/dist/agent-runtime/sql-rows.d.ts +20 -10
- package/dist/agent-runtime/sql-rows.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +40 -20
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-support.d.ts +20 -10
- package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +70 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +120 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +140 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +10 -0
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
- package/dist/agent-runtime/testing.d.ts +20 -0
- package/dist/agent-runtime/testing.d.ts.map +1 -1
- package/dist/browser/client-call-arguments.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client-url.d.ts.map +1 -1
- package/dist/browser/client.d.ts +6 -0
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/device-presence-client.d.ts +42 -0
- package/dist/browser/device-presence-client.d.ts.map +1 -0
- package/dist/browser/device-presence-ops.d.ts +47 -0
- package/dist/browser/device-presence-ops.d.ts.map +1 -0
- package/dist/browser/device-presence-relay-adapter.d.ts +37 -0
- package/dist/browser/device-presence-relay-adapter.d.ts.map +1 -0
- package/dist/browser/http-fetch.d.ts +7 -2
- package/dist/browser/http-fetch.d.ts.map +1 -1
- package/dist/browser/http-helpers.d.ts +15 -0
- package/dist/browser/http-helpers.d.ts.map +1 -0
- package/dist/browser/http.d.ts +8 -0
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +8 -0
- package/dist/contract/client-types.d.ts.map +1 -1
- package/dist/contract/runtime-context.d.ts +13 -1
- package/dist/contract/runtime-context.d.ts.map +1 -1
- package/dist/device-relay/agent-handlers.d.ts +45 -0
- package/dist/device-relay/agent-handlers.d.ts.map +1 -0
- package/dist/device-relay/agent.d.ts +80 -0
- package/dist/device-relay/agent.d.ts.map +1 -0
- package/dist/device-relay/broker.d.ts +49 -0
- package/dist/device-relay/broker.d.ts.map +1 -0
- package/dist/device-relay/contract.d.ts +614 -0
- package/dist/device-relay/contract.d.ts.map +1 -0
- package/dist/device-relay/encoding.d.ts +30 -0
- package/dist/device-relay/encoding.d.ts.map +1 -0
- package/dist/device-relay/hub-connection.d.ts +43 -0
- package/dist/device-relay/hub-connection.d.ts.map +1 -0
- package/dist/device-relay/hub-dispatch.d.ts +19 -0
- package/dist/device-relay/hub-dispatch.d.ts.map +1 -0
- package/dist/device-relay/hub-handshake.d.ts +20 -0
- package/dist/device-relay/hub-handshake.d.ts.map +1 -0
- package/dist/device-relay/hub-shared-streams.d.ts +24 -0
- package/dist/device-relay/hub-shared-streams.d.ts.map +1 -0
- package/dist/device-relay/hub-streams.d.ts +57 -0
- package/dist/device-relay/hub-streams.d.ts.map +1 -0
- package/dist/device-relay/hub.d.ts +117 -0
- package/dist/device-relay/hub.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +224 -47
- package/dist/entrypoints/agent-executor/claude-sdk.js +15 -15
- package/dist/entrypoints/agent-executor/claude.js +13 -15
- package/dist/entrypoints/agent-executor/codex.js +88 -48
- package/dist/entrypoints/agent-executor/testing/claude-sdk.js +5 -5
- package/dist/entrypoints/agent-executor/testing.js +31 -30
- package/dist/entrypoints/agent-executor.d.ts +2 -2
- package/dist/entrypoints/agent-executor.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor.js +23 -17
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts +9 -0
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/ai-sdk.js +821 -0
- package/dist/entrypoints/agent-runtime/anthropic.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/anthropic.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/anthropic.js +1260 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +4 -1
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +449 -50
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +24 -19
- package/dist/entrypoints/agent-runtime/openai.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/openai.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/openai.js +1246 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +5 -2
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +2355 -371
- package/dist/entrypoints/agent-runtime/postgres.js +12 -10
- package/dist/entrypoints/agent-runtime/realtime.js +11 -10
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +3 -0
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +530 -7
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +13 -11
- package/dist/entrypoints/agent-runtime/sqlite/node.js +13 -11
- package/dist/entrypoints/agent-runtime/testing.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/testing.js +56 -15
- package/dist/entrypoints/agent-runtime.d.ts +14 -6
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +1412 -115
- package/dist/entrypoints/application/diagnostic-journal.js +6 -6
- package/dist/entrypoints/application/directory-inbox.js +6 -6
- package/dist/entrypoints/application/opentelemetry.js +3 -3
- package/dist/entrypoints/application.js +17 -17
- package/dist/entrypoints/cli/publish.js +8 -8
- package/dist/entrypoints/cli.js +14 -15
- package/dist/entrypoints/contract.d.ts +1 -0
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +13 -9
- package/dist/entrypoints/device-relay.d.ts +10 -0
- package/dist/entrypoints/device-relay.d.ts.map +1 -0
- package/dist/entrypoints/device-relay.js +2517 -0
- package/dist/entrypoints/files/packaging.js +3 -3
- package/dist/entrypoints/files.js +11 -11
- package/dist/entrypoints/geo.js +5 -5
- package/dist/entrypoints/google.js +1 -1
- package/dist/entrypoints/handler.js +6 -6
- package/dist/entrypoints/http.js +9 -9
- package/dist/entrypoints/index.js +21 -17
- package/dist/entrypoints/live.js +4 -4
- package/dist/entrypoints/node.js +13 -13
- package/dist/entrypoints/observability.js +9 -9
- package/dist/entrypoints/process/bootstrap.js +1 -1
- package/dist/entrypoints/process.js +5 -5
- package/dist/entrypoints/react.js +4 -4
- package/dist/entrypoints/realtime.d.ts +3 -0
- package/dist/entrypoints/realtime.d.ts.map +1 -1
- package/dist/entrypoints/realtime.js +413 -4
- package/dist/entrypoints/release.js +1 -1
- package/dist/entrypoints/remote.js +10 -10
- package/dist/entrypoints/server.d.ts +1 -0
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +546 -40
- package/dist/entrypoints/service-host/macos.js +10 -10
- package/dist/entrypoints/service-host/work.js +7 -7
- package/dist/entrypoints/service-host.js +15 -15
- package/dist/entrypoints/spend.js +3 -3
- package/dist/entrypoints/sync.js +4 -4
- package/dist/entrypoints/telegram/screens.js +6 -6
- package/dist/entrypoints/telegram.js +20 -20
- package/dist/entrypoints/testing.js +14 -14
- package/dist/entrypoints/tools/agent.d.ts +2 -1
- package/dist/entrypoints/tools/agent.d.ts.map +1 -1
- package/dist/entrypoints/tools/agent.js +8 -7
- package/dist/entrypoints/tools/connections.js +5 -5
- package/dist/entrypoints/tools/invoker.js +3 -4
- package/dist/entrypoints/tools/mcp.js +8 -9
- package/dist/entrypoints/tools/toolkit.js +32 -13
- package/dist/entrypoints/tools.d.ts +3 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +37 -35
- package/dist/entrypoints/tracking/contract.js +1 -1
- package/dist/entrypoints/tracking/performance.js +4 -4
- package/dist/entrypoints/tracking.js +3 -3
- package/dist/{index-09f7w2qq.js → index-02kdtrcd.js} +1 -1
- package/dist/{index-y53cqwke.js → index-033tyx59.js} +1 -1
- package/dist/{index-9ft4n9j1.js → index-05b65gj4.js} +2 -2
- package/dist/{index-d04w81fz.js → index-0sxj3y45.js} +1 -1
- package/dist/{index-dm6nxkn1.js → index-18pf56dq.js} +4 -6
- package/dist/index-1gmgwfn3.js +439 -0
- package/dist/index-23wn8sgf.js +47 -0
- package/dist/{index-tqjamnax.js → index-27srek2g.js} +15 -13
- package/dist/{index-2nwvn7m2.js → index-29v1p1f4.js} +2 -2
- package/dist/index-36dmtzjr.js +194 -0
- package/dist/{index-ycr4pk0z.js → index-42n9jycn.js} +3 -3
- package/dist/{index-ke02kxsr.js → index-43k180c2.js} +1 -1
- package/dist/{index-pbekeqzm.js → index-5c4m8zdf.js} +2 -2
- package/dist/{index-qggqqja2.js → index-5dxgx3yj.js} +1 -1
- package/dist/{index-x5ayy5bn.js → index-5gdexvke.js} +3 -1
- package/dist/{index-t1a2jrg7.js → index-5xsxvk2x.js} +1 -1
- package/dist/{index-mbd92r1w.js → index-654rhe5d.js} +1 -1
- package/dist/{index-2dzc7mv9.js → index-67pnt4bh.js} +1 -1
- package/dist/index-6kpwkpgx.js +415 -0
- package/dist/{index-s43tr4my.js → index-6kwdfb9m.js} +18 -3
- package/dist/{index-1qwd54n3.js → index-6nzzj7qr.js} +1 -1
- package/dist/{index-rkjfzs0a.js → index-6p5pshcd.js} +2 -2
- package/dist/{index-118aebbg.js → index-6t4c98gr.js} +1 -1
- package/dist/{index-pws5c3x6.js → index-6xw1wf4m.js} +51 -32
- package/dist/{index-kwsr7j5k.js → index-6yb4stq3.js} +1 -1
- package/dist/{index-8jf4bt7v.js → index-76yhxa41.js} +8 -8
- package/dist/{index-7416mhyh.js → index-79vqbjcz.js} +1 -1
- package/dist/{index-13wmzpa6.js → index-7an2fs5h.js} +1 -1
- package/dist/index-7qza24g1.js +14 -0
- package/dist/{index-gtaaxe9d.js → index-8cek82ar.js} +1 -1
- package/dist/index-9f60gnfn.js +393 -0
- package/dist/{index-stpy56r3.js → index-aacwkve4.js} +209 -10
- package/dist/{index-rpyn7geq.js → index-ac3rfec5.js} +2 -2
- package/dist/{index-d2drhb9c.js → index-b0mh2t9x.js} +2 -2
- package/dist/index-b23s6e2c.js +158 -0
- package/dist/{index-an7vcmwf.js → index-bvpevwt6.js} +5 -5
- package/dist/{index-msxf2r8x.js → index-by8w2461.js} +1 -1
- package/dist/{index-8t9dr41h.js → index-c0yym4a0.js} +4 -4
- package/dist/{index-wddcfbng.js → index-c7fj4yw9.js} +1 -1
- package/dist/{index-tf70nm22.js → index-cb4nnvfr.js} +8 -6
- package/dist/{index-205456mf.js → index-d3s070eh.js} +2 -2
- package/dist/{index-apf5g7y9.js → index-dz6tstcp.js} +2 -2
- package/dist/{index-agy5fqgf.js → index-e1y74yra.js} +15 -8
- package/dist/index-edtg4tak.js +55 -0
- package/dist/{index-pq6g1k9t.js → index-ek9w11r0.js} +2 -2
- package/dist/{index-x46y9z26.js → index-epyj7ptp.js} +7 -5
- package/dist/{index-6kmjcm81.js → index-er483f3w.js} +93 -4
- package/dist/{index-827bgv33.js → index-f16b7rze.js} +1 -1
- package/dist/{index-gbhj370g.js → index-fec05c9k.js} +21 -21
- package/dist/{index-9wdrwx3b.js → index-fjac2w5e.js} +20 -22
- package/dist/{index-6918kxbf.js → index-fthw8dwa.js} +1 -0
- package/dist/{index-2mz8hj58.js → index-g04hszcm.js} +1 -1
- package/dist/{index-rw8ze745.js → index-ga6avd48.js} +1 -1
- package/dist/{index-paff5y0r.js → index-grhhsrd5.js} +9 -7
- package/dist/{index-mxt0wfjy.js → index-h20qcyh5.js} +5 -2
- package/dist/index-j3r7r1mh.js +150 -0
- package/dist/{index-vgytj9wp.js → index-jmaw365j.js} +1 -1
- package/dist/{index-t5g5rm9n.js → index-jzdbkanz.js} +5 -3
- package/dist/index-k137ezb6.js +79 -0
- package/dist/{index-tazm4dxf.js → index-kdw0n92g.js} +1 -1
- package/dist/{index-wh70tmpd.js → index-ke6jtxkd.js} +1 -1
- package/dist/index-kgj8j7bv.js +83 -0
- package/dist/{index-9kpxz49v.js → index-kgkevngs.js} +1 -1
- package/dist/{index-hab790s6.js → index-kp1j7cc8.js} +4 -4
- package/dist/{index-jcge9tx3.js → index-krekhmp7.js} +142 -123
- package/dist/{index-3y2tzhr8.js → index-ky79wwgs.js} +4 -4
- package/dist/{index-39rmc00v.js → index-mfe9a266.js} +1 -1
- package/dist/{index-qpzyahe3.js → index-mgr0mdqp.js} +5 -2
- package/dist/{index-n20tybgk.js → index-mh3jdb25.js} +2 -2
- package/dist/{index-g5fgeb6v.js → index-mkmep637.js} +1 -1
- package/dist/{index-02r5sq9p.js → index-mrng24wq.js} +19 -21
- package/dist/index-mx2gya05.js +465 -0
- package/dist/{index-8yt3rwe7.js → index-n2t87ggz.js} +5 -5
- package/dist/index-nfeafbzh.js +7379 -0
- package/dist/{index-j0ef04jw.js → index-nfm15ej7.js} +4 -4
- package/dist/index-pd9e8rz4.js +193 -0
- package/dist/{index-zwgwyvdt.js → index-pdcbjd6a.js} +1 -1
- package/dist/{index-q427q23r.js → index-pjjh91vw.js} +2 -2
- package/dist/{index-gnjgkecx.js → index-q46b16xz.js} +1 -1
- package/dist/{index-9xr44d2g.js → index-qv5v6w9c.js} +330 -106
- package/dist/{index-tmv3ez1h.js → index-qymek778.js} +69 -12
- package/dist/{index-yrr3n391.js → index-ry8m2mhg.js} +2 -2
- package/dist/{index-93n6jwy0.js → index-s0n0nnz5.js} +3 -3
- package/dist/{index-1p8q0yrt.js → index-t5zp1jjj.js} +5 -7
- package/dist/{index-2rf33y2h.js → index-tav72wz5.js} +4 -2
- package/dist/{index-jpecjm30.js → index-tgehj4bp.js} +1 -1
- package/dist/{index-ma26mfnt.js → index-v5hmyef8.js} +1 -1
- package/dist/index-vebzvse6.js +230 -0
- package/dist/index-vv0hxrmy.js +295 -0
- package/dist/index-vxm0ya3f.js +707 -0
- package/dist/{index-t3qcac2a.js → index-w3s79kcb.js} +1 -1
- package/dist/{index-r97ppg0g.js → index-x1r7kxzd.js} +1 -1
- package/dist/{index-kynwa08q.js → index-xrsryvd2.js} +2 -2
- package/dist/{index-3mcbr8sx.js → index-xtxxt87z.js} +1 -1
- package/dist/index-zk839vzf.js +231 -0
- package/dist/{index-9c76vfxf.js → index-zyyerdny.js} +4 -4
- package/dist/internal/base64.d.ts +9 -0
- package/dist/internal/base64.d.ts.map +1 -0
- package/dist/internal/deadline-budget.d.ts +57 -0
- package/dist/internal/deadline-budget.d.ts.map +1 -0
- package/dist/internal/deadline.d.ts.map +1 -1
- package/dist/internal/timers.d.ts +2 -0
- package/dist/internal/timers.d.ts.map +1 -1
- package/dist/realtime/device-presence-contract.d.ts +194 -0
- package/dist/realtime/device-presence-contract.d.ts.map +1 -0
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts.map +1 -1
- package/dist/server/device-presence-handlers.d.ts +54 -0
- package/dist/server/device-presence-handlers.d.ts.map +1 -0
- package/dist/server/device-presence-registry.d.ts +35 -0
- package/dist/server/device-presence-registry.d.ts.map +1 -0
- package/dist/server/device-presence.d.ts +45 -0
- package/dist/server/device-presence.d.ts.map +1 -0
- package/dist/server/endpoint-dispatch.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +3 -1
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/types.d.ts +4 -11
- package/dist/server/types.d.ts.map +1 -1
- package/dist/service-host/systemd-render-shared.d.ts.map +1 -1
- package/dist/tools/agent-messages.d.ts +6 -0
- package/dist/tools/agent-messages.d.ts.map +1 -0
- package/dist/tools/agent-tool-error.d.ts +2 -2
- package/dist/tools/agent-tools.d.ts +153 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent.d.ts +6 -56
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +3 -4
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +3 -1
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +4 -4
- package/llms/agent-executor-codex.txt +1 -1
- package/llms/agent-executor.txt +7 -3
- package/llms/agent-runtime-ai-sdk.txt +26 -0
- package/llms/agent-runtime-anthropic.txt +33 -0
- package/llms/agent-runtime-browser.txt +22 -8
- package/llms/agent-runtime-harness.txt +2 -2
- package/llms/agent-runtime-openai.txt +31 -0
- package/llms/agent-runtime-openrouter.txt +17 -7
- package/llms/agent-runtime-sandbox.txt +53 -1
- package/llms/agent-runtime-testing.txt +4 -2
- package/llms/agent-runtime.2.txt +158 -271
- package/llms/agent-runtime.3.txt +289 -243
- package/llms/agent-runtime.4.txt +273 -216
- package/llms/agent-runtime.5.txt +209 -2
- package/llms/agent-runtime.txt +238 -181
- package/llms/contract.txt +2 -1
- package/llms/device-relay.txt +34 -0
- package/llms/realtime.txt +20 -0
- package/llms/server.2.txt +125 -1
- package/llms/server.3.txt +111 -122
- package/llms/server.4.txt +1 -1
- package/llms/server.5.txt +3 -1
- package/llms/server.txt +31 -1
- package/llms/spend.txt +11 -6
- package/llms/stitchkit.2.txt +21 -43
- package/llms/stitchkit.3.txt +43 -0
- package/llms/stitchkit.txt +93 -84
- package/llms/tools-agent.txt +7 -5
- package/llms/tools-toolkit.txt +1 -1
- package/llms/tools.4.txt +7 -2
- package/llms/{upgrading-0.128.0-0.133.0.txt → upgrading-0.128.0-0.134.0.txt} +173 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +983 -212
- package/llms.txt +21 -17
- package/package.json +18 -7
- package/dist/index-0p0s5hrj.js +0 -249
- package/dist/index-1dn2wjq6.js +0 -135
- package/dist/index-1psbyyhj.js +0 -21
- package/dist/index-34k82crg.js +0 -3961
- package/dist/index-5n3a8hd8.js +0 -102
- package/dist/index-97rp94ff.js +0 -8
- package/dist/index-bn2baakz.js +0 -336
- package/dist/index-eh71zr32.js +0 -14
- package/dist/index-emgrmavr.js +0 -1193
- package/dist/index-fzd477xk.js +0 -135
- package/dist/index-vgzhw2zk.js +0 -304
- package/dist/internal/ai-sdk-typed.d.ts +0 -14
- package/dist/internal/ai-sdk-typed.d.ts.map +0 -1
- package/dist/tools/runtime-call-context.d.ts +0 -15
- package/dist/tools/runtime-call-context.d.ts.map +0 -1
- package/dist/{index-vmbxj75t.js → index-jwtmw39p.js} +0 -0
- package/dist/{index-877e9y8r.js → index-sk03xe0n.js} +3 -3
- package/dist/{index-21cfxc4z.js → index-vh4291qh.js} +3 -3
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentCacheControlSchema2,
|
|
3
|
+
AgentToolModelOutputSchema2
|
|
4
|
+
} from "../../index-vebzvse6.js";
|
|
5
|
+
import"../../index-tav72wz5.js";
|
|
6
|
+
import"../../index-j3r7r1mh.js";
|
|
7
|
+
import"../../index-7qza24g1.js";
|
|
8
|
+
import {
|
|
9
|
+
providerEnvelope,
|
|
10
|
+
normalizeTokenUsage
|
|
11
|
+
} from "../../index-9f60gnfn.js";
|
|
12
|
+
import {
|
|
13
|
+
abortReason,
|
|
14
|
+
raceAbort
|
|
15
|
+
} from "../../index-rptj3qnc.js";
|
|
16
|
+
import {
|
|
17
|
+
isRecord
|
|
18
|
+
} from "../../index-ps3djm8d.js";
|
|
19
|
+
|
|
20
|
+
// src/agent-runtime/ai-sdk.ts
|
|
21
|
+
import { asSchema } from "ai";
|
|
22
|
+
|
|
23
|
+
// src/agent-runtime/ai-sdk-convert.ts
|
|
24
|
+
function isCustomKind(kind) {
|
|
25
|
+
return kind.includes(".");
|
|
26
|
+
}
|
|
27
|
+
function toV4JsonValue(value) {
|
|
28
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(value))
|
|
32
|
+
return value.map(toV4JsonValue);
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const [k, v] of Object.entries(value)) {
|
|
35
|
+
if (v !== undefined)
|
|
36
|
+
out[k] = toV4JsonValue(v);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
function toV4ProviderOptions(options) {
|
|
41
|
+
if (!options)
|
|
42
|
+
return;
|
|
43
|
+
const out = {};
|
|
44
|
+
for (const [providerKey, entry] of Object.entries(options)) {
|
|
45
|
+
if (!entry)
|
|
46
|
+
continue;
|
|
47
|
+
const inner = {};
|
|
48
|
+
for (const [k, v] of Object.entries(entry)) {
|
|
49
|
+
if (v !== undefined)
|
|
50
|
+
inner[k] = toV4JsonValue(v);
|
|
51
|
+
}
|
|
52
|
+
out[providerKey] = inner;
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function toV4ProviderReference(reference) {
|
|
57
|
+
const out = {};
|
|
58
|
+
for (const [key, value] of Object.entries(reference)) {
|
|
59
|
+
if (key !== "type")
|
|
60
|
+
out[key] = value;
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
function toV4FileData(data) {
|
|
65
|
+
switch (data.type) {
|
|
66
|
+
case "data":
|
|
67
|
+
return {
|
|
68
|
+
type: "data",
|
|
69
|
+
data: data.data instanceof ArrayBuffer ? new Uint8Array(data.data) : data.data
|
|
70
|
+
};
|
|
71
|
+
case "url":
|
|
72
|
+
return {
|
|
73
|
+
type: "url",
|
|
74
|
+
url: data.url,
|
|
75
|
+
...data.originalUrl !== undefined && { originalUrl: data.originalUrl }
|
|
76
|
+
};
|
|
77
|
+
case "reference":
|
|
78
|
+
return { type: "reference", reference: toV4ProviderReference(data.reference) };
|
|
79
|
+
case "text":
|
|
80
|
+
return { type: "text", text: data.text };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function toV4JsonSchema(schema) {
|
|
84
|
+
return schema;
|
|
85
|
+
}
|
|
86
|
+
function toV4ToolOutput(output) {
|
|
87
|
+
const providerOptions = toV4ProviderOptions(output.providerOptions);
|
|
88
|
+
switch (output.type) {
|
|
89
|
+
case "text":
|
|
90
|
+
case "error-text":
|
|
91
|
+
return {
|
|
92
|
+
type: output.type,
|
|
93
|
+
value: output.value,
|
|
94
|
+
...providerOptions && { providerOptions }
|
|
95
|
+
};
|
|
96
|
+
case "json":
|
|
97
|
+
case "error-json":
|
|
98
|
+
return {
|
|
99
|
+
type: output.type,
|
|
100
|
+
value: toV4JsonValue(output.value),
|
|
101
|
+
...providerOptions && { providerOptions }
|
|
102
|
+
};
|
|
103
|
+
case "execution-denied":
|
|
104
|
+
return {
|
|
105
|
+
type: "execution-denied",
|
|
106
|
+
...output.reason !== undefined && { reason: output.reason },
|
|
107
|
+
...providerOptions && { providerOptions }
|
|
108
|
+
};
|
|
109
|
+
case "content":
|
|
110
|
+
return {
|
|
111
|
+
type: "content",
|
|
112
|
+
value: output.value.map((part) => {
|
|
113
|
+
const partOpts = toV4ProviderOptions(part.providerOptions);
|
|
114
|
+
if (part.type === "text") {
|
|
115
|
+
return {
|
|
116
|
+
type: "text",
|
|
117
|
+
text: part.text,
|
|
118
|
+
...partOpts && { providerOptions: partOpts }
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (part.type === "file") {
|
|
122
|
+
return {
|
|
123
|
+
type: "file",
|
|
124
|
+
data: toV4FileData(part.data),
|
|
125
|
+
mediaType: part.mediaType,
|
|
126
|
+
...part.filename !== undefined && { filename: part.filename },
|
|
127
|
+
...partOpts && { providerOptions: partOpts }
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return { type: "custom", ...partOpts && { providerOptions: partOpts } };
|
|
131
|
+
})
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function convertUserPart(part) {
|
|
136
|
+
const providerOptions = toV4ProviderOptions(part.providerOptions);
|
|
137
|
+
if (part.type === "text") {
|
|
138
|
+
return { type: "text", text: part.text, ...providerOptions && { providerOptions } };
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
type: "file",
|
|
142
|
+
data: toV4FileData(part.data),
|
|
143
|
+
mediaType: part.mediaType,
|
|
144
|
+
...part.filename !== undefined && { filename: part.filename },
|
|
145
|
+
...providerOptions && { providerOptions }
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function convertAssistantParts(content) {
|
|
149
|
+
if (typeof content === "string")
|
|
150
|
+
return content.length > 0 ? [{ type: "text", text: content }] : [];
|
|
151
|
+
const out = [];
|
|
152
|
+
for (const part of content) {
|
|
153
|
+
const providerOptions = "providerOptions" in part ? toV4ProviderOptions(part.providerOptions) : undefined;
|
|
154
|
+
const opt = providerOptions ? { providerOptions } : {};
|
|
155
|
+
switch (part.type) {
|
|
156
|
+
case "text":
|
|
157
|
+
out.push({ type: "text", text: part.text, ...opt });
|
|
158
|
+
break;
|
|
159
|
+
case "reasoning":
|
|
160
|
+
out.push({ type: "reasoning", text: part.text, ...opt });
|
|
161
|
+
break;
|
|
162
|
+
case "file":
|
|
163
|
+
out.push({
|
|
164
|
+
type: "file",
|
|
165
|
+
data: toV4FileData(part.data),
|
|
166
|
+
mediaType: part.mediaType,
|
|
167
|
+
...part.filename !== undefined && { filename: part.filename },
|
|
168
|
+
...opt
|
|
169
|
+
});
|
|
170
|
+
break;
|
|
171
|
+
case "reasoning-file": {
|
|
172
|
+
const data = toV4FileData(part.data);
|
|
173
|
+
out.push(data.type === "data" || data.type === "url" ? { type: "reasoning-file", data, mediaType: part.mediaType, ...opt } : { type: "file", data, mediaType: part.mediaType, ...opt });
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
case "tool-call":
|
|
177
|
+
out.push({
|
|
178
|
+
type: "tool-call",
|
|
179
|
+
toolCallId: part.toolCallId,
|
|
180
|
+
toolName: part.toolName,
|
|
181
|
+
input: part.input,
|
|
182
|
+
...part.providerExecuted !== undefined && {
|
|
183
|
+
providerExecuted: part.providerExecuted
|
|
184
|
+
},
|
|
185
|
+
...opt
|
|
186
|
+
});
|
|
187
|
+
break;
|
|
188
|
+
case "tool-result":
|
|
189
|
+
out.push({
|
|
190
|
+
type: "tool-result",
|
|
191
|
+
toolCallId: part.toolCallId,
|
|
192
|
+
toolName: part.toolName,
|
|
193
|
+
output: toV4ToolOutput(part.output),
|
|
194
|
+
...opt
|
|
195
|
+
});
|
|
196
|
+
break;
|
|
197
|
+
case "custom":
|
|
198
|
+
if (isCustomKind(part.kind))
|
|
199
|
+
out.push({ type: "custom", kind: part.kind, ...opt });
|
|
200
|
+
break;
|
|
201
|
+
case "tool-approval-request":
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return out;
|
|
206
|
+
}
|
|
207
|
+
function convertToolParts(content, includeClientApprovals) {
|
|
208
|
+
const out = [];
|
|
209
|
+
for (const part of content) {
|
|
210
|
+
if (part.type === "tool-result") {
|
|
211
|
+
const providerOptions = toV4ProviderOptions(part.providerOptions);
|
|
212
|
+
out.push({
|
|
213
|
+
type: "tool-result",
|
|
214
|
+
toolCallId: part.toolCallId,
|
|
215
|
+
toolName: part.toolName,
|
|
216
|
+
output: toV4ToolOutput(part.output),
|
|
217
|
+
...providerOptions && { providerOptions }
|
|
218
|
+
});
|
|
219
|
+
} else if (includeClientApprovals || part.providerExecuted === true) {
|
|
220
|
+
out.push({
|
|
221
|
+
type: "tool-approval-response",
|
|
222
|
+
approvalId: part.approvalId,
|
|
223
|
+
approved: part.approved,
|
|
224
|
+
...part.reason !== undefined && { reason: part.reason }
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
230
|
+
function toV4Prompt(request) {
|
|
231
|
+
const prompt = [];
|
|
232
|
+
for (const sys of request.instructions) {
|
|
233
|
+
if (sys.content.length === 0)
|
|
234
|
+
continue;
|
|
235
|
+
const providerOptions = toV4ProviderOptions(sys.providerOptions);
|
|
236
|
+
prompt.push({
|
|
237
|
+
role: "system",
|
|
238
|
+
content: sys.content,
|
|
239
|
+
...providerOptions && { providerOptions }
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
for (const message of request.messages) {
|
|
243
|
+
const providerOptions = toV4ProviderOptions(message.providerOptions);
|
|
244
|
+
const opt = providerOptions ? { providerOptions } : {};
|
|
245
|
+
if (message.role === "system") {
|
|
246
|
+
if (message.content.length > 0)
|
|
247
|
+
prompt.push({ role: "system", content: message.content, ...opt });
|
|
248
|
+
} else if (message.role === "user") {
|
|
249
|
+
const content = typeof message.content === "string" ? message.content.length > 0 ? [{ type: "text", text: message.content }] : [] : message.content.map(convertUserPart);
|
|
250
|
+
if (content.length > 0)
|
|
251
|
+
prompt.push({ role: "user", content, ...opt });
|
|
252
|
+
} else if (message.role === "assistant") {
|
|
253
|
+
const content = convertAssistantParts(message.content);
|
|
254
|
+
if (content.length > 0)
|
|
255
|
+
prompt.push({ role: "assistant", content, ...opt });
|
|
256
|
+
} else {
|
|
257
|
+
const content = convertToolParts(message.content, false);
|
|
258
|
+
if (content.length > 0)
|
|
259
|
+
prompt.push({ role: "tool", content, ...opt });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return prompt;
|
|
263
|
+
}
|
|
264
|
+
function toAiSdkModelMessages(messages) {
|
|
265
|
+
const out = [];
|
|
266
|
+
for (const message of messages) {
|
|
267
|
+
const providerOptions = toV4ProviderOptions(message.providerOptions);
|
|
268
|
+
const opt = providerOptions ? { providerOptions } : {};
|
|
269
|
+
if (message.role === "system") {
|
|
270
|
+
out.push({ role: "system", content: message.content, ...opt });
|
|
271
|
+
} else if (message.role === "user") {
|
|
272
|
+
out.push({
|
|
273
|
+
role: "user",
|
|
274
|
+
content: typeof message.content === "string" ? message.content : message.content.map(convertUserPart),
|
|
275
|
+
...opt
|
|
276
|
+
});
|
|
277
|
+
} else if (message.role === "assistant") {
|
|
278
|
+
out.push({
|
|
279
|
+
role: "assistant",
|
|
280
|
+
content: typeof message.content === "string" ? message.content : convertAssistantParts(message.content),
|
|
281
|
+
...opt
|
|
282
|
+
});
|
|
283
|
+
} else {
|
|
284
|
+
out.push({ role: "tool", content: convertToolParts(message.content, true), ...opt });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return out;
|
|
288
|
+
}
|
|
289
|
+
function toV4CallOptions(request, signal) {
|
|
290
|
+
const toolChoice = request.toolChoice === undefined ? undefined : typeof request.toolChoice === "string" ? { type: request.toolChoice } : { type: "tool", toolName: request.toolChoice.toolName };
|
|
291
|
+
const responseFormat = request.responseFormat === undefined ? undefined : request.responseFormat.type === "text" ? { type: "text" } : request.responseFormat.type === "json-object" ? { type: "json" } : {
|
|
292
|
+
type: "json",
|
|
293
|
+
name: request.responseFormat.name,
|
|
294
|
+
schema: toV4JsonSchema(request.responseFormat.schema),
|
|
295
|
+
...request.responseFormat.description !== undefined && {
|
|
296
|
+
description: request.responseFormat.description
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
const providerOptions = toV4ProviderOptions(request.providerOptions);
|
|
300
|
+
const filteredHeaders = request.headers ? Object.fromEntries(Object.entries(request.headers).filter(([k]) => k.toLowerCase() !== "content-type")) : undefined;
|
|
301
|
+
const { settings } = request;
|
|
302
|
+
return {
|
|
303
|
+
prompt: toV4Prompt(request),
|
|
304
|
+
...request.tools.length > 0 && {
|
|
305
|
+
tools: request.tools.map((spec) => {
|
|
306
|
+
if (spec.type === "provider") {
|
|
307
|
+
throw new TypeError(`fromAiSdkModel: unsupported provider tool "${spec.id}" (type: "provider")`);
|
|
308
|
+
}
|
|
309
|
+
const specOpts = toV4ProviderOptions(spec.providerOptions);
|
|
310
|
+
return {
|
|
311
|
+
type: "function",
|
|
312
|
+
name: spec.name,
|
|
313
|
+
...spec.description !== undefined && { description: spec.description },
|
|
314
|
+
inputSchema: toV4JsonSchema(spec.inputSchema),
|
|
315
|
+
...spec.strict !== undefined && { strict: spec.strict },
|
|
316
|
+
...specOpts && { providerOptions: specOpts }
|
|
317
|
+
};
|
|
318
|
+
})
|
|
319
|
+
},
|
|
320
|
+
...toolChoice !== undefined && { toolChoice },
|
|
321
|
+
...responseFormat !== undefined && { responseFormat },
|
|
322
|
+
...settings.maxOutputTokens !== undefined && {
|
|
323
|
+
maxOutputTokens: settings.maxOutputTokens
|
|
324
|
+
},
|
|
325
|
+
...settings.temperature !== undefined && { temperature: settings.temperature },
|
|
326
|
+
...settings.topP !== undefined && { topP: settings.topP },
|
|
327
|
+
...settings.topK !== undefined && { topK: settings.topK },
|
|
328
|
+
...settings.presencePenalty !== undefined && {
|
|
329
|
+
presencePenalty: settings.presencePenalty
|
|
330
|
+
},
|
|
331
|
+
...settings.frequencyPenalty !== undefined && {
|
|
332
|
+
frequencyPenalty: settings.frequencyPenalty
|
|
333
|
+
},
|
|
334
|
+
...settings.seed !== undefined && { seed: settings.seed },
|
|
335
|
+
...settings.stopSequences !== undefined && {
|
|
336
|
+
stopSequences: [...settings.stopSequences]
|
|
337
|
+
},
|
|
338
|
+
...providerOptions && { providerOptions },
|
|
339
|
+
...filteredHeaders && Object.keys(filteredHeaders).length > 0 && { headers: filteredHeaders },
|
|
340
|
+
abortSignal: signal
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function toAgentJsonValue(value) {
|
|
344
|
+
if (value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value)) {
|
|
345
|
+
return value;
|
|
346
|
+
}
|
|
347
|
+
if (Array.isArray(value))
|
|
348
|
+
return value.map(toAgentJsonValue);
|
|
349
|
+
if (isRecord(value)) {
|
|
350
|
+
const nested = {};
|
|
351
|
+
for (const [k, v] of Object.entries(value)) {
|
|
352
|
+
if (v !== undefined)
|
|
353
|
+
nested[k] = toAgentJsonValue(v);
|
|
354
|
+
}
|
|
355
|
+
return nested;
|
|
356
|
+
}
|
|
357
|
+
return String(value);
|
|
358
|
+
}
|
|
359
|
+
function toAgentProviderOptions(raw) {
|
|
360
|
+
if (!isRecord(raw))
|
|
361
|
+
return;
|
|
362
|
+
const out = {};
|
|
363
|
+
for (const [ns, entry] of Object.entries(raw)) {
|
|
364
|
+
if (!isRecord(entry))
|
|
365
|
+
continue;
|
|
366
|
+
const inner = {};
|
|
367
|
+
for (const [k, v] of Object.entries(entry)) {
|
|
368
|
+
if (v !== undefined)
|
|
369
|
+
inner[k] = toAgentJsonValue(v);
|
|
370
|
+
}
|
|
371
|
+
out[ns] = inner;
|
|
372
|
+
}
|
|
373
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
374
|
+
}
|
|
375
|
+
function normalizeProviderReference(raw) {
|
|
376
|
+
if (typeof raw === "string" && raw.length > 0)
|
|
377
|
+
return { default: raw };
|
|
378
|
+
if (!isRecord(raw))
|
|
379
|
+
return;
|
|
380
|
+
const out = {};
|
|
381
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
382
|
+
if (k !== "type" && typeof v === "string")
|
|
383
|
+
out[k] = v;
|
|
384
|
+
}
|
|
385
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
386
|
+
}
|
|
387
|
+
function toOwnedBytes(bytes) {
|
|
388
|
+
const copy = new Uint8Array(bytes.byteLength);
|
|
389
|
+
copy.set(bytes);
|
|
390
|
+
return copy;
|
|
391
|
+
}
|
|
392
|
+
function normalizeExternalFileData(raw) {
|
|
393
|
+
if (raw instanceof Uint8Array)
|
|
394
|
+
return { type: "data", data: toOwnedBytes(raw) };
|
|
395
|
+
if (raw instanceof ArrayBuffer)
|
|
396
|
+
return { type: "data", data: new Uint8Array(raw) };
|
|
397
|
+
if (raw instanceof URL)
|
|
398
|
+
return { type: "url", url: raw };
|
|
399
|
+
if (typeof raw === "string")
|
|
400
|
+
return { type: "data", data: raw };
|
|
401
|
+
if (!isRecord(raw))
|
|
402
|
+
return;
|
|
403
|
+
if (raw.type === "data") {
|
|
404
|
+
if (raw.data instanceof Uint8Array)
|
|
405
|
+
return { type: "data", data: toOwnedBytes(raw.data) };
|
|
406
|
+
if (raw.data instanceof ArrayBuffer)
|
|
407
|
+
return { type: "data", data: new Uint8Array(raw.data) };
|
|
408
|
+
if (typeof raw.data === "string")
|
|
409
|
+
return { type: "data", data: raw.data };
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (raw.type === "url") {
|
|
413
|
+
if (raw.url instanceof URL) {
|
|
414
|
+
return {
|
|
415
|
+
type: "url",
|
|
416
|
+
url: raw.url,
|
|
417
|
+
...typeof raw.originalUrl === "string" && { originalUrl: raw.originalUrl }
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
if (typeof raw.url === "string") {
|
|
421
|
+
return URL.canParse(raw.url) ? { type: "url", url: new URL(raw.url), originalUrl: raw.url } : undefined;
|
|
422
|
+
}
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (raw.type === "reference") {
|
|
426
|
+
const reference = normalizeProviderReference(raw.reference);
|
|
427
|
+
return reference ? { type: "reference", reference } : undefined;
|
|
428
|
+
}
|
|
429
|
+
if (raw.type === "text" && typeof raw.text === "string") {
|
|
430
|
+
return { type: "text", text: raw.text };
|
|
431
|
+
}
|
|
432
|
+
const bareReference = normalizeProviderReference(raw);
|
|
433
|
+
return bareReference ? { type: "reference", reference: bareReference } : undefined;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// src/agent-runtime/ai-sdk.ts
|
|
437
|
+
function isV4LanguageModel(model) {
|
|
438
|
+
return typeof model === "object" && model !== null && "specificationVersion" in model && model.specificationVersion === "v4" && typeof model.doStream === "function";
|
|
439
|
+
}
|
|
440
|
+
function toLanguageModelUsage(v4Usage) {
|
|
441
|
+
const inputTotal = v4Usage.inputTokens.total;
|
|
442
|
+
const outputTotal = v4Usage.outputTokens.total;
|
|
443
|
+
return {
|
|
444
|
+
inputTokens: inputTotal,
|
|
445
|
+
outputTokens: outputTotal,
|
|
446
|
+
totalTokens: inputTotal !== undefined && outputTotal !== undefined ? inputTotal + outputTotal : undefined,
|
|
447
|
+
inputTokenDetails: {
|
|
448
|
+
noCacheTokens: v4Usage.inputTokens.noCache,
|
|
449
|
+
cacheReadTokens: v4Usage.inputTokens.cacheRead,
|
|
450
|
+
cacheWriteTokens: v4Usage.inputTokens.cacheWrite
|
|
451
|
+
},
|
|
452
|
+
outputTokenDetails: {
|
|
453
|
+
textTokens: v4Usage.outputTokens.text,
|
|
454
|
+
reasoningTokens: v4Usage.outputTokens.reasoning
|
|
455
|
+
},
|
|
456
|
+
...v4Usage.raw !== undefined && { raw: v4Usage.raw }
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function mapFinishReason(raw) {
|
|
460
|
+
switch (raw.unified) {
|
|
461
|
+
case "stop":
|
|
462
|
+
case "length":
|
|
463
|
+
case "tool-calls":
|
|
464
|
+
case "content-filter":
|
|
465
|
+
case "error":
|
|
466
|
+
case "interrupted":
|
|
467
|
+
return raw.unified;
|
|
468
|
+
default:
|
|
469
|
+
return "other";
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function extractGeneratedFileData(data) {
|
|
473
|
+
return data.type === "data" ? { type: "data", data: data.data } : { type: "url", url: data.url };
|
|
474
|
+
}
|
|
475
|
+
function mapV4StreamPart(part, options) {
|
|
476
|
+
const env = (meta) => {
|
|
477
|
+
const cleaned = toAgentProviderOptions(meta);
|
|
478
|
+
return cleaned !== undefined ? providerEnvelope(cleaned) : undefined;
|
|
479
|
+
};
|
|
480
|
+
switch (part.type) {
|
|
481
|
+
case "stream-start":
|
|
482
|
+
return;
|
|
483
|
+
case "response-metadata":
|
|
484
|
+
return {
|
|
485
|
+
type: "response-metadata",
|
|
486
|
+
...part.id !== undefined && { id: part.id },
|
|
487
|
+
...part.modelId !== undefined && { modelId: part.modelId },
|
|
488
|
+
...part.timestamp !== undefined && { timestamp: part.timestamp }
|
|
489
|
+
};
|
|
490
|
+
case "text-start":
|
|
491
|
+
case "text-end":
|
|
492
|
+
case "reasoning-start":
|
|
493
|
+
case "reasoning-end": {
|
|
494
|
+
const provider = env(part.providerMetadata);
|
|
495
|
+
return { type: part.type, id: part.id, ...provider && { provider } };
|
|
496
|
+
}
|
|
497
|
+
case "text-delta":
|
|
498
|
+
case "reasoning-delta": {
|
|
499
|
+
const provider = env(part.providerMetadata);
|
|
500
|
+
return {
|
|
501
|
+
type: part.type,
|
|
502
|
+
id: part.id,
|
|
503
|
+
delta: part.delta,
|
|
504
|
+
...provider && { provider }
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
case "tool-input-start":
|
|
508
|
+
return {
|
|
509
|
+
type: "tool-input-start",
|
|
510
|
+
toolCallId: part.id,
|
|
511
|
+
toolName: part.toolName,
|
|
512
|
+
...part.providerExecuted !== undefined && {
|
|
513
|
+
providerExecuted: part.providerExecuted
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
case "tool-input-delta":
|
|
517
|
+
return { type: "tool-input-delta", toolCallId: part.id, delta: part.delta };
|
|
518
|
+
case "tool-input-end":
|
|
519
|
+
return { type: "tool-input-end", toolCallId: part.id };
|
|
520
|
+
case "tool-call": {
|
|
521
|
+
const provider = env(part.providerMetadata);
|
|
522
|
+
return {
|
|
523
|
+
type: "tool-call",
|
|
524
|
+
toolCallId: part.toolCallId,
|
|
525
|
+
toolName: part.toolName,
|
|
526
|
+
input: part.input,
|
|
527
|
+
...part.providerExecuted !== undefined && {
|
|
528
|
+
providerExecuted: part.providerExecuted
|
|
529
|
+
},
|
|
530
|
+
...part.dynamic !== undefined && { dynamic: part.dynamic },
|
|
531
|
+
...provider && { provider }
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
case "tool-result": {
|
|
535
|
+
const provider = env(part.providerMetadata);
|
|
536
|
+
return {
|
|
537
|
+
type: "tool-result",
|
|
538
|
+
toolCallId: part.toolCallId,
|
|
539
|
+
toolName: part.toolName,
|
|
540
|
+
result: part.result,
|
|
541
|
+
providerExecuted: true,
|
|
542
|
+
...part.isError !== undefined && { isError: part.isError },
|
|
543
|
+
...part.preliminary !== undefined && { preliminary: part.preliminary },
|
|
544
|
+
...provider && { provider }
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
case "tool-approval-request": {
|
|
548
|
+
const provider = env(part.providerMetadata);
|
|
549
|
+
return {
|
|
550
|
+
type: "tool-approval-request",
|
|
551
|
+
approvalId: part.approvalId,
|
|
552
|
+
toolCallId: part.toolCallId,
|
|
553
|
+
...provider && { provider }
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
case "source": {
|
|
557
|
+
const validUrl = part.sourceType === "url" && typeof part.url === "string" && URL.canParse(part.url) ? part.url : undefined;
|
|
558
|
+
const source = {
|
|
559
|
+
type: "source",
|
|
560
|
+
sourceId: part.id,
|
|
561
|
+
...validUrl !== undefined && { url: validUrl },
|
|
562
|
+
...part.title !== undefined && { title: part.title }
|
|
563
|
+
};
|
|
564
|
+
return { type: "source", source };
|
|
565
|
+
}
|
|
566
|
+
case "file":
|
|
567
|
+
case "reasoning-file": {
|
|
568
|
+
const provider = env(part.providerMetadata);
|
|
569
|
+
return {
|
|
570
|
+
type: part.type,
|
|
571
|
+
mediaType: part.mediaType,
|
|
572
|
+
data: extractGeneratedFileData(part.data),
|
|
573
|
+
...provider && { provider }
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
case "custom": {
|
|
577
|
+
const provider = env(part.providerMetadata);
|
|
578
|
+
return { type: "custom", kind: part.kind, ...provider && { provider } };
|
|
579
|
+
}
|
|
580
|
+
case "raw":
|
|
581
|
+
return { type: "raw", rawValue: part.rawValue };
|
|
582
|
+
case "error":
|
|
583
|
+
return { type: "error", error: part.error };
|
|
584
|
+
case "finish": {
|
|
585
|
+
const sdkUsage = toLanguageModelUsage(part.usage);
|
|
586
|
+
const usage = options.normalizeUsage ? options.normalizeUsage({ usage: sdkUsage, providerMetadata: part.providerMetadata }) : normalizeTokenUsage({
|
|
587
|
+
inputTokens: sdkUsage.inputTokens,
|
|
588
|
+
outputTokens: sdkUsage.outputTokens,
|
|
589
|
+
reasoningTokens: sdkUsage.outputTokenDetails.reasoningTokens,
|
|
590
|
+
cacheReadTokens: sdkUsage.inputTokenDetails.cacheReadTokens,
|
|
591
|
+
cacheWriteTokens: sdkUsage.inputTokenDetails.cacheWriteTokens
|
|
592
|
+
});
|
|
593
|
+
const responseProvider = options.resolveResponseProvider?.({
|
|
594
|
+
providerMetadata: part.providerMetadata
|
|
595
|
+
});
|
|
596
|
+
const provider = env(part.providerMetadata);
|
|
597
|
+
return {
|
|
598
|
+
type: "finish",
|
|
599
|
+
finishReason: mapFinishReason(part.finishReason),
|
|
600
|
+
...part.finishReason.raw !== undefined && { rawFinishReason: part.finishReason.raw },
|
|
601
|
+
usage,
|
|
602
|
+
...responseProvider !== undefined && { responseProvider },
|
|
603
|
+
...provider && { provider }
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
default:
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
function fromAiSdkModel(model, options = {}) {
|
|
611
|
+
if (!isV4LanguageModel(model)) {
|
|
612
|
+
throw new TypeError('fromAiSdkModel requires an AI SDK LanguageModelV4 object (specificationVersion: "v4")');
|
|
613
|
+
}
|
|
614
|
+
return {
|
|
615
|
+
provider: model.provider,
|
|
616
|
+
modelId: model.modelId,
|
|
617
|
+
async stream(request, signal) {
|
|
618
|
+
const result = await model.doStream(toV4CallOptions(request, signal));
|
|
619
|
+
const parts = {
|
|
620
|
+
async* [Symbol.asyncIterator]() {
|
|
621
|
+
const reader = result.stream.getReader();
|
|
622
|
+
const onAbort = () => {
|
|
623
|
+
reader.cancel(abortReason(signal)).catch(() => {
|
|
624
|
+
return;
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
if (signal.aborted) {
|
|
628
|
+
reader.cancel(abortReason(signal)).catch(() => {
|
|
629
|
+
return;
|
|
630
|
+
});
|
|
631
|
+
throw abortReason(signal);
|
|
632
|
+
}
|
|
633
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
634
|
+
try {
|
|
635
|
+
for (;; ) {
|
|
636
|
+
const next = await raceAbort(reader.read(), signal);
|
|
637
|
+
signal.throwIfAborted();
|
|
638
|
+
if (next.done)
|
|
639
|
+
break;
|
|
640
|
+
const mapped = mapV4StreamPart(next.value, options);
|
|
641
|
+
if (mapped !== undefined)
|
|
642
|
+
yield mapped;
|
|
643
|
+
}
|
|
644
|
+
} finally {
|
|
645
|
+
signal.removeEventListener("abort", onAbort);
|
|
646
|
+
if (signal.aborted) {
|
|
647
|
+
reader.cancel(abortReason(signal)).catch(() => {
|
|
648
|
+
return;
|
|
649
|
+
});
|
|
650
|
+
} else {
|
|
651
|
+
await reader.cancel().catch(() => {
|
|
652
|
+
return;
|
|
653
|
+
});
|
|
654
|
+
reader.releaseLock();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
return { parts };
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
function normalizeExternalToolOutput(raw) {
|
|
664
|
+
const direct = AgentToolModelOutputSchema2.safeParse(raw);
|
|
665
|
+
if (direct.success)
|
|
666
|
+
return direct.data;
|
|
667
|
+
if (!isRecord(raw) || typeof raw.type !== "string") {
|
|
668
|
+
return { type: "text", value: JSON.stringify(raw) ?? "" };
|
|
669
|
+
}
|
|
670
|
+
const topOpts = toAgentProviderOptions(raw.providerOptions);
|
|
671
|
+
const parsedCc = AgentCacheControlSchema2.safeParse(raw.cacheControl);
|
|
672
|
+
const topFields = {
|
|
673
|
+
...topOpts && { providerOptions: topOpts },
|
|
674
|
+
...parsedCc.success && { cacheControl: parsedCc.data }
|
|
675
|
+
};
|
|
676
|
+
if ((raw.type === "text" || raw.type === "error-text") && typeof raw.value === "string") {
|
|
677
|
+
return { type: raw.type, value: raw.value, ...topFields };
|
|
678
|
+
}
|
|
679
|
+
if ((raw.type === "json" || raw.type === "error-json") && "value" in raw) {
|
|
680
|
+
return { type: raw.type, value: toAgentJsonValue(raw.value), ...topFields };
|
|
681
|
+
}
|
|
682
|
+
if (raw.type === "execution-denied") {
|
|
683
|
+
return {
|
|
684
|
+
type: "execution-denied",
|
|
685
|
+
...typeof raw.reason === "string" && { reason: raw.reason },
|
|
686
|
+
...topFields
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
if (raw.type !== "content" || !Array.isArray(raw.value)) {
|
|
690
|
+
return { type: "text", value: JSON.stringify(raw) ?? "" };
|
|
691
|
+
}
|
|
692
|
+
const parts = [];
|
|
693
|
+
for (const entry of raw.value) {
|
|
694
|
+
if (!isRecord(entry) || typeof entry.type !== "string")
|
|
695
|
+
continue;
|
|
696
|
+
const providerOptions = toAgentProviderOptions(entry.providerOptions);
|
|
697
|
+
const optField = providerOptions ? { providerOptions } : {};
|
|
698
|
+
if (entry.type === "text" && typeof entry.text === "string") {
|
|
699
|
+
parts.push({ type: "text", text: entry.text, ...optField });
|
|
700
|
+
} else if (entry.type === "custom") {
|
|
701
|
+
parts.push({ type: "custom", ...optField });
|
|
702
|
+
} else if ((entry.type === "file" || entry.type === "media") && typeof entry.mediaType === "string") {
|
|
703
|
+
const data = normalizeExternalFileData(entry.data);
|
|
704
|
+
if (data) {
|
|
705
|
+
parts.push({
|
|
706
|
+
type: "file",
|
|
707
|
+
data,
|
|
708
|
+
mediaType: entry.mediaType,
|
|
709
|
+
...typeof entry.filename === "string" && { filename: entry.filename },
|
|
710
|
+
...optField
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
} else if ((entry.type === "file-data" || entry.type === "image-data") && typeof entry.data === "string" && typeof entry.mediaType === "string") {
|
|
714
|
+
parts.push({
|
|
715
|
+
type: "file",
|
|
716
|
+
data: { type: "data", data: entry.data },
|
|
717
|
+
mediaType: entry.mediaType,
|
|
718
|
+
...typeof entry.filename === "string" && { filename: entry.filename },
|
|
719
|
+
...optField
|
|
720
|
+
});
|
|
721
|
+
} else if ((entry.type === "file-url" || entry.type === "image-url") && typeof entry.url === "string" && URL.canParse(entry.url)) {
|
|
722
|
+
const mediaType = entry.type === "image-url" ? "image/*" : typeof entry.mediaType === "string" ? entry.mediaType : "application/octet-stream";
|
|
723
|
+
parts.push({
|
|
724
|
+
type: "file",
|
|
725
|
+
data: { type: "url", url: new URL(entry.url), originalUrl: entry.url },
|
|
726
|
+
mediaType,
|
|
727
|
+
...optField
|
|
728
|
+
});
|
|
729
|
+
} else if (entry.type === "file-id" || entry.type === "image-file-id") {
|
|
730
|
+
const reference = normalizeProviderReference(entry.fileId);
|
|
731
|
+
if (reference) {
|
|
732
|
+
parts.push({
|
|
733
|
+
type: "file",
|
|
734
|
+
data: { type: "reference", reference },
|
|
735
|
+
mediaType: entry.type === "image-file-id" ? "image/*" : "application/octet-stream",
|
|
736
|
+
...optField
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
} else if (entry.type === "file-reference" || entry.type === "image-file-reference") {
|
|
740
|
+
const reference = normalizeProviderReference(entry.providerReference);
|
|
741
|
+
if (reference) {
|
|
742
|
+
parts.push({
|
|
743
|
+
type: "file",
|
|
744
|
+
data: { type: "reference", reference },
|
|
745
|
+
mediaType: entry.type === "image-file-reference" ? "image/*" : "application/octet-stream",
|
|
746
|
+
...optField
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
return AgentToolModelOutputSchema2.parse({ type: "content", value: parts, ...topFields });
|
|
752
|
+
}
|
|
753
|
+
async function fromAiSdkTools(toolSet) {
|
|
754
|
+
const result = {};
|
|
755
|
+
for (const [name, sdkTool] of Object.entries(toolSet)) {
|
|
756
|
+
if (sdkTool.type === "provider") {
|
|
757
|
+
throw new TypeError(`fromAiSdkTools does not support provider-defined tool "${name}" (type: "provider")`);
|
|
758
|
+
}
|
|
759
|
+
const schema = asSchema(sdkTool.inputSchema);
|
|
760
|
+
const resolvedSchema = await schema.jsonSchema;
|
|
761
|
+
const inputSchema = isRecord(resolvedSchema) ? { ...resolvedSchema } : {};
|
|
762
|
+
const description = typeof sdkTool.description === "string" ? sdkTool.description : typeof sdkTool.description === "function" ? sdkTool.description({ context: undefined }) : undefined;
|
|
763
|
+
const execute = sdkTool.execute;
|
|
764
|
+
const needsApproval = sdkTool.needsApproval;
|
|
765
|
+
const onInputAvailable = sdkTool.onInputAvailable;
|
|
766
|
+
const toModelOutput = sdkTool.toModelOutput;
|
|
767
|
+
const providerOptions = toAgentProviderOptions(sdkTool.providerOptions);
|
|
768
|
+
const adapted = {
|
|
769
|
+
...description !== undefined && { description },
|
|
770
|
+
inputSchema,
|
|
771
|
+
...sdkTool.strict !== undefined && { strict: sdkTool.strict },
|
|
772
|
+
...providerOptions && { providerOptions },
|
|
773
|
+
parseInput: async (value) => {
|
|
774
|
+
if (!schema.validate)
|
|
775
|
+
return { ok: true, value };
|
|
776
|
+
const checked = await schema.validate(value);
|
|
777
|
+
return checked.success ? { ok: true, value: checked.value } : { ok: false, error: checked.error };
|
|
778
|
+
},
|
|
779
|
+
...execute && {
|
|
780
|
+
execute(input, call) {
|
|
781
|
+
return execute.call(sdkTool, input, {
|
|
782
|
+
toolCallId: call.toolCallId,
|
|
783
|
+
messages: toAiSdkModelMessages(call.messages),
|
|
784
|
+
abortSignal: call.abortSignal,
|
|
785
|
+
context: undefined
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
...needsApproval !== undefined && {
|
|
790
|
+
needsApproval: typeof needsApproval === "function" ? (input, call) => needsApproval.call(sdkTool, input, {
|
|
791
|
+
toolCallId: call.toolCallId,
|
|
792
|
+
messages: toAiSdkModelMessages(call.messages),
|
|
793
|
+
context: undefined
|
|
794
|
+
}) : needsApproval
|
|
795
|
+
},
|
|
796
|
+
...onInputAvailable && {
|
|
797
|
+
onInputAvailable(opts) {
|
|
798
|
+
return onInputAvailable.call(sdkTool, {
|
|
799
|
+
input: opts.input,
|
|
800
|
+
toolCallId: opts.toolCallId,
|
|
801
|
+
messages: toAiSdkModelMessages(opts.messages),
|
|
802
|
+
abortSignal: opts.abortSignal,
|
|
803
|
+
context: undefined
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
...toModelOutput && {
|
|
808
|
+
async toModelOutput(opts) {
|
|
809
|
+
const raw = await toModelOutput.call(sdkTool, opts);
|
|
810
|
+
return normalizeExternalToolOutput(raw);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
result[name] = adapted;
|
|
815
|
+
}
|
|
816
|
+
return result;
|
|
817
|
+
}
|
|
818
|
+
export {
|
|
819
|
+
fromAiSdkModel,
|
|
820
|
+
fromAiSdkTools
|
|
821
|
+
};
|