@probelabs/visor 0.1.192 → 0.1.193
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/142.index.js +124 -52
- package/dist/action-cli-bridge.d.ts.map +1 -1
- package/dist/agent-protocol/a2a-frontend.d.ts.map +1 -1
- package/dist/agent-protocol/index.d.ts.map +1 -1
- package/dist/agent-protocol/push-notification-manager.d.ts.map +1 -1
- package/dist/agent-protocol/state-transitions.d.ts.map +1 -1
- package/dist/agent-protocol/task-evaluator.d.ts.map +1 -1
- package/dist/agent-protocol/task-live-update-slack.d.ts.map +1 -1
- package/dist/agent-protocol/task-live-update-teams.d.ts.map +1 -1
- package/dist/agent-protocol/task-live-update-telegram.d.ts.map +1 -1
- package/dist/agent-protocol/task-live-updates.d.ts.map +1 -1
- package/dist/agent-protocol/task-progress-tool.d.ts.map +1 -1
- package/dist/agent-protocol/task-queue.d.ts.map +1 -1
- package/dist/agent-protocol/task-store.d.ts.map +1 -1
- package/dist/agent-protocol/task-stream-manager.d.ts.map +1 -1
- package/dist/agent-protocol/task-trace-resolution.d.ts.map +1 -1
- package/dist/agent-protocol/tasks-cli-handler.d.ts.map +1 -1
- package/dist/agent-protocol/tasks-tui.d.ts.map +1 -1
- package/dist/agent-protocol/trace-serializer.d.ts.map +1 -1
- package/dist/agent-protocol/track-execution.d.ts.map +1 -1
- package/dist/agent-protocol/types.d.ts.map +1 -1
- package/dist/ai-review-service.d.ts.map +1 -1
- package/dist/check-execution-engine.d.ts.map +1 -1
- package/dist/cli-main.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/config/cli-handler.d.ts.map +1 -1
- package/dist/config/config-reloader.d.ts.map +1 -1
- package/dist/config/config-snapshot-store.d.ts.map +1 -1
- package/dist/config/config-watcher.d.ts.map +1 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/cron-scheduler.d.ts.map +1 -1
- package/dist/debug-visualizer/debug-span-exporter.d.ts.map +1 -1
- package/dist/debug-visualizer/trace-reader.d.ts.map +1 -1
- package/dist/debug-visualizer/ws-server.d.ts.map +1 -1
- package/dist/dependency-resolver.d.ts.map +1 -1
- package/dist/email/adapter.d.ts.map +1 -1
- package/dist/email/client.d.ts.map +1 -1
- package/dist/email/markdown.d.ts.map +1 -1
- package/dist/email/polling-runner.d.ts.map +1 -1
- package/dist/engine/on-finish/orchestrator.d.ts.map +1 -1
- package/dist/engine/on-finish/utils.d.ts.map +1 -1
- package/dist/event-bus/event-bus.d.ts.map +1 -1
- package/dist/event-bus/types.d.ts.map +1 -1
- package/dist/event-mapper.d.ts.map +1 -1
- package/dist/failure-condition-evaluator.d.ts.map +1 -1
- package/dist/footer.d.ts.map +1 -1
- package/dist/frontends/email-frontend.d.ts.map +1 -1
- package/dist/frontends/github-frontend.d.ts.map +1 -1
- package/dist/frontends/host.d.ts.map +1 -1
- package/dist/frontends/ndjson-sink.d.ts.map +1 -1
- package/dist/frontends/slack-frontend.d.ts.map +1 -1
- package/dist/frontends/teams-frontend.d.ts.map +1 -1
- package/dist/frontends/telegram-frontend.d.ts.map +1 -1
- package/dist/frontends/whatsapp-frontend.d.ts.map +1 -1
- package/dist/generated/config-schema.d.ts.map +1 -1
- package/dist/git-repository-analyzer.d.ts.map +1 -1
- package/dist/github-auth.d.ts.map +1 -1
- package/dist/github-check-service.d.ts.map +1 -1
- package/dist/github-comments.d.ts.map +1 -1
- package/dist/github-reactions.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2888 -221
- package/dist/issue-filter.d.ts.map +1 -1
- package/dist/liquid-extensions.d.ts.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/mcp-job-manager.d.ts.map +1 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/memory-store.d.ts.map +1 -1
- package/dist/output/traces/{run-2026-09-04T18-22-07-538Z.ndjson → run-2026-09-08T12-33-44-000Z.ndjson} +2733 -2733
- package/dist/output-formatters.d.ts.map +1 -1
- package/dist/policy/default-engine.d.ts.map +1 -1
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/policy-check-command.d.ts.map +1 -1
- package/dist/policy/types.d.ts.map +1 -1
- package/dist/pr-analyzer.d.ts.map +1 -1
- package/dist/pr-detector.d.ts.map +1 -1
- package/dist/providers/a2a-check-provider.d.ts.map +1 -1
- package/dist/providers/ai-check-provider.d.ts.map +1 -1
- package/dist/providers/api-tool-executor.d.ts.map +1 -1
- package/dist/providers/check-provider-registry.d.ts.map +1 -1
- package/dist/providers/check-provider.interface.d.ts.map +1 -1
- package/dist/providers/claude-code-check-provider.d.ts.map +1 -1
- package/dist/providers/claude-code-types.d.ts.map +1 -1
- package/dist/providers/command-check-provider.d.ts.map +1 -1
- package/dist/providers/custom-tool-executor.d.ts.map +1 -1
- package/dist/providers/git-checkout-provider.d.ts.map +1 -1
- package/dist/providers/github-ops-provider.d.ts.map +1 -1
- package/dist/providers/http-check-provider.d.ts.map +1 -1
- package/dist/providers/http-client-provider.d.ts.map +1 -1
- package/dist/providers/http-input-provider.d.ts.map +1 -1
- package/dist/providers/human-input-check-provider.d.ts.map +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/log-check-provider.d.ts.map +1 -1
- package/dist/providers/mcp-check-provider.d.ts.map +1 -1
- package/dist/providers/mcp-custom-sse-server.d.ts.map +1 -1
- package/dist/providers/mcp-tools.d.ts.map +1 -1
- package/dist/providers/memory-check-provider.d.ts.map +1 -1
- package/dist/providers/noop-check-provider.d.ts.map +1 -1
- package/dist/providers/script-check-provider.d.ts.map +1 -1
- package/dist/providers/utcp-check-provider.d.ts.map +1 -1
- package/dist/providers/workflow-check-provider.d.ts.map +1 -1
- package/dist/providers/workflow-tool-executor.d.ts.map +1 -1
- package/dist/reviewer.d.ts.map +1 -1
- package/dist/runners/config-reload-runtime.d.ts.map +1 -1
- package/dist/runners/graceful-restart.d.ts.map +1 -1
- package/dist/runners/mcp-server-runner.d.ts.map +1 -1
- package/dist/runners/process-cli-handler.d.ts.map +1 -1
- package/dist/runners/process-discovery.d.ts.map +1 -1
- package/dist/runners/runner-factory.d.ts.map +1 -1
- package/dist/runners/runner-host.d.ts.map +1 -1
- package/dist/runners/runner.d.ts.map +1 -1
- package/dist/runners/telemetry-init.d.ts.map +1 -1
- package/dist/sandbox/bubblewrap-sandbox.d.ts.map +1 -1
- package/dist/sandbox/cache-volume-manager.d.ts.map +1 -1
- package/dist/sandbox/check-runner.d.ts.map +1 -1
- package/dist/sandbox/compose-generator.d.ts.map +1 -1
- package/dist/sandbox/docker-compose-sandbox.d.ts.map +1 -1
- package/dist/sandbox/docker-image-sandbox.d.ts.map +1 -1
- package/dist/sandbox/env-filter.d.ts.map +1 -1
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/sandbox-manager.d.ts.map +1 -1
- package/dist/sandbox/sandbox-telemetry.d.ts.map +1 -1
- package/dist/sandbox/seatbelt-sandbox.d.ts.map +1 -1
- package/dist/sandbox/trace-ingester.d.ts.map +1 -1
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/scheduler/cli-handler.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/message-trigger.d.ts.map +1 -1
- package/dist/scheduler/schedule-parser.d.ts.map +1 -1
- package/dist/scheduler/schedule-store.d.ts.map +1 -1
- package/dist/scheduler/schedule-tool.d.ts.map +1 -1
- package/dist/scheduler/scheduler.d.ts.map +1 -1
- package/dist/scheduler/store/index.d.ts.map +1 -1
- package/dist/scheduler/store/json-migrator.d.ts.map +1 -1
- package/dist/scheduler/store/sqlite-store.d.ts.map +1 -1
- package/dist/scheduler/store/types.d.ts.map +1 -1
- package/dist/sdk/{a2a-frontend-PJCABGOP.mjs → a2a-frontend-DTL6KBBT.mjs} +3 -3
- package/dist/sdk/{check-provider-registry-BJ3HM5QA.mjs → check-provider-registry-WPFEUMJB.mjs} +6 -6
- package/dist/sdk/{chunk-ZYX6MWEZ.mjs → chunk-AHIRSKZN.mjs} +2 -2
- package/dist/sdk/{chunk-7Y6FILDF.mjs → chunk-DOA4ZAQN.mjs} +18 -18
- package/dist/sdk/{chunk-ZBUWGGGM.mjs → chunk-HPZ3DPH3.mjs} +2 -2
- package/dist/sdk/{chunk-3MLVJMFH.mjs → chunk-J3U4U73O.mjs} +3 -3
- package/dist/sdk/{chunk-QK5WDIBY.mjs → chunk-JTLPD3XT.mjs} +3 -3
- package/dist/sdk/{chunk-QK5WDIBY.mjs.map → chunk-JTLPD3XT.mjs.map} +1 -1
- package/dist/sdk/{failure-condition-evaluator-YIDPBP6D.mjs → failure-condition-evaluator-3TEFKXFO.mjs} +4 -4
- package/dist/sdk/{github-frontend-6XNHGGYC.mjs → github-frontend-QLC43YSG.mjs} +4 -4
- package/dist/sdk/{host-DUS4Q5S2.mjs → host-CLECMKBM.mjs} +3 -3
- package/dist/sdk/{routing-XA2ADZBI.mjs → routing-RW67TD5Y.mjs} +5 -5
- package/dist/sdk/{schedule-tool-3EKJMU4G.mjs → schedule-tool-5N5LMN47.mjs} +6 -6
- package/dist/sdk/{schedule-tool-handler-2EC3THOP.mjs → schedule-tool-handler-YHFXV7E6.mjs} +6 -6
- package/dist/sdk/sdk.js +2 -2
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +5 -5
- package/dist/sdk/{trace-helpers-SCIIPM5Q.mjs → trace-helpers-QNQGD3SI.mjs} +3 -3
- package/dist/sdk/{track-execution-ROUXNL4I.mjs → track-execution-YR62D4UB.mjs} +2 -2
- package/dist/sdk/{workflow-check-provider-ZGU7RCNC.mjs → workflow-check-provider-SUK5GJVI.mjs} +6 -6
- package/dist/sdk.d.ts.map +1 -1
- package/dist/session-registry.d.ts.map +1 -1
- package/dist/slack/adapter.d.ts.map +1 -1
- package/dist/slack/cache-prewarmer.d.ts.map +1 -1
- package/dist/slack/client.d.ts.map +1 -1
- package/dist/slack/markdown.d.ts.map +1 -1
- package/dist/slack/prompt-state.d.ts.map +1 -1
- package/dist/slack/rate-limiter.d.ts.map +1 -1
- package/dist/slack/schedule-tool-handler.d.ts.map +1 -1
- package/dist/slack/signature.d.ts.map +1 -1
- package/dist/slack/slack-output-adapter.d.ts.map +1 -1
- package/dist/slack/socket-runner.d.ts.map +1 -1
- package/dist/slack/thread-cache.d.ts.map +1 -1
- package/dist/snapshot-store.d.ts.map +1 -1
- package/dist/state-machine/context/build-engine-context.d.ts.map +1 -1
- package/dist/state-machine/context/workflow-inputs.d.ts.map +1 -1
- package/dist/state-machine/dispatch/debounce-manager.d.ts.map +1 -1
- package/dist/state-machine/dispatch/dependency-gating.d.ts.map +1 -1
- package/dist/state-machine/dispatch/execution-invoker.d.ts.map +1 -1
- package/dist/state-machine/dispatch/foreach-processor.d.ts.map +1 -1
- package/dist/state-machine/dispatch/history-snapshot.d.ts.map +1 -1
- package/dist/state-machine/dispatch/on-init-handlers.d.ts.map +1 -1
- package/dist/state-machine/dispatch/policy-gate.d.ts.map +1 -1
- package/dist/state-machine/dispatch/renderer-schema.d.ts.map +1 -1
- package/dist/state-machine/dispatch/sandbox-routing.d.ts.map +1 -1
- package/dist/state-machine/dispatch/stats-manager.d.ts.map +1 -1
- package/dist/state-machine/dispatch/template-renderer.d.ts.map +1 -1
- package/dist/state-machine/execution/summary.d.ts.map +1 -1
- package/dist/state-machine/runner.d.ts.map +1 -1
- package/dist/state-machine/states/check-running.d.ts.map +1 -1
- package/dist/state-machine/states/completed.d.ts.map +1 -1
- package/dist/state-machine/states/error.d.ts.map +1 -1
- package/dist/state-machine/states/init.d.ts.map +1 -1
- package/dist/state-machine/states/level-dispatch.d.ts.map +1 -1
- package/dist/state-machine/states/plan-ready.d.ts.map +1 -1
- package/dist/state-machine/states/routing.d.ts.map +1 -1
- package/dist/state-machine/states/wave-planning.d.ts.map +1 -1
- package/dist/state-machine/workflow-projection.d.ts.map +1 -1
- package/dist/state-machine-execution-engine.d.ts.map +1 -1
- package/dist/teams/adapter.d.ts.map +1 -1
- package/dist/teams/client.d.ts.map +1 -1
- package/dist/teams/markdown.d.ts.map +1 -1
- package/dist/teams/webhook-runner.d.ts.map +1 -1
- package/dist/telegram/adapter.d.ts.map +1 -1
- package/dist/telegram/client.d.ts.map +1 -1
- package/dist/telegram/markdown.d.ts.map +1 -1
- package/dist/telegram/polling-runner.d.ts.map +1 -1
- package/dist/telemetry/fallback-ndjson.d.ts.map +1 -1
- package/dist/telemetry/file-span-exporter.d.ts.map +1 -1
- package/dist/telemetry/lazy-otel.d.ts.map +1 -1
- package/dist/telemetry/metrics.d.ts.map +1 -1
- package/dist/telemetry/opentelemetry.d.ts.map +1 -1
- package/dist/telemetry/state-capture.d.ts.map +1 -1
- package/dist/telemetry/trace-helpers.d.ts.map +1 -1
- package/dist/telemetry/trace-report-exporter.d.ts.map +1 -1
- package/dist/test-runner/assertions.d.ts.map +1 -1
- package/dist/test-runner/conversation-sugar.d.ts.map +1 -1
- package/dist/test-runner/core/environment.d.ts.map +1 -1
- package/dist/test-runner/core/fixture.d.ts.map +1 -1
- package/dist/test-runner/core/flow-stage.d.ts.map +1 -1
- package/dist/test-runner/core/mocks.d.ts.map +1 -1
- package/dist/test-runner/core/test-execution-wrapper.d.ts.map +1 -1
- package/dist/test-runner/evaluators.d.ts.map +1 -1
- package/dist/test-runner/fixture-loader.d.ts.map +1 -1
- package/dist/test-runner/index.d.ts.map +1 -1
- package/dist/test-runner/llm-judge.d.ts.map +1 -1
- package/dist/test-runner/recorders/github-recorder.d.ts.map +1 -1
- package/dist/test-runner/recorders/global-recorder.d.ts.map +1 -1
- package/dist/test-runner/recorders/slack-recorder.d.ts.map +1 -1
- package/dist/test-runner/utils/selectors.d.ts.map +1 -1
- package/dist/test-runner/validator.d.ts.map +1 -1
- package/dist/traces/{run-2026-09-04T18-22-07-538Z.ndjson → run-2026-09-08T12-33-44-000Z.ndjson} +2733 -2733
- package/dist/tui/chat-runner.d.ts.map +1 -1
- package/dist/tui/chat-state.d.ts.map +1 -1
- package/dist/tui/chat-tui.d.ts.map +1 -1
- package/dist/tui/components/chat-box.d.ts.map +1 -1
- package/dist/tui/components/input-bar.d.ts.map +1 -1
- package/dist/tui/components/status-bar.d.ts.map +1 -1
- package/dist/tui/components/trace-viewer.d.ts.map +1 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/tui-frontend.d.ts.map +1 -1
- package/dist/types/bot.d.ts.map +1 -1
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/engine.d.ts.map +1 -1
- package/dist/types/execution.d.ts.map +1 -1
- package/dist/types/git-checkout.d.ts.map +1 -1
- package/dist/types/github.d.ts.map +1 -1
- package/dist/types/workflow.d.ts.map +1 -1
- package/dist/utils/author-permissions.d.ts.map +1 -1
- package/dist/utils/child-process-error-handler.d.ts.map +1 -1
- package/dist/utils/command-executor.d.ts.map +1 -1
- package/dist/utils/comment-metadata.d.ts.map +1 -1
- package/dist/utils/config-loader.d.ts.map +1 -1
- package/dist/utils/config-merger.d.ts.map +1 -1
- package/dist/utils/diff-processor.d.ts.map +1 -1
- package/dist/utils/env-exposure.d.ts.map +1 -1
- package/dist/utils/env-resolver.d.ts.map +1 -1
- package/dist/utils/fair-concurrency-limiter.d.ts.map +1 -1
- package/dist/utils/file-exclusion.d.ts.map +1 -1
- package/dist/utils/head-sha.d.ts.map +1 -1
- package/dist/utils/human-id.d.ts.map +1 -1
- package/dist/utils/instance-id.d.ts.map +1 -1
- package/dist/utils/interactive-prompt.d.ts.map +1 -1
- package/dist/utils/issue-normalizer.d.ts.map +1 -1
- package/dist/utils/json-text-extractor.d.ts.map +1 -1
- package/dist/utils/mermaid-telemetry.d.ts.map +1 -1
- package/dist/utils/oauth2-token-cache.d.ts.map +1 -1
- package/dist/utils/rate-limiter.d.ts.map +1 -1
- package/dist/utils/sandbox.d.ts.map +1 -1
- package/dist/utils/script-memory-ops.d.ts.map +1 -1
- package/dist/utils/script-tool-environment.d.ts.map +1 -1
- package/dist/utils/stdin-reader.d.ts.map +1 -1
- package/dist/utils/template-context.d.ts.map +1 -1
- package/dist/utils/tool-resolver.d.ts.map +1 -1
- package/dist/utils/toolkit-expander.d.ts.map +1 -1
- package/dist/utils/tracer-init.d.ts.map +1 -1
- package/dist/utils/ui-helpers.d.ts.map +1 -1
- package/dist/utils/user-facing-error.d.ts.map +1 -1
- package/dist/utils/workspace-manager.d.ts.map +1 -1
- package/dist/utils/worktree-cleanup.d.ts.map +1 -1
- package/dist/utils/worktree-manager.d.ts.map +1 -1
- package/dist/webhook-server.d.ts.map +1 -1
- package/dist/whatsapp/adapter.d.ts.map +1 -1
- package/dist/whatsapp/client.d.ts.map +1 -1
- package/dist/whatsapp/markdown.d.ts.map +1 -1
- package/dist/whatsapp/webhook-runner.d.ts.map +1 -1
- package/dist/workflow-executor.d.ts.map +1 -1
- package/dist/workflow-registry.d.ts.map +1 -1
- package/package.json +2 -2
- /package/dist/sdk/{a2a-frontend-PJCABGOP.mjs.map → a2a-frontend-DTL6KBBT.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-BJ3HM5QA.mjs.map → check-provider-registry-WPFEUMJB.mjs.map} +0 -0
- /package/dist/sdk/{chunk-ZYX6MWEZ.mjs.map → chunk-AHIRSKZN.mjs.map} +0 -0
- /package/dist/sdk/{chunk-7Y6FILDF.mjs.map → chunk-DOA4ZAQN.mjs.map} +0 -0
- /package/dist/sdk/{chunk-ZBUWGGGM.mjs.map → chunk-HPZ3DPH3.mjs.map} +0 -0
- /package/dist/sdk/{chunk-3MLVJMFH.mjs.map → chunk-J3U4U73O.mjs.map} +0 -0
- /package/dist/sdk/{failure-condition-evaluator-YIDPBP6D.mjs.map → failure-condition-evaluator-3TEFKXFO.mjs.map} +0 -0
- /package/dist/sdk/{github-frontend-6XNHGGYC.mjs.map → github-frontend-QLC43YSG.mjs.map} +0 -0
- /package/dist/sdk/{host-DUS4Q5S2.mjs.map → host-CLECMKBM.mjs.map} +0 -0
- /package/dist/sdk/{routing-XA2ADZBI.mjs.map → routing-RW67TD5Y.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-3EKJMU4G.mjs.map → schedule-tool-5N5LMN47.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-2EC3THOP.mjs.map → schedule-tool-handler-YHFXV7E6.mjs.map} +0 -0
- /package/dist/sdk/{trace-helpers-SCIIPM5Q.mjs.map → trace-helpers-QNQGD3SI.mjs.map} +0 -0
- /package/dist/sdk/{track-execution-ROUXNL4I.mjs.map → track-execution-YR62D4UB.mjs.map} +0 -0
- /package/dist/sdk/{workflow-check-provider-ZGU7RCNC.mjs.map → workflow-check-provider-SUK5GJVI.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
process.env.VISOR_VERSION = '0.1.
|
|
3
|
-
process.env.PROBE_VERSION = '0.6.0-
|
|
2
|
+
process.env.VISOR_VERSION = '0.1.193';
|
|
3
|
+
process.env.PROBE_VERSION = '0.6.0-rc339';
|
|
4
4
|
process.env.VISOR_COMMIT_SHA = 'unknown';
|
|
5
5
|
process.env.VISOR_COMMIT_SHORT = 'unknown';
|
|
6
6
|
/******/ (() => { // webpackBootstrap
|
|
@@ -474175,6 +474175,218 @@ var init_v3 = __esm({
|
|
|
474175
474175
|
}
|
|
474176
474176
|
});
|
|
474177
474177
|
|
|
474178
|
+
// node_modules/eventsource-parser/dist/index.js
|
|
474179
|
+
function noop(_arg) {
|
|
474180
|
+
}
|
|
474181
|
+
function createParser(config2) {
|
|
474182
|
+
if (typeof config2 == "function")
|
|
474183
|
+
throw new TypeError(
|
|
474184
|
+
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
474185
|
+
);
|
|
474186
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
|
|
474187
|
+
let pendingFragmentsLength = 0, isFirstChunk = true, id, data2 = "", dataLines = 0, eventType, terminated = false;
|
|
474188
|
+
function feed(chunk) {
|
|
474189
|
+
if (terminated)
|
|
474190
|
+
throw new Error(
|
|
474191
|
+
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
474192
|
+
);
|
|
474193
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
474194
|
+
const trailing2 = processLines(chunk);
|
|
474195
|
+
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
474196
|
+
return;
|
|
474197
|
+
}
|
|
474198
|
+
if (chunk.indexOf(`
|
|
474199
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
474200
|
+
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
474201
|
+
return;
|
|
474202
|
+
}
|
|
474203
|
+
pendingFragments.push(chunk);
|
|
474204
|
+
const input = pendingFragments.join("");
|
|
474205
|
+
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
474206
|
+
const trailing = processLines(input);
|
|
474207
|
+
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
474208
|
+
}
|
|
474209
|
+
function checkBufferSize() {
|
|
474210
|
+
maxBufferSize !== void 0 && (pendingFragmentsLength + data2.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data2 = "", dataLines = 0, eventType = void 0, onError(
|
|
474211
|
+
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
474212
|
+
type: "max-buffer-size-exceeded"
|
|
474213
|
+
})
|
|
474214
|
+
)));
|
|
474215
|
+
}
|
|
474216
|
+
function processLines(chunk) {
|
|
474217
|
+
let searchIndex = 0;
|
|
474218
|
+
if (chunk.indexOf("\r") === -1) {
|
|
474219
|
+
let lfIndex = chunk.indexOf(`
|
|
474220
|
+
`, searchIndex);
|
|
474221
|
+
for (; lfIndex !== -1; ) {
|
|
474222
|
+
if (searchIndex === lfIndex) {
|
|
474223
|
+
dataLines > 0 && onEvent({ id, event: eventType, data: data2 }), id = void 0, data2 = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
474224
|
+
`, searchIndex);
|
|
474225
|
+
continue;
|
|
474226
|
+
}
|
|
474227
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
474228
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
474229
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
474230
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
474231
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data2 = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
474232
|
+
`, searchIndex);
|
|
474233
|
+
continue;
|
|
474234
|
+
}
|
|
474235
|
+
data2 = dataLines === 0 ? value : `${data2}
|
|
474236
|
+
${value}`, dataLines++;
|
|
474237
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
474238
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
474239
|
+
lfIndex
|
|
474240
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
474241
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
474242
|
+
`, searchIndex);
|
|
474243
|
+
}
|
|
474244
|
+
return chunk.slice(searchIndex);
|
|
474245
|
+
}
|
|
474246
|
+
for (; searchIndex < chunk.length; ) {
|
|
474247
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
474248
|
+
`, searchIndex);
|
|
474249
|
+
let lineEnd = -1;
|
|
474250
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
474251
|
+
break;
|
|
474252
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
474253
|
+
}
|
|
474254
|
+
return chunk.slice(searchIndex);
|
|
474255
|
+
}
|
|
474256
|
+
function parseLine(chunk, start, end) {
|
|
474257
|
+
if (start === end) {
|
|
474258
|
+
dispatchEvent();
|
|
474259
|
+
return;
|
|
474260
|
+
}
|
|
474261
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
474262
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
474263
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
474264
|
+
data2 = dataLines === 0 ? value2 : `${data2}
|
|
474265
|
+
${value2}`, dataLines++;
|
|
474266
|
+
return;
|
|
474267
|
+
}
|
|
474268
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
474269
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
474270
|
+
return;
|
|
474271
|
+
}
|
|
474272
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
474273
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
474274
|
+
value2.includes("\0") || (id = value2);
|
|
474275
|
+
return;
|
|
474276
|
+
}
|
|
474277
|
+
if (firstCharCode === 58) {
|
|
474278
|
+
if (onComment) {
|
|
474279
|
+
const line2 = chunk.slice(start, end);
|
|
474280
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
474281
|
+
}
|
|
474282
|
+
return;
|
|
474283
|
+
}
|
|
474284
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
474285
|
+
if (fieldSeparatorIndex === -1) {
|
|
474286
|
+
processField(line, "", line);
|
|
474287
|
+
return;
|
|
474288
|
+
}
|
|
474289
|
+
const field = line.slice(0, fieldSeparatorIndex), offset2 = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset2);
|
|
474290
|
+
processField(field, value, line);
|
|
474291
|
+
}
|
|
474292
|
+
function processField(field, value, line) {
|
|
474293
|
+
switch (field) {
|
|
474294
|
+
case "event":
|
|
474295
|
+
eventType = value || void 0;
|
|
474296
|
+
break;
|
|
474297
|
+
case "data":
|
|
474298
|
+
data2 = dataLines === 0 ? value : `${data2}
|
|
474299
|
+
${value}`, dataLines++;
|
|
474300
|
+
break;
|
|
474301
|
+
case "id":
|
|
474302
|
+
value.includes("\0") || (id = value);
|
|
474303
|
+
break;
|
|
474304
|
+
case "retry":
|
|
474305
|
+
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
474306
|
+
new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
474307
|
+
type: "invalid-retry",
|
|
474308
|
+
value,
|
|
474309
|
+
line
|
|
474310
|
+
})
|
|
474311
|
+
);
|
|
474312
|
+
break;
|
|
474313
|
+
default:
|
|
474314
|
+
onError(
|
|
474315
|
+
new ParseError(
|
|
474316
|
+
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
474317
|
+
{ type: "unknown-field", field, value, line }
|
|
474318
|
+
)
|
|
474319
|
+
);
|
|
474320
|
+
break;
|
|
474321
|
+
}
|
|
474322
|
+
}
|
|
474323
|
+
function dispatchEvent() {
|
|
474324
|
+
dataLines > 0 && onEvent({
|
|
474325
|
+
id,
|
|
474326
|
+
event: eventType,
|
|
474327
|
+
data: data2
|
|
474328
|
+
}), id = void 0, data2 = "", dataLines = 0, eventType = void 0;
|
|
474329
|
+
}
|
|
474330
|
+
function reset2(options = {}) {
|
|
474331
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
474332
|
+
const incompleteLine = pendingFragments.join("");
|
|
474333
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
474334
|
+
}
|
|
474335
|
+
isFirstChunk = true, id = void 0, data2 = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
|
|
474336
|
+
}
|
|
474337
|
+
return { feed, reset: reset2 };
|
|
474338
|
+
}
|
|
474339
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
474340
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
474341
|
+
}
|
|
474342
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
474343
|
+
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
474344
|
+
}
|
|
474345
|
+
var ParseError, LF, CR, SPACE;
|
|
474346
|
+
var init_dist2 = __esm({
|
|
474347
|
+
"node_modules/eventsource-parser/dist/index.js"() {
|
|
474348
|
+
ParseError = class extends Error {
|
|
474349
|
+
constructor(message, options) {
|
|
474350
|
+
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
474351
|
+
}
|
|
474352
|
+
};
|
|
474353
|
+
LF = 10;
|
|
474354
|
+
CR = 13;
|
|
474355
|
+
SPACE = 32;
|
|
474356
|
+
}
|
|
474357
|
+
});
|
|
474358
|
+
|
|
474359
|
+
// node_modules/eventsource-parser/dist/stream.js
|
|
474360
|
+
var EventSourceParserStream;
|
|
474361
|
+
var init_stream = __esm({
|
|
474362
|
+
"node_modules/eventsource-parser/dist/stream.js"() {
|
|
474363
|
+
init_dist2();
|
|
474364
|
+
EventSourceParserStream = class extends TransformStream {
|
|
474365
|
+
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
474366
|
+
let parser;
|
|
474367
|
+
super({
|
|
474368
|
+
start(controller) {
|
|
474369
|
+
parser = createParser({
|
|
474370
|
+
onEvent: (event) => {
|
|
474371
|
+
controller.enqueue(event);
|
|
474372
|
+
},
|
|
474373
|
+
onError(error40) {
|
|
474374
|
+
typeof onError == "function" && onError(error40), (onError === "terminate" || error40.type === "max-buffer-size-exceeded") && controller.error(error40);
|
|
474375
|
+
},
|
|
474376
|
+
onRetry,
|
|
474377
|
+
onComment,
|
|
474378
|
+
maxBufferSize
|
|
474379
|
+
});
|
|
474380
|
+
},
|
|
474381
|
+
transform(chunk) {
|
|
474382
|
+
parser.feed(chunk);
|
|
474383
|
+
}
|
|
474384
|
+
});
|
|
474385
|
+
}
|
|
474386
|
+
};
|
|
474387
|
+
}
|
|
474388
|
+
});
|
|
474389
|
+
|
|
474178
474390
|
// node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
474179
474391
|
function combineHeaders(...headers) {
|
|
474180
474392
|
return headers.reduce(
|
|
@@ -474188,6 +474400,11 @@ function combineHeaders(...headers) {
|
|
|
474188
474400
|
function extractResponseHeaders(response) {
|
|
474189
474401
|
return Object.fromEntries([...response.headers]);
|
|
474190
474402
|
}
|
|
474403
|
+
function convertBase64ToUint8Array(base64String) {
|
|
474404
|
+
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
474405
|
+
const latin1string = atob2(base64Url);
|
|
474406
|
+
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
|
474407
|
+
}
|
|
474191
474408
|
function convertUint8ArrayToBase64(array2) {
|
|
474192
474409
|
let latin1string = "";
|
|
474193
474410
|
for (let i = 0; i < array2.length; i++) {
|
|
@@ -474198,6 +474415,28 @@ function convertUint8ArrayToBase64(array2) {
|
|
|
474198
474415
|
function convertToBase64(value) {
|
|
474199
474416
|
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
|
474200
474417
|
}
|
|
474418
|
+
function convertToFormData(input, options = {}) {
|
|
474419
|
+
const { useArrayBrackets = true } = options;
|
|
474420
|
+
const formData = new FormData();
|
|
474421
|
+
for (const [key, value] of Object.entries(input)) {
|
|
474422
|
+
if (value == null) {
|
|
474423
|
+
continue;
|
|
474424
|
+
}
|
|
474425
|
+
if (Array.isArray(value)) {
|
|
474426
|
+
if (value.length === 1) {
|
|
474427
|
+
formData.append(key, value[0]);
|
|
474428
|
+
continue;
|
|
474429
|
+
}
|
|
474430
|
+
const arrayKey = useArrayBrackets ? `${key}[]` : key;
|
|
474431
|
+
for (const item of value) {
|
|
474432
|
+
formData.append(arrayKey, item);
|
|
474433
|
+
}
|
|
474434
|
+
continue;
|
|
474435
|
+
}
|
|
474436
|
+
formData.append(key, value);
|
|
474437
|
+
}
|
|
474438
|
+
return formData;
|
|
474439
|
+
}
|
|
474201
474440
|
async function cancelResponseBody(response) {
|
|
474202
474441
|
var _a22;
|
|
474203
474442
|
try {
|
|
@@ -474205,6 +474444,202 @@ async function cancelResponseBody(response) {
|
|
|
474205
474444
|
} catch (e) {
|
|
474206
474445
|
}
|
|
474207
474446
|
}
|
|
474447
|
+
function isBrowserRuntime(globalThisAny = globalThis) {
|
|
474448
|
+
return globalThisAny.window != null;
|
|
474449
|
+
}
|
|
474450
|
+
function validateDownloadUrl(url2) {
|
|
474451
|
+
let parsed;
|
|
474452
|
+
try {
|
|
474453
|
+
parsed = new URL(url2);
|
|
474454
|
+
} catch (e) {
|
|
474455
|
+
throw new DownloadError({
|
|
474456
|
+
url: url2,
|
|
474457
|
+
message: `Invalid URL: ${url2}`
|
|
474458
|
+
});
|
|
474459
|
+
}
|
|
474460
|
+
if (parsed.protocol === "data:") {
|
|
474461
|
+
return;
|
|
474462
|
+
}
|
|
474463
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
474464
|
+
throw new DownloadError({
|
|
474465
|
+
url: url2,
|
|
474466
|
+
message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
|
|
474467
|
+
});
|
|
474468
|
+
}
|
|
474469
|
+
const hostname2 = parsed.hostname.toLowerCase().replace(/\.+$/, "");
|
|
474470
|
+
if (!hostname2) {
|
|
474471
|
+
throw new DownloadError({
|
|
474472
|
+
url: url2,
|
|
474473
|
+
message: `URL must have a hostname`
|
|
474474
|
+
});
|
|
474475
|
+
}
|
|
474476
|
+
if (hostname2 === "localhost" || hostname2.endsWith(".local") || hostname2.endsWith(".localhost")) {
|
|
474477
|
+
throw new DownloadError({
|
|
474478
|
+
url: url2,
|
|
474479
|
+
message: `URL with hostname ${hostname2} is not allowed`
|
|
474480
|
+
});
|
|
474481
|
+
}
|
|
474482
|
+
if (hostname2.startsWith("[") && hostname2.endsWith("]")) {
|
|
474483
|
+
const ipv63 = hostname2.slice(1, -1);
|
|
474484
|
+
if (isPrivateIPv6(ipv63)) {
|
|
474485
|
+
throw new DownloadError({
|
|
474486
|
+
url: url2,
|
|
474487
|
+
message: `URL with IPv6 address ${hostname2} is not allowed`
|
|
474488
|
+
});
|
|
474489
|
+
}
|
|
474490
|
+
return;
|
|
474491
|
+
}
|
|
474492
|
+
if (isIPv4(hostname2)) {
|
|
474493
|
+
if (isPrivateIPv4(hostname2)) {
|
|
474494
|
+
throw new DownloadError({
|
|
474495
|
+
url: url2,
|
|
474496
|
+
message: `URL with IP address ${hostname2} is not allowed`
|
|
474497
|
+
});
|
|
474498
|
+
}
|
|
474499
|
+
return;
|
|
474500
|
+
}
|
|
474501
|
+
}
|
|
474502
|
+
function validateDownloadAddress({
|
|
474503
|
+
address,
|
|
474504
|
+
family,
|
|
474505
|
+
hostname: hostname2
|
|
474506
|
+
}) {
|
|
474507
|
+
const isUnsafe = family === 4 ? !isIPv4(address) || isPrivateIPv4(address) : family === 6 ? isPrivateIPv6(address) : true;
|
|
474508
|
+
if (isUnsafe) {
|
|
474509
|
+
throw new DownloadError({
|
|
474510
|
+
url: hostname2,
|
|
474511
|
+
message: `Hostname ${hostname2} resolved to disallowed IP address ${address}`
|
|
474512
|
+
});
|
|
474513
|
+
}
|
|
474514
|
+
}
|
|
474515
|
+
function isIPv4(hostname2) {
|
|
474516
|
+
const parts = hostname2.split(".");
|
|
474517
|
+
if (parts.length !== 4) return false;
|
|
474518
|
+
return parts.every((part) => {
|
|
474519
|
+
const num = Number(part);
|
|
474520
|
+
return Number.isInteger(num) && num >= 0 && num <= 255 && String(num) === part;
|
|
474521
|
+
});
|
|
474522
|
+
}
|
|
474523
|
+
function isPrivateIPv4(ip) {
|
|
474524
|
+
const parts = ip.split(".").map(Number);
|
|
474525
|
+
const [a, b, c] = parts;
|
|
474526
|
+
if (a === 0) return true;
|
|
474527
|
+
if (a === 10) return true;
|
|
474528
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
474529
|
+
if (a === 127) return true;
|
|
474530
|
+
if (a === 169 && b === 254) return true;
|
|
474531
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
474532
|
+
if (a === 192 && b === 0 && c === 0) return true;
|
|
474533
|
+
if (a === 192 && b === 168) return true;
|
|
474534
|
+
if (a === 198 && (b === 18 || b === 19)) return true;
|
|
474535
|
+
if (a >= 240) return true;
|
|
474536
|
+
return false;
|
|
474537
|
+
}
|
|
474538
|
+
function parseIPv6(ip) {
|
|
474539
|
+
let address = ip.toLowerCase();
|
|
474540
|
+
const zoneIndex = address.indexOf("%");
|
|
474541
|
+
if (zoneIndex !== -1) {
|
|
474542
|
+
address = address.slice(0, zoneIndex);
|
|
474543
|
+
}
|
|
474544
|
+
const halves = address.split("::");
|
|
474545
|
+
if (halves.length > 2) return null;
|
|
474546
|
+
const toGroups = (segment) => {
|
|
474547
|
+
if (segment === "") return [];
|
|
474548
|
+
const groups = [];
|
|
474549
|
+
const parts = segment.split(":");
|
|
474550
|
+
for (let i = 0; i < parts.length; i++) {
|
|
474551
|
+
const part = parts[i];
|
|
474552
|
+
if (part.includes(".")) {
|
|
474553
|
+
if (i !== parts.length - 1 || !isIPv4(part)) return null;
|
|
474554
|
+
const [a, b, c, d] = part.split(".").map(Number);
|
|
474555
|
+
groups.push(a << 8 | b, c << 8 | d);
|
|
474556
|
+
continue;
|
|
474557
|
+
}
|
|
474558
|
+
if (!/^[0-9a-f]{1,4}$/.test(part)) return null;
|
|
474559
|
+
groups.push(parseInt(part, 16));
|
|
474560
|
+
}
|
|
474561
|
+
return groups;
|
|
474562
|
+
};
|
|
474563
|
+
const head2 = toGroups(halves[0]);
|
|
474564
|
+
if (head2 === null) return null;
|
|
474565
|
+
if (halves.length === 2) {
|
|
474566
|
+
const tail = toGroups(halves[1]);
|
|
474567
|
+
if (tail === null) return null;
|
|
474568
|
+
const fill = 8 - head2.length - tail.length;
|
|
474569
|
+
if (fill < 0) return null;
|
|
474570
|
+
return [...head2, ...new Array(fill).fill(0), ...tail];
|
|
474571
|
+
}
|
|
474572
|
+
return head2.length === 8 ? head2 : null;
|
|
474573
|
+
}
|
|
474574
|
+
function isPrivateIPv6(ip) {
|
|
474575
|
+
const groups = parseIPv6(ip);
|
|
474576
|
+
if (groups === null) return true;
|
|
474577
|
+
const topZero = (count) => groups.slice(0, count).every((group) => group === 0);
|
|
474578
|
+
if (topZero(7) && (groups[7] === 0 || groups[7] === 1)) return true;
|
|
474579
|
+
if ((groups[0] & 65024) === 64512) return true;
|
|
474580
|
+
if ((groups[0] & 65472) === 65152) return true;
|
|
474581
|
+
if ((groups[0] & 65472) === 65216) return true;
|
|
474582
|
+
if ((groups[0] & 65280) === 65280) return true;
|
|
474583
|
+
const embedsIPv4 = (
|
|
474584
|
+
// ::/96 — IPv4-compatible (deprecated)
|
|
474585
|
+
topZero(6) || // ::ffff:0:0/96 — IPv4-mapped (ffff in group 5)
|
|
474586
|
+
topZero(5) && groups[5] === 65535 || // ::ffff:0:0/96 — IPv4-translated form (ffff in group 4, group 5 zero)
|
|
474587
|
+
topZero(4) && groups[4] === 65535 && groups[5] === 0 || // 64:ff9b::/96 — NAT64 well-known prefix
|
|
474588
|
+
groups[0] === 100 && groups[1] === 65435 && groups[2] === 0 && groups[3] === 0 && groups[4] === 0 && groups[5] === 0 || // 64:ff9b:1::/48 — NAT64 local-use prefix
|
|
474589
|
+
groups[0] === 100 && groups[1] === 65435 && groups[2] === 1
|
|
474590
|
+
);
|
|
474591
|
+
if (embedsIPv4) {
|
|
474592
|
+
const a = groups[6] >> 8 & 255;
|
|
474593
|
+
const b = groups[6] & 255;
|
|
474594
|
+
const c = groups[7] >> 8 & 255;
|
|
474595
|
+
const d = groups[7] & 255;
|
|
474596
|
+
return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
|
|
474597
|
+
}
|
|
474598
|
+
return false;
|
|
474599
|
+
}
|
|
474600
|
+
function createSafeLookup(lookup) {
|
|
474601
|
+
return ((hostname2, options, callback) => {
|
|
474602
|
+
lookup(hostname2, { ...options, all: true }, (error40, addresses) => {
|
|
474603
|
+
if (error40) {
|
|
474604
|
+
callback(error40);
|
|
474605
|
+
return;
|
|
474606
|
+
}
|
|
474607
|
+
try {
|
|
474608
|
+
const [firstAddress] = addresses;
|
|
474609
|
+
if (firstAddress == null) {
|
|
474610
|
+
throw new Error(`Hostname ${hostname2} did not resolve to an address`);
|
|
474611
|
+
}
|
|
474612
|
+
for (const { address, family } of addresses) {
|
|
474613
|
+
validateDownloadAddress({ address, family, hostname: hostname2 });
|
|
474614
|
+
}
|
|
474615
|
+
if (options.all === true) {
|
|
474616
|
+
callback(null, addresses);
|
|
474617
|
+
} else {
|
|
474618
|
+
callback(
|
|
474619
|
+
null,
|
|
474620
|
+
firstAddress.address,
|
|
474621
|
+
firstAddress.family
|
|
474622
|
+
);
|
|
474623
|
+
}
|
|
474624
|
+
} catch (error210) {
|
|
474625
|
+
callback(
|
|
474626
|
+
error210 instanceof Error ? error210 : new Error(String(error210))
|
|
474627
|
+
);
|
|
474628
|
+
}
|
|
474629
|
+
});
|
|
474630
|
+
});
|
|
474631
|
+
}
|
|
474632
|
+
function isNodeRuntime() {
|
|
474633
|
+
var _a22, _b22;
|
|
474634
|
+
const runtimeProcess = globalThis.process;
|
|
474635
|
+
return ((_a22 = runtimeProcess == null ? void 0 : runtimeProcess.release) == null ? void 0 : _a22.name) === "node" && ((_b22 = runtimeProcess.versions) == null ? void 0 : _b22.bun) == null;
|
|
474636
|
+
}
|
|
474637
|
+
async function getDefaultDownloadFetch() {
|
|
474638
|
+
if (!isNodeRuntime() || !initialGlobalFetchIsNodeDefault || globalThis.fetch !== initialGlobalFetch) {
|
|
474639
|
+
return globalThis.fetch;
|
|
474640
|
+
}
|
|
474641
|
+
return safeNodeFetchPromise != null ? safeNodeFetchPromise : safeNodeFetchPromise = createSafeNodeFetch();
|
|
474642
|
+
}
|
|
474208
474643
|
function isNodeDefaultFetch(fetch2) {
|
|
474209
474644
|
if (typeof fetch2 !== "function") {
|
|
474210
474645
|
return false;
|
|
@@ -474212,6 +474647,92 @@ function isNodeDefaultFetch(fetch2) {
|
|
|
474212
474647
|
const source = Function.prototype.toString.call(fetch2);
|
|
474213
474648
|
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
474214
474649
|
}
|
|
474650
|
+
async function createSafeNodeFetch() {
|
|
474651
|
+
const [{ createRequire: createRequire2 }, { lookup }] = await Promise.all([
|
|
474652
|
+
loadNodeModule("node:module"),
|
|
474653
|
+
loadNodeModule("node:dns")
|
|
474654
|
+
]);
|
|
474655
|
+
const { Agent, fetch: fetch2 } = createRequire2(getCurrentModulePath())(
|
|
474656
|
+
"undici"
|
|
474657
|
+
);
|
|
474658
|
+
const dispatcher = new Agent({
|
|
474659
|
+
connect: {
|
|
474660
|
+
lookup: createSafeLookup(lookup)
|
|
474661
|
+
}
|
|
474662
|
+
});
|
|
474663
|
+
return ((input, init) => fetch2(
|
|
474664
|
+
input,
|
|
474665
|
+
{
|
|
474666
|
+
...init,
|
|
474667
|
+
dispatcher
|
|
474668
|
+
}
|
|
474669
|
+
));
|
|
474670
|
+
}
|
|
474671
|
+
async function loadNodeModule(id) {
|
|
474672
|
+
var _a22;
|
|
474673
|
+
const processWithBuiltins = globalThis.process;
|
|
474674
|
+
const builtinModule = (_a22 = processWithBuiltins == null ? void 0 : processWithBuiltins.getBuiltinModule) == null ? void 0 : _a22.call(processWithBuiltins, id);
|
|
474675
|
+
if (builtinModule == null) {
|
|
474676
|
+
throw new Error(`Node.js built-in module ${id} is unavailable`);
|
|
474677
|
+
}
|
|
474678
|
+
return builtinModule;
|
|
474679
|
+
}
|
|
474680
|
+
function getCurrentModulePath() {
|
|
474681
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
474682
|
+
try {
|
|
474683
|
+
Error.prepareStackTrace = (_error, callSites) => callSites;
|
|
474684
|
+
const error40 = new Error("Capture current module path");
|
|
474685
|
+
Error.captureStackTrace(error40, getCurrentModulePath);
|
|
474686
|
+
const [caller] = error40.stack;
|
|
474687
|
+
const fileName = caller == null ? void 0 : caller.getFileName();
|
|
474688
|
+
if (fileName == null) {
|
|
474689
|
+
throw new Error("Unable to determine the current module path");
|
|
474690
|
+
}
|
|
474691
|
+
return fileName;
|
|
474692
|
+
} finally {
|
|
474693
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
474694
|
+
}
|
|
474695
|
+
}
|
|
474696
|
+
async function fetchWithValidatedRedirects({
|
|
474697
|
+
url: url2,
|
|
474698
|
+
headers,
|
|
474699
|
+
abortSignal,
|
|
474700
|
+
maxRedirects = MAX_DOWNLOAD_REDIRECTS
|
|
474701
|
+
}) {
|
|
474702
|
+
const baseInit = { signal: abortSignal };
|
|
474703
|
+
if (headers !== void 0) {
|
|
474704
|
+
baseInit.headers = headers;
|
|
474705
|
+
}
|
|
474706
|
+
let currentUrl = url2;
|
|
474707
|
+
for (let redirectCount = 0; redirectCount <= maxRedirects; redirectCount++) {
|
|
474708
|
+
validateDownloadUrl(currentUrl);
|
|
474709
|
+
const fetch2 = await getDefaultDownloadFetch();
|
|
474710
|
+
const response = await fetch2(currentUrl, {
|
|
474711
|
+
...baseInit,
|
|
474712
|
+
redirect: "manual"
|
|
474713
|
+
});
|
|
474714
|
+
if (response.type === "opaqueredirect") {
|
|
474715
|
+
if (!isBrowserRuntime()) {
|
|
474716
|
+
throw new DownloadError({
|
|
474717
|
+
url: url2,
|
|
474718
|
+
message: `Redirect from ${currentUrl} could not be validated and was blocked`
|
|
474719
|
+
});
|
|
474720
|
+
}
|
|
474721
|
+
return await fetch2(currentUrl, { ...baseInit, redirect: "follow" });
|
|
474722
|
+
}
|
|
474723
|
+
const location = response.headers.get("location");
|
|
474724
|
+
if (response.status >= 300 && response.status < 400 && location) {
|
|
474725
|
+
await cancelResponseBody(response);
|
|
474726
|
+
currentUrl = new URL(location, currentUrl).toString();
|
|
474727
|
+
continue;
|
|
474728
|
+
}
|
|
474729
|
+
return response;
|
|
474730
|
+
}
|
|
474731
|
+
throw new DownloadError({
|
|
474732
|
+
url: url2,
|
|
474733
|
+
message: `Too many redirects (max ${maxRedirects})`
|
|
474734
|
+
});
|
|
474735
|
+
}
|
|
474215
474736
|
async function readResponseWithSizeLimit({
|
|
474216
474737
|
response,
|
|
474217
474738
|
url: url2,
|
|
@@ -474266,6 +474787,35 @@ async function readResponseWithSizeLimit({
|
|
|
474266
474787
|
}
|
|
474267
474788
|
return result;
|
|
474268
474789
|
}
|
|
474790
|
+
async function downloadBlob(url2, options) {
|
|
474791
|
+
var _a22, _b22;
|
|
474792
|
+
try {
|
|
474793
|
+
const response = await fetchWithValidatedRedirects({
|
|
474794
|
+
url: url2,
|
|
474795
|
+
abortSignal: options == null ? void 0 : options.abortSignal
|
|
474796
|
+
});
|
|
474797
|
+
if (!response.ok) {
|
|
474798
|
+
await cancelResponseBody(response);
|
|
474799
|
+
throw new DownloadError({
|
|
474800
|
+
url: url2,
|
|
474801
|
+
statusCode: response.status,
|
|
474802
|
+
statusText: response.statusText
|
|
474803
|
+
});
|
|
474804
|
+
}
|
|
474805
|
+
const data2 = await readResponseWithSizeLimit({
|
|
474806
|
+
response,
|
|
474807
|
+
url: url2,
|
|
474808
|
+
maxBytes: (_a22 = options == null ? void 0 : options.maxBytes) != null ? _a22 : DEFAULT_MAX_DOWNLOAD_SIZE
|
|
474809
|
+
});
|
|
474810
|
+
const contentType = (_b22 = response.headers.get("content-type")) != null ? _b22 : void 0;
|
|
474811
|
+
return new Blob([data2], contentType ? { type: contentType } : void 0);
|
|
474812
|
+
} catch (error40) {
|
|
474813
|
+
if (DownloadError.isInstance(error40)) {
|
|
474814
|
+
throw error40;
|
|
474815
|
+
}
|
|
474816
|
+
throw new DownloadError({ url: url2, cause: error40 });
|
|
474817
|
+
}
|
|
474818
|
+
}
|
|
474269
474819
|
function isAbortError(error40) {
|
|
474270
474820
|
return (error40 instanceof Error || error40 instanceof DOMException) && (error40.name === "AbortError" || error40.name === "ResponseAborted" || // Next.js
|
|
474271
474821
|
error40.name === "TimeoutError");
|
|
@@ -475485,6 +476035,21 @@ async function safeParseJSON({
|
|
|
475485
476035
|
};
|
|
475486
476036
|
}
|
|
475487
476037
|
}
|
|
476038
|
+
function parseJsonEventStream({
|
|
476039
|
+
stream: stream2,
|
|
476040
|
+
schema
|
|
476041
|
+
}) {
|
|
476042
|
+
return stream2.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(
|
|
476043
|
+
new TransformStream({
|
|
476044
|
+
async transform({ data: data2 }, controller) {
|
|
476045
|
+
if (data2 === "[DONE]") {
|
|
476046
|
+
return;
|
|
476047
|
+
}
|
|
476048
|
+
controller.enqueue(await safeParseJSON({ text: data2, schema }));
|
|
476049
|
+
}
|
|
476050
|
+
})
|
|
476051
|
+
);
|
|
476052
|
+
}
|
|
475488
476053
|
async function parseProviderOptions({
|
|
475489
476054
|
provider,
|
|
475490
476055
|
providerOptions,
|
|
@@ -475512,6 +476077,62 @@ async function resolve(value) {
|
|
|
475512
476077
|
}
|
|
475513
476078
|
return Promise.resolve(value);
|
|
475514
476079
|
}
|
|
476080
|
+
function wrapResponseBodyStream({
|
|
476081
|
+
stream: stream2,
|
|
476082
|
+
url: url2,
|
|
476083
|
+
requestBodyValues,
|
|
476084
|
+
statusCode,
|
|
476085
|
+
responseHeaders
|
|
476086
|
+
}) {
|
|
476087
|
+
const reader = stream2.getReader();
|
|
476088
|
+
let readerReleased = false;
|
|
476089
|
+
const releaseReader = () => {
|
|
476090
|
+
if (!readerReleased) {
|
|
476091
|
+
reader.releaseLock();
|
|
476092
|
+
readerReleased = true;
|
|
476093
|
+
}
|
|
476094
|
+
};
|
|
476095
|
+
return new ReadableStream({
|
|
476096
|
+
async pull(controller) {
|
|
476097
|
+
try {
|
|
476098
|
+
const { done, value } = await reader.read();
|
|
476099
|
+
if (done) {
|
|
476100
|
+
releaseReader();
|
|
476101
|
+
controller.close();
|
|
476102
|
+
} else {
|
|
476103
|
+
controller.enqueue(value);
|
|
476104
|
+
}
|
|
476105
|
+
} catch (error40) {
|
|
476106
|
+
releaseReader();
|
|
476107
|
+
if (isAbortError(error40)) {
|
|
476108
|
+
controller.error(error40);
|
|
476109
|
+
return;
|
|
476110
|
+
}
|
|
476111
|
+
controller.error(
|
|
476112
|
+
handleFetchError({
|
|
476113
|
+
error: new APICallError({
|
|
476114
|
+
message: "Failed to process successful response",
|
|
476115
|
+
cause: error40,
|
|
476116
|
+
statusCode,
|
|
476117
|
+
url: url2,
|
|
476118
|
+
responseHeaders,
|
|
476119
|
+
requestBodyValues
|
|
476120
|
+
}),
|
|
476121
|
+
url: url2,
|
|
476122
|
+
requestBodyValues
|
|
476123
|
+
})
|
|
476124
|
+
);
|
|
476125
|
+
}
|
|
476126
|
+
},
|
|
476127
|
+
async cancel(reason) {
|
|
476128
|
+
try {
|
|
476129
|
+
await reader.cancel(reason);
|
|
476130
|
+
} finally {
|
|
476131
|
+
releaseReader();
|
|
476132
|
+
}
|
|
476133
|
+
}
|
|
476134
|
+
});
|
|
476135
|
+
}
|
|
475515
476136
|
async function readResponseBodyAsText({
|
|
475516
476137
|
response,
|
|
475517
476138
|
url: url2
|
|
@@ -475530,8 +476151,8 @@ function stripFileExtension(filename) {
|
|
|
475530
476151
|
function withoutTrailingSlash(url2) {
|
|
475531
476152
|
return url2 == null ? void 0 : url2.replace(/\/$/, "");
|
|
475532
476153
|
}
|
|
475533
|
-
var btoa2, atob2, name14, marker15, symbol16, _a15, _b15, DownloadError, initialGlobalFetch, initialGlobalFetchIsNodeDefault, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator, generateId, FETCH_FAILED_ERROR_MESSAGES, RETRYABLE_NETWORK_ERROR_CODES, VERSION, DEFAULT_SCHEMA_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_GENERIC_SUFFIX, suspectProtoRx, suspectConstructorRx, ignoreOverride, defaultOptions, getDefaultOptions, parseCatchDef, integerDateParser, isJsonSchema7AllOfType, emojiRegex2, zodPatterns, ALPHA_NUMERIC, primitiveMappings, asAnyOf, parseOptionalDef, parsePipelineDef, parseReadonlyDef, selectParser, getRelativePath, get$ref, addMeta, getRefs, zod3ToJsonSchema, schemaSymbol, getOriginalFetch2, postJsonToApi, postToApi, textDecoder, createJsonErrorResponseHandler, createJsonResponseHandler;
|
|
475534
|
-
var
|
|
476154
|
+
var btoa2, atob2, name14, marker15, symbol16, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault, MAX_DOWNLOAD_REDIRECTS, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator, generateId, FETCH_FAILED_ERROR_MESSAGES, RETRYABLE_NETWORK_ERROR_CODES, VERSION, DEFAULT_SCHEMA_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_GENERIC_SUFFIX, suspectProtoRx, suspectConstructorRx, ignoreOverride, defaultOptions, getDefaultOptions, parseCatchDef, integerDateParser, isJsonSchema7AllOfType, emojiRegex2, zodPatterns, ALPHA_NUMERIC, primitiveMappings, asAnyOf, parseOptionalDef, parsePipelineDef, parseReadonlyDef, selectParser, getRelativePath, get$ref, addMeta, getRefs, zod3ToJsonSchema, schemaSymbol, getOriginalFetch2, postJsonToApi, postFormDataToApi, postToApi, textDecoder, createJsonErrorResponseHandler, createEventSourceResponseHandler, createJsonResponseHandler;
|
|
476155
|
+
var init_dist3 = __esm({
|
|
475535
476156
|
"node_modules/@ai-sdk/provider-utils/dist/index.mjs"() {
|
|
475536
476157
|
init_dist();
|
|
475537
476158
|
init_dist();
|
|
@@ -475544,6 +476165,7 @@ var init_dist2 = __esm({
|
|
|
475544
476165
|
init_v3();
|
|
475545
476166
|
init_v3();
|
|
475546
476167
|
init_v3();
|
|
476168
|
+
init_stream();
|
|
475547
476169
|
init_dist();
|
|
475548
476170
|
init_dist();
|
|
475549
476171
|
init_dist();
|
|
@@ -475571,6 +476193,7 @@ var init_dist2 = __esm({
|
|
|
475571
476193
|
};
|
|
475572
476194
|
initialGlobalFetch = globalThis.fetch;
|
|
475573
476195
|
initialGlobalFetchIsNodeDefault = isNodeDefaultFetch(initialGlobalFetch);
|
|
476196
|
+
MAX_DOWNLOAD_REDIRECTS = 10;
|
|
475574
476197
|
DEFAULT_MAX_DOWNLOAD_SIZE = 2 * 1024 * 1024 * 1024;
|
|
475575
476198
|
createIdGenerator = ({
|
|
475576
476199
|
prefix,
|
|
@@ -475979,6 +476602,26 @@ var init_dist2 = __esm({
|
|
|
475979
476602
|
abortSignal,
|
|
475980
476603
|
fetch: fetch2
|
|
475981
476604
|
});
|
|
476605
|
+
postFormDataToApi = async ({
|
|
476606
|
+
url: url2,
|
|
476607
|
+
headers,
|
|
476608
|
+
formData,
|
|
476609
|
+
failedResponseHandler,
|
|
476610
|
+
successfulResponseHandler,
|
|
476611
|
+
abortSignal,
|
|
476612
|
+
fetch: fetch2
|
|
476613
|
+
}) => postToApi({
|
|
476614
|
+
url: url2,
|
|
476615
|
+
headers,
|
|
476616
|
+
body: {
|
|
476617
|
+
content: formData,
|
|
476618
|
+
values: Object.fromEntries(formData.entries())
|
|
476619
|
+
},
|
|
476620
|
+
failedResponseHandler,
|
|
476621
|
+
successfulResponseHandler,
|
|
476622
|
+
abortSignal,
|
|
476623
|
+
fetch: fetch2
|
|
476624
|
+
});
|
|
475982
476625
|
postToApi = async ({
|
|
475983
476626
|
url: url2,
|
|
475984
476627
|
headers = {},
|
|
@@ -476103,6 +476746,25 @@ var init_dist2 = __esm({
|
|
|
476103
476746
|
};
|
|
476104
476747
|
}
|
|
476105
476748
|
};
|
|
476749
|
+
createEventSourceResponseHandler = (chunkSchema) => async ({ response, url: url2, requestBodyValues }) => {
|
|
476750
|
+
const responseHeaders = extractResponseHeaders(response);
|
|
476751
|
+
if (response.body == null) {
|
|
476752
|
+
throw new EmptyResponseBodyError({});
|
|
476753
|
+
}
|
|
476754
|
+
return {
|
|
476755
|
+
responseHeaders,
|
|
476756
|
+
value: parseJsonEventStream({
|
|
476757
|
+
stream: wrapResponseBodyStream({
|
|
476758
|
+
stream: response.body,
|
|
476759
|
+
url: url2,
|
|
476760
|
+
requestBodyValues,
|
|
476761
|
+
statusCode: response.status,
|
|
476762
|
+
responseHeaders
|
|
476763
|
+
}),
|
|
476764
|
+
schema: chunkSchema
|
|
476765
|
+
})
|
|
476766
|
+
};
|
|
476767
|
+
};
|
|
476106
476768
|
createJsonResponseHandler = (responseSchema) => async ({ response, url: url2, requestBodyValues }) => {
|
|
476107
476769
|
const responseBody = await readResponseBodyAsText({ response, url: url2 });
|
|
476108
476770
|
const parsedResult = await safeParseJSON({
|
|
@@ -476130,6 +476792,1758 @@ var init_dist2 = __esm({
|
|
|
476130
476792
|
}
|
|
476131
476793
|
});
|
|
476132
476794
|
|
|
476795
|
+
// node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
476796
|
+
function toCamelCase(str) {
|
|
476797
|
+
return str.replace(/[_-]([a-z])/g, (g) => g[1].toUpperCase());
|
|
476798
|
+
}
|
|
476799
|
+
function resolveProviderOptionsKey(rawName, providerOptions) {
|
|
476800
|
+
const camelName = toCamelCase(rawName);
|
|
476801
|
+
if (camelName !== rawName && (providerOptions == null ? void 0 : providerOptions[camelName]) != null) {
|
|
476802
|
+
return camelName;
|
|
476803
|
+
}
|
|
476804
|
+
return rawName;
|
|
476805
|
+
}
|
|
476806
|
+
function convertOpenAICompatibleChatUsage(usage) {
|
|
476807
|
+
var _a17, _b16, _c, _d, _e, _f;
|
|
476808
|
+
if (usage == null) {
|
|
476809
|
+
return {
|
|
476810
|
+
inputTokens: {
|
|
476811
|
+
total: void 0,
|
|
476812
|
+
noCache: void 0,
|
|
476813
|
+
cacheRead: void 0,
|
|
476814
|
+
cacheWrite: void 0
|
|
476815
|
+
},
|
|
476816
|
+
outputTokens: {
|
|
476817
|
+
total: void 0,
|
|
476818
|
+
text: void 0,
|
|
476819
|
+
reasoning: void 0
|
|
476820
|
+
},
|
|
476821
|
+
raw: void 0
|
|
476822
|
+
};
|
|
476823
|
+
}
|
|
476824
|
+
const promptTokens = (_a17 = usage.prompt_tokens) != null ? _a17 : 0;
|
|
476825
|
+
const completionTokens = (_b16 = usage.completion_tokens) != null ? _b16 : 0;
|
|
476826
|
+
const cacheReadTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
|
|
476827
|
+
const reasoningTokens = (_f = (_e = usage.completion_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
|
|
476828
|
+
return {
|
|
476829
|
+
inputTokens: {
|
|
476830
|
+
total: promptTokens,
|
|
476831
|
+
noCache: promptTokens - cacheReadTokens,
|
|
476832
|
+
cacheRead: cacheReadTokens,
|
|
476833
|
+
cacheWrite: void 0
|
|
476834
|
+
},
|
|
476835
|
+
outputTokens: {
|
|
476836
|
+
total: completionTokens,
|
|
476837
|
+
text: Math.max(0, completionTokens - reasoningTokens),
|
|
476838
|
+
reasoning: reasoningTokens
|
|
476839
|
+
},
|
|
476840
|
+
raw: usage
|
|
476841
|
+
};
|
|
476842
|
+
}
|
|
476843
|
+
function getOpenAIMetadata(message) {
|
|
476844
|
+
var _a17, _b16;
|
|
476845
|
+
return (_b16 = (_a17 = message == null ? void 0 : message.providerOptions) == null ? void 0 : _a17.openaiCompatible) != null ? _b16 : {};
|
|
476846
|
+
}
|
|
476847
|
+
function getAudioFormat(mediaType) {
|
|
476848
|
+
switch (mediaType) {
|
|
476849
|
+
case "audio/wav":
|
|
476850
|
+
return "wav";
|
|
476851
|
+
case "audio/mp3":
|
|
476852
|
+
case "audio/mpeg":
|
|
476853
|
+
return "mp3";
|
|
476854
|
+
default:
|
|
476855
|
+
return null;
|
|
476856
|
+
}
|
|
476857
|
+
}
|
|
476858
|
+
function convertToOpenAICompatibleChatMessages(prompt) {
|
|
476859
|
+
var _a17, _b16, _c;
|
|
476860
|
+
const messages = [];
|
|
476861
|
+
for (const { role, content, ...message } of prompt) {
|
|
476862
|
+
const metadata = getOpenAIMetadata({ ...message });
|
|
476863
|
+
switch (role) {
|
|
476864
|
+
case "system": {
|
|
476865
|
+
messages.push({ role: "system", content, ...metadata });
|
|
476866
|
+
break;
|
|
476867
|
+
}
|
|
476868
|
+
case "user": {
|
|
476869
|
+
if (content.length === 1 && content[0].type === "text") {
|
|
476870
|
+
messages.push({
|
|
476871
|
+
role: "user",
|
|
476872
|
+
content: content[0].text,
|
|
476873
|
+
...getOpenAIMetadata(content[0])
|
|
476874
|
+
});
|
|
476875
|
+
break;
|
|
476876
|
+
}
|
|
476877
|
+
messages.push({
|
|
476878
|
+
role: "user",
|
|
476879
|
+
content: content.map((part) => {
|
|
476880
|
+
var _a22;
|
|
476881
|
+
const partMetadata = getOpenAIMetadata(part);
|
|
476882
|
+
switch (part.type) {
|
|
476883
|
+
case "text": {
|
|
476884
|
+
return { type: "text", text: part.text, ...partMetadata };
|
|
476885
|
+
}
|
|
476886
|
+
case "file": {
|
|
476887
|
+
if (part.mediaType.startsWith("image/")) {
|
|
476888
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
476889
|
+
return {
|
|
476890
|
+
type: "image_url",
|
|
476891
|
+
image_url: {
|
|
476892
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`
|
|
476893
|
+
},
|
|
476894
|
+
...partMetadata
|
|
476895
|
+
};
|
|
476896
|
+
}
|
|
476897
|
+
if (part.mediaType.startsWith("audio/")) {
|
|
476898
|
+
if (part.data instanceof URL) {
|
|
476899
|
+
throw new UnsupportedFunctionalityError({
|
|
476900
|
+
functionality: "audio file parts with URLs"
|
|
476901
|
+
});
|
|
476902
|
+
}
|
|
476903
|
+
const format2 = getAudioFormat(part.mediaType);
|
|
476904
|
+
if (format2 === null) {
|
|
476905
|
+
throw new UnsupportedFunctionalityError({
|
|
476906
|
+
functionality: `audio media type ${part.mediaType}`
|
|
476907
|
+
});
|
|
476908
|
+
}
|
|
476909
|
+
return {
|
|
476910
|
+
type: "input_audio",
|
|
476911
|
+
input_audio: {
|
|
476912
|
+
data: convertToBase64(part.data),
|
|
476913
|
+
format: format2
|
|
476914
|
+
},
|
|
476915
|
+
...partMetadata
|
|
476916
|
+
};
|
|
476917
|
+
}
|
|
476918
|
+
if (part.mediaType === "application/pdf") {
|
|
476919
|
+
if (part.data instanceof URL) {
|
|
476920
|
+
throw new UnsupportedFunctionalityError({
|
|
476921
|
+
functionality: "PDF file parts with URLs"
|
|
476922
|
+
});
|
|
476923
|
+
}
|
|
476924
|
+
return {
|
|
476925
|
+
type: "file",
|
|
476926
|
+
file: {
|
|
476927
|
+
filename: (_a22 = part.filename) != null ? _a22 : "document.pdf",
|
|
476928
|
+
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
|
|
476929
|
+
},
|
|
476930
|
+
...partMetadata
|
|
476931
|
+
};
|
|
476932
|
+
}
|
|
476933
|
+
if (part.mediaType.startsWith("text/")) {
|
|
476934
|
+
const textContent = part.data instanceof URL ? part.data.toString() : typeof part.data === "string" ? new TextDecoder().decode(
|
|
476935
|
+
convertBase64ToUint8Array(part.data)
|
|
476936
|
+
) : new TextDecoder().decode(part.data);
|
|
476937
|
+
return {
|
|
476938
|
+
type: "text",
|
|
476939
|
+
text: textContent,
|
|
476940
|
+
...partMetadata
|
|
476941
|
+
};
|
|
476942
|
+
}
|
|
476943
|
+
throw new UnsupportedFunctionalityError({
|
|
476944
|
+
functionality: `file part media type ${part.mediaType}`
|
|
476945
|
+
});
|
|
476946
|
+
}
|
|
476947
|
+
}
|
|
476948
|
+
}),
|
|
476949
|
+
...metadata
|
|
476950
|
+
});
|
|
476951
|
+
break;
|
|
476952
|
+
}
|
|
476953
|
+
case "assistant": {
|
|
476954
|
+
let text = "";
|
|
476955
|
+
let reasoning = "";
|
|
476956
|
+
const toolCalls = [];
|
|
476957
|
+
for (const part of content) {
|
|
476958
|
+
const partMetadata = getOpenAIMetadata(part);
|
|
476959
|
+
switch (part.type) {
|
|
476960
|
+
case "text": {
|
|
476961
|
+
text += part.text;
|
|
476962
|
+
break;
|
|
476963
|
+
}
|
|
476964
|
+
case "reasoning": {
|
|
476965
|
+
reasoning += part.text;
|
|
476966
|
+
break;
|
|
476967
|
+
}
|
|
476968
|
+
case "tool-call": {
|
|
476969
|
+
const thoughtSignature = (_b16 = (_a17 = part.providerOptions) == null ? void 0 : _a17.google) == null ? void 0 : _b16.thoughtSignature;
|
|
476970
|
+
toolCalls.push({
|
|
476971
|
+
id: part.toolCallId,
|
|
476972
|
+
type: "function",
|
|
476973
|
+
function: {
|
|
476974
|
+
name: part.toolName,
|
|
476975
|
+
arguments: JSON.stringify(part.input)
|
|
476976
|
+
},
|
|
476977
|
+
...partMetadata,
|
|
476978
|
+
// Include extra_content for Google Gemini thought signatures
|
|
476979
|
+
...thoughtSignature ? {
|
|
476980
|
+
extra_content: {
|
|
476981
|
+
google: {
|
|
476982
|
+
thought_signature: String(thoughtSignature)
|
|
476983
|
+
}
|
|
476984
|
+
}
|
|
476985
|
+
} : {}
|
|
476986
|
+
});
|
|
476987
|
+
break;
|
|
476988
|
+
}
|
|
476989
|
+
}
|
|
476990
|
+
}
|
|
476991
|
+
messages.push({
|
|
476992
|
+
role: "assistant",
|
|
476993
|
+
content: toolCalls.length > 0 ? text || null : text,
|
|
476994
|
+
...reasoning.length > 0 ? { reasoning_content: reasoning } : {},
|
|
476995
|
+
tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
476996
|
+
...metadata
|
|
476997
|
+
});
|
|
476998
|
+
break;
|
|
476999
|
+
}
|
|
477000
|
+
case "tool": {
|
|
477001
|
+
for (const toolResponse of content) {
|
|
477002
|
+
if (toolResponse.type === "tool-approval-response") {
|
|
477003
|
+
continue;
|
|
477004
|
+
}
|
|
477005
|
+
const output = toolResponse.output;
|
|
477006
|
+
let contentValue;
|
|
477007
|
+
switch (output.type) {
|
|
477008
|
+
case "text":
|
|
477009
|
+
case "error-text":
|
|
477010
|
+
contentValue = output.value;
|
|
477011
|
+
break;
|
|
477012
|
+
case "execution-denied":
|
|
477013
|
+
contentValue = (_c = output.reason) != null ? _c : "Tool call execution denied.";
|
|
477014
|
+
break;
|
|
477015
|
+
case "content":
|
|
477016
|
+
case "json":
|
|
477017
|
+
case "error-json":
|
|
477018
|
+
contentValue = JSON.stringify(output.value);
|
|
477019
|
+
break;
|
|
477020
|
+
}
|
|
477021
|
+
const toolResponseMetadata = getOpenAIMetadata(toolResponse);
|
|
477022
|
+
messages.push({
|
|
477023
|
+
role: "tool",
|
|
477024
|
+
tool_call_id: toolResponse.toolCallId,
|
|
477025
|
+
content: contentValue,
|
|
477026
|
+
...toolResponseMetadata
|
|
477027
|
+
});
|
|
477028
|
+
}
|
|
477029
|
+
break;
|
|
477030
|
+
}
|
|
477031
|
+
default: {
|
|
477032
|
+
const _exhaustiveCheck = role;
|
|
477033
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
|
477034
|
+
}
|
|
477035
|
+
}
|
|
477036
|
+
}
|
|
477037
|
+
return messages;
|
|
477038
|
+
}
|
|
477039
|
+
function getResponseMetadata({
|
|
477040
|
+
id,
|
|
477041
|
+
model,
|
|
477042
|
+
created
|
|
477043
|
+
}) {
|
|
477044
|
+
return {
|
|
477045
|
+
id: id != null ? id : void 0,
|
|
477046
|
+
modelId: model != null ? model : void 0,
|
|
477047
|
+
timestamp: created != null ? new Date(created * 1e3) : void 0
|
|
477048
|
+
};
|
|
477049
|
+
}
|
|
477050
|
+
function mapOpenAICompatibleFinishReason(finishReason) {
|
|
477051
|
+
switch (finishReason) {
|
|
477052
|
+
case "stop":
|
|
477053
|
+
return "stop";
|
|
477054
|
+
case "length":
|
|
477055
|
+
return "length";
|
|
477056
|
+
case "content_filter":
|
|
477057
|
+
return "content-filter";
|
|
477058
|
+
case "function_call":
|
|
477059
|
+
case "tool_calls":
|
|
477060
|
+
return "tool-calls";
|
|
477061
|
+
default:
|
|
477062
|
+
return "other";
|
|
477063
|
+
}
|
|
477064
|
+
}
|
|
477065
|
+
function prepareTools({
|
|
477066
|
+
tools: tools2,
|
|
477067
|
+
toolChoice
|
|
477068
|
+
}) {
|
|
477069
|
+
tools2 = (tools2 == null ? void 0 : tools2.length) ? tools2 : void 0;
|
|
477070
|
+
const toolWarnings = [];
|
|
477071
|
+
if (tools2 == null) {
|
|
477072
|
+
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
477073
|
+
}
|
|
477074
|
+
const openaiCompatTools = [];
|
|
477075
|
+
for (const tool6 of tools2) {
|
|
477076
|
+
if (tool6.type === "provider") {
|
|
477077
|
+
toolWarnings.push({
|
|
477078
|
+
type: "unsupported",
|
|
477079
|
+
feature: `provider-defined tool ${tool6.id}`
|
|
477080
|
+
});
|
|
477081
|
+
} else {
|
|
477082
|
+
openaiCompatTools.push({
|
|
477083
|
+
type: "function",
|
|
477084
|
+
function: {
|
|
477085
|
+
name: tool6.name,
|
|
477086
|
+
description: tool6.description,
|
|
477087
|
+
parameters: tool6.inputSchema,
|
|
477088
|
+
...tool6.strict != null ? { strict: tool6.strict } : {}
|
|
477089
|
+
}
|
|
477090
|
+
});
|
|
477091
|
+
}
|
|
477092
|
+
}
|
|
477093
|
+
if (toolChoice == null) {
|
|
477094
|
+
return { tools: openaiCompatTools, toolChoice: void 0, toolWarnings };
|
|
477095
|
+
}
|
|
477096
|
+
const type = toolChoice.type;
|
|
477097
|
+
switch (type) {
|
|
477098
|
+
case "auto":
|
|
477099
|
+
case "none":
|
|
477100
|
+
case "required":
|
|
477101
|
+
return { tools: openaiCompatTools, toolChoice: type, toolWarnings };
|
|
477102
|
+
case "tool":
|
|
477103
|
+
return {
|
|
477104
|
+
tools: openaiCompatTools,
|
|
477105
|
+
toolChoice: {
|
|
477106
|
+
type: "function",
|
|
477107
|
+
function: { name: toolChoice.toolName }
|
|
477108
|
+
},
|
|
477109
|
+
toolWarnings
|
|
477110
|
+
};
|
|
477111
|
+
default: {
|
|
477112
|
+
const _exhaustiveCheck = type;
|
|
477113
|
+
throw new UnsupportedFunctionalityError({
|
|
477114
|
+
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
477115
|
+
});
|
|
477116
|
+
}
|
|
477117
|
+
}
|
|
477118
|
+
}
|
|
477119
|
+
function convertOpenAICompatibleContent(content) {
|
|
477120
|
+
if (content == null) {
|
|
477121
|
+
return [];
|
|
477122
|
+
}
|
|
477123
|
+
if (typeof content === "string") {
|
|
477124
|
+
return content.length > 0 ? [{ type: "text", text: content }] : [];
|
|
477125
|
+
}
|
|
477126
|
+
const result = [];
|
|
477127
|
+
for (const part of content) {
|
|
477128
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
477129
|
+
if (part.text.length > 0) {
|
|
477130
|
+
result.push({ type: "text", text: part.text });
|
|
477131
|
+
}
|
|
477132
|
+
} else if (part.type === "thinking" && Array.isArray(part.thinking)) {
|
|
477133
|
+
const reasoningText = part.thinking.filter(
|
|
477134
|
+
(chunk) => chunk != null && typeof chunk === "object" && "type" in chunk && chunk.type === "text" && "text" in chunk && typeof chunk.text === "string"
|
|
477135
|
+
).map((chunk) => chunk.text).join("");
|
|
477136
|
+
if (reasoningText.length > 0) {
|
|
477137
|
+
result.push({ type: "reasoning", text: reasoningText });
|
|
477138
|
+
}
|
|
477139
|
+
}
|
|
477140
|
+
}
|
|
477141
|
+
return result;
|
|
477142
|
+
}
|
|
477143
|
+
function convertOpenAICompatibleCompletionUsage(usage) {
|
|
477144
|
+
var _a17, _b16;
|
|
477145
|
+
if (usage == null) {
|
|
477146
|
+
return {
|
|
477147
|
+
inputTokens: {
|
|
477148
|
+
total: void 0,
|
|
477149
|
+
noCache: void 0,
|
|
477150
|
+
cacheRead: void 0,
|
|
477151
|
+
cacheWrite: void 0
|
|
477152
|
+
},
|
|
477153
|
+
outputTokens: {
|
|
477154
|
+
total: void 0,
|
|
477155
|
+
text: void 0,
|
|
477156
|
+
reasoning: void 0
|
|
477157
|
+
},
|
|
477158
|
+
raw: void 0
|
|
477159
|
+
};
|
|
477160
|
+
}
|
|
477161
|
+
const promptTokens = (_a17 = usage.prompt_tokens) != null ? _a17 : 0;
|
|
477162
|
+
const completionTokens = (_b16 = usage.completion_tokens) != null ? _b16 : 0;
|
|
477163
|
+
return {
|
|
477164
|
+
inputTokens: {
|
|
477165
|
+
total: promptTokens,
|
|
477166
|
+
noCache: promptTokens,
|
|
477167
|
+
cacheRead: void 0,
|
|
477168
|
+
cacheWrite: void 0
|
|
477169
|
+
},
|
|
477170
|
+
outputTokens: {
|
|
477171
|
+
total: completionTokens,
|
|
477172
|
+
text: completionTokens,
|
|
477173
|
+
reasoning: void 0
|
|
477174
|
+
},
|
|
477175
|
+
raw: usage
|
|
477176
|
+
};
|
|
477177
|
+
}
|
|
477178
|
+
function convertToOpenAICompatibleCompletionPrompt({
|
|
477179
|
+
prompt,
|
|
477180
|
+
user = "user",
|
|
477181
|
+
assistant = "assistant"
|
|
477182
|
+
}) {
|
|
477183
|
+
let text = "";
|
|
477184
|
+
if (prompt[0].role === "system") {
|
|
477185
|
+
text += `${prompt[0].content}
|
|
477186
|
+
|
|
477187
|
+
`;
|
|
477188
|
+
prompt = prompt.slice(1);
|
|
477189
|
+
}
|
|
477190
|
+
for (const { role, content } of prompt) {
|
|
477191
|
+
switch (role) {
|
|
477192
|
+
case "system": {
|
|
477193
|
+
throw new InvalidPromptError({
|
|
477194
|
+
message: "Unexpected system message in prompt: ${content}",
|
|
477195
|
+
prompt
|
|
477196
|
+
});
|
|
477197
|
+
}
|
|
477198
|
+
case "user": {
|
|
477199
|
+
const userMessage = content.map((part) => {
|
|
477200
|
+
switch (part.type) {
|
|
477201
|
+
case "text": {
|
|
477202
|
+
return part.text;
|
|
477203
|
+
}
|
|
477204
|
+
}
|
|
477205
|
+
}).filter(Boolean).join("");
|
|
477206
|
+
text += `${user}:
|
|
477207
|
+
${userMessage}
|
|
477208
|
+
|
|
477209
|
+
`;
|
|
477210
|
+
break;
|
|
477211
|
+
}
|
|
477212
|
+
case "assistant": {
|
|
477213
|
+
const assistantMessage = content.map((part) => {
|
|
477214
|
+
switch (part.type) {
|
|
477215
|
+
case "text": {
|
|
477216
|
+
return part.text;
|
|
477217
|
+
}
|
|
477218
|
+
case "tool-call": {
|
|
477219
|
+
throw new UnsupportedFunctionalityError({
|
|
477220
|
+
functionality: "tool-call messages"
|
|
477221
|
+
});
|
|
477222
|
+
}
|
|
477223
|
+
}
|
|
477224
|
+
}).join("");
|
|
477225
|
+
text += `${assistant}:
|
|
477226
|
+
${assistantMessage}
|
|
477227
|
+
|
|
477228
|
+
`;
|
|
477229
|
+
break;
|
|
477230
|
+
}
|
|
477231
|
+
case "tool": {
|
|
477232
|
+
throw new UnsupportedFunctionalityError({
|
|
477233
|
+
functionality: "tool messages"
|
|
477234
|
+
});
|
|
477235
|
+
}
|
|
477236
|
+
default: {
|
|
477237
|
+
const _exhaustiveCheck = role;
|
|
477238
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
|
477239
|
+
}
|
|
477240
|
+
}
|
|
477241
|
+
}
|
|
477242
|
+
text += `${assistant}:
|
|
477243
|
+
`;
|
|
477244
|
+
return {
|
|
477245
|
+
prompt: text,
|
|
477246
|
+
stopSequences: [`
|
|
477247
|
+
${user}:`]
|
|
477248
|
+
};
|
|
477249
|
+
}
|
|
477250
|
+
function getResponseMetadata2({
|
|
477251
|
+
id,
|
|
477252
|
+
model,
|
|
477253
|
+
created
|
|
477254
|
+
}) {
|
|
477255
|
+
return {
|
|
477256
|
+
id: id != null ? id : void 0,
|
|
477257
|
+
modelId: model != null ? model : void 0,
|
|
477258
|
+
timestamp: created != null ? new Date(created * 1e3) : void 0
|
|
477259
|
+
};
|
|
477260
|
+
}
|
|
477261
|
+
function mapOpenAICompatibleFinishReason2(finishReason) {
|
|
477262
|
+
switch (finishReason) {
|
|
477263
|
+
case "stop":
|
|
477264
|
+
return "stop";
|
|
477265
|
+
case "length":
|
|
477266
|
+
return "length";
|
|
477267
|
+
case "content_filter":
|
|
477268
|
+
return "content-filter";
|
|
477269
|
+
case "function_call":
|
|
477270
|
+
case "tool_calls":
|
|
477271
|
+
return "tool-calls";
|
|
477272
|
+
default:
|
|
477273
|
+
return "other";
|
|
477274
|
+
}
|
|
477275
|
+
}
|
|
477276
|
+
async function fileToBlob(file2) {
|
|
477277
|
+
if (file2.type === "url") {
|
|
477278
|
+
return downloadBlob(file2.url);
|
|
477279
|
+
}
|
|
477280
|
+
const data2 = file2.data instanceof Uint8Array ? file2.data : convertBase64ToUint8Array(file2.data);
|
|
477281
|
+
return new Blob([data2], { type: file2.mediaType });
|
|
477282
|
+
}
|
|
477283
|
+
function createOpenAICompatible(options) {
|
|
477284
|
+
const baseURL = withoutTrailingSlash(options.baseURL);
|
|
477285
|
+
const providerName = options.name;
|
|
477286
|
+
const headers = {
|
|
477287
|
+
...options.apiKey && { Authorization: `Bearer ${options.apiKey}` },
|
|
477288
|
+
...options.headers
|
|
477289
|
+
};
|
|
477290
|
+
const getHeaders = () => withUserAgentSuffix(headers, `ai-sdk/openai-compatible/${VERSION2}`);
|
|
477291
|
+
const getCommonModelConfig = (modelType) => ({
|
|
477292
|
+
provider: `${providerName}.${modelType}`,
|
|
477293
|
+
url: ({ path: path9 }) => {
|
|
477294
|
+
const url2 = new URL(`${baseURL}${path9}`);
|
|
477295
|
+
if (options.queryParams) {
|
|
477296
|
+
url2.search = new URLSearchParams(options.queryParams).toString();
|
|
477297
|
+
}
|
|
477298
|
+
return url2.toString();
|
|
477299
|
+
},
|
|
477300
|
+
headers: getHeaders,
|
|
477301
|
+
fetch: options.fetch
|
|
477302
|
+
});
|
|
477303
|
+
const createLanguageModel2 = (modelId) => createChatModel(modelId);
|
|
477304
|
+
const createChatModel = (modelId) => new OpenAICompatibleChatLanguageModel(modelId, {
|
|
477305
|
+
...getCommonModelConfig("chat"),
|
|
477306
|
+
includeUsage: options.includeUsage,
|
|
477307
|
+
supportsStructuredOutputs: options.supportsStructuredOutputs,
|
|
477308
|
+
supportedUrls: options.supportedUrls,
|
|
477309
|
+
transformRequestBody: options.transformRequestBody,
|
|
477310
|
+
metadataExtractor: options.metadataExtractor,
|
|
477311
|
+
convertUsage: options.convertUsage
|
|
477312
|
+
});
|
|
477313
|
+
const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(modelId, {
|
|
477314
|
+
...getCommonModelConfig("completion"),
|
|
477315
|
+
includeUsage: options.includeUsage
|
|
477316
|
+
});
|
|
477317
|
+
const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(modelId, {
|
|
477318
|
+
...getCommonModelConfig("embedding")
|
|
477319
|
+
});
|
|
477320
|
+
const createImageModel = (modelId) => new OpenAICompatibleImageModel(modelId, getCommonModelConfig("image"));
|
|
477321
|
+
const provider = (modelId) => createLanguageModel2(modelId);
|
|
477322
|
+
provider.specificationVersion = "v3";
|
|
477323
|
+
provider.languageModel = createLanguageModel2;
|
|
477324
|
+
provider.chatModel = createChatModel;
|
|
477325
|
+
provider.completionModel = createCompletionModel;
|
|
477326
|
+
provider.embeddingModel = createEmbeddingModel;
|
|
477327
|
+
provider.textEmbeddingModel = createEmbeddingModel;
|
|
477328
|
+
provider.imageModel = createImageModel;
|
|
477329
|
+
return provider;
|
|
477330
|
+
}
|
|
477331
|
+
var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, openaiCompatibleLanguageModelChatOptions, OpenAICompatibleChatLanguageModel, openaiCompatibleTokenUsageSchema, openAICompatibleContentSchema, OpenAICompatibleChatResponseSchema, chunkBaseSchema, createOpenAICompatibleChatChunkSchema, openaiCompatibleLanguageModelCompletionOptions, OpenAICompatibleCompletionLanguageModel, usageSchema, openaiCompatibleCompletionResponseSchema, createOpenAICompatibleCompletionChunkSchema, openaiCompatibleEmbeddingModelOptions, OpenAICompatibleEmbeddingModel, openaiTextEmbeddingResponseSchema, OpenAICompatibleImageModel, openaiCompatibleImageResponseSchema, VERSION2;
|
|
477332
|
+
var init_dist4 = __esm({
|
|
477333
|
+
"node_modules/@ai-sdk/openai-compatible/dist/index.mjs"() {
|
|
477334
|
+
init_dist();
|
|
477335
|
+
init_dist3();
|
|
477336
|
+
init_v4();
|
|
477337
|
+
init_v4();
|
|
477338
|
+
init_dist();
|
|
477339
|
+
init_dist3();
|
|
477340
|
+
init_v4();
|
|
477341
|
+
init_dist();
|
|
477342
|
+
init_dist3();
|
|
477343
|
+
init_v4();
|
|
477344
|
+
init_dist();
|
|
477345
|
+
init_v4();
|
|
477346
|
+
init_dist();
|
|
477347
|
+
init_dist3();
|
|
477348
|
+
init_v4();
|
|
477349
|
+
init_v4();
|
|
477350
|
+
init_dist3();
|
|
477351
|
+
init_v4();
|
|
477352
|
+
init_dist3();
|
|
477353
|
+
openaiCompatibleErrorDataSchema = external_exports.object({
|
|
477354
|
+
error: external_exports.object({
|
|
477355
|
+
message: external_exports.string(),
|
|
477356
|
+
// The additional information below is handled loosely to support
|
|
477357
|
+
// OpenAI-compatible providers that have slightly different error
|
|
477358
|
+
// responses:
|
|
477359
|
+
type: external_exports.string().nullish(),
|
|
477360
|
+
param: external_exports.any().nullish(),
|
|
477361
|
+
code: external_exports.union([external_exports.string(), external_exports.number()]).nullish()
|
|
477362
|
+
})
|
|
477363
|
+
});
|
|
477364
|
+
defaultOpenAICompatibleErrorStructure = {
|
|
477365
|
+
errorSchema: openaiCompatibleErrorDataSchema,
|
|
477366
|
+
errorToMessage: (data2) => data2.error.message
|
|
477367
|
+
};
|
|
477368
|
+
openaiCompatibleLanguageModelChatOptions = external_exports.object({
|
|
477369
|
+
/**
|
|
477370
|
+
* A unique identifier representing your end-user, which can help the provider to
|
|
477371
|
+
* monitor and detect abuse.
|
|
477372
|
+
*/
|
|
477373
|
+
user: external_exports.string().optional(),
|
|
477374
|
+
/**
|
|
477375
|
+
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
477376
|
+
*/
|
|
477377
|
+
reasoningEffort: external_exports.string().optional(),
|
|
477378
|
+
/**
|
|
477379
|
+
* Controls the verbosity of the generated text. Defaults to `medium`.
|
|
477380
|
+
*/
|
|
477381
|
+
textVerbosity: external_exports.string().optional(),
|
|
477382
|
+
/**
|
|
477383
|
+
* Whether to use strict JSON schema validation.
|
|
477384
|
+
* When true, the model uses constrained decoding to guarantee schema compliance.
|
|
477385
|
+
* Only used when the provider supports structured outputs and a schema is provided.
|
|
477386
|
+
*
|
|
477387
|
+
* @default true
|
|
477388
|
+
*/
|
|
477389
|
+
strictJsonSchema: external_exports.boolean().optional()
|
|
477390
|
+
});
|
|
477391
|
+
OpenAICompatibleChatLanguageModel = class {
|
|
477392
|
+
// type inferred via constructor
|
|
477393
|
+
constructor(modelId, config2) {
|
|
477394
|
+
this.specificationVersion = "v3";
|
|
477395
|
+
var _a17, _b16;
|
|
477396
|
+
this.modelId = modelId;
|
|
477397
|
+
this.config = config2;
|
|
477398
|
+
const errorStructure = (_a17 = config2.errorStructure) != null ? _a17 : defaultOpenAICompatibleErrorStructure;
|
|
477399
|
+
this.chunkSchema = createOpenAICompatibleChatChunkSchema(
|
|
477400
|
+
errorStructure.errorSchema
|
|
477401
|
+
);
|
|
477402
|
+
this.failedResponseHandler = createJsonErrorResponseHandler(errorStructure);
|
|
477403
|
+
this.supportsStructuredOutputs = (_b16 = config2.supportsStructuredOutputs) != null ? _b16 : false;
|
|
477404
|
+
}
|
|
477405
|
+
get provider() {
|
|
477406
|
+
return this.config.provider;
|
|
477407
|
+
}
|
|
477408
|
+
get providerOptionsName() {
|
|
477409
|
+
return this.config.provider.split(".")[0].trim();
|
|
477410
|
+
}
|
|
477411
|
+
get supportedUrls() {
|
|
477412
|
+
var _a17, _b16, _c;
|
|
477413
|
+
return (_c = (_b16 = (_a17 = this.config).supportedUrls) == null ? void 0 : _b16.call(_a17)) != null ? _c : {};
|
|
477414
|
+
}
|
|
477415
|
+
transformRequestBody(args) {
|
|
477416
|
+
var _a17, _b16, _c;
|
|
477417
|
+
return (_c = (_b16 = (_a17 = this.config).transformRequestBody) == null ? void 0 : _b16.call(_a17, args)) != null ? _c : args;
|
|
477418
|
+
}
|
|
477419
|
+
convertUsage(usage) {
|
|
477420
|
+
var _a17, _b16, _c;
|
|
477421
|
+
return (_c = (_b16 = (_a17 = this.config).convertUsage) == null ? void 0 : _b16.call(_a17, usage)) != null ? _c : convertOpenAICompatibleChatUsage(usage);
|
|
477422
|
+
}
|
|
477423
|
+
async getArgs({
|
|
477424
|
+
prompt,
|
|
477425
|
+
maxOutputTokens,
|
|
477426
|
+
temperature,
|
|
477427
|
+
topP,
|
|
477428
|
+
topK,
|
|
477429
|
+
frequencyPenalty,
|
|
477430
|
+
presencePenalty,
|
|
477431
|
+
providerOptions,
|
|
477432
|
+
stopSequences,
|
|
477433
|
+
responseFormat,
|
|
477434
|
+
seed,
|
|
477435
|
+
toolChoice,
|
|
477436
|
+
tools: tools2
|
|
477437
|
+
}) {
|
|
477438
|
+
var _a17, _b16, _c, _d, _e;
|
|
477439
|
+
const warnings = [];
|
|
477440
|
+
const deprecatedOptions = await parseProviderOptions({
|
|
477441
|
+
provider: "openai-compatible",
|
|
477442
|
+
providerOptions,
|
|
477443
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
477444
|
+
});
|
|
477445
|
+
if (deprecatedOptions != null) {
|
|
477446
|
+
warnings.push({
|
|
477447
|
+
type: "other",
|
|
477448
|
+
message: `The 'openai-compatible' key in providerOptions is deprecated. Use 'openaiCompatible' instead.`
|
|
477449
|
+
});
|
|
477450
|
+
}
|
|
477451
|
+
const compatibleOptions = Object.assign(
|
|
477452
|
+
deprecatedOptions != null ? deprecatedOptions : {},
|
|
477453
|
+
(_a17 = await parseProviderOptions({
|
|
477454
|
+
provider: "openaiCompatible",
|
|
477455
|
+
providerOptions,
|
|
477456
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
477457
|
+
})) != null ? _a17 : {},
|
|
477458
|
+
(_b16 = await parseProviderOptions({
|
|
477459
|
+
provider: this.providerOptionsName,
|
|
477460
|
+
providerOptions,
|
|
477461
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
477462
|
+
})) != null ? _b16 : {},
|
|
477463
|
+
(_c = await parseProviderOptions({
|
|
477464
|
+
provider: toCamelCase(this.providerOptionsName),
|
|
477465
|
+
providerOptions,
|
|
477466
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
477467
|
+
})) != null ? _c : {}
|
|
477468
|
+
);
|
|
477469
|
+
const strictJsonSchema = (_d = compatibleOptions == null ? void 0 : compatibleOptions.strictJsonSchema) != null ? _d : true;
|
|
477470
|
+
if (topK != null) {
|
|
477471
|
+
warnings.push({ type: "unsupported", feature: "topK" });
|
|
477472
|
+
}
|
|
477473
|
+
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !this.supportsStructuredOutputs) {
|
|
477474
|
+
warnings.push({
|
|
477475
|
+
type: "unsupported",
|
|
477476
|
+
feature: "responseFormat",
|
|
477477
|
+
details: "JSON response format schema is only supported with structuredOutputs"
|
|
477478
|
+
});
|
|
477479
|
+
}
|
|
477480
|
+
const {
|
|
477481
|
+
tools: openaiTools,
|
|
477482
|
+
toolChoice: openaiToolChoice,
|
|
477483
|
+
toolWarnings
|
|
477484
|
+
} = prepareTools({
|
|
477485
|
+
tools: tools2,
|
|
477486
|
+
toolChoice
|
|
477487
|
+
});
|
|
477488
|
+
const metadataKey = resolveProviderOptionsKey(
|
|
477489
|
+
this.providerOptionsName,
|
|
477490
|
+
providerOptions
|
|
477491
|
+
);
|
|
477492
|
+
return {
|
|
477493
|
+
metadataKey,
|
|
477494
|
+
args: {
|
|
477495
|
+
// model id:
|
|
477496
|
+
model: this.modelId,
|
|
477497
|
+
// model specific settings:
|
|
477498
|
+
user: compatibleOptions.user,
|
|
477499
|
+
// standardized settings:
|
|
477500
|
+
max_tokens: maxOutputTokens,
|
|
477501
|
+
temperature,
|
|
477502
|
+
top_p: topP,
|
|
477503
|
+
frequency_penalty: frequencyPenalty,
|
|
477504
|
+
presence_penalty: presencePenalty,
|
|
477505
|
+
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? this.supportsStructuredOutputs === true && responseFormat.schema != null ? {
|
|
477506
|
+
type: "json_schema",
|
|
477507
|
+
json_schema: {
|
|
477508
|
+
schema: responseFormat.schema,
|
|
477509
|
+
strict: strictJsonSchema,
|
|
477510
|
+
name: (_e = responseFormat.name) != null ? _e : "response",
|
|
477511
|
+
description: responseFormat.description
|
|
477512
|
+
}
|
|
477513
|
+
} : { type: "json_object" } : void 0,
|
|
477514
|
+
stop: stopSequences,
|
|
477515
|
+
seed,
|
|
477516
|
+
...Object.fromEntries(
|
|
477517
|
+
Object.entries({
|
|
477518
|
+
...providerOptions == null ? void 0 : providerOptions[this.providerOptionsName],
|
|
477519
|
+
...providerOptions == null ? void 0 : providerOptions[toCamelCase(this.providerOptionsName)]
|
|
477520
|
+
}).filter(
|
|
477521
|
+
([key]) => !Object.keys(
|
|
477522
|
+
openaiCompatibleLanguageModelChatOptions.shape
|
|
477523
|
+
).includes(key)
|
|
477524
|
+
)
|
|
477525
|
+
),
|
|
477526
|
+
reasoning_effort: compatibleOptions.reasoningEffort,
|
|
477527
|
+
verbosity: compatibleOptions.textVerbosity,
|
|
477528
|
+
// messages:
|
|
477529
|
+
messages: convertToOpenAICompatibleChatMessages(prompt),
|
|
477530
|
+
// tools:
|
|
477531
|
+
tools: openaiTools,
|
|
477532
|
+
tool_choice: openaiToolChoice
|
|
477533
|
+
},
|
|
477534
|
+
warnings: [...warnings, ...toolWarnings]
|
|
477535
|
+
};
|
|
477536
|
+
}
|
|
477537
|
+
async doGenerate(options) {
|
|
477538
|
+
var _a17, _b16, _c, _d, _e, _f, _g, _h;
|
|
477539
|
+
const { args, warnings, metadataKey } = await this.getArgs({ ...options });
|
|
477540
|
+
const transformedBody = this.transformRequestBody(args);
|
|
477541
|
+
const body = JSON.stringify(transformedBody);
|
|
477542
|
+
const {
|
|
477543
|
+
responseHeaders,
|
|
477544
|
+
value: responseBody,
|
|
477545
|
+
rawValue: rawResponse
|
|
477546
|
+
} = await postJsonToApi({
|
|
477547
|
+
url: this.config.url({
|
|
477548
|
+
path: "/chat/completions",
|
|
477549
|
+
modelId: this.modelId
|
|
477550
|
+
}),
|
|
477551
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
477552
|
+
body: transformedBody,
|
|
477553
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
477554
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
477555
|
+
OpenAICompatibleChatResponseSchema
|
|
477556
|
+
),
|
|
477557
|
+
abortSignal: options.abortSignal,
|
|
477558
|
+
fetch: this.config.fetch
|
|
477559
|
+
});
|
|
477560
|
+
const choice = responseBody.choices[0];
|
|
477561
|
+
const content = [];
|
|
477562
|
+
content.push(...convertOpenAICompatibleContent(choice.message.content));
|
|
477563
|
+
const reasoning = (_a17 = choice.message.reasoning_content) != null ? _a17 : choice.message.reasoning;
|
|
477564
|
+
if (reasoning != null && reasoning.length > 0) {
|
|
477565
|
+
content.push({
|
|
477566
|
+
type: "reasoning",
|
|
477567
|
+
text: reasoning
|
|
477568
|
+
});
|
|
477569
|
+
}
|
|
477570
|
+
if (choice.message.tool_calls != null) {
|
|
477571
|
+
for (const toolCall of choice.message.tool_calls) {
|
|
477572
|
+
const thoughtSignature = (_c = (_b16 = toolCall.extra_content) == null ? void 0 : _b16.google) == null ? void 0 : _c.thought_signature;
|
|
477573
|
+
content.push({
|
|
477574
|
+
type: "tool-call",
|
|
477575
|
+
toolCallId: (_d = toolCall.id) != null ? _d : generateId(),
|
|
477576
|
+
toolName: toolCall.function.name,
|
|
477577
|
+
input: toolCall.function.arguments,
|
|
477578
|
+
...thoughtSignature ? {
|
|
477579
|
+
providerMetadata: {
|
|
477580
|
+
[metadataKey]: { thoughtSignature }
|
|
477581
|
+
}
|
|
477582
|
+
} : {}
|
|
477583
|
+
});
|
|
477584
|
+
}
|
|
477585
|
+
}
|
|
477586
|
+
const providerMetadata = {
|
|
477587
|
+
[metadataKey]: {},
|
|
477588
|
+
...await ((_f = (_e = this.config.metadataExtractor) == null ? void 0 : _e.extractMetadata) == null ? void 0 : _f.call(_e, {
|
|
477589
|
+
parsedBody: rawResponse
|
|
477590
|
+
}))
|
|
477591
|
+
};
|
|
477592
|
+
const completionTokenDetails = (_g = responseBody.usage) == null ? void 0 : _g.completion_tokens_details;
|
|
477593
|
+
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
477594
|
+
providerMetadata[metadataKey].acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
477595
|
+
}
|
|
477596
|
+
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
477597
|
+
providerMetadata[metadataKey].rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
|
|
477598
|
+
}
|
|
477599
|
+
return {
|
|
477600
|
+
content,
|
|
477601
|
+
finishReason: {
|
|
477602
|
+
unified: mapOpenAICompatibleFinishReason(choice.finish_reason),
|
|
477603
|
+
raw: (_h = choice.finish_reason) != null ? _h : void 0
|
|
477604
|
+
},
|
|
477605
|
+
usage: this.convertUsage(responseBody.usage),
|
|
477606
|
+
providerMetadata,
|
|
477607
|
+
request: { body },
|
|
477608
|
+
response: {
|
|
477609
|
+
...getResponseMetadata(responseBody),
|
|
477610
|
+
headers: responseHeaders,
|
|
477611
|
+
body: rawResponse
|
|
477612
|
+
},
|
|
477613
|
+
warnings
|
|
477614
|
+
};
|
|
477615
|
+
}
|
|
477616
|
+
async doStream(options) {
|
|
477617
|
+
var _a17;
|
|
477618
|
+
const { args, warnings, metadataKey } = await this.getArgs({ ...options });
|
|
477619
|
+
const body = this.transformRequestBody({
|
|
477620
|
+
...args,
|
|
477621
|
+
stream: true,
|
|
477622
|
+
// only include stream_options when in strict compatibility mode:
|
|
477623
|
+
stream_options: this.config.includeUsage ? { include_usage: true } : void 0
|
|
477624
|
+
});
|
|
477625
|
+
const metadataExtractor = (_a17 = this.config.metadataExtractor) == null ? void 0 : _a17.createStreamExtractor();
|
|
477626
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
477627
|
+
url: this.config.url({
|
|
477628
|
+
path: "/chat/completions",
|
|
477629
|
+
modelId: this.modelId
|
|
477630
|
+
}),
|
|
477631
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
477632
|
+
body,
|
|
477633
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
477634
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
477635
|
+
this.chunkSchema
|
|
477636
|
+
),
|
|
477637
|
+
abortSignal: options.abortSignal,
|
|
477638
|
+
fetch: this.config.fetch
|
|
477639
|
+
});
|
|
477640
|
+
const toolCalls = [];
|
|
477641
|
+
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
477642
|
+
let finishReason;
|
|
477643
|
+
let usage = void 0;
|
|
477644
|
+
let isFirstChunk = true;
|
|
477645
|
+
const providerOptionsName = metadataKey;
|
|
477646
|
+
let isActiveReasoning = false;
|
|
477647
|
+
let isActiveText = false;
|
|
477648
|
+
const convertUsage = (usage2) => this.convertUsage(usage2);
|
|
477649
|
+
return {
|
|
477650
|
+
stream: response.pipeThrough(
|
|
477651
|
+
new TransformStream({
|
|
477652
|
+
start(controller) {
|
|
477653
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
477654
|
+
},
|
|
477655
|
+
transform(chunk, controller) {
|
|
477656
|
+
var _a22, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
477657
|
+
if (options.includeRawChunks) {
|
|
477658
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
477659
|
+
}
|
|
477660
|
+
if (!chunk.success) {
|
|
477661
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
477662
|
+
controller.enqueue({ type: "error", error: chunk.error });
|
|
477663
|
+
return;
|
|
477664
|
+
}
|
|
477665
|
+
metadataExtractor == null ? void 0 : metadataExtractor.processChunk(chunk.rawValue);
|
|
477666
|
+
if ("error" in chunk.value) {
|
|
477667
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
477668
|
+
controller.enqueue({
|
|
477669
|
+
type: "error",
|
|
477670
|
+
error: chunk.value.error
|
|
477671
|
+
});
|
|
477672
|
+
return;
|
|
477673
|
+
}
|
|
477674
|
+
const value = chunk.value;
|
|
477675
|
+
if (isFirstChunk) {
|
|
477676
|
+
isFirstChunk = false;
|
|
477677
|
+
controller.enqueue({
|
|
477678
|
+
type: "response-metadata",
|
|
477679
|
+
...getResponseMetadata(value)
|
|
477680
|
+
});
|
|
477681
|
+
}
|
|
477682
|
+
if (value.usage != null) {
|
|
477683
|
+
usage = value.usage;
|
|
477684
|
+
}
|
|
477685
|
+
const choice = value.choices[0];
|
|
477686
|
+
if ((choice == null ? void 0 : choice.finish_reason) != null) {
|
|
477687
|
+
finishReason = {
|
|
477688
|
+
unified: mapOpenAICompatibleFinishReason(choice.finish_reason),
|
|
477689
|
+
raw: (_a22 = choice.finish_reason) != null ? _a22 : void 0
|
|
477690
|
+
};
|
|
477691
|
+
}
|
|
477692
|
+
if ((choice == null ? void 0 : choice.delta) == null) {
|
|
477693
|
+
return;
|
|
477694
|
+
}
|
|
477695
|
+
const delta = choice.delta;
|
|
477696
|
+
const enqueueReasoningDelta = (reasoningDelta) => {
|
|
477697
|
+
if (isActiveText) {
|
|
477698
|
+
controller.enqueue({ type: "text-end", id: "txt-0" });
|
|
477699
|
+
isActiveText = false;
|
|
477700
|
+
}
|
|
477701
|
+
if (!isActiveReasoning) {
|
|
477702
|
+
controller.enqueue({
|
|
477703
|
+
type: "reasoning-start",
|
|
477704
|
+
id: "reasoning-0"
|
|
477705
|
+
});
|
|
477706
|
+
isActiveReasoning = true;
|
|
477707
|
+
}
|
|
477708
|
+
controller.enqueue({
|
|
477709
|
+
type: "reasoning-delta",
|
|
477710
|
+
id: "reasoning-0",
|
|
477711
|
+
delta: reasoningDelta
|
|
477712
|
+
});
|
|
477713
|
+
};
|
|
477714
|
+
const enqueueTextDelta = (textDelta) => {
|
|
477715
|
+
if (isActiveReasoning) {
|
|
477716
|
+
controller.enqueue({
|
|
477717
|
+
type: "reasoning-end",
|
|
477718
|
+
id: "reasoning-0"
|
|
477719
|
+
});
|
|
477720
|
+
isActiveReasoning = false;
|
|
477721
|
+
}
|
|
477722
|
+
if (!isActiveText) {
|
|
477723
|
+
controller.enqueue({ type: "text-start", id: "txt-0" });
|
|
477724
|
+
isActiveText = true;
|
|
477725
|
+
}
|
|
477726
|
+
controller.enqueue({
|
|
477727
|
+
type: "text-delta",
|
|
477728
|
+
id: "txt-0",
|
|
477729
|
+
delta: textDelta
|
|
477730
|
+
});
|
|
477731
|
+
};
|
|
477732
|
+
const reasoningContent = (_b16 = delta.reasoning_content) != null ? _b16 : delta.reasoning;
|
|
477733
|
+
if (reasoningContent) {
|
|
477734
|
+
enqueueReasoningDelta(reasoningContent);
|
|
477735
|
+
}
|
|
477736
|
+
for (const contentPart of convertOpenAICompatibleContent(
|
|
477737
|
+
delta.content
|
|
477738
|
+
)) {
|
|
477739
|
+
if (contentPart.type === "reasoning") {
|
|
477740
|
+
enqueueReasoningDelta(contentPart.text);
|
|
477741
|
+
} else {
|
|
477742
|
+
enqueueTextDelta(contentPart.text);
|
|
477743
|
+
}
|
|
477744
|
+
}
|
|
477745
|
+
if (delta.tool_calls != null) {
|
|
477746
|
+
if (isActiveReasoning) {
|
|
477747
|
+
controller.enqueue({
|
|
477748
|
+
type: "reasoning-end",
|
|
477749
|
+
id: "reasoning-0"
|
|
477750
|
+
});
|
|
477751
|
+
isActiveReasoning = false;
|
|
477752
|
+
}
|
|
477753
|
+
for (const toolCallDelta of delta.tool_calls) {
|
|
477754
|
+
const index = (_c = toolCallDelta.index) != null ? _c : toolCalls.length;
|
|
477755
|
+
if (toolCalls[index] == null) {
|
|
477756
|
+
if (toolCallDelta.index != null) {
|
|
477757
|
+
let pending = pendingToolCalls.get(index);
|
|
477758
|
+
if (pending == null) {
|
|
477759
|
+
pending = {
|
|
477760
|
+
id: (_d = toolCallDelta.id) != null ? _d : null,
|
|
477761
|
+
bufferedArguments: "",
|
|
477762
|
+
thoughtSignature: (_g = (_f = (_e = toolCallDelta.extra_content) == null ? void 0 : _e.google) == null ? void 0 : _f.thought_signature) != null ? _g : void 0
|
|
477763
|
+
};
|
|
477764
|
+
pendingToolCalls.set(index, pending);
|
|
477765
|
+
} else {
|
|
477766
|
+
if (pending.id == null && toolCallDelta.id != null) {
|
|
477767
|
+
pending.id = toolCallDelta.id;
|
|
477768
|
+
}
|
|
477769
|
+
if (pending.thoughtSignature == null && ((_i = (_h = toolCallDelta.extra_content) == null ? void 0 : _h.google) == null ? void 0 : _i.thought_signature) != null) {
|
|
477770
|
+
pending.thoughtSignature = toolCallDelta.extra_content.google.thought_signature;
|
|
477771
|
+
}
|
|
477772
|
+
}
|
|
477773
|
+
const argumentsDelta = (_j = toolCallDelta.function) == null ? void 0 : _j.arguments;
|
|
477774
|
+
if (argumentsDelta != null) {
|
|
477775
|
+
pending.bufferedArguments += argumentsDelta;
|
|
477776
|
+
}
|
|
477777
|
+
const name15 = (_k = toolCallDelta.function) == null ? void 0 : _k.name;
|
|
477778
|
+
if (name15 == null) {
|
|
477779
|
+
continue;
|
|
477780
|
+
}
|
|
477781
|
+
pendingToolCalls.delete(index);
|
|
477782
|
+
if (pending.id == null) {
|
|
477783
|
+
throw new InvalidResponseDataError({
|
|
477784
|
+
data: toolCallDelta,
|
|
477785
|
+
message: `Expected 'id' to be a string.`
|
|
477786
|
+
});
|
|
477787
|
+
}
|
|
477788
|
+
controller.enqueue({
|
|
477789
|
+
type: "tool-input-start",
|
|
477790
|
+
id: pending.id,
|
|
477791
|
+
toolName: name15
|
|
477792
|
+
});
|
|
477793
|
+
toolCalls[index] = {
|
|
477794
|
+
id: pending.id,
|
|
477795
|
+
type: "function",
|
|
477796
|
+
function: {
|
|
477797
|
+
name: name15,
|
|
477798
|
+
arguments: pending.bufferedArguments
|
|
477799
|
+
},
|
|
477800
|
+
hasFinished: false,
|
|
477801
|
+
thoughtSignature: pending.thoughtSignature
|
|
477802
|
+
};
|
|
477803
|
+
} else {
|
|
477804
|
+
if (toolCallDelta.id == null) {
|
|
477805
|
+
throw new InvalidResponseDataError({
|
|
477806
|
+
data: toolCallDelta,
|
|
477807
|
+
message: `Expected 'id' to be a string.`
|
|
477808
|
+
});
|
|
477809
|
+
}
|
|
477810
|
+
if (((_l = toolCallDelta.function) == null ? void 0 : _l.name) == null) {
|
|
477811
|
+
throw new InvalidResponseDataError({
|
|
477812
|
+
data: toolCallDelta,
|
|
477813
|
+
message: `Expected 'function.name' to be a string.`
|
|
477814
|
+
});
|
|
477815
|
+
}
|
|
477816
|
+
controller.enqueue({
|
|
477817
|
+
type: "tool-input-start",
|
|
477818
|
+
id: toolCallDelta.id,
|
|
477819
|
+
toolName: toolCallDelta.function.name
|
|
477820
|
+
});
|
|
477821
|
+
toolCalls[index] = {
|
|
477822
|
+
id: toolCallDelta.id,
|
|
477823
|
+
type: "function",
|
|
477824
|
+
function: {
|
|
477825
|
+
name: toolCallDelta.function.name,
|
|
477826
|
+
arguments: (_m = toolCallDelta.function.arguments) != null ? _m : ""
|
|
477827
|
+
},
|
|
477828
|
+
hasFinished: false,
|
|
477829
|
+
thoughtSignature: (_p = (_o = (_n = toolCallDelta.extra_content) == null ? void 0 : _n.google) == null ? void 0 : _o.thought_signature) != null ? _p : void 0
|
|
477830
|
+
};
|
|
477831
|
+
}
|
|
477832
|
+
const toolCall2 = toolCalls[index];
|
|
477833
|
+
if (((_q = toolCall2.function) == null ? void 0 : _q.name) != null && ((_r = toolCall2.function) == null ? void 0 : _r.arguments) != null) {
|
|
477834
|
+
if (toolCall2.function.arguments.length > 0) {
|
|
477835
|
+
controller.enqueue({
|
|
477836
|
+
type: "tool-input-delta",
|
|
477837
|
+
id: toolCall2.id,
|
|
477838
|
+
delta: toolCall2.function.arguments
|
|
477839
|
+
});
|
|
477840
|
+
}
|
|
477841
|
+
}
|
|
477842
|
+
continue;
|
|
477843
|
+
}
|
|
477844
|
+
const toolCall = toolCalls[index];
|
|
477845
|
+
if (toolCall.hasFinished) {
|
|
477846
|
+
continue;
|
|
477847
|
+
}
|
|
477848
|
+
if (((_s = toolCallDelta.function) == null ? void 0 : _s.arguments) != null) {
|
|
477849
|
+
toolCall.function.arguments += (_u = (_t = toolCallDelta.function) == null ? void 0 : _t.arguments) != null ? _u : "";
|
|
477850
|
+
}
|
|
477851
|
+
controller.enqueue({
|
|
477852
|
+
type: "tool-input-delta",
|
|
477853
|
+
id: toolCall.id,
|
|
477854
|
+
delta: (_v = toolCallDelta.function.arguments) != null ? _v : ""
|
|
477855
|
+
});
|
|
477856
|
+
}
|
|
477857
|
+
}
|
|
477858
|
+
},
|
|
477859
|
+
flush(controller) {
|
|
477860
|
+
var _a22, _b16, _c, _d, _e;
|
|
477861
|
+
if (isActiveReasoning) {
|
|
477862
|
+
controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
|
|
477863
|
+
}
|
|
477864
|
+
if (isActiveText) {
|
|
477865
|
+
controller.enqueue({ type: "text-end", id: "txt-0" });
|
|
477866
|
+
}
|
|
477867
|
+
for (const [index, pending] of pendingToolCalls) {
|
|
477868
|
+
throw new InvalidResponseDataError({
|
|
477869
|
+
data: {
|
|
477870
|
+
index,
|
|
477871
|
+
id: pending.id,
|
|
477872
|
+
function: { arguments: pending.bufferedArguments }
|
|
477873
|
+
},
|
|
477874
|
+
message: `Expected 'function.name' to be a string.`
|
|
477875
|
+
});
|
|
477876
|
+
}
|
|
477877
|
+
for (const toolCall of toolCalls.filter(
|
|
477878
|
+
(toolCall2) => !toolCall2.hasFinished
|
|
477879
|
+
)) {
|
|
477880
|
+
controller.enqueue({
|
|
477881
|
+
type: "tool-input-end",
|
|
477882
|
+
id: toolCall.id
|
|
477883
|
+
});
|
|
477884
|
+
controller.enqueue({
|
|
477885
|
+
type: "tool-call",
|
|
477886
|
+
toolCallId: (_a22 = toolCall.id) != null ? _a22 : generateId(),
|
|
477887
|
+
toolName: toolCall.function.name,
|
|
477888
|
+
input: toolCall.function.arguments,
|
|
477889
|
+
...toolCall.thoughtSignature ? {
|
|
477890
|
+
providerMetadata: {
|
|
477891
|
+
[providerOptionsName]: {
|
|
477892
|
+
thoughtSignature: toolCall.thoughtSignature
|
|
477893
|
+
}
|
|
477894
|
+
}
|
|
477895
|
+
} : {}
|
|
477896
|
+
});
|
|
477897
|
+
}
|
|
477898
|
+
if (finishReason == null) {
|
|
477899
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
477900
|
+
controller.enqueue({
|
|
477901
|
+
type: "error",
|
|
477902
|
+
error: new InvalidResponseDataError({
|
|
477903
|
+
data: void 0,
|
|
477904
|
+
message: "Response stream ended without a finish reason."
|
|
477905
|
+
})
|
|
477906
|
+
});
|
|
477907
|
+
}
|
|
477908
|
+
const providerMetadata = {
|
|
477909
|
+
[providerOptionsName]: {},
|
|
477910
|
+
...metadataExtractor == null ? void 0 : metadataExtractor.buildMetadata()
|
|
477911
|
+
};
|
|
477912
|
+
if (((_b16 = usage == null ? void 0 : usage.completion_tokens_details) == null ? void 0 : _b16.accepted_prediction_tokens) != null) {
|
|
477913
|
+
providerMetadata[providerOptionsName].acceptedPredictionTokens = (_c = usage == null ? void 0 : usage.completion_tokens_details) == null ? void 0 : _c.accepted_prediction_tokens;
|
|
477914
|
+
}
|
|
477915
|
+
if (((_d = usage == null ? void 0 : usage.completion_tokens_details) == null ? void 0 : _d.rejected_prediction_tokens) != null) {
|
|
477916
|
+
providerMetadata[providerOptionsName].rejectedPredictionTokens = (_e = usage == null ? void 0 : usage.completion_tokens_details) == null ? void 0 : _e.rejected_prediction_tokens;
|
|
477917
|
+
}
|
|
477918
|
+
controller.enqueue({
|
|
477919
|
+
type: "finish",
|
|
477920
|
+
finishReason,
|
|
477921
|
+
usage: convertUsage(usage),
|
|
477922
|
+
providerMetadata
|
|
477923
|
+
});
|
|
477924
|
+
}
|
|
477925
|
+
})
|
|
477926
|
+
),
|
|
477927
|
+
request: { body },
|
|
477928
|
+
response: { headers: responseHeaders }
|
|
477929
|
+
};
|
|
477930
|
+
}
|
|
477931
|
+
};
|
|
477932
|
+
openaiCompatibleTokenUsageSchema = external_exports.looseObject({
|
|
477933
|
+
prompt_tokens: external_exports.number().nullish(),
|
|
477934
|
+
completion_tokens: external_exports.number().nullish(),
|
|
477935
|
+
total_tokens: external_exports.number().nullish(),
|
|
477936
|
+
prompt_tokens_details: external_exports.looseObject({
|
|
477937
|
+
cached_tokens: external_exports.number().nullish()
|
|
477938
|
+
}).nullish(),
|
|
477939
|
+
completion_tokens_details: external_exports.looseObject({
|
|
477940
|
+
reasoning_tokens: external_exports.number().nullish(),
|
|
477941
|
+
accepted_prediction_tokens: external_exports.number().nullish(),
|
|
477942
|
+
rejected_prediction_tokens: external_exports.number().nullish()
|
|
477943
|
+
}).nullish()
|
|
477944
|
+
}).nullish();
|
|
477945
|
+
openAICompatibleContentSchema = external_exports.union([
|
|
477946
|
+
external_exports.string(),
|
|
477947
|
+
external_exports.array(
|
|
477948
|
+
external_exports.looseObject({
|
|
477949
|
+
type: external_exports.string()
|
|
477950
|
+
})
|
|
477951
|
+
)
|
|
477952
|
+
]).nullish();
|
|
477953
|
+
OpenAICompatibleChatResponseSchema = external_exports.looseObject({
|
|
477954
|
+
id: external_exports.string().nullish(),
|
|
477955
|
+
created: external_exports.number().nullish(),
|
|
477956
|
+
model: external_exports.string().nullish(),
|
|
477957
|
+
choices: external_exports.array(
|
|
477958
|
+
external_exports.object({
|
|
477959
|
+
message: external_exports.object({
|
|
477960
|
+
role: external_exports.literal("assistant").nullish(),
|
|
477961
|
+
content: openAICompatibleContentSchema,
|
|
477962
|
+
reasoning_content: external_exports.string().nullish(),
|
|
477963
|
+
reasoning: external_exports.string().nullish(),
|
|
477964
|
+
tool_calls: external_exports.array(
|
|
477965
|
+
external_exports.object({
|
|
477966
|
+
id: external_exports.string().nullish(),
|
|
477967
|
+
function: external_exports.object({
|
|
477968
|
+
name: external_exports.string(),
|
|
477969
|
+
arguments: external_exports.string()
|
|
477970
|
+
}),
|
|
477971
|
+
// Support for Google Gemini thought signatures via OpenAI compatibility
|
|
477972
|
+
extra_content: external_exports.object({
|
|
477973
|
+
google: external_exports.object({
|
|
477974
|
+
thought_signature: external_exports.string().nullish()
|
|
477975
|
+
}).nullish()
|
|
477976
|
+
}).nullish()
|
|
477977
|
+
})
|
|
477978
|
+
).nullish()
|
|
477979
|
+
}),
|
|
477980
|
+
finish_reason: external_exports.string().nullish()
|
|
477981
|
+
})
|
|
477982
|
+
),
|
|
477983
|
+
usage: openaiCompatibleTokenUsageSchema
|
|
477984
|
+
});
|
|
477985
|
+
chunkBaseSchema = external_exports.looseObject({
|
|
477986
|
+
id: external_exports.string().nullish(),
|
|
477987
|
+
created: external_exports.number().nullish(),
|
|
477988
|
+
model: external_exports.string().nullish(),
|
|
477989
|
+
choices: external_exports.array(
|
|
477990
|
+
external_exports.object({
|
|
477991
|
+
delta: external_exports.object({
|
|
477992
|
+
role: external_exports.enum(["assistant", ""]).nullish(),
|
|
477993
|
+
content: openAICompatibleContentSchema,
|
|
477994
|
+
// Most openai-compatible models set `reasoning_content`, but some
|
|
477995
|
+
// providers serving `gpt-oss` set `reasoning`. See #7866
|
|
477996
|
+
reasoning_content: external_exports.string().nullish(),
|
|
477997
|
+
reasoning: external_exports.string().nullish(),
|
|
477998
|
+
tool_calls: external_exports.array(
|
|
477999
|
+
external_exports.object({
|
|
478000
|
+
index: external_exports.number().nullish(),
|
|
478001
|
+
//google does not send index
|
|
478002
|
+
id: external_exports.string().nullish(),
|
|
478003
|
+
function: external_exports.object({
|
|
478004
|
+
name: external_exports.string().nullish(),
|
|
478005
|
+
arguments: external_exports.string().nullish()
|
|
478006
|
+
}),
|
|
478007
|
+
// Support for Google Gemini thought signatures via OpenAI compatibility
|
|
478008
|
+
extra_content: external_exports.object({
|
|
478009
|
+
google: external_exports.object({
|
|
478010
|
+
thought_signature: external_exports.string().nullish()
|
|
478011
|
+
}).nullish()
|
|
478012
|
+
}).nullish()
|
|
478013
|
+
})
|
|
478014
|
+
).nullish()
|
|
478015
|
+
}).nullish(),
|
|
478016
|
+
finish_reason: external_exports.string().nullish()
|
|
478017
|
+
})
|
|
478018
|
+
),
|
|
478019
|
+
usage: openaiCompatibleTokenUsageSchema
|
|
478020
|
+
});
|
|
478021
|
+
createOpenAICompatibleChatChunkSchema = (errorSchema) => external_exports.union([chunkBaseSchema, errorSchema]);
|
|
478022
|
+
openaiCompatibleLanguageModelCompletionOptions = external_exports.object({
|
|
478023
|
+
/**
|
|
478024
|
+
* Echo back the prompt in addition to the completion.
|
|
478025
|
+
*/
|
|
478026
|
+
echo: external_exports.boolean().optional(),
|
|
478027
|
+
/**
|
|
478028
|
+
* Modify the likelihood of specified tokens appearing in the completion.
|
|
478029
|
+
*
|
|
478030
|
+
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
478031
|
+
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
478032
|
+
*/
|
|
478033
|
+
logitBias: external_exports.record(external_exports.string(), external_exports.number()).optional(),
|
|
478034
|
+
/**
|
|
478035
|
+
* The suffix that comes after a completion of inserted text.
|
|
478036
|
+
*/
|
|
478037
|
+
suffix: external_exports.string().optional(),
|
|
478038
|
+
/**
|
|
478039
|
+
* A unique identifier representing your end-user, which can help providers to
|
|
478040
|
+
* monitor and detect abuse.
|
|
478041
|
+
*/
|
|
478042
|
+
user: external_exports.string().optional()
|
|
478043
|
+
});
|
|
478044
|
+
OpenAICompatibleCompletionLanguageModel = class {
|
|
478045
|
+
// type inferred via constructor
|
|
478046
|
+
constructor(modelId, config2) {
|
|
478047
|
+
this.specificationVersion = "v3";
|
|
478048
|
+
var _a17;
|
|
478049
|
+
this.modelId = modelId;
|
|
478050
|
+
this.config = config2;
|
|
478051
|
+
const errorStructure = (_a17 = config2.errorStructure) != null ? _a17 : defaultOpenAICompatibleErrorStructure;
|
|
478052
|
+
this.chunkSchema = createOpenAICompatibleCompletionChunkSchema(
|
|
478053
|
+
errorStructure.errorSchema
|
|
478054
|
+
);
|
|
478055
|
+
this.failedResponseHandler = createJsonErrorResponseHandler(errorStructure);
|
|
478056
|
+
}
|
|
478057
|
+
get provider() {
|
|
478058
|
+
return this.config.provider;
|
|
478059
|
+
}
|
|
478060
|
+
get providerOptionsName() {
|
|
478061
|
+
return this.config.provider.split(".")[0].trim();
|
|
478062
|
+
}
|
|
478063
|
+
get supportedUrls() {
|
|
478064
|
+
var _a17, _b16, _c;
|
|
478065
|
+
return (_c = (_b16 = (_a17 = this.config).supportedUrls) == null ? void 0 : _b16.call(_a17)) != null ? _c : {};
|
|
478066
|
+
}
|
|
478067
|
+
async getArgs({
|
|
478068
|
+
prompt,
|
|
478069
|
+
maxOutputTokens,
|
|
478070
|
+
temperature,
|
|
478071
|
+
topP,
|
|
478072
|
+
topK,
|
|
478073
|
+
frequencyPenalty,
|
|
478074
|
+
presencePenalty,
|
|
478075
|
+
stopSequences: userStopSequences,
|
|
478076
|
+
responseFormat,
|
|
478077
|
+
seed,
|
|
478078
|
+
providerOptions,
|
|
478079
|
+
tools: tools2,
|
|
478080
|
+
toolChoice
|
|
478081
|
+
}) {
|
|
478082
|
+
var _a17, _b16;
|
|
478083
|
+
const warnings = [];
|
|
478084
|
+
const completionOptions = Object.assign(
|
|
478085
|
+
(_a17 = await parseProviderOptions({
|
|
478086
|
+
provider: this.providerOptionsName,
|
|
478087
|
+
providerOptions,
|
|
478088
|
+
schema: openaiCompatibleLanguageModelCompletionOptions
|
|
478089
|
+
})) != null ? _a17 : {},
|
|
478090
|
+
(_b16 = await parseProviderOptions({
|
|
478091
|
+
provider: toCamelCase(this.providerOptionsName),
|
|
478092
|
+
providerOptions,
|
|
478093
|
+
schema: openaiCompatibleLanguageModelCompletionOptions
|
|
478094
|
+
})) != null ? _b16 : {}
|
|
478095
|
+
);
|
|
478096
|
+
if (topK != null) {
|
|
478097
|
+
warnings.push({ type: "unsupported", feature: "topK" });
|
|
478098
|
+
}
|
|
478099
|
+
if (tools2 == null ? void 0 : tools2.length) {
|
|
478100
|
+
warnings.push({ type: "unsupported", feature: "tools" });
|
|
478101
|
+
}
|
|
478102
|
+
if (toolChoice != null) {
|
|
478103
|
+
warnings.push({ type: "unsupported", feature: "toolChoice" });
|
|
478104
|
+
}
|
|
478105
|
+
if (responseFormat != null && responseFormat.type !== "text") {
|
|
478106
|
+
warnings.push({
|
|
478107
|
+
type: "unsupported",
|
|
478108
|
+
feature: "responseFormat",
|
|
478109
|
+
details: "JSON response format is not supported."
|
|
478110
|
+
});
|
|
478111
|
+
}
|
|
478112
|
+
const { prompt: completionPrompt, stopSequences } = convertToOpenAICompatibleCompletionPrompt({ prompt });
|
|
478113
|
+
const stop = [...stopSequences != null ? stopSequences : [], ...userStopSequences != null ? userStopSequences : []];
|
|
478114
|
+
return {
|
|
478115
|
+
args: {
|
|
478116
|
+
// model id:
|
|
478117
|
+
model: this.modelId,
|
|
478118
|
+
// model specific settings:
|
|
478119
|
+
echo: completionOptions.echo,
|
|
478120
|
+
logit_bias: completionOptions.logitBias,
|
|
478121
|
+
suffix: completionOptions.suffix,
|
|
478122
|
+
user: completionOptions.user,
|
|
478123
|
+
// standardized settings:
|
|
478124
|
+
max_tokens: maxOutputTokens,
|
|
478125
|
+
temperature,
|
|
478126
|
+
top_p: topP,
|
|
478127
|
+
frequency_penalty: frequencyPenalty,
|
|
478128
|
+
presence_penalty: presencePenalty,
|
|
478129
|
+
seed,
|
|
478130
|
+
...providerOptions == null ? void 0 : providerOptions[this.providerOptionsName],
|
|
478131
|
+
...providerOptions == null ? void 0 : providerOptions[toCamelCase(this.providerOptionsName)],
|
|
478132
|
+
// prompt:
|
|
478133
|
+
prompt: completionPrompt,
|
|
478134
|
+
// stop sequences:
|
|
478135
|
+
stop: stop.length > 0 ? stop : void 0
|
|
478136
|
+
},
|
|
478137
|
+
warnings
|
|
478138
|
+
};
|
|
478139
|
+
}
|
|
478140
|
+
async doGenerate(options) {
|
|
478141
|
+
const { args, warnings } = await this.getArgs(options);
|
|
478142
|
+
const {
|
|
478143
|
+
responseHeaders,
|
|
478144
|
+
value: response,
|
|
478145
|
+
rawValue: rawResponse
|
|
478146
|
+
} = await postJsonToApi({
|
|
478147
|
+
url: this.config.url({
|
|
478148
|
+
path: "/completions",
|
|
478149
|
+
modelId: this.modelId
|
|
478150
|
+
}),
|
|
478151
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
478152
|
+
body: args,
|
|
478153
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
478154
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
478155
|
+
openaiCompatibleCompletionResponseSchema
|
|
478156
|
+
),
|
|
478157
|
+
abortSignal: options.abortSignal,
|
|
478158
|
+
fetch: this.config.fetch
|
|
478159
|
+
});
|
|
478160
|
+
const choice = response.choices[0];
|
|
478161
|
+
const content = [];
|
|
478162
|
+
if (choice.text != null && choice.text.length > 0) {
|
|
478163
|
+
content.push({ type: "text", text: choice.text });
|
|
478164
|
+
}
|
|
478165
|
+
return {
|
|
478166
|
+
content,
|
|
478167
|
+
usage: convertOpenAICompatibleCompletionUsage(response.usage),
|
|
478168
|
+
finishReason: {
|
|
478169
|
+
unified: mapOpenAICompatibleFinishReason2(choice.finish_reason),
|
|
478170
|
+
raw: choice.finish_reason
|
|
478171
|
+
},
|
|
478172
|
+
request: { body: args },
|
|
478173
|
+
response: {
|
|
478174
|
+
...getResponseMetadata2(response),
|
|
478175
|
+
headers: responseHeaders,
|
|
478176
|
+
body: rawResponse
|
|
478177
|
+
},
|
|
478178
|
+
warnings
|
|
478179
|
+
};
|
|
478180
|
+
}
|
|
478181
|
+
async doStream(options) {
|
|
478182
|
+
const { args, warnings } = await this.getArgs(options);
|
|
478183
|
+
const body = {
|
|
478184
|
+
...args,
|
|
478185
|
+
stream: true,
|
|
478186
|
+
// only include stream_options when in strict compatibility mode:
|
|
478187
|
+
stream_options: this.config.includeUsage ? { include_usage: true } : void 0
|
|
478188
|
+
};
|
|
478189
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
478190
|
+
url: this.config.url({
|
|
478191
|
+
path: "/completions",
|
|
478192
|
+
modelId: this.modelId
|
|
478193
|
+
}),
|
|
478194
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
478195
|
+
body,
|
|
478196
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
478197
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
478198
|
+
this.chunkSchema
|
|
478199
|
+
),
|
|
478200
|
+
abortSignal: options.abortSignal,
|
|
478201
|
+
fetch: this.config.fetch
|
|
478202
|
+
});
|
|
478203
|
+
let finishReason = {
|
|
478204
|
+
unified: "other",
|
|
478205
|
+
raw: void 0
|
|
478206
|
+
};
|
|
478207
|
+
let usage = void 0;
|
|
478208
|
+
let isFirstChunk = true;
|
|
478209
|
+
return {
|
|
478210
|
+
stream: response.pipeThrough(
|
|
478211
|
+
new TransformStream({
|
|
478212
|
+
start(controller) {
|
|
478213
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
478214
|
+
},
|
|
478215
|
+
transform(chunk, controller) {
|
|
478216
|
+
var _a17;
|
|
478217
|
+
if (options.includeRawChunks) {
|
|
478218
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
478219
|
+
}
|
|
478220
|
+
if (!chunk.success) {
|
|
478221
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
478222
|
+
controller.enqueue({ type: "error", error: chunk.error });
|
|
478223
|
+
return;
|
|
478224
|
+
}
|
|
478225
|
+
const value = chunk.value;
|
|
478226
|
+
if ("error" in value) {
|
|
478227
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
478228
|
+
controller.enqueue({ type: "error", error: value.error });
|
|
478229
|
+
return;
|
|
478230
|
+
}
|
|
478231
|
+
if (isFirstChunk) {
|
|
478232
|
+
isFirstChunk = false;
|
|
478233
|
+
controller.enqueue({
|
|
478234
|
+
type: "response-metadata",
|
|
478235
|
+
...getResponseMetadata2(value)
|
|
478236
|
+
});
|
|
478237
|
+
controller.enqueue({
|
|
478238
|
+
type: "text-start",
|
|
478239
|
+
id: "0"
|
|
478240
|
+
});
|
|
478241
|
+
}
|
|
478242
|
+
if (value.usage != null) {
|
|
478243
|
+
usage = value.usage;
|
|
478244
|
+
}
|
|
478245
|
+
const choice = value.choices[0];
|
|
478246
|
+
if ((choice == null ? void 0 : choice.finish_reason) != null) {
|
|
478247
|
+
finishReason = {
|
|
478248
|
+
unified: mapOpenAICompatibleFinishReason2(choice.finish_reason),
|
|
478249
|
+
raw: (_a17 = choice.finish_reason) != null ? _a17 : void 0
|
|
478250
|
+
};
|
|
478251
|
+
}
|
|
478252
|
+
if ((choice == null ? void 0 : choice.text) != null) {
|
|
478253
|
+
controller.enqueue({
|
|
478254
|
+
type: "text-delta",
|
|
478255
|
+
id: "0",
|
|
478256
|
+
delta: choice.text
|
|
478257
|
+
});
|
|
478258
|
+
}
|
|
478259
|
+
},
|
|
478260
|
+
flush(controller) {
|
|
478261
|
+
if (!isFirstChunk) {
|
|
478262
|
+
controller.enqueue({ type: "text-end", id: "0" });
|
|
478263
|
+
}
|
|
478264
|
+
controller.enqueue({
|
|
478265
|
+
type: "finish",
|
|
478266
|
+
finishReason,
|
|
478267
|
+
usage: convertOpenAICompatibleCompletionUsage(usage)
|
|
478268
|
+
});
|
|
478269
|
+
}
|
|
478270
|
+
})
|
|
478271
|
+
),
|
|
478272
|
+
request: { body },
|
|
478273
|
+
response: { headers: responseHeaders }
|
|
478274
|
+
};
|
|
478275
|
+
}
|
|
478276
|
+
};
|
|
478277
|
+
usageSchema = external_exports.looseObject({
|
|
478278
|
+
prompt_tokens: external_exports.number(),
|
|
478279
|
+
completion_tokens: external_exports.number(),
|
|
478280
|
+
total_tokens: external_exports.number()
|
|
478281
|
+
});
|
|
478282
|
+
openaiCompatibleCompletionResponseSchema = external_exports.object({
|
|
478283
|
+
id: external_exports.string().nullish(),
|
|
478284
|
+
created: external_exports.number().nullish(),
|
|
478285
|
+
model: external_exports.string().nullish(),
|
|
478286
|
+
choices: external_exports.array(
|
|
478287
|
+
external_exports.object({
|
|
478288
|
+
text: external_exports.string(),
|
|
478289
|
+
finish_reason: external_exports.string()
|
|
478290
|
+
})
|
|
478291
|
+
),
|
|
478292
|
+
usage: usageSchema.nullish()
|
|
478293
|
+
});
|
|
478294
|
+
createOpenAICompatibleCompletionChunkSchema = (errorSchema) => external_exports.union([
|
|
478295
|
+
external_exports.object({
|
|
478296
|
+
id: external_exports.string().nullish(),
|
|
478297
|
+
created: external_exports.number().nullish(),
|
|
478298
|
+
model: external_exports.string().nullish(),
|
|
478299
|
+
choices: external_exports.array(
|
|
478300
|
+
external_exports.object({
|
|
478301
|
+
text: external_exports.string(),
|
|
478302
|
+
finish_reason: external_exports.string().nullish(),
|
|
478303
|
+
index: external_exports.number()
|
|
478304
|
+
})
|
|
478305
|
+
),
|
|
478306
|
+
usage: usageSchema.nullish()
|
|
478307
|
+
}),
|
|
478308
|
+
errorSchema
|
|
478309
|
+
]);
|
|
478310
|
+
openaiCompatibleEmbeddingModelOptions = external_exports.object({
|
|
478311
|
+
/**
|
|
478312
|
+
* The number of dimensions the resulting output embeddings should have.
|
|
478313
|
+
* Only supported in text-embedding-3 and later models.
|
|
478314
|
+
*/
|
|
478315
|
+
dimensions: external_exports.number().optional(),
|
|
478316
|
+
/**
|
|
478317
|
+
* A unique identifier representing your end-user, which can help providers to
|
|
478318
|
+
* monitor and detect abuse.
|
|
478319
|
+
*/
|
|
478320
|
+
user: external_exports.string().optional()
|
|
478321
|
+
});
|
|
478322
|
+
OpenAICompatibleEmbeddingModel = class {
|
|
478323
|
+
constructor(modelId, config2) {
|
|
478324
|
+
this.specificationVersion = "v3";
|
|
478325
|
+
this.modelId = modelId;
|
|
478326
|
+
this.config = config2;
|
|
478327
|
+
}
|
|
478328
|
+
get provider() {
|
|
478329
|
+
return this.config.provider;
|
|
478330
|
+
}
|
|
478331
|
+
get maxEmbeddingsPerCall() {
|
|
478332
|
+
var _a17;
|
|
478333
|
+
return (_a17 = this.config.maxEmbeddingsPerCall) != null ? _a17 : 2048;
|
|
478334
|
+
}
|
|
478335
|
+
get supportsParallelCalls() {
|
|
478336
|
+
var _a17;
|
|
478337
|
+
return (_a17 = this.config.supportsParallelCalls) != null ? _a17 : true;
|
|
478338
|
+
}
|
|
478339
|
+
get providerOptionsName() {
|
|
478340
|
+
return this.config.provider.split(".")[0].trim();
|
|
478341
|
+
}
|
|
478342
|
+
async doEmbed({
|
|
478343
|
+
values: values2,
|
|
478344
|
+
headers,
|
|
478345
|
+
abortSignal,
|
|
478346
|
+
providerOptions
|
|
478347
|
+
}) {
|
|
478348
|
+
var _a17, _b16, _c;
|
|
478349
|
+
const warnings = [];
|
|
478350
|
+
const deprecatedOptions = await parseProviderOptions({
|
|
478351
|
+
provider: "openai-compatible",
|
|
478352
|
+
providerOptions,
|
|
478353
|
+
schema: openaiCompatibleEmbeddingModelOptions
|
|
478354
|
+
});
|
|
478355
|
+
if (deprecatedOptions != null) {
|
|
478356
|
+
warnings.push({
|
|
478357
|
+
type: "other",
|
|
478358
|
+
message: `The 'openai-compatible' key in providerOptions is deprecated. Use 'openaiCompatible' instead.`
|
|
478359
|
+
});
|
|
478360
|
+
}
|
|
478361
|
+
const compatibleOptions = Object.assign(
|
|
478362
|
+
deprecatedOptions != null ? deprecatedOptions : {},
|
|
478363
|
+
(_a17 = await parseProviderOptions({
|
|
478364
|
+
provider: "openaiCompatible",
|
|
478365
|
+
providerOptions,
|
|
478366
|
+
schema: openaiCompatibleEmbeddingModelOptions
|
|
478367
|
+
})) != null ? _a17 : {},
|
|
478368
|
+
(_b16 = await parseProviderOptions({
|
|
478369
|
+
provider: this.providerOptionsName,
|
|
478370
|
+
providerOptions,
|
|
478371
|
+
schema: openaiCompatibleEmbeddingModelOptions
|
|
478372
|
+
})) != null ? _b16 : {}
|
|
478373
|
+
);
|
|
478374
|
+
if (values2.length > this.maxEmbeddingsPerCall) {
|
|
478375
|
+
throw new TooManyEmbeddingValuesForCallError({
|
|
478376
|
+
provider: this.provider,
|
|
478377
|
+
modelId: this.modelId,
|
|
478378
|
+
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
478379
|
+
values: values2
|
|
478380
|
+
});
|
|
478381
|
+
}
|
|
478382
|
+
const {
|
|
478383
|
+
responseHeaders,
|
|
478384
|
+
value: response,
|
|
478385
|
+
rawValue
|
|
478386
|
+
} = await postJsonToApi({
|
|
478387
|
+
url: this.config.url({
|
|
478388
|
+
path: "/embeddings",
|
|
478389
|
+
modelId: this.modelId
|
|
478390
|
+
}),
|
|
478391
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
478392
|
+
body: {
|
|
478393
|
+
model: this.modelId,
|
|
478394
|
+
input: values2,
|
|
478395
|
+
encoding_format: "float",
|
|
478396
|
+
dimensions: compatibleOptions.dimensions,
|
|
478397
|
+
user: compatibleOptions.user
|
|
478398
|
+
},
|
|
478399
|
+
failedResponseHandler: createJsonErrorResponseHandler(
|
|
478400
|
+
(_c = this.config.errorStructure) != null ? _c : defaultOpenAICompatibleErrorStructure
|
|
478401
|
+
),
|
|
478402
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
478403
|
+
openaiTextEmbeddingResponseSchema
|
|
478404
|
+
),
|
|
478405
|
+
abortSignal,
|
|
478406
|
+
fetch: this.config.fetch
|
|
478407
|
+
});
|
|
478408
|
+
return {
|
|
478409
|
+
warnings,
|
|
478410
|
+
embeddings: response.data.map((item) => item.embedding),
|
|
478411
|
+
usage: response.usage ? { tokens: response.usage.prompt_tokens } : void 0,
|
|
478412
|
+
providerMetadata: response.providerMetadata,
|
|
478413
|
+
response: { headers: responseHeaders, body: rawValue }
|
|
478414
|
+
};
|
|
478415
|
+
}
|
|
478416
|
+
};
|
|
478417
|
+
openaiTextEmbeddingResponseSchema = external_exports.object({
|
|
478418
|
+
data: external_exports.array(external_exports.object({ embedding: external_exports.array(external_exports.number()) })),
|
|
478419
|
+
usage: external_exports.object({ prompt_tokens: external_exports.number() }).nullish(),
|
|
478420
|
+
providerMetadata: external_exports.record(external_exports.string(), external_exports.record(external_exports.string(), external_exports.any())).optional()
|
|
478421
|
+
});
|
|
478422
|
+
OpenAICompatibleImageModel = class {
|
|
478423
|
+
constructor(modelId, config2) {
|
|
478424
|
+
this.modelId = modelId;
|
|
478425
|
+
this.config = config2;
|
|
478426
|
+
this.specificationVersion = "v3";
|
|
478427
|
+
this.maxImagesPerCall = 10;
|
|
478428
|
+
}
|
|
478429
|
+
get provider() {
|
|
478430
|
+
return this.config.provider;
|
|
478431
|
+
}
|
|
478432
|
+
/**
|
|
478433
|
+
* The provider options key used to extract provider-specific options.
|
|
478434
|
+
*/
|
|
478435
|
+
get providerOptionsKey() {
|
|
478436
|
+
return this.config.provider.split(".")[0].trim();
|
|
478437
|
+
}
|
|
478438
|
+
// TODO: deprecate non-camelCase keys and remove in future major version
|
|
478439
|
+
getArgs(providerOptions) {
|
|
478440
|
+
return {
|
|
478441
|
+
...providerOptions[this.providerOptionsKey],
|
|
478442
|
+
...providerOptions[toCamelCase(this.providerOptionsKey)]
|
|
478443
|
+
};
|
|
478444
|
+
}
|
|
478445
|
+
async doGenerate({
|
|
478446
|
+
prompt,
|
|
478447
|
+
n,
|
|
478448
|
+
size,
|
|
478449
|
+
aspectRatio,
|
|
478450
|
+
seed,
|
|
478451
|
+
providerOptions,
|
|
478452
|
+
headers,
|
|
478453
|
+
abortSignal,
|
|
478454
|
+
files,
|
|
478455
|
+
mask
|
|
478456
|
+
}) {
|
|
478457
|
+
var _a17, _b16, _c, _d, _e;
|
|
478458
|
+
const warnings = [];
|
|
478459
|
+
if (aspectRatio != null) {
|
|
478460
|
+
warnings.push({
|
|
478461
|
+
type: "unsupported",
|
|
478462
|
+
feature: "aspectRatio",
|
|
478463
|
+
details: "This model does not support aspect ratio. Use `size` instead."
|
|
478464
|
+
});
|
|
478465
|
+
}
|
|
478466
|
+
if (seed != null) {
|
|
478467
|
+
warnings.push({ type: "unsupported", feature: "seed" });
|
|
478468
|
+
}
|
|
478469
|
+
const currentDate = (_c = (_b16 = (_a17 = this.config._internal) == null ? void 0 : _a17.currentDate) == null ? void 0 : _b16.call(_a17)) != null ? _c : /* @__PURE__ */ new Date();
|
|
478470
|
+
const args = this.getArgs(providerOptions);
|
|
478471
|
+
if (files != null && files.length > 0) {
|
|
478472
|
+
const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
|
|
478473
|
+
url: this.config.url({
|
|
478474
|
+
path: "/images/edits",
|
|
478475
|
+
modelId: this.modelId
|
|
478476
|
+
}),
|
|
478477
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
478478
|
+
formData: convertToFormData({
|
|
478479
|
+
model: this.modelId,
|
|
478480
|
+
prompt,
|
|
478481
|
+
image: await Promise.all(files.map((file2) => fileToBlob(file2))),
|
|
478482
|
+
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
478483
|
+
n,
|
|
478484
|
+
size,
|
|
478485
|
+
...args
|
|
478486
|
+
}),
|
|
478487
|
+
failedResponseHandler: createJsonErrorResponseHandler(
|
|
478488
|
+
(_d = this.config.errorStructure) != null ? _d : defaultOpenAICompatibleErrorStructure
|
|
478489
|
+
),
|
|
478490
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
478491
|
+
openaiCompatibleImageResponseSchema
|
|
478492
|
+
),
|
|
478493
|
+
abortSignal,
|
|
478494
|
+
fetch: this.config.fetch
|
|
478495
|
+
});
|
|
478496
|
+
return {
|
|
478497
|
+
images: response2.data.map((item) => item.b64_json),
|
|
478498
|
+
warnings,
|
|
478499
|
+
response: {
|
|
478500
|
+
timestamp: currentDate,
|
|
478501
|
+
modelId: this.modelId,
|
|
478502
|
+
headers: responseHeaders2
|
|
478503
|
+
}
|
|
478504
|
+
};
|
|
478505
|
+
}
|
|
478506
|
+
const { value: response, responseHeaders } = await postJsonToApi({
|
|
478507
|
+
url: this.config.url({
|
|
478508
|
+
path: "/images/generations",
|
|
478509
|
+
modelId: this.modelId
|
|
478510
|
+
}),
|
|
478511
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
478512
|
+
body: {
|
|
478513
|
+
model: this.modelId,
|
|
478514
|
+
prompt,
|
|
478515
|
+
n,
|
|
478516
|
+
size,
|
|
478517
|
+
...args,
|
|
478518
|
+
response_format: "b64_json"
|
|
478519
|
+
},
|
|
478520
|
+
failedResponseHandler: createJsonErrorResponseHandler(
|
|
478521
|
+
(_e = this.config.errorStructure) != null ? _e : defaultOpenAICompatibleErrorStructure
|
|
478522
|
+
),
|
|
478523
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
478524
|
+
openaiCompatibleImageResponseSchema
|
|
478525
|
+
),
|
|
478526
|
+
abortSignal,
|
|
478527
|
+
fetch: this.config.fetch
|
|
478528
|
+
});
|
|
478529
|
+
return {
|
|
478530
|
+
images: response.data.map((item) => item.b64_json),
|
|
478531
|
+
warnings,
|
|
478532
|
+
response: {
|
|
478533
|
+
timestamp: currentDate,
|
|
478534
|
+
modelId: this.modelId,
|
|
478535
|
+
headers: responseHeaders
|
|
478536
|
+
}
|
|
478537
|
+
};
|
|
478538
|
+
}
|
|
478539
|
+
};
|
|
478540
|
+
openaiCompatibleImageResponseSchema = external_exports.object({
|
|
478541
|
+
data: external_exports.array(external_exports.object({ b64_json: external_exports.string() }))
|
|
478542
|
+
});
|
|
478543
|
+
VERSION2 = true ? "2.0.74" : 0;
|
|
478544
|
+
}
|
|
478545
|
+
});
|
|
478546
|
+
|
|
476133
478547
|
// node_modules/@smithy/core/dist-es/submodules/serde/is-array-buffer/is-array-buffer.js
|
|
476134
478548
|
var isArrayBuffer;
|
|
476135
478549
|
var init_is_array_buffer = __esm({
|
|
@@ -480767,16 +483181,17 @@ var init_aws4fetch_esm = __esm({
|
|
|
480767
483181
|
|
|
480768
483182
|
// node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs
|
|
480769
483183
|
function supportsStrictTools(modelId) {
|
|
480770
|
-
return !
|
|
483184
|
+
return !matchesModel(modelId, MODELS_WITHOUT_STRICT_TOOL_SUPPORT);
|
|
480771
483185
|
}
|
|
480772
483186
|
function supportsNativeStructuredOutput(modelId) {
|
|
480773
|
-
return !
|
|
480774
|
-
|
|
480775
|
-
|
|
480776
|
-
return MODELS_REJECTING_NEWER_SCHEMA_FIELDS.some(
|
|
480777
|
-
(model) => modelId.includes(model)
|
|
483187
|
+
return !matchesModel(
|
|
483188
|
+
modelId,
|
|
483189
|
+
MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT
|
|
480778
483190
|
);
|
|
480779
483191
|
}
|
|
483192
|
+
function matchesModel(modelId, models) {
|
|
483193
|
+
return models.some((model) => modelId.includes(model));
|
|
483194
|
+
}
|
|
480780
483195
|
function createBedrockEventStreamDecoder(body, processEvent) {
|
|
480781
483196
|
const codec = new import_eventstream_codec.EventStreamCodec(import_util_utf8.toUtf8, import_util_utf8.fromUtf8);
|
|
480782
483197
|
let buffer = new Uint8Array(0);
|
|
@@ -480821,7 +483236,7 @@ function createBedrockEventStreamDecoder(body, processEvent) {
|
|
|
480821
483236
|
})
|
|
480822
483237
|
);
|
|
480823
483238
|
}
|
|
480824
|
-
async function
|
|
483239
|
+
async function prepareTools2({
|
|
480825
483240
|
tools: tools2,
|
|
480826
483241
|
toolChoice,
|
|
480827
483242
|
modelId,
|
|
@@ -481474,6 +483889,9 @@ function mapBedrockFinishReason(finishReason, isJsonResponseFromTool) {
|
|
|
481474
483889
|
return "other";
|
|
481475
483890
|
}
|
|
481476
483891
|
}
|
|
483892
|
+
function isJsonResponseToolName(name15) {
|
|
483893
|
+
return name15 === "json" || name15 === "json<|channel|>commentary";
|
|
483894
|
+
}
|
|
481477
483895
|
function isCohereEmbeddingModel(modelId) {
|
|
481478
483896
|
return modelId.includes("cohere.embed-");
|
|
481479
483897
|
}
|
|
@@ -481505,7 +483923,7 @@ function createSigV4FetchFunction(getCredentials, fetch2, service = "bedrock") {
|
|
|
481505
483923
|
);
|
|
481506
483924
|
const headersWithUserAgent = withUserAgentSuffix(
|
|
481507
483925
|
originalHeaders,
|
|
481508
|
-
`ai-sdk/amazon-bedrock/${
|
|
483926
|
+
`ai-sdk/amazon-bedrock/${VERSION3}`,
|
|
481509
483927
|
getRuntimeEnvironmentUserAgent()
|
|
481510
483928
|
);
|
|
481511
483929
|
let effectiveBody = (_a17 = init == null ? void 0 : init.body) != null ? _a17 : void 0;
|
|
@@ -481563,7 +483981,7 @@ function createApiKeyFetchFunction(apiKey, fetch2) {
|
|
|
481563
483981
|
const originalHeaders = normalizeHeaders(init == null ? void 0 : init.headers);
|
|
481564
483982
|
const headersWithUserAgent = withUserAgentSuffix(
|
|
481565
483983
|
originalHeaders,
|
|
481566
|
-
`ai-sdk/amazon-bedrock/${
|
|
483984
|
+
`ai-sdk/amazon-bedrock/${VERSION3}`,
|
|
481567
483985
|
getRuntimeEnvironmentUserAgent()
|
|
481568
483986
|
);
|
|
481569
483987
|
const finalHeaders = combineHeaders(headersWithUserAgent, {
|
|
@@ -481645,7 +484063,7 @@ Original error: ${errorMessage}`
|
|
|
481645
484063
|
const getHeaders = () => {
|
|
481646
484064
|
var _a17;
|
|
481647
484065
|
const baseHeaders = (_a17 = options.headers) != null ? _a17 : {};
|
|
481648
|
-
return withUserAgentSuffix(baseHeaders, `ai-sdk/amazon-bedrock/${
|
|
484066
|
+
return withUserAgentSuffix(baseHeaders, `ai-sdk/amazon-bedrock/${VERSION3}`);
|
|
481649
484067
|
};
|
|
481650
484068
|
const getBedrockRuntimeBaseUrl = () => {
|
|
481651
484069
|
var _a17, _b16;
|
|
@@ -481718,38 +484136,38 @@ Original error: ${errorMessage}`
|
|
|
481718
484136
|
provider.tools = import_internal.anthropicTools;
|
|
481719
484137
|
return provider;
|
|
481720
484138
|
}
|
|
481721
|
-
var import_internal, import_internal2, import_eventstream_codec, import_util_utf8, import_internal3, BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES, bedrockFilePartProviderOptions, amazonBedrockLanguageModelOptions,
|
|
481722
|
-
var
|
|
484139
|
+
var import_internal, import_internal2, import_eventstream_codec, import_util_utf8, import_internal3, BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES, bedrockFilePartProviderOptions, amazonBedrockLanguageModelOptions, MODELS_WITHOUT_STRICT_TOOL_SUPPORT, MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT, BedrockErrorSchema, createBedrockEventStreamResponseHandler, bedrockReasoningMetadataSchema, anthropicProviderOptions, BedrockChatLanguageModel, JsonObjectTextExtractor, BedrockStopReasonSchema, BedrockAdditionalModelResponseFieldsSchema, BedrockToolUseSchema, BedrockReasoningTextSchema, BedrockRedactedReasoningSchema, AmazonBedrockCacheDetailSchema, BedrockResponseSchema, BedrockStreamSchema, amazonBedrockEmbeddingModelOptionsSchema, BedrockEmbeddingModel, BedrockEmbeddingResponseSchema, modelMaxImagesPerCall, BedrockImageModel, bedrockImageResponseSchema, VERSION3, bedrockRerankingResponseSchema, amazonBedrockRerankingModelOptionsSchema, BedrockRerankingModel, bedrock;
|
|
484140
|
+
var init_dist5 = __esm({
|
|
481723
484141
|
"node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs"() {
|
|
481724
484142
|
import_internal = __nccwpck_require__(91909);
|
|
481725
|
-
|
|
481726
|
-
|
|
484143
|
+
init_dist3();
|
|
484144
|
+
init_dist3();
|
|
481727
484145
|
import_internal2 = __nccwpck_require__(91909);
|
|
481728
484146
|
init_v4();
|
|
481729
484147
|
init_v4();
|
|
481730
484148
|
init_v4();
|
|
481731
484149
|
init_dist();
|
|
481732
|
-
|
|
484150
|
+
init_dist3();
|
|
481733
484151
|
import_eventstream_codec = __toESM(require_dist_cjs2(), 1);
|
|
481734
484152
|
import_util_utf8 = __toESM(require_dist_cjs3(), 1);
|
|
481735
484153
|
init_dist();
|
|
481736
|
-
|
|
484154
|
+
init_dist3();
|
|
481737
484155
|
import_internal3 = __nccwpck_require__(91909);
|
|
481738
484156
|
init_dist();
|
|
481739
|
-
|
|
484157
|
+
init_dist3();
|
|
481740
484158
|
init_v4();
|
|
481741
484159
|
init_dist();
|
|
481742
|
-
|
|
484160
|
+
init_dist3();
|
|
481743
484161
|
init_v4();
|
|
481744
484162
|
init_v4();
|
|
481745
|
-
|
|
484163
|
+
init_dist3();
|
|
481746
484164
|
init_v4();
|
|
481747
|
-
|
|
484165
|
+
init_dist3();
|
|
481748
484166
|
init_aws4fetch_esm();
|
|
481749
|
-
|
|
481750
|
-
|
|
484167
|
+
init_dist3();
|
|
484168
|
+
init_dist3();
|
|
481751
484169
|
init_v4();
|
|
481752
|
-
|
|
484170
|
+
init_dist3();
|
|
481753
484171
|
init_v4();
|
|
481754
484172
|
BEDROCK_STOP_REASONS = [
|
|
481755
484173
|
"stop",
|
|
@@ -481793,6 +484211,14 @@ var init_dist3 = __esm({
|
|
|
481793
484211
|
}).optional()
|
|
481794
484212
|
});
|
|
481795
484213
|
amazonBedrockLanguageModelOptions = external_exports.object({
|
|
484214
|
+
/**
|
|
484215
|
+
* Determines how structured outputs are generated for Anthropic models.
|
|
484216
|
+
*
|
|
484217
|
+
* - `outputFormat`: Use the native `output_config.format` parameter.
|
|
484218
|
+
* - `jsonTool`: Use a special 'json' tool to specify the structured output format.
|
|
484219
|
+
* - `auto`: Use `outputFormat` when supported, otherwise use `jsonTool` (default).
|
|
484220
|
+
*/
|
|
484221
|
+
structuredOutputMode: external_exports.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
481796
484222
|
/**
|
|
481797
484223
|
* Additional inference parameters that the model supports,
|
|
481798
484224
|
* beyond the base set of inference parameters that Converse
|
|
@@ -481824,13 +484250,18 @@ var init_dist3 = __esm({
|
|
|
481824
484250
|
*/
|
|
481825
484251
|
serviceTier: external_exports.enum(["reserved", "priority", "default", "flex"]).optional()
|
|
481826
484252
|
});
|
|
481827
|
-
|
|
484253
|
+
MODELS_WITHOUT_STRICT_TOOL_SUPPORT = [
|
|
481828
484254
|
"claude-opus-4-7",
|
|
481829
484255
|
"claude-opus-4-8",
|
|
481830
484256
|
"claude-opus-5",
|
|
481831
484257
|
"claude-fable-5",
|
|
481832
484258
|
"claude-sonnet-5"
|
|
481833
484259
|
];
|
|
484260
|
+
MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT = [
|
|
484261
|
+
...MODELS_WITHOUT_STRICT_TOOL_SUPPORT,
|
|
484262
|
+
"claude-sonnet-4-6",
|
|
484263
|
+
"claude-haiku-4-5"
|
|
484264
|
+
];
|
|
481834
484265
|
BedrockErrorSchema = external_exports.object({
|
|
481835
484266
|
message: external_exports.string(),
|
|
481836
484267
|
type: external_exports.string().nullish()
|
|
@@ -481881,7 +484312,8 @@ var init_dist3 = __esm({
|
|
|
481881
484312
|
redactedContent: external_exports.string().optional()
|
|
481882
484313
|
});
|
|
481883
484314
|
anthropicProviderOptions = external_exports.object({
|
|
481884
|
-
disableParallelToolUse: external_exports.boolean().optional()
|
|
484315
|
+
disableParallelToolUse: external_exports.boolean().optional(),
|
|
484316
|
+
structuredOutputMode: external_exports.enum(["outputFormat", "jsonTool", "auto"]).optional()
|
|
481885
484317
|
});
|
|
481886
484318
|
BedrockChatLanguageModel = class {
|
|
481887
484319
|
constructor(modelId, config2) {
|
|
@@ -481908,7 +484340,7 @@ var init_dist3 = __esm({
|
|
|
481908
484340
|
toolChoice,
|
|
481909
484341
|
providerOptions
|
|
481910
484342
|
}) {
|
|
481911
|
-
var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
484343
|
+
var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
481912
484344
|
const bedrockOptions = (_a17 = await parseProviderOptions({
|
|
481913
484345
|
provider: "bedrock",
|
|
481914
484346
|
providerOptions,
|
|
@@ -481966,15 +484398,33 @@ var init_dist3 = __esm({
|
|
|
481966
484398
|
const isOpenAIGptOssModel = (_d = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _d : false;
|
|
481967
484399
|
const isThinkingEnabled = ((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type) === "enabled" || ((_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.type) === "adaptive";
|
|
481968
484400
|
const { supportsStructuredOutput: modelSupportsStructuredOutput } = (0, import_internal2.getModelCapabilities)(this.modelId);
|
|
481969
|
-
const
|
|
481970
|
-
|
|
484401
|
+
const structuredOutputMode = (_h = (_g = bedrockOptions.structuredOutputMode) != null ? _g : anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _h : "auto";
|
|
484402
|
+
if (structuredOutputMode === "jsonTool") {
|
|
484403
|
+
const additionalModelRequestFields = {
|
|
484404
|
+
...bedrockOptions.additionalModelRequestFields
|
|
484405
|
+
};
|
|
484406
|
+
const outputConfig = additionalModelRequestFields.output_config;
|
|
484407
|
+
if (outputConfig != null && typeof outputConfig === "object" && !Array.isArray(outputConfig)) {
|
|
484408
|
+
const outputConfigWithoutFormat = { ...outputConfig };
|
|
484409
|
+
delete outputConfigWithoutFormat.format;
|
|
484410
|
+
if (Object.keys(outputConfigWithoutFormat).length > 0) {
|
|
484411
|
+
additionalModelRequestFields.output_config = outputConfigWithoutFormat;
|
|
484412
|
+
} else {
|
|
484413
|
+
delete additionalModelRequestFields.output_config;
|
|
484414
|
+
}
|
|
484415
|
+
bedrockOptions.additionalModelRequestFields = additionalModelRequestFields;
|
|
484416
|
+
}
|
|
484417
|
+
}
|
|
484418
|
+
const modelSupportsNativeStructuredOutput = supportsNativeStructuredOutput(this.modelId) && (modelSupportsStructuredOutput || isThinkingEnabled);
|
|
484419
|
+
const useNativeStructuredOutput = isAnthropicModel && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && (structuredOutputMode === "outputFormat" || structuredOutputMode === "auto" && modelSupportsNativeStructuredOutput);
|
|
484420
|
+
const useJsonInstructionForStructuredOutput = !useNativeStructuredOutput && structuredOutputMode !== "jsonTool" && isAnthropicModel && !supportsStrictTools(this.modelId) && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && tools2 != null && tools2.length > 0;
|
|
481971
484421
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useNativeStructuredOutput && !useJsonInstructionForStructuredOutput ? {
|
|
481972
484422
|
type: "function",
|
|
481973
484423
|
name: "json",
|
|
481974
484424
|
description: "Respond with a JSON object.",
|
|
481975
484425
|
inputSchema: responseFormat.schema
|
|
481976
484426
|
} : void 0;
|
|
481977
|
-
const { toolConfig, additionalTools, toolWarnings, betas } = await
|
|
484427
|
+
const { toolConfig, additionalTools, toolWarnings, betas } = await prepareTools2({
|
|
481978
484428
|
tools: jsonResponseTool ? [...tools2 != null ? tools2 : [], jsonResponseTool] : tools2,
|
|
481979
484429
|
toolChoice: jsonResponseTool != null ? { type: "required" } : toolChoice,
|
|
481980
484430
|
modelId: this.modelId,
|
|
@@ -481988,16 +484438,16 @@ var init_dist3 = __esm({
|
|
|
481988
484438
|
};
|
|
481989
484439
|
}
|
|
481990
484440
|
if (betas.size > 0 || bedrockOptions.anthropicBeta) {
|
|
481991
|
-
const existingBetas = (
|
|
484441
|
+
const existingBetas = (_i = bedrockOptions.anthropicBeta) != null ? _i : [];
|
|
481992
484442
|
const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
|
|
481993
484443
|
bedrockOptions.additionalModelRequestFields = {
|
|
481994
484444
|
...bedrockOptions.additionalModelRequestFields,
|
|
481995
484445
|
anthropic_beta: mergedBetas
|
|
481996
484446
|
};
|
|
481997
484447
|
}
|
|
481998
|
-
const thinkingType = (
|
|
481999
|
-
const thinkingBudget = thinkingType === "enabled" ? (
|
|
482000
|
-
const thinkingDisplay = thinkingType === "adaptive" ? (
|
|
484448
|
+
const thinkingType = (_j = bedrockOptions.reasoningConfig) == null ? void 0 : _j.type;
|
|
484449
|
+
const thinkingBudget = thinkingType === "enabled" ? (_k = bedrockOptions.reasoningConfig) == null ? void 0 : _k.budgetTokens : void 0;
|
|
484450
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_l = bedrockOptions.reasoningConfig) == null ? void 0 : _l.display : void 0;
|
|
482001
484451
|
const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingEnabled;
|
|
482002
484452
|
const inferenceConfig = {
|
|
482003
484453
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
@@ -482030,7 +484480,7 @@ var init_dist3 = __esm({
|
|
|
482030
484480
|
};
|
|
482031
484481
|
}
|
|
482032
484482
|
} else if (!isAnthropicModel) {
|
|
482033
|
-
if (((
|
|
484483
|
+
if (((_m = bedrockOptions.reasoningConfig) == null ? void 0 : _m.budgetTokens) != null) {
|
|
482034
484484
|
warnings.push({
|
|
482035
484485
|
type: "unsupported",
|
|
482036
484486
|
feature: "budgetTokens",
|
|
@@ -482045,13 +484495,13 @@ var init_dist3 = __esm({
|
|
|
482045
484495
|
});
|
|
482046
484496
|
}
|
|
482047
484497
|
}
|
|
482048
|
-
const maxReasoningEffort = (
|
|
484498
|
+
const maxReasoningEffort = (_n = bedrockOptions.reasoningConfig) == null ? void 0 : _n.maxReasoningEffort;
|
|
482049
484499
|
if (maxReasoningEffort != null) {
|
|
482050
484500
|
if (isAnthropicModel) {
|
|
482051
484501
|
bedrockOptions.additionalModelRequestFields = {
|
|
482052
484502
|
...bedrockOptions.additionalModelRequestFields,
|
|
482053
484503
|
output_config: {
|
|
482054
|
-
...(
|
|
484504
|
+
...(_o = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _o.output_config,
|
|
482055
484505
|
effort: maxReasoningEffort
|
|
482056
484506
|
}
|
|
482057
484507
|
};
|
|
@@ -482062,7 +484512,7 @@ var init_dist3 = __esm({
|
|
|
482062
484512
|
} : {
|
|
482063
484513
|
...bedrockOptions.additionalModelRequestFields,
|
|
482064
484514
|
reasoning: {
|
|
482065
|
-
...(
|
|
484515
|
+
...(_p = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _p.reasoning,
|
|
482066
484516
|
effort: maxReasoningEffort
|
|
482067
484517
|
}
|
|
482068
484518
|
};
|
|
@@ -482081,7 +484531,7 @@ var init_dist3 = __esm({
|
|
|
482081
484531
|
bedrockOptions.additionalModelRequestFields = {
|
|
482082
484532
|
...bedrockOptions.additionalModelRequestFields,
|
|
482083
484533
|
output_config: {
|
|
482084
|
-
...(
|
|
484534
|
+
...(_q = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _q.output_config,
|
|
482085
484535
|
format: {
|
|
482086
484536
|
type: "json_schema",
|
|
482087
484537
|
schema: (0, import_internal2.sanitizeJsonSchema)(responseFormat.schema)
|
|
@@ -482113,7 +484563,7 @@ var init_dist3 = __esm({
|
|
|
482113
484563
|
details: "topK is not supported when thinking is enabled"
|
|
482114
484564
|
});
|
|
482115
484565
|
}
|
|
482116
|
-
const hasAnyTools = ((
|
|
484566
|
+
const hasAnyTools = ((_s = (_r = toolConfig.tools) == null ? void 0 : _r.length) != null ? _s : 0) > 0 || additionalTools;
|
|
482117
484567
|
let filteredPrompt = prompt;
|
|
482118
484568
|
if (!hasAnyTools) {
|
|
482119
484569
|
const hasToolContent = prompt.some(
|
|
@@ -482155,6 +484605,7 @@ var init_dist3 = __esm({
|
|
|
482155
484605
|
reasoningConfig: _,
|
|
482156
484606
|
additionalModelRequestFields: __,
|
|
482157
484607
|
serviceTier: ___,
|
|
484608
|
+
structuredOutputMode: ____,
|
|
482158
484609
|
...filteredBedrockOptions
|
|
482159
484610
|
} = (providerOptions == null ? void 0 : providerOptions.bedrock) || {};
|
|
482160
484611
|
const additionalModelResponseFieldPaths = isAnthropicModel ? ["/delta/stop_sequence"] : void 0;
|
|
@@ -482189,7 +484640,7 @@ var init_dist3 = __esm({
|
|
|
482189
484640
|
return combineHeaders(await resolve(this.config.headers), headers);
|
|
482190
484641
|
}
|
|
482191
484642
|
async doGenerate(options) {
|
|
482192
|
-
var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
484643
|
+
var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
482193
484644
|
const {
|
|
482194
484645
|
command: args,
|
|
482195
484646
|
warnings,
|
|
@@ -482218,10 +484669,12 @@ var init_dist3 = __esm({
|
|
|
482218
484669
|
let isJsonResponseFromTool = false;
|
|
482219
484670
|
const jsonObjectTextExtractor = usesJsonInstruction ? new JsonObjectTextExtractor() : void 0;
|
|
482220
484671
|
for (const part of response.output.message.content) {
|
|
482221
|
-
|
|
484672
|
+
const citationText = (_b16 = (_a17 = part.citationsContent) == null ? void 0 : _a17.content) == null ? void 0 : _b16.map((generatedContent) => generatedContent.text).filter((text2) => text2 != null).join("");
|
|
484673
|
+
const text = (_c = part.text) != null ? _c : citationText ? citationText : void 0;
|
|
484674
|
+
if (text != null) {
|
|
482222
484675
|
content.push({
|
|
482223
484676
|
type: "text",
|
|
482224
|
-
text: (
|
|
484677
|
+
text: (_d = jsonObjectTextExtractor == null ? void 0 : jsonObjectTextExtractor.process(text)) != null ? _d : text
|
|
482225
484678
|
});
|
|
482226
484679
|
}
|
|
482227
484680
|
if (part.reasoningContent) {
|
|
@@ -482244,7 +484697,7 @@ var init_dist3 = __esm({
|
|
|
482244
484697
|
text: "",
|
|
482245
484698
|
providerMetadata: {
|
|
482246
484699
|
bedrock: {
|
|
482247
|
-
redactedData: (
|
|
484700
|
+
redactedData: (_e = part.reasoningContent.redactedReasoning.data) != null ? _e : ""
|
|
482248
484701
|
}
|
|
482249
484702
|
}
|
|
482250
484703
|
});
|
|
@@ -482261,7 +484714,7 @@ var init_dist3 = __esm({
|
|
|
482261
484714
|
}
|
|
482262
484715
|
}
|
|
482263
484716
|
if (part.toolUse) {
|
|
482264
|
-
const isJsonResponseTool = usesJsonResponseTool && part.toolUse.name
|
|
484717
|
+
const isJsonResponseTool = usesJsonResponseTool && isJsonResponseToolName(part.toolUse.name);
|
|
482265
484718
|
if (isJsonResponseTool) {
|
|
482266
484719
|
isJsonResponseFromTool = true;
|
|
482267
484720
|
content.push({
|
|
@@ -482270,17 +484723,17 @@ var init_dist3 = __esm({
|
|
|
482270
484723
|
});
|
|
482271
484724
|
} else {
|
|
482272
484725
|
const isMistral = isMistralModel(this.modelId);
|
|
482273
|
-
const rawToolCallId = (
|
|
484726
|
+
const rawToolCallId = (_g = (_f = part.toolUse) == null ? void 0 : _f.toolUseId) != null ? _g : this.config.generateId();
|
|
482274
484727
|
content.push({
|
|
482275
484728
|
type: "tool-call",
|
|
482276
484729
|
toolCallId: normalizeToolCallId(rawToolCallId, isMistral),
|
|
482277
|
-
toolName: (
|
|
482278
|
-
input: JSON.stringify((
|
|
484730
|
+
toolName: (_i = (_h = part.toolUse) == null ? void 0 : _h.name) != null ? _i : `tool-${this.config.generateId()}`,
|
|
484731
|
+
input: JSON.stringify((_k = (_j = part.toolUse) == null ? void 0 : _j.input) != null ? _k : {})
|
|
482279
484732
|
});
|
|
482280
484733
|
}
|
|
482281
484734
|
}
|
|
482282
484735
|
}
|
|
482283
|
-
const stopSequence = (
|
|
484736
|
+
const stopSequence = (_n = (_m = (_l = response.additionalModelResponseFields) == null ? void 0 : _l.delta) == null ? void 0 : _m.stop_sequence) != null ? _n : null;
|
|
482284
484737
|
const providerMetadata = response.trace || response.usage || response.performanceConfig || response.serviceTier || isJsonResponseFromTool || stopSequence ? {
|
|
482285
484738
|
bedrock: {
|
|
482286
484739
|
...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
|
|
@@ -482290,7 +484743,7 @@ var init_dist3 = __esm({
|
|
|
482290
484743
|
...response.serviceTier && {
|
|
482291
484744
|
serviceTier: response.serviceTier
|
|
482292
484745
|
},
|
|
482293
|
-
...(((
|
|
484746
|
+
...(((_o = response.usage) == null ? void 0 : _o.cacheWriteInputTokens) != null || ((_p = response.usage) == null ? void 0 : _p.cacheDetails) != null) && {
|
|
482294
484747
|
usage: {
|
|
482295
484748
|
...response.usage.cacheWriteInputTokens != null && {
|
|
482296
484749
|
cacheWriteInputTokens: response.usage.cacheWriteInputTokens
|
|
@@ -482311,11 +484764,11 @@ var init_dist3 = __esm({
|
|
|
482311
484764
|
response.stopReason,
|
|
482312
484765
|
isJsonResponseFromTool
|
|
482313
484766
|
),
|
|
482314
|
-
raw: (
|
|
484767
|
+
raw: (_q = response.stopReason) != null ? _q : void 0
|
|
482315
484768
|
},
|
|
482316
484769
|
usage: convertBedrockUsage(response.usage),
|
|
482317
484770
|
response: {
|
|
482318
|
-
id: (
|
|
484771
|
+
id: (_r = responseHeaders == null ? void 0 : responseHeaders["x-amzn-requestid"]) != null ? _r : void 0,
|
|
482319
484772
|
timestamp: (responseHeaders == null ? void 0 : responseHeaders["date"]) != null ? new Date(responseHeaders["date"]) : void 0,
|
|
482320
484773
|
modelId: this.modelId,
|
|
482321
484774
|
headers: responseHeaders
|
|
@@ -482596,7 +485049,7 @@ var init_dist3 = __esm({
|
|
|
482596
485049
|
if (((_q = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _q.toolUse) != null) {
|
|
482597
485050
|
const toolUse = contentBlockStart.start.toolUse;
|
|
482598
485051
|
const blockIndex = contentBlockStart.contentBlockIndex;
|
|
482599
|
-
const isJsonResponseTool = usesJsonResponseTool && toolUse.name
|
|
485052
|
+
const isJsonResponseTool = usesJsonResponseTool && isJsonResponseToolName(toolUse.name);
|
|
482600
485053
|
const normalizedToolCallId = normalizeToolCallId(
|
|
482601
485054
|
toolUse.toolUseId,
|
|
482602
485055
|
isMistral
|
|
@@ -482756,6 +485209,13 @@ var init_dist3 = __esm({
|
|
|
482756
485209
|
content: external_exports.array(
|
|
482757
485210
|
external_exports.object({
|
|
482758
485211
|
text: external_exports.string().nullish(),
|
|
485212
|
+
citationsContent: external_exports.object({
|
|
485213
|
+
content: external_exports.array(
|
|
485214
|
+
external_exports.object({
|
|
485215
|
+
text: external_exports.string().nullish()
|
|
485216
|
+
})
|
|
485217
|
+
).nullish()
|
|
485218
|
+
}).nullish(),
|
|
482759
485219
|
toolUse: BedrockToolUseSchema.nullish(),
|
|
482760
485220
|
reasoningContent: external_exports.union([
|
|
482761
485221
|
external_exports.object({
|
|
@@ -483218,7 +485678,7 @@ var init_dist3 = __esm({
|
|
|
483218
485678
|
details: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
483219
485679
|
preview: external_exports.unknown().optional()
|
|
483220
485680
|
});
|
|
483221
|
-
|
|
485681
|
+
VERSION3 = true ? "4.0.172" : 0;
|
|
483222
485682
|
bedrockRerankingResponseSchema = lazySchema(
|
|
483223
485683
|
() => zodSchema(
|
|
483224
485684
|
external_exports.object({
|
|
@@ -483336,10 +485796,17 @@ function createProviderInstance(config2) {
|
|
|
483336
485796
|
...config2.baseURL && { baseURL: config2.baseURL }
|
|
483337
485797
|
});
|
|
483338
485798
|
case "openai": {
|
|
485799
|
+
if (config2.baseURL) {
|
|
485800
|
+
const provider = createOpenAICompatible({
|
|
485801
|
+
name: "openai-compatible",
|
|
485802
|
+
baseURL: config2.baseURL,
|
|
485803
|
+
apiKey: config2.apiKey
|
|
485804
|
+
});
|
|
485805
|
+
return provider;
|
|
485806
|
+
}
|
|
483339
485807
|
const openai = (0, import_openai.createOpenAI)({
|
|
483340
485808
|
compatibility: "strict",
|
|
483341
|
-
apiKey: config2.apiKey
|
|
483342
|
-
...config2.baseURL && { baseURL: config2.baseURL }
|
|
485809
|
+
apiKey: config2.apiKey
|
|
483343
485810
|
});
|
|
483344
485811
|
const chatProvider = (modelId, settings) => openai.chat(modelId, settings);
|
|
483345
485812
|
chatProvider.chat = openai.chat.bind(openai);
|
|
@@ -483419,8 +485886,9 @@ var init_provider = __esm({
|
|
|
483419
485886
|
"use strict";
|
|
483420
485887
|
import_anthropic = __nccwpck_require__(98655);
|
|
483421
485888
|
import_openai = __nccwpck_require__(75917);
|
|
485889
|
+
init_dist4();
|
|
483422
485890
|
import_google = __nccwpck_require__(47110);
|
|
483423
|
-
|
|
485891
|
+
init_dist5();
|
|
483424
485892
|
DEFAULT_MODELS = {
|
|
483425
485893
|
anthropic: "claude-sonnet-4-6",
|
|
483426
485894
|
openai: "gpt-5.2",
|
|
@@ -489521,7 +491989,7 @@ var require_parser = __commonJS({
|
|
|
489521
491989
|
/* LispType.None */
|
|
489522
491990
|
});
|
|
489523
491991
|
var lispTypes = /* @__PURE__ */ new Map();
|
|
489524
|
-
var
|
|
491992
|
+
var ParseError2 = class extends Error {
|
|
489525
491993
|
constructor(message, code) {
|
|
489526
491994
|
super(message + ": " + code.substring(0, 40));
|
|
489527
491995
|
this.code = code;
|
|
@@ -490456,7 +492924,7 @@ var require_parser = __commonJS({
|
|
|
490456
492924
|
lispTypes.get(type)?.(constants, type, part, res, expect, ctx);
|
|
490457
492925
|
} catch (e) {
|
|
490458
492926
|
if (topLevel && e instanceof SyntaxError) {
|
|
490459
|
-
throw new
|
|
492927
|
+
throw new ParseError2(e.message, str);
|
|
490460
492928
|
}
|
|
490461
492929
|
throw e;
|
|
490462
492930
|
}
|
|
@@ -490468,7 +492936,7 @@ var require_parser = __commonJS({
|
|
|
490468
492936
|
}
|
|
490469
492937
|
if (!res && part.length) {
|
|
490470
492938
|
if (topLevel) {
|
|
490471
|
-
throw new
|
|
492939
|
+
throw new ParseError2(`Unexpected token after ${lastType}: ${part.char(0)}`, str);
|
|
490472
492940
|
}
|
|
490473
492941
|
throw new SyntaxError(`Unexpected token after ${lastType}: ${part.char(0)}`);
|
|
490474
492942
|
}
|
|
@@ -490763,7 +493231,7 @@ var require_parser = __commonJS({
|
|
|
490763
493231
|
}
|
|
490764
493232
|
function parse11(code, eager = false, expression = false) {
|
|
490765
493233
|
if (typeof code !== "string")
|
|
490766
|
-
throw new
|
|
493234
|
+
throw new ParseError2(`Cannot parse ${code}`, code);
|
|
490767
493235
|
let str = " " + code;
|
|
490768
493236
|
const constants = { strings: [], literals: [], regexes: [], eager };
|
|
490769
493237
|
str = extractConstants(constants, str).str;
|
|
@@ -490773,7 +493241,7 @@ var require_parser = __commonJS({
|
|
|
490773
493241
|
}
|
|
490774
493242
|
return { tree: lispifyFunction(new utils.CodeString(str), constants, expression), constants };
|
|
490775
493243
|
}
|
|
490776
|
-
exports2.ParseError =
|
|
493244
|
+
exports2.ParseError = ParseError2;
|
|
490777
493245
|
exports2.checkRegex = checkRegex;
|
|
490778
493246
|
exports2.default = parse11;
|
|
490779
493247
|
exports2.expectTypes = expectTypes;
|
|
@@ -511115,12 +513583,12 @@ var init_apply = __esm({
|
|
|
511115
513583
|
});
|
|
511116
513584
|
|
|
511117
513585
|
// node_modules/lodash-es/noop.js
|
|
511118
|
-
function
|
|
513586
|
+
function noop2() {
|
|
511119
513587
|
}
|
|
511120
513588
|
var noop_default;
|
|
511121
513589
|
var init_noop = __esm({
|
|
511122
513590
|
"node_modules/lodash-es/noop.js"() {
|
|
511123
|
-
noop_default =
|
|
513591
|
+
noop_default = noop2;
|
|
511124
513592
|
}
|
|
511125
513593
|
});
|
|
511126
513594
|
|
|
@@ -533069,9 +535537,9 @@ var require_arrayIncludesWith = __commonJS({
|
|
|
533069
535537
|
// node_modules/lodash/noop.js
|
|
533070
535538
|
var require_noop = __commonJS({
|
|
533071
535539
|
"node_modules/lodash/noop.js"(exports2, module2) {
|
|
533072
|
-
function
|
|
535540
|
+
function noop3() {
|
|
533073
535541
|
}
|
|
533074
|
-
module2.exports =
|
|
535542
|
+
module2.exports = noop3;
|
|
533075
535543
|
}
|
|
533076
535544
|
});
|
|
533077
535545
|
|
|
@@ -533079,10 +535547,10 @@ var require_noop = __commonJS({
|
|
|
533079
535547
|
var require_createSet = __commonJS({
|
|
533080
535548
|
"node_modules/lodash/_createSet.js"(exports2, module2) {
|
|
533081
535549
|
var Set3 = require_Set();
|
|
533082
|
-
var
|
|
535550
|
+
var noop3 = require_noop();
|
|
533083
535551
|
var setToArray2 = require_setToArray();
|
|
533084
535552
|
var INFINITY5 = 1 / 0;
|
|
533085
|
-
var createSet2 = !(Set3 && 1 / setToArray2(new Set3([, -0]))[1] == INFINITY5) ?
|
|
535553
|
+
var createSet2 = !(Set3 && 1 / setToArray2(new Set3([, -0]))[1] == INFINITY5) ? noop3 : function(values2) {
|
|
533086
535554
|
return new Set3(values2);
|
|
533087
535555
|
};
|
|
533088
535556
|
module2.exports = createSet2;
|
|
@@ -544199,7 +546667,8 @@ var require_utils2 = __commonJS({
|
|
|
544199
546667
|
"node_modules/fast-uri/lib/utils.js"(exports2, module2) {
|
|
544200
546668
|
"use strict";
|
|
544201
546669
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
544202
|
-
var
|
|
546670
|
+
var isIPv42 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
546671
|
+
var isPort = RegExp.prototype.test.bind(/^\d*$/u);
|
|
544203
546672
|
var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
544204
546673
|
var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
544205
546674
|
var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
|
|
@@ -544299,7 +546768,7 @@ var require_utils2 = __commonJS({
|
|
|
544299
546768
|
const part = parts[i];
|
|
544300
546769
|
if (part === "") return void 0;
|
|
544301
546770
|
if (part.indexOf(".") !== -1) {
|
|
544302
|
-
if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !
|
|
546771
|
+
if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv42(part)) return void 0;
|
|
544303
546772
|
hextetCount += 2;
|
|
544304
546773
|
continue;
|
|
544305
546774
|
}
|
|
@@ -544650,7 +547119,7 @@ var require_utils2 = __commonJS({
|
|
|
544650
547119
|
}
|
|
544651
547120
|
if (component.host !== void 0) {
|
|
544652
547121
|
let host = component.host;
|
|
544653
|
-
if (!
|
|
547122
|
+
if (!isIPv42(host)) {
|
|
544654
547123
|
let ipV6res = normalizeIPv6(host);
|
|
544655
547124
|
if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
|
|
544656
547125
|
host = normalizePercentEncoding(host, true);
|
|
@@ -544665,8 +547134,12 @@ var require_utils2 = __commonJS({
|
|
|
544665
547134
|
uriTokens.push(host);
|
|
544666
547135
|
}
|
|
544667
547136
|
if (typeof component.port === "number" || typeof component.port === "string") {
|
|
547137
|
+
const port = String(component.port);
|
|
547138
|
+
if (!isPort(port)) {
|
|
547139
|
+
throw new TypeError("URI port is malformed.");
|
|
547140
|
+
}
|
|
544668
547141
|
uriTokens.push(":");
|
|
544669
|
-
uriTokens.push(
|
|
547142
|
+
uriTokens.push(port);
|
|
544670
547143
|
}
|
|
544671
547144
|
return uriTokens.length ? uriTokens.join("") : void 0;
|
|
544672
547145
|
}
|
|
@@ -544683,7 +547156,7 @@ var require_utils2 = __commonJS({
|
|
|
544683
547156
|
encodeFragment,
|
|
544684
547157
|
escapePreservingEscapes,
|
|
544685
547158
|
removeDotSegments,
|
|
544686
|
-
isIPv4,
|
|
547159
|
+
isIPv4: isIPv42,
|
|
544687
547160
|
isUUID,
|
|
544688
547161
|
normalizeIPv6,
|
|
544689
547162
|
stringArrayToHexStripped
|
|
@@ -544906,7 +547379,7 @@ var require_schemes = __commonJS({
|
|
|
544906
547379
|
var require_fast_uri = __commonJS({
|
|
544907
547380
|
"node_modules/fast-uri/index.js"(exports2, module2) {
|
|
544908
547381
|
"use strict";
|
|
544909
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2();
|
|
547382
|
+
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4: isIPv42, nonSimpleDomain } = require_utils2();
|
|
544910
547383
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
544911
547384
|
var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
544912
547385
|
var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
@@ -544951,7 +547424,7 @@ var require_fast_uri = __commonJS({
|
|
|
544951
547424
|
const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
|
|
544952
547425
|
const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
|
|
544953
547426
|
const resolvedHost = resolved.host;
|
|
544954
|
-
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (
|
|
547427
|
+
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv42(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
|
|
544955
547428
|
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
|
|
544956
547429
|
const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
|
|
544957
547430
|
if (resolved.error && !encodedASCIIHost) {
|
|
@@ -545109,12 +547582,15 @@ var require_fast_uri = __commonJS({
|
|
|
545109
547582
|
}
|
|
545110
547583
|
return false;
|
|
545111
547584
|
}
|
|
547585
|
+
function isIPLiteral(host) {
|
|
547586
|
+
return host[0] === "[" && host[host.length - 1] === "]";
|
|
547587
|
+
}
|
|
545112
547588
|
function hasMalformedComponentPercentEncoding(matches) {
|
|
545113
547589
|
const host = matches[4];
|
|
545114
|
-
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host
|
|
547590
|
+
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
|
|
545115
547591
|
}
|
|
545116
547592
|
function canonicalizeHost(parsed, options, schemeHandler, isIP) {
|
|
545117
|
-
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host
|
|
547593
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
545118
547594
|
try {
|
|
545119
547595
|
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
545120
547596
|
} catch (e) {
|
|
@@ -545199,12 +547675,13 @@ var require_fast_uri = __commonJS({
|
|
|
545199
547675
|
malformedAuthorityOrPort = true;
|
|
545200
547676
|
}
|
|
545201
547677
|
if (parsed.host) {
|
|
545202
|
-
const ipv4result =
|
|
547678
|
+
const ipv4result = isIPv42(parsed.host);
|
|
545203
547679
|
if (ipv4result === false) {
|
|
545204
|
-
const bracketedIPLiteral = parsed.host
|
|
547680
|
+
const bracketedIPLiteral = isIPLiteral(parsed.host);
|
|
547681
|
+
const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
|
|
545205
547682
|
const ipv6result = normalizeIPv6(parsed.host);
|
|
545206
547683
|
isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
|
|
545207
|
-
malformedIPLiteral =
|
|
547684
|
+
malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
|
|
545208
547685
|
parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
|
|
545209
547686
|
if (malformedIPLiteral) {
|
|
545210
547687
|
parsed.error = parsed.error || "URI host is malformed.";
|
|
@@ -545227,7 +547704,9 @@ var require_fast_uri = __commonJS({
|
|
|
545227
547704
|
parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
|
|
545228
547705
|
}
|
|
545229
547706
|
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
|
|
545230
|
-
|
|
547707
|
+
if (!malformedIPLiteral) {
|
|
547708
|
+
malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
|
|
547709
|
+
}
|
|
545231
547710
|
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
545232
547711
|
if (uri.indexOf("%") !== -1) {
|
|
545233
547712
|
if (parsed.host !== void 0 && !malformedIPLiteral) {
|
|
@@ -549912,51 +552391,23 @@ function createTransport(serverConfig) {
|
|
|
549912
552391
|
throw new Error(`Invalid WebSocket URL: ${url2}`);
|
|
549913
552392
|
}
|
|
549914
552393
|
case "http":
|
|
549915
|
-
case "streamable":
|
|
552394
|
+
case "streamable": {
|
|
549916
552395
|
if (!url2) {
|
|
549917
552396
|
throw new Error("HTTP transport requires a URL");
|
|
549918
552397
|
}
|
|
549919
|
-
|
|
549920
|
-
|
|
549921
|
-
|
|
549922
|
-
}
|
|
549923
|
-
}
|
|
549924
|
-
function createHttpTransport(url2) {
|
|
549925
|
-
return {
|
|
549926
|
-
async start() {
|
|
549927
|
-
const response = await fetch(`${url2}/initialize`, {
|
|
549928
|
-
method: "POST",
|
|
549929
|
-
headers: { "Content-Type": "application/json" },
|
|
549930
|
-
body: JSON.stringify({
|
|
549931
|
-
protocolVersion: "2024-11-05",
|
|
549932
|
-
capabilities: {}
|
|
549933
|
-
})
|
|
549934
|
-
});
|
|
549935
|
-
if (!response.ok) {
|
|
549936
|
-
throw new Error(`HTTP initialization failed: ${response.statusText}`);
|
|
552398
|
+
const requestInit = {};
|
|
552399
|
+
if (serverConfig.headers && typeof serverConfig.headers === "object") {
|
|
552400
|
+
requestInit.headers = { ...serverConfig.headers };
|
|
549937
552401
|
}
|
|
549938
|
-
return
|
|
549939
|
-
|
|
549940
|
-
async send(message) {
|
|
549941
|
-
const response = await fetch(`${url2}/message`, {
|
|
549942
|
-
method: "POST",
|
|
549943
|
-
headers: { "Content-Type": "application/json" },
|
|
549944
|
-
body: JSON.stringify(message)
|
|
549945
|
-
});
|
|
549946
|
-
if (!response.ok) {
|
|
549947
|
-
throw new Error(`HTTP request failed: ${response.statusText}`);
|
|
549948
|
-
}
|
|
549949
|
-
return response.json();
|
|
549950
|
-
},
|
|
549951
|
-
async close() {
|
|
549952
|
-
await fetch(`${url2}/close`, {
|
|
549953
|
-
method: "POST"
|
|
549954
|
-
}).catch(() => {
|
|
552402
|
+
return new import_streamableHttp.StreamableHTTPClientTransport(new URL(url2), {
|
|
552403
|
+
requestInit: Object.keys(requestInit).length > 0 ? requestInit : void 0
|
|
549955
552404
|
});
|
|
549956
552405
|
}
|
|
549957
|
-
|
|
552406
|
+
default:
|
|
552407
|
+
throw new Error(`Unknown transport type: ${transport}`);
|
|
552408
|
+
}
|
|
549958
552409
|
}
|
|
549959
|
-
var import_client, import_stdio, import_sse, import_websocket, MCPClientManager;
|
|
552410
|
+
var import_client, import_stdio, import_sse, import_websocket, import_streamableHttp, MCPClientManager;
|
|
549960
552411
|
var init_client = __esm({
|
|
549961
552412
|
"src/agent/mcp/client.js"() {
|
|
549962
552413
|
"use strict";
|
|
@@ -549964,6 +552415,7 @@ var init_client = __esm({
|
|
|
549964
552415
|
import_stdio = __nccwpck_require__(21237);
|
|
549965
552416
|
import_sse = __nccwpck_require__(40013);
|
|
549966
552417
|
import_websocket = __nccwpck_require__(36615);
|
|
552418
|
+
import_streamableHttp = __nccwpck_require__(47894);
|
|
549967
552419
|
init_config2();
|
|
549968
552420
|
MCPClientManager = class {
|
|
549969
552421
|
constructor(options = {}) {
|
|
@@ -550665,7 +553117,7 @@ function abortable(promise2, signal) {
|
|
|
550665
553117
|
});
|
|
550666
553118
|
});
|
|
550667
553119
|
}
|
|
550668
|
-
var import_http, import_events2, import_crypto5, import_server, import_sse2,
|
|
553120
|
+
var import_http, import_events2, import_crypto5, import_server, import_sse2, import_streamableHttp2, import_ai5, import_types5, TOOL_DESCRIPTORS, ARGUMENT_DOMAIN, GOVERNED_CODEX_PROFILE_V2, GOVERNED_CALL_LIMIT, InMemoryEventStore, BuiltInMCPServer;
|
|
550669
553121
|
var init_built_in_server = __esm({
|
|
550670
553122
|
"src/agent/mcp/built-in-server.js"() {
|
|
550671
553123
|
"use strict";
|
|
@@ -550674,7 +553126,7 @@ var init_built_in_server = __esm({
|
|
|
550674
553126
|
import_crypto5 = __nccwpck_require__(76982);
|
|
550675
553127
|
import_server = __nccwpck_require__(53420);
|
|
550676
553128
|
import_sse2 = __nccwpck_require__(4449);
|
|
550677
|
-
|
|
553129
|
+
import_streamableHttp2 = __nccwpck_require__(98722);
|
|
550678
553130
|
import_ai5 = __nccwpck_require__(43409);
|
|
550679
553131
|
init_common();
|
|
550680
553132
|
import_types5 = __nccwpck_require__(19579);
|
|
@@ -550928,7 +553380,7 @@ var init_built_in_server = __esm({
|
|
|
550928
553380
|
console.log("[MCP] Creating new Streamable HTTP transport for initialization");
|
|
550929
553381
|
}
|
|
550930
553382
|
const eventStore = new InMemoryEventStore();
|
|
550931
|
-
transport = new
|
|
553383
|
+
transport = new import_streamableHttp2.StreamableHTTPServerTransport({
|
|
550932
553384
|
sessionIdGenerator: () => (0, import_crypto5.randomUUID)(),
|
|
550933
553385
|
eventStore,
|
|
550934
553386
|
// Enable resumability
|
|
@@ -560198,7 +562650,7 @@ var init_governed_codex_profile = __esm({
|
|
|
560198
562650
|
function governedAttestationPredicate(error40) {
|
|
560199
562651
|
return error40 instanceof TypeError ? GOVERNED_ATTESTATION_ERROR_PREDICATES.get(error40.message) ?? null : null;
|
|
560200
562652
|
}
|
|
560201
|
-
function governedAnswerFailure(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null) {
|
|
562653
|
+
function governedAnswerFailure(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null, providerEngineFailureBoundary = null) {
|
|
560202
562654
|
return new GovernedAnswerFailure(
|
|
560203
562655
|
stage,
|
|
560204
562656
|
nativeEventFailureBoundary,
|
|
@@ -560206,21 +562658,23 @@ function governedAnswerFailure(stage, nativeEventFailureBoundary = null, nativeE
|
|
|
560206
562658
|
nativeEventFailureCorrelationOperand,
|
|
560207
562659
|
nativeEventFailureAttestationPredicate,
|
|
560208
562660
|
schemaResultValidationSubreason,
|
|
560209
|
-
schemaResultValidationKeyword
|
|
562661
|
+
schemaResultValidationKeyword,
|
|
562662
|
+
providerEngineFailureBoundary
|
|
560210
562663
|
);
|
|
560211
562664
|
}
|
|
560212
|
-
function normalizeGovernedAnswerFailure(error40, fallback = "unknown", nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null) {
|
|
562665
|
+
function normalizeGovernedAnswerFailure(error40, fallback = "unknown", nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null, providerEngineFailureBoundary = null, nativeEventFailureAttestationPredicate = null) {
|
|
560213
562666
|
return error40 instanceof GovernedAnswerFailure ? error40 : governedAnswerFailure(
|
|
560214
562667
|
fallback,
|
|
560215
562668
|
nativeEventFailureBoundary,
|
|
560216
562669
|
nativeEventFailureSubreason,
|
|
560217
562670
|
nativeEventFailureCorrelationOperand,
|
|
560218
|
-
fallback === "native_event_grammar" && nativeEventFailureBoundary === "live_envelope_session" && nativeEventFailureSubreason === "attestation" ? governedAttestationPredicate(error40) : null,
|
|
562671
|
+
fallback === "native_event_grammar" && nativeEventFailureBoundary === "live_envelope_session" && nativeEventFailureSubreason === "attestation" ? nativeEventFailureAttestationPredicate ?? governedAttestationPredicate(error40) : null,
|
|
560219
562672
|
schemaResultValidationSubreason,
|
|
560220
|
-
schemaResultValidationKeyword
|
|
562673
|
+
schemaResultValidationKeyword,
|
|
562674
|
+
providerEngineFailureBoundary
|
|
560221
562675
|
);
|
|
560222
562676
|
}
|
|
560223
|
-
var GOVERNED_ANSWER_FAILURE_STAGES, GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES, GOVERNED_NATIVE_EVENT_FAILURE_SUBREASONS, GOVERNED_NATIVE_EVENT_FAILURE_CORRELATION_OPERANDS, GOVERNED_NATIVE_EVENT_FAILURE_ATTESTATION_PREDICATES, GOVERNED_SCHEMA_RESULT_VALIDATION_SUBREASONS, GOVERNED_SCHEMA_RESULT_VALIDATION_KEYWORDS, GOVERNED_ATTESTATION_ERROR_PREDICATES, GovernedAnswerFailure;
|
|
562677
|
+
var GOVERNED_ANSWER_FAILURE_STAGES, GOVERNED_PROVIDER_ENGINE_FAILURE_BOUNDARIES, GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES, GOVERNED_NATIVE_EVENT_FAILURE_SUBREASONS, GOVERNED_NATIVE_EVENT_FAILURE_CORRELATION_OPERANDS, GOVERNED_NATIVE_EVENT_FAILURE_ATTESTATION_PREDICATES, GOVERNED_SCHEMA_RESULT_VALIDATION_SUBREASONS, GOVERNED_SCHEMA_RESULT_VALIDATION_KEYWORDS, GOVERNED_ATTESTATION_ERROR_PREDICATES, GovernedAnswerFailure;
|
|
560224
562678
|
var init_governed_answer_failure = __esm({
|
|
560225
562679
|
"src/agent/engines/governed-answer-failure.js"() {
|
|
560226
562680
|
"use strict";
|
|
@@ -560228,8 +562682,10 @@ var init_governed_answer_failure = __esm({
|
|
|
560228
562682
|
"native_event_grammar",
|
|
560229
562683
|
"provider_engine",
|
|
560230
562684
|
"schema_result_validation",
|
|
562685
|
+
"internal_contract",
|
|
560231
562686
|
"unknown"
|
|
560232
562687
|
]);
|
|
562688
|
+
GOVERNED_PROVIDER_ENGINE_FAILURE_BOUNDARIES = /* @__PURE__ */ new Set(["acquire", "query", "close"]);
|
|
560233
562689
|
GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES = /* @__PURE__ */ new Set([
|
|
560234
562690
|
"raw_item_predicate",
|
|
560235
562691
|
"live_envelope_session"
|
|
@@ -560273,7 +562729,9 @@ var init_governed_answer_failure = __esm({
|
|
|
560273
562729
|
"value_shape",
|
|
560274
562730
|
"kind",
|
|
560275
562731
|
"native_tool_evidence",
|
|
560276
|
-
"internal_contract"
|
|
562732
|
+
"internal_contract",
|
|
562733
|
+
"invocation_attestation",
|
|
562734
|
+
"native_capability_aggregate"
|
|
560277
562735
|
]);
|
|
560278
562736
|
GOVERNED_SCHEMA_RESULT_VALIDATION_SUBREASONS = /* @__PURE__ */ new Set([
|
|
560279
562737
|
"response_json",
|
|
@@ -560356,7 +562814,7 @@ var init_governed_answer_failure = __esm({
|
|
|
560356
562814
|
["Invalid profile capability overlap", "internal_contract"]
|
|
560357
562815
|
]);
|
|
560358
562816
|
GovernedAnswerFailure = class extends Error {
|
|
560359
|
-
constructor(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null) {
|
|
562817
|
+
constructor(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null, providerEngineFailureBoundary = null) {
|
|
560360
562818
|
super();
|
|
560361
562819
|
delete this.stack;
|
|
560362
562820
|
const answerFailureStage = GOVERNED_ANSWER_FAILURE_STAGES.has(stage) ? stage : "unknown";
|
|
@@ -560365,6 +562823,10 @@ var init_governed_answer_failure = __esm({
|
|
|
560365
562823
|
value: answerFailureStage,
|
|
560366
562824
|
enumerable: true
|
|
560367
562825
|
});
|
|
562826
|
+
if (answerFailureStage === "provider_engine") Object.defineProperty(this, "providerEngineFailureBoundary", {
|
|
562827
|
+
value: GOVERNED_PROVIDER_ENGINE_FAILURE_BOUNDARIES.has(providerEngineFailureBoundary) ? providerEngineFailureBoundary : null,
|
|
562828
|
+
enumerable: true
|
|
562829
|
+
});
|
|
560368
562830
|
if (answerFailureStage === "native_event_grammar") Object.defineProperty(this, "nativeEventFailureBoundary", {
|
|
560369
562831
|
value: GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES.has(nativeEventFailureBoundary) ? nativeEventFailureBoundary : null,
|
|
560370
562832
|
enumerable: true
|
|
@@ -561375,7 +563837,9 @@ async function createCodexEngine(options = {}) {
|
|
|
561375
563837
|
}
|
|
561376
563838
|
});
|
|
561377
563839
|
if (opts.abortSignal) {
|
|
561378
|
-
if (opts.abortSignal.aborted)
|
|
563840
|
+
if (opts.abortSignal.aborted) {
|
|
563841
|
+
throw governedProfile ? governedAnswerFailure("provider_engine", null, null, null, null, null, null, "query") : new Error("Codex query cancelled");
|
|
563842
|
+
}
|
|
561379
563843
|
abortHandler = () => {
|
|
561380
563844
|
void cleanup(new Error("Codex query cancelled")).catch(() => {
|
|
561381
563845
|
});
|
|
@@ -561408,7 +563872,16 @@ async function createCodexEngine(options = {}) {
|
|
|
561408
563872
|
try {
|
|
561409
563873
|
result = await resultPromise;
|
|
561410
563874
|
} catch (error40) {
|
|
561411
|
-
throw governedProfile ?
|
|
563875
|
+
throw governedProfile ? evidenceFailure || normalizeGovernedAnswerFailure(
|
|
563876
|
+
error40,
|
|
563877
|
+
"provider_engine",
|
|
563878
|
+
null,
|
|
563879
|
+
null,
|
|
563880
|
+
null,
|
|
563881
|
+
null,
|
|
563882
|
+
null,
|
|
563883
|
+
"query"
|
|
563884
|
+
) : error40;
|
|
561412
563885
|
}
|
|
561413
563886
|
eventHandlers.delete(reqId);
|
|
561414
563887
|
governedEvidenceHandlers.delete(reqId);
|
|
@@ -561426,17 +563899,50 @@ async function createCodexEngine(options = {}) {
|
|
|
561426
563899
|
profile: governedProfile,
|
|
561427
563900
|
events: governedProfile.version === "probe.governed-codex-profile/v2" ? [collected.sessionEvent, collected.capabilities.nativeTools] : [collected.sessionEvent]
|
|
561428
563901
|
});
|
|
563902
|
+
} catch (error40) {
|
|
563903
|
+
throw normalizeGovernedAnswerFailure(
|
|
563904
|
+
error40,
|
|
563905
|
+
"native_event_grammar",
|
|
563906
|
+
"live_envelope_session",
|
|
563907
|
+
"attestation"
|
|
563908
|
+
);
|
|
563909
|
+
}
|
|
563910
|
+
try {
|
|
561429
563911
|
probeMcpCallCount = governedProfile.version === "probe.governed-codex-profile/v2" ? governedProbeMcpCallCount(mcpServer?.getGovernedCallEvidence()) : 0;
|
|
561430
563912
|
} catch (error40) {
|
|
561431
|
-
throw normalizeGovernedAnswerFailure(
|
|
561432
|
-
|
|
561433
|
-
|
|
561434
|
-
|
|
561435
|
-
|
|
561436
|
-
|
|
561437
|
-
|
|
561438
|
-
|
|
561439
|
-
|
|
563913
|
+
throw normalizeGovernedAnswerFailure(
|
|
563914
|
+
error40,
|
|
563915
|
+
"native_event_grammar",
|
|
563916
|
+
"live_envelope_session",
|
|
563917
|
+
"attestation",
|
|
563918
|
+
null,
|
|
563919
|
+
null,
|
|
563920
|
+
null,
|
|
563921
|
+
null,
|
|
563922
|
+
"native_capability_aggregate"
|
|
563923
|
+
);
|
|
563924
|
+
}
|
|
563925
|
+
try {
|
|
563926
|
+
attestation = hasInvocationDigest ? externalBoundReceipt(internal, dispatch, invocationDigest, {
|
|
563927
|
+
nativeCallCount: collected.capabilities.nativeTools.total,
|
|
563928
|
+
probeMcpCallCount
|
|
563929
|
+
}) : externalReceipt(internal, {
|
|
563930
|
+
nativeCallCount: collected.capabilities.nativeTools.total,
|
|
563931
|
+
probeMcpCallCount
|
|
563932
|
+
});
|
|
563933
|
+
} catch (error40) {
|
|
563934
|
+
throw normalizeGovernedAnswerFailure(
|
|
563935
|
+
error40,
|
|
563936
|
+
"native_event_grammar",
|
|
563937
|
+
"live_envelope_session",
|
|
563938
|
+
"attestation",
|
|
563939
|
+
null,
|
|
563940
|
+
null,
|
|
563941
|
+
null,
|
|
563942
|
+
null,
|
|
563943
|
+
"invocation_attestation"
|
|
563944
|
+
);
|
|
563945
|
+
}
|
|
561440
563946
|
session.setConversationId(collected.sessionEvent.params.msg.session_id);
|
|
561441
563947
|
}
|
|
561442
563948
|
if (result && result.content && Array.isArray(result.content)) {
|
|
@@ -561473,7 +563979,7 @@ async function createCodexEngine(options = {}) {
|
|
|
561473
563979
|
}
|
|
561474
563980
|
};
|
|
561475
563981
|
} catch (error40) {
|
|
561476
|
-
if (governedProfile) error40 = normalizeGovernedAnswerFailure(error40, "
|
|
563982
|
+
if (governedProfile) error40 = normalizeGovernedAnswerFailure(error40, "internal_contract");
|
|
561477
563983
|
queryError = error40;
|
|
561478
563984
|
if (debug) {
|
|
561479
563985
|
console.error("[DEBUG] Codex query error:", error40);
|
|
@@ -561488,7 +563994,16 @@ async function createCodexEngine(options = {}) {
|
|
|
561488
563994
|
try {
|
|
561489
563995
|
await cleanup();
|
|
561490
563996
|
} catch (cleanupError) {
|
|
561491
|
-
if (!queryError) throw
|
|
563997
|
+
if (!queryError) throw normalizeGovernedAnswerFailure(
|
|
563998
|
+
cleanupError,
|
|
563999
|
+
"provider_engine",
|
|
564000
|
+
null,
|
|
564001
|
+
null,
|
|
564002
|
+
null,
|
|
564003
|
+
null,
|
|
564004
|
+
null,
|
|
564005
|
+
"close"
|
|
564006
|
+
);
|
|
561492
564007
|
}
|
|
561493
564008
|
}
|
|
561494
564009
|
}
|
|
@@ -563575,7 +566090,6 @@ var init_ProbeAgent = __esm({
|
|
|
563575
566090
|
agent: this,
|
|
563576
566091
|
// Pass reference to ProbeAgent for tool access
|
|
563577
566092
|
systemPrompt,
|
|
563578
|
-
customPrompt: this.customPrompt,
|
|
563579
566093
|
sessionId: this.options?.sessionId,
|
|
563580
566094
|
debug: this.debug,
|
|
563581
566095
|
allowedTools: this.allowedTools,
|
|
@@ -563592,7 +566106,18 @@ var init_ProbeAgent = __esm({
|
|
|
563592
566106
|
}
|
|
563593
566107
|
return this.engine;
|
|
563594
566108
|
} catch (error40) {
|
|
563595
|
-
if (this.governedCodexProfile)
|
|
566109
|
+
if (this.governedCodexProfile) {
|
|
566110
|
+
throw normalizeGovernedAnswerFailure(
|
|
566111
|
+
error40,
|
|
566112
|
+
"provider_engine",
|
|
566113
|
+
null,
|
|
566114
|
+
null,
|
|
566115
|
+
null,
|
|
566116
|
+
null,
|
|
566117
|
+
null,
|
|
566118
|
+
"acquire"
|
|
566119
|
+
);
|
|
566120
|
+
}
|
|
563596
566121
|
console.warn("[WARNING] Failed to load Codex CLI engine:", error40.message);
|
|
563597
566122
|
console.warn("[WARNING] Falling back to Vercel AI SDK");
|
|
563598
566123
|
this.clientApiProvider = null;
|
|
@@ -564273,7 +566798,7 @@ Workspace: ${this.allowedFolders.join(", ")}`;
|
|
|
564273
566798
|
const { prompt } = this._prepareGovernedAnswerPrompt(message, options);
|
|
564274
566799
|
const systemPrompt = await this._getCachedCodexNativeSystemPrompt();
|
|
564275
566800
|
const { previewGovernedCodexInitialDispatch: previewGovernedCodexInitialDispatch2 } = await Promise.resolve().then(() => (init_codex(), codex_exports));
|
|
564276
|
-
return previewGovernedCodexInitialDispatch2({ systemPrompt,
|
|
566801
|
+
return previewGovernedCodexInitialDispatch2({ systemPrompt, prompt });
|
|
564277
566802
|
}
|
|
564278
566803
|
/**
|
|
564279
566804
|
* Get the system message with instructions for the AI (XML Tool Format)
|
|
@@ -564463,38 +566988,99 @@ You are working with a workspace. Available paths: ${workspaceDesc}
|
|
|
564463
566988
|
try {
|
|
564464
566989
|
try {
|
|
564465
566990
|
engine = await this.getEngine();
|
|
564466
|
-
} catch {
|
|
564467
|
-
throw
|
|
566991
|
+
} catch (error40) {
|
|
566992
|
+
throw normalizeGovernedAnswerFailure(
|
|
566993
|
+
error40,
|
|
566994
|
+
"provider_engine",
|
|
566995
|
+
null,
|
|
566996
|
+
null,
|
|
566997
|
+
null,
|
|
566998
|
+
null,
|
|
566999
|
+
null,
|
|
567000
|
+
"acquire"
|
|
567001
|
+
);
|
|
564468
567002
|
}
|
|
564469
|
-
if (!engine?.query) throw governedAnswerFailure("
|
|
567003
|
+
if (!engine?.query) throw governedAnswerFailure("internal_contract");
|
|
564470
567004
|
const candidateChunks = [];
|
|
564471
567005
|
let runtimeAttestation;
|
|
564472
567006
|
let attestationCount = 0;
|
|
564473
567007
|
let nativeToolBatch;
|
|
564474
567008
|
let nativeToolBatchCount = 0;
|
|
564475
567009
|
const queryOptions = hasInvocationDigest ? { abortSignal: this._abortController.signal, invocationDigest } : { abortSignal: this._abortController.signal };
|
|
564476
|
-
|
|
564477
|
-
|
|
564478
|
-
|
|
564479
|
-
|
|
564480
|
-
|
|
564481
|
-
|
|
564482
|
-
|
|
564483
|
-
|
|
564484
|
-
|
|
567010
|
+
try {
|
|
567011
|
+
for await (const chunk of engine.query(prompt, queryOptions)) {
|
|
567012
|
+
if (chunk.type === "text" && chunk.content) candidateChunks.push(chunk.content);
|
|
567013
|
+
else if (chunk.type === "metadata" && chunk.data?.attestation) {
|
|
567014
|
+
runtimeAttestation = chunk.data.attestation;
|
|
567015
|
+
attestationCount++;
|
|
567016
|
+
} else if (chunk.type === "toolBatch") {
|
|
567017
|
+
nativeToolBatch = chunk;
|
|
567018
|
+
nativeToolBatchCount++;
|
|
567019
|
+
} else if (chunk.type === "error") {
|
|
567020
|
+
throw normalizeGovernedAnswerFailure(
|
|
567021
|
+
chunk.error,
|
|
567022
|
+
"provider_engine",
|
|
567023
|
+
null,
|
|
567024
|
+
null,
|
|
567025
|
+
null,
|
|
567026
|
+
null,
|
|
567027
|
+
null,
|
|
567028
|
+
"query"
|
|
567029
|
+
);
|
|
567030
|
+
}
|
|
567031
|
+
}
|
|
567032
|
+
} catch (error40) {
|
|
567033
|
+
throw normalizeGovernedAnswerFailure(
|
|
567034
|
+
error40,
|
|
567035
|
+
"provider_engine",
|
|
567036
|
+
null,
|
|
567037
|
+
null,
|
|
567038
|
+
null,
|
|
567039
|
+
null,
|
|
567040
|
+
null,
|
|
567041
|
+
"query"
|
|
567042
|
+
);
|
|
564485
567043
|
}
|
|
564486
567044
|
if (hasInvocationDigest) {
|
|
564487
567045
|
const expectedAttestation = this.governedCodexProfile?.version === "probe.governed-codex-profile/v2" ? "probe.governed-codex-attestation/v3" : "probe.governed-codex-attestation/v2";
|
|
564488
567046
|
if (attestationCount !== 1 || runtimeAttestation?.version !== expectedAttestation || runtimeAttestation?.executionContext?.source !== "caller" || runtimeAttestation?.executionContext?.invocationDigest !== invocationDigest) {
|
|
564489
|
-
throw
|
|
567047
|
+
throw governedAnswerFailure(
|
|
567048
|
+
"native_event_grammar",
|
|
567049
|
+
"live_envelope_session",
|
|
567050
|
+
"attestation",
|
|
567051
|
+
null,
|
|
567052
|
+
"invocation_attestation"
|
|
567053
|
+
);
|
|
564490
567054
|
}
|
|
564491
|
-
} else if (attestationCount !== 1)
|
|
567055
|
+
} else if (attestationCount !== 1) {
|
|
567056
|
+
throw governedAnswerFailure(
|
|
567057
|
+
"native_event_grammar",
|
|
567058
|
+
"live_envelope_session",
|
|
567059
|
+
"attestation",
|
|
567060
|
+
null,
|
|
567061
|
+
"invocation_attestation"
|
|
567062
|
+
);
|
|
567063
|
+
}
|
|
564492
567064
|
if (this.governedCodexProfile?.version === "probe.governed-codex-profile/v2") {
|
|
564493
567065
|
if (nativeToolBatchCount !== 1 || !Number.isSafeInteger(nativeToolBatch?.total) || !Array.isArray(nativeToolBatch?.tools) || nativeToolBatch.total !== runtimeAttestation?.observed?.nativeTools?.total || JSON.stringify(nativeToolBatch.tools) !== JSON.stringify(runtimeAttestation?.observed?.nativeTools?.tools)) {
|
|
564494
|
-
throw
|
|
567066
|
+
throw governedAnswerFailure(
|
|
567067
|
+
"native_event_grammar",
|
|
567068
|
+
"live_envelope_session",
|
|
567069
|
+
"attestation",
|
|
567070
|
+
null,
|
|
567071
|
+
"native_capability_aggregate"
|
|
567072
|
+
);
|
|
564495
567073
|
}
|
|
564496
567074
|
for (const toolEvent of nativeToolBatch.tools) this.events.emit("toolCall", toolEvent);
|
|
564497
|
-
} else if (nativeToolBatchCount !== 0)
|
|
567075
|
+
} else if (nativeToolBatchCount !== 0) {
|
|
567076
|
+
throw governedAnswerFailure(
|
|
567077
|
+
"native_event_grammar",
|
|
567078
|
+
"live_envelope_session",
|
|
567079
|
+
"attestation",
|
|
567080
|
+
null,
|
|
567081
|
+
"native_capability_aggregate"
|
|
567082
|
+
);
|
|
567083
|
+
}
|
|
564498
567084
|
const validation = validateJsonResponse(candidateChunks.join(""), { debug: this.debug, schema });
|
|
564499
567085
|
if (!validation.isValid) throw governedSchemaResultValidationFailure(validation);
|
|
564500
567086
|
if (hasResultIdentity) {
|
|
@@ -564510,14 +567096,23 @@ You are working with a workspace. Available paths: ${workspaceDesc}
|
|
|
564510
567096
|
}
|
|
564511
567097
|
return { data: validation.parsed, runtimeAttestation };
|
|
564512
567098
|
} catch (error40) {
|
|
564513
|
-
answerFailure = normalizeGovernedAnswerFailure(error40, "
|
|
567099
|
+
answerFailure = normalizeGovernedAnswerFailure(error40, "internal_contract");
|
|
564514
567100
|
throw answerFailure;
|
|
564515
567101
|
} finally {
|
|
564516
567102
|
if (engine) {
|
|
564517
567103
|
try {
|
|
564518
567104
|
await engine.close();
|
|
564519
|
-
} catch {
|
|
564520
|
-
if (!answerFailure) throw
|
|
567105
|
+
} catch (error40) {
|
|
567106
|
+
if (!answerFailure) throw normalizeGovernedAnswerFailure(
|
|
567107
|
+
error40,
|
|
567108
|
+
"provider_engine",
|
|
567109
|
+
null,
|
|
567110
|
+
null,
|
|
567111
|
+
null,
|
|
567112
|
+
null,
|
|
567113
|
+
null,
|
|
567114
|
+
"close"
|
|
567115
|
+
);
|
|
564521
567116
|
}
|
|
564522
567117
|
}
|
|
564523
567118
|
}
|
|
@@ -596206,49 +598801,131 @@ class ParseError extends Error {
|
|
|
596206
598801
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
596207
598802
|
}
|
|
596208
598803
|
}
|
|
598804
|
+
const LF = 10, CR = 13, SPACE = 32;
|
|
596209
598805
|
function noop(_arg) {
|
|
596210
598806
|
}
|
|
596211
|
-
function createParser(
|
|
596212
|
-
if (typeof
|
|
598807
|
+
function createParser(config) {
|
|
598808
|
+
if (typeof config == "function")
|
|
596213
598809
|
throw new TypeError(
|
|
596214
|
-
"`
|
|
598810
|
+
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
596215
598811
|
);
|
|
596216
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } =
|
|
596217
|
-
let
|
|
596218
|
-
function feed(
|
|
596219
|
-
|
|
596220
|
-
|
|
596221
|
-
|
|
596222
|
-
|
|
596223
|
-
|
|
596224
|
-
|
|
596225
|
-
|
|
598812
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config, pendingFragments = [];
|
|
598813
|
+
let pendingFragmentsLength = 0, isFirstChunk = !0, id, data = "", dataLines = 0, eventType, terminated = !1;
|
|
598814
|
+
function feed(chunk) {
|
|
598815
|
+
if (terminated)
|
|
598816
|
+
throw new Error(
|
|
598817
|
+
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
598818
|
+
);
|
|
598819
|
+
if (isFirstChunk && (isFirstChunk = !1, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
598820
|
+
const trailing2 = processLines(chunk);
|
|
598821
|
+
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
598822
|
+
return;
|
|
598823
|
+
}
|
|
598824
|
+
if (chunk.indexOf(`
|
|
598825
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
598826
|
+
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
598827
|
+
return;
|
|
598828
|
+
}
|
|
598829
|
+
pendingFragments.push(chunk);
|
|
598830
|
+
const input = pendingFragments.join("");
|
|
598831
|
+
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
598832
|
+
const trailing = processLines(input);
|
|
598833
|
+
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
598834
|
+
}
|
|
598835
|
+
function checkBufferSize() {
|
|
598836
|
+
maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = !0, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
|
|
598837
|
+
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
598838
|
+
type: "max-buffer-size-exceeded"
|
|
598839
|
+
})
|
|
598840
|
+
)));
|
|
598841
|
+
}
|
|
598842
|
+
function processLines(chunk) {
|
|
598843
|
+
let searchIndex = 0;
|
|
598844
|
+
if (chunk.indexOf("\r") === -1) {
|
|
598845
|
+
let lfIndex = chunk.indexOf(`
|
|
598846
|
+
`, searchIndex);
|
|
598847
|
+
for (; lfIndex !== -1; ) {
|
|
598848
|
+
if (searchIndex === lfIndex) {
|
|
598849
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
598850
|
+
`, searchIndex);
|
|
598851
|
+
continue;
|
|
598852
|
+
}
|
|
598853
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
598854
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
598855
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
598856
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
598857
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
598858
|
+
`, searchIndex);
|
|
598859
|
+
continue;
|
|
598860
|
+
}
|
|
598861
|
+
data = dataLines === 0 ? value : `${data}
|
|
598862
|
+
${value}`, dataLines++;
|
|
598863
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
598864
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
598865
|
+
lfIndex
|
|
598866
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
598867
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
598868
|
+
`, searchIndex);
|
|
598869
|
+
}
|
|
598870
|
+
return chunk.slice(searchIndex);
|
|
598871
|
+
}
|
|
598872
|
+
for (; searchIndex < chunk.length; ) {
|
|
598873
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
598874
|
+
`, searchIndex);
|
|
598875
|
+
let lineEnd = -1;
|
|
598876
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
598877
|
+
break;
|
|
598878
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
598879
|
+
}
|
|
598880
|
+
return chunk.slice(searchIndex);
|
|
598881
|
+
}
|
|
598882
|
+
function parseLine(chunk, start, end) {
|
|
598883
|
+
if (start === end) {
|
|
596226
598884
|
dispatchEvent();
|
|
596227
598885
|
return;
|
|
596228
598886
|
}
|
|
596229
|
-
|
|
596230
|
-
|
|
598887
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
598888
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
598889
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
598890
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
598891
|
+
${value2}`, dataLines++;
|
|
598892
|
+
return;
|
|
598893
|
+
}
|
|
598894
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
598895
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
596231
598896
|
return;
|
|
596232
598897
|
}
|
|
596233
|
-
|
|
596234
|
-
|
|
596235
|
-
|
|
596236
|
-
processField(field, value, line);
|
|
598898
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
598899
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
598900
|
+
value2.includes("\0") || (id = value2);
|
|
596237
598901
|
return;
|
|
596238
598902
|
}
|
|
596239
|
-
|
|
598903
|
+
if (firstCharCode === 58) {
|
|
598904
|
+
if (onComment) {
|
|
598905
|
+
const line2 = chunk.slice(start, end);
|
|
598906
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
598907
|
+
}
|
|
598908
|
+
return;
|
|
598909
|
+
}
|
|
598910
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
598911
|
+
if (fieldSeparatorIndex === -1) {
|
|
598912
|
+
processField(line, "", line);
|
|
598913
|
+
return;
|
|
598914
|
+
}
|
|
598915
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
598916
|
+
processField(field, value, line);
|
|
596240
598917
|
}
|
|
596241
598918
|
function processField(field, value, line) {
|
|
596242
598919
|
switch (field) {
|
|
596243
598920
|
case "event":
|
|
596244
|
-
eventType = value;
|
|
598921
|
+
eventType = value || void 0;
|
|
596245
598922
|
break;
|
|
596246
598923
|
case "data":
|
|
596247
|
-
data = `${data}
|
|
596248
|
-
|
|
598924
|
+
data = dataLines === 0 ? value : `${data}
|
|
598925
|
+
${value}`, dataLines++;
|
|
596249
598926
|
break;
|
|
596250
598927
|
case "id":
|
|
596251
|
-
|
|
598928
|
+
value.includes("\0") || (id = value);
|
|
596252
598929
|
break;
|
|
596253
598930
|
case "retry":
|
|
596254
598931
|
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
@@ -596270,37 +598947,26 @@ function createParser(callbacks) {
|
|
|
596270
598947
|
}
|
|
596271
598948
|
}
|
|
596272
598949
|
function dispatchEvent() {
|
|
596273
|
-
|
|
598950
|
+
dataLines > 0 && onEvent({
|
|
596274
598951
|
id,
|
|
596275
|
-
event: eventType
|
|
596276
|
-
|
|
596277
|
-
|
|
596278
|
-
data: data.endsWith(`
|
|
596279
|
-
`) ? data.slice(0, -1) : data
|
|
596280
|
-
}), id = void 0, data = "", eventType = "";
|
|
598952
|
+
event: eventType,
|
|
598953
|
+
data
|
|
598954
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
596281
598955
|
}
|
|
596282
598956
|
function reset(options = {}) {
|
|
596283
|
-
|
|
598957
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
598958
|
+
const incompleteLine = pendingFragments.join("");
|
|
598959
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
598960
|
+
}
|
|
598961
|
+
isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = !1;
|
|
596284
598962
|
}
|
|
596285
598963
|
return { feed, reset };
|
|
596286
598964
|
}
|
|
596287
|
-
function
|
|
596288
|
-
|
|
596289
|
-
|
|
596290
|
-
|
|
596291
|
-
|
|
596292
|
-
`, searchIndex);
|
|
596293
|
-
let lineEnd = -1;
|
|
596294
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
|
|
596295
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
596296
|
-
break;
|
|
596297
|
-
} else {
|
|
596298
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
596299
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
596300
|
-
` && searchIndex++;
|
|
596301
|
-
}
|
|
596302
|
-
}
|
|
596303
|
-
return [lines, incompleteLine];
|
|
598965
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
598966
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
598967
|
+
}
|
|
598968
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
598969
|
+
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
596304
598970
|
}
|
|
596305
598971
|
exports.ParseError = ParseError;
|
|
596306
598972
|
exports.createParser = createParser;
|
|
@@ -596317,7 +598983,7 @@ exports.createParser = createParser;
|
|
|
596317
598983
|
Object.defineProperty(exports, "__esModule", ({ value: !0 }));
|
|
596318
598984
|
var index = __nccwpck_require__(19455);
|
|
596319
598985
|
class EventSourceParserStream extends TransformStream {
|
|
596320
|
-
constructor({ onError, onRetry, onComment } = {}) {
|
|
598986
|
+
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
596321
598987
|
let parser;
|
|
596322
598988
|
super({
|
|
596323
598989
|
start(controller) {
|
|
@@ -596326,10 +598992,11 @@ class EventSourceParserStream extends TransformStream {
|
|
|
596326
598992
|
controller.enqueue(event);
|
|
596327
598993
|
},
|
|
596328
598994
|
onError(error) {
|
|
596329
|
-
onError
|
|
598995
|
+
typeof onError == "function" && onError(error), (onError === "terminate" || error.type === "max-buffer-size-exceeded") && controller.error(error);
|
|
596330
598996
|
},
|
|
596331
598997
|
onRetry,
|
|
596332
|
-
onComment
|
|
598998
|
+
onComment,
|
|
598999
|
+
maxBufferSize
|
|
596333
599000
|
});
|
|
596334
599001
|
},
|
|
596335
599002
|
transform(chunk) {
|
|
@@ -635530,7 +638197,7 @@ module.exports = /*#__PURE__*/JSON.parse('["aaa","aarp","abb","abbott","abbvie",
|
|
|
635530
638197
|
/***/ ((module) => {
|
|
635531
638198
|
|
|
635532
638199
|
"use strict";
|
|
635533
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.
|
|
638200
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.193","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"npm run build:oss","build:oss":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@grammyjs/runner":"^2.0.3","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#d0d8c8ab3113d3b73e08b79b88a4b834ba3fae11","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.203.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-logs-otlp-http":"^0.203.0","@opentelemetry/exporter-metrics-otlp-http":"^0.203.0","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-logs":"^0.203.0","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","@probelabs/probe":"^0.6.0-rc339","@types/commander":"^2.12.0","@types/uuid":"^10.0.0","@utcp/file":"^1.1.0","@utcp/http":"^1.1.0","@utcp/sdk":"^1.1.0","@utcp/text":"^1.1.0","acorn":"^8.16.0","acorn-walk":"^8.3.5","ajv":"^8.17.1","ajv-formats":"^3.0.1","better-sqlite3":"^11.0.0","blessed":"^0.1.81","botbuilder":"^4.23.3","botframework-connector":"^4.23.3","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","grammy":"^1.41.1","ignore":"^7.0.5","imapflow":"^1.2.12","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","mailparser":"^3.9.3","minimatch":"^10.2.2","node-cron":"^3.0.3","nodemailer":"^8.0.1","open":"^9.1.0","resend":"^6.9.3","simple-git":"^3.28.0","uuid":"^11.1.0","ws":"^8.18.3"},"optionalDependencies":{"@anthropic/claude-code-sdk":"npm:null@*","@open-policy-agent/opa-wasm":"^1.10.0","knex":"^3.1.0","mysql2":"^3.11.0","pg":"^8.13.0","tedious":"^19.0.0"},"devDependencies":{"@eslint/js":"^9.34.0","@kie/act-js":"^2.6.2","@kie/mock-github":"^2.0.1","@swc/core":"^1.13.2","@swc/jest":"^0.2.37","@types/better-sqlite3":"^7.6.0","@types/blessed":"^0.1.27","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/mailparser":"^3.4.6","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/nodemailer":"^7.0.11","@types/ws":"^8.18.1","@typescript-eslint/eslint-plugin":"^8.42.0","@typescript-eslint/parser":"^8.42.0","@vercel/ncc":"^0.38.4","eslint":"^9.34.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","husky":"^9.1.7","jest":"^30.1.3","lint-staged":"^16.1.6","prettier":"^3.6.2","reveal-md":"^6.1.2","ts-json-schema-generator":"^1.5.1","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.2","wrangler":"^3.0.0"},"peerDependenciesMeta":{"@anthropic/claude-code-sdk":{"optional":true}},"directories":{"test":"tests"},"lint-staged":{"src/**/*.{ts,js}":["eslint --fix","prettier --write"],"tests/**/*.{ts,js}":["eslint --fix","prettier --write"],"*.{json,md,yml,yaml}":["prettier --write"]}}');
|
|
635534
638201
|
|
|
635535
638202
|
/***/ })
|
|
635536
638203
|
|