@dexto/core 1.4.0 → 1.5.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 +36 -0
- package/dist/agent/DextoAgent.cjs +22 -3
- package/dist/agent/DextoAgent.d.ts +19 -2
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +23 -4
- package/dist/agent/index.cjs +4 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +5 -1
- package/dist/agent/schemas.cjs +90 -71
- package/dist/agent/schemas.d.ts +5911 -96
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/agent/schemas.js +87 -66
- package/dist/approval/manager.cjs +165 -1
- package/dist/approval/manager.d.ts +91 -2
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +155 -1
- package/dist/approval/schemas.cjs +39 -3
- package/dist/approval/schemas.d.ts +238 -1
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +35 -3
- package/dist/approval/types.cjs +1 -0
- package/dist/approval/types.d.ts +26 -1
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +1 -0
- package/dist/context/compaction/factory.cjs +57 -0
- package/dist/context/compaction/factory.d.ts +17 -0
- package/dist/context/compaction/factory.d.ts.map +1 -0
- package/dist/context/compaction/factory.js +34 -0
- package/dist/context/compaction/index.cjs +49 -0
- package/dist/context/compaction/index.d.ts +11 -0
- package/dist/context/compaction/index.d.ts.map +1 -0
- package/dist/context/compaction/index.js +19 -0
- package/dist/context/{compression → compaction}/overflow.cjs +3 -3
- package/dist/context/{compression → compaction}/overflow.d.ts +4 -4
- package/dist/context/compaction/overflow.d.ts.map +1 -0
- package/dist/context/{compression → compaction}/overflow.js +2 -2
- package/dist/context/compaction/provider.cjs +16 -0
- package/dist/context/compaction/provider.d.ts +48 -0
- package/dist/context/compaction/provider.d.ts.map +1 -0
- package/dist/context/compaction/providers/noop-provider.cjs +48 -0
- package/dist/context/compaction/providers/noop-provider.d.ts +24 -0
- package/dist/context/compaction/providers/noop-provider.d.ts.map +1 -0
- package/dist/context/compaction/providers/noop-provider.js +24 -0
- package/dist/context/compaction/providers/reactive-overflow-provider.cjs +61 -0
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts +36 -0
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts.map +1 -0
- package/dist/context/compaction/providers/reactive-overflow-provider.js +37 -0
- package/dist/context/compaction/registry.cjs +39 -0
- package/dist/context/compaction/registry.d.ts +19 -0
- package/dist/context/compaction/registry.d.ts.map +1 -0
- package/dist/context/compaction/registry.js +16 -0
- package/dist/context/compaction/schemas.cjs +38 -0
- package/dist/context/compaction/schemas.d.ts +24 -0
- package/dist/context/compaction/schemas.d.ts.map +1 -0
- package/dist/context/compaction/schemas.js +14 -0
- package/dist/context/compaction/strategies/noop.cjs +36 -0
- package/dist/context/compaction/strategies/noop.d.ts +18 -0
- package/dist/context/compaction/strategies/noop.d.ts.map +1 -0
- package/dist/context/compaction/strategies/noop.js +13 -0
- package/dist/context/{compression → compaction/strategies}/reactive-overflow.cjs +3 -3
- package/dist/context/{compression → compaction/strategies}/reactive-overflow.d.ts +6 -6
- package/dist/context/compaction/strategies/reactive-overflow.d.ts.map +1 -0
- package/dist/context/{compression → compaction/strategies}/reactive-overflow.js +4 -4
- package/dist/context/{compression → compaction}/types.d.ts +4 -4
- package/dist/context/compaction/types.d.ts.map +1 -0
- package/dist/context/compaction/types.js +0 -0
- package/dist/context/error-codes.cjs +4 -0
- package/dist/context/error-codes.d.ts +4 -0
- package/dist/context/error-codes.d.ts.map +1 -1
- package/dist/context/error-codes.js +4 -0
- package/dist/context/errors.cjs +40 -0
- package/dist/context/errors.d.ts +14 -0
- package/dist/context/errors.d.ts.map +1 -1
- package/dist/context/errors.js +40 -0
- package/dist/context/index.cjs +3 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/types.d.ts +6 -0
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/utils.cjs +27 -7
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +27 -7
- package/dist/errors/result-bridge.cjs +2 -3
- package/dist/errors/result-bridge.d.ts.map +1 -1
- package/dist/errors/result-bridge.js +2 -3
- package/dist/events/index.cjs +2 -2
- package/dist/events/index.d.ts +16 -16
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +2 -2
- package/dist/filesystem/filesystem-service.cjs +39 -0
- package/dist/filesystem/filesystem-service.d.ts +32 -0
- package/dist/filesystem/filesystem-service.d.ts.map +1 -1
- package/dist/filesystem/filesystem-service.js +39 -0
- package/dist/filesystem/index.d.ts +1 -1
- package/dist/filesystem/index.d.ts.map +1 -1
- package/dist/filesystem/path-validator.cjs +69 -1
- package/dist/filesystem/path-validator.d.ts +43 -2
- package/dist/filesystem/path-validator.d.ts.map +1 -1
- package/dist/filesystem/path-validator.js +69 -1
- package/dist/image/define-image.cjs +146 -0
- package/dist/image/define-image.d.ts +71 -0
- package/dist/image/define-image.d.ts.map +1 -0
- package/dist/image/define-image.js +121 -0
- package/dist/image/index.cjs +32 -0
- package/dist/image/index.d.ts +53 -0
- package/dist/image/index.d.ts.map +1 -0
- package/dist/image/index.js +7 -0
- package/dist/image/types.cjs +16 -0
- package/dist/image/types.d.ts +231 -0
- package/dist/image/types.d.ts.map +1 -0
- package/dist/image/types.js +0 -0
- package/dist/index.cjs +5 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/llm/error-codes.cjs +1 -0
- package/dist/llm/error-codes.d.ts +1 -0
- package/dist/llm/error-codes.d.ts.map +1 -1
- package/dist/llm/error-codes.js +1 -0
- package/dist/llm/errors.cjs +24 -0
- package/dist/llm/errors.d.ts +19 -6
- package/dist/llm/errors.d.ts.map +1 -1
- package/dist/llm/errors.js +24 -0
- package/dist/llm/executor/stream-processor.cjs +11 -3
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +11 -3
- package/dist/llm/executor/turn-executor.cjs +50 -23
- package/dist/llm/executor/turn-executor.d.ts +6 -5
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +50 -23
- package/dist/llm/formatters/vercel.cjs +6 -2
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +6 -2
- package/dist/llm/index.cjs +18 -1
- package/dist/llm/index.d.ts +2 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +14 -0
- package/dist/llm/providers/local/ai-sdk-adapter.cjs +308 -0
- package/dist/llm/providers/local/ai-sdk-adapter.d.ts +29 -0
- package/dist/llm/providers/local/ai-sdk-adapter.d.ts.map +1 -0
- package/dist/llm/providers/local/ai-sdk-adapter.js +278 -0
- package/dist/llm/providers/local/downloader.cjs +291 -0
- package/dist/llm/providers/local/downloader.d.ts +82 -0
- package/dist/llm/providers/local/downloader.d.ts.map +1 -0
- package/dist/llm/providers/local/downloader.js +251 -0
- package/dist/llm/providers/local/error-codes.cjs +57 -0
- package/dist/llm/providers/local/error-codes.d.ts +66 -0
- package/dist/llm/providers/local/error-codes.d.ts.map +1 -0
- package/dist/llm/providers/local/error-codes.js +34 -0
- package/dist/llm/providers/local/errors.cjs +240 -0
- package/dist/llm/providers/local/errors.d.ts +31 -0
- package/dist/llm/providers/local/errors.d.ts.map +1 -0
- package/dist/llm/providers/local/errors.js +217 -0
- package/dist/llm/providers/local/gpu-detector.cjs +214 -0
- package/dist/llm/providers/local/gpu-detector.d.ts +28 -0
- package/dist/llm/providers/local/gpu-detector.d.ts.map +1 -0
- package/dist/llm/providers/local/gpu-detector.js +178 -0
- package/dist/llm/providers/local/index.cjs +147 -0
- package/dist/llm/providers/local/index.d.ts +21 -0
- package/dist/llm/providers/local/index.d.ts.map +1 -0
- package/dist/llm/providers/local/index.js +126 -0
- package/dist/llm/providers/local/node-llama-provider.cjs +216 -0
- package/dist/llm/providers/local/node-llama-provider.d.ts +90 -0
- package/dist/llm/providers/local/node-llama-provider.d.ts.map +1 -0
- package/dist/llm/providers/local/node-llama-provider.js +176 -0
- package/dist/llm/providers/local/ollama-provider.cjs +230 -0
- package/dist/llm/providers/local/ollama-provider.d.ts +70 -0
- package/dist/llm/providers/local/ollama-provider.d.ts.map +1 -0
- package/dist/llm/providers/local/ollama-provider.js +198 -0
- package/dist/llm/providers/local/registry.cjs +343 -0
- package/dist/llm/providers/local/registry.d.ts +51 -0
- package/dist/llm/providers/local/registry.d.ts.map +1 -0
- package/dist/llm/providers/local/registry.js +312 -0
- package/dist/llm/providers/local/schemas.cjs +169 -0
- package/dist/llm/providers/local/schemas.d.ts +395 -0
- package/dist/llm/providers/local/schemas.d.ts.map +1 -0
- package/dist/llm/providers/local/schemas.js +133 -0
- package/dist/llm/providers/local/types.cjs +16 -0
- package/dist/llm/providers/local/types.d.ts +219 -0
- package/dist/llm/providers/local/types.d.ts.map +1 -0
- package/dist/llm/providers/local/types.js +0 -0
- package/dist/llm/providers/openrouter-model-registry.cjs +350 -0
- package/dist/llm/providers/openrouter-model-registry.d.ts +120 -0
- package/dist/llm/providers/openrouter-model-registry.d.ts.map +1 -0
- package/dist/llm/providers/openrouter-model-registry.js +309 -0
- package/dist/llm/registry.cjs +535 -9
- package/dist/llm/registry.d.ts +26 -0
- package/dist/llm/registry.d.ts.map +1 -1
- package/dist/llm/registry.js +532 -9
- package/dist/llm/resolver.cjs +63 -5
- package/dist/llm/resolver.d.ts +3 -3
- package/dist/llm/resolver.d.ts.map +1 -1
- package/dist/llm/resolver.js +69 -6
- package/dist/llm/schemas.cjs +90 -80
- package/dist/llm/schemas.d.ts +158 -22
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +90 -80
- package/dist/llm/services/factory.cjs +87 -13
- package/dist/llm/services/factory.d.ts +4 -1
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +85 -12
- package/dist/llm/services/test-utils.integration.cjs +22 -2
- package/dist/llm/services/test-utils.integration.d.ts +7 -1
- package/dist/llm/services/test-utils.integration.d.ts.map +1 -1
- package/dist/llm/services/test-utils.integration.js +26 -3
- package/dist/llm/services/vercel.cjs +5 -2
- package/dist/llm/services/vercel.d.ts +3 -2
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +5 -2
- package/dist/llm/types.cjs +11 -1
- package/dist/llm/types.d.ts +1 -1
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js +11 -1
- package/dist/mcp/manager.cjs +8 -0
- package/dist/mcp/manager.d.ts +17 -0
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +8 -0
- package/dist/mcp/mcp-client.cjs +0 -3
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +0 -3
- package/dist/memory/schemas.d.ts +1 -1
- package/dist/plugins/error-codes.cjs +3 -0
- package/dist/plugins/error-codes.d.ts +7 -1
- package/dist/plugins/error-codes.d.ts.map +1 -1
- package/dist/plugins/error-codes.js +3 -0
- package/dist/plugins/index.cjs +7 -0
- package/dist/plugins/index.d.ts +4 -2
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +6 -1
- package/dist/plugins/manager.cjs +92 -7
- package/dist/plugins/manager.d.ts +10 -3
- package/dist/plugins/manager.d.ts.map +1 -1
- package/dist/plugins/manager.js +92 -7
- package/dist/plugins/registry.cjs +63 -0
- package/dist/plugins/registry.d.ts +101 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +39 -0
- package/dist/plugins/schemas.cjs +17 -5
- package/dist/plugins/schemas.d.ts +62 -5
- package/dist/plugins/schemas.d.ts.map +1 -1
- package/dist/plugins/schemas.js +15 -4
- package/dist/providers/base-registry.cjs +147 -0
- package/dist/providers/base-registry.d.ts +147 -0
- package/dist/providers/base-registry.d.ts.map +1 -0
- package/dist/providers/base-registry.js +123 -0
- package/dist/providers/discovery.cjs +95 -0
- package/dist/providers/discovery.d.ts +94 -0
- package/dist/providers/discovery.d.ts.map +1 -0
- package/dist/providers/discovery.js +70 -0
- package/dist/providers/index.cjs +24 -0
- package/dist/providers/index.d.ts +32 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +2 -0
- package/dist/resources/reference-parser.cjs +3 -3
- package/dist/resources/reference-parser.d.ts.map +1 -1
- package/dist/resources/reference-parser.js +3 -3
- package/dist/session/chat-session.cjs +20 -3
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +21 -4
- package/dist/storage/blob/factory.cjs +8 -11
- package/dist/storage/blob/factory.d.ts +32 -6
- package/dist/storage/blob/factory.d.ts.map +1 -1
- package/dist/storage/blob/factory.js +8 -11
- package/dist/storage/blob/index.cjs +56 -0
- package/dist/storage/blob/index.d.ts +45 -0
- package/dist/storage/blob/index.d.ts.map +1 -0
- package/dist/storage/blob/index.js +30 -0
- package/dist/storage/blob/provider.cjs +16 -0
- package/dist/storage/blob/provider.d.ts +50 -0
- package/dist/storage/blob/provider.d.ts.map +1 -0
- package/dist/storage/blob/provider.js +0 -0
- package/dist/storage/blob/providers/index.cjs +31 -0
- package/dist/storage/blob/providers/index.d.ts +8 -0
- package/dist/storage/blob/providers/index.d.ts.map +1 -0
- package/dist/storage/blob/providers/index.js +7 -0
- package/dist/storage/blob/providers/local.cjs +39 -0
- package/dist/storage/blob/providers/local.d.ts +17 -0
- package/dist/storage/blob/providers/local.d.ts.map +1 -0
- package/dist/storage/blob/providers/local.js +16 -0
- package/dist/storage/blob/providers/memory.cjs +39 -0
- package/dist/storage/blob/providers/memory.d.ts +17 -0
- package/dist/storage/blob/providers/memory.d.ts.map +1 -0
- package/dist/storage/blob/providers/memory.js +16 -0
- package/dist/storage/blob/registry.cjs +50 -0
- package/dist/storage/blob/registry.d.ts +42 -0
- package/dist/storage/blob/registry.d.ts.map +1 -0
- package/dist/storage/blob/registry.js +26 -0
- package/dist/storage/blob/schemas.cjs +9 -12
- package/dist/storage/blob/schemas.d.ts +39 -34
- package/dist/storage/blob/schemas.d.ts.map +1 -1
- package/dist/storage/blob/schemas.js +6 -11
- package/dist/storage/cache/factory.cjs +8 -36
- package/dist/storage/cache/factory.d.ts +32 -7
- package/dist/storage/cache/factory.d.ts.map +1 -1
- package/dist/storage/cache/factory.js +8 -26
- package/dist/storage/cache/index.cjs +53 -0
- package/dist/storage/cache/index.d.ts +44 -0
- package/dist/storage/cache/index.d.ts.map +1 -0
- package/dist/storage/cache/index.js +28 -0
- package/dist/storage/cache/provider.cjs +16 -0
- package/dist/storage/cache/provider.d.ts +56 -0
- package/dist/storage/cache/provider.d.ts.map +1 -0
- package/dist/storage/cache/provider.js +0 -0
- package/dist/storage/cache/providers/index.cjs +31 -0
- package/dist/storage/cache/providers/index.d.ts +8 -0
- package/dist/storage/cache/providers/index.d.ts.map +1 -0
- package/dist/storage/cache/providers/index.js +7 -0
- package/dist/storage/cache/providers/memory.cjs +40 -0
- package/dist/storage/cache/providers/memory.d.ts +17 -0
- package/dist/storage/cache/providers/memory.d.ts.map +1 -0
- package/dist/storage/cache/providers/memory.js +17 -0
- package/dist/storage/cache/providers/redis.cjs +66 -0
- package/dist/storage/cache/providers/redis.d.ts +20 -0
- package/dist/storage/cache/providers/redis.d.ts.map +1 -0
- package/dist/storage/cache/providers/redis.js +33 -0
- package/dist/storage/cache/registry.cjs +50 -0
- package/dist/storage/cache/registry.d.ts +42 -0
- package/dist/storage/cache/registry.d.ts.map +1 -0
- package/dist/storage/cache/registry.js +26 -0
- package/dist/storage/cache/schemas.cjs +6 -2
- package/dist/storage/cache/schemas.d.ts +2 -3
- package/dist/storage/cache/schemas.d.ts.map +1 -1
- package/dist/storage/cache/schemas.js +3 -1
- package/dist/storage/database/factory.cjs +8 -47
- package/dist/storage/database/factory.d.ts +34 -8
- package/dist/storage/database/factory.d.ts.map +1 -1
- package/dist/storage/database/factory.js +8 -37
- package/dist/storage/database/index.cjs +58 -0
- package/dist/storage/database/index.d.ts +45 -0
- package/dist/storage/database/index.d.ts.map +1 -0
- package/dist/storage/database/index.js +37 -0
- package/dist/storage/database/provider.cjs +16 -0
- package/dist/storage/database/provider.d.ts +56 -0
- package/dist/storage/database/provider.d.ts.map +1 -0
- package/dist/storage/database/provider.js +0 -0
- package/dist/storage/database/providers/index.cjs +34 -0
- package/dist/storage/database/providers/index.d.ts +9 -0
- package/dist/storage/database/providers/index.d.ts.map +1 -0
- package/dist/storage/database/providers/index.js +9 -0
- package/dist/storage/database/providers/memory.cjs +40 -0
- package/dist/storage/database/providers/memory.d.ts +16 -0
- package/dist/storage/database/providers/memory.d.ts.map +1 -0
- package/dist/storage/database/providers/memory.js +17 -0
- package/dist/storage/database/providers/postgres.cjs +62 -0
- package/dist/storage/database/providers/postgres.d.ts +19 -0
- package/dist/storage/database/providers/postgres.d.ts.map +1 -0
- package/dist/storage/database/providers/postgres.js +29 -0
- package/dist/storage/database/providers/sqlite.cjs +66 -0
- package/dist/storage/database/providers/sqlite.d.ts +20 -0
- package/dist/storage/database/providers/sqlite.d.ts.map +1 -0
- package/dist/storage/database/providers/sqlite.js +33 -0
- package/dist/storage/database/registry.cjs +50 -0
- package/dist/storage/database/registry.d.ts +42 -0
- package/dist/storage/database/registry.d.ts.map +1 -0
- package/dist/storage/database/registry.js +26 -0
- package/dist/storage/database/schemas.cjs +8 -2
- package/dist/storage/database/schemas.d.ts +3 -4
- package/dist/storage/database/schemas.d.ts.map +1 -1
- package/dist/storage/database/schemas.js +4 -1
- package/dist/storage/error-codes.cjs +6 -0
- package/dist/storage/error-codes.d.ts +7 -1
- package/dist/storage/error-codes.d.ts.map +1 -1
- package/dist/storage/error-codes.js +6 -0
- package/dist/storage/errors.cjs +80 -0
- package/dist/storage/errors.d.ts +24 -0
- package/dist/storage/errors.d.ts.map +1 -1
- package/dist/storage/errors.js +80 -0
- package/dist/storage/index.cjs +47 -4
- package/dist/storage/index.d.ts +34 -8
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +32 -3
- package/dist/storage/schemas.cjs +4 -0
- package/dist/storage/schemas.d.ts +17 -50
- package/dist/storage/schemas.d.ts.map +1 -1
- package/dist/storage/schemas.js +5 -1
- package/dist/storage/storage-manager.cjs +6 -6
- package/dist/storage/storage-manager.d.ts.map +1 -1
- package/dist/storage/storage-manager.js +3 -3
- package/dist/systemPrompt/in-built-prompts.cjs +7 -6
- package/dist/systemPrompt/in-built-prompts.d.ts +2 -2
- package/dist/systemPrompt/in-built-prompts.d.ts.map +1 -1
- package/dist/systemPrompt/in-built-prompts.js +6 -5
- package/dist/systemPrompt/registry.cjs +2 -2
- package/dist/systemPrompt/registry.d.ts +1 -1
- package/dist/systemPrompt/registry.d.ts.map +1 -1
- package/dist/systemPrompt/registry.js +2 -2
- package/dist/systemPrompt/schemas.cjs +2 -2
- package/dist/systemPrompt/schemas.d.ts +13 -13
- package/dist/systemPrompt/schemas.js +2 -2
- package/dist/tools/custom-tool-registry.cjs +64 -0
- package/dist/tools/custom-tool-registry.d.ts +120 -0
- package/dist/tools/custom-tool-registry.d.ts.map +1 -0
- package/dist/tools/custom-tool-registry.js +40 -0
- package/dist/tools/custom-tool-schema-registry.cjs +164 -0
- package/dist/tools/custom-tool-schema-registry.d.ts +86 -0
- package/dist/tools/custom-tool-schema-registry.d.ts.map +1 -0
- package/dist/tools/custom-tool-schema-registry.js +140 -0
- package/dist/tools/error-codes.cjs +3 -0
- package/dist/tools/error-codes.d.ts +4 -1
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +3 -0
- package/dist/tools/errors.cjs +41 -0
- package/dist/tools/errors.d.ts +17 -0
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +41 -0
- package/dist/tools/index.cjs +13 -1
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +11 -1
- package/dist/tools/internal-tools/constants.cjs +3 -9
- package/dist/tools/internal-tools/constants.d.ts +1 -1
- package/dist/tools/internal-tools/constants.d.ts.map +1 -1
- package/dist/tools/internal-tools/constants.js +3 -9
- package/dist/tools/internal-tools/implementations/get-resource-tool.cjs +113 -0
- package/dist/tools/internal-tools/implementations/get-resource-tool.d.ts +30 -0
- package/dist/tools/internal-tools/implementations/get-resource-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/get-resource-tool.js +90 -0
- package/dist/tools/internal-tools/implementations/list-resources-tool.cjs +91 -0
- package/dist/tools/internal-tools/implementations/list-resources-tool.d.ts +24 -0
- package/dist/tools/internal-tools/implementations/list-resources-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/list-resources-tool.js +68 -0
- package/dist/tools/internal-tools/provider.cjs +150 -23
- package/dist/tools/internal-tools/provider.d.ts +55 -10
- package/dist/tools/internal-tools/provider.d.ts.map +1 -1
- package/dist/tools/internal-tools/provider.js +150 -23
- package/dist/tools/internal-tools/registry.cjs +18 -43
- package/dist/tools/internal-tools/registry.d.ts +4 -4
- package/dist/tools/internal-tools/registry.d.ts.map +1 -1
- package/dist/tools/internal-tools/registry.js +18 -43
- package/dist/tools/schemas.cjs +20 -0
- package/dist/tools/schemas.d.ts +43 -1
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +16 -0
- package/dist/tools/tool-manager.cjs +140 -13
- package/dist/tools/tool-manager.d.ts +22 -3
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +140 -13
- package/dist/tools/types.d.ts +43 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/api-key-resolver.cjs +19 -1
- package/dist/utils/api-key-resolver.d.ts.map +1 -1
- package/dist/utils/api-key-resolver.js +19 -1
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/redactor.cjs +18 -3
- package/dist/utils/redactor.d.ts +0 -7
- package/dist/utils/redactor.d.ts.map +1 -1
- package/dist/utils/redactor.js +18 -3
- package/dist/utils/service-initializer.cjs +9 -35
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +9 -35
- package/package.json +5 -2
- package/dist/context/compression/overflow.d.ts.map +0 -1
- package/dist/context/compression/reactive-overflow.d.ts.map +0 -1
- package/dist/context/compression/types.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/bash-exec-tool.cjs +0 -130
- package/dist/tools/internal-tools/implementations/bash-exec-tool.d.ts +0 -13
- package/dist/tools/internal-tools/implementations/bash-exec-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/bash-exec-tool.js +0 -97
- package/dist/tools/internal-tools/implementations/bash-output-tool.cjs +0 -49
- package/dist/tools/internal-tools/implementations/bash-output-tool.d.ts +0 -12
- package/dist/tools/internal-tools/implementations/bash-output-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/bash-output-tool.js +0 -26
- package/dist/tools/internal-tools/implementations/edit-file-tool.cjs +0 -127
- package/dist/tools/internal-tools/implementations/edit-file-tool.d.ts +0 -12
- package/dist/tools/internal-tools/implementations/edit-file-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/edit-file-tool.js +0 -104
- package/dist/tools/internal-tools/implementations/glob-files-tool.cjs +0 -70
- package/dist/tools/internal-tools/implementations/glob-files-tool.d.ts +0 -12
- package/dist/tools/internal-tools/implementations/glob-files-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/glob-files-tool.js +0 -47
- package/dist/tools/internal-tools/implementations/grep-content-tool.cjs +0 -86
- package/dist/tools/internal-tools/implementations/grep-content-tool.d.ts +0 -12
- package/dist/tools/internal-tools/implementations/grep-content-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/grep-content-tool.js +0 -63
- package/dist/tools/internal-tools/implementations/kill-process-tool.cjs +0 -47
- package/dist/tools/internal-tools/implementations/kill-process-tool.d.ts +0 -12
- package/dist/tools/internal-tools/implementations/kill-process-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/kill-process-tool.js +0 -24
- package/dist/tools/internal-tools/implementations/read-file-tool.cjs +0 -63
- package/dist/tools/internal-tools/implementations/read-file-tool.d.ts +0 -12
- package/dist/tools/internal-tools/implementations/read-file-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/read-file-tool.js +0 -40
- package/dist/tools/internal-tools/implementations/write-file-tool.cjs +0 -124
- package/dist/tools/internal-tools/implementations/write-file-tool.d.ts +0 -12
- package/dist/tools/internal-tools/implementations/write-file-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/write-file-tool.js +0 -103
- package/dist/utils/env-file.cjs +0 -118
- package/dist/utils/env-file.d.ts +0 -5
- package/dist/utils/env-file.d.ts.map +0 -1
- package/dist/utils/env-file.js +0 -85
- /package/dist/context/{compression/types.js → compaction/provider.js} +0 -0
- /package/dist/context/{compression → compaction}/types.cjs +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openrouter-model-registry.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/openrouter-model-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAE3D,iCAAiC;AACjC,MAAM,WAAW,mBAAmB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;CACzB;AAOD,UAAU,cAAc;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAKD,cAAM,uBAAuB;IAQb,OAAO,CAAC,QAAQ,CAAC,SAAS;IAPtC,iDAAiD;IACjD,OAAO,CAAC,MAAM,CAAiD;IAC/D,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,cAAc,CAAC,CAAS;gBAEH,SAAS,EAAE,MAAM;IAI9C;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY;IAqBrC;;;OAGG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAchD;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;IAazD;;OAEG;IACH,eAAe,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI;IA+B/C;;OAEG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCtD;;OAEG;IACH,eAAe,IAAI,MAAM,EAAE,GAAG,IAAI;IAOlC;;OAEG;IACH,uBAAuB,IAAI,mBAAmB,EAAE,GAAG,IAAI;IAOvD;;OAEG;IACH,gBAAgB,IAAI;QAAE,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE;YAQ1E,eAAe;IA6B7B,OAAO,CAAC,iBAAiB;IAsCzB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,YAAY;YAON,UAAU;IAwBxB,OAAO,CAAC,aAAa;IAwCrB,OAAO,CAAC,WAAW;CAQtB;AAID,eAAO,MAAM,uBAAuB,yBAAyC,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAEnE;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,CAE7E;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,EAAE,GAAG,IAAI,CAE3D;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE9E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAElF;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI;IAC3C,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CACpB,CAEA;AAGD,eAAO,MAAM,aAAa;;;CAGzB,CAAC"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import "../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { getDextoGlobalPath } from "../../utils/path.js";
|
|
6
|
+
import { logger } from "../../logger/logger.js";
|
|
7
|
+
const OPENROUTER_MODELS_ENDPOINT = "https://openrouter.ai/api/v1/models";
|
|
8
|
+
const CACHE_FILENAME = "openrouter-models.json";
|
|
9
|
+
const CACHE_SUBDIR = "cache";
|
|
10
|
+
const CACHE_TTL_MS = 1e3 * 60 * 60 * 24;
|
|
11
|
+
const MIN_REFRESH_INTERVAL_MS = 1e3 * 60 * 5;
|
|
12
|
+
const DEFAULT_CONTEXT_LENGTH = 128e3;
|
|
13
|
+
class OpenRouterModelRegistry {
|
|
14
|
+
constructor(cachePath2) {
|
|
15
|
+
this.cachePath = cachePath2;
|
|
16
|
+
this.loadCacheFromDisk();
|
|
17
|
+
}
|
|
18
|
+
/** Map from normalized model ID to model info */
|
|
19
|
+
models = null;
|
|
20
|
+
lastFetchedAt = null;
|
|
21
|
+
refreshPromise = null;
|
|
22
|
+
lastRefreshAttemptAt = null;
|
|
23
|
+
lastUsedApiKey;
|
|
24
|
+
/**
|
|
25
|
+
* Look up a model ID against the OpenRouter catalog.
|
|
26
|
+
* @returns 'valid' if model exists, 'invalid' if not found, 'unknown' if cache is stale/empty
|
|
27
|
+
*/
|
|
28
|
+
lookup(modelId) {
|
|
29
|
+
const normalized = this.normalizeModelId(modelId);
|
|
30
|
+
if (!normalized) {
|
|
31
|
+
return "unknown";
|
|
32
|
+
}
|
|
33
|
+
if (!this.models || this.models.size === 0) {
|
|
34
|
+
this.scheduleRefresh({ force: true });
|
|
35
|
+
return "unknown";
|
|
36
|
+
}
|
|
37
|
+
if (!this.isCacheFresh()) {
|
|
38
|
+
this.scheduleRefresh();
|
|
39
|
+
return "unknown";
|
|
40
|
+
}
|
|
41
|
+
return this.models.has(normalized) ? "valid" : "invalid";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get context length for a model ID.
|
|
45
|
+
* @returns context length if model is in cache, null if not found or cache is stale
|
|
46
|
+
*/
|
|
47
|
+
getContextLength(modelId) {
|
|
48
|
+
const normalized = this.normalizeModelId(modelId);
|
|
49
|
+
if (!normalized) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (!this.models || this.models.size === 0 || !this.isCacheFresh()) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const info = this.models.get(normalized);
|
|
56
|
+
return info?.contextLength ?? null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get model info for a model ID.
|
|
60
|
+
* @returns model info if found in cache, null otherwise
|
|
61
|
+
*/
|
|
62
|
+
getModelInfo(modelId) {
|
|
63
|
+
const normalized = this.normalizeModelId(modelId);
|
|
64
|
+
if (!normalized) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
if (!this.models || this.models.size === 0 || !this.isCacheFresh()) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return this.models.get(normalized) ?? null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Schedule a non-blocking background refresh of the model cache.
|
|
74
|
+
*/
|
|
75
|
+
scheduleRefresh(options) {
|
|
76
|
+
const apiKey = options?.apiKey ?? this.lastUsedApiKey;
|
|
77
|
+
if (apiKey) {
|
|
78
|
+
this.lastUsedApiKey = apiKey;
|
|
79
|
+
}
|
|
80
|
+
if (this.refreshPromise) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const now = Date.now();
|
|
84
|
+
if (!options?.force && this.lastRefreshAttemptAt && now - this.lastRefreshAttemptAt < MIN_REFRESH_INTERVAL_MS) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.lastRefreshAttemptAt = now;
|
|
88
|
+
this.refreshPromise = this.refreshInternal(apiKey).catch((error) => {
|
|
89
|
+
logger.warn(
|
|
90
|
+
`Failed to refresh OpenRouter model registry: ${error instanceof Error ? error.message : String(error)}`
|
|
91
|
+
);
|
|
92
|
+
}).finally(() => {
|
|
93
|
+
this.refreshPromise = null;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Blocking refresh of the model cache.
|
|
98
|
+
*/
|
|
99
|
+
async refresh(options) {
|
|
100
|
+
const apiKey = options?.apiKey ?? this.lastUsedApiKey;
|
|
101
|
+
if (apiKey) {
|
|
102
|
+
this.lastUsedApiKey = apiKey;
|
|
103
|
+
}
|
|
104
|
+
if (!options?.force && this.refreshPromise) {
|
|
105
|
+
await this.refreshPromise;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!options?.force) {
|
|
109
|
+
const now = Date.now();
|
|
110
|
+
if (this.lastRefreshAttemptAt && now - this.lastRefreshAttemptAt < MIN_REFRESH_INTERVAL_MS) {
|
|
111
|
+
if (this.refreshPromise) {
|
|
112
|
+
await this.refreshPromise;
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.lastRefreshAttemptAt = now;
|
|
117
|
+
} else {
|
|
118
|
+
this.lastRefreshAttemptAt = Date.now();
|
|
119
|
+
}
|
|
120
|
+
const promise = this.refreshInternal(apiKey).finally(() => {
|
|
121
|
+
this.refreshPromise = null;
|
|
122
|
+
});
|
|
123
|
+
this.refreshPromise = promise;
|
|
124
|
+
await promise;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get all cached model IDs (or null if cache is empty).
|
|
128
|
+
*/
|
|
129
|
+
getCachedModels() {
|
|
130
|
+
if (!this.models || this.models.size === 0) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return Array.from(this.models.keys());
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get all cached model info (or null if cache is empty).
|
|
137
|
+
*/
|
|
138
|
+
getCachedModelsWithInfo() {
|
|
139
|
+
if (!this.models || this.models.size === 0) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return Array.from(this.models.values());
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get cache metadata for debugging/monitoring.
|
|
146
|
+
*/
|
|
147
|
+
getCacheMetadata() {
|
|
148
|
+
return {
|
|
149
|
+
lastFetchedAt: this.lastFetchedAt ? new Date(this.lastFetchedAt) : null,
|
|
150
|
+
modelCount: this.models ? this.models.size : 0,
|
|
151
|
+
isFresh: this.isCacheFresh()
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async refreshInternal(apiKey) {
|
|
155
|
+
try {
|
|
156
|
+
const headers = {
|
|
157
|
+
Accept: "application/json"
|
|
158
|
+
};
|
|
159
|
+
if (apiKey) {
|
|
160
|
+
headers.Authorization = `Bearer ${apiKey}`;
|
|
161
|
+
}
|
|
162
|
+
logger.debug("Refreshing OpenRouter model registry from remote source");
|
|
163
|
+
const response = await fetch(OPENROUTER_MODELS_ENDPOINT, { headers });
|
|
164
|
+
if (!response.ok) {
|
|
165
|
+
const body = await response.text();
|
|
166
|
+
throw new Error(`HTTP ${response.status}: ${body}`);
|
|
167
|
+
}
|
|
168
|
+
const payload = await response.json();
|
|
169
|
+
const models = this.extractModels(payload);
|
|
170
|
+
if (models.length === 0) {
|
|
171
|
+
throw new Error("No model identifiers returned by OpenRouter");
|
|
172
|
+
}
|
|
173
|
+
await this.writeCache(models);
|
|
174
|
+
logger.info(`OpenRouter model registry refreshed with ${models.length} models`);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
throw error instanceof Error ? error : new Error(String(error));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
loadCacheFromDisk() {
|
|
180
|
+
if (!existsSync(this.cachePath)) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const raw = readFileSync(this.cachePath, "utf-8");
|
|
185
|
+
const parsed = JSON.parse(raw);
|
|
186
|
+
if (!Array.isArray(parsed.models) || typeof parsed.fetchedAt !== "string") {
|
|
187
|
+
logger.warn(`Invalid OpenRouter model cache structure at ${this.cachePath}`);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.models = /* @__PURE__ */ new Map();
|
|
191
|
+
for (const model of parsed.models) {
|
|
192
|
+
if (typeof model === "object" && model.id && typeof model.contextLength === "number") {
|
|
193
|
+
this.models.set(model.id.toLowerCase(), model);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const timestamp = Date.parse(parsed.fetchedAt);
|
|
197
|
+
this.lastFetchedAt = Number.isNaN(timestamp) ? null : timestamp;
|
|
198
|
+
logger.debug(
|
|
199
|
+
`Loaded ${this.models.size} OpenRouter models from cache (fetched at ${parsed.fetchedAt})`
|
|
200
|
+
);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
logger.warn(
|
|
203
|
+
`Failed to load OpenRouter model cache: ${error instanceof Error ? error.message : String(error)}`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
normalizeModelId(modelId) {
|
|
208
|
+
if (!modelId) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
return modelId.trim().toLowerCase();
|
|
212
|
+
}
|
|
213
|
+
isCacheFresh() {
|
|
214
|
+
if (!this.lastFetchedAt) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
return Date.now() - this.lastFetchedAt < CACHE_TTL_MS;
|
|
218
|
+
}
|
|
219
|
+
async writeCache(models) {
|
|
220
|
+
const modelMap = /* @__PURE__ */ new Map();
|
|
221
|
+
for (const model of models) {
|
|
222
|
+
if (model.id.trim()) {
|
|
223
|
+
modelMap.set(model.id.toLowerCase(), model);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const uniqueModels = Array.from(modelMap.values()).sort((a, b) => a.id.localeCompare(b.id));
|
|
227
|
+
await fs.mkdir(path.dirname(this.cachePath), { recursive: true });
|
|
228
|
+
const now = /* @__PURE__ */ new Date();
|
|
229
|
+
const cachePayload = {
|
|
230
|
+
fetchedAt: now.toISOString(),
|
|
231
|
+
models: uniqueModels
|
|
232
|
+
};
|
|
233
|
+
await fs.writeFile(this.cachePath, JSON.stringify(cachePayload, null, 2), "utf-8");
|
|
234
|
+
this.models = new Map(uniqueModels.map((m) => [m.id.toLowerCase(), m]));
|
|
235
|
+
this.lastFetchedAt = now.getTime();
|
|
236
|
+
}
|
|
237
|
+
extractModels(payload) {
|
|
238
|
+
if (!payload) {
|
|
239
|
+
return [];
|
|
240
|
+
}
|
|
241
|
+
const raw = payload.data ?? payload.models ?? payload;
|
|
242
|
+
if (!Array.isArray(raw)) {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
const models = [];
|
|
246
|
+
for (const item of raw) {
|
|
247
|
+
if (item && typeof item === "object") {
|
|
248
|
+
const record = item;
|
|
249
|
+
const id = this.firstString([record.id, record.model, record.name]);
|
|
250
|
+
if (id) {
|
|
251
|
+
let contextLength = DEFAULT_CONTEXT_LENGTH;
|
|
252
|
+
if (typeof record.context_length === "number") {
|
|
253
|
+
contextLength = record.context_length;
|
|
254
|
+
} else if (record.top_provider && typeof record.top_provider === "object" && typeof record.top_provider.context_length === "number") {
|
|
255
|
+
contextLength = record.top_provider.context_length;
|
|
256
|
+
}
|
|
257
|
+
models.push({ id, contextLength });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return models;
|
|
262
|
+
}
|
|
263
|
+
firstString(values) {
|
|
264
|
+
for (const value of values) {
|
|
265
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
266
|
+
return value;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const cachePath = getDextoGlobalPath(CACHE_SUBDIR, CACHE_FILENAME);
|
|
273
|
+
const openRouterModelRegistry = new OpenRouterModelRegistry(cachePath);
|
|
274
|
+
function lookupOpenRouterModel(modelId) {
|
|
275
|
+
return openRouterModelRegistry.lookup(modelId);
|
|
276
|
+
}
|
|
277
|
+
function scheduleOpenRouterModelRefresh(options) {
|
|
278
|
+
openRouterModelRegistry.scheduleRefresh(options);
|
|
279
|
+
}
|
|
280
|
+
async function refreshOpenRouterModelCache(options) {
|
|
281
|
+
await openRouterModelRegistry.refresh(options);
|
|
282
|
+
}
|
|
283
|
+
function getCachedOpenRouterModels() {
|
|
284
|
+
return openRouterModelRegistry.getCachedModels();
|
|
285
|
+
}
|
|
286
|
+
function getOpenRouterModelContextLength(modelId) {
|
|
287
|
+
return openRouterModelRegistry.getContextLength(modelId);
|
|
288
|
+
}
|
|
289
|
+
function getOpenRouterModelInfo(modelId) {
|
|
290
|
+
return openRouterModelRegistry.getModelInfo(modelId);
|
|
291
|
+
}
|
|
292
|
+
function getOpenRouterModelCacheInfo() {
|
|
293
|
+
return openRouterModelRegistry.getCacheMetadata();
|
|
294
|
+
}
|
|
295
|
+
const __TEST_ONLY__ = {
|
|
296
|
+
cachePath,
|
|
297
|
+
CACHE_TTL_MS
|
|
298
|
+
};
|
|
299
|
+
export {
|
|
300
|
+
__TEST_ONLY__,
|
|
301
|
+
getCachedOpenRouterModels,
|
|
302
|
+
getOpenRouterModelCacheInfo,
|
|
303
|
+
getOpenRouterModelContextLength,
|
|
304
|
+
getOpenRouterModelInfo,
|
|
305
|
+
lookupOpenRouterModel,
|
|
306
|
+
openRouterModelRegistry,
|
|
307
|
+
refreshOpenRouterModelCache,
|
|
308
|
+
scheduleOpenRouterModelRefresh
|
|
309
|
+
};
|