@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,176 @@
|
|
|
1
|
+
import "../../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { LocalModelError } from "./errors.js";
|
|
3
|
+
import { detectGPU } from "./gpu-detector.js";
|
|
4
|
+
import { getDextoGlobalPath } from "../../../utils/path.js";
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
function getGlobalNodeLlamaCppPath() {
|
|
8
|
+
return path.join(getDextoGlobalPath("deps"), "node_modules", "node-llama-cpp");
|
|
9
|
+
}
|
|
10
|
+
async function isNodeLlamaCppInstalled() {
|
|
11
|
+
try {
|
|
12
|
+
await import("node-llama-cpp");
|
|
13
|
+
return true;
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const globalPath = getGlobalNodeLlamaCppPath();
|
|
18
|
+
const require2 = createRequire(import.meta.url);
|
|
19
|
+
require2.resolve(globalPath);
|
|
20
|
+
return true;
|
|
21
|
+
} catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function importNodeLlamaCpp() {
|
|
26
|
+
try {
|
|
27
|
+
return await import("node-llama-cpp");
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const globalPath = getGlobalNodeLlamaCppPath();
|
|
32
|
+
const entryPoint = path.join(globalPath, "dist", "index.js");
|
|
33
|
+
return await import(entryPoint);
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function requireNodeLlamaCpp() {
|
|
39
|
+
throw LocalModelError.nodeLlamaNotInstalled();
|
|
40
|
+
}
|
|
41
|
+
const modelCache = /* @__PURE__ */ new Map();
|
|
42
|
+
async function loadModel(config) {
|
|
43
|
+
const { modelPath, gpuLayers = -1, contextSize, threads, batchSize = 512 } = config;
|
|
44
|
+
const cacheKey = `${modelPath}:${gpuLayers}:${contextSize}`;
|
|
45
|
+
const cached = modelCache.get(cacheKey);
|
|
46
|
+
if (cached) {
|
|
47
|
+
return cached;
|
|
48
|
+
}
|
|
49
|
+
const loadPromise = (async () => {
|
|
50
|
+
const nodeLlama = await importNodeLlamaCpp();
|
|
51
|
+
if (!nodeLlama) {
|
|
52
|
+
throw LocalModelError.nodeLlamaNotInstalled();
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const gpuInfo = await detectGPU();
|
|
56
|
+
const getLlama = nodeLlama["getLlama"];
|
|
57
|
+
const LlamaLogLevel = nodeLlama["LlamaLogLevel"];
|
|
58
|
+
const LlamaChatSession = nodeLlama["LlamaChatSession"];
|
|
59
|
+
const llama = await getLlama({
|
|
60
|
+
logLevel: LlamaLogLevel.warn,
|
|
61
|
+
gpu: gpuInfo.backend === "cpu" ? false : "auto"
|
|
62
|
+
});
|
|
63
|
+
const model = await llama.loadModel({
|
|
64
|
+
modelPath,
|
|
65
|
+
gpuLayers: gpuLayers === -1 ? "auto" : gpuLayers
|
|
66
|
+
});
|
|
67
|
+
const contextOptions = {
|
|
68
|
+
batchSize
|
|
69
|
+
};
|
|
70
|
+
if (contextSize !== void 0) {
|
|
71
|
+
contextOptions.contextSize = contextSize;
|
|
72
|
+
}
|
|
73
|
+
if (threads !== void 0) {
|
|
74
|
+
contextOptions.threads = threads;
|
|
75
|
+
}
|
|
76
|
+
const context = await model.createContext(contextOptions);
|
|
77
|
+
return {
|
|
78
|
+
modelPath,
|
|
79
|
+
gpuInfo,
|
|
80
|
+
async createSession() {
|
|
81
|
+
const session = new LlamaChatSession({
|
|
82
|
+
contextSequence: context.getSequence()
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
async prompt(text, options = {}) {
|
|
86
|
+
const {
|
|
87
|
+
maxTokens = 1024,
|
|
88
|
+
temperature = 0.7,
|
|
89
|
+
topP = 0.9,
|
|
90
|
+
signal,
|
|
91
|
+
onToken
|
|
92
|
+
} = options;
|
|
93
|
+
const promptOptions = {
|
|
94
|
+
maxTokens,
|
|
95
|
+
temperature,
|
|
96
|
+
topP,
|
|
97
|
+
stopOnAbortSignal: true,
|
|
98
|
+
trimWhitespaceSuffix: true
|
|
99
|
+
};
|
|
100
|
+
if (signal) {
|
|
101
|
+
promptOptions.signal = signal;
|
|
102
|
+
}
|
|
103
|
+
if (onToken) {
|
|
104
|
+
promptOptions.onTextChunk = onToken;
|
|
105
|
+
}
|
|
106
|
+
const response = await session.prompt(text, promptOptions);
|
|
107
|
+
return response;
|
|
108
|
+
},
|
|
109
|
+
async dispose() {
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
async dispose() {
|
|
114
|
+
await context.dispose();
|
|
115
|
+
await model.dispose();
|
|
116
|
+
modelCache.delete(cacheKey);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
} catch (error) {
|
|
120
|
+
modelCache.delete(cacheKey);
|
|
121
|
+
if (error instanceof Error && "code" in error) {
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
throw LocalModelError.modelLoadFailed(
|
|
125
|
+
modelPath,
|
|
126
|
+
error instanceof Error ? error.message : String(error)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
})();
|
|
130
|
+
modelCache.set(cacheKey, loadPromise);
|
|
131
|
+
return loadPromise;
|
|
132
|
+
}
|
|
133
|
+
async function unloadModel(modelPath) {
|
|
134
|
+
for (const [key, loadPromise] of modelCache.entries()) {
|
|
135
|
+
const keyModelPath = key.split(":")[0];
|
|
136
|
+
if (keyModelPath === modelPath) {
|
|
137
|
+
try {
|
|
138
|
+
const loaded = await loadPromise;
|
|
139
|
+
await loaded.dispose();
|
|
140
|
+
} catch {
|
|
141
|
+
}
|
|
142
|
+
modelCache.delete(key);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async function unloadAllModels() {
|
|
147
|
+
for (const [key, loadPromise] of modelCache.entries()) {
|
|
148
|
+
try {
|
|
149
|
+
const loaded = await loadPromise;
|
|
150
|
+
await loaded.dispose();
|
|
151
|
+
} catch {
|
|
152
|
+
}
|
|
153
|
+
modelCache.delete(key);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function isModelLoaded(modelPath) {
|
|
157
|
+
for (const key of modelCache.keys()) {
|
|
158
|
+
const keyModelPath = key.split(":")[0];
|
|
159
|
+
if (keyModelPath === modelPath) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
function getLoadedModelCount() {
|
|
166
|
+
return modelCache.size;
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
getLoadedModelCount,
|
|
170
|
+
isModelLoaded,
|
|
171
|
+
isNodeLlamaCppInstalled,
|
|
172
|
+
loadModel,
|
|
173
|
+
requireNodeLlamaCpp,
|
|
174
|
+
unloadAllModels,
|
|
175
|
+
unloadModel
|
|
176
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ollama_provider_exports = {};
|
|
20
|
+
__export(ollama_provider_exports, {
|
|
21
|
+
DEFAULT_OLLAMA_URL: () => DEFAULT_OLLAMA_URL,
|
|
22
|
+
checkOllamaStatus: () => checkOllamaStatus,
|
|
23
|
+
createOllamaModel: () => createOllamaModel,
|
|
24
|
+
createValidatedOllamaModel: () => createValidatedOllamaModel,
|
|
25
|
+
deleteOllamaModel: () => deleteOllamaModel,
|
|
26
|
+
generateOllamaEmbeddings: () => generateOllamaEmbeddings,
|
|
27
|
+
getOllamaModelInfo: () => getOllamaModelInfo,
|
|
28
|
+
isOllamaModelAvailable: () => isOllamaModelAvailable,
|
|
29
|
+
listOllamaModels: () => listOllamaModels,
|
|
30
|
+
pullOllamaModel: () => pullOllamaModel
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(ollama_provider_exports);
|
|
33
|
+
var import_openai = require("@ai-sdk/openai");
|
|
34
|
+
var import_errors = require("./errors.js");
|
|
35
|
+
const DEFAULT_OLLAMA_URL = "http://localhost:11434";
|
|
36
|
+
async function checkOllamaStatus(baseURL = DEFAULT_OLLAMA_URL) {
|
|
37
|
+
try {
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
const timeoutId = setTimeout(() => controller.abort(), 5e3);
|
|
40
|
+
const response = await fetch(`${baseURL}/api/version`, {
|
|
41
|
+
signal: controller.signal
|
|
42
|
+
});
|
|
43
|
+
clearTimeout(timeoutId);
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
return {
|
|
46
|
+
running: false,
|
|
47
|
+
url: baseURL,
|
|
48
|
+
error: `HTTP ${response.status}: ${response.statusText}`
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const data = await response.json();
|
|
52
|
+
const models = await listOllamaModels(baseURL);
|
|
53
|
+
const status = {
|
|
54
|
+
running: true,
|
|
55
|
+
url: baseURL,
|
|
56
|
+
models
|
|
57
|
+
};
|
|
58
|
+
if (data.version) {
|
|
59
|
+
status.version = data.version;
|
|
60
|
+
}
|
|
61
|
+
return status;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
const errorMessage = error instanceof Error ? error.name === "AbortError" ? "Connection timed out" : error.message : "Unknown error";
|
|
64
|
+
return {
|
|
65
|
+
running: false,
|
|
66
|
+
url: baseURL,
|
|
67
|
+
error: errorMessage
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function listOllamaModels(baseURL = DEFAULT_OLLAMA_URL) {
|
|
72
|
+
try {
|
|
73
|
+
const response = await fetch(`${baseURL}/api/tags`);
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
const data = await response.json();
|
|
78
|
+
return (data.models ?? []).map((model) => {
|
|
79
|
+
const modelInfo = {
|
|
80
|
+
name: model.name,
|
|
81
|
+
size: model.size,
|
|
82
|
+
digest: model.digest,
|
|
83
|
+
modifiedAt: model.modified_at
|
|
84
|
+
};
|
|
85
|
+
if (model.details) {
|
|
86
|
+
const details = {};
|
|
87
|
+
if (model.details.family) {
|
|
88
|
+
details.family = model.details.family;
|
|
89
|
+
}
|
|
90
|
+
if (model.details.parameter_size) {
|
|
91
|
+
details.parameterSize = model.details.parameter_size;
|
|
92
|
+
}
|
|
93
|
+
if (model.details.quantization_level) {
|
|
94
|
+
details.quantizationLevel = model.details.quantization_level;
|
|
95
|
+
}
|
|
96
|
+
if (Object.keys(details).length > 0) {
|
|
97
|
+
modelInfo.details = details;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return modelInfo;
|
|
101
|
+
});
|
|
102
|
+
} catch {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function isOllamaModelAvailable(modelName, baseURL = DEFAULT_OLLAMA_URL) {
|
|
107
|
+
const models = await listOllamaModels(baseURL);
|
|
108
|
+
return models.some(
|
|
109
|
+
(m) => m.name === modelName || m.name.startsWith(`${modelName}:`) || modelName.startsWith(`${m.name}:`)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
async function pullOllamaModel(modelName, baseURL = DEFAULT_OLLAMA_URL, onProgress, signal) {
|
|
113
|
+
try {
|
|
114
|
+
const fetchOptions = {
|
|
115
|
+
method: "POST",
|
|
116
|
+
headers: { "Content-Type": "application/json" },
|
|
117
|
+
body: JSON.stringify({ name: modelName })
|
|
118
|
+
};
|
|
119
|
+
if (signal) {
|
|
120
|
+
fetchOptions.signal = signal;
|
|
121
|
+
}
|
|
122
|
+
const response = await fetch(`${baseURL}/api/pull`, fetchOptions);
|
|
123
|
+
if (!response.ok) {
|
|
124
|
+
throw import_errors.LocalModelError.ollamaPullFailed(
|
|
125
|
+
modelName,
|
|
126
|
+
`HTTP ${response.status}: ${response.statusText}`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const reader = response.body?.getReader();
|
|
130
|
+
if (!reader) {
|
|
131
|
+
throw import_errors.LocalModelError.ollamaPullFailed(modelName, "No response body");
|
|
132
|
+
}
|
|
133
|
+
const decoder = new TextDecoder();
|
|
134
|
+
let buffer = "";
|
|
135
|
+
while (true) {
|
|
136
|
+
const { done, value } = await reader.read();
|
|
137
|
+
if (done) break;
|
|
138
|
+
buffer += decoder.decode(value, { stream: true });
|
|
139
|
+
const lines = buffer.split("\n");
|
|
140
|
+
buffer = lines.pop() || "";
|
|
141
|
+
for (const line of lines) {
|
|
142
|
+
if (!line.trim()) continue;
|
|
143
|
+
try {
|
|
144
|
+
const progress = JSON.parse(line);
|
|
145
|
+
if (progress.error) {
|
|
146
|
+
throw import_errors.LocalModelError.ollamaPullFailed(modelName, progress.error);
|
|
147
|
+
}
|
|
148
|
+
onProgress?.(progress);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
if (e instanceof Error && e.message.includes("ollamaPullFailed")) {
|
|
151
|
+
throw e;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (error instanceof Error && error.message.includes("ECONNREFUSED")) {
|
|
158
|
+
throw import_errors.LocalModelError.ollamaNotRunning(baseURL);
|
|
159
|
+
}
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function createOllamaModel(modelName, config = {}) {
|
|
164
|
+
const { baseURL = DEFAULT_OLLAMA_URL } = config;
|
|
165
|
+
const openai = (0, import_openai.createOpenAI)({
|
|
166
|
+
baseURL: `${baseURL}/v1`,
|
|
167
|
+
apiKey: "ollama"
|
|
168
|
+
// Ollama doesn't require an API key, but the SDK requires a non-empty string
|
|
169
|
+
});
|
|
170
|
+
return openai(modelName);
|
|
171
|
+
}
|
|
172
|
+
async function createValidatedOllamaModel(modelName, config = {}) {
|
|
173
|
+
const { baseURL = DEFAULT_OLLAMA_URL } = config;
|
|
174
|
+
const status = await checkOllamaStatus(baseURL);
|
|
175
|
+
if (!status.running) {
|
|
176
|
+
throw import_errors.LocalModelError.ollamaNotRunning(baseURL);
|
|
177
|
+
}
|
|
178
|
+
const isAvailable = await isOllamaModelAvailable(modelName, baseURL);
|
|
179
|
+
if (!isAvailable) {
|
|
180
|
+
throw import_errors.LocalModelError.ollamaModelNotFound(modelName);
|
|
181
|
+
}
|
|
182
|
+
return createOllamaModel(modelName, config);
|
|
183
|
+
}
|
|
184
|
+
async function getOllamaModelInfo(modelName, baseURL = DEFAULT_OLLAMA_URL) {
|
|
185
|
+
const models = await listOllamaModels(baseURL);
|
|
186
|
+
return models.find(
|
|
187
|
+
(m) => m.name === modelName || m.name.startsWith(`${modelName}:`) || modelName.startsWith(`${m.name}:`)
|
|
188
|
+
) ?? null;
|
|
189
|
+
}
|
|
190
|
+
async function deleteOllamaModel(modelName, baseURL = DEFAULT_OLLAMA_URL) {
|
|
191
|
+
try {
|
|
192
|
+
const response = await fetch(`${baseURL}/api/delete`, {
|
|
193
|
+
method: "DELETE",
|
|
194
|
+
headers: { "Content-Type": "application/json" },
|
|
195
|
+
body: JSON.stringify({ name: modelName })
|
|
196
|
+
});
|
|
197
|
+
return response.ok;
|
|
198
|
+
} catch {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async function generateOllamaEmbeddings(modelName, input, baseURL = DEFAULT_OLLAMA_URL) {
|
|
203
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
204
|
+
const response = await fetch(`${baseURL}/api/embed`, {
|
|
205
|
+
method: "POST",
|
|
206
|
+
headers: { "Content-Type": "application/json" },
|
|
207
|
+
body: JSON.stringify({
|
|
208
|
+
model: modelName,
|
|
209
|
+
input: inputs
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
if (!response.ok) {
|
|
213
|
+
throw import_errors.LocalModelError.ollamaApiError(`HTTP ${response.status}: ${response.statusText}`);
|
|
214
|
+
}
|
|
215
|
+
const data = await response.json();
|
|
216
|
+
return data.embeddings;
|
|
217
|
+
}
|
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
219
|
+
0 && (module.exports = {
|
|
220
|
+
DEFAULT_OLLAMA_URL,
|
|
221
|
+
checkOllamaStatus,
|
|
222
|
+
createOllamaModel,
|
|
223
|
+
createValidatedOllamaModel,
|
|
224
|
+
deleteOllamaModel,
|
|
225
|
+
generateOllamaEmbeddings,
|
|
226
|
+
getOllamaModelInfo,
|
|
227
|
+
isOllamaModelAvailable,
|
|
228
|
+
listOllamaModels,
|
|
229
|
+
pullOllamaModel
|
|
230
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ollama provider for local model inference.
|
|
3
|
+
*
|
|
4
|
+
* Uses Ollama's OpenAI-compatible API for seamless integration
|
|
5
|
+
* with the Vercel AI SDK.
|
|
6
|
+
*/
|
|
7
|
+
import type { LanguageModel } from 'ai';
|
|
8
|
+
import type { OllamaModelInfo, OllamaStatus } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Default Ollama server URL.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_OLLAMA_URL = "http://localhost:11434";
|
|
13
|
+
/**
|
|
14
|
+
* Ollama configuration options.
|
|
15
|
+
*/
|
|
16
|
+
export interface OllamaConfig {
|
|
17
|
+
/** Ollama server base URL (default: http://localhost:11434) */
|
|
18
|
+
baseURL?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Check if the Ollama server is running.
|
|
22
|
+
*/
|
|
23
|
+
export declare function checkOllamaStatus(baseURL?: string): Promise<OllamaStatus>;
|
|
24
|
+
/**
|
|
25
|
+
* List available models on the Ollama server.
|
|
26
|
+
*/
|
|
27
|
+
export declare function listOllamaModels(baseURL?: string): Promise<OllamaModelInfo[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a specific model is available on Ollama.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isOllamaModelAvailable(modelName: string, baseURL?: string): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Pull a model from the Ollama registry.
|
|
34
|
+
* Returns a stream of progress events.
|
|
35
|
+
*
|
|
36
|
+
* @param modelName - Name of the model to pull
|
|
37
|
+
* @param baseURL - Ollama server URL (default: http://localhost:11434)
|
|
38
|
+
* @param onProgress - Optional callback for progress updates
|
|
39
|
+
* @param signal - Optional AbortSignal for cancellation
|
|
40
|
+
*/
|
|
41
|
+
export declare function pullOllamaModel(modelName: string, baseURL?: string, onProgress?: (progress: {
|
|
42
|
+
status: string;
|
|
43
|
+
completed?: number;
|
|
44
|
+
total?: number;
|
|
45
|
+
}) => void, signal?: AbortSignal): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Create an Ollama language model using the OpenAI-compatible API.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createOllamaModel(modelName: string, config?: OllamaConfig): LanguageModel;
|
|
50
|
+
/**
|
|
51
|
+
* Create an Ollama model with status validation.
|
|
52
|
+
* Throws if Ollama is not running or model is not available.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createValidatedOllamaModel(modelName: string, config?: OllamaConfig): Promise<LanguageModel>;
|
|
55
|
+
/**
|
|
56
|
+
* Get information about a specific Ollama model.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getOllamaModelInfo(modelName: string, baseURL?: string): Promise<OllamaModelInfo | null>;
|
|
59
|
+
/**
|
|
60
|
+
* Delete a model from Ollama.
|
|
61
|
+
*/
|
|
62
|
+
export declare function deleteOllamaModel(modelName: string, baseURL?: string): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* Generate embeddings using Ollama.
|
|
65
|
+
* Uses the /api/embed endpoint which supports batch processing.
|
|
66
|
+
*
|
|
67
|
+
* Note: Reserved for future RAG/vector search functionality.
|
|
68
|
+
*/
|
|
69
|
+
export declare function generateOllamaEmbeddings(modelName: string, input: string | string[], baseURL?: string): Promise<number[][]>;
|
|
70
|
+
//# sourceMappingURL=ollama-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama-provider.d.ts","sourceRoot":"","sources":["../../../../src/llm/providers/local/ollama-provider.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGhE;;GAEG;AACH,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACnC,OAAO,GAAE,MAA2B,GACrC,OAAO,CAAC,YAAY,CAAC,CAiDvB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAClC,OAAO,GAAE,MAA2B,GACrC,OAAO,CAAC,eAAe,EAAE,CAAC,CAmD5B;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAA2B,GACrC,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAA2B,EACpC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,EACvF,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,IAAI,CAAC,CAkEf;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,YAAiB,GAAG,aAAa,CAU7F;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC5C,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,YAAiB,GAC1B,OAAO,CAAC,aAAa,CAAC,CAgBxB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACpC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAA2B,GACrC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAUjC;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACnC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAA2B,GACrC,OAAO,CAAC,OAAO,CAAC,CAYlB;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC1C,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,MAA2B,GACrC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAmBrB"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import "../../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
3
|
+
import { LocalModelError } from "./errors.js";
|
|
4
|
+
const DEFAULT_OLLAMA_URL = "http://localhost:11434";
|
|
5
|
+
async function checkOllamaStatus(baseURL = DEFAULT_OLLAMA_URL) {
|
|
6
|
+
try {
|
|
7
|
+
const controller = new AbortController();
|
|
8
|
+
const timeoutId = setTimeout(() => controller.abort(), 5e3);
|
|
9
|
+
const response = await fetch(`${baseURL}/api/version`, {
|
|
10
|
+
signal: controller.signal
|
|
11
|
+
});
|
|
12
|
+
clearTimeout(timeoutId);
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
return {
|
|
15
|
+
running: false,
|
|
16
|
+
url: baseURL,
|
|
17
|
+
error: `HTTP ${response.status}: ${response.statusText}`
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const data = await response.json();
|
|
21
|
+
const models = await listOllamaModels(baseURL);
|
|
22
|
+
const status = {
|
|
23
|
+
running: true,
|
|
24
|
+
url: baseURL,
|
|
25
|
+
models
|
|
26
|
+
};
|
|
27
|
+
if (data.version) {
|
|
28
|
+
status.version = data.version;
|
|
29
|
+
}
|
|
30
|
+
return status;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
const errorMessage = error instanceof Error ? error.name === "AbortError" ? "Connection timed out" : error.message : "Unknown error";
|
|
33
|
+
return {
|
|
34
|
+
running: false,
|
|
35
|
+
url: baseURL,
|
|
36
|
+
error: errorMessage
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function listOllamaModels(baseURL = DEFAULT_OLLAMA_URL) {
|
|
41
|
+
try {
|
|
42
|
+
const response = await fetch(`${baseURL}/api/tags`);
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
const data = await response.json();
|
|
47
|
+
return (data.models ?? []).map((model) => {
|
|
48
|
+
const modelInfo = {
|
|
49
|
+
name: model.name,
|
|
50
|
+
size: model.size,
|
|
51
|
+
digest: model.digest,
|
|
52
|
+
modifiedAt: model.modified_at
|
|
53
|
+
};
|
|
54
|
+
if (model.details) {
|
|
55
|
+
const details = {};
|
|
56
|
+
if (model.details.family) {
|
|
57
|
+
details.family = model.details.family;
|
|
58
|
+
}
|
|
59
|
+
if (model.details.parameter_size) {
|
|
60
|
+
details.parameterSize = model.details.parameter_size;
|
|
61
|
+
}
|
|
62
|
+
if (model.details.quantization_level) {
|
|
63
|
+
details.quantizationLevel = model.details.quantization_level;
|
|
64
|
+
}
|
|
65
|
+
if (Object.keys(details).length > 0) {
|
|
66
|
+
modelInfo.details = details;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return modelInfo;
|
|
70
|
+
});
|
|
71
|
+
} catch {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function isOllamaModelAvailable(modelName, baseURL = DEFAULT_OLLAMA_URL) {
|
|
76
|
+
const models = await listOllamaModels(baseURL);
|
|
77
|
+
return models.some(
|
|
78
|
+
(m) => m.name === modelName || m.name.startsWith(`${modelName}:`) || modelName.startsWith(`${m.name}:`)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
async function pullOllamaModel(modelName, baseURL = DEFAULT_OLLAMA_URL, onProgress, signal) {
|
|
82
|
+
try {
|
|
83
|
+
const fetchOptions = {
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: { "Content-Type": "application/json" },
|
|
86
|
+
body: JSON.stringify({ name: modelName })
|
|
87
|
+
};
|
|
88
|
+
if (signal) {
|
|
89
|
+
fetchOptions.signal = signal;
|
|
90
|
+
}
|
|
91
|
+
const response = await fetch(`${baseURL}/api/pull`, fetchOptions);
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
throw LocalModelError.ollamaPullFailed(
|
|
94
|
+
modelName,
|
|
95
|
+
`HTTP ${response.status}: ${response.statusText}`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const reader = response.body?.getReader();
|
|
99
|
+
if (!reader) {
|
|
100
|
+
throw LocalModelError.ollamaPullFailed(modelName, "No response body");
|
|
101
|
+
}
|
|
102
|
+
const decoder = new TextDecoder();
|
|
103
|
+
let buffer = "";
|
|
104
|
+
while (true) {
|
|
105
|
+
const { done, value } = await reader.read();
|
|
106
|
+
if (done) break;
|
|
107
|
+
buffer += decoder.decode(value, { stream: true });
|
|
108
|
+
const lines = buffer.split("\n");
|
|
109
|
+
buffer = lines.pop() || "";
|
|
110
|
+
for (const line of lines) {
|
|
111
|
+
if (!line.trim()) continue;
|
|
112
|
+
try {
|
|
113
|
+
const progress = JSON.parse(line);
|
|
114
|
+
if (progress.error) {
|
|
115
|
+
throw LocalModelError.ollamaPullFailed(modelName, progress.error);
|
|
116
|
+
}
|
|
117
|
+
onProgress?.(progress);
|
|
118
|
+
} catch (e) {
|
|
119
|
+
if (e instanceof Error && e.message.includes("ollamaPullFailed")) {
|
|
120
|
+
throw e;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (error instanceof Error && error.message.includes("ECONNREFUSED")) {
|
|
127
|
+
throw LocalModelError.ollamaNotRunning(baseURL);
|
|
128
|
+
}
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function createOllamaModel(modelName, config = {}) {
|
|
133
|
+
const { baseURL = DEFAULT_OLLAMA_URL } = config;
|
|
134
|
+
const openai = createOpenAI({
|
|
135
|
+
baseURL: `${baseURL}/v1`,
|
|
136
|
+
apiKey: "ollama"
|
|
137
|
+
// Ollama doesn't require an API key, but the SDK requires a non-empty string
|
|
138
|
+
});
|
|
139
|
+
return openai(modelName);
|
|
140
|
+
}
|
|
141
|
+
async function createValidatedOllamaModel(modelName, config = {}) {
|
|
142
|
+
const { baseURL = DEFAULT_OLLAMA_URL } = config;
|
|
143
|
+
const status = await checkOllamaStatus(baseURL);
|
|
144
|
+
if (!status.running) {
|
|
145
|
+
throw LocalModelError.ollamaNotRunning(baseURL);
|
|
146
|
+
}
|
|
147
|
+
const isAvailable = await isOllamaModelAvailable(modelName, baseURL);
|
|
148
|
+
if (!isAvailable) {
|
|
149
|
+
throw LocalModelError.ollamaModelNotFound(modelName);
|
|
150
|
+
}
|
|
151
|
+
return createOllamaModel(modelName, config);
|
|
152
|
+
}
|
|
153
|
+
async function getOllamaModelInfo(modelName, baseURL = DEFAULT_OLLAMA_URL) {
|
|
154
|
+
const models = await listOllamaModels(baseURL);
|
|
155
|
+
return models.find(
|
|
156
|
+
(m) => m.name === modelName || m.name.startsWith(`${modelName}:`) || modelName.startsWith(`${m.name}:`)
|
|
157
|
+
) ?? null;
|
|
158
|
+
}
|
|
159
|
+
async function deleteOllamaModel(modelName, baseURL = DEFAULT_OLLAMA_URL) {
|
|
160
|
+
try {
|
|
161
|
+
const response = await fetch(`${baseURL}/api/delete`, {
|
|
162
|
+
method: "DELETE",
|
|
163
|
+
headers: { "Content-Type": "application/json" },
|
|
164
|
+
body: JSON.stringify({ name: modelName })
|
|
165
|
+
});
|
|
166
|
+
return response.ok;
|
|
167
|
+
} catch {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function generateOllamaEmbeddings(modelName, input, baseURL = DEFAULT_OLLAMA_URL) {
|
|
172
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
173
|
+
const response = await fetch(`${baseURL}/api/embed`, {
|
|
174
|
+
method: "POST",
|
|
175
|
+
headers: { "Content-Type": "application/json" },
|
|
176
|
+
body: JSON.stringify({
|
|
177
|
+
model: modelName,
|
|
178
|
+
input: inputs
|
|
179
|
+
})
|
|
180
|
+
});
|
|
181
|
+
if (!response.ok) {
|
|
182
|
+
throw LocalModelError.ollamaApiError(`HTTP ${response.status}: ${response.statusText}`);
|
|
183
|
+
}
|
|
184
|
+
const data = await response.json();
|
|
185
|
+
return data.embeddings;
|
|
186
|
+
}
|
|
187
|
+
export {
|
|
188
|
+
DEFAULT_OLLAMA_URL,
|
|
189
|
+
checkOllamaStatus,
|
|
190
|
+
createOllamaModel,
|
|
191
|
+
createValidatedOllamaModel,
|
|
192
|
+
deleteOllamaModel,
|
|
193
|
+
generateOllamaEmbeddings,
|
|
194
|
+
getOllamaModelInfo,
|
|
195
|
+
isOllamaModelAvailable,
|
|
196
|
+
listOllamaModels,
|
|
197
|
+
pullOllamaModel
|
|
198
|
+
};
|