@dexto/core 1.5.7 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -8
- package/dist/agent/DextoAgent.cjs +383 -153
- package/dist/agent/DextoAgent.d.ts +112 -60
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +380 -150
- package/dist/{context/compaction/provider.cjs → agent/agent-options.cjs} +2 -2
- package/dist/agent/agent-options.d.ts +53 -0
- package/dist/agent/agent-options.d.ts.map +1 -0
- package/dist/agent/agentCard.cjs +1 -1
- package/dist/agent/errors.cjs +2 -2
- package/dist/agent/errors.d.ts.map +1 -1
- package/dist/agent/index.cjs +1 -6
- package/dist/agent/index.d.ts +3 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +1 -7
- package/dist/{storage/blob/provider.cjs → agent/runtime-config.cjs} +2 -2
- package/dist/agent/runtime-config.d.ts +53 -0
- package/dist/agent/runtime-config.d.ts.map +1 -0
- package/dist/agent/schemas.cjs +2 -99
- package/dist/agent/schemas.d.ts +10 -9160
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/agent/schemas.js +1 -104
- package/dist/agent/state-manager.d.ts +5 -5
- package/dist/agent/state-manager.d.ts.map +1 -1
- package/dist/approval/error-codes.cjs +1 -1
- package/dist/approval/error-codes.d.ts +1 -1
- package/dist/approval/error-codes.d.ts.map +1 -1
- package/dist/approval/error-codes.js +1 -1
- package/dist/approval/errors.cjs +5 -5
- package/dist/approval/errors.d.ts +2 -2
- package/dist/approval/errors.d.ts.map +1 -1
- package/dist/approval/errors.js +5 -5
- package/dist/approval/index.cjs +8 -8
- package/dist/approval/index.d.ts +2 -2
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +8 -8
- package/dist/approval/manager.cjs +77 -57
- package/dist/approval/manager.d.ts +41 -43
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +75 -55
- package/dist/approval/schemas.cjs +26 -25
- package/dist/approval/schemas.d.ts +35 -15
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +22 -21
- package/dist/approval/types.cjs +1 -1
- package/dist/approval/types.d.ts +14 -14
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +1 -1
- package/dist/context/compaction/index.cjs +2 -23
- package/dist/context/compaction/index.d.ts +1 -7
- package/dist/context/compaction/index.d.ts.map +1 -1
- package/dist/context/compaction/index.js +1 -16
- package/dist/context/compaction/strategies/noop.cjs +19 -1
- package/dist/context/compaction/strategies/noop.d.ts +13 -3
- package/dist/context/compaction/strategies/noop.d.ts.map +1 -1
- package/dist/context/compaction/strategies/noop.js +19 -1
- package/dist/context/compaction/strategies/{reactive-overflow.cjs → reactive-overflow-compaction.cjs} +67 -64
- package/dist/context/compaction/strategies/{reactive-overflow.d.ts → reactive-overflow-compaction.d.ts} +19 -36
- package/dist/context/compaction/strategies/reactive-overflow-compaction.d.ts.map +1 -0
- package/dist/context/compaction/strategies/{reactive-overflow.js → reactive-overflow-compaction.js} +63 -60
- package/dist/context/compaction/types.d.ts +40 -8
- package/dist/context/compaction/types.d.ts.map +1 -1
- package/dist/context/manager.cjs +5 -3
- package/dist/context/manager.d.ts +4 -3
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +5 -3
- package/dist/context/types.d.ts +2 -0
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/utils.cjs +70 -43
- package/dist/context/utils.d.ts +14 -14
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +69 -42
- package/dist/errors/result-bridge.d.ts +2 -2
- package/dist/errors/result-bridge.d.ts.map +1 -1
- package/dist/errors/types.cjs +1 -1
- package/dist/errors/types.d.ts +3 -3
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/errors/types.js +1 -1
- package/dist/events/index.cjs +15 -2
- package/dist/events/index.d.ts +78 -7
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +15 -2
- package/dist/{plugins → hooks}/builtins/content-policy.cjs +7 -6
- package/dist/hooks/builtins/content-policy.d.ts +24 -0
- package/dist/hooks/builtins/content-policy.d.ts.map +1 -0
- package/dist/{plugins → hooks}/builtins/content-policy.js +6 -5
- package/dist/{plugins → hooks}/builtins/response-sanitizer.cjs +3 -3
- package/dist/hooks/builtins/response-sanitizer.d.ts +22 -0
- package/dist/hooks/builtins/response-sanitizer.d.ts.map +1 -0
- package/dist/{plugins → hooks}/builtins/response-sanitizer.js +2 -2
- package/dist/hooks/error-codes.cjs +43 -0
- package/dist/hooks/error-codes.d.ts +34 -0
- package/dist/hooks/error-codes.d.ts.map +1 -0
- package/dist/hooks/error-codes.js +20 -0
- package/dist/{storage/cache/providers/memory.cjs → hooks/index.cjs} +15 -18
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/manager.cjs +354 -0
- package/dist/hooks/manager.d.ts +103 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +331 -0
- package/dist/{plugins → hooks}/types.d.ts +36 -34
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/index.browser.cjs +13 -12
- package/dist/index.browser.d.ts +6 -6
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +8 -7
- package/dist/index.cjs +5 -7
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/llm/curation-config.cjs +82 -0
- package/dist/llm/curation-config.d.ts +13 -0
- package/dist/llm/curation-config.d.ts.map +1 -0
- package/dist/llm/curation-config.js +59 -0
- package/dist/llm/curation.cjs +57 -0
- package/dist/llm/curation.d.ts +16 -0
- package/dist/llm/curation.d.ts.map +1 -0
- package/dist/llm/curation.js +34 -0
- package/dist/llm/errors.cjs +2 -2
- package/dist/llm/errors.d.ts +8 -8
- package/dist/llm/errors.js +1 -1
- package/dist/llm/executor/provider-options.cjs +1 -1
- package/dist/llm/executor/provider-options.js +1 -1
- package/dist/llm/executor/stream-processor.cjs +131 -11
- package/dist/llm/executor/stream-processor.d.ts +7 -5
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +131 -11
- package/dist/llm/executor/turn-executor.cjs +57 -56
- package/dist/llm/executor/turn-executor.d.ts +7 -8
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +57 -56
- package/dist/llm/formatters/vercel.cjs +2 -2
- package/dist/llm/formatters/vercel.d.ts +2 -2
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/index.cjs +14 -3
- package/dist/llm/index.d.ts +3 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +13 -2
- package/dist/llm/providers/local/schemas.d.ts +10 -10
- package/dist/llm/registry/auto-update.cjs +263 -0
- package/dist/llm/registry/auto-update.d.ts +27 -0
- package/dist/llm/registry/auto-update.d.ts.map +1 -0
- package/dist/llm/registry/auto-update.js +227 -0
- package/dist/llm/registry/index.cjs +806 -0
- package/dist/llm/{registry.d.ts → registry/index.d.ts} +21 -43
- package/dist/llm/registry/index.d.ts.map +1 -0
- package/dist/llm/registry/index.js +756 -0
- package/dist/llm/registry/models.generated.cjs +4861 -0
- package/dist/llm/registry/models.generated.d.ts +431 -0
- package/dist/llm/registry/models.generated.d.ts.map +1 -0
- package/dist/llm/registry/models.generated.js +4838 -0
- package/dist/{storage/database/providers/index.cjs → llm/registry/models.manual.cjs} +22 -12
- package/dist/llm/registry/models.manual.d.ts +22 -0
- package/dist/llm/registry/models.manual.d.ts.map +1 -0
- package/dist/llm/registry/models.manual.js +21 -0
- package/dist/llm/registry/sync.cjs +354 -0
- package/dist/llm/registry/sync.d.ts +41 -0
- package/dist/llm/registry/sync.d.ts.map +1 -0
- package/dist/llm/registry/sync.js +328 -0
- package/dist/llm/resolver.cjs +29 -20
- package/dist/llm/resolver.d.ts +4 -4
- package/dist/llm/resolver.d.ts.map +1 -1
- package/dist/llm/resolver.js +28 -20
- package/dist/llm/schemas.cjs +69 -94
- package/dist/llm/schemas.d.ts +19 -158
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +67 -91
- package/dist/llm/services/factory.cjs +6 -7
- package/dist/llm/services/factory.d.ts +3 -4
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +6 -7
- package/dist/llm/services/vercel.cjs +11 -15
- package/dist/llm/services/vercel.d.ts +7 -7
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +11 -15
- package/dist/llm/types.cjs +1 -1
- package/dist/llm/types.d.ts +1 -1
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js +1 -1
- package/dist/llm/validation.cjs +2 -2
- package/dist/llm/validation.d.ts +2 -2
- package/dist/llm/validation.d.ts.map +1 -1
- package/dist/llm/validation.js +1 -1
- package/dist/logger/browser.cjs +4 -4
- package/dist/logger/browser.d.ts +4 -4
- package/dist/logger/browser.d.ts.map +1 -1
- package/dist/logger/browser.js +3 -3
- package/dist/{context/compaction/providers/noop-provider.cjs → logger/default-logger-factory.cjs} +16 -22
- package/dist/logger/default-logger-factory.d.ts +301 -0
- package/dist/logger/default-logger-factory.d.ts.map +1 -0
- package/dist/logger/default-logger-factory.js +18 -0
- package/dist/logger/factory.d.ts +2 -2
- package/dist/logger/factory.d.ts.map +1 -1
- package/dist/logger/index.cjs +7 -2
- package/dist/logger/index.d.ts +5 -3
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +8 -2
- package/dist/logger/logger.cjs +4 -4
- package/dist/logger/logger.d.ts +4 -4
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +3 -3
- package/dist/logger/v2/dexto-logger.d.ts +3 -3
- package/dist/logger/v2/dexto-logger.d.ts.map +1 -1
- package/dist/logger/v2/schemas.d.ts +12 -12
- package/dist/logger/v2/test-utils.d.ts +5 -5
- package/dist/logger/v2/test-utils.d.ts.map +1 -1
- package/dist/logger/v2/transport-factory.d.ts +3 -3
- package/dist/logger/v2/transport-factory.d.ts.map +1 -1
- package/dist/logger/v2/transports/console-transport.d.ts +2 -2
- package/dist/logger/v2/transports/console-transport.d.ts.map +1 -1
- package/dist/logger/v2/transports/file-transport.d.ts +2 -2
- package/dist/logger/v2/transports/file-transport.d.ts.map +1 -1
- package/dist/logger/v2/transports/silent-transport.d.ts +2 -2
- package/dist/logger/v2/transports/silent-transport.d.ts.map +1 -1
- package/dist/logger/v2/types.cjs +1 -1
- package/dist/logger/v2/types.d.ts +8 -8
- package/dist/logger/v2/types.d.ts.map +1 -1
- package/dist/logger/v2/types.js +1 -1
- package/dist/mcp/errors.cjs +2 -2
- package/dist/mcp/errors.d.ts.map +1 -1
- package/dist/mcp/manager.cjs +16 -11
- package/dist/mcp/manager.d.ts +16 -13
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +17 -12
- package/dist/mcp/mcp-client.cjs +25 -20
- package/dist/mcp/mcp-client.d.ts +5 -5
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +20 -15
- package/dist/mcp/resolver.cjs +1 -1
- package/dist/mcp/schemas.cjs +5 -5
- package/dist/mcp/schemas.d.ts +4 -4
- package/dist/mcp/schemas.js +2 -2
- package/dist/mcp/types.d.ts +7 -7
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/memory/manager.d.ts +2 -2
- package/dist/memory/manager.d.ts.map +1 -1
- package/dist/memory/schemas.d.ts +2 -2
- package/dist/prompts/errors.cjs +3 -3
- package/dist/prompts/errors.d.ts.map +1 -1
- package/dist/prompts/prompt-manager.d.ts +3 -3
- package/dist/prompts/prompt-manager.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.cjs +15 -29
- package/dist/prompts/providers/config-prompt-provider.d.ts +3 -3
- package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.js +15 -29
- package/dist/prompts/providers/custom-prompt-provider.d.ts +2 -2
- package/dist/prompts/providers/custom-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/mcp-prompt-provider.d.ts +2 -2
- package/dist/prompts/providers/mcp-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/schemas.d.ts +4 -4
- package/dist/resources/{internal-provider.cjs → agent-resources-provider.cjs} +16 -16
- package/dist/resources/{internal-provider.d.ts → agent-resources-provider.d.ts} +6 -6
- package/dist/resources/agent-resources-provider.d.ts.map +1 -0
- package/dist/resources/{internal-provider.js → agent-resources-provider.js} +13 -13
- package/dist/resources/errors.cjs +2 -2
- package/dist/resources/errors.d.ts.map +1 -1
- package/dist/resources/handlers/blob-handler.d.ts +2 -2
- package/dist/resources/handlers/blob-handler.d.ts.map +1 -1
- package/dist/resources/handlers/factory.d.ts +3 -3
- package/dist/resources/handlers/factory.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.cjs +25 -0
- package/dist/resources/handlers/filesystem-handler.d.ts +3 -2
- package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.js +25 -0
- package/dist/resources/index.cjs +7 -9
- package/dist/resources/index.d.ts +3 -3
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +5 -10
- package/dist/resources/manager.cjs +77 -74
- package/dist/resources/manager.d.ts +16 -7
- package/dist/resources/manager.d.ts.map +1 -1
- package/dist/resources/manager.js +77 -74
- package/dist/resources/schemas.cjs +6 -26
- package/dist/resources/schemas.d.ts +8 -100
- package/dist/resources/schemas.d.ts.map +1 -1
- package/dist/resources/schemas.js +4 -23
- package/dist/search/search-service.d.ts +2 -2
- package/dist/search/search-service.d.ts.map +1 -1
- package/dist/session/chat-session.cjs +16 -26
- package/dist/session/chat-session.d.ts +7 -5
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +17 -27
- package/dist/session/errors.cjs +2 -2
- package/dist/session/errors.d.ts.map +1 -1
- package/dist/session/history/database.cjs +1 -1
- package/dist/session/history/database.d.ts +4 -4
- package/dist/session/history/database.d.ts.map +1 -1
- package/dist/session/history/factory.d.ts +3 -3
- package/dist/session/history/factory.d.ts.map +1 -1
- package/dist/session/history/memory.d.ts +4 -4
- package/dist/session/history/memory.d.ts.map +1 -1
- package/dist/session/history/types.d.ts +2 -2
- package/dist/session/history/types.d.ts.map +1 -1
- package/dist/session/index.cjs +3 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +2 -0
- package/dist/session/message-queue.cjs +29 -5
- package/dist/session/message-queue.d.ts +5 -3
- package/dist/session/message-queue.d.ts.map +1 -1
- package/dist/session/message-queue.js +29 -5
- package/dist/session/session-manager.cjs +107 -12
- package/dist/session/session-manager.d.ts +49 -8
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +97 -12
- package/dist/session/title-generator.cjs +2 -2
- package/dist/session/title-generator.d.ts +2 -2
- package/dist/session/title-generator.d.ts.map +1 -1
- package/dist/session/types.d.ts +1 -0
- package/dist/session/types.d.ts.map +1 -1
- package/dist/storage/blob/index.cjs +0 -40
- package/dist/storage/blob/index.d.ts +2 -44
- package/dist/storage/blob/index.d.ts.map +1 -1
- package/dist/storage/blob/index.js +0 -30
- package/dist/storage/cache/index.cjs +0 -37
- package/dist/storage/cache/index.d.ts +0 -42
- package/dist/storage/cache/index.d.ts.map +1 -1
- package/dist/storage/cache/index.js +0 -28
- package/dist/storage/database/index.cjs +0 -42
- package/dist/storage/database/index.d.ts +0 -43
- package/dist/storage/database/index.d.ts.map +1 -1
- package/dist/storage/database/index.js +0 -37
- package/dist/storage/error-codes.cjs +1 -6
- package/dist/storage/error-codes.d.ts +2 -7
- package/dist/storage/error-codes.d.ts.map +1 -1
- package/dist/storage/error-codes.js +1 -6
- package/dist/storage/errors.cjs +18 -82
- package/dist/storage/errors.d.ts +4 -24
- package/dist/storage/errors.d.ts.map +1 -1
- package/dist/storage/errors.js +16 -80
- package/dist/storage/index.cjs +8 -69
- package/dist/storage/index.d.ts +11 -66
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +6 -50
- package/dist/storage/storage-manager.cjs +9 -25
- package/dist/storage/storage-manager.d.ts +11 -15
- package/dist/storage/storage-manager.d.ts.map +1 -1
- package/dist/storage/storage-manager.js +8 -23
- package/dist/storage/types.d.ts +0 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/systemPrompt/contributors.d.ts +4 -4
- package/dist/systemPrompt/contributors.d.ts.map +1 -1
- package/dist/systemPrompt/errors.cjs +2 -2
- package/dist/systemPrompt/errors.d.ts.map +1 -1
- package/dist/systemPrompt/manager.cjs +1 -5
- package/dist/systemPrompt/manager.d.ts +2 -3
- package/dist/systemPrompt/manager.d.ts.map +1 -1
- package/dist/systemPrompt/manager.js +1 -5
- package/dist/telemetry/index.cjs +3 -0
- package/dist/telemetry/index.d.ts +2 -0
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/utils.d.ts +4 -4
- package/dist/telemetry/utils.d.ts.map +1 -1
- package/dist/test-utils/in-memory-storage.cjs +288 -0
- package/dist/test-utils/in-memory-storage.js +252 -0
- package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts +3 -3
- package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/in-memory.d.ts +2 -2
- package/dist/tools/confirmation/allowed-tools-provider/in-memory.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts +4 -4
- package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/types.d.ts +2 -2
- package/dist/tools/confirmation/allowed-tools-provider/types.d.ts.map +1 -1
- package/dist/tools/{internal-tools/constants.cjs → define-tool.cjs} +8 -13
- package/dist/tools/define-tool.d.ts +11 -0
- package/dist/tools/define-tool.d.ts.map +1 -0
- package/dist/tools/define-tool.js +7 -0
- package/dist/tools/error-codes.cjs +2 -2
- package/dist/tools/error-codes.d.ts +2 -2
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +2 -2
- package/dist/tools/errors.cjs +11 -23
- package/dist/tools/errors.d.ts +4 -10
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +9 -21
- package/dist/tools/index.cjs +3 -8
- package/dist/tools/index.d.ts +2 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -7
- package/dist/{storage/blob/providers/index.cjs → tools/pattern-utils.cjs} +11 -9
- package/dist/tools/pattern-utils.d.ts +20 -0
- package/dist/tools/pattern-utils.d.ts.map +1 -0
- package/dist/tools/pattern-utils.js +10 -0
- package/dist/tools/schemas.cjs +14 -40
- package/dist/tools/schemas.d.ts +6 -50
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +11 -32
- package/dist/tools/tool-call-metadata.cjs +75 -0
- package/dist/tools/tool-call-metadata.d.ts +16 -0
- package/dist/tools/tool-call-metadata.d.ts.map +1 -0
- package/dist/tools/tool-call-metadata.js +51 -0
- package/dist/tools/tool-manager.cjs +578 -302
- package/dist/tools/tool-manager.d.ts +105 -81
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +578 -306
- package/dist/tools/types.d.ts +112 -13
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/api-key-resolver.cjs +1 -1
- package/dist/utils/api-key-resolver.js +1 -1
- package/dist/utils/env.cjs +49 -0
- package/dist/utils/env.d.ts +4 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +24 -0
- package/dist/utils/error-conversion.d.ts +2 -2
- package/dist/utils/error-conversion.d.ts.map +1 -1
- package/dist/utils/index.cjs +3 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/path.d.ts +2 -2
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/result.cjs +1 -1
- package/dist/utils/result.d.ts.map +1 -1
- package/dist/utils/schema.cjs +9 -5
- package/dist/utils/schema.d.ts +4 -2
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +9 -5
- package/dist/utils/service-initializer.cjs +58 -51
- package/dist/utils/service-initializer.d.ts +31 -9
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +58 -51
- package/dist/{storage/cache/providers/index.cjs → workspace/error-codes.cjs} +8 -9
- package/dist/workspace/error-codes.d.ts +5 -0
- package/dist/workspace/error-codes.d.ts.map +1 -0
- package/dist/workspace/error-codes.js +7 -0
- package/dist/{storage/blob/factory.cjs → workspace/errors.cjs} +20 -14
- package/dist/workspace/errors.d.ts +5 -0
- package/dist/workspace/errors.d.ts.map +1 -0
- package/dist/workspace/errors.js +21 -0
- package/dist/{image → workspace}/index.cjs +12 -10
- package/dist/workspace/index.d.ts +5 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +9 -0
- package/dist/workspace/manager.cjs +113 -0
- package/dist/workspace/manager.d.ts +18 -0
- package/dist/workspace/manager.d.ts.map +1 -0
- package/dist/workspace/manager.js +90 -0
- package/dist/workspace/types.d.ts +14 -0
- package/dist/workspace/types.d.ts.map +1 -0
- package/package.json +7 -3
- package/dist/context/compaction/factory.cjs +0 -57
- package/dist/context/compaction/factory.d.ts +0 -17
- package/dist/context/compaction/factory.d.ts.map +0 -1
- package/dist/context/compaction/factory.js +0 -34
- package/dist/context/compaction/provider.d.ts +0 -48
- package/dist/context/compaction/provider.d.ts.map +0 -1
- package/dist/context/compaction/providers/noop-provider.d.ts +0 -24
- package/dist/context/compaction/providers/noop-provider.d.ts.map +0 -1
- package/dist/context/compaction/providers/noop-provider.js +0 -24
- package/dist/context/compaction/providers/reactive-overflow-provider.cjs +0 -76
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts +0 -51
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts.map +0 -1
- package/dist/context/compaction/providers/reactive-overflow-provider.js +0 -52
- package/dist/context/compaction/registry.cjs +0 -39
- package/dist/context/compaction/registry.d.ts +0 -19
- package/dist/context/compaction/registry.d.ts.map +0 -1
- package/dist/context/compaction/registry.js +0 -16
- package/dist/context/compaction/schemas.cjs +0 -58
- package/dist/context/compaction/schemas.d.ts +0 -69
- package/dist/context/compaction/schemas.d.ts.map +0 -1
- package/dist/context/compaction/schemas.js +0 -34
- package/dist/context/compaction/strategies/reactive-overflow.d.ts.map +0 -1
- package/dist/image/define-image.cjs +0 -146
- package/dist/image/define-image.d.ts +0 -71
- package/dist/image/define-image.d.ts.map +0 -1
- package/dist/image/define-image.js +0 -121
- package/dist/image/index.d.ts +0 -53
- package/dist/image/index.d.ts.map +0 -1
- package/dist/image/index.js +0 -7
- package/dist/image/types.d.ts +0 -246
- package/dist/image/types.d.ts.map +0 -1
- package/dist/llm/registry.cjs +0 -2075
- package/dist/llm/registry.d.ts.map +0 -1
- package/dist/llm/registry.js +0 -2025
- package/dist/llm/services/test-utils.integration.cjs +0 -237
- package/dist/llm/services/test-utils.integration.d.ts +0 -48
- package/dist/llm/services/test-utils.integration.d.ts.map +0 -1
- package/dist/llm/services/test-utils.integration.js +0 -214
- package/dist/plugins/builtins/content-policy.d.ts +0 -26
- package/dist/plugins/builtins/content-policy.d.ts.map +0 -1
- package/dist/plugins/builtins/response-sanitizer.d.ts +0 -25
- package/dist/plugins/builtins/response-sanitizer.d.ts.map +0 -1
- package/dist/plugins/error-codes.cjs +0 -43
- package/dist/plugins/error-codes.d.ts +0 -34
- package/dist/plugins/error-codes.d.ts.map +0 -1
- package/dist/plugins/error-codes.js +0 -20
- package/dist/plugins/index.cjs +0 -61
- package/dist/plugins/index.d.ts +0 -21
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -30
- package/dist/plugins/loader.cjs +0 -171
- package/dist/plugins/loader.d.ts +0 -30
- package/dist/plugins/loader.d.ts.map +0 -1
- package/dist/plugins/loader.js +0 -145
- package/dist/plugins/manager.cjs +0 -473
- package/dist/plugins/manager.d.ts +0 -106
- package/dist/plugins/manager.d.ts.map +0 -1
- package/dist/plugins/manager.js +0 -450
- package/dist/plugins/registrations/builtins.cjs +0 -51
- package/dist/plugins/registrations/builtins.d.ts +0 -17
- package/dist/plugins/registrations/builtins.d.ts.map +0 -1
- package/dist/plugins/registrations/builtins.js +0 -28
- package/dist/plugins/registry.cjs +0 -63
- package/dist/plugins/registry.d.ts +0 -101
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js +0 -39
- package/dist/plugins/schemas.cjs +0 -73
- package/dist/plugins/schemas.d.ts +0 -195
- package/dist/plugins/schemas.d.ts.map +0 -1
- package/dist/plugins/schemas.js +0 -47
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/providers/base-registry.cjs +0 -147
- package/dist/providers/base-registry.d.ts +0 -147
- package/dist/providers/base-registry.d.ts.map +0 -1
- package/dist/providers/base-registry.js +0 -123
- package/dist/providers/discovery.cjs +0 -109
- package/dist/providers/discovery.d.ts +0 -96
- package/dist/providers/discovery.d.ts.map +0 -1
- package/dist/providers/discovery.js +0 -84
- package/dist/providers/index.cjs +0 -24
- package/dist/providers/index.d.ts +0 -32
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -2
- package/dist/resources/internal-provider.d.ts.map +0 -1
- package/dist/storage/blob/factory.d.ts +0 -37
- package/dist/storage/blob/factory.d.ts.map +0 -1
- package/dist/storage/blob/factory.js +0 -15
- package/dist/storage/blob/local-blob-store.cjs +0 -496
- package/dist/storage/blob/local-blob-store.d.ts +0 -58
- package/dist/storage/blob/local-blob-store.d.ts.map +0 -1
- package/dist/storage/blob/local-blob-store.js +0 -463
- package/dist/storage/blob/memory-blob-store.cjs +0 -326
- package/dist/storage/blob/memory-blob-store.d.ts +0 -66
- package/dist/storage/blob/memory-blob-store.d.ts.map +0 -1
- package/dist/storage/blob/memory-blob-store.js +0 -303
- package/dist/storage/blob/provider.d.ts +0 -50
- package/dist/storage/blob/provider.d.ts.map +0 -1
- package/dist/storage/blob/providers/index.d.ts +0 -8
- package/dist/storage/blob/providers/index.d.ts.map +0 -1
- package/dist/storage/blob/providers/index.js +0 -7
- package/dist/storage/blob/providers/local.cjs +0 -39
- package/dist/storage/blob/providers/local.d.ts +0 -17
- package/dist/storage/blob/providers/local.d.ts.map +0 -1
- package/dist/storage/blob/providers/local.js +0 -16
- package/dist/storage/blob/providers/memory.cjs +0 -39
- package/dist/storage/blob/providers/memory.d.ts +0 -17
- package/dist/storage/blob/providers/memory.d.ts.map +0 -1
- package/dist/storage/blob/providers/memory.js +0 -16
- package/dist/storage/blob/registry.cjs +0 -50
- package/dist/storage/blob/registry.d.ts +0 -42
- package/dist/storage/blob/registry.d.ts.map +0 -1
- package/dist/storage/blob/registry.js +0 -26
- package/dist/storage/blob/schemas.cjs +0 -52
- package/dist/storage/blob/schemas.d.ts +0 -85
- package/dist/storage/blob/schemas.d.ts.map +0 -1
- package/dist/storage/blob/schemas.js +0 -26
- package/dist/storage/cache/factory.cjs +0 -38
- package/dist/storage/cache/factory.d.ts +0 -37
- package/dist/storage/cache/factory.d.ts.map +0 -1
- package/dist/storage/cache/factory.js +0 -15
- package/dist/storage/cache/memory-cache-store.cjs +0 -107
- package/dist/storage/cache/memory-cache-store.d.ts +0 -26
- package/dist/storage/cache/memory-cache-store.d.ts.map +0 -1
- package/dist/storage/cache/memory-cache-store.js +0 -84
- package/dist/storage/cache/provider.cjs +0 -16
- package/dist/storage/cache/provider.d.ts +0 -56
- package/dist/storage/cache/provider.d.ts.map +0 -1
- package/dist/storage/cache/provider.js +0 -0
- package/dist/storage/cache/providers/index.d.ts +0 -8
- package/dist/storage/cache/providers/index.d.ts.map +0 -1
- package/dist/storage/cache/providers/index.js +0 -7
- package/dist/storage/cache/providers/memory.d.ts +0 -17
- package/dist/storage/cache/providers/memory.d.ts.map +0 -1
- package/dist/storage/cache/providers/memory.js +0 -17
- package/dist/storage/cache/providers/redis.cjs +0 -66
- package/dist/storage/cache/providers/redis.d.ts +0 -20
- package/dist/storage/cache/providers/redis.d.ts.map +0 -1
- package/dist/storage/cache/providers/redis.js +0 -33
- package/dist/storage/cache/redis-store.cjs +0 -173
- package/dist/storage/cache/redis-store.d.ts +0 -32
- package/dist/storage/cache/redis-store.d.ts.map +0 -1
- package/dist/storage/cache/redis-store.js +0 -150
- package/dist/storage/cache/registry.cjs +0 -50
- package/dist/storage/cache/registry.d.ts +0 -42
- package/dist/storage/cache/registry.d.ts.map +0 -1
- package/dist/storage/cache/registry.js +0 -26
- package/dist/storage/cache/schemas.cjs +0 -81
- package/dist/storage/cache/schemas.d.ts +0 -150
- package/dist/storage/cache/schemas.d.ts.map +0 -1
- package/dist/storage/cache/schemas.js +0 -55
- package/dist/storage/database/factory.cjs +0 -38
- package/dist/storage/database/factory.d.ts +0 -39
- package/dist/storage/database/factory.d.ts.map +0 -1
- package/dist/storage/database/factory.js +0 -15
- package/dist/storage/database/memory-database-store.cjs +0 -122
- package/dist/storage/database/memory-database-store.d.ts +0 -29
- package/dist/storage/database/memory-database-store.d.ts.map +0 -1
- package/dist/storage/database/memory-database-store.js +0 -99
- package/dist/storage/database/postgres-store.cjs +0 -342
- package/dist/storage/database/postgres-store.d.ts +0 -55
- package/dist/storage/database/postgres-store.d.ts.map +0 -1
- package/dist/storage/database/postgres-store.js +0 -319
- package/dist/storage/database/provider.cjs +0 -16
- package/dist/storage/database/provider.d.ts +0 -56
- package/dist/storage/database/provider.d.ts.map +0 -1
- package/dist/storage/database/provider.js +0 -0
- package/dist/storage/database/providers/index.d.ts +0 -9
- package/dist/storage/database/providers/index.d.ts.map +0 -1
- package/dist/storage/database/providers/index.js +0 -9
- package/dist/storage/database/providers/memory.cjs +0 -40
- package/dist/storage/database/providers/memory.d.ts +0 -16
- package/dist/storage/database/providers/memory.d.ts.map +0 -1
- package/dist/storage/database/providers/memory.js +0 -17
- package/dist/storage/database/providers/postgres.cjs +0 -62
- package/dist/storage/database/providers/postgres.d.ts +0 -19
- package/dist/storage/database/providers/postgres.d.ts.map +0 -1
- package/dist/storage/database/providers/postgres.js +0 -29
- package/dist/storage/database/providers/sqlite.cjs +0 -66
- package/dist/storage/database/providers/sqlite.d.ts +0 -20
- package/dist/storage/database/providers/sqlite.d.ts.map +0 -1
- package/dist/storage/database/providers/sqlite.js +0 -33
- package/dist/storage/database/registry.cjs +0 -50
- package/dist/storage/database/registry.d.ts +0 -42
- package/dist/storage/database/registry.d.ts.map +0 -1
- package/dist/storage/database/registry.js +0 -26
- package/dist/storage/database/schemas.cjs +0 -97
- package/dist/storage/database/schemas.d.ts +0 -226
- package/dist/storage/database/schemas.d.ts.map +0 -1
- package/dist/storage/database/schemas.js +0 -70
- package/dist/storage/database/sqlite-store.cjs +0 -270
- package/dist/storage/database/sqlite-store.d.ts +0 -33
- package/dist/storage/database/sqlite-store.d.ts.map +0 -1
- package/dist/storage/database/sqlite-store.js +0 -237
- package/dist/storage/schemas.cjs +0 -57
- package/dist/storage/schemas.d.ts +0 -347
- package/dist/storage/schemas.d.ts.map +0 -1
- package/dist/storage/schemas.js +0 -37
- package/dist/tools/bash-pattern-utils.cjs +0 -91
- package/dist/tools/bash-pattern-utils.d.ts +0 -58
- package/dist/tools/bash-pattern-utils.d.ts.map +0 -1
- package/dist/tools/bash-pattern-utils.js +0 -64
- package/dist/tools/custom-tool-registry.cjs +0 -64
- package/dist/tools/custom-tool-registry.d.ts +0 -126
- package/dist/tools/custom-tool-registry.d.ts.map +0 -1
- package/dist/tools/custom-tool-registry.js +0 -40
- package/dist/tools/custom-tool-schema-registry.cjs +0 -164
- package/dist/tools/custom-tool-schema-registry.d.ts +0 -86
- package/dist/tools/custom-tool-schema-registry.d.ts.map +0 -1
- package/dist/tools/custom-tool-schema-registry.js +0 -140
- package/dist/tools/internal-tools/constants.d.ts +0 -12
- package/dist/tools/internal-tools/constants.d.ts.map +0 -1
- package/dist/tools/internal-tools/constants.js +0 -12
- package/dist/tools/internal-tools/implementations/ask-user-tool.cjs +0 -57
- package/dist/tools/internal-tools/implementations/ask-user-tool.d.ts +0 -18
- package/dist/tools/internal-tools/implementations/ask-user-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/ask-user-tool.js +0 -34
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.cjs +0 -192
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.d.ts +0 -33
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.js +0 -169
- package/dist/tools/internal-tools/implementations/get-resource-tool.cjs +0 -113
- package/dist/tools/internal-tools/implementations/get-resource-tool.d.ts +0 -30
- package/dist/tools/internal-tools/implementations/get-resource-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/get-resource-tool.js +0 -90
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.cjs +0 -140
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.d.ts +0 -24
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.js +0 -117
- package/dist/tools/internal-tools/implementations/list-resources-tool.cjs +0 -91
- package/dist/tools/internal-tools/implementations/list-resources-tool.d.ts +0 -24
- package/dist/tools/internal-tools/implementations/list-resources-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/list-resources-tool.js +0 -68
- package/dist/tools/internal-tools/implementations/search-history-tool.cjs +0 -61
- package/dist/tools/internal-tools/implementations/search-history-tool.d.ts +0 -7
- package/dist/tools/internal-tools/implementations/search-history-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/search-history-tool.js +0 -38
- package/dist/tools/internal-tools/index.cjs +0 -26
- package/dist/tools/internal-tools/index.d.ts +0 -4
- package/dist/tools/internal-tools/index.d.ts.map +0 -1
- package/dist/tools/internal-tools/index.js +0 -3
- package/dist/tools/internal-tools/provider.cjs +0 -324
- package/dist/tools/internal-tools/provider.d.ts +0 -114
- package/dist/tools/internal-tools/provider.d.ts.map +0 -1
- package/dist/tools/internal-tools/provider.js +0 -301
- package/dist/tools/internal-tools/registry.cjs +0 -71
- package/dist/tools/internal-tools/registry.d.ts +0 -91
- package/dist/tools/internal-tools/registry.d.ts.map +0 -1
- package/dist/tools/internal-tools/registry.js +0 -47
- /package/dist/{context/compaction/provider.js → agent/agent-options.js} +0 -0
- /package/dist/{image/types.js → agent/runtime-config.js} +0 -0
- /package/dist/{image → hooks}/types.cjs +0 -0
- /package/dist/{plugins → hooks}/types.js +0 -0
- /package/dist/{plugins → workspace}/types.cjs +0 -0
- /package/dist/{storage/blob/provider.js → workspace/types.js} +0 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
import "../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { LLMError } from "../errors.js";
|
|
3
|
+
import { LLMErrorCode } from "../error-codes.js";
|
|
4
|
+
import { DextoRuntimeError } from "../../errors/DextoRuntimeError.js";
|
|
5
|
+
import {
|
|
6
|
+
LLM_PROVIDERS
|
|
7
|
+
} from "../types.js";
|
|
8
|
+
import { getOpenRouterModelContextLength } from "../providers/openrouter-model-registry.js";
|
|
9
|
+
import { MODELS_BY_PROVIDER } from "./models.generated.js";
|
|
10
|
+
import { MANUAL_MODELS_BY_PROVIDER } from "./models.manual.js";
|
|
11
|
+
const LEGACY_MODEL_ID_ALIASES = {
|
|
12
|
+
anthropic: {
|
|
13
|
+
// Older Dexto configs/tests used "claude-4-{tier}-{date}".
|
|
14
|
+
// models.dev (and our generated snapshot) use "claude-{tier}-4-{date}".
|
|
15
|
+
"claude-4-sonnet-20250514": "claude-sonnet-4-20250514",
|
|
16
|
+
"claude-4-opus-20250514": "claude-opus-4-20250514"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function getNormalizedModelIdForLookup(provider, model) {
|
|
20
|
+
const stripped = stripBedrockRegionPrefix(model);
|
|
21
|
+
const lower = stripped.toLowerCase();
|
|
22
|
+
const aliases = LEGACY_MODEL_ID_ALIASES[provider];
|
|
23
|
+
return aliases?.[lower] ?? lower;
|
|
24
|
+
}
|
|
25
|
+
function mergeModels(base, extra) {
|
|
26
|
+
if (!extra || extra.length === 0) return base;
|
|
27
|
+
const merged = [...base];
|
|
28
|
+
const indexByName = /* @__PURE__ */ new Map();
|
|
29
|
+
for (let i = 0; i < merged.length; i++) {
|
|
30
|
+
indexByName.set(merged[i].name.toLowerCase(), i);
|
|
31
|
+
}
|
|
32
|
+
for (const m of extra) {
|
|
33
|
+
const key = m.name.toLowerCase();
|
|
34
|
+
const existingIndex = indexByName.get(key);
|
|
35
|
+
if (existingIndex != null) {
|
|
36
|
+
merged[existingIndex] = m;
|
|
37
|
+
} else {
|
|
38
|
+
indexByName.set(key, merged.length);
|
|
39
|
+
merged.push(m);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return merged;
|
|
43
|
+
}
|
|
44
|
+
const MIME_TYPE_TO_FILE_TYPE = {
|
|
45
|
+
"application/pdf": "pdf",
|
|
46
|
+
"audio/mp3": "audio",
|
|
47
|
+
"audio/mpeg": "audio",
|
|
48
|
+
"audio/wav": "audio",
|
|
49
|
+
"audio/x-wav": "audio",
|
|
50
|
+
"audio/wave": "audio",
|
|
51
|
+
"audio/webm": "audio",
|
|
52
|
+
"audio/ogg": "audio",
|
|
53
|
+
"audio/m4a": "audio",
|
|
54
|
+
"audio/aac": "audio",
|
|
55
|
+
// Common image MIME types
|
|
56
|
+
"image/jpeg": "image",
|
|
57
|
+
"image/jpg": "image",
|
|
58
|
+
"image/png": "image",
|
|
59
|
+
"image/webp": "image",
|
|
60
|
+
"image/gif": "image"
|
|
61
|
+
};
|
|
62
|
+
function getAllowedMimeTypes() {
|
|
63
|
+
return Object.keys(MIME_TYPE_TO_FILE_TYPE);
|
|
64
|
+
}
|
|
65
|
+
const DEFAULT_MAX_INPUT_TOKENS = 128e3;
|
|
66
|
+
const LLM_REGISTRY = {
|
|
67
|
+
openai: {
|
|
68
|
+
models: mergeModels(MODELS_BY_PROVIDER.openai, MANUAL_MODELS_BY_PROVIDER.openai),
|
|
69
|
+
baseURLSupport: "none",
|
|
70
|
+
supportedFileTypes: []
|
|
71
|
+
// No defaults - models must explicitly specify support
|
|
72
|
+
},
|
|
73
|
+
"openai-compatible": {
|
|
74
|
+
models: [],
|
|
75
|
+
// Empty - accepts any model name for custom endpoints
|
|
76
|
+
baseURLSupport: "required",
|
|
77
|
+
supportedFileTypes: ["pdf", "image", "audio"],
|
|
78
|
+
// Allow all types for custom endpoints
|
|
79
|
+
supportsCustomModels: true
|
|
80
|
+
},
|
|
81
|
+
anthropic: {
|
|
82
|
+
models: MODELS_BY_PROVIDER.anthropic,
|
|
83
|
+
baseURLSupport: "none",
|
|
84
|
+
supportedFileTypes: []
|
|
85
|
+
// No defaults - models must explicitly specify support
|
|
86
|
+
},
|
|
87
|
+
google: {
|
|
88
|
+
models: MODELS_BY_PROVIDER.google,
|
|
89
|
+
baseURLSupport: "none",
|
|
90
|
+
supportedFileTypes: []
|
|
91
|
+
// No defaults - models must explicitly specify support
|
|
92
|
+
},
|
|
93
|
+
// https://console.groq.com/docs/models
|
|
94
|
+
groq: {
|
|
95
|
+
models: MODELS_BY_PROVIDER.groq,
|
|
96
|
+
baseURLSupport: "none",
|
|
97
|
+
supportedFileTypes: []
|
|
98
|
+
// Groq currently doesn't support file uploads
|
|
99
|
+
},
|
|
100
|
+
// https://docs.x.ai/docs/models
|
|
101
|
+
// Note: XAI API only supports image uploads (JPG/PNG up to 20MB), not PDFs
|
|
102
|
+
xai: {
|
|
103
|
+
models: MODELS_BY_PROVIDER.xai,
|
|
104
|
+
baseURLSupport: "none",
|
|
105
|
+
supportedFileTypes: []
|
|
106
|
+
// No defaults - models must explicitly specify support
|
|
107
|
+
},
|
|
108
|
+
// https://docs.cohere.com/reference/models
|
|
109
|
+
cohere: {
|
|
110
|
+
models: MODELS_BY_PROVIDER.cohere,
|
|
111
|
+
baseURLSupport: "none",
|
|
112
|
+
supportedFileTypes: []
|
|
113
|
+
// No defaults - models must explicitly specify support
|
|
114
|
+
},
|
|
115
|
+
// https://platform.minimax.io/docs/api-reference/text-openai-api
|
|
116
|
+
// MiniMax provides an OpenAI-compatible endpoint at https://api.minimax.chat/v1
|
|
117
|
+
minimax: {
|
|
118
|
+
models: MODELS_BY_PROVIDER.minimax,
|
|
119
|
+
baseURLSupport: "none",
|
|
120
|
+
supportedFileTypes: []
|
|
121
|
+
// No defaults - models must explicitly specify support
|
|
122
|
+
},
|
|
123
|
+
// https://open.bigmodel.cn/dev/api/normal-model/glm-4
|
|
124
|
+
// GLM (Zhipu AI) provides an OpenAI-compatible endpoint
|
|
125
|
+
glm: {
|
|
126
|
+
models: MODELS_BY_PROVIDER.glm,
|
|
127
|
+
baseURLSupport: "none",
|
|
128
|
+
supportedFileTypes: []
|
|
129
|
+
// No defaults - models must explicitly specify support
|
|
130
|
+
},
|
|
131
|
+
// https://openrouter.ai/docs
|
|
132
|
+
// OpenRouter is a unified API gateway providing access to 100+ models from various providers.
|
|
133
|
+
// Model validation is handled dynamically via openrouter-model-registry.ts
|
|
134
|
+
openrouter: {
|
|
135
|
+
models: MODELS_BY_PROVIDER.openrouter,
|
|
136
|
+
baseURLSupport: "none",
|
|
137
|
+
// Fixed endpoint - baseURL auto-injected in resolver, no user override allowed
|
|
138
|
+
supportedFileTypes: ["pdf", "image", "audio"],
|
|
139
|
+
// Allow all types - user assumes responsibility
|
|
140
|
+
supportsCustomModels: true,
|
|
141
|
+
supportsAllRegistryModels: true
|
|
142
|
+
// Can serve models from all other providers
|
|
143
|
+
},
|
|
144
|
+
// https://docs.litellm.ai/
|
|
145
|
+
// LiteLLM is an OpenAI-compatible proxy that unifies 100+ LLM providers.
|
|
146
|
+
// User must host their own LiteLLM proxy and provide the baseURL.
|
|
147
|
+
litellm: {
|
|
148
|
+
models: [],
|
|
149
|
+
baseURLSupport: "required",
|
|
150
|
+
supportedFileTypes: ["pdf", "image", "audio"],
|
|
151
|
+
supportsCustomModels: true
|
|
152
|
+
},
|
|
153
|
+
// https://glama.ai/
|
|
154
|
+
// Glama is an OpenAI-compatible gateway providing unified access to multiple LLM providers.
|
|
155
|
+
// Fixed endpoint: https://glama.ai/api/gateway/openai/v1
|
|
156
|
+
glama: {
|
|
157
|
+
models: [],
|
|
158
|
+
baseURLSupport: "none",
|
|
159
|
+
supportedFileTypes: ["pdf", "image", "audio"],
|
|
160
|
+
supportsCustomModels: true
|
|
161
|
+
},
|
|
162
|
+
// https://cloud.google.com/vertex-ai
|
|
163
|
+
vertex: {
|
|
164
|
+
models: MODELS_BY_PROVIDER.vertex,
|
|
165
|
+
baseURLSupport: "none",
|
|
166
|
+
supportedFileTypes: []
|
|
167
|
+
// No defaults - models must explicitly specify support
|
|
168
|
+
},
|
|
169
|
+
// https://docs.aws.amazon.com/bedrock/latest/userguide/models.html
|
|
170
|
+
bedrock: {
|
|
171
|
+
models: MODELS_BY_PROVIDER.bedrock,
|
|
172
|
+
baseURLSupport: "none",
|
|
173
|
+
supportedFileTypes: [],
|
|
174
|
+
// No defaults - models must explicitly specify support
|
|
175
|
+
supportsCustomModels: true
|
|
176
|
+
},
|
|
177
|
+
// Native local model execution via node-llama-cpp
|
|
178
|
+
local: {
|
|
179
|
+
models: [],
|
|
180
|
+
// Populated dynamically from local model registry
|
|
181
|
+
baseURLSupport: "none",
|
|
182
|
+
supportedFileTypes: ["image"],
|
|
183
|
+
supportsCustomModels: true
|
|
184
|
+
},
|
|
185
|
+
// Ollama server integration
|
|
186
|
+
ollama: {
|
|
187
|
+
models: [],
|
|
188
|
+
// Populated dynamically from Ollama API
|
|
189
|
+
baseURLSupport: "optional",
|
|
190
|
+
supportedFileTypes: ["image"],
|
|
191
|
+
supportsCustomModels: true
|
|
192
|
+
},
|
|
193
|
+
// Dexto Gateway - OpenAI-compatible proxy through api.dexto.ai
|
|
194
|
+
// Routes to OpenRouter with per-request billing (balance decrement)
|
|
195
|
+
// Requires DEXTO_API_KEY from dexto login
|
|
196
|
+
//
|
|
197
|
+
// Model IDs are in OpenRouter format (e.g., 'anthropic/claude-sonnet-4.5')
|
|
198
|
+
"dexto-nova": {
|
|
199
|
+
models: [
|
|
200
|
+
// Claude models (Anthropic via OpenRouter)
|
|
201
|
+
{
|
|
202
|
+
name: "anthropic/claude-haiku-4.5",
|
|
203
|
+
displayName: "Claude 4.5 Haiku",
|
|
204
|
+
maxInputTokens: 2e5,
|
|
205
|
+
default: true,
|
|
206
|
+
supportedFileTypes: ["pdf", "image"],
|
|
207
|
+
pricing: {
|
|
208
|
+
inputPerM: 1,
|
|
209
|
+
outputPerM: 5,
|
|
210
|
+
cacheWritePerM: 1.25,
|
|
211
|
+
cacheReadPerM: 0.1,
|
|
212
|
+
currency: "USD",
|
|
213
|
+
unit: "per_million_tokens"
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: "anthropic/claude-sonnet-4.5",
|
|
218
|
+
displayName: "Claude 4.5 Sonnet",
|
|
219
|
+
maxInputTokens: 2e5,
|
|
220
|
+
supportedFileTypes: ["pdf", "image"],
|
|
221
|
+
pricing: {
|
|
222
|
+
inputPerM: 3,
|
|
223
|
+
outputPerM: 15,
|
|
224
|
+
cacheWritePerM: 3.75,
|
|
225
|
+
cacheReadPerM: 0.3,
|
|
226
|
+
currency: "USD",
|
|
227
|
+
unit: "per_million_tokens"
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "anthropic/claude-opus-4.5",
|
|
232
|
+
displayName: "Claude 4.5 Opus",
|
|
233
|
+
maxInputTokens: 2e5,
|
|
234
|
+
supportedFileTypes: ["pdf", "image"],
|
|
235
|
+
pricing: {
|
|
236
|
+
inputPerM: 5,
|
|
237
|
+
outputPerM: 25,
|
|
238
|
+
cacheWritePerM: 6.25,
|
|
239
|
+
cacheReadPerM: 0.5,
|
|
240
|
+
currency: "USD",
|
|
241
|
+
unit: "per_million_tokens"
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
// OpenAI models (via OpenRouter)
|
|
245
|
+
{
|
|
246
|
+
name: "openai/gpt-5.2",
|
|
247
|
+
displayName: "GPT-5.2",
|
|
248
|
+
maxInputTokens: 4e5,
|
|
249
|
+
supportedFileTypes: ["pdf", "image"],
|
|
250
|
+
pricing: {
|
|
251
|
+
inputPerM: 1.75,
|
|
252
|
+
outputPerM: 14,
|
|
253
|
+
cacheReadPerM: 0.175,
|
|
254
|
+
currency: "USD",
|
|
255
|
+
unit: "per_million_tokens"
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "openai/gpt-5.2-codex",
|
|
260
|
+
displayName: "GPT-5.2 Codex",
|
|
261
|
+
maxInputTokens: 4e5,
|
|
262
|
+
supportedFileTypes: ["pdf", "image"],
|
|
263
|
+
pricing: {
|
|
264
|
+
inputPerM: 1.75,
|
|
265
|
+
outputPerM: 14,
|
|
266
|
+
cacheReadPerM: 0.175,
|
|
267
|
+
currency: "USD",
|
|
268
|
+
unit: "per_million_tokens"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
// Google models (via OpenRouter)
|
|
272
|
+
{
|
|
273
|
+
name: "google/gemini-3-pro-preview",
|
|
274
|
+
displayName: "Gemini 3 Pro",
|
|
275
|
+
maxInputTokens: 1048576,
|
|
276
|
+
supportedFileTypes: ["pdf", "image", "audio"]
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: "google/gemini-3-flash-preview",
|
|
280
|
+
displayName: "Gemini 3 Flash",
|
|
281
|
+
maxInputTokens: 1048576,
|
|
282
|
+
supportedFileTypes: ["pdf", "image", "audio"]
|
|
283
|
+
},
|
|
284
|
+
// Free models (via OpenRouter)
|
|
285
|
+
{
|
|
286
|
+
name: "qwen/qwen3-coder:free",
|
|
287
|
+
displayName: "Qwen3 Coder (Free)",
|
|
288
|
+
maxInputTokens: 262e3,
|
|
289
|
+
supportedFileTypes: []
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: "deepseek/deepseek-r1-0528:free",
|
|
293
|
+
displayName: "DeepSeek R1 (Free)",
|
|
294
|
+
maxInputTokens: 163840,
|
|
295
|
+
supportedFileTypes: []
|
|
296
|
+
},
|
|
297
|
+
// Other models (via OpenRouter)
|
|
298
|
+
{
|
|
299
|
+
name: "z-ai/glm-4.7",
|
|
300
|
+
displayName: "GLM 4.7",
|
|
301
|
+
maxInputTokens: 202752,
|
|
302
|
+
supportedFileTypes: [],
|
|
303
|
+
pricing: {
|
|
304
|
+
inputPerM: 0.27,
|
|
305
|
+
outputPerM: 1.1,
|
|
306
|
+
currency: "USD",
|
|
307
|
+
unit: "per_million_tokens"
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: "minimax/minimax-m2.1",
|
|
312
|
+
displayName: "Minimax M2.1",
|
|
313
|
+
maxInputTokens: 196608,
|
|
314
|
+
supportedFileTypes: [],
|
|
315
|
+
pricing: {
|
|
316
|
+
inputPerM: 0.2,
|
|
317
|
+
outputPerM: 0.6,
|
|
318
|
+
currency: "USD",
|
|
319
|
+
unit: "per_million_tokens"
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: "moonshotai/kimi-k2.5",
|
|
324
|
+
displayName: "Kimi K2.5",
|
|
325
|
+
maxInputTokens: 262144,
|
|
326
|
+
supportedFileTypes: ["image"],
|
|
327
|
+
pricing: {
|
|
328
|
+
inputPerM: 0.5,
|
|
329
|
+
outputPerM: 2.5,
|
|
330
|
+
currency: "USD",
|
|
331
|
+
unit: "per_million_tokens"
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
],
|
|
335
|
+
baseURLSupport: "none",
|
|
336
|
+
supportedFileTypes: ["pdf", "image", "audio"],
|
|
337
|
+
supportsCustomModels: true,
|
|
338
|
+
supportsAllRegistryModels: true
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
function stripBedrockRegionPrefix(model) {
|
|
342
|
+
if (model.startsWith("eu.") || model.startsWith("us.")) {
|
|
343
|
+
return model.slice(3);
|
|
344
|
+
}
|
|
345
|
+
if (model.startsWith("global.")) {
|
|
346
|
+
return model.slice(7);
|
|
347
|
+
}
|
|
348
|
+
return model;
|
|
349
|
+
}
|
|
350
|
+
function getDefaultModelForProvider(provider) {
|
|
351
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
352
|
+
const explicit = providerInfo.models.find((m) => m.default)?.name;
|
|
353
|
+
if (explicit) return explicit;
|
|
354
|
+
if (providerInfo.models.length === 0) return null;
|
|
355
|
+
const sorted = [...providerInfo.models].sort((a, b) => a.name.localeCompare(b.name));
|
|
356
|
+
return sorted[0]?.name ?? null;
|
|
357
|
+
}
|
|
358
|
+
function getSupportedProviders() {
|
|
359
|
+
return [...LLM_PROVIDERS];
|
|
360
|
+
}
|
|
361
|
+
function getSupportedModels(provider) {
|
|
362
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
363
|
+
return providerInfo.models.map((m) => m.name);
|
|
364
|
+
}
|
|
365
|
+
function getMaxInputTokensForModel(provider, model, logger) {
|
|
366
|
+
const modelInfo = findModelInfo(provider, model);
|
|
367
|
+
if (!modelInfo) {
|
|
368
|
+
if ((provider === "openrouter" || provider === "dexto-nova") && model.includes("/")) {
|
|
369
|
+
const contextLength = getOpenRouterModelContextLength(model);
|
|
370
|
+
if (typeof contextLength === "number") {
|
|
371
|
+
logger?.debug(
|
|
372
|
+
`Using max tokens from OpenRouter cache for ${provider}/${model}: ${contextLength}`
|
|
373
|
+
);
|
|
374
|
+
return contextLength;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
const supportedModels = getSupportedModels(provider).join(", ");
|
|
378
|
+
logger?.error(
|
|
379
|
+
`Model '${model}' not found for provider '${provider}' in LLM registry. Supported models: ${supportedModels}`
|
|
380
|
+
);
|
|
381
|
+
throw LLMError.unknownModel(provider, model);
|
|
382
|
+
}
|
|
383
|
+
logger?.debug(`Found max tokens for ${provider}/${model}: ${modelInfo.maxInputTokens}`);
|
|
384
|
+
return modelInfo.maxInputTokens;
|
|
385
|
+
}
|
|
386
|
+
function isValidProviderModel(provider, model) {
|
|
387
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
388
|
+
const normalizedModel = getNormalizedModelIdForLookup(provider, model);
|
|
389
|
+
return providerInfo.models.some((m) => m.name.toLowerCase() === normalizedModel);
|
|
390
|
+
}
|
|
391
|
+
function getProviderFromModel(model) {
|
|
392
|
+
if (model.includes("/")) {
|
|
393
|
+
throw LLMError.modelProviderUnknown(model);
|
|
394
|
+
}
|
|
395
|
+
for (const provider of LLM_PROVIDERS) {
|
|
396
|
+
const info = LLM_REGISTRY[provider];
|
|
397
|
+
const normalizedModel = getNormalizedModelIdForLookup(provider, model);
|
|
398
|
+
if (info.models.some((m) => m.name.toLowerCase() === normalizedModel)) {
|
|
399
|
+
return provider;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
throw LLMError.modelProviderUnknown(model);
|
|
403
|
+
}
|
|
404
|
+
function getAllSupportedModels() {
|
|
405
|
+
return Object.values(LLM_REGISTRY).flatMap((info) => info.models.map((m) => m.name));
|
|
406
|
+
}
|
|
407
|
+
function supportsBaseURL(provider) {
|
|
408
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
409
|
+
return providerInfo.baseURLSupport !== "none";
|
|
410
|
+
}
|
|
411
|
+
function requiresBaseURL(provider) {
|
|
412
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
413
|
+
return providerInfo.baseURLSupport === "required";
|
|
414
|
+
}
|
|
415
|
+
function acceptsAnyModel(provider) {
|
|
416
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
417
|
+
return providerInfo.models.length === 0;
|
|
418
|
+
}
|
|
419
|
+
function supportsCustomModels(provider) {
|
|
420
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
421
|
+
return providerInfo.supportsCustomModels === true;
|
|
422
|
+
}
|
|
423
|
+
function hasAllRegistryModelsSupport(provider) {
|
|
424
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
425
|
+
return providerInfo.supportsAllRegistryModels === true;
|
|
426
|
+
}
|
|
427
|
+
const OPENROUTER_PREFIX_BY_PROVIDER = {
|
|
428
|
+
openai: "openai",
|
|
429
|
+
anthropic: "anthropic",
|
|
430
|
+
google: "google",
|
|
431
|
+
xai: "x-ai",
|
|
432
|
+
cohere: "cohere",
|
|
433
|
+
minimax: "minimax",
|
|
434
|
+
glm: "z-ai"
|
|
435
|
+
};
|
|
436
|
+
function getOpenRouterModelIdSet() {
|
|
437
|
+
return new Set(LLM_REGISTRY.openrouter.models.map((m) => m.name.toLowerCase()));
|
|
438
|
+
}
|
|
439
|
+
function getOpenRouterCandidateModelIds(model, originalProvider) {
|
|
440
|
+
if (model.includes("/")) return [model];
|
|
441
|
+
const prefix = OPENROUTER_PREFIX_BY_PROVIDER[originalProvider];
|
|
442
|
+
if (!prefix) return [];
|
|
443
|
+
if (originalProvider === "anthropic") {
|
|
444
|
+
const noDate = model.replace(/-\d{8}.*$/i, "");
|
|
445
|
+
const dotted = noDate.replace(/-(\d)-(\d)\b/g, "-$1.$2");
|
|
446
|
+
return [`${prefix}/${dotted}`, `${prefix}/${noDate}`, `${prefix}/${model}`];
|
|
447
|
+
}
|
|
448
|
+
if (originalProvider === "google") {
|
|
449
|
+
if (!/^gemini-/i.test(model)) {
|
|
450
|
+
return [`${prefix}/${model}`];
|
|
451
|
+
}
|
|
452
|
+
return [`${prefix}/${model}`, `${prefix}/${model}-001`];
|
|
453
|
+
}
|
|
454
|
+
return [`${prefix}/${model}`];
|
|
455
|
+
}
|
|
456
|
+
function pickExistingOpenRouterModelId(candidates) {
|
|
457
|
+
const openrouterSet = getOpenRouterModelIdSet();
|
|
458
|
+
for (const candidate of candidates) {
|
|
459
|
+
if (openrouterSet.has(candidate.toLowerCase())) {
|
|
460
|
+
return candidate;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
function findModelInfo(provider, model) {
|
|
466
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
467
|
+
const normalizedModel = getNormalizedModelIdForLookup(provider, model);
|
|
468
|
+
const direct = providerInfo.models.find((m) => m.name.toLowerCase() === normalizedModel);
|
|
469
|
+
if (direct) return direct;
|
|
470
|
+
if (provider !== "openrouter" && hasAllRegistryModelsSupport(provider) && model.includes("/")) {
|
|
471
|
+
const openrouterModel = LLM_REGISTRY.openrouter.models.find(
|
|
472
|
+
(m) => m.name.toLowerCase() === model.toLowerCase()
|
|
473
|
+
);
|
|
474
|
+
if (openrouterModel) return openrouterModel;
|
|
475
|
+
}
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
function getAllModelsForProvider(provider) {
|
|
479
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
480
|
+
if (!providerInfo.supportsAllRegistryModels) {
|
|
481
|
+
return providerInfo.models.map((m) => ({ ...m }));
|
|
482
|
+
}
|
|
483
|
+
const allModels = [];
|
|
484
|
+
const seen = /* @__PURE__ */ new Set();
|
|
485
|
+
for (const model of providerInfo.models) {
|
|
486
|
+
const key = model.name.toLowerCase();
|
|
487
|
+
if (seen.has(key)) continue;
|
|
488
|
+
seen.add(key);
|
|
489
|
+
allModels.push({ ...model, originalProvider: provider });
|
|
490
|
+
}
|
|
491
|
+
if (provider !== "openrouter") {
|
|
492
|
+
for (const model of LLM_REGISTRY.openrouter.models) {
|
|
493
|
+
const key = model.name.toLowerCase();
|
|
494
|
+
if (seen.has(key)) continue;
|
|
495
|
+
seen.add(key);
|
|
496
|
+
allModels.push({ ...model, originalProvider: "openrouter" });
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return allModels;
|
|
500
|
+
}
|
|
501
|
+
function transformModelNameForProvider(model, originalProvider, targetProvider) {
|
|
502
|
+
if (!hasAllRegistryModelsSupport(targetProvider)) {
|
|
503
|
+
return model;
|
|
504
|
+
}
|
|
505
|
+
if (hasAllRegistryModelsSupport(originalProvider)) {
|
|
506
|
+
return model;
|
|
507
|
+
}
|
|
508
|
+
if (model.includes("/")) {
|
|
509
|
+
return model;
|
|
510
|
+
}
|
|
511
|
+
const candidates = getOpenRouterCandidateModelIds(model, originalProvider);
|
|
512
|
+
if (candidates.length === 0) return model;
|
|
513
|
+
return pickExistingOpenRouterModelId(candidates) ?? candidates[0];
|
|
514
|
+
}
|
|
515
|
+
function isModelValidForProvider(provider, model) {
|
|
516
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
517
|
+
const normalizedModel = getNormalizedModelIdForLookup(provider, model);
|
|
518
|
+
if (providerInfo.models.some((m) => m.name.toLowerCase() === normalizedModel)) {
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
if (providerInfo.supportsAllRegistryModels && !model.includes("/")) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
if (providerInfo.supportsCustomModels) {
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
527
|
+
if (providerInfo.supportsAllRegistryModels) {
|
|
528
|
+
return findModelInfo(provider, model) !== null;
|
|
529
|
+
}
|
|
530
|
+
return false;
|
|
531
|
+
}
|
|
532
|
+
const API_KEY_OPTIONAL_PROVIDERS = /* @__PURE__ */ new Set([
|
|
533
|
+
"local",
|
|
534
|
+
// Native node-llama-cpp execution - no auth needed
|
|
535
|
+
"ollama",
|
|
536
|
+
// Ollama server - no auth needed by default
|
|
537
|
+
"openai-compatible",
|
|
538
|
+
// vLLM, LocalAI - often no auth needed
|
|
539
|
+
"litellm",
|
|
540
|
+
// Self-hosted proxy - handles auth internally
|
|
541
|
+
"vertex",
|
|
542
|
+
// Uses Google Cloud ADC (Application Default Credentials)
|
|
543
|
+
"bedrock"
|
|
544
|
+
// Uses AWS credentials (access key + secret or IAM role)
|
|
545
|
+
]);
|
|
546
|
+
function requiresApiKey(provider) {
|
|
547
|
+
return !API_KEY_OPTIONAL_PROVIDERS.has(provider);
|
|
548
|
+
}
|
|
549
|
+
function getSupportedFileTypesForModel(provider, model) {
|
|
550
|
+
const providerInfo = LLM_REGISTRY[provider];
|
|
551
|
+
if (acceptsAnyModel(provider)) {
|
|
552
|
+
return providerInfo.supportedFileTypes;
|
|
553
|
+
}
|
|
554
|
+
const modelInfo = findModelInfo(provider, model);
|
|
555
|
+
if (modelInfo) {
|
|
556
|
+
return modelInfo.supportedFileTypes;
|
|
557
|
+
}
|
|
558
|
+
if (supportsCustomModels(provider)) {
|
|
559
|
+
return providerInfo.supportedFileTypes;
|
|
560
|
+
}
|
|
561
|
+
throw LLMError.unknownModel(provider, model);
|
|
562
|
+
}
|
|
563
|
+
function modelSupportsFileType(provider, model, fileType) {
|
|
564
|
+
const supportedTypes = getSupportedFileTypesForModel(provider, model);
|
|
565
|
+
return supportedTypes.includes(fileType);
|
|
566
|
+
}
|
|
567
|
+
function validateModelFileSupport(provider, model, mimeType) {
|
|
568
|
+
const baseMimeType = mimeType.toLowerCase().split(";")[0]?.trim() || mimeType.toLowerCase();
|
|
569
|
+
const fileType = MIME_TYPE_TO_FILE_TYPE[baseMimeType];
|
|
570
|
+
if (!fileType) {
|
|
571
|
+
return {
|
|
572
|
+
isSupported: false,
|
|
573
|
+
error: `Unsupported file type: ${mimeType}`
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
try {
|
|
577
|
+
if (!modelSupportsFileType(provider, model, fileType)) {
|
|
578
|
+
return {
|
|
579
|
+
isSupported: false,
|
|
580
|
+
fileType,
|
|
581
|
+
error: `Model '${model}' (${provider}) does not support ${fileType} files`
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
return {
|
|
585
|
+
isSupported: true,
|
|
586
|
+
fileType
|
|
587
|
+
};
|
|
588
|
+
} catch (error) {
|
|
589
|
+
return {
|
|
590
|
+
isSupported: false,
|
|
591
|
+
fileType,
|
|
592
|
+
error: error instanceof Error ? error.message : "Unknown error validating model file support"
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
function getEffectiveMaxInputTokens(config, logger) {
|
|
597
|
+
const configuredMaxInputTokens = config.maxInputTokens;
|
|
598
|
+
if (configuredMaxInputTokens != null) {
|
|
599
|
+
if (config.baseURL) {
|
|
600
|
+
logger.debug(
|
|
601
|
+
`Using maxInputTokens from configuration (with baseURL): ${configuredMaxInputTokens}`
|
|
602
|
+
);
|
|
603
|
+
return configuredMaxInputTokens;
|
|
604
|
+
}
|
|
605
|
+
try {
|
|
606
|
+
const registryMaxInputTokens = getMaxInputTokensForModel(
|
|
607
|
+
config.provider,
|
|
608
|
+
config.model,
|
|
609
|
+
logger
|
|
610
|
+
);
|
|
611
|
+
if (configuredMaxInputTokens > registryMaxInputTokens) {
|
|
612
|
+
logger.warn(
|
|
613
|
+
`Provided maxInputTokens (${configuredMaxInputTokens}) for ${config.provider}/${config.model} exceeds the known limit (${registryMaxInputTokens}) for model ${config.model}. Capping to registry limit.`
|
|
614
|
+
);
|
|
615
|
+
return registryMaxInputTokens;
|
|
616
|
+
} else {
|
|
617
|
+
logger.debug(
|
|
618
|
+
`Using valid maxInputTokens override from configuration: ${configuredMaxInputTokens} (Registry limit: ${registryMaxInputTokens})`
|
|
619
|
+
);
|
|
620
|
+
return configuredMaxInputTokens;
|
|
621
|
+
}
|
|
622
|
+
} catch (error) {
|
|
623
|
+
if (error instanceof DextoRuntimeError && error.code === LLMErrorCode.MODEL_UNKNOWN) {
|
|
624
|
+
logger.warn(
|
|
625
|
+
`Registry lookup failed during maxInputTokens override check for ${config.provider}/${config.model}: ${error.message}. Proceeding with the provided maxInputTokens value (${configuredMaxInputTokens}), but it might be invalid.`
|
|
626
|
+
);
|
|
627
|
+
return configuredMaxInputTokens;
|
|
628
|
+
} else {
|
|
629
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
630
|
+
logger.error(
|
|
631
|
+
`getEffectiveMaxInputTokens: unexpected error during maxInputTokens override check: ${errorMessage}`
|
|
632
|
+
);
|
|
633
|
+
throw error;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if (config.baseURL) {
|
|
638
|
+
logger.warn(
|
|
639
|
+
`baseURL is set but maxInputTokens is missing. Defaulting to ${DEFAULT_MAX_INPUT_TOKENS}. Provide 'maxInputTokens' in configuration to avoid default fallback.`
|
|
640
|
+
);
|
|
641
|
+
return DEFAULT_MAX_INPUT_TOKENS;
|
|
642
|
+
}
|
|
643
|
+
if (acceptsAnyModel(config.provider)) {
|
|
644
|
+
logger.debug(
|
|
645
|
+
`Provider ${config.provider} accepts any model, defaulting to ${DEFAULT_MAX_INPUT_TOKENS} tokens`
|
|
646
|
+
);
|
|
647
|
+
return DEFAULT_MAX_INPUT_TOKENS;
|
|
648
|
+
}
|
|
649
|
+
try {
|
|
650
|
+
const registryMaxInputTokens = getMaxInputTokensForModel(
|
|
651
|
+
config.provider,
|
|
652
|
+
config.model,
|
|
653
|
+
logger
|
|
654
|
+
);
|
|
655
|
+
logger.debug(
|
|
656
|
+
`Using maxInputTokens from registry for ${config.provider}/${config.model}: ${registryMaxInputTokens}`
|
|
657
|
+
);
|
|
658
|
+
return registryMaxInputTokens;
|
|
659
|
+
} catch (error) {
|
|
660
|
+
if (error instanceof DextoRuntimeError && error.code === LLMErrorCode.MODEL_UNKNOWN) {
|
|
661
|
+
if (supportsCustomModels(config.provider)) {
|
|
662
|
+
logger.debug(
|
|
663
|
+
`Custom model ${config.model} not in ${config.provider} registry, defaulting to ${DEFAULT_MAX_INPUT_TOKENS} tokens`
|
|
664
|
+
);
|
|
665
|
+
return DEFAULT_MAX_INPUT_TOKENS;
|
|
666
|
+
}
|
|
667
|
+
logger.error(
|
|
668
|
+
`Registry lookup failed for ${config.provider}/${config.model}: ${error.message}. Effective maxInputTokens cannot be determined.`
|
|
669
|
+
);
|
|
670
|
+
throw LLMError.unknownModel(config.provider, config.model);
|
|
671
|
+
} else {
|
|
672
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
673
|
+
logger.error(
|
|
674
|
+
`getEffectiveMaxInputTokens: unexpected error during registry lookup for maxInputTokens: ${errorMessage}`
|
|
675
|
+
);
|
|
676
|
+
throw error;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
function getModelPricing(provider, model) {
|
|
681
|
+
if (acceptsAnyModel(provider)) {
|
|
682
|
+
return void 0;
|
|
683
|
+
}
|
|
684
|
+
const modelInfo = findModelInfo(provider, model);
|
|
685
|
+
return modelInfo?.pricing;
|
|
686
|
+
}
|
|
687
|
+
function getModelDisplayName(model, provider) {
|
|
688
|
+
if (provider) {
|
|
689
|
+
const modelInfo = findModelInfo(provider, model);
|
|
690
|
+
return modelInfo?.displayName ?? model;
|
|
691
|
+
}
|
|
692
|
+
if (model.includes("/")) {
|
|
693
|
+
const modelInfo = findModelInfo("openrouter", model);
|
|
694
|
+
return modelInfo?.displayName ?? model;
|
|
695
|
+
}
|
|
696
|
+
try {
|
|
697
|
+
const inferredProvider = getProviderFromModel(model);
|
|
698
|
+
const modelInfo = findModelInfo(inferredProvider, model);
|
|
699
|
+
return modelInfo?.displayName ?? model;
|
|
700
|
+
} catch {
|
|
701
|
+
return model;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function isReasoningCapableModel(model, _provider) {
|
|
705
|
+
const modelLower = model.toLowerCase();
|
|
706
|
+
if (modelLower.includes("codex")) {
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
if (modelLower.startsWith("o1") || modelLower.startsWith("o3") || modelLower.startsWith("o4")) {
|
|
710
|
+
return true;
|
|
711
|
+
}
|
|
712
|
+
if (modelLower.includes("gpt-5") || modelLower.includes("gpt-5.1") || modelLower.includes("gpt-5.2")) {
|
|
713
|
+
return true;
|
|
714
|
+
}
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
function calculateCost(usage, pricing) {
|
|
718
|
+
const inputCost = (usage.inputTokens ?? 0) * pricing.inputPerM / 1e6;
|
|
719
|
+
const outputCost = (usage.outputTokens ?? 0) * pricing.outputPerM / 1e6;
|
|
720
|
+
const cacheReadCost = (usage.cacheReadTokens ?? 0) * (pricing.cacheReadPerM ?? 0) / 1e6;
|
|
721
|
+
const cacheWriteCost = (usage.cacheWriteTokens ?? 0) * (pricing.cacheWritePerM ?? 0) / 1e6;
|
|
722
|
+
const reasoningCost = (usage.reasoningTokens ?? 0) * pricing.outputPerM / 1e6;
|
|
723
|
+
return inputCost + outputCost + cacheReadCost + cacheWriteCost + reasoningCost;
|
|
724
|
+
}
|
|
725
|
+
export {
|
|
726
|
+
DEFAULT_MAX_INPUT_TOKENS,
|
|
727
|
+
LLM_REGISTRY,
|
|
728
|
+
MIME_TYPE_TO_FILE_TYPE,
|
|
729
|
+
acceptsAnyModel,
|
|
730
|
+
calculateCost,
|
|
731
|
+
getAllModelsForProvider,
|
|
732
|
+
getAllSupportedModels,
|
|
733
|
+
getAllowedMimeTypes,
|
|
734
|
+
getDefaultModelForProvider,
|
|
735
|
+
getEffectiveMaxInputTokens,
|
|
736
|
+
getMaxInputTokensForModel,
|
|
737
|
+
getModelDisplayName,
|
|
738
|
+
getModelPricing,
|
|
739
|
+
getOpenRouterCandidateModelIds,
|
|
740
|
+
getProviderFromModel,
|
|
741
|
+
getSupportedFileTypesForModel,
|
|
742
|
+
getSupportedModels,
|
|
743
|
+
getSupportedProviders,
|
|
744
|
+
hasAllRegistryModelsSupport,
|
|
745
|
+
isModelValidForProvider,
|
|
746
|
+
isReasoningCapableModel,
|
|
747
|
+
isValidProviderModel,
|
|
748
|
+
modelSupportsFileType,
|
|
749
|
+
requiresApiKey,
|
|
750
|
+
requiresBaseURL,
|
|
751
|
+
stripBedrockRegionPrefix,
|
|
752
|
+
supportsBaseURL,
|
|
753
|
+
supportsCustomModels,
|
|
754
|
+
transformModelNameForProvider,
|
|
755
|
+
validateModelFileSupport
|
|
756
|
+
};
|