@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/llm/providers/local/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAMzE;;GAEG;AACH,eAAO,MAAM,eAAe;6BAEC,iBAAiB;kCAWZ,MAAM,GAAG,iBAAiB;qBAWvC,iBAAiB;4BAYV,MAAM,SAAS,MAAM,GAAG,iBAAiB;iCAWpC,MAAM,GAAG,iBAAiB;0BAWjC,MAAM,YAAY,MAAM,UAAU,MAAM,GAAG,iBAAiB;mCAWnD,MAAM,YAAY,MAAM,aAAa,MAAM,GAAG,iBAAiB;4BAatE,MAAM,GAAG,iBAAiB;2BAY3B,MAAM,GAAG,iBAAiB;gCAWrB,MAAM,GAAG,iBAAiB;6BAW7B,MAAM,SAAS,MAAM,GAAG,iBAAiB;0BAW5C,MAAM,YAAY,MAAM,GAAG,iBAAiB;6BAWzC,MAAM,aAAa,MAAM,gBAAgB,MAAM,GAAG,iBAAiB;uBAYzE,iBAAiB;8BAWV,MAAM,YAAY,MAAM,aAAa,MAAM,GAAG,iBAAiB;0BAWnE,MAAM,GAAG,iBAAiB;0BAY1B,MAAM,GAAG,iBAAiB;mCAWjB,MAAM,GAAG,iBAAiB;gCAW7B,MAAM,SAAS,MAAM,GAAG,iBAAiB;0BAW/C,MAAM,GAAG,iBAAiB;CAUnD,CAAC"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import "../../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { DextoRuntimeError } from "../../../errors/DextoRuntimeError.js";
|
|
3
|
+
import { ErrorType } from "../../../errors/types.js";
|
|
4
|
+
import { LocalModelErrorCode } from "./error-codes.js";
|
|
5
|
+
const SCOPE = "local-models";
|
|
6
|
+
const LocalModelError = {
|
|
7
|
+
// Installation errors
|
|
8
|
+
nodeLlamaNotInstalled() {
|
|
9
|
+
return new DextoRuntimeError(
|
|
10
|
+
LocalModelErrorCode.NODE_LLAMA_NOT_INSTALLED,
|
|
11
|
+
SCOPE,
|
|
12
|
+
ErrorType.NOT_FOUND,
|
|
13
|
+
'node-llama-cpp is not installed. Run `dexto setup` and select "local" provider to install it.',
|
|
14
|
+
{},
|
|
15
|
+
'Run `dexto setup` and select "local" provider to install local model support'
|
|
16
|
+
);
|
|
17
|
+
},
|
|
18
|
+
nodeLlamaInstallFailed(error) {
|
|
19
|
+
return new DextoRuntimeError(
|
|
20
|
+
LocalModelErrorCode.NODE_LLAMA_INSTALL_FAILED,
|
|
21
|
+
SCOPE,
|
|
22
|
+
ErrorType.THIRD_PARTY,
|
|
23
|
+
`Failed to install node-llama-cpp: ${error}`,
|
|
24
|
+
{ error },
|
|
25
|
+
"Check your Node.js version and try again. CMake may be required for your platform."
|
|
26
|
+
);
|
|
27
|
+
},
|
|
28
|
+
cmakeNotFound() {
|
|
29
|
+
return new DextoRuntimeError(
|
|
30
|
+
LocalModelErrorCode.CMAKE_NOT_FOUND,
|
|
31
|
+
SCOPE,
|
|
32
|
+
ErrorType.NOT_FOUND,
|
|
33
|
+
"CMake is required to build node-llama-cpp from source but was not found.",
|
|
34
|
+
{},
|
|
35
|
+
"Install CMake: brew install cmake (macOS), apt install cmake (Linux), or download from cmake.org (Windows)"
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
// Download errors
|
|
39
|
+
downloadFailed(modelId, error) {
|
|
40
|
+
return new DextoRuntimeError(
|
|
41
|
+
LocalModelErrorCode.DOWNLOAD_FAILED,
|
|
42
|
+
SCOPE,
|
|
43
|
+
ErrorType.THIRD_PARTY,
|
|
44
|
+
`Failed to download model '${modelId}': ${error}`,
|
|
45
|
+
{ modelId, error },
|
|
46
|
+
"Check your internet connection and try again"
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
downloadInterrupted(modelId) {
|
|
50
|
+
return new DextoRuntimeError(
|
|
51
|
+
LocalModelErrorCode.DOWNLOAD_INTERRUPTED,
|
|
52
|
+
SCOPE,
|
|
53
|
+
ErrorType.THIRD_PARTY,
|
|
54
|
+
`Download of model '${modelId}' was interrupted`,
|
|
55
|
+
{ modelId },
|
|
56
|
+
"Run the download command again to resume"
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
hashMismatch(modelId, expected, actual) {
|
|
60
|
+
return new DextoRuntimeError(
|
|
61
|
+
LocalModelErrorCode.DOWNLOAD_HASH_MISMATCH,
|
|
62
|
+
SCOPE,
|
|
63
|
+
ErrorType.USER,
|
|
64
|
+
`Downloaded model '${modelId}' has invalid hash. Expected: ${expected}, Got: ${actual}`,
|
|
65
|
+
{ modelId, expected, actual },
|
|
66
|
+
"Delete the file and download again"
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
insufficientDiskSpace(modelId, required, available) {
|
|
70
|
+
const requiredGB = (required / (1024 * 1024 * 1024)).toFixed(1);
|
|
71
|
+
const availableGB = (available / (1024 * 1024 * 1024)).toFixed(1);
|
|
72
|
+
return new DextoRuntimeError(
|
|
73
|
+
LocalModelErrorCode.INSUFFICIENT_DISK_SPACE,
|
|
74
|
+
SCOPE,
|
|
75
|
+
ErrorType.USER,
|
|
76
|
+
`Insufficient disk space to download '${modelId}'. Required: ${requiredGB}GB, Available: ${availableGB}GB`,
|
|
77
|
+
{ modelId, required, available },
|
|
78
|
+
"Free up disk space or choose a smaller model"
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
hfAuthRequired(modelId) {
|
|
82
|
+
return new DextoRuntimeError(
|
|
83
|
+
LocalModelErrorCode.HF_AUTH_REQUIRED,
|
|
84
|
+
SCOPE,
|
|
85
|
+
ErrorType.FORBIDDEN,
|
|
86
|
+
`Model '${modelId}' is a gated model and requires HuggingFace authentication`,
|
|
87
|
+
{ modelId },
|
|
88
|
+
"Set HF_TOKEN environment variable or run `huggingface-cli login`"
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
// Model errors
|
|
92
|
+
modelNotFound(modelId) {
|
|
93
|
+
return new DextoRuntimeError(
|
|
94
|
+
LocalModelErrorCode.MODEL_NOT_FOUND,
|
|
95
|
+
SCOPE,
|
|
96
|
+
ErrorType.NOT_FOUND,
|
|
97
|
+
`Model '${modelId}' not found in local model registry`,
|
|
98
|
+
{ modelId },
|
|
99
|
+
'Run `dexto setup` and select "local" to see available models'
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
modelNotDownloaded(modelId) {
|
|
103
|
+
return new DextoRuntimeError(
|
|
104
|
+
LocalModelErrorCode.MODEL_NOT_DOWNLOADED,
|
|
105
|
+
SCOPE,
|
|
106
|
+
ErrorType.NOT_FOUND,
|
|
107
|
+
`Model '${modelId}' is not downloaded. Download it first.`,
|
|
108
|
+
{ modelId },
|
|
109
|
+
'Run `dexto setup` and select "local" to download models'
|
|
110
|
+
);
|
|
111
|
+
},
|
|
112
|
+
modelLoadFailed(modelId, error) {
|
|
113
|
+
return new DextoRuntimeError(
|
|
114
|
+
LocalModelErrorCode.MODEL_LOAD_FAILED,
|
|
115
|
+
SCOPE,
|
|
116
|
+
ErrorType.THIRD_PARTY,
|
|
117
|
+
`Failed to load model '${modelId}': ${error}`,
|
|
118
|
+
{ modelId, error },
|
|
119
|
+
"The model file may be corrupted. Try re-downloading it."
|
|
120
|
+
);
|
|
121
|
+
},
|
|
122
|
+
modelCorrupt(modelId, filePath) {
|
|
123
|
+
return new DextoRuntimeError(
|
|
124
|
+
LocalModelErrorCode.MODEL_CORRUPT,
|
|
125
|
+
SCOPE,
|
|
126
|
+
ErrorType.USER,
|
|
127
|
+
`Model file for '${modelId}' appears to be corrupted`,
|
|
128
|
+
{ modelId, filePath },
|
|
129
|
+
`Delete ${filePath} and download the model again`
|
|
130
|
+
);
|
|
131
|
+
},
|
|
132
|
+
contextTooLarge(modelId, requested, maxSupported) {
|
|
133
|
+
return new DextoRuntimeError(
|
|
134
|
+
LocalModelErrorCode.CONTEXT_TOO_LARGE,
|
|
135
|
+
SCOPE,
|
|
136
|
+
ErrorType.USER,
|
|
137
|
+
`Requested context size ${requested} exceeds model's maximum of ${maxSupported}`,
|
|
138
|
+
{ modelId, requested, maxSupported },
|
|
139
|
+
`Use a context size of ${maxSupported} or less`
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
// GPU errors
|
|
143
|
+
gpuNotAvailable() {
|
|
144
|
+
return new DextoRuntimeError(
|
|
145
|
+
LocalModelErrorCode.GPU_NOT_AVAILABLE,
|
|
146
|
+
SCOPE,
|
|
147
|
+
ErrorType.NOT_FOUND,
|
|
148
|
+
"No GPU acceleration available. Running on CPU.",
|
|
149
|
+
{},
|
|
150
|
+
"For better performance, ensure GPU drivers are installed"
|
|
151
|
+
);
|
|
152
|
+
},
|
|
153
|
+
insufficientVRAM(modelId, required, available) {
|
|
154
|
+
return new DextoRuntimeError(
|
|
155
|
+
LocalModelErrorCode.INSUFFICIENT_VRAM,
|
|
156
|
+
SCOPE,
|
|
157
|
+
ErrorType.USER,
|
|
158
|
+
`Model '${modelId}' requires ${required}GB VRAM but only ${available}GB available`,
|
|
159
|
+
{ modelId, required, available },
|
|
160
|
+
"Use a smaller quantization or reduce GPU layers"
|
|
161
|
+
);
|
|
162
|
+
},
|
|
163
|
+
gpuDriverError(error) {
|
|
164
|
+
return new DextoRuntimeError(
|
|
165
|
+
LocalModelErrorCode.GPU_DRIVER_ERROR,
|
|
166
|
+
SCOPE,
|
|
167
|
+
ErrorType.THIRD_PARTY,
|
|
168
|
+
`GPU driver error: ${error}`,
|
|
169
|
+
{ error },
|
|
170
|
+
"Update your GPU drivers"
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
// Ollama errors
|
|
174
|
+
ollamaNotRunning(url) {
|
|
175
|
+
return new DextoRuntimeError(
|
|
176
|
+
LocalModelErrorCode.OLLAMA_NOT_RUNNING,
|
|
177
|
+
SCOPE,
|
|
178
|
+
ErrorType.THIRD_PARTY,
|
|
179
|
+
`Ollama server is not running at ${url}`,
|
|
180
|
+
{ url },
|
|
181
|
+
"Start Ollama with `ollama serve` or ensure it is running"
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
ollamaModelNotFound(modelName) {
|
|
185
|
+
return new DextoRuntimeError(
|
|
186
|
+
LocalModelErrorCode.OLLAMA_MODEL_NOT_FOUND,
|
|
187
|
+
SCOPE,
|
|
188
|
+
ErrorType.NOT_FOUND,
|
|
189
|
+
`Model '${modelName}' not found on Ollama server`,
|
|
190
|
+
{ modelName },
|
|
191
|
+
`Pull the model with \`ollama pull ${modelName}\``
|
|
192
|
+
);
|
|
193
|
+
},
|
|
194
|
+
ollamaPullFailed(modelName, error) {
|
|
195
|
+
return new DextoRuntimeError(
|
|
196
|
+
LocalModelErrorCode.OLLAMA_PULL_FAILED,
|
|
197
|
+
SCOPE,
|
|
198
|
+
ErrorType.THIRD_PARTY,
|
|
199
|
+
`Failed to pull model '${modelName}' from Ollama: ${error}`,
|
|
200
|
+
{ modelName, error },
|
|
201
|
+
"Check your internet connection and Ollama server status"
|
|
202
|
+
);
|
|
203
|
+
},
|
|
204
|
+
ollamaApiError(error) {
|
|
205
|
+
return new DextoRuntimeError(
|
|
206
|
+
LocalModelErrorCode.OLLAMA_API_ERROR,
|
|
207
|
+
SCOPE,
|
|
208
|
+
ErrorType.THIRD_PARTY,
|
|
209
|
+
`Ollama API error: ${error}`,
|
|
210
|
+
{ error },
|
|
211
|
+
"Check Ollama server logs for details"
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
export {
|
|
216
|
+
LocalModelError
|
|
217
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
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 gpu_detector_exports = {};
|
|
30
|
+
__export(gpu_detector_exports, {
|
|
31
|
+
detectGPU: () => detectGPU,
|
|
32
|
+
formatGPUInfo: () => formatGPUInfo,
|
|
33
|
+
getAvailableBackends: () => getAvailableBackends,
|
|
34
|
+
isBackendAvailable: () => isBackendAvailable
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(gpu_detector_exports);
|
|
37
|
+
var import_child_process = require("child_process");
|
|
38
|
+
var import_util = require("util");
|
|
39
|
+
var os = __toESM(require("os"), 1);
|
|
40
|
+
const execAsync = (0, import_util.promisify)(import_child_process.exec);
|
|
41
|
+
async function detectGPU() {
|
|
42
|
+
const platform = os.platform();
|
|
43
|
+
if (platform === "darwin") {
|
|
44
|
+
const metalInfo = await detectMetal();
|
|
45
|
+
if (metalInfo.available) {
|
|
46
|
+
return metalInfo;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (platform === "linux" || platform === "win32") {
|
|
50
|
+
const cudaInfo = await detectCUDA();
|
|
51
|
+
if (cudaInfo.available) {
|
|
52
|
+
return cudaInfo;
|
|
53
|
+
}
|
|
54
|
+
const vulkanInfo = await detectVulkan();
|
|
55
|
+
if (vulkanInfo.available) {
|
|
56
|
+
return vulkanInfo;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
backend: "cpu",
|
|
61
|
+
available: true,
|
|
62
|
+
deviceName: `${os.cpus()[0]?.model ?? "Unknown CPU"}`
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async function detectMetal() {
|
|
66
|
+
try {
|
|
67
|
+
const { stdout } = await execAsync("system_profiler SPDisplaysDataType -json 2>/dev/null");
|
|
68
|
+
const data = JSON.parse(stdout);
|
|
69
|
+
const gpuData = data?.SPDisplaysDataType?.[0];
|
|
70
|
+
if (gpuData) {
|
|
71
|
+
const chipName = gpuData.sppci_model ?? gpuData._name ?? "Apple GPU";
|
|
72
|
+
const isAppleSilicon = chipName.toLowerCase().includes("apple") || chipName.toLowerCase().includes("m1") || chipName.toLowerCase().includes("m2") || chipName.toLowerCase().includes("m3") || chipName.toLowerCase().includes("m4");
|
|
73
|
+
const result = {
|
|
74
|
+
backend: "metal",
|
|
75
|
+
available: true,
|
|
76
|
+
deviceName: chipName
|
|
77
|
+
};
|
|
78
|
+
if (isAppleSilicon) {
|
|
79
|
+
result.vramMB = Math.round(os.totalmem() / (1024 * 1024));
|
|
80
|
+
} else if (gpuData.sppci_vram) {
|
|
81
|
+
const vramMatch = gpuData.sppci_vram.match(/(\d+)\s*(GB|MB)/i);
|
|
82
|
+
if (vramMatch) {
|
|
83
|
+
result.vramMB = parseInt(vramMatch[1]) * (vramMatch[2].toUpperCase() === "GB" ? 1024 : 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
backend: "metal",
|
|
92
|
+
available: false
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async function detectCUDA() {
|
|
96
|
+
try {
|
|
97
|
+
const { stdout } = await execAsync(
|
|
98
|
+
"nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv,noheader,nounits 2>/dev/null"
|
|
99
|
+
);
|
|
100
|
+
const lines = stdout.trim().split("\n");
|
|
101
|
+
if (lines.length > 0 && lines[0]) {
|
|
102
|
+
const [name, memoryMB, driverVersion] = lines[0].split(", ").map((s) => s.trim());
|
|
103
|
+
const result = {
|
|
104
|
+
backend: "cuda",
|
|
105
|
+
available: true
|
|
106
|
+
};
|
|
107
|
+
if (name) {
|
|
108
|
+
result.deviceName = name;
|
|
109
|
+
}
|
|
110
|
+
if (memoryMB) {
|
|
111
|
+
result.vramMB = parseInt(memoryMB);
|
|
112
|
+
}
|
|
113
|
+
if (driverVersion) {
|
|
114
|
+
result.driverVersion = driverVersion;
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
backend: "cuda",
|
|
122
|
+
available: false
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async function detectVulkan() {
|
|
126
|
+
try {
|
|
127
|
+
const { stdout } = await execAsync("vulkaninfo --summary 2>/dev/null");
|
|
128
|
+
const deviceMatch = stdout.match(/deviceName\s*=\s*(.+)/);
|
|
129
|
+
const deviceName = deviceMatch?.[1]?.trim() ?? "Vulkan GPU";
|
|
130
|
+
const result = {
|
|
131
|
+
backend: "vulkan",
|
|
132
|
+
available: true,
|
|
133
|
+
deviceName
|
|
134
|
+
};
|
|
135
|
+
const heapMatch = stdout.match(/heapSize\s*=\s*(\d+)/);
|
|
136
|
+
if (heapMatch) {
|
|
137
|
+
result.vramMB = Math.round(parseInt(heapMatch[1]) / (1024 * 1024));
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
} catch {
|
|
141
|
+
}
|
|
142
|
+
if (os.platform() === "linux") {
|
|
143
|
+
try {
|
|
144
|
+
const { stdout } = await execAsync('lspci | grep -i "vga\\|3d\\|display" 2>/dev/null');
|
|
145
|
+
if (stdout.includes("AMD") || stdout.includes("Intel") || stdout.includes("Radeon")) {
|
|
146
|
+
const deviceMatch = stdout.match(/: (.+)/);
|
|
147
|
+
return {
|
|
148
|
+
backend: "vulkan",
|
|
149
|
+
available: true,
|
|
150
|
+
deviceName: deviceMatch?.[1]?.trim() ?? "GPU (Vulkan)"
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
} catch {
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
backend: "vulkan",
|
|
158
|
+
available: false
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function formatGPUInfo(info) {
|
|
162
|
+
if (!info.available) {
|
|
163
|
+
return `${info.backend.toUpperCase()} not available`;
|
|
164
|
+
}
|
|
165
|
+
const parts = [info.deviceName ?? info.backend.toUpperCase()];
|
|
166
|
+
if (info.vramMB) {
|
|
167
|
+
const vramGB = (info.vramMB / 1024).toFixed(1);
|
|
168
|
+
parts.push(`${vramGB}GB`);
|
|
169
|
+
}
|
|
170
|
+
if (info.driverVersion) {
|
|
171
|
+
parts.push(`Driver: ${info.driverVersion}`);
|
|
172
|
+
}
|
|
173
|
+
return parts.join(" \u2022 ");
|
|
174
|
+
}
|
|
175
|
+
async function isBackendAvailable(backend) {
|
|
176
|
+
switch (backend) {
|
|
177
|
+
case "metal":
|
|
178
|
+
return (await detectMetal()).available;
|
|
179
|
+
case "cuda":
|
|
180
|
+
return (await detectCUDA()).available;
|
|
181
|
+
case "vulkan":
|
|
182
|
+
return (await detectVulkan()).available;
|
|
183
|
+
case "cpu":
|
|
184
|
+
return true;
|
|
185
|
+
default:
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
async function getAvailableBackends() {
|
|
190
|
+
const backends = [];
|
|
191
|
+
const platform = os.platform();
|
|
192
|
+
if (platform === "darwin") {
|
|
193
|
+
if ((await detectMetal()).available) {
|
|
194
|
+
backends.push("metal");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (platform === "linux" || platform === "win32") {
|
|
198
|
+
if ((await detectCUDA()).available) {
|
|
199
|
+
backends.push("cuda");
|
|
200
|
+
}
|
|
201
|
+
if ((await detectVulkan()).available) {
|
|
202
|
+
backends.push("vulkan");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
backends.push("cpu");
|
|
206
|
+
return backends;
|
|
207
|
+
}
|
|
208
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
209
|
+
0 && (module.exports = {
|
|
210
|
+
detectGPU,
|
|
211
|
+
formatGPUInfo,
|
|
212
|
+
getAvailableBackends,
|
|
213
|
+
isBackendAvailable
|
|
214
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GPU detection for local model acceleration.
|
|
3
|
+
*
|
|
4
|
+
* Detects available GPU backends:
|
|
5
|
+
* - Metal: Apple Silicon (M1/M2/M3/M4 series)
|
|
6
|
+
* - CUDA: NVIDIA GPUs on Linux/Windows
|
|
7
|
+
* - Vulkan: Cross-platform fallback for AMD/Intel GPUs
|
|
8
|
+
* - CPU: Fallback when no GPU is available
|
|
9
|
+
*/
|
|
10
|
+
import type { GPUBackend, GPUInfo } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Detect available GPU backend for the current system.
|
|
13
|
+
* Returns the best available option.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectGPU(): Promise<GPUInfo>;
|
|
16
|
+
/**
|
|
17
|
+
* Get a human-readable summary of GPU detection results.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatGPUInfo(info: GPUInfo): string;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a specific backend is available.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isBackendAvailable(backend: GPUBackend): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Get all available backends on the current system.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getAvailableBackends(): Promise<GPUBackend[]>;
|
|
28
|
+
//# sourceMappingURL=gpu-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-detector.d.ts","sourceRoot":"","sources":["../../../../src/llm/providers/local/gpu-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAItD;;;GAGG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CA+BlD;AAmJD;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAiBnD;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAa9E;AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAuBlE"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import "../../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { exec } from "child_process";
|
|
3
|
+
import { promisify } from "util";
|
|
4
|
+
import * as os from "os";
|
|
5
|
+
const execAsync = promisify(exec);
|
|
6
|
+
async function detectGPU() {
|
|
7
|
+
const platform = os.platform();
|
|
8
|
+
if (platform === "darwin") {
|
|
9
|
+
const metalInfo = await detectMetal();
|
|
10
|
+
if (metalInfo.available) {
|
|
11
|
+
return metalInfo;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (platform === "linux" || platform === "win32") {
|
|
15
|
+
const cudaInfo = await detectCUDA();
|
|
16
|
+
if (cudaInfo.available) {
|
|
17
|
+
return cudaInfo;
|
|
18
|
+
}
|
|
19
|
+
const vulkanInfo = await detectVulkan();
|
|
20
|
+
if (vulkanInfo.available) {
|
|
21
|
+
return vulkanInfo;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
backend: "cpu",
|
|
26
|
+
available: true,
|
|
27
|
+
deviceName: `${os.cpus()[0]?.model ?? "Unknown CPU"}`
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function detectMetal() {
|
|
31
|
+
try {
|
|
32
|
+
const { stdout } = await execAsync("system_profiler SPDisplaysDataType -json 2>/dev/null");
|
|
33
|
+
const data = JSON.parse(stdout);
|
|
34
|
+
const gpuData = data?.SPDisplaysDataType?.[0];
|
|
35
|
+
if (gpuData) {
|
|
36
|
+
const chipName = gpuData.sppci_model ?? gpuData._name ?? "Apple GPU";
|
|
37
|
+
const isAppleSilicon = chipName.toLowerCase().includes("apple") || chipName.toLowerCase().includes("m1") || chipName.toLowerCase().includes("m2") || chipName.toLowerCase().includes("m3") || chipName.toLowerCase().includes("m4");
|
|
38
|
+
const result = {
|
|
39
|
+
backend: "metal",
|
|
40
|
+
available: true,
|
|
41
|
+
deviceName: chipName
|
|
42
|
+
};
|
|
43
|
+
if (isAppleSilicon) {
|
|
44
|
+
result.vramMB = Math.round(os.totalmem() / (1024 * 1024));
|
|
45
|
+
} else if (gpuData.sppci_vram) {
|
|
46
|
+
const vramMatch = gpuData.sppci_vram.match(/(\d+)\s*(GB|MB)/i);
|
|
47
|
+
if (vramMatch) {
|
|
48
|
+
result.vramMB = parseInt(vramMatch[1]) * (vramMatch[2].toUpperCase() === "GB" ? 1024 : 1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
backend: "metal",
|
|
57
|
+
available: false
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function detectCUDA() {
|
|
61
|
+
try {
|
|
62
|
+
const { stdout } = await execAsync(
|
|
63
|
+
"nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv,noheader,nounits 2>/dev/null"
|
|
64
|
+
);
|
|
65
|
+
const lines = stdout.trim().split("\n");
|
|
66
|
+
if (lines.length > 0 && lines[0]) {
|
|
67
|
+
const [name, memoryMB, driverVersion] = lines[0].split(", ").map((s) => s.trim());
|
|
68
|
+
const result = {
|
|
69
|
+
backend: "cuda",
|
|
70
|
+
available: true
|
|
71
|
+
};
|
|
72
|
+
if (name) {
|
|
73
|
+
result.deviceName = name;
|
|
74
|
+
}
|
|
75
|
+
if (memoryMB) {
|
|
76
|
+
result.vramMB = parseInt(memoryMB);
|
|
77
|
+
}
|
|
78
|
+
if (driverVersion) {
|
|
79
|
+
result.driverVersion = driverVersion;
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
backend: "cuda",
|
|
87
|
+
available: false
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async function detectVulkan() {
|
|
91
|
+
try {
|
|
92
|
+
const { stdout } = await execAsync("vulkaninfo --summary 2>/dev/null");
|
|
93
|
+
const deviceMatch = stdout.match(/deviceName\s*=\s*(.+)/);
|
|
94
|
+
const deviceName = deviceMatch?.[1]?.trim() ?? "Vulkan GPU";
|
|
95
|
+
const result = {
|
|
96
|
+
backend: "vulkan",
|
|
97
|
+
available: true,
|
|
98
|
+
deviceName
|
|
99
|
+
};
|
|
100
|
+
const heapMatch = stdout.match(/heapSize\s*=\s*(\d+)/);
|
|
101
|
+
if (heapMatch) {
|
|
102
|
+
result.vramMB = Math.round(parseInt(heapMatch[1]) / (1024 * 1024));
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
} catch {
|
|
106
|
+
}
|
|
107
|
+
if (os.platform() === "linux") {
|
|
108
|
+
try {
|
|
109
|
+
const { stdout } = await execAsync('lspci | grep -i "vga\\|3d\\|display" 2>/dev/null');
|
|
110
|
+
if (stdout.includes("AMD") || stdout.includes("Intel") || stdout.includes("Radeon")) {
|
|
111
|
+
const deviceMatch = stdout.match(/: (.+)/);
|
|
112
|
+
return {
|
|
113
|
+
backend: "vulkan",
|
|
114
|
+
available: true,
|
|
115
|
+
deviceName: deviceMatch?.[1]?.trim() ?? "GPU (Vulkan)"
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
backend: "vulkan",
|
|
123
|
+
available: false
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function formatGPUInfo(info) {
|
|
127
|
+
if (!info.available) {
|
|
128
|
+
return `${info.backend.toUpperCase()} not available`;
|
|
129
|
+
}
|
|
130
|
+
const parts = [info.deviceName ?? info.backend.toUpperCase()];
|
|
131
|
+
if (info.vramMB) {
|
|
132
|
+
const vramGB = (info.vramMB / 1024).toFixed(1);
|
|
133
|
+
parts.push(`${vramGB}GB`);
|
|
134
|
+
}
|
|
135
|
+
if (info.driverVersion) {
|
|
136
|
+
parts.push(`Driver: ${info.driverVersion}`);
|
|
137
|
+
}
|
|
138
|
+
return parts.join(" \u2022 ");
|
|
139
|
+
}
|
|
140
|
+
async function isBackendAvailable(backend) {
|
|
141
|
+
switch (backend) {
|
|
142
|
+
case "metal":
|
|
143
|
+
return (await detectMetal()).available;
|
|
144
|
+
case "cuda":
|
|
145
|
+
return (await detectCUDA()).available;
|
|
146
|
+
case "vulkan":
|
|
147
|
+
return (await detectVulkan()).available;
|
|
148
|
+
case "cpu":
|
|
149
|
+
return true;
|
|
150
|
+
default:
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function getAvailableBackends() {
|
|
155
|
+
const backends = [];
|
|
156
|
+
const platform = os.platform();
|
|
157
|
+
if (platform === "darwin") {
|
|
158
|
+
if ((await detectMetal()).available) {
|
|
159
|
+
backends.push("metal");
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (platform === "linux" || platform === "win32") {
|
|
163
|
+
if ((await detectCUDA()).available) {
|
|
164
|
+
backends.push("cuda");
|
|
165
|
+
}
|
|
166
|
+
if ((await detectVulkan()).available) {
|
|
167
|
+
backends.push("vulkan");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
backends.push("cpu");
|
|
171
|
+
return backends;
|
|
172
|
+
}
|
|
173
|
+
export {
|
|
174
|
+
detectGPU,
|
|
175
|
+
formatGPUInfo,
|
|
176
|
+
getAvailableBackends,
|
|
177
|
+
isBackendAvailable
|
|
178
|
+
};
|