@zyraxon-ai/core 19.0.5
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/account/sql.js +31 -0
- package/dist/account/sql.js.map +1 -0
- package/dist/account.js +82 -0
- package/dist/account.js.map +1 -0
- package/dist/agent.js +77 -0
- package/dist/agent.js.map +1 -0
- package/dist/aisdk.js +171 -0
- package/dist/aisdk.js.map +1 -0
- package/dist/background-job.js +236 -0
- package/dist/background-job.js.map +1 -0
- package/dist/catalog.js +197 -0
- package/dist/catalog.js.map +1 -0
- package/dist/command.js +40 -0
- package/dist/command.js.map +1 -0
- package/dist/config/agent.js +24 -0
- package/dist/config/agent.js.map +1 -0
- package/dist/config/attachments.js +15 -0
- package/dist/config/attachments.js.map +1 -0
- package/dist/config/command.js +12 -0
- package/dist/config/command.js.map +1 -0
- package/dist/config/compaction.js +15 -0
- package/dist/config/compaction.js.map +1 -0
- package/dist/config/experimental.js +17 -0
- package/dist/config/experimental.js.map +1 -0
- package/dist/config/formatter.js +11 -0
- package/dist/config/formatter.js.map +1 -0
- package/dist/config/lsp.js +16 -0
- package/dist/config/lsp.js.map +1 -0
- package/dist/config/markdown.js +41 -0
- package/dist/config/markdown.js.map +1 -0
- package/dist/config/mcp.js +47 -0
- package/dist/config/mcp.js.map +1 -0
- package/dist/config/plugin/agent.js +149 -0
- package/dist/config/plugin/agent.js.map +1 -0
- package/dist/config/plugin/command.js +71 -0
- package/dist/config/plugin/command.js.map +1 -0
- package/dist/config/plugin/external.js +82 -0
- package/dist/config/plugin/external.js.map +1 -0
- package/dist/config/plugin/provider.js +109 -0
- package/dist/config/plugin/provider.js.map +1 -0
- package/dist/config/plugin/reference.js +59 -0
- package/dist/config/plugin/reference.js.map +1 -0
- package/dist/config/plugin/skill.js +41 -0
- package/dist/config/plugin/skill.js.map +1 -0
- package/dist/config/plugin.js +10 -0
- package/dist/config/plugin.js.map +1 -0
- package/dist/config/provider.js +70 -0
- package/dist/config/provider.js.map +1 -0
- package/dist/config/reference.js +18 -0
- package/dist/config/reference.js.map +1 -0
- package/dist/config/tool-output.js +9 -0
- package/dist/config/tool-output.js.map +1 -0
- package/dist/config/watcher.js +7 -0
- package/dist/config/watcher.js.map +1 -0
- package/dist/config.js +201 -0
- package/dist/config.js.map +1 -0
- package/dist/control-plane/move-session.js +111 -0
- package/dist/control-plane/move-session.js.map +1 -0
- package/dist/control-plane/workspace.sql.js +18 -0
- package/dist/control-plane/workspace.sql.js.map +1 -0
- package/dist/credential/sql.js +13 -0
- package/dist/credential/sql.js.map +1 -0
- package/dist/credential.js +105 -0
- package/dist/credential.js.map +1 -0
- package/dist/cross-spawn-spawner.js +412 -0
- package/dist/cross-spawn-spawner.js.map +1 -0
- package/dist/data-migration.sql.js +6 -0
- package/dist/data-migration.sql.js.map +1 -0
- package/dist/database/database.js +67 -0
- package/dist/database/database.js.map +1 -0
- package/dist/database/migration/20260127222353_familiar_lady_ursula.js +106 -0
- package/dist/database/migration/20260127222353_familiar_lady_ursula.js.map +1 -0
- package/dist/database/migration/20260211171708_add_project_commands.js +10 -0
- package/dist/database/migration/20260211171708_add_project_commands.js.map +1 -0
- package/dist/database/migration/20260213144116_wakeful_the_professor.js +22 -0
- package/dist/database/migration/20260213144116_wakeful_the_professor.js.map +1 -0
- package/dist/database/migration/20260225215848_workspace.js +18 -0
- package/dist/database/migration/20260225215848_workspace.js.map +1 -0
- package/dist/database/migration/20260227213759_add_session_workspace_id.js +11 -0
- package/dist/database/migration/20260227213759_add_session_workspace_id.js.map +1 -0
- package/dist/database/migration/20260228203230_blue_harpoon.js +29 -0
- package/dist/database/migration/20260228203230_blue_harpoon.js.map +1 -0
- package/dist/database/migration/20260303231226_add_workspace_fields.js +14 -0
- package/dist/database/migration/20260303231226_add_workspace_fields.js.map +1 -0
- package/dist/database/migration/20260309230000_move_org_to_state.js +12 -0
- package/dist/database/migration/20260309230000_move_org_to_state.js.map +1 -0
- package/dist/database/migration/20260312043431_session_message_cursor.js +13 -0
- package/dist/database/migration/20260312043431_session_message_cursor.js.map +1 -0
- package/dist/database/migration/20260323234822_events.js +25 -0
- package/dist/database/migration/20260323234822_events.js.map +1 -0
- package/dist/database/migration/20260410174513_workspace-name.js +26 -0
- package/dist/database/migration/20260410174513_workspace-name.js.map +1 -0
- package/dist/database/migration/20260413175956_chief_energizer.js +23 -0
- package/dist/database/migration/20260413175956_chief_energizer.js.map +1 -0
- package/dist/database/migration/20260423070820_add_icon_url_override.js +13 -0
- package/dist/database/migration/20260423070820_add_icon_url_override.js.map +1 -0
- package/dist/database/migration/20260427172553_slow_nightmare.js +27 -0
- package/dist/database/migration/20260427172553_slow_nightmare.js.map +1 -0
- package/dist/database/migration/20260428004200_add_session_path.js +10 -0
- package/dist/database/migration/20260428004200_add_session_path.js.map +1 -0
- package/dist/database/migration/20260501142318_next_venus.js +11 -0
- package/dist/database/migration/20260501142318_next_venus.js.map +1 -0
- package/dist/database/migration/20260504145000_add_sync_owner.js +10 -0
- package/dist/database/migration/20260504145000_add_sync_owner.js.map +1 -0
- package/dist/database/migration/20260507164347_add_workspace_time.js +10 -0
- package/dist/database/migration/20260507164347_add_workspace_time.js.map +1 -0
- package/dist/database/migration/20260510033149_session_usage.js +55 -0
- package/dist/database/migration/20260510033149_session_usage.js.map +1 -0
- package/dist/database/migration/20260511000411_data_migration_state.js +15 -0
- package/dist/database/migration/20260511000411_data_migration_state.js.map +1 -0
- package/dist/database/migration/20260511173437_session-metadata.js +13 -0
- package/dist/database/migration/20260511173437_session-metadata.js.map +1 -0
- package/dist/database/migration/20260601010001_normalize_storage_paths.js +13 -0
- package/dist/database/migration/20260601010001_normalize_storage_paths.js.map +1 -0
- package/dist/database/migration/20260601202201_amazing_prowler.js +10 -0
- package/dist/database/migration/20260601202201_amazing_prowler.js.map +1 -0
- package/dist/database/migration/20260602002951_lowly_union_jack.js +21 -0
- package/dist/database/migration/20260602002951_lowly_union_jack.js.map +1 -0
- package/dist/database/migration/20260602182828_add_project_directories.js +19 -0
- package/dist/database/migration/20260602182828_add_project_directories.js.map +1 -0
- package/dist/database/migration/20260603001617_session_message_projection_indexes.js +14 -0
- package/dist/database/migration/20260603001617_session_message_projection_indexes.js.map +1 -0
- package/dist/database/migration/20260603040000_session_message_projection_order.js +16 -0
- package/dist/database/migration/20260603040000_session_message_projection_order.js.map +1 -0
- package/dist/database/migration/20260603141458_session_input_inbox.js +22 -0
- package/dist/database/migration/20260603141458_session_input_inbox.js.map +1 -0
- package/dist/database/migration/20260603160727_jittery_ezekiel_stane.js +13 -0
- package/dist/database/migration/20260603160727_jittery_ezekiel_stane.js.map +1 -0
- package/dist/database/migration/20260604172448_event_sourced_session_input.js +38 -0
- package/dist/database/migration/20260604172448_event_sourced_session_input.js.map +1 -0
- package/dist/database/migration/20260605003541_add_session_context_snapshot.js +20 -0
- package/dist/database/migration/20260605003541_add_session_context_snapshot.js.map +1 -0
- package/dist/database/migration/20260605042240_add_context_epoch_agent.js +10 -0
- package/dist/database/migration/20260605042240_add_context_epoch_agent.js.map +1 -0
- package/dist/database/migration/20260611035744_credential.js +22 -0
- package/dist/database/migration/20260611035744_credential.js.map +1 -0
- package/dist/database/migration/20260611192811_lush_chimera.js +24 -0
- package/dist/database/migration/20260611192811_lush_chimera.js.map +1 -0
- package/dist/database/migration/20260612174303_project_dir_strategy.js +26 -0
- package/dist/database/migration/20260612174303_project_dir_strategy.js.map +1 -0
- package/dist/database/migration/20260622142730_simplify_session_context_epoch.js +12 -0
- package/dist/database/migration/20260622142730_simplify_session_context_epoch.js.map +1 -0
- package/dist/database/migration/20260622170816_reset_v2_session_state.js +16 -0
- package/dist/database/migration/20260622170816_reset_v2_session_state.js.map +1 -0
- package/dist/database/migration/20260622202450_simplify_session_input.js +16 -0
- package/dist/database/migration/20260622202450_simplify_session_input.js.map +1 -0
- package/dist/database/migration/20260730000000_eternal_memory_system.js +141 -0
- package/dist/database/migration/20260730000000_eternal_memory_system.js.map +1 -0
- package/dist/database/migration/20260912000000_db_performance_optimization.js +29 -0
- package/dist/database/migration/20260912000000_db_performance_optimization.js.map +1 -0
- package/dist/database/migration/20260912000000_performance_indexes.js +35 -0
- package/dist/database/migration/20260912000000_performance_indexes.js.map +1 -0
- package/dist/database/migration.gen.js +42 -0
- package/dist/database/migration.gen.js.map +1 -0
- package/dist/database/migration.js +48 -0
- package/dist/database/migration.js.map +1 -0
- package/dist/database/path.js +70 -0
- package/dist/database/path.js.map +1 -0
- package/dist/database/schema.gen.js +257 -0
- package/dist/database/schema.gen.js.map +1 -0
- package/dist/database/schema.sql.js +10 -0
- package/dist/database/schema.sql.js.map +1 -0
- package/dist/database/sqlite.bun.js +130 -0
- package/dist/database/sqlite.bun.js.map +1 -0
- package/dist/database/sqlite.js +7 -0
- package/dist/database/sqlite.js.map +1 -0
- package/dist/database/sqlite.node.js +124 -0
- package/dist/database/sqlite.node.js.map +1 -0
- package/dist/effect/app-node-builder.js +19 -0
- package/dist/effect/app-node-builder.js.map +1 -0
- package/dist/effect/app-node-platform.js +17 -0
- package/dist/effect/app-node-platform.js.map +1 -0
- package/dist/effect/app-node.js +9 -0
- package/dist/effect/app-node.js.map +1 -0
- package/dist/effect/keyed-mutex.js +31 -0
- package/dist/effect/keyed-mutex.js.map +1 -0
- package/dist/effect/layer-node.js +182 -0
- package/dist/effect/layer-node.js.map +1 -0
- package/dist/effect/memo-map.js +3 -0
- package/dist/effect/memo-map.js.map +1 -0
- package/dist/effect/runtime.js +17 -0
- package/dist/effect/runtime.js.map +1 -0
- package/dist/effect/service-use.js +28 -0
- package/dist/effect/service-use.js.map +1 -0
- package/dist/event/sql.js +19 -0
- package/dist/event/sql.js.map +1 -0
- package/dist/event.js +421 -0
- package/dist/event.js.map +1 -0
- package/dist/file-mutation.js +102 -0
- package/dist/file-mutation.js.map +1 -0
- package/dist/file.js +4 -0
- package/dist/file.js.map +1 -0
- package/dist/filesystem/fff.bun.js +28 -0
- package/dist/filesystem/fff.bun.js.map +1 -0
- package/dist/filesystem/fff.node.js +8 -0
- package/dist/filesystem/fff.node.js.map +1 -0
- package/dist/filesystem/ignore.js +63 -0
- package/dist/filesystem/ignore.js.map +1 -0
- package/dist/filesystem/protected.js +50 -0
- package/dist/filesystem/protected.js.map +1 -0
- package/dist/filesystem/search.js +198 -0
- package/dist/filesystem/search.js.map +1 -0
- package/dist/filesystem/watcher.js +109 -0
- package/dist/filesystem/watcher.js.map +1 -0
- package/dist/filesystem.js +96 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/flag/flag.js +66 -0
- package/dist/flag/flag.js.map +1 -0
- package/dist/fs-util.js +222 -0
- package/dist/fs-util.js.map +1 -0
- package/dist/git.js +558 -0
- package/dist/git.js.map +1 -0
- package/dist/github-copilot/chat/convert-to-openai-compatible-chat-messages.js +147 -0
- package/dist/github-copilot/chat/convert-to-openai-compatible-chat-messages.js.map +1 -0
- package/dist/github-copilot/chat/get-response-metadata.js +8 -0
- package/dist/github-copilot/chat/get-response-metadata.js.map +1 -0
- package/dist/github-copilot/chat/map-openai-compatible-finish-reason.js +16 -0
- package/dist/github-copilot/chat/map-openai-compatible-finish-reason.js.map +1 -0
- package/dist/github-copilot/chat/openai-compatible-api-types.js +2 -0
- package/dist/github-copilot/chat/openai-compatible-api-types.js.map +1 -0
- package/dist/github-copilot/chat/openai-compatible-chat-language-model.js +618 -0
- package/dist/github-copilot/chat/openai-compatible-chat-language-model.js.map +1 -0
- package/dist/github-copilot/chat/openai-compatible-chat-options.js +21 -0
- package/dist/github-copilot/chat/openai-compatible-chat-options.js.map +1 -0
- package/dist/github-copilot/chat/openai-compatible-metadata-extractor.js +2 -0
- package/dist/github-copilot/chat/openai-compatible-metadata-extractor.js.map +1 -0
- package/dist/github-copilot/chat/openai-compatible-prepare-tools.js +51 -0
- package/dist/github-copilot/chat/openai-compatible-prepare-tools.js.map +1 -0
- package/dist/github-copilot/copilot-provider.js +48 -0
- package/dist/github-copilot/copilot-provider.js.map +1 -0
- package/dist/github-copilot/openai-compatible-error.js +17 -0
- package/dist/github-copilot/openai-compatible-error.js.map +1 -0
- package/dist/github-copilot/responses/convert-to-openai-responses-input.js +284 -0
- package/dist/github-copilot/responses/convert-to-openai-responses-input.js.map +1 -0
- package/dist/github-copilot/responses/map-openai-responses-finish-reason.js +14 -0
- package/dist/github-copilot/responses/map-openai-responses-finish-reason.js.map +1 -0
- package/dist/github-copilot/responses/openai-config.js +2 -0
- package/dist/github-copilot/responses/openai-config.js.map +1 -0
- package/dist/github-copilot/responses/openai-error.js +18 -0
- package/dist/github-copilot/responses/openai-error.js.map +1 -0
- package/dist/github-copilot/responses/openai-responses-api-types.js +2 -0
- package/dist/github-copilot/responses/openai-responses-api-types.js.map +1 -0
- package/dist/github-copilot/responses/openai-responses-language-model.js +1487 -0
- package/dist/github-copilot/responses/openai-responses-language-model.js.map +1 -0
- package/dist/github-copilot/responses/openai-responses-prepare-tools.js +140 -0
- package/dist/github-copilot/responses/openai-responses-prepare-tools.js.map +1 -0
- package/dist/github-copilot/responses/openai-responses-settings.js +2 -0
- package/dist/github-copilot/responses/openai-responses-settings.js.map +1 -0
- package/dist/github-copilot/responses/tool/code-interpreter.js +33 -0
- package/dist/github-copilot/responses/tool/code-interpreter.js.map +1 -0
- package/dist/github-copilot/responses/tool/file-search.js +40 -0
- package/dist/github-copilot/responses/tool/file-search.js.map +1 -0
- package/dist/github-copilot/responses/tool/image-generation.js +33 -0
- package/dist/github-copilot/responses/tool/image-generation.js.map +1 -0
- package/dist/github-copilot/responses/tool/local-shell.js +21 -0
- package/dist/github-copilot/responses/tool/local-shell.js.map +1 -0
- package/dist/github-copilot/responses/tool/web-search-preview.js +62 -0
- package/dist/github-copilot/responses/tool/web-search-preview.js.map +1 -0
- package/dist/github-copilot/responses/tool/web-search.js +45 -0
- package/dist/github-copilot/responses/tool/web-search.js.map +1 -0
- package/dist/global.js +78 -0
- package/dist/global.js.map +1 -0
- package/dist/id/id.js +40 -0
- package/dist/id/id.js.map +1 -0
- package/dist/image/photon.js +84 -0
- package/dist/image/photon.js.map +1 -0
- package/dist/image.js +49 -0
- package/dist/image.js.map +1 -0
- package/dist/installation/version.js +4 -0
- package/dist/installation/version.js.map +1 -0
- package/dist/instruction-context.js +69 -0
- package/dist/instruction-context.js.map +1 -0
- package/dist/integration/connection.js +6 -0
- package/dist/integration/connection.js.map +1 -0
- package/dist/integration.js +335 -0
- package/dist/integration.js.map +1 -0
- package/dist/location-mutation.js +104 -0
- package/dist/location-mutation.js.map +1 -0
- package/dist/location-service-map.js +11 -0
- package/dist/location-service-map.js.map +1 -0
- package/dist/location-services.js +94 -0
- package/dist/location-services.js.map +1 -0
- package/dist/location.js +26 -0
- package/dist/location.js.map +1 -0
- package/dist/model.js +20 -0
- package/dist/model.js.map +1 -0
- package/dist/models-dev.js +187 -0
- package/dist/models-dev.js.map +1 -0
- package/dist/npm-config.js +33 -0
- package/dist/npm-config.js.map +1 -0
- package/dist/npm.js +203 -0
- package/dist/npm.js.map +1 -0
- package/dist/oauth/page.js +229 -0
- package/dist/oauth/page.js.map +1 -0
- package/dist/observability/logging.js +62 -0
- package/dist/observability/logging.js.map +1 -0
- package/dist/observability/otlp.js +69 -0
- package/dist/observability/otlp.js.map +1 -0
- package/dist/observability/shared.js +2 -0
- package/dist/observability/shared.js.map +1 -0
- package/dist/observability.js +14 -0
- package/dist/observability.js.map +1 -0
- package/dist/omni/index.js +36 -0
- package/dist/omni/index.js.map +1 -0
- package/dist/omni/kernel/01-multi-file-composer.js +57 -0
- package/dist/omni/kernel/01-multi-file-composer.js.map +1 -0
- package/dist/omni/kernel/02-terminal-autonomy.js +47 -0
- package/dist/omni/kernel/02-terminal-autonomy.js.map +1 -0
- package/dist/omni/kernel/03-background-loop.js +43 -0
- package/dist/omni/kernel/03-background-loop.js.map +1 -0
- package/dist/omni/kernel/04-behavior-cascade.js +39 -0
- package/dist/omni/kernel/04-behavior-cascade.js.map +1 -0
- package/dist/omni/kernel/05-git-pair.js +42 -0
- package/dist/omni/kernel/05-git-pair.js.map +1 -0
- package/dist/omni/kernel/06-sandbox-runtime.js +34 -0
- package/dist/omni/kernel/06-sandbox-runtime.js.map +1 -0
- package/dist/omni/kernel/07-idea-to-deploy.js +28 -0
- package/dist/omni/kernel/07-idea-to-deploy.js.map +1 -0
- package/dist/omni/kernel/08-cost-router.js +26 -0
- package/dist/omni/kernel/08-cost-router.js.map +1 -0
- package/dist/omni/kernel/09-live-observability.js +40 -0
- package/dist/omni/kernel/09-live-observability.js.map +1 -0
- package/dist/omni/kernel/10-knowledge-graph.js +39 -0
- package/dist/omni/kernel/10-knowledge-graph.js.map +1 -0
- package/dist/omni/kernel/11-security-scanner.js +52 -0
- package/dist/omni/kernel/11-security-scanner.js.map +1 -0
- package/dist/omni/kernel/12-silent-precompile.js +58 -0
- package/dist/omni/kernel/12-silent-precompile.js.map +1 -0
- package/dist/omni/kernel/13-visual-context-sync.js +59 -0
- package/dist/omni/kernel/13-visual-context-sync.js.map +1 -0
- package/dist/omni/kernel/14-self-evolving-prompt.js +45 -0
- package/dist/omni/kernel/14-self-evolving-prompt.js.map +1 -0
- package/dist/omni/kernel/15-zero-trust-token.js +78 -0
- package/dist/omni/kernel/15-zero-trust-token.js.map +1 -0
- package/dist/omni/kernel/index.js +79 -0
- package/dist/omni/kernel/index.js.map +1 -0
- package/dist/omni/memory-graph.js +64 -0
- package/dist/omni/memory-graph.js.map +1 -0
- package/dist/omni/secret-redact.js +81 -0
- package/dist/omni/secret-redact.js.map +1 -0
- package/dist/omni/shadow-clone.js +54 -0
- package/dist/omni/shadow-clone.js.map +1 -0
- package/dist/omni/vision-context.js +61 -0
- package/dist/omni/vision-context.js.map +1 -0
- package/dist/patch.js +179 -0
- package/dist/patch.js.map +1 -0
- package/dist/permission/saved.js +53 -0
- package/dist/permission/saved.js.map +1 -0
- package/dist/permission/sql.js +14 -0
- package/dist/permission/sql.js.map +1 -0
- package/dist/permission.js +222 -0
- package/dist/permission.js.map +1 -0
- package/dist/plugin/agent.js +180 -0
- package/dist/plugin/agent.js.map +1 -0
- package/dist/plugin/command.js +24 -0
- package/dist/plugin/command.js.map +1 -0
- package/dist/plugin/host.js +168 -0
- package/dist/plugin/host.js.map +1 -0
- package/dist/plugin/internal.js +102 -0
- package/dist/plugin/internal.js.map +1 -0
- package/dist/plugin/layer-map.example.js +37 -0
- package/dist/plugin/layer-map.example.js.map +1 -0
- package/dist/plugin/models-dev.js +161 -0
- package/dist/plugin/models-dev.js.map +1 -0
- package/dist/plugin/promise.js +71 -0
- package/dist/plugin/promise.js.map +1 -0
- package/dist/plugin/provider/alibaba.js +14 -0
- package/dist/plugin/provider/alibaba.js.map +1 -0
- package/dist/plugin/provider/amazon-bedrock.js +109 -0
- package/dist/plugin/provider/amazon-bedrock.js.map +1 -0
- package/dist/plugin/provider/anthropic.js +26 -0
- package/dist/plugin/provider/anthropic.js.map +1 -0
- package/dist/plugin/provider/azure.js +79 -0
- package/dist/plugin/provider/azure.js.map +1 -0
- package/dist/plugin/provider/cerebras.js +25 -0
- package/dist/plugin/provider/cerebras.js.map +1 -0
- package/dist/plugin/provider/cloudflare-ai-gateway.js +68 -0
- package/dist/plugin/provider/cloudflare-ai-gateway.js.map +1 -0
- package/dist/plugin/provider/cloudflare-workers-ai.js +74 -0
- package/dist/plugin/provider/cloudflare-workers-ai.js.map +1 -0
- package/dist/plugin/provider/cohere.js +14 -0
- package/dist/plugin/provider/cohere.js.map +1 -0
- package/dist/plugin/provider/deepinfra.js +14 -0
- package/dist/plugin/provider/deepinfra.js.map +1 -0
- package/dist/plugin/provider/dynamic.js +27 -0
- package/dist/plugin/provider/dynamic.js.map +1 -0
- package/dist/plugin/provider/gateway.js +14 -0
- package/dist/plugin/provider/gateway.js.map +1 -0
- package/dist/plugin/provider/github-copilot.js +48 -0
- package/dist/plugin/provider/github-copilot.js.map +1 -0
- package/dist/plugin/provider/gitlab.js +57 -0
- package/dist/plugin/provider/gitlab.js.map +1 -0
- package/dist/plugin/provider/google-vertex.js +153 -0
- package/dist/plugin/provider/google-vertex.js.map +1 -0
- package/dist/plugin/provider/google.js +14 -0
- package/dist/plugin/provider/google.js.map +1 -0
- package/dist/plugin/provider/groq.js +14 -0
- package/dist/plugin/provider/groq.js.map +1 -0
- package/dist/plugin/provider/kilo.js +22 -0
- package/dist/plugin/provider/kilo.js.map +1 -0
- package/dist/plugin/provider/llmgateway.js +29 -0
- package/dist/plugin/provider/llmgateway.js.map +1 -0
- package/dist/plugin/provider/mistral.js +14 -0
- package/dist/plugin/provider/mistral.js.map +1 -0
- package/dist/plugin/provider/nvidia.js +23 -0
- package/dist/plugin/provider/nvidia.js.map +1 -0
- package/dist/plugin/provider/openai-compatible.js +18 -0
- package/dist/plugin/provider/openai-compatible.js.map +1 -0
- package/dist/plugin/provider/openai.js +241 -0
- package/dist/plugin/provider/openai.js.map +1 -0
- package/dist/plugin/provider/openrouter.js +36 -0
- package/dist/plugin/provider/openrouter.js.map +1 -0
- package/dist/plugin/provider/perplexity.js +14 -0
- package/dist/plugin/provider/perplexity.js.map +1 -0
- package/dist/plugin/provider/sap-ai-core.js +39 -0
- package/dist/plugin/provider/sap-ai-core.js.map +1 -0
- package/dist/plugin/provider/snowflake-cortex.js +76 -0
- package/dist/plugin/provider/snowflake-cortex.js.map +1 -0
- package/dist/plugin/provider/togetherai.js +14 -0
- package/dist/plugin/provider/togetherai.js.map +1 -0
- package/dist/plugin/provider/venice.js +14 -0
- package/dist/plugin/provider/venice.js.map +1 -0
- package/dist/plugin/provider/vercel.js +26 -0
- package/dist/plugin/provider/vercel.js.map +1 -0
- package/dist/plugin/provider/xai.js +20 -0
- package/dist/plugin/provider/xai.js.map +1 -0
- package/dist/plugin/provider/zenmux.js +22 -0
- package/dist/plugin/provider/zenmux.js.map +1 -0
- package/dist/plugin/provider/zyraxon.js +260 -0
- package/dist/plugin/provider/zyraxon.js.map +1 -0
- package/dist/plugin/provider.js +69 -0
- package/dist/plugin/provider.js.map +1 -0
- package/dist/plugin/skill.js +25 -0
- package/dist/plugin/skill.js.map +1 -0
- package/dist/plugin/variant.js +38 -0
- package/dist/plugin/variant.js.map +1 -0
- package/dist/plugin.js +119 -0
- package/dist/plugin.js.map +1 -0
- package/dist/policy.js +30 -0
- package/dist/policy.js.map +1 -0
- package/dist/process.js +163 -0
- package/dist/process.js.map +1 -0
- package/dist/project/copy-strategies.js +28 -0
- package/dist/project/copy-strategies.js.map +1 -0
- package/dist/project/copy.js +180 -0
- package/dist/project/copy.js.map +1 -0
- package/dist/project/directories.js +89 -0
- package/dist/project/directories.js.map +1 -0
- package/dist/project/schema.js +12 -0
- package/dist/project/schema.js.map +1 -0
- package/dist/project/sql.js +29 -0
- package/dist/project/sql.js.map +1 -0
- package/dist/project.js +94 -0
- package/dist/project.js.map +1 -0
- package/dist/provider.js +9 -0
- package/dist/provider.js.map +1 -0
- package/dist/pty/protocol.js +35 -0
- package/dist/pty/protocol.js.map +1 -0
- package/dist/pty/pty.bun.js +23 -0
- package/dist/pty/pty.bun.js.map +1 -0
- package/dist/pty/pty.js +2 -0
- package/dist/pty/pty.js.map +1 -0
- package/dist/pty/pty.node.js +23 -0
- package/dist/pty/pty.node.js.map +1 -0
- package/dist/pty/schema.js +2 -0
- package/dist/pty/schema.js.map +1 -0
- package/dist/pty/ticket.js +33 -0
- package/dist/pty/ticket.js.map +1 -0
- package/dist/pty.js +253 -0
- package/dist/pty.js.map +1 -0
- package/dist/public-event-manifest.js +6 -0
- package/dist/public-event-manifest.js.map +1 -0
- package/dist/question.js +78 -0
- package/dist/question.js.map +1 -0
- package/dist/reference/guidance.js +55 -0
- package/dist/reference/guidance.js.map +1 -0
- package/dist/reference.js +90 -0
- package/dist/reference.js.map +1 -0
- package/dist/repository-cache.js +180 -0
- package/dist/repository-cache.js.map +1 -0
- package/dist/repository.js +164 -0
- package/dist/repository.js.map +1 -0
- package/dist/ripgrep/binary.js +107 -0
- package/dist/ripgrep/binary.js.map +1 -0
- package/dist/ripgrep.js +174 -0
- package/dist/ripgrep.js.map +1 -0
- package/dist/schema.js +33 -0
- package/dist/schema.js.map +1 -0
- package/dist/session/compaction.js +197 -0
- package/dist/session/compaction.js.map +1 -0
- package/dist/session/context-epoch.js +110 -0
- package/dist/session/context-epoch.js.map +1 -0
- package/dist/session/error.js +20 -0
- package/dist/session/error.js.map +1 -0
- package/dist/session/event.js +3 -0
- package/dist/session/event.js.map +1 -0
- package/dist/session/execution/local.js +35 -0
- package/dist/session/execution/local.js.map +1 -0
- package/dist/session/execution.js +16 -0
- package/dist/session/execution.js.map +1 -0
- package/dist/session/history.js +58 -0
- package/dist/session/history.js.map +1 -0
- package/dist/session/info.js +48 -0
- package/dist/session/info.js.map +1 -0
- package/dist/session/input.js +167 -0
- package/dist/session/input.js.map +1 -0
- package/dist/session/message-updater.js +340 -0
- package/dist/session/message-updater.js.map +1 -0
- package/dist/session/message.js +3 -0
- package/dist/session/message.js.map +1 -0
- package/dist/session/projector.js +385 -0
- package/dist/session/projector.js.map +1 -0
- package/dist/session/prompt.js +2 -0
- package/dist/session/prompt.js.map +1 -0
- package/dist/session/revert.js +107 -0
- package/dist/session/revert.js.map +1 -0
- package/dist/session/run-coordinator.js +65 -0
- package/dist/session/run-coordinator.js.map +1 -0
- package/dist/session/runner/index.js +5 -0
- package/dist/session/runner/index.js.map +1 -0
- package/dist/session/runner/llm.js +356 -0
- package/dist/session/runner/llm.js.map +1 -0
- package/dist/session/runner/max-steps.js +17 -0
- package/dist/session/runner/max-steps.js.map +1 -0
- package/dist/session/runner/model.js +150 -0
- package/dist/session/runner/model.js.map +1 -0
- package/dist/session/runner/publish-llm-event.js +387 -0
- package/dist/session/runner/publish-llm-event.js.map +1 -0
- package/dist/session/runner/to-llm-message.js +152 -0
- package/dist/session/runner/to-llm-message.js.map +1 -0
- package/dist/session/schema.js +5 -0
- package/dist/session/schema.js.map +1 -0
- package/dist/session/sql.js +121 -0
- package/dist/session/sql.js.map +1 -0
- package/dist/session/store.js +44 -0
- package/dist/session/store.js.map +1 -0
- package/dist/session/todo.js +53 -0
- package/dist/session/todo.js.map +1 -0
- package/dist/session.js +330 -0
- package/dist/session.js.map +1 -0
- package/dist/share/sql.js +13 -0
- package/dist/share/sql.js.map +1 -0
- package/dist/shell.js +227 -0
- package/dist/shell.js.map +1 -0
- package/dist/skill/discovery.js +163 -0
- package/dist/skill/discovery.js.map +1 -0
- package/dist/skill/guidance.js +58 -0
- package/dist/skill/guidance.js.map +1 -0
- package/dist/skill.js +101 -0
- package/dist/skill.js.map +1 -0
- package/dist/snapshot.js +174 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/state.js +76 -0
- package/dist/state.js.map +1 -0
- package/dist/system-context/builtins.js +44 -0
- package/dist/system-context/builtins.js.map +1 -0
- package/dist/system-context/index.js +208 -0
- package/dist/system-context/index.js.map +1 -0
- package/dist/system-context/registry.js +24 -0
- package/dist/system-context/registry.js.map +1 -0
- package/dist/tool/application-tools.js +33 -0
- package/dist/tool/application-tools.js.map +1 -0
- package/dist/tool/apply-patch.js +177 -0
- package/dist/tool/apply-patch.js.map +1 -0
- package/dist/tool/bash.js +177 -0
- package/dist/tool/bash.js.map +1 -0
- package/dist/tool/builtins.js +49 -0
- package/dist/tool/builtins.js.map +1 -0
- package/dist/tool/edit.js +181 -0
- package/dist/tool/edit.js.map +1 -0
- package/dist/tool/glob.js +83 -0
- package/dist/tool/glob.js.map +1 -0
- package/dist/tool/grep.js +110 -0
- package/dist/tool/grep.js.map +1 -0
- package/dist/tool/http-body.js +26 -0
- package/dist/tool/http-body.js.map +1 -0
- package/dist/tool/marketplace.js +483 -0
- package/dist/tool/marketplace.js.map +1 -0
- package/dist/tool/question.js +70 -0
- package/dist/tool/question.js.map +1 -0
- package/dist/tool/read-filesystem.js +326 -0
- package/dist/tool/read-filesystem.js.map +1 -0
- package/dist/tool/read.js +107 -0
- package/dist/tool/read.js.map +1 -0
- package/dist/tool/registry.js +102 -0
- package/dist/tool/registry.js.map +1 -0
- package/dist/tool/skill.js +97 -0
- package/dist/tool/skill.js.map +1 -0
- package/dist/tool/todowrite.js +50 -0
- package/dist/tool/todowrite.js.map +1 -0
- package/dist/tool/tool.js +71 -0
- package/dist/tool/tool.js.map +1 -0
- package/dist/tool/tools.js +6 -0
- package/dist/tool/tools.js.map +1 -0
- package/dist/tool/webfetch.js +184 -0
- package/dist/tool/webfetch.js.map +1 -0
- package/dist/tool/websearch.js +201 -0
- package/dist/tool/websearch.js.map +1 -0
- package/dist/tool/write.js +83 -0
- package/dist/tool/write.js.map +1 -0
- package/dist/tool-output-store.js +164 -0
- package/dist/tool-output-store.js.map +1 -0
- package/dist/util/array.js +9 -0
- package/dist/util/array.js.map +1 -0
- package/dist/util/binary.js +41 -0
- package/dist/util/binary.js.map +1 -0
- package/dist/util/effect-flock.js +179 -0
- package/dist/util/effect-flock.js.map +1 -0
- package/dist/util/encode.js +50 -0
- package/dist/util/encode.js.map +1 -0
- package/dist/util/error.js +46 -0
- package/dist/util/error.js.map +1 -0
- package/dist/util/flock.js +274 -0
- package/dist/util/flock.js.map +1 -0
- package/dist/util/glob.js +27 -0
- package/dist/util/glob.js.map +1 -0
- package/dist/util/hash.js +13 -0
- package/dist/util/hash.js.map +1 -0
- package/dist/util/identifier.js +2 -0
- package/dist/util/identifier.js.map +1 -0
- package/dist/util/iife.js +4 -0
- package/dist/util/iife.js.map +1 -0
- package/dist/util/lazy.js +12 -0
- package/dist/util/lazy.js.map +1 -0
- package/dist/util/module.js +13 -0
- package/dist/util/module.js.map +1 -0
- package/dist/util/path.js +40 -0
- package/dist/util/path.js.map +1 -0
- package/dist/util/retry.js +35 -0
- package/dist/util/retry.js.map +1 -0
- package/dist/util/slug.js +75 -0
- package/dist/util/slug.js.map +1 -0
- package/dist/util/token.js +4 -0
- package/dist/util/token.js.map +1 -0
- package/dist/util/which.js +14 -0
- package/dist/util/which.js.map +1 -0
- package/dist/util/wildcard.js +13 -0
- package/dist/util/wildcard.js.map +1 -0
- package/dist/v1/config/agent.js +77 -0
- package/dist/v1/config/agent.js.map +1 -0
- package/dist/v1/config/attachment.js +21 -0
- package/dist/v1/config/attachment.js.map +1 -0
- package/dist/v1/config/command.js +11 -0
- package/dist/v1/config/command.js.map +1 -0
- package/dist/v1/config/config.js +157 -0
- package/dist/v1/config/config.js.map +1 -0
- package/dist/v1/config/console-state.js +15 -0
- package/dist/v1/config/console-state.js.map +1 -0
- package/dist/v1/config/error.js +30 -0
- package/dist/v1/config/error.js.map +1 -0
- package/dist/v1/config/formatter.js +10 -0
- package/dist/v1/config/formatter.js.map +1 -0
- package/dist/v1/config/layout.js +4 -0
- package/dist/v1/config/layout.js.map +1 -0
- package/dist/v1/config/lsp.js +74 -0
- package/dist/v1/config/lsp.js.map +1 -0
- package/dist/v1/config/mcp.js +54 -0
- package/dist/v1/config/mcp.js.map +1 -0
- package/dist/v1/config/migrate.js +230 -0
- package/dist/v1/config/migrate.js.map +1 -0
- package/dist/v1/config/permission.js +32 -0
- package/dist/v1/config/permission.js.map +1 -0
- package/dist/v1/config/plugin.js +5 -0
- package/dist/v1/config/plugin.js.map +1 -0
- package/dist/v1/config/provider-options.js +193 -0
- package/dist/v1/config/provider-options.js.map +1 -0
- package/dist/v1/config/provider.js +83 -0
- package/dist/v1/config/provider.js.map +1 -0
- package/dist/v1/config/server.js +17 -0
- package/dist/v1/config/server.js.map +1 -0
- package/dist/v1/config/skills.js +11 -0
- package/dist/v1/config/skills.js.map +1 -0
- package/dist/v1/permission.js +28 -0
- package/dist/v1/permission.js.map +1 -0
- package/dist/v1/session.js +26 -0
- package/dist/v1/session.js.map +1 -0
- package/dist/v2-schema.js +3 -0
- package/dist/v2-schema.js.map +1 -0
- package/dist/workspace.js +4 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +103 -0
|
@@ -0,0 +1,1487 @@
|
|
|
1
|
+
import { APICallError, } from "@ai-sdk/provider";
|
|
2
|
+
import { combineHeaders, createEventSourceResponseHandler, createJsonResponseHandler, generateId, parseProviderOptions, postJsonToApi, } from "@ai-sdk/provider-utils";
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
|
+
import { openaiFailedResponseHandler } from "./openai-error";
|
|
5
|
+
import { convertToOpenAIResponsesInput } from "./convert-to-openai-responses-input";
|
|
6
|
+
import { mapOpenAIResponseFinishReason } from "./map-openai-responses-finish-reason";
|
|
7
|
+
import { prepareResponsesTools } from "./openai-responses-prepare-tools";
|
|
8
|
+
const webSearchCallItem = z.object({
|
|
9
|
+
type: z.literal("web_search_call"),
|
|
10
|
+
id: z.string(),
|
|
11
|
+
status: z.string(),
|
|
12
|
+
action: z
|
|
13
|
+
.discriminatedUnion("type", [
|
|
14
|
+
z.object({
|
|
15
|
+
type: z.literal("search"),
|
|
16
|
+
query: z.string().nullish(),
|
|
17
|
+
}),
|
|
18
|
+
z.object({
|
|
19
|
+
type: z.literal("open_page"),
|
|
20
|
+
url: z.string(),
|
|
21
|
+
}),
|
|
22
|
+
z.object({
|
|
23
|
+
type: z.literal("find"),
|
|
24
|
+
url: z.string(),
|
|
25
|
+
pattern: z.string(),
|
|
26
|
+
}),
|
|
27
|
+
])
|
|
28
|
+
.nullish(),
|
|
29
|
+
});
|
|
30
|
+
const fileSearchCallItem = z.object({
|
|
31
|
+
type: z.literal("file_search_call"),
|
|
32
|
+
id: z.string(),
|
|
33
|
+
queries: z.array(z.string()),
|
|
34
|
+
results: z
|
|
35
|
+
.array(z.object({
|
|
36
|
+
attributes: z.record(z.string(), z.unknown()),
|
|
37
|
+
file_id: z.string(),
|
|
38
|
+
filename: z.string(),
|
|
39
|
+
score: z.number(),
|
|
40
|
+
text: z.string(),
|
|
41
|
+
}))
|
|
42
|
+
.nullish(),
|
|
43
|
+
});
|
|
44
|
+
const codeInterpreterCallItem = z.object({
|
|
45
|
+
type: z.literal("code_interpreter_call"),
|
|
46
|
+
id: z.string(),
|
|
47
|
+
code: z.string().nullable(),
|
|
48
|
+
container_id: z.string(),
|
|
49
|
+
outputs: z
|
|
50
|
+
.array(z.discriminatedUnion("type", [
|
|
51
|
+
z.object({ type: z.literal("logs"), logs: z.string() }),
|
|
52
|
+
z.object({ type: z.literal("image"), url: z.string() }),
|
|
53
|
+
]))
|
|
54
|
+
.nullable(),
|
|
55
|
+
});
|
|
56
|
+
const localShellCallItem = z.object({
|
|
57
|
+
type: z.literal("local_shell_call"),
|
|
58
|
+
id: z.string(),
|
|
59
|
+
call_id: z.string(),
|
|
60
|
+
action: z.object({
|
|
61
|
+
type: z.literal("exec"),
|
|
62
|
+
command: z.array(z.string()),
|
|
63
|
+
timeout_ms: z.number().optional(),
|
|
64
|
+
user: z.string().optional(),
|
|
65
|
+
working_directory: z.string().optional(),
|
|
66
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
const imageGenerationCallItem = z.object({
|
|
70
|
+
type: z.literal("image_generation_call"),
|
|
71
|
+
id: z.string(),
|
|
72
|
+
result: z.string(),
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* `top_logprobs` request body argument can be set to an integer between
|
|
76
|
+
* 0 and 20 specifying the number of most likely tokens to return at each
|
|
77
|
+
* token position, each with an associated log probability.
|
|
78
|
+
*
|
|
79
|
+
* @see https://platform.openai.com/docs/api-reference/responses/create#responses_create-top_logprobs
|
|
80
|
+
*/
|
|
81
|
+
const TOP_LOGPROBS_MAX = 20;
|
|
82
|
+
const LOGPROBS_SCHEMA = z.array(z.object({
|
|
83
|
+
token: z.string(),
|
|
84
|
+
logprob: z.number(),
|
|
85
|
+
top_logprobs: z.array(z.object({
|
|
86
|
+
token: z.string(),
|
|
87
|
+
logprob: z.number(),
|
|
88
|
+
})),
|
|
89
|
+
}));
|
|
90
|
+
export class OpenAIResponsesLanguageModel {
|
|
91
|
+
specificationVersion = "v3";
|
|
92
|
+
modelId;
|
|
93
|
+
config;
|
|
94
|
+
constructor(modelId, config) {
|
|
95
|
+
this.modelId = modelId;
|
|
96
|
+
this.config = config;
|
|
97
|
+
}
|
|
98
|
+
supportedUrls = {
|
|
99
|
+
"image/*": [/^https?:\/\/.*$/],
|
|
100
|
+
"application/pdf": [/^https?:\/\/.*$/],
|
|
101
|
+
};
|
|
102
|
+
get provider() {
|
|
103
|
+
return this.config.provider;
|
|
104
|
+
}
|
|
105
|
+
async getArgs({ maxOutputTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, providerOptions, tools, toolChoice, responseFormat, }) {
|
|
106
|
+
const warnings = [];
|
|
107
|
+
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
108
|
+
if (topK != null) {
|
|
109
|
+
warnings.push({ type: "unsupported", feature: "topK" });
|
|
110
|
+
}
|
|
111
|
+
if (seed != null) {
|
|
112
|
+
warnings.push({ type: "unsupported", feature: "seed" });
|
|
113
|
+
}
|
|
114
|
+
if (presencePenalty != null) {
|
|
115
|
+
warnings.push({
|
|
116
|
+
type: "unsupported",
|
|
117
|
+
feature: "presencePenalty",
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (frequencyPenalty != null) {
|
|
121
|
+
warnings.push({
|
|
122
|
+
type: "unsupported",
|
|
123
|
+
feature: "frequencyPenalty",
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (stopSequences != null) {
|
|
127
|
+
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
128
|
+
}
|
|
129
|
+
const openaiOptions = await parseProviderOptions({
|
|
130
|
+
provider: "copilot",
|
|
131
|
+
providerOptions,
|
|
132
|
+
schema: openaiResponsesProviderOptionsSchema,
|
|
133
|
+
});
|
|
134
|
+
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
135
|
+
prompt,
|
|
136
|
+
systemMessageMode: modelConfig.systemMessageMode,
|
|
137
|
+
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
138
|
+
store: openaiOptions?.store ?? true,
|
|
139
|
+
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
140
|
+
});
|
|
141
|
+
warnings.push(...inputWarnings);
|
|
142
|
+
const strictJsonSchema = openaiOptions?.strictJsonSchema ?? false;
|
|
143
|
+
let include = openaiOptions?.include;
|
|
144
|
+
function addInclude(key) {
|
|
145
|
+
include = include != null ? [...include, key] : [key];
|
|
146
|
+
}
|
|
147
|
+
function hasOpenAITool(id) {
|
|
148
|
+
return tools?.find((tool) => tool.type === "provider" && tool.id === id) != null;
|
|
149
|
+
}
|
|
150
|
+
// when logprobs are requested, automatically include them:
|
|
151
|
+
const topLogprobs = typeof openaiOptions?.logprobs === "number"
|
|
152
|
+
? openaiOptions?.logprobs
|
|
153
|
+
: openaiOptions?.logprobs === true
|
|
154
|
+
? TOP_LOGPROBS_MAX
|
|
155
|
+
: undefined;
|
|
156
|
+
if (topLogprobs) {
|
|
157
|
+
addInclude("message.output_text.logprobs");
|
|
158
|
+
}
|
|
159
|
+
// when a web search tool is present, automatically include the sources:
|
|
160
|
+
const webSearchToolName = tools?.find((tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview"))?.name;
|
|
161
|
+
if (webSearchToolName) {
|
|
162
|
+
addInclude("web_search_call.action.sources");
|
|
163
|
+
}
|
|
164
|
+
// when a code interpreter tool is present, automatically include the outputs:
|
|
165
|
+
if (hasOpenAITool("openai.code_interpreter")) {
|
|
166
|
+
addInclude("code_interpreter_call.outputs");
|
|
167
|
+
}
|
|
168
|
+
const baseArgs = {
|
|
169
|
+
model: this.modelId,
|
|
170
|
+
input,
|
|
171
|
+
temperature,
|
|
172
|
+
top_p: topP,
|
|
173
|
+
max_output_tokens: maxOutputTokens,
|
|
174
|
+
...((responseFormat?.type === "json" || openaiOptions?.textVerbosity) && {
|
|
175
|
+
text: {
|
|
176
|
+
...(responseFormat?.type === "json" && {
|
|
177
|
+
format: responseFormat.schema != null
|
|
178
|
+
? {
|
|
179
|
+
type: "json_schema",
|
|
180
|
+
strict: strictJsonSchema,
|
|
181
|
+
name: responseFormat.name ?? "response",
|
|
182
|
+
description: responseFormat.description,
|
|
183
|
+
schema: responseFormat.schema,
|
|
184
|
+
}
|
|
185
|
+
: { type: "json_object" },
|
|
186
|
+
}),
|
|
187
|
+
...(openaiOptions?.textVerbosity && {
|
|
188
|
+
verbosity: openaiOptions.textVerbosity,
|
|
189
|
+
}),
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
// provider options:
|
|
193
|
+
max_tool_calls: openaiOptions?.maxToolCalls,
|
|
194
|
+
metadata: openaiOptions?.metadata,
|
|
195
|
+
parallel_tool_calls: openaiOptions?.parallelToolCalls,
|
|
196
|
+
previous_response_id: openaiOptions?.previousResponseId,
|
|
197
|
+
store: openaiOptions?.store,
|
|
198
|
+
user: openaiOptions?.user,
|
|
199
|
+
instructions: openaiOptions?.instructions,
|
|
200
|
+
service_tier: openaiOptions?.serviceTier,
|
|
201
|
+
include,
|
|
202
|
+
prompt_cache_key: openaiOptions?.promptCacheKey,
|
|
203
|
+
safety_identifier: openaiOptions?.safetyIdentifier,
|
|
204
|
+
top_logprobs: topLogprobs,
|
|
205
|
+
// model-specific settings:
|
|
206
|
+
...(modelConfig.isReasoningModel &&
|
|
207
|
+
(openaiOptions?.reasoningEffort != null || openaiOptions?.reasoningSummary != null) && {
|
|
208
|
+
reasoning: {
|
|
209
|
+
...(openaiOptions?.reasoningEffort != null && {
|
|
210
|
+
effort: openaiOptions.reasoningEffort,
|
|
211
|
+
}),
|
|
212
|
+
...(openaiOptions?.reasoningSummary != null && {
|
|
213
|
+
summary: openaiOptions.reasoningSummary,
|
|
214
|
+
}),
|
|
215
|
+
},
|
|
216
|
+
}),
|
|
217
|
+
...(modelConfig.requiredAutoTruncation && {
|
|
218
|
+
truncation: "auto",
|
|
219
|
+
}),
|
|
220
|
+
};
|
|
221
|
+
if (modelConfig.isReasoningModel) {
|
|
222
|
+
// remove unsupported settings for reasoning models
|
|
223
|
+
// see https://platform.openai.com/docs/guides/reasoning#limitations
|
|
224
|
+
if (baseArgs.temperature != null) {
|
|
225
|
+
baseArgs.temperature = undefined;
|
|
226
|
+
warnings.push({
|
|
227
|
+
type: "unsupported",
|
|
228
|
+
feature: "temperature",
|
|
229
|
+
details: "temperature is not supported for reasoning models",
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (baseArgs.top_p != null) {
|
|
233
|
+
baseArgs.top_p = undefined;
|
|
234
|
+
warnings.push({
|
|
235
|
+
type: "unsupported",
|
|
236
|
+
feature: "topP",
|
|
237
|
+
details: "topP is not supported for reasoning models",
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
if (openaiOptions?.reasoningEffort != null) {
|
|
243
|
+
warnings.push({
|
|
244
|
+
type: "unsupported",
|
|
245
|
+
feature: "reasoningEffort",
|
|
246
|
+
details: "reasoningEffort is not supported for non-reasoning models",
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
if (openaiOptions?.reasoningSummary != null) {
|
|
250
|
+
warnings.push({
|
|
251
|
+
type: "unsupported",
|
|
252
|
+
feature: "reasoningSummary",
|
|
253
|
+
details: "reasoningSummary is not supported for non-reasoning models",
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// Validate flex processing support
|
|
258
|
+
if (openaiOptions?.serviceTier === "flex" && !modelConfig.supportsFlexProcessing) {
|
|
259
|
+
warnings.push({
|
|
260
|
+
type: "unsupported",
|
|
261
|
+
feature: "serviceTier",
|
|
262
|
+
details: "flex processing is only available for o3, o4-mini, and gpt-5 models",
|
|
263
|
+
});
|
|
264
|
+
// Remove from args if not supported
|
|
265
|
+
baseArgs.service_tier = undefined;
|
|
266
|
+
}
|
|
267
|
+
// Validate priority processing support
|
|
268
|
+
if (openaiOptions?.serviceTier === "priority" && !modelConfig.supportsPriorityProcessing) {
|
|
269
|
+
warnings.push({
|
|
270
|
+
type: "unsupported",
|
|
271
|
+
feature: "serviceTier",
|
|
272
|
+
details: "priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported",
|
|
273
|
+
});
|
|
274
|
+
// Remove from args if not supported
|
|
275
|
+
baseArgs.service_tier = undefined;
|
|
276
|
+
}
|
|
277
|
+
const { tools: openaiTools, toolChoice: openaiToolChoice, toolWarnings, } = prepareResponsesTools({
|
|
278
|
+
tools,
|
|
279
|
+
toolChoice,
|
|
280
|
+
strictJsonSchema,
|
|
281
|
+
});
|
|
282
|
+
return {
|
|
283
|
+
webSearchToolName,
|
|
284
|
+
args: {
|
|
285
|
+
...baseArgs,
|
|
286
|
+
tools: openaiTools,
|
|
287
|
+
tool_choice: openaiToolChoice,
|
|
288
|
+
},
|
|
289
|
+
warnings: [...warnings, ...toolWarnings],
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
async doGenerate(options) {
|
|
293
|
+
const { args: body, warnings, webSearchToolName } = await this.getArgs(options);
|
|
294
|
+
const url = this.config.url({
|
|
295
|
+
path: "/responses",
|
|
296
|
+
modelId: this.modelId,
|
|
297
|
+
});
|
|
298
|
+
const { responseHeaders, value: response, rawValue: rawResponse, } = await postJsonToApi({
|
|
299
|
+
url,
|
|
300
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
301
|
+
body,
|
|
302
|
+
failedResponseHandler: openaiFailedResponseHandler,
|
|
303
|
+
successfulResponseHandler: createJsonResponseHandler(z.object({
|
|
304
|
+
id: z.string(),
|
|
305
|
+
created_at: z.number(),
|
|
306
|
+
error: z
|
|
307
|
+
.object({
|
|
308
|
+
code: z.string(),
|
|
309
|
+
message: z.string(),
|
|
310
|
+
})
|
|
311
|
+
.nullish(),
|
|
312
|
+
model: z.string(),
|
|
313
|
+
output: z.array(z.discriminatedUnion("type", [
|
|
314
|
+
z.object({
|
|
315
|
+
type: z.literal("message"),
|
|
316
|
+
role: z.literal("assistant"),
|
|
317
|
+
id: z.string(),
|
|
318
|
+
content: z.array(z.object({
|
|
319
|
+
type: z.literal("output_text"),
|
|
320
|
+
text: z.string(),
|
|
321
|
+
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
322
|
+
annotations: z.array(z.discriminatedUnion("type", [
|
|
323
|
+
z.object({
|
|
324
|
+
type: z.literal("url_citation"),
|
|
325
|
+
start_index: z.number(),
|
|
326
|
+
end_index: z.number(),
|
|
327
|
+
url: z.string(),
|
|
328
|
+
title: z.string(),
|
|
329
|
+
}),
|
|
330
|
+
z.object({
|
|
331
|
+
type: z.literal("file_citation"),
|
|
332
|
+
file_id: z.string(),
|
|
333
|
+
filename: z.string().nullish(),
|
|
334
|
+
index: z.number().nullish(),
|
|
335
|
+
start_index: z.number().nullish(),
|
|
336
|
+
end_index: z.number().nullish(),
|
|
337
|
+
quote: z.string().nullish(),
|
|
338
|
+
}),
|
|
339
|
+
z.object({
|
|
340
|
+
type: z.literal("container_file_citation"),
|
|
341
|
+
}),
|
|
342
|
+
])),
|
|
343
|
+
})),
|
|
344
|
+
}),
|
|
345
|
+
webSearchCallItem,
|
|
346
|
+
fileSearchCallItem,
|
|
347
|
+
codeInterpreterCallItem,
|
|
348
|
+
imageGenerationCallItem,
|
|
349
|
+
localShellCallItem,
|
|
350
|
+
z.object({
|
|
351
|
+
type: z.literal("function_call"),
|
|
352
|
+
call_id: z.string(),
|
|
353
|
+
name: z.string(),
|
|
354
|
+
arguments: z.string(),
|
|
355
|
+
id: z.string(),
|
|
356
|
+
}),
|
|
357
|
+
z.object({
|
|
358
|
+
type: z.literal("computer_call"),
|
|
359
|
+
id: z.string(),
|
|
360
|
+
status: z.string().optional(),
|
|
361
|
+
}),
|
|
362
|
+
z.object({
|
|
363
|
+
type: z.literal("reasoning"),
|
|
364
|
+
id: z.string(),
|
|
365
|
+
encrypted_content: z.string().nullish(),
|
|
366
|
+
summary: z.array(z.object({
|
|
367
|
+
type: z.literal("summary_text"),
|
|
368
|
+
text: z.string(),
|
|
369
|
+
})),
|
|
370
|
+
}),
|
|
371
|
+
])),
|
|
372
|
+
service_tier: z.string().nullish(),
|
|
373
|
+
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
374
|
+
usage: usageSchema,
|
|
375
|
+
})),
|
|
376
|
+
abortSignal: options.abortSignal,
|
|
377
|
+
fetch: this.config.fetch,
|
|
378
|
+
});
|
|
379
|
+
if (response.error) {
|
|
380
|
+
throw new APICallError({
|
|
381
|
+
message: response.error.message,
|
|
382
|
+
url,
|
|
383
|
+
requestBodyValues: body,
|
|
384
|
+
statusCode: 400,
|
|
385
|
+
responseHeaders,
|
|
386
|
+
responseBody: rawResponse,
|
|
387
|
+
isRetryable: false,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
const content = [];
|
|
391
|
+
const logprobs = [];
|
|
392
|
+
// flag that checks if there have been client-side tool calls (not executed by openai)
|
|
393
|
+
let hasFunctionCall = false;
|
|
394
|
+
// map response content to content array
|
|
395
|
+
for (const part of response.output) {
|
|
396
|
+
switch (part.type) {
|
|
397
|
+
case "reasoning": {
|
|
398
|
+
// when there are no summary parts, we need to add an empty reasoning part:
|
|
399
|
+
if (part.summary.length === 0) {
|
|
400
|
+
part.summary.push({ type: "summary_text", text: "" });
|
|
401
|
+
}
|
|
402
|
+
for (const summary of part.summary) {
|
|
403
|
+
content.push({
|
|
404
|
+
type: "reasoning",
|
|
405
|
+
text: summary.text,
|
|
406
|
+
providerMetadata: {
|
|
407
|
+
copilot: {
|
|
408
|
+
itemId: part.id,
|
|
409
|
+
reasoningEncryptedContent: part.encrypted_content ?? null,
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
case "image_generation_call": {
|
|
417
|
+
content.push({
|
|
418
|
+
type: "tool-call",
|
|
419
|
+
toolCallId: part.id,
|
|
420
|
+
toolName: "image_generation",
|
|
421
|
+
input: "{}",
|
|
422
|
+
providerExecuted: true,
|
|
423
|
+
});
|
|
424
|
+
content.push({
|
|
425
|
+
type: "tool-result",
|
|
426
|
+
toolCallId: part.id,
|
|
427
|
+
toolName: "image_generation",
|
|
428
|
+
result: {
|
|
429
|
+
result: part.result,
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
case "local_shell_call": {
|
|
435
|
+
content.push({
|
|
436
|
+
type: "tool-call",
|
|
437
|
+
toolCallId: part.call_id,
|
|
438
|
+
toolName: "local_shell",
|
|
439
|
+
input: JSON.stringify({ action: part.action }),
|
|
440
|
+
providerMetadata: {
|
|
441
|
+
copilot: {
|
|
442
|
+
itemId: part.id,
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
case "message": {
|
|
449
|
+
for (const contentPart of part.content) {
|
|
450
|
+
if (options.providerOptions?.copilot?.logprobs && contentPart.logprobs) {
|
|
451
|
+
logprobs.push(contentPart.logprobs);
|
|
452
|
+
}
|
|
453
|
+
content.push({
|
|
454
|
+
type: "text",
|
|
455
|
+
text: contentPart.text,
|
|
456
|
+
providerMetadata: {
|
|
457
|
+
copilot: {
|
|
458
|
+
itemId: part.id,
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
for (const annotation of contentPart.annotations) {
|
|
463
|
+
if (annotation.type === "url_citation") {
|
|
464
|
+
content.push({
|
|
465
|
+
type: "source",
|
|
466
|
+
sourceType: "url",
|
|
467
|
+
id: this.config.generateId?.() ?? generateId(),
|
|
468
|
+
url: annotation.url,
|
|
469
|
+
title: annotation.title,
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
else if (annotation.type === "file_citation") {
|
|
473
|
+
content.push({
|
|
474
|
+
type: "source",
|
|
475
|
+
sourceType: "document",
|
|
476
|
+
id: this.config.generateId?.() ?? generateId(),
|
|
477
|
+
mediaType: "text/plain",
|
|
478
|
+
title: annotation.quote ?? annotation.filename ?? "Document",
|
|
479
|
+
filename: annotation.filename ?? annotation.file_id,
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
case "function_call": {
|
|
487
|
+
hasFunctionCall = true;
|
|
488
|
+
content.push({
|
|
489
|
+
type: "tool-call",
|
|
490
|
+
toolCallId: part.call_id,
|
|
491
|
+
toolName: part.name,
|
|
492
|
+
input: part.arguments,
|
|
493
|
+
providerMetadata: {
|
|
494
|
+
copilot: {
|
|
495
|
+
itemId: part.id,
|
|
496
|
+
},
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
case "web_search_call": {
|
|
502
|
+
content.push({
|
|
503
|
+
type: "tool-call",
|
|
504
|
+
toolCallId: part.id,
|
|
505
|
+
toolName: webSearchToolName ?? "web_search",
|
|
506
|
+
input: JSON.stringify({ action: part.action }),
|
|
507
|
+
providerExecuted: true,
|
|
508
|
+
});
|
|
509
|
+
content.push({
|
|
510
|
+
type: "tool-result",
|
|
511
|
+
toolCallId: part.id,
|
|
512
|
+
toolName: webSearchToolName ?? "web_search",
|
|
513
|
+
result: { status: part.status },
|
|
514
|
+
});
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
case "computer_call": {
|
|
518
|
+
content.push({
|
|
519
|
+
type: "tool-call",
|
|
520
|
+
toolCallId: part.id,
|
|
521
|
+
toolName: "computer_use",
|
|
522
|
+
input: "",
|
|
523
|
+
providerExecuted: true,
|
|
524
|
+
});
|
|
525
|
+
content.push({
|
|
526
|
+
type: "tool-result",
|
|
527
|
+
toolCallId: part.id,
|
|
528
|
+
toolName: "computer_use",
|
|
529
|
+
result: {
|
|
530
|
+
type: "computer_use_tool_result",
|
|
531
|
+
status: part.status || "completed",
|
|
532
|
+
},
|
|
533
|
+
});
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
case "file_search_call": {
|
|
537
|
+
content.push({
|
|
538
|
+
type: "tool-call",
|
|
539
|
+
toolCallId: part.id,
|
|
540
|
+
toolName: "file_search",
|
|
541
|
+
input: "{}",
|
|
542
|
+
providerExecuted: true,
|
|
543
|
+
});
|
|
544
|
+
content.push({
|
|
545
|
+
type: "tool-result",
|
|
546
|
+
toolCallId: part.id,
|
|
547
|
+
toolName: "file_search",
|
|
548
|
+
result: {
|
|
549
|
+
queries: part.queries,
|
|
550
|
+
results: part.results?.map((result) => ({
|
|
551
|
+
attributes: result.attributes,
|
|
552
|
+
fileId: result.file_id,
|
|
553
|
+
filename: result.filename,
|
|
554
|
+
score: result.score,
|
|
555
|
+
text: result.text,
|
|
556
|
+
})) ?? null,
|
|
557
|
+
},
|
|
558
|
+
});
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
case "code_interpreter_call": {
|
|
562
|
+
content.push({
|
|
563
|
+
type: "tool-call",
|
|
564
|
+
toolCallId: part.id,
|
|
565
|
+
toolName: "code_interpreter",
|
|
566
|
+
input: JSON.stringify({
|
|
567
|
+
code: part.code,
|
|
568
|
+
containerId: part.container_id,
|
|
569
|
+
}),
|
|
570
|
+
providerExecuted: true,
|
|
571
|
+
});
|
|
572
|
+
content.push({
|
|
573
|
+
type: "tool-result",
|
|
574
|
+
toolCallId: part.id,
|
|
575
|
+
toolName: "code_interpreter",
|
|
576
|
+
result: {
|
|
577
|
+
outputs: part.outputs,
|
|
578
|
+
},
|
|
579
|
+
});
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
const providerMetadata = {
|
|
585
|
+
copilot: { responseId: response.id },
|
|
586
|
+
};
|
|
587
|
+
if (logprobs.length > 0) {
|
|
588
|
+
providerMetadata.copilot.logprobs = logprobs;
|
|
589
|
+
}
|
|
590
|
+
if (typeof response.service_tier === "string") {
|
|
591
|
+
providerMetadata.copilot.serviceTier = response.service_tier;
|
|
592
|
+
}
|
|
593
|
+
return {
|
|
594
|
+
content,
|
|
595
|
+
finishReason: {
|
|
596
|
+
unified: mapOpenAIResponseFinishReason({
|
|
597
|
+
finishReason: response.incomplete_details?.reason,
|
|
598
|
+
hasFunctionCall,
|
|
599
|
+
}),
|
|
600
|
+
raw: response.incomplete_details?.reason,
|
|
601
|
+
},
|
|
602
|
+
usage: {
|
|
603
|
+
inputTokens: {
|
|
604
|
+
total: response.usage.input_tokens,
|
|
605
|
+
noCache: response.usage.input_tokens_details?.cached_tokens != null
|
|
606
|
+
? response.usage.input_tokens - response.usage.input_tokens_details.cached_tokens
|
|
607
|
+
: undefined,
|
|
608
|
+
cacheRead: response.usage.input_tokens_details?.cached_tokens ?? undefined,
|
|
609
|
+
cacheWrite: undefined,
|
|
610
|
+
},
|
|
611
|
+
outputTokens: {
|
|
612
|
+
total: response.usage.output_tokens,
|
|
613
|
+
text: undefined,
|
|
614
|
+
reasoning: response.usage.output_tokens_details?.reasoning_tokens ?? undefined,
|
|
615
|
+
},
|
|
616
|
+
raw: response.usage,
|
|
617
|
+
},
|
|
618
|
+
request: { body },
|
|
619
|
+
response: {
|
|
620
|
+
id: response.id,
|
|
621
|
+
timestamp: new Date(response.created_at * 1000),
|
|
622
|
+
modelId: response.model,
|
|
623
|
+
headers: responseHeaders,
|
|
624
|
+
body: rawResponse,
|
|
625
|
+
},
|
|
626
|
+
providerMetadata,
|
|
627
|
+
warnings,
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
async doStream(options) {
|
|
631
|
+
const { args: body, warnings, webSearchToolName } = await this.getArgs(options);
|
|
632
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
633
|
+
url: this.config.url({
|
|
634
|
+
path: "/responses",
|
|
635
|
+
modelId: this.modelId,
|
|
636
|
+
}),
|
|
637
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
638
|
+
body: {
|
|
639
|
+
...body,
|
|
640
|
+
stream: true,
|
|
641
|
+
},
|
|
642
|
+
failedResponseHandler: openaiFailedResponseHandler,
|
|
643
|
+
successfulResponseHandler: createEventSourceResponseHandler(openaiResponsesChunkSchema),
|
|
644
|
+
abortSignal: options.abortSignal,
|
|
645
|
+
fetch: this.config.fetch,
|
|
646
|
+
});
|
|
647
|
+
// oxlint-disable-next-line no-this-alias -- needed for closure scope inside generator
|
|
648
|
+
const self = this;
|
|
649
|
+
let finishReason = {
|
|
650
|
+
unified: "other",
|
|
651
|
+
raw: undefined,
|
|
652
|
+
};
|
|
653
|
+
const usage = {
|
|
654
|
+
inputTokens: undefined,
|
|
655
|
+
outputTokens: undefined,
|
|
656
|
+
totalTokens: undefined,
|
|
657
|
+
reasoningTokens: undefined,
|
|
658
|
+
cachedInputTokens: undefined,
|
|
659
|
+
};
|
|
660
|
+
const logprobs = [];
|
|
661
|
+
let responseId = null;
|
|
662
|
+
const ongoingToolCalls = {};
|
|
663
|
+
// flag that checks if there have been client-side tool calls (not executed by openai)
|
|
664
|
+
let hasFunctionCall = false;
|
|
665
|
+
// Track reasoning by output_index instead of item_id
|
|
666
|
+
// GitHub Copilot rotates encrypted item IDs on every event
|
|
667
|
+
const activeReasoning = {};
|
|
668
|
+
// Track current active reasoning output_index for correlating summary events
|
|
669
|
+
let currentReasoningOutputIndex = null;
|
|
670
|
+
// Track a stable text part id for the current assistant message.
|
|
671
|
+
// Copilot may change item_id across text deltas; normalize to one id.
|
|
672
|
+
let currentTextId = null;
|
|
673
|
+
let serviceTier;
|
|
674
|
+
return {
|
|
675
|
+
stream: response.pipeThrough(new TransformStream({
|
|
676
|
+
start(controller) {
|
|
677
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
678
|
+
},
|
|
679
|
+
transform(chunk, controller) {
|
|
680
|
+
if (options.includeRawChunks) {
|
|
681
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
682
|
+
}
|
|
683
|
+
// handle failed chunk parsing / validation:
|
|
684
|
+
if (!chunk.success) {
|
|
685
|
+
finishReason = {
|
|
686
|
+
unified: "error",
|
|
687
|
+
raw: undefined,
|
|
688
|
+
};
|
|
689
|
+
controller.enqueue({ type: "error", error: chunk.error });
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
const value = chunk.value;
|
|
693
|
+
if (isResponseOutputItemAddedChunk(value)) {
|
|
694
|
+
if (value.item.type === "function_call") {
|
|
695
|
+
ongoingToolCalls[value.output_index] = {
|
|
696
|
+
toolName: value.item.name,
|
|
697
|
+
toolCallId: value.item.call_id,
|
|
698
|
+
};
|
|
699
|
+
controller.enqueue({
|
|
700
|
+
type: "tool-input-start",
|
|
701
|
+
id: value.item.call_id,
|
|
702
|
+
toolName: value.item.name,
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
else if (value.item.type === "web_search_call") {
|
|
706
|
+
ongoingToolCalls[value.output_index] = {
|
|
707
|
+
toolName: webSearchToolName ?? "web_search",
|
|
708
|
+
toolCallId: value.item.id,
|
|
709
|
+
};
|
|
710
|
+
controller.enqueue({
|
|
711
|
+
type: "tool-input-start",
|
|
712
|
+
id: value.item.id,
|
|
713
|
+
toolName: webSearchToolName ?? "web_search",
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
else if (value.item.type === "computer_call") {
|
|
717
|
+
ongoingToolCalls[value.output_index] = {
|
|
718
|
+
toolName: "computer_use",
|
|
719
|
+
toolCallId: value.item.id,
|
|
720
|
+
};
|
|
721
|
+
controller.enqueue({
|
|
722
|
+
type: "tool-input-start",
|
|
723
|
+
id: value.item.id,
|
|
724
|
+
toolName: "computer_use",
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
else if (value.item.type === "code_interpreter_call") {
|
|
728
|
+
ongoingToolCalls[value.output_index] = {
|
|
729
|
+
toolName: "code_interpreter",
|
|
730
|
+
toolCallId: value.item.id,
|
|
731
|
+
codeInterpreter: {
|
|
732
|
+
containerId: value.item.container_id,
|
|
733
|
+
},
|
|
734
|
+
};
|
|
735
|
+
controller.enqueue({
|
|
736
|
+
type: "tool-input-start",
|
|
737
|
+
id: value.item.id,
|
|
738
|
+
toolName: "code_interpreter",
|
|
739
|
+
});
|
|
740
|
+
controller.enqueue({
|
|
741
|
+
type: "tool-input-delta",
|
|
742
|
+
id: value.item.id,
|
|
743
|
+
delta: `{"containerId":"${value.item.container_id}","code":"`,
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
else if (value.item.type === "file_search_call") {
|
|
747
|
+
controller.enqueue({
|
|
748
|
+
type: "tool-call",
|
|
749
|
+
toolCallId: value.item.id,
|
|
750
|
+
toolName: "file_search",
|
|
751
|
+
input: "{}",
|
|
752
|
+
providerExecuted: true,
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
else if (value.item.type === "image_generation_call") {
|
|
756
|
+
controller.enqueue({
|
|
757
|
+
type: "tool-call",
|
|
758
|
+
toolCallId: value.item.id,
|
|
759
|
+
toolName: "image_generation",
|
|
760
|
+
input: "{}",
|
|
761
|
+
providerExecuted: true,
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
else if (value.item.type === "message") {
|
|
765
|
+
// Start a stable text part for this assistant message
|
|
766
|
+
currentTextId = value.item.id;
|
|
767
|
+
controller.enqueue({
|
|
768
|
+
type: "text-start",
|
|
769
|
+
id: value.item.id,
|
|
770
|
+
providerMetadata: {
|
|
771
|
+
copilot: {
|
|
772
|
+
itemId: value.item.id,
|
|
773
|
+
},
|
|
774
|
+
},
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
else if (isResponseOutputItemAddedReasoningChunk(value)) {
|
|
778
|
+
activeReasoning[value.output_index] = {
|
|
779
|
+
canonicalId: value.item.id,
|
|
780
|
+
encryptedContent: value.item.encrypted_content,
|
|
781
|
+
summaryParts: [0],
|
|
782
|
+
};
|
|
783
|
+
currentReasoningOutputIndex = value.output_index;
|
|
784
|
+
controller.enqueue({
|
|
785
|
+
type: "reasoning-start",
|
|
786
|
+
id: `${value.item.id}:0`,
|
|
787
|
+
providerMetadata: {
|
|
788
|
+
copilot: {
|
|
789
|
+
itemId: value.item.id,
|
|
790
|
+
reasoningEncryptedContent: value.item.encrypted_content ?? null,
|
|
791
|
+
},
|
|
792
|
+
},
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
else if (isResponseOutputItemDoneChunk(value)) {
|
|
797
|
+
if (value.item.type === "function_call") {
|
|
798
|
+
ongoingToolCalls[value.output_index] = undefined;
|
|
799
|
+
hasFunctionCall = true;
|
|
800
|
+
controller.enqueue({
|
|
801
|
+
type: "tool-input-end",
|
|
802
|
+
id: value.item.call_id,
|
|
803
|
+
});
|
|
804
|
+
controller.enqueue({
|
|
805
|
+
type: "tool-call",
|
|
806
|
+
toolCallId: value.item.call_id,
|
|
807
|
+
toolName: value.item.name,
|
|
808
|
+
input: value.item.arguments,
|
|
809
|
+
providerMetadata: {
|
|
810
|
+
copilot: {
|
|
811
|
+
itemId: value.item.id,
|
|
812
|
+
},
|
|
813
|
+
},
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
else if (value.item.type === "web_search_call") {
|
|
817
|
+
ongoingToolCalls[value.output_index] = undefined;
|
|
818
|
+
controller.enqueue({
|
|
819
|
+
type: "tool-input-end",
|
|
820
|
+
id: value.item.id,
|
|
821
|
+
});
|
|
822
|
+
controller.enqueue({
|
|
823
|
+
type: "tool-call",
|
|
824
|
+
toolCallId: value.item.id,
|
|
825
|
+
toolName: "web_search",
|
|
826
|
+
input: JSON.stringify({ action: value.item.action }),
|
|
827
|
+
providerExecuted: true,
|
|
828
|
+
});
|
|
829
|
+
controller.enqueue({
|
|
830
|
+
type: "tool-result",
|
|
831
|
+
toolCallId: value.item.id,
|
|
832
|
+
toolName: "web_search",
|
|
833
|
+
result: { status: value.item.status },
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
else if (value.item.type === "computer_call") {
|
|
837
|
+
ongoingToolCalls[value.output_index] = undefined;
|
|
838
|
+
controller.enqueue({
|
|
839
|
+
type: "tool-input-end",
|
|
840
|
+
id: value.item.id,
|
|
841
|
+
});
|
|
842
|
+
controller.enqueue({
|
|
843
|
+
type: "tool-call",
|
|
844
|
+
toolCallId: value.item.id,
|
|
845
|
+
toolName: "computer_use",
|
|
846
|
+
input: "",
|
|
847
|
+
providerExecuted: true,
|
|
848
|
+
});
|
|
849
|
+
controller.enqueue({
|
|
850
|
+
type: "tool-result",
|
|
851
|
+
toolCallId: value.item.id,
|
|
852
|
+
toolName: "computer_use",
|
|
853
|
+
result: {
|
|
854
|
+
type: "computer_use_tool_result",
|
|
855
|
+
status: value.item.status || "completed",
|
|
856
|
+
},
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
else if (value.item.type === "file_search_call") {
|
|
860
|
+
ongoingToolCalls[value.output_index] = undefined;
|
|
861
|
+
controller.enqueue({
|
|
862
|
+
type: "tool-result",
|
|
863
|
+
toolCallId: value.item.id,
|
|
864
|
+
toolName: "file_search",
|
|
865
|
+
result: {
|
|
866
|
+
queries: value.item.queries,
|
|
867
|
+
results: value.item.results?.map((result) => ({
|
|
868
|
+
attributes: result.attributes,
|
|
869
|
+
fileId: result.file_id,
|
|
870
|
+
filename: result.filename,
|
|
871
|
+
score: result.score,
|
|
872
|
+
text: result.text,
|
|
873
|
+
})) ?? null,
|
|
874
|
+
},
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
else if (value.item.type === "code_interpreter_call") {
|
|
878
|
+
ongoingToolCalls[value.output_index] = undefined;
|
|
879
|
+
controller.enqueue({
|
|
880
|
+
type: "tool-result",
|
|
881
|
+
toolCallId: value.item.id,
|
|
882
|
+
toolName: "code_interpreter",
|
|
883
|
+
result: {
|
|
884
|
+
outputs: value.item.outputs,
|
|
885
|
+
},
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
else if (value.item.type === "image_generation_call") {
|
|
889
|
+
controller.enqueue({
|
|
890
|
+
type: "tool-result",
|
|
891
|
+
toolCallId: value.item.id,
|
|
892
|
+
toolName: "image_generation",
|
|
893
|
+
result: {
|
|
894
|
+
result: value.item.result,
|
|
895
|
+
},
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
else if (value.item.type === "local_shell_call") {
|
|
899
|
+
ongoingToolCalls[value.output_index] = undefined;
|
|
900
|
+
controller.enqueue({
|
|
901
|
+
type: "tool-call",
|
|
902
|
+
toolCallId: value.item.call_id,
|
|
903
|
+
toolName: "local_shell",
|
|
904
|
+
input: JSON.stringify({
|
|
905
|
+
action: {
|
|
906
|
+
type: "exec",
|
|
907
|
+
command: value.item.action.command,
|
|
908
|
+
timeoutMs: value.item.action.timeout_ms,
|
|
909
|
+
user: value.item.action.user,
|
|
910
|
+
workingDirectory: value.item.action.working_directory,
|
|
911
|
+
env: value.item.action.env,
|
|
912
|
+
},
|
|
913
|
+
}),
|
|
914
|
+
providerMetadata: {
|
|
915
|
+
copilot: { itemId: value.item.id },
|
|
916
|
+
},
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
else if (value.item.type === "message") {
|
|
920
|
+
if (currentTextId) {
|
|
921
|
+
controller.enqueue({
|
|
922
|
+
type: "text-end",
|
|
923
|
+
id: currentTextId,
|
|
924
|
+
});
|
|
925
|
+
currentTextId = null;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
else if (isResponseOutputItemDoneReasoningChunk(value)) {
|
|
929
|
+
const activeReasoningPart = activeReasoning[value.output_index];
|
|
930
|
+
if (activeReasoningPart) {
|
|
931
|
+
for (const summaryIndex of activeReasoningPart.summaryParts) {
|
|
932
|
+
controller.enqueue({
|
|
933
|
+
type: "reasoning-end",
|
|
934
|
+
id: `${activeReasoningPart.canonicalId}:${summaryIndex}`,
|
|
935
|
+
providerMetadata: {
|
|
936
|
+
copilot: {
|
|
937
|
+
itemId: activeReasoningPart.canonicalId,
|
|
938
|
+
reasoningEncryptedContent: value.item.encrypted_content ?? null,
|
|
939
|
+
},
|
|
940
|
+
},
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
delete activeReasoning[value.output_index];
|
|
944
|
+
if (currentReasoningOutputIndex === value.output_index) {
|
|
945
|
+
currentReasoningOutputIndex = null;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
|
|
951
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
952
|
+
if (toolCall != null) {
|
|
953
|
+
controller.enqueue({
|
|
954
|
+
type: "tool-input-delta",
|
|
955
|
+
id: toolCall.toolCallId,
|
|
956
|
+
delta: value.delta,
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
else if (isResponseImageGenerationCallPartialImageChunk(value)) {
|
|
961
|
+
controller.enqueue({
|
|
962
|
+
type: "tool-result",
|
|
963
|
+
toolCallId: value.item_id,
|
|
964
|
+
toolName: "image_generation",
|
|
965
|
+
result: {
|
|
966
|
+
result: value.partial_image_b64,
|
|
967
|
+
},
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
|
|
971
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
972
|
+
if (toolCall != null) {
|
|
973
|
+
controller.enqueue({
|
|
974
|
+
type: "tool-input-delta",
|
|
975
|
+
id: toolCall.toolCallId,
|
|
976
|
+
// The delta is code, which is embedding in a JSON string.
|
|
977
|
+
// To escape it, we use JSON.stringify and slice to remove the outer quotes.
|
|
978
|
+
delta: JSON.stringify(value.delta).slice(1, -1),
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
|
|
983
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
984
|
+
if (toolCall != null) {
|
|
985
|
+
controller.enqueue({
|
|
986
|
+
type: "tool-input-delta",
|
|
987
|
+
id: toolCall.toolCallId,
|
|
988
|
+
delta: '"}',
|
|
989
|
+
});
|
|
990
|
+
controller.enqueue({
|
|
991
|
+
type: "tool-input-end",
|
|
992
|
+
id: toolCall.toolCallId,
|
|
993
|
+
});
|
|
994
|
+
// immediately send the tool call after the input end:
|
|
995
|
+
controller.enqueue({
|
|
996
|
+
type: "tool-call",
|
|
997
|
+
toolCallId: toolCall.toolCallId,
|
|
998
|
+
toolName: "code_interpreter",
|
|
999
|
+
input: JSON.stringify({
|
|
1000
|
+
code: value.code,
|
|
1001
|
+
containerId: toolCall.codeInterpreter.containerId,
|
|
1002
|
+
}),
|
|
1003
|
+
providerExecuted: true,
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
else if (isResponseCreatedChunk(value)) {
|
|
1008
|
+
responseId = value.response.id;
|
|
1009
|
+
controller.enqueue({
|
|
1010
|
+
type: "response-metadata",
|
|
1011
|
+
id: value.response.id,
|
|
1012
|
+
timestamp: new Date(value.response.created_at * 1000),
|
|
1013
|
+
modelId: value.response.model,
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
else if (isTextDeltaChunk(value)) {
|
|
1017
|
+
// Ensure a text-start exists, and normalize deltas to a stable id
|
|
1018
|
+
if (!currentTextId) {
|
|
1019
|
+
currentTextId = value.item_id;
|
|
1020
|
+
controller.enqueue({
|
|
1021
|
+
type: "text-start",
|
|
1022
|
+
id: currentTextId,
|
|
1023
|
+
providerMetadata: {
|
|
1024
|
+
copilot: { itemId: value.item_id },
|
|
1025
|
+
},
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
controller.enqueue({
|
|
1029
|
+
type: "text-delta",
|
|
1030
|
+
id: currentTextId,
|
|
1031
|
+
delta: value.delta,
|
|
1032
|
+
});
|
|
1033
|
+
if (options.providerOptions?.copilot?.logprobs && value.logprobs) {
|
|
1034
|
+
logprobs.push(value.logprobs);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
else if (isResponseReasoningSummaryPartAddedChunk(value)) {
|
|
1038
|
+
const activeItem = currentReasoningOutputIndex !== null ? activeReasoning[currentReasoningOutputIndex] : null;
|
|
1039
|
+
// the first reasoning start is pushed in isResponseOutputItemAddedReasoningChunk.
|
|
1040
|
+
if (activeItem && value.summary_index > 0) {
|
|
1041
|
+
activeItem.summaryParts.push(value.summary_index);
|
|
1042
|
+
controller.enqueue({
|
|
1043
|
+
type: "reasoning-start",
|
|
1044
|
+
id: `${activeItem.canonicalId}:${value.summary_index}`,
|
|
1045
|
+
providerMetadata: {
|
|
1046
|
+
copilot: {
|
|
1047
|
+
itemId: activeItem.canonicalId,
|
|
1048
|
+
reasoningEncryptedContent: activeItem.encryptedContent ?? null,
|
|
1049
|
+
},
|
|
1050
|
+
},
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
|
|
1055
|
+
const activeItem = currentReasoningOutputIndex !== null ? activeReasoning[currentReasoningOutputIndex] : null;
|
|
1056
|
+
if (activeItem) {
|
|
1057
|
+
controller.enqueue({
|
|
1058
|
+
type: "reasoning-delta",
|
|
1059
|
+
id: `${activeItem.canonicalId}:${value.summary_index}`,
|
|
1060
|
+
delta: value.delta,
|
|
1061
|
+
providerMetadata: {
|
|
1062
|
+
copilot: {
|
|
1063
|
+
itemId: activeItem.canonicalId,
|
|
1064
|
+
},
|
|
1065
|
+
},
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
else if (isResponseFinishedChunk(value)) {
|
|
1070
|
+
finishReason = {
|
|
1071
|
+
unified: mapOpenAIResponseFinishReason({
|
|
1072
|
+
finishReason: value.response.incomplete_details?.reason,
|
|
1073
|
+
hasFunctionCall,
|
|
1074
|
+
}),
|
|
1075
|
+
raw: value.response.incomplete_details?.reason ?? undefined,
|
|
1076
|
+
};
|
|
1077
|
+
usage.inputTokens = value.response.usage.input_tokens;
|
|
1078
|
+
usage.outputTokens = value.response.usage.output_tokens;
|
|
1079
|
+
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
1080
|
+
usage.reasoningTokens = value.response.usage.output_tokens_details?.reasoning_tokens ?? undefined;
|
|
1081
|
+
usage.cachedInputTokens = value.response.usage.input_tokens_details?.cached_tokens ?? undefined;
|
|
1082
|
+
if (typeof value.response.service_tier === "string") {
|
|
1083
|
+
serviceTier = value.response.service_tier;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
else if (isResponseAnnotationAddedChunk(value)) {
|
|
1087
|
+
if (value.annotation.type === "url_citation") {
|
|
1088
|
+
controller.enqueue({
|
|
1089
|
+
type: "source",
|
|
1090
|
+
sourceType: "url",
|
|
1091
|
+
id: self.config.generateId?.() ?? generateId(),
|
|
1092
|
+
url: value.annotation.url,
|
|
1093
|
+
title: value.annotation.title,
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
else if (value.annotation.type === "file_citation") {
|
|
1097
|
+
controller.enqueue({
|
|
1098
|
+
type: "source",
|
|
1099
|
+
sourceType: "document",
|
|
1100
|
+
id: self.config.generateId?.() ?? generateId(),
|
|
1101
|
+
mediaType: "text/plain",
|
|
1102
|
+
title: value.annotation.quote ?? value.annotation.filename ?? "Document",
|
|
1103
|
+
filename: value.annotation.filename ?? value.annotation.file_id,
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
else if (isErrorChunk(value)) {
|
|
1108
|
+
controller.enqueue({ type: "error", error: value });
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
flush(controller) {
|
|
1112
|
+
// Close any dangling text part
|
|
1113
|
+
if (currentTextId) {
|
|
1114
|
+
controller.enqueue({ type: "text-end", id: currentTextId });
|
|
1115
|
+
currentTextId = null;
|
|
1116
|
+
}
|
|
1117
|
+
const providerMetadata = {
|
|
1118
|
+
copilot: {
|
|
1119
|
+
responseId,
|
|
1120
|
+
},
|
|
1121
|
+
};
|
|
1122
|
+
if (logprobs.length > 0) {
|
|
1123
|
+
providerMetadata.copilot.logprobs = logprobs;
|
|
1124
|
+
}
|
|
1125
|
+
if (serviceTier !== undefined) {
|
|
1126
|
+
providerMetadata.copilot.serviceTier = serviceTier;
|
|
1127
|
+
}
|
|
1128
|
+
controller.enqueue({
|
|
1129
|
+
type: "finish",
|
|
1130
|
+
finishReason,
|
|
1131
|
+
usage: {
|
|
1132
|
+
inputTokens: {
|
|
1133
|
+
total: usage.inputTokens,
|
|
1134
|
+
noCache: usage.inputTokens != null && usage.cachedInputTokens != null
|
|
1135
|
+
? usage.inputTokens - usage.cachedInputTokens
|
|
1136
|
+
: undefined,
|
|
1137
|
+
cacheRead: usage.cachedInputTokens,
|
|
1138
|
+
cacheWrite: undefined,
|
|
1139
|
+
},
|
|
1140
|
+
outputTokens: {
|
|
1141
|
+
total: usage.outputTokens,
|
|
1142
|
+
text: undefined,
|
|
1143
|
+
reasoning: usage.reasoningTokens,
|
|
1144
|
+
},
|
|
1145
|
+
raw: {
|
|
1146
|
+
input_tokens: usage.inputTokens,
|
|
1147
|
+
output_tokens: usage.outputTokens,
|
|
1148
|
+
total_tokens: usage.totalTokens,
|
|
1149
|
+
},
|
|
1150
|
+
},
|
|
1151
|
+
providerMetadata,
|
|
1152
|
+
});
|
|
1153
|
+
},
|
|
1154
|
+
})),
|
|
1155
|
+
request: { body },
|
|
1156
|
+
response: { headers: responseHeaders },
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
const usageSchema = z.object({
|
|
1161
|
+
input_tokens: z.number(),
|
|
1162
|
+
input_tokens_details: z.object({ cached_tokens: z.number().nullish() }).nullish(),
|
|
1163
|
+
output_tokens: z.number(),
|
|
1164
|
+
output_tokens_details: z.object({ reasoning_tokens: z.number().nullish() }).nullish(),
|
|
1165
|
+
});
|
|
1166
|
+
const textDeltaChunkSchema = z.object({
|
|
1167
|
+
type: z.literal("response.output_text.delta"),
|
|
1168
|
+
item_id: z.string(),
|
|
1169
|
+
delta: z.string(),
|
|
1170
|
+
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
1171
|
+
});
|
|
1172
|
+
const errorChunkSchema = z.object({
|
|
1173
|
+
type: z.literal("error"),
|
|
1174
|
+
code: z.string(),
|
|
1175
|
+
message: z.string(),
|
|
1176
|
+
param: z.string().nullish(),
|
|
1177
|
+
sequence_number: z.number(),
|
|
1178
|
+
});
|
|
1179
|
+
const responseFinishedChunkSchema = z.object({
|
|
1180
|
+
type: z.enum(["response.completed", "response.incomplete"]),
|
|
1181
|
+
response: z.object({
|
|
1182
|
+
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
1183
|
+
usage: usageSchema,
|
|
1184
|
+
service_tier: z.string().nullish(),
|
|
1185
|
+
}),
|
|
1186
|
+
});
|
|
1187
|
+
const responseCreatedChunkSchema = z.object({
|
|
1188
|
+
type: z.literal("response.created"),
|
|
1189
|
+
response: z.object({
|
|
1190
|
+
id: z.string(),
|
|
1191
|
+
created_at: z.number(),
|
|
1192
|
+
model: z.string(),
|
|
1193
|
+
service_tier: z.string().nullish(),
|
|
1194
|
+
}),
|
|
1195
|
+
});
|
|
1196
|
+
const responseOutputItemAddedSchema = z.object({
|
|
1197
|
+
type: z.literal("response.output_item.added"),
|
|
1198
|
+
output_index: z.number(),
|
|
1199
|
+
item: z.discriminatedUnion("type", [
|
|
1200
|
+
z.object({
|
|
1201
|
+
type: z.literal("message"),
|
|
1202
|
+
id: z.string(),
|
|
1203
|
+
}),
|
|
1204
|
+
z.object({
|
|
1205
|
+
type: z.literal("reasoning"),
|
|
1206
|
+
id: z.string(),
|
|
1207
|
+
encrypted_content: z.string().nullish(),
|
|
1208
|
+
}),
|
|
1209
|
+
z.object({
|
|
1210
|
+
type: z.literal("function_call"),
|
|
1211
|
+
id: z.string(),
|
|
1212
|
+
call_id: z.string(),
|
|
1213
|
+
name: z.string(),
|
|
1214
|
+
arguments: z.string(),
|
|
1215
|
+
}),
|
|
1216
|
+
z.object({
|
|
1217
|
+
type: z.literal("web_search_call"),
|
|
1218
|
+
id: z.string(),
|
|
1219
|
+
status: z.string(),
|
|
1220
|
+
action: z
|
|
1221
|
+
.object({
|
|
1222
|
+
type: z.literal("search"),
|
|
1223
|
+
query: z.string().optional(),
|
|
1224
|
+
})
|
|
1225
|
+
.nullish(),
|
|
1226
|
+
}),
|
|
1227
|
+
z.object({
|
|
1228
|
+
type: z.literal("computer_call"),
|
|
1229
|
+
id: z.string(),
|
|
1230
|
+
status: z.string(),
|
|
1231
|
+
}),
|
|
1232
|
+
z.object({
|
|
1233
|
+
type: z.literal("file_search_call"),
|
|
1234
|
+
id: z.string(),
|
|
1235
|
+
}),
|
|
1236
|
+
z.object({
|
|
1237
|
+
type: z.literal("image_generation_call"),
|
|
1238
|
+
id: z.string(),
|
|
1239
|
+
}),
|
|
1240
|
+
z.object({
|
|
1241
|
+
type: z.literal("code_interpreter_call"),
|
|
1242
|
+
id: z.string(),
|
|
1243
|
+
container_id: z.string(),
|
|
1244
|
+
code: z.string().nullable(),
|
|
1245
|
+
outputs: z
|
|
1246
|
+
.array(z.discriminatedUnion("type", [
|
|
1247
|
+
z.object({ type: z.literal("logs"), logs: z.string() }),
|
|
1248
|
+
z.object({ type: z.literal("image"), url: z.string() }),
|
|
1249
|
+
]))
|
|
1250
|
+
.nullable(),
|
|
1251
|
+
status: z.string(),
|
|
1252
|
+
}),
|
|
1253
|
+
]),
|
|
1254
|
+
});
|
|
1255
|
+
const responseOutputItemDoneSchema = z.object({
|
|
1256
|
+
type: z.literal("response.output_item.done"),
|
|
1257
|
+
output_index: z.number(),
|
|
1258
|
+
item: z.discriminatedUnion("type", [
|
|
1259
|
+
z.object({
|
|
1260
|
+
type: z.literal("message"),
|
|
1261
|
+
id: z.string(),
|
|
1262
|
+
}),
|
|
1263
|
+
z.object({
|
|
1264
|
+
type: z.literal("reasoning"),
|
|
1265
|
+
id: z.string(),
|
|
1266
|
+
encrypted_content: z.string().nullish(),
|
|
1267
|
+
}),
|
|
1268
|
+
z.object({
|
|
1269
|
+
type: z.literal("function_call"),
|
|
1270
|
+
id: z.string(),
|
|
1271
|
+
call_id: z.string(),
|
|
1272
|
+
name: z.string(),
|
|
1273
|
+
arguments: z.string(),
|
|
1274
|
+
status: z.literal("completed"),
|
|
1275
|
+
}),
|
|
1276
|
+
codeInterpreterCallItem,
|
|
1277
|
+
imageGenerationCallItem,
|
|
1278
|
+
webSearchCallItem,
|
|
1279
|
+
fileSearchCallItem,
|
|
1280
|
+
localShellCallItem,
|
|
1281
|
+
z.object({
|
|
1282
|
+
type: z.literal("computer_call"),
|
|
1283
|
+
id: z.string(),
|
|
1284
|
+
status: z.literal("completed"),
|
|
1285
|
+
}),
|
|
1286
|
+
]),
|
|
1287
|
+
});
|
|
1288
|
+
const responseFunctionCallArgumentsDeltaSchema = z.object({
|
|
1289
|
+
type: z.literal("response.function_call_arguments.delta"),
|
|
1290
|
+
item_id: z.string(),
|
|
1291
|
+
output_index: z.number(),
|
|
1292
|
+
delta: z.string(),
|
|
1293
|
+
});
|
|
1294
|
+
const responseImageGenerationCallPartialImageSchema = z.object({
|
|
1295
|
+
type: z.literal("response.image_generation_call.partial_image"),
|
|
1296
|
+
item_id: z.string(),
|
|
1297
|
+
output_index: z.number(),
|
|
1298
|
+
partial_image_b64: z.string(),
|
|
1299
|
+
});
|
|
1300
|
+
const responseCodeInterpreterCallCodeDeltaSchema = z.object({
|
|
1301
|
+
type: z.literal("response.code_interpreter_call_code.delta"),
|
|
1302
|
+
item_id: z.string(),
|
|
1303
|
+
output_index: z.number(),
|
|
1304
|
+
delta: z.string(),
|
|
1305
|
+
});
|
|
1306
|
+
const responseCodeInterpreterCallCodeDoneSchema = z.object({
|
|
1307
|
+
type: z.literal("response.code_interpreter_call_code.done"),
|
|
1308
|
+
item_id: z.string(),
|
|
1309
|
+
output_index: z.number(),
|
|
1310
|
+
code: z.string(),
|
|
1311
|
+
});
|
|
1312
|
+
const responseAnnotationAddedSchema = z.object({
|
|
1313
|
+
type: z.literal("response.output_text.annotation.added"),
|
|
1314
|
+
annotation: z.discriminatedUnion("type", [
|
|
1315
|
+
z.object({
|
|
1316
|
+
type: z.literal("url_citation"),
|
|
1317
|
+
url: z.string(),
|
|
1318
|
+
title: z.string(),
|
|
1319
|
+
}),
|
|
1320
|
+
z.object({
|
|
1321
|
+
type: z.literal("file_citation"),
|
|
1322
|
+
file_id: z.string(),
|
|
1323
|
+
filename: z.string().nullish(),
|
|
1324
|
+
index: z.number().nullish(),
|
|
1325
|
+
start_index: z.number().nullish(),
|
|
1326
|
+
end_index: z.number().nullish(),
|
|
1327
|
+
quote: z.string().nullish(),
|
|
1328
|
+
}),
|
|
1329
|
+
]),
|
|
1330
|
+
});
|
|
1331
|
+
const responseReasoningSummaryPartAddedSchema = z.object({
|
|
1332
|
+
type: z.literal("response.reasoning_summary_part.added"),
|
|
1333
|
+
item_id: z.string(),
|
|
1334
|
+
summary_index: z.number(),
|
|
1335
|
+
});
|
|
1336
|
+
const responseReasoningSummaryTextDeltaSchema = z.object({
|
|
1337
|
+
type: z.literal("response.reasoning_summary_text.delta"),
|
|
1338
|
+
item_id: z.string(),
|
|
1339
|
+
summary_index: z.number(),
|
|
1340
|
+
delta: z.string(),
|
|
1341
|
+
});
|
|
1342
|
+
const openaiResponsesChunkSchema = z.union([
|
|
1343
|
+
textDeltaChunkSchema,
|
|
1344
|
+
responseFinishedChunkSchema,
|
|
1345
|
+
responseCreatedChunkSchema,
|
|
1346
|
+
responseOutputItemAddedSchema,
|
|
1347
|
+
responseOutputItemDoneSchema,
|
|
1348
|
+
responseFunctionCallArgumentsDeltaSchema,
|
|
1349
|
+
responseImageGenerationCallPartialImageSchema,
|
|
1350
|
+
responseCodeInterpreterCallCodeDeltaSchema,
|
|
1351
|
+
responseCodeInterpreterCallCodeDoneSchema,
|
|
1352
|
+
responseAnnotationAddedSchema,
|
|
1353
|
+
responseReasoningSummaryPartAddedSchema,
|
|
1354
|
+
responseReasoningSummaryTextDeltaSchema,
|
|
1355
|
+
errorChunkSchema,
|
|
1356
|
+
z.object({ type: z.string() }).loose(), // fallback for unknown chunks
|
|
1357
|
+
]);
|
|
1358
|
+
function isTextDeltaChunk(chunk) {
|
|
1359
|
+
return chunk.type === "response.output_text.delta";
|
|
1360
|
+
}
|
|
1361
|
+
function isResponseOutputItemDoneChunk(chunk) {
|
|
1362
|
+
return chunk.type === "response.output_item.done";
|
|
1363
|
+
}
|
|
1364
|
+
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
1365
|
+
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
1366
|
+
}
|
|
1367
|
+
function isResponseFinishedChunk(chunk) {
|
|
1368
|
+
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
1369
|
+
}
|
|
1370
|
+
function isResponseCreatedChunk(chunk) {
|
|
1371
|
+
return chunk.type === "response.created";
|
|
1372
|
+
}
|
|
1373
|
+
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
1374
|
+
return chunk.type === "response.function_call_arguments.delta";
|
|
1375
|
+
}
|
|
1376
|
+
function isResponseImageGenerationCallPartialImageChunk(chunk) {
|
|
1377
|
+
return chunk.type === "response.image_generation_call.partial_image";
|
|
1378
|
+
}
|
|
1379
|
+
function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
1380
|
+
return chunk.type === "response.code_interpreter_call_code.delta";
|
|
1381
|
+
}
|
|
1382
|
+
function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
1383
|
+
return chunk.type === "response.code_interpreter_call_code.done";
|
|
1384
|
+
}
|
|
1385
|
+
function isResponseOutputItemAddedChunk(chunk) {
|
|
1386
|
+
return chunk.type === "response.output_item.added";
|
|
1387
|
+
}
|
|
1388
|
+
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
1389
|
+
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
1390
|
+
}
|
|
1391
|
+
function isResponseAnnotationAddedChunk(chunk) {
|
|
1392
|
+
return chunk.type === "response.output_text.annotation.added";
|
|
1393
|
+
}
|
|
1394
|
+
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
1395
|
+
return chunk.type === "response.reasoning_summary_part.added";
|
|
1396
|
+
}
|
|
1397
|
+
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
1398
|
+
return chunk.type === "response.reasoning_summary_text.delta";
|
|
1399
|
+
}
|
|
1400
|
+
function isErrorChunk(chunk) {
|
|
1401
|
+
return chunk.type === "error";
|
|
1402
|
+
}
|
|
1403
|
+
function getResponsesModelConfig(modelId) {
|
|
1404
|
+
const supportsFlexProcessing = modelId.startsWith("o3") ||
|
|
1405
|
+
modelId.startsWith("o4-mini") ||
|
|
1406
|
+
(modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat"));
|
|
1407
|
+
const supportsPriorityProcessing = modelId.startsWith("gpt-4") ||
|
|
1408
|
+
modelId.startsWith("gpt-5-mini") ||
|
|
1409
|
+
(modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat")) ||
|
|
1410
|
+
modelId.startsWith("o3") ||
|
|
1411
|
+
modelId.startsWith("o4-mini");
|
|
1412
|
+
const defaults = {
|
|
1413
|
+
requiredAutoTruncation: false,
|
|
1414
|
+
systemMessageMode: "system",
|
|
1415
|
+
supportsFlexProcessing,
|
|
1416
|
+
supportsPriorityProcessing,
|
|
1417
|
+
};
|
|
1418
|
+
// gpt-5-chat models are non-reasoning
|
|
1419
|
+
if (modelId.startsWith("gpt-5-chat")) {
|
|
1420
|
+
return {
|
|
1421
|
+
...defaults,
|
|
1422
|
+
isReasoningModel: false,
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
// o series reasoning models:
|
|
1426
|
+
if (modelId.startsWith("o") ||
|
|
1427
|
+
modelId.startsWith("gpt-5") ||
|
|
1428
|
+
modelId.startsWith("codex-") ||
|
|
1429
|
+
modelId.startsWith("computer-use")) {
|
|
1430
|
+
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
1431
|
+
return {
|
|
1432
|
+
...defaults,
|
|
1433
|
+
isReasoningModel: true,
|
|
1434
|
+
systemMessageMode: "remove",
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
return {
|
|
1438
|
+
...defaults,
|
|
1439
|
+
isReasoningModel: true,
|
|
1440
|
+
systemMessageMode: "developer",
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
// gpt models:
|
|
1444
|
+
return {
|
|
1445
|
+
...defaults,
|
|
1446
|
+
isReasoningModel: false,
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
// TODO AI SDK 6: use optional here instead of nullish
|
|
1450
|
+
const openaiResponsesProviderOptionsSchema = z.object({
|
|
1451
|
+
include: z
|
|
1452
|
+
.array(z.enum(["reasoning.encrypted_content", "file_search_call.results", "message.output_text.logprobs"]))
|
|
1453
|
+
.nullish(),
|
|
1454
|
+
instructions: z.string().nullish(),
|
|
1455
|
+
/**
|
|
1456
|
+
* Return the log probabilities of the tokens.
|
|
1457
|
+
*
|
|
1458
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
1459
|
+
* were generated.
|
|
1460
|
+
*
|
|
1461
|
+
* Setting to a number will return the log probabilities of the top n
|
|
1462
|
+
* tokens that were generated.
|
|
1463
|
+
*
|
|
1464
|
+
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
1465
|
+
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
1466
|
+
*/
|
|
1467
|
+
logprobs: z.union([z.boolean(), z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
1468
|
+
/**
|
|
1469
|
+
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
1470
|
+
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
1471
|
+
* Any further attempts to call a tool by the model will be ignored.
|
|
1472
|
+
*/
|
|
1473
|
+
maxToolCalls: z.number().nullish(),
|
|
1474
|
+
metadata: z.any().nullish(),
|
|
1475
|
+
parallelToolCalls: z.boolean().nullish(),
|
|
1476
|
+
previousResponseId: z.string().nullish(),
|
|
1477
|
+
promptCacheKey: z.string().nullish(),
|
|
1478
|
+
reasoningEffort: z.string().nullish(),
|
|
1479
|
+
reasoningSummary: z.string().nullish(),
|
|
1480
|
+
safetyIdentifier: z.string().nullish(),
|
|
1481
|
+
serviceTier: z.enum(["auto", "flex", "priority"]).nullish(),
|
|
1482
|
+
store: z.boolean().nullish(),
|
|
1483
|
+
strictJsonSchema: z.boolean().nullish(),
|
|
1484
|
+
textVerbosity: z.enum(["low", "medium", "high"]).nullish(),
|
|
1485
|
+
user: z.string().nullish(),
|
|
1486
|
+
});
|
|
1487
|
+
//# sourceMappingURL=openai-responses-language-model.js.map
|