@dexto/core 1.4.0 → 1.5.1
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 +5959 -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 +6 -3
- package/dist/events/index.d.ts +35 -19
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +5 -3
- 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/provider-options.cjs +87 -0
- package/dist/llm/executor/provider-options.d.ts +49 -0
- package/dist/llm/executor/provider-options.d.ts.map +1 -0
- package/dist/llm/executor/provider-options.js +63 -0
- package/dist/llm/executor/stream-processor.cjs +22 -11
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +22 -11
- package/dist/llm/executor/turn-executor.cjs +60 -23
- package/dist/llm/executor/turn-executor.d.ts +7 -5
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +60 -23
- package/dist/llm/formatters/vercel.cjs +15 -3
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +15 -3
- 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 +604 -9
- package/dist/llm/registry.d.ts +35 -0
- package/dist/llm/registry.d.ts.map +1 -1
- package/dist/llm/registry.js +600 -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 +107 -81
- package/dist/llm/schemas.d.ts +181 -22
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +107 -81
- 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 +8 -3
- 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 +8 -3
- 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/logger/logger.cjs +7 -3
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +7 -3
- 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 +3 -3
- 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 +109 -0
- package/dist/providers/discovery.d.ts +96 -0
- package/dist/providers/discovery.d.ts.map +1 -0
- package/dist/providers/discovery.js +84 -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/session/history/database.cjs +49 -15
- package/dist/session/history/database.d.ts.map +1 -1
- package/dist/session/history/database.js +49 -15
- package/dist/session/session-manager.cjs +2 -1
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +2 -1
- 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/postgres-store.cjs +174 -78
- package/dist/storage/database/postgres-store.d.ts +19 -0
- package/dist/storage/database/postgres-store.d.ts.map +1 -1
- package/dist/storage/database/postgres-store.js +174 -78
- 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 +12 -3
- package/dist/storage/database/schemas.d.ts +11 -4
- package/dist/storage/database/schemas.d.ts.map +1 -1
- package/dist/storage/database/schemas.js +8 -2
- 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 +24 -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 +126 -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 +153 -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 +153 -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
|
@@ -11,17 +11,19 @@ import {
|
|
|
11
11
|
} from "ai";
|
|
12
12
|
import { trace } from "@opentelemetry/api";
|
|
13
13
|
import { StreamProcessor } from "./stream-processor.js";
|
|
14
|
+
import { buildProviderOptions } from "./provider-options.js";
|
|
14
15
|
import { DextoLogComponent } from "../../logger/v2/types.js";
|
|
15
16
|
import { defer } from "../../utils/defer.js";
|
|
16
17
|
import { DextoRuntimeError } from "../../errors/DextoRuntimeError.js";
|
|
17
18
|
import { ErrorScope, ErrorType } from "../../errors/types.js";
|
|
18
19
|
import { LLMErrorCode } from "../error-codes.js";
|
|
19
20
|
import { toError } from "../../utils/error-conversion.js";
|
|
20
|
-
import { isOverflow } from "../../context/
|
|
21
|
-
import { ReactiveOverflowStrategy } from "../../context/
|
|
21
|
+
import { isOverflow } from "../../context/compaction/overflow.js";
|
|
22
|
+
import { ReactiveOverflowStrategy } from "../../context/compaction/strategies/reactive-overflow.js";
|
|
22
23
|
const toolSupportCache = /* @__PURE__ */ new Map();
|
|
24
|
+
const LOCAL_PROVIDERS = ["ollama", "local"];
|
|
23
25
|
class TurnExecutor {
|
|
24
|
-
constructor(model, toolManager, contextManager, eventBus, resourceManager, sessionId, config, llmContext, logger, messageQueue, modelLimits, externalSignal) {
|
|
26
|
+
constructor(model, toolManager, contextManager, eventBus, resourceManager, sessionId, config, llmContext, logger, messageQueue, modelLimits, externalSignal, compactionStrategy) {
|
|
25
27
|
this.model = model;
|
|
26
28
|
this.toolManager = toolManager;
|
|
27
29
|
this.contextManager = contextManager;
|
|
@@ -35,8 +37,10 @@ class TurnExecutor {
|
|
|
35
37
|
this.externalSignal = externalSignal;
|
|
36
38
|
this.logger = logger.createChild(DextoLogComponent.EXECUTOR);
|
|
37
39
|
this.stepAbortController = new AbortController();
|
|
38
|
-
if (
|
|
39
|
-
this.
|
|
40
|
+
if (compactionStrategy !== void 0) {
|
|
41
|
+
this.compactionStrategy = compactionStrategy;
|
|
42
|
+
} else if (modelLimits) {
|
|
43
|
+
this.compactionStrategy = new ReactiveOverflowStrategy(model, {}, this.logger);
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
logger;
|
|
@@ -45,8 +49,7 @@ class TurnExecutor {
|
|
|
45
49
|
* This allows soft cancel (abort current step) while still continuing with queued messages.
|
|
46
50
|
*/
|
|
47
51
|
stepAbortController;
|
|
48
|
-
|
|
49
|
-
compressionStrategy = null;
|
|
52
|
+
compactionStrategy = null;
|
|
50
53
|
/**
|
|
51
54
|
* Map to track approval metadata by toolCallId.
|
|
52
55
|
* Used to pass approval info from tool execution to result persistence.
|
|
@@ -79,6 +82,24 @@ class TurnExecutor {
|
|
|
79
82
|
let lastText = "";
|
|
80
83
|
this.eventBus.emit("llm:thinking");
|
|
81
84
|
const supportsTools = await this.validateToolSupport();
|
|
85
|
+
if (!supportsTools) {
|
|
86
|
+
const modelKey = `${this.llmContext.provider}:${this.llmContext.model}`;
|
|
87
|
+
this.eventBus.emit("llm:unsupported-input", {
|
|
88
|
+
errors: [
|
|
89
|
+
`Model '${modelKey}' does not support tool calling.`,
|
|
90
|
+
"You can still chat, but the model will not be able to use tools or execute commands."
|
|
91
|
+
],
|
|
92
|
+
provider: this.llmContext.provider,
|
|
93
|
+
model: this.llmContext.model,
|
|
94
|
+
details: {
|
|
95
|
+
feature: "tool-calling",
|
|
96
|
+
supported: false
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
this.logger.warn(
|
|
100
|
+
`Model ${modelKey} does not support tools - continuing without tool calling`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
82
103
|
let currentAbortHandler = null;
|
|
83
104
|
try {
|
|
84
105
|
while (true) {
|
|
@@ -115,6 +136,11 @@ class TurnExecutor {
|
|
|
115
136
|
streaming,
|
|
116
137
|
this.approvalMetadata
|
|
117
138
|
);
|
|
139
|
+
const providerOptions = buildProviderOptions({
|
|
140
|
+
provider: this.llmContext.provider,
|
|
141
|
+
model: this.llmContext.model,
|
|
142
|
+
reasoningEffort: this.config.reasoningEffort
|
|
143
|
+
});
|
|
118
144
|
const result = await streamProcessor.process(
|
|
119
145
|
() => streamText({
|
|
120
146
|
model: this.model,
|
|
@@ -128,6 +154,10 @@ class TurnExecutor {
|
|
|
128
154
|
...this.config.temperature !== void 0 && {
|
|
129
155
|
temperature: this.config.temperature
|
|
130
156
|
},
|
|
157
|
+
// Provider-specific options (caching, reasoning, etc.)
|
|
158
|
+
...providerOptions !== void 0 && {
|
|
159
|
+
providerOptions
|
|
160
|
+
},
|
|
131
161
|
// Log stream-level errors (tool errors, API errors during streaming)
|
|
132
162
|
onError: (error) => {
|
|
133
163
|
this.logger.error("Stream error", { error });
|
|
@@ -231,20 +261,25 @@ class TurnExecutor {
|
|
|
231
261
|
* Validates if the current model supports tools.
|
|
232
262
|
* Uses a static cache to avoid repeated validation calls.
|
|
233
263
|
*
|
|
234
|
-
* For
|
|
235
|
-
*
|
|
264
|
+
* For local providers (Ollama, local) and custom baseURL endpoints, makes a test call to verify tool support.
|
|
265
|
+
* Known cloud providers without baseURL are assumed to support tools.
|
|
236
266
|
*/
|
|
237
267
|
async validateToolSupport() {
|
|
238
268
|
const modelKey = `${this.llmContext.provider}:${this.llmContext.model}:${this.config.baseURL ?? ""}`;
|
|
239
269
|
if (toolSupportCache.has(modelKey)) {
|
|
240
270
|
return toolSupportCache.get(modelKey);
|
|
241
271
|
}
|
|
242
|
-
|
|
243
|
-
|
|
272
|
+
const isLocalProvider = LOCAL_PROVIDERS.includes(this.llmContext.provider);
|
|
273
|
+
if (!this.config.baseURL && !isLocalProvider) {
|
|
274
|
+
this.logger.debug(
|
|
275
|
+
`Skipping tool validation for ${modelKey} - known cloud provider without custom baseURL`
|
|
276
|
+
);
|
|
244
277
|
toolSupportCache.set(modelKey, true);
|
|
245
278
|
return true;
|
|
246
279
|
}
|
|
247
|
-
this.logger.debug(
|
|
280
|
+
this.logger.debug(
|
|
281
|
+
`Testing tool support for ${isLocalProvider ? "local provider" : "custom endpoint"} model: ${modelKey}`
|
|
282
|
+
);
|
|
248
283
|
const testTool = {
|
|
249
284
|
test_tool: {
|
|
250
285
|
inputSchema: jsonSchema({
|
|
@@ -274,7 +309,9 @@ class TurnExecutor {
|
|
|
274
309
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
275
310
|
if (errorMessage.includes("does not support tools")) {
|
|
276
311
|
toolSupportCache.set(modelKey, false);
|
|
277
|
-
this.logger.debug(
|
|
312
|
+
this.logger.debug(
|
|
313
|
+
`Detected that model ${modelKey} does not support tool calling - tool functionality will be disabled`
|
|
314
|
+
);
|
|
278
315
|
return false;
|
|
279
316
|
}
|
|
280
317
|
this.logger.debug(
|
|
@@ -555,7 +592,7 @@ class TurnExecutor {
|
|
|
555
592
|
* Check if context has overflowed based on actual token usage from API.
|
|
556
593
|
*/
|
|
557
594
|
checkAndHandleOverflow(tokens) {
|
|
558
|
-
if (!this.modelLimits || !this.
|
|
595
|
+
if (!this.modelLimits || !this.compactionStrategy) {
|
|
559
596
|
return false;
|
|
560
597
|
}
|
|
561
598
|
return isOverflow(tokens, this.modelLimits);
|
|
@@ -570,16 +607,16 @@ class TurnExecutor {
|
|
|
570
607
|
* @param originalTokens The actual input token count from API that triggered overflow
|
|
571
608
|
*/
|
|
572
609
|
async compress(originalTokens) {
|
|
573
|
-
if (!this.
|
|
610
|
+
if (!this.compactionStrategy) {
|
|
574
611
|
return;
|
|
575
612
|
}
|
|
576
613
|
this.logger.info(
|
|
577
614
|
`Context overflow detected (${originalTokens} tokens), running compression`
|
|
578
615
|
);
|
|
579
616
|
const history = await this.contextManager.getHistory();
|
|
580
|
-
const summaryMessages = await this.
|
|
617
|
+
const summaryMessages = await this.compactionStrategy.compact(history);
|
|
581
618
|
if (summaryMessages.length === 0) {
|
|
582
|
-
this.logger.debug("
|
|
619
|
+
this.logger.debug("Compaction returned no summary (history too short)");
|
|
583
620
|
return;
|
|
584
621
|
}
|
|
585
622
|
for (const summary of summaryMessages) {
|
|
@@ -588,17 +625,17 @@ class TurnExecutor {
|
|
|
588
625
|
const { filterCompacted, estimateMessagesTokens } = await import("../../context/utils.js");
|
|
589
626
|
const updatedHistory = await this.contextManager.getHistory();
|
|
590
627
|
const filteredHistory = filterCompacted(updatedHistory);
|
|
591
|
-
const
|
|
592
|
-
this.eventBus.emit("context:
|
|
628
|
+
const compactedTokens = estimateMessagesTokens(filteredHistory);
|
|
629
|
+
this.eventBus.emit("context:compacted", {
|
|
593
630
|
originalTokens,
|
|
594
|
-
|
|
631
|
+
compactedTokens,
|
|
595
632
|
originalMessages: history.length,
|
|
596
|
-
|
|
597
|
-
strategy: this.
|
|
633
|
+
compactedMessages: filteredHistory.length,
|
|
634
|
+
strategy: this.compactionStrategy.name,
|
|
598
635
|
reason: "overflow"
|
|
599
636
|
});
|
|
600
637
|
this.logger.info(
|
|
601
|
-
`
|
|
638
|
+
`Compaction complete: ${originalTokens} \u2192 ~${compactedTokens} tokens (${history.length} \u2192 ${filteredHistory.length} messages after filtering)`
|
|
602
639
|
);
|
|
603
640
|
}
|
|
604
641
|
/**
|
|
@@ -59,9 +59,17 @@ class VercelMessageFormatter {
|
|
|
59
59
|
filteredHistory = [...history];
|
|
60
60
|
}
|
|
61
61
|
if (systemPrompt) {
|
|
62
|
+
const modelLower = context.model.toLowerCase();
|
|
63
|
+
const isClaudeModel = modelLower.includes("claude");
|
|
64
|
+
const isAnthropicProvider = context.provider === "anthropic" || context.provider === "bedrock" && isClaudeModel || context.provider === "vertex" && isClaudeModel;
|
|
62
65
|
formatted.push({
|
|
63
66
|
role: "system",
|
|
64
|
-
content: systemPrompt
|
|
67
|
+
content: systemPrompt,
|
|
68
|
+
...isAnthropicProvider && {
|
|
69
|
+
providerOptions: {
|
|
70
|
+
anthropic: { cacheControl: { type: "ephemeral" } }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
65
73
|
});
|
|
66
74
|
}
|
|
67
75
|
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
@@ -183,12 +191,16 @@ class VercelMessageFormatter {
|
|
|
183
191
|
} else {
|
|
184
192
|
parsed = rawArgs ?? {};
|
|
185
193
|
}
|
|
186
|
-
|
|
194
|
+
const toolCallPart = {
|
|
187
195
|
type: "tool-call",
|
|
188
196
|
toolCallId: toolCall.id,
|
|
189
197
|
toolName: toolCall.function.name,
|
|
190
198
|
input: parsed
|
|
191
|
-
}
|
|
199
|
+
};
|
|
200
|
+
if (toolCall.providerOptions) {
|
|
201
|
+
toolCallPart.providerOptions = toolCall.providerOptions;
|
|
202
|
+
}
|
|
203
|
+
contentParts.push(toolCallPart);
|
|
192
204
|
}
|
|
193
205
|
const firstToolCall = msg.toolCalls?.[0];
|
|
194
206
|
if (firstToolCall) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/llm/formatters/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAiD,MAAM,IAAI,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAiC,MAAM,wBAAwB,CAAC;AAE7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAmB7D;;;;;;;;;;GAUG;AACH,qBAAa,sBAAsB;IAC/B,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,YAAY;IAGhC;;;;;;OAMG;IACH,MAAM,CACF,OAAO,EAAE,QAAQ,CAAC,eAAe,EAAE,CAAC,EACpC,OAAO,EAAE,UAAU,EACnB,YAAY,EAAE,MAAM,GAAG,IAAI,GAC5B,YAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/llm/formatters/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAiD,MAAM,IAAI,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAiC,MAAM,wBAAwB,CAAC;AAE7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAmB7D;;;;;;;;;;GAUG;AACH,qBAAa,sBAAsB;IAC/B,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,YAAY;IAGhC;;;;;;OAMG;IACH,MAAM,CACF,OAAO,EAAE,QAAQ,CAAC,eAAe,EAAE,CAAC,EACpC,OAAO,EAAE,UAAU,EACnB,YAAY,EAAE,MAAM,GAAG,IAAI,GAC5B,YAAY,EAAE;IAsJjB;;;;;;OAMG;IACH,kBAAkB,IAAI,IAAI;IAK1B,OAAO,CAAC,sBAAsB;IA8E9B,OAAO,CAAC,iBAAiB;CAoE5B"}
|
|
@@ -37,9 +37,17 @@ class VercelMessageFormatter {
|
|
|
37
37
|
filteredHistory = [...history];
|
|
38
38
|
}
|
|
39
39
|
if (systemPrompt) {
|
|
40
|
+
const modelLower = context.model.toLowerCase();
|
|
41
|
+
const isClaudeModel = modelLower.includes("claude");
|
|
42
|
+
const isAnthropicProvider = context.provider === "anthropic" || context.provider === "bedrock" && isClaudeModel || context.provider === "vertex" && isClaudeModel;
|
|
40
43
|
formatted.push({
|
|
41
44
|
role: "system",
|
|
42
|
-
content: systemPrompt
|
|
45
|
+
content: systemPrompt,
|
|
46
|
+
...isAnthropicProvider && {
|
|
47
|
+
providerOptions: {
|
|
48
|
+
anthropic: { cacheControl: { type: "ephemeral" } }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
43
51
|
});
|
|
44
52
|
}
|
|
45
53
|
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
@@ -161,12 +169,16 @@ class VercelMessageFormatter {
|
|
|
161
169
|
} else {
|
|
162
170
|
parsed = rawArgs ?? {};
|
|
163
171
|
}
|
|
164
|
-
|
|
172
|
+
const toolCallPart = {
|
|
165
173
|
type: "tool-call",
|
|
166
174
|
toolCallId: toolCall.id,
|
|
167
175
|
toolName: toolCall.function.name,
|
|
168
176
|
input: parsed
|
|
169
|
-
}
|
|
177
|
+
};
|
|
178
|
+
if (toolCall.providerOptions) {
|
|
179
|
+
toolCallPart.providerOptions = toolCall.providerOptions;
|
|
180
|
+
}
|
|
181
|
+
contentParts.push(toolCallPart);
|
|
170
182
|
}
|
|
171
183
|
const firstToolCall = msg.toolCalls?.[0];
|
|
172
184
|
if (firstToolCall) {
|
package/dist/llm/index.cjs
CHANGED
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -14,6 +18,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
18
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
20
|
var llm_exports = {};
|
|
21
|
+
__export(llm_exports, {
|
|
22
|
+
getOpenRouterModelContextLength: () => import_openrouter_model_registry.getOpenRouterModelContextLength,
|
|
23
|
+
getOpenRouterModelInfo: () => import_openrouter_model_registry.getOpenRouterModelInfo,
|
|
24
|
+
lookupOpenRouterModel: () => import_openrouter_model_registry.lookupOpenRouterModel,
|
|
25
|
+
refreshOpenRouterModelCache: () => import_openrouter_model_registry.refreshOpenRouterModelCache
|
|
26
|
+
});
|
|
17
27
|
module.exports = __toCommonJS(llm_exports);
|
|
18
28
|
__reExport(llm_exports, require("./errors.js"), module.exports);
|
|
19
29
|
__reExport(llm_exports, require("./error-codes.js"), module.exports);
|
|
@@ -22,13 +32,20 @@ __reExport(llm_exports, require("./validation.js"), module.exports);
|
|
|
22
32
|
__reExport(llm_exports, require("./types.js"), module.exports);
|
|
23
33
|
__reExport(llm_exports, require("./services/index.js"), module.exports);
|
|
24
34
|
__reExport(llm_exports, require("./schemas.js"), module.exports);
|
|
35
|
+
var import_openrouter_model_registry = require("./providers/openrouter-model-registry.js");
|
|
36
|
+
__reExport(llm_exports, require("./providers/local/index.js"), module.exports);
|
|
25
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
38
|
0 && (module.exports = {
|
|
39
|
+
getOpenRouterModelContextLength,
|
|
40
|
+
getOpenRouterModelInfo,
|
|
41
|
+
lookupOpenRouterModel,
|
|
42
|
+
refreshOpenRouterModelCache,
|
|
27
43
|
...require("./errors.js"),
|
|
28
44
|
...require("./error-codes.js"),
|
|
29
45
|
...require("./registry.js"),
|
|
30
46
|
...require("./validation.js"),
|
|
31
47
|
...require("./types.js"),
|
|
32
48
|
...require("./services/index.js"),
|
|
33
|
-
...require("./schemas.js")
|
|
49
|
+
...require("./schemas.js"),
|
|
50
|
+
...require("./providers/local/index.js")
|
|
34
51
|
});
|
package/dist/llm/index.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export * from './validation.js';
|
|
|
5
5
|
export * from './types.js';
|
|
6
6
|
export * from './services/index.js';
|
|
7
7
|
export * from './schemas.js';
|
|
8
|
+
export { lookupOpenRouterModel, refreshOpenRouterModelCache, getOpenRouterModelContextLength, getOpenRouterModelInfo, type LookupStatus, type OpenRouterModelInfo, } from './providers/openrouter-model-registry.js';
|
|
9
|
+
export * from './providers/local/index.js';
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/llm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,OAAO,EACH,qBAAqB,EACrB,2BAA2B,EAC3B,+BAA+B,EAC/B,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GAC3B,MAAM,0CAA0C,CAAC;AAGlD,cAAc,4BAA4B,CAAC"}
|
package/dist/llm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../chunk-PTJYTZNU.js";
|
|
1
2
|
export * from "./errors.js";
|
|
2
3
|
export * from "./error-codes.js";
|
|
3
4
|
export * from "./registry.js";
|
|
@@ -5,3 +6,16 @@ export * from "./validation.js";
|
|
|
5
6
|
export * from "./types.js";
|
|
6
7
|
export * from "./services/index.js";
|
|
7
8
|
export * from "./schemas.js";
|
|
9
|
+
import {
|
|
10
|
+
lookupOpenRouterModel,
|
|
11
|
+
refreshOpenRouterModelCache,
|
|
12
|
+
getOpenRouterModelContextLength,
|
|
13
|
+
getOpenRouterModelInfo
|
|
14
|
+
} from "./providers/openrouter-model-registry.js";
|
|
15
|
+
export * from "./providers/local/index.js";
|
|
16
|
+
export {
|
|
17
|
+
getOpenRouterModelContextLength,
|
|
18
|
+
getOpenRouterModelInfo,
|
|
19
|
+
lookupOpenRouterModel,
|
|
20
|
+
refreshOpenRouterModelCache
|
|
21
|
+
};
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var ai_sdk_adapter_exports = {};
|
|
30
|
+
__export(ai_sdk_adapter_exports, {
|
|
31
|
+
createLocalLanguageModel: () => createLocalLanguageModel
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(ai_sdk_adapter_exports);
|
|
34
|
+
var import_node_llama_provider = require("./node-llama-provider.js");
|
|
35
|
+
var import_errors = require("./errors.js");
|
|
36
|
+
var import_registry = require("./registry.js");
|
|
37
|
+
var fs = __toESM(require("fs"), 1);
|
|
38
|
+
var path = __toESM(require("path"), 1);
|
|
39
|
+
var os = __toESM(require("os"), 1);
|
|
40
|
+
function getModelsDirectory() {
|
|
41
|
+
return path.join(os.homedir(), ".dexto", "models");
|
|
42
|
+
}
|
|
43
|
+
function getInstalledModelInfo(modelId) {
|
|
44
|
+
const stateFile = path.join(getModelsDirectory(), "state.json");
|
|
45
|
+
try {
|
|
46
|
+
if (!fs.existsSync(stateFile)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const content = fs.readFileSync(stateFile, "utf-8");
|
|
50
|
+
const state = JSON.parse(content);
|
|
51
|
+
return state.installed[modelId] ?? null;
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function getCustomModelFilePath(modelId) {
|
|
57
|
+
const customModelsFile = path.join(getModelsDirectory(), "custom-models.json");
|
|
58
|
+
try {
|
|
59
|
+
if (!fs.existsSync(customModelsFile)) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const content = fs.readFileSync(customModelsFile, "utf-8");
|
|
63
|
+
const storage = JSON.parse(content);
|
|
64
|
+
const customModel = storage.models.find(
|
|
65
|
+
(m) => m.name === modelId && m.provider === "local" && m.filePath
|
|
66
|
+
);
|
|
67
|
+
return customModel?.filePath ?? null;
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function createLocalLanguageModel(config) {
|
|
73
|
+
return new LocalLanguageModel(config);
|
|
74
|
+
}
|
|
75
|
+
class LocalLanguageModel {
|
|
76
|
+
specificationVersion = "v2";
|
|
77
|
+
provider = "local";
|
|
78
|
+
modelId;
|
|
79
|
+
// Local models don't support URL-based content natively
|
|
80
|
+
supportedUrls = {};
|
|
81
|
+
config;
|
|
82
|
+
session = null;
|
|
83
|
+
loadedModel = null;
|
|
84
|
+
initPromise = null;
|
|
85
|
+
deviceName = "Local";
|
|
86
|
+
constructor(config) {
|
|
87
|
+
this.modelId = config.modelId;
|
|
88
|
+
this.config = config;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Initialize the model lazily on first use.
|
|
92
|
+
*/
|
|
93
|
+
async ensureInitialized() {
|
|
94
|
+
if (this.session) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (this.initPromise) {
|
|
98
|
+
return this.initPromise;
|
|
99
|
+
}
|
|
100
|
+
this.initPromise = this.initialize();
|
|
101
|
+
return this.initPromise;
|
|
102
|
+
}
|
|
103
|
+
async initialize() {
|
|
104
|
+
const {
|
|
105
|
+
modelId,
|
|
106
|
+
modelPath: directPath,
|
|
107
|
+
contextSize,
|
|
108
|
+
// Let node-llama-cpp default to "auto" if not specified
|
|
109
|
+
gpuLayers = -1,
|
|
110
|
+
threads
|
|
111
|
+
} = this.config;
|
|
112
|
+
const isInstalled = await (0, import_node_llama_provider.isNodeLlamaCppInstalled)();
|
|
113
|
+
if (!isInstalled) {
|
|
114
|
+
throw import_errors.LocalModelError.nodeLlamaNotInstalled();
|
|
115
|
+
}
|
|
116
|
+
let modelPath;
|
|
117
|
+
if (directPath) {
|
|
118
|
+
modelPath = directPath;
|
|
119
|
+
} else {
|
|
120
|
+
const installedModel = getInstalledModelInfo(modelId);
|
|
121
|
+
if (installedModel) {
|
|
122
|
+
modelPath = installedModel.filePath;
|
|
123
|
+
} else {
|
|
124
|
+
const customPath = getCustomModelFilePath(modelId);
|
|
125
|
+
if (customPath) {
|
|
126
|
+
modelPath = customPath;
|
|
127
|
+
} else {
|
|
128
|
+
const registryModel = (0, import_registry.getLocalModelById)(modelId);
|
|
129
|
+
if (!registryModel) {
|
|
130
|
+
throw import_errors.LocalModelError.modelNotFound(modelId);
|
|
131
|
+
}
|
|
132
|
+
throw import_errors.LocalModelError.modelNotDownloaded(modelId);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const loadConfig = {
|
|
137
|
+
modelPath,
|
|
138
|
+
gpuLayers
|
|
139
|
+
};
|
|
140
|
+
if (contextSize !== void 0) {
|
|
141
|
+
loadConfig.contextSize = contextSize;
|
|
142
|
+
}
|
|
143
|
+
if (threads !== void 0) {
|
|
144
|
+
loadConfig.threads = threads;
|
|
145
|
+
}
|
|
146
|
+
this.loadedModel = await (0, import_node_llama_provider.loadModel)(loadConfig);
|
|
147
|
+
this.deviceName = this.loadedModel.gpuInfo.deviceName || "Local";
|
|
148
|
+
this.session = await this.loadedModel.createSession();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Non-streaming text generation (V2 interface).
|
|
152
|
+
*/
|
|
153
|
+
async doGenerate(options) {
|
|
154
|
+
await this.ensureInitialized();
|
|
155
|
+
const prompt = this.formatPrompt(options);
|
|
156
|
+
const maxTokens = options.maxOutputTokens ?? 1024;
|
|
157
|
+
const temperature = options.temperature ?? 0.7;
|
|
158
|
+
const promptOptions = {
|
|
159
|
+
maxTokens,
|
|
160
|
+
temperature
|
|
161
|
+
};
|
|
162
|
+
if (options.abortSignal) {
|
|
163
|
+
promptOptions.signal = options.abortSignal;
|
|
164
|
+
}
|
|
165
|
+
const response = await this.session.prompt(prompt, promptOptions);
|
|
166
|
+
const inputTokens = Math.ceil(prompt.length / 4);
|
|
167
|
+
const outputTokens = Math.ceil(response.length / 4);
|
|
168
|
+
const content = [{ type: "text", text: response }];
|
|
169
|
+
const finishReason = "stop";
|
|
170
|
+
const usage = {
|
|
171
|
+
inputTokens,
|
|
172
|
+
outputTokens,
|
|
173
|
+
totalTokens: inputTokens + outputTokens
|
|
174
|
+
};
|
|
175
|
+
const warnings = [];
|
|
176
|
+
return {
|
|
177
|
+
content,
|
|
178
|
+
finishReason,
|
|
179
|
+
usage,
|
|
180
|
+
providerMetadata: {
|
|
181
|
+
local: {
|
|
182
|
+
device: this.deviceName
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
warnings
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Streaming text generation (V2 interface).
|
|
190
|
+
*/
|
|
191
|
+
async doStream(options) {
|
|
192
|
+
await this.ensureInitialized();
|
|
193
|
+
const prompt = this.formatPrompt(options);
|
|
194
|
+
const maxTokens = options.maxOutputTokens ?? 1024;
|
|
195
|
+
const temperature = options.temperature ?? 0.7;
|
|
196
|
+
const inputTokens = Math.ceil(prompt.length / 4);
|
|
197
|
+
let outputTokens = 0;
|
|
198
|
+
const session = this.session;
|
|
199
|
+
const textId = "text-0";
|
|
200
|
+
const streamPromptOptions = {
|
|
201
|
+
maxTokens,
|
|
202
|
+
temperature,
|
|
203
|
+
onToken: (_token) => {
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
if (options.abortSignal) {
|
|
207
|
+
streamPromptOptions.signal = options.abortSignal;
|
|
208
|
+
}
|
|
209
|
+
let controller;
|
|
210
|
+
const stream = new ReadableStream({
|
|
211
|
+
async start(ctrl) {
|
|
212
|
+
controller = ctrl;
|
|
213
|
+
controller.enqueue({
|
|
214
|
+
type: "stream-start",
|
|
215
|
+
warnings: []
|
|
216
|
+
});
|
|
217
|
+
controller.enqueue({
|
|
218
|
+
type: "text-start",
|
|
219
|
+
id: textId
|
|
220
|
+
});
|
|
221
|
+
try {
|
|
222
|
+
streamPromptOptions.onToken = (token) => {
|
|
223
|
+
outputTokens += 1;
|
|
224
|
+
controller.enqueue({
|
|
225
|
+
type: "text-delta",
|
|
226
|
+
id: textId,
|
|
227
|
+
delta: token
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
await session.prompt(prompt, streamPromptOptions);
|
|
231
|
+
controller.enqueue({
|
|
232
|
+
type: "text-end",
|
|
233
|
+
id: textId
|
|
234
|
+
});
|
|
235
|
+
controller.enqueue({
|
|
236
|
+
type: "finish",
|
|
237
|
+
finishReason: "stop",
|
|
238
|
+
usage: {
|
|
239
|
+
inputTokens,
|
|
240
|
+
outputTokens,
|
|
241
|
+
totalTokens: inputTokens + outputTokens
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
controller.close();
|
|
245
|
+
} catch (error) {
|
|
246
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
247
|
+
controller.enqueue({
|
|
248
|
+
type: "text-end",
|
|
249
|
+
id: textId
|
|
250
|
+
});
|
|
251
|
+
controller.enqueue({
|
|
252
|
+
type: "finish",
|
|
253
|
+
finishReason: "stop",
|
|
254
|
+
usage: {
|
|
255
|
+
inputTokens,
|
|
256
|
+
outputTokens,
|
|
257
|
+
totalTokens: inputTokens + outputTokens
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
controller.close();
|
|
261
|
+
} else {
|
|
262
|
+
controller.enqueue({
|
|
263
|
+
type: "error",
|
|
264
|
+
error
|
|
265
|
+
});
|
|
266
|
+
controller.close();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
return {
|
|
272
|
+
stream
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Format the prompt from AI SDK message format.
|
|
277
|
+
*/
|
|
278
|
+
formatPrompt(options) {
|
|
279
|
+
const parts = [];
|
|
280
|
+
if (options.prompt && Array.isArray(options.prompt)) {
|
|
281
|
+
for (const message of options.prompt) {
|
|
282
|
+
if (message.role === "system") {
|
|
283
|
+
parts.push(`System: ${message.content}`);
|
|
284
|
+
} else if (message.role === "user") {
|
|
285
|
+
if (Array.isArray(message.content)) {
|
|
286
|
+
const textParts = message.content.filter((p) => p.type === "text").map((p) => p.text);
|
|
287
|
+
if (textParts.length > 0) {
|
|
288
|
+
parts.push(`User: ${textParts.join("\n")}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
} else if (message.role === "assistant") {
|
|
292
|
+
if (Array.isArray(message.content)) {
|
|
293
|
+
const textParts = message.content.filter((p) => p.type === "text").map((p) => p.text);
|
|
294
|
+
if (textParts.length > 0) {
|
|
295
|
+
parts.push(`Assistant: ${textParts.join("\n")}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
parts.push("Assistant:");
|
|
302
|
+
return parts.join("\n\n");
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
306
|
+
0 && (module.exports = {
|
|
307
|
+
createLocalLanguageModel
|
|
308
|
+
});
|