@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
|
@@ -12,20 +12,89 @@ class PostgresStore {
|
|
|
12
12
|
logger;
|
|
13
13
|
async connect() {
|
|
14
14
|
if (this.connected) return;
|
|
15
|
+
const connectionString = this.config.connectionString || this.config.url;
|
|
16
|
+
if (connectionString?.startsWith("$")) {
|
|
17
|
+
throw StorageError.connectionFailed(
|
|
18
|
+
`PostgreSQL: Connection string contains unexpanded environment variable: ${connectionString}. Ensure the environment variable is set in your .env file.`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (!connectionString) {
|
|
22
|
+
throw StorageError.connectionFailed(
|
|
23
|
+
"PostgreSQL: No connection string provided. Set url or connectionString in database config."
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const { schema, ...pgOptions } = this.config.options || {};
|
|
27
|
+
this.logger.info("Connecting to PostgreSQL database...");
|
|
15
28
|
this.pool = new Pool({
|
|
16
|
-
connectionString
|
|
29
|
+
connectionString,
|
|
17
30
|
max: this.config.maxConnections || 20,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
// Shorter idle timeout for serverless DBs (Neon) - connections go stale quickly
|
|
32
|
+
idleTimeoutMillis: this.config.idleTimeoutMillis || 1e4,
|
|
33
|
+
connectionTimeoutMillis: this.config.connectionTimeoutMillis || 1e4,
|
|
34
|
+
// Enable TCP keepalive to detect dead connections
|
|
35
|
+
keepAlive: true,
|
|
36
|
+
keepAliveInitialDelayMillis: 1e4,
|
|
37
|
+
...pgOptions
|
|
21
38
|
});
|
|
22
|
-
|
|
39
|
+
this.pool.on("error", (err) => {
|
|
40
|
+
this.logger.warn(`PostgreSQL pool error (will retry on next query): ${err.message}`);
|
|
41
|
+
});
|
|
42
|
+
if (schema) {
|
|
43
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(schema)) {
|
|
44
|
+
throw StorageError.connectionFailed(
|
|
45
|
+
`PostgreSQL: Invalid schema name "${schema}". Schema names must start with a letter or underscore and contain only alphanumeric characters and underscores.`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
this.pool.on("connect", async (client2) => {
|
|
49
|
+
try {
|
|
50
|
+
await client2.query(`SET search_path TO "${schema}", public`);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
this.logger.error(`Failed to set search_path to "${schema}": ${err}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
this.logger.info(`Using custom schema: "${schema}"`);
|
|
56
|
+
}
|
|
57
|
+
let client;
|
|
23
58
|
try {
|
|
59
|
+
client = await this.pool.connect();
|
|
24
60
|
await client.query("SELECT NOW()");
|
|
61
|
+
if (schema) {
|
|
62
|
+
await this.createSchema(client, schema);
|
|
63
|
+
}
|
|
25
64
|
await this.createTables(client);
|
|
26
65
|
this.connected = true;
|
|
66
|
+
this.logger.info("PostgreSQL database connected successfully");
|
|
67
|
+
} catch (error) {
|
|
68
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
69
|
+
this.logger.error(`PostgreSQL connection failed: ${errorMessage}`);
|
|
70
|
+
if (this.pool) {
|
|
71
|
+
await this.pool.end().catch(() => {
|
|
72
|
+
});
|
|
73
|
+
this.pool = null;
|
|
74
|
+
}
|
|
75
|
+
throw StorageError.connectionFailed(`PostgreSQL: ${errorMessage}`);
|
|
27
76
|
} finally {
|
|
28
|
-
client
|
|
77
|
+
if (client) {
|
|
78
|
+
client.release();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Creates a PostgreSQL schema if it doesn't exist.
|
|
84
|
+
*/
|
|
85
|
+
async createSchema(client, schemaName) {
|
|
86
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(schemaName)) {
|
|
87
|
+
throw StorageError.connectionFailed(
|
|
88
|
+
`PostgreSQL: Invalid schema name "${schemaName}". Schema names must start with a letter or underscore and contain only alphanumeric characters and underscores.`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
await client.query(`CREATE SCHEMA IF NOT EXISTS "${schemaName}"`);
|
|
93
|
+
this.logger.debug(`Schema "${schemaName}" ready`);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
this.logger.warn(
|
|
96
|
+
`Could not create schema "${schemaName}": ${error}. Assuming it exists.`
|
|
97
|
+
);
|
|
29
98
|
}
|
|
30
99
|
}
|
|
31
100
|
async disconnect() {
|
|
@@ -41,61 +110,54 @@ class PostgresStore {
|
|
|
41
110
|
getStoreType() {
|
|
42
111
|
return "postgres";
|
|
43
112
|
}
|
|
44
|
-
// Core operations
|
|
113
|
+
// Core operations - all use withRetry for serverless DB resilience
|
|
45
114
|
async get(key) {
|
|
46
|
-
this.checkConnection();
|
|
47
|
-
const client = await this.pool.connect();
|
|
48
115
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
116
|
+
return await this.withRetry("get", async (client) => {
|
|
117
|
+
const result = await client.query("SELECT value FROM kv WHERE key = $1", [key]);
|
|
118
|
+
return result.rows[0] ? result.rows[0].value : void 0;
|
|
119
|
+
});
|
|
51
120
|
} catch (error) {
|
|
52
121
|
throw StorageError.readFailed(
|
|
53
122
|
"get",
|
|
54
123
|
error instanceof Error ? error.message : String(error),
|
|
55
124
|
{ key }
|
|
56
125
|
);
|
|
57
|
-
} finally {
|
|
58
|
-
client.release();
|
|
59
126
|
}
|
|
60
127
|
}
|
|
61
128
|
async set(key, value) {
|
|
62
|
-
this.checkConnection();
|
|
63
|
-
const client = await this.pool.connect();
|
|
64
129
|
try {
|
|
65
|
-
await
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
130
|
+
await this.withRetry("set", async (client) => {
|
|
131
|
+
const jsonValue = JSON.stringify(value);
|
|
132
|
+
await client.query(
|
|
133
|
+
"INSERT INTO kv (key, value, updated_at) VALUES ($1, $2::jsonb, $3) ON CONFLICT (key) DO UPDATE SET value = $2::jsonb, updated_at = $3",
|
|
134
|
+
[key, jsonValue, /* @__PURE__ */ new Date()]
|
|
135
|
+
);
|
|
136
|
+
});
|
|
69
137
|
} catch (error) {
|
|
70
138
|
throw StorageError.writeFailed(
|
|
71
139
|
"set",
|
|
72
140
|
error instanceof Error ? error.message : String(error),
|
|
73
141
|
{ key }
|
|
74
142
|
);
|
|
75
|
-
} finally {
|
|
76
|
-
client.release();
|
|
77
143
|
}
|
|
78
144
|
}
|
|
79
145
|
async delete(key) {
|
|
80
|
-
this.
|
|
81
|
-
const client = await this.pool.connect();
|
|
82
|
-
try {
|
|
146
|
+
await this.withRetry("delete", async (client) => {
|
|
83
147
|
await client.query("BEGIN");
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
148
|
+
try {
|
|
149
|
+
await client.query("DELETE FROM kv WHERE key = $1", [key]);
|
|
150
|
+
await client.query("DELETE FROM lists WHERE key = $1", [key]);
|
|
151
|
+
await client.query("COMMIT");
|
|
152
|
+
} catch (error) {
|
|
153
|
+
await client.query("ROLLBACK");
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
93
157
|
}
|
|
94
158
|
// List operations
|
|
95
159
|
async list(prefix) {
|
|
96
|
-
this.
|
|
97
|
-
const client = await this.pool.connect();
|
|
98
|
-
try {
|
|
160
|
+
return await this.withRetry("list", async (client) => {
|
|
99
161
|
const kvResult = await client.query("SELECT key FROM kv WHERE key LIKE $1", [
|
|
100
162
|
`${prefix}%`
|
|
101
163
|
]);
|
|
@@ -108,41 +170,33 @@ class PostgresStore {
|
|
|
108
170
|
...listResult.rows.map((row) => row.key)
|
|
109
171
|
]);
|
|
110
172
|
return Array.from(allKeys).sort();
|
|
111
|
-
}
|
|
112
|
-
client.release();
|
|
113
|
-
}
|
|
173
|
+
});
|
|
114
174
|
}
|
|
115
175
|
async append(key, item) {
|
|
116
|
-
this.checkConnection();
|
|
117
|
-
const client = await this.pool.connect();
|
|
118
176
|
try {
|
|
119
|
-
await
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
177
|
+
await this.withRetry("append", async (client) => {
|
|
178
|
+
const jsonItem = JSON.stringify(item);
|
|
179
|
+
await client.query(
|
|
180
|
+
"INSERT INTO lists (key, item, created_at) VALUES ($1, $2::jsonb, $3)",
|
|
181
|
+
[key, jsonItem, /* @__PURE__ */ new Date()]
|
|
182
|
+
);
|
|
183
|
+
});
|
|
124
184
|
} catch (error) {
|
|
125
185
|
throw StorageError.writeFailed(
|
|
126
186
|
"append",
|
|
127
187
|
error instanceof Error ? error.message : String(error),
|
|
128
188
|
{ key }
|
|
129
189
|
);
|
|
130
|
-
} finally {
|
|
131
|
-
client.release();
|
|
132
190
|
}
|
|
133
191
|
}
|
|
134
192
|
async getRange(key, start, count) {
|
|
135
|
-
this.
|
|
136
|
-
const client = await this.pool.connect();
|
|
137
|
-
try {
|
|
193
|
+
return await this.withRetry("getRange", async (client) => {
|
|
138
194
|
const result = await client.query(
|
|
139
195
|
"SELECT item FROM lists WHERE key = $1 ORDER BY created_at ASC LIMIT $2 OFFSET $3",
|
|
140
196
|
[key, count, start]
|
|
141
197
|
);
|
|
142
198
|
return result.rows.map((row) => row.item);
|
|
143
|
-
}
|
|
144
|
-
client.release();
|
|
145
|
-
}
|
|
199
|
+
});
|
|
146
200
|
}
|
|
147
201
|
// Schema management
|
|
148
202
|
async createTables(client) {
|
|
@@ -172,26 +226,74 @@ class PostgresStore {
|
|
|
172
226
|
throw StorageError.notConnected("PostgresStore");
|
|
173
227
|
}
|
|
174
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Check if an error is a connection error that should trigger a retry.
|
|
231
|
+
* Common with serverless databases (Neon) where connections go stale.
|
|
232
|
+
*/
|
|
233
|
+
isConnectionError(error) {
|
|
234
|
+
if (!(error instanceof Error)) return false;
|
|
235
|
+
const code = error.code;
|
|
236
|
+
return code === "ETIMEDOUT" || code === "ECONNRESET" || code === "ECONNREFUSED" || code === "EPIPE" || code === "57P01" || // admin_shutdown
|
|
237
|
+
code === "57P02" || // crash_shutdown
|
|
238
|
+
code === "57P03" || // cannot_connect_now
|
|
239
|
+
error.message.includes("Connection terminated") || error.message.includes("connection lost");
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Execute a database operation with automatic retry on connection errors.
|
|
243
|
+
* Handles serverless DB connection issues (Neon cold starts, stale connections).
|
|
244
|
+
*/
|
|
245
|
+
async withRetry(operation, fn, maxRetries = 2) {
|
|
246
|
+
this.checkConnection();
|
|
247
|
+
let lastError;
|
|
248
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
249
|
+
let client;
|
|
250
|
+
try {
|
|
251
|
+
client = await this.pool.connect();
|
|
252
|
+
const result = await fn(client);
|
|
253
|
+
return result;
|
|
254
|
+
} catch (error) {
|
|
255
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
256
|
+
if (client) {
|
|
257
|
+
client.release(true);
|
|
258
|
+
client = void 0;
|
|
259
|
+
}
|
|
260
|
+
if (this.isConnectionError(error) && attempt < maxRetries) {
|
|
261
|
+
this.logger.warn(
|
|
262
|
+
`PostgreSQL ${operation} failed with connection error (attempt ${attempt + 1}/${maxRetries + 1}): ${lastError.message}. Retrying...`
|
|
263
|
+
);
|
|
264
|
+
await new Promise((resolve) => setTimeout(resolve, 100 * (attempt + 1)));
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
throw error;
|
|
268
|
+
} finally {
|
|
269
|
+
if (client) {
|
|
270
|
+
client.release();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
throw lastError;
|
|
275
|
+
}
|
|
175
276
|
// Advanced operations
|
|
277
|
+
/**
|
|
278
|
+
* Execute a callback within a database transaction.
|
|
279
|
+
* Note: On connection failure, the entire callback will be retried on a new connection.
|
|
280
|
+
* Ensure callback operations are idempotent or use this only for read operations.
|
|
281
|
+
*/
|
|
176
282
|
async transaction(callback) {
|
|
177
|
-
this.
|
|
178
|
-
const client = await this.pool.connect();
|
|
179
|
-
try {
|
|
283
|
+
return await this.withRetry("transaction", async (client) => {
|
|
180
284
|
await client.query("BEGIN");
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
285
|
+
try {
|
|
286
|
+
const result = await callback(client);
|
|
287
|
+
await client.query("COMMIT");
|
|
288
|
+
return result;
|
|
289
|
+
} catch (error) {
|
|
290
|
+
await client.query("ROLLBACK");
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
});
|
|
190
294
|
}
|
|
191
295
|
async getStats() {
|
|
192
|
-
this.
|
|
193
|
-
const client = await this.pool.connect();
|
|
194
|
-
try {
|
|
296
|
+
return await this.withRetry("getStats", async (client) => {
|
|
195
297
|
const kvResult = await client.query("SELECT COUNT(*) as count FROM kv");
|
|
196
298
|
const listResult = await client.query("SELECT COUNT(*) as count FROM lists");
|
|
197
299
|
const sizeResult = await client.query(
|
|
@@ -203,19 +305,13 @@ class PostgresStore {
|
|
|
203
305
|
listCount: parseInt(listResult.rows[0].count),
|
|
204
306
|
totalSize: sizeResult.rows[0].size
|
|
205
307
|
};
|
|
206
|
-
}
|
|
207
|
-
client.release();
|
|
208
|
-
}
|
|
308
|
+
});
|
|
209
309
|
}
|
|
210
310
|
// Maintenance operations
|
|
211
311
|
async vacuum() {
|
|
212
|
-
this.
|
|
213
|
-
const client = await this.pool.connect();
|
|
214
|
-
try {
|
|
312
|
+
await this.withRetry("vacuum", async (client) => {
|
|
215
313
|
await client.query("VACUUM ANALYZE kv, lists");
|
|
216
|
-
}
|
|
217
|
-
client.release();
|
|
218
|
-
}
|
|
314
|
+
});
|
|
219
315
|
}
|
|
220
316
|
}
|
|
221
317
|
export {
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var provider_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(provider_exports);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { Database } from './types.js';
|
|
3
|
+
import type { IDextoLogger } from '../../logger/v2/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Provider interface for creating database instances.
|
|
6
|
+
*
|
|
7
|
+
* This interface uses TypeScript generics to enforce type safety:
|
|
8
|
+
* - TType: The literal type string (e.g., 'sqlite', 'postgres')
|
|
9
|
+
* - TConfig: The configuration type with discriminator { type: TType }
|
|
10
|
+
*
|
|
11
|
+
* This ensures that the provider type matches the config type discriminator,
|
|
12
|
+
* providing compile-time safety for provider implementations.
|
|
13
|
+
*/
|
|
14
|
+
export interface DatabaseProvider<TType extends string = string, TConfig extends {
|
|
15
|
+
type: TType;
|
|
16
|
+
} = any> {
|
|
17
|
+
/**
|
|
18
|
+
* Unique identifier for this provider (e.g., 'sqlite', 'postgres', 'in-memory').
|
|
19
|
+
* Must match the 'type' field in the configuration.
|
|
20
|
+
*/
|
|
21
|
+
type: TType;
|
|
22
|
+
/**
|
|
23
|
+
* Zod schema for validating provider-specific configuration.
|
|
24
|
+
* The schema must output TConfig type.
|
|
25
|
+
*
|
|
26
|
+
* Note: Uses z.ZodType with relaxed generics to allow input/output type variance.
|
|
27
|
+
* This is necessary because Zod schemas with `.optional().default()` have
|
|
28
|
+
* input types that include undefined, but output types that don't.
|
|
29
|
+
*/
|
|
30
|
+
configSchema: z.ZodType<TConfig, any, any>;
|
|
31
|
+
/**
|
|
32
|
+
* Factory function to create a Database instance.
|
|
33
|
+
*
|
|
34
|
+
* Unlike blob store providers (which are sync), database providers may return
|
|
35
|
+
* a Promise to support lazy loading of optional dependencies (e.g., better-sqlite3, pg).
|
|
36
|
+
*
|
|
37
|
+
* @param config - Validated configuration specific to this provider
|
|
38
|
+
* @param logger - Logger instance for the database
|
|
39
|
+
* @returns A Database implementation (or Promise for async providers)
|
|
40
|
+
*/
|
|
41
|
+
create(config: TConfig, logger: IDextoLogger): Database | Promise<Database>;
|
|
42
|
+
/**
|
|
43
|
+
* Optional metadata for documentation, UIs, and discovery.
|
|
44
|
+
*/
|
|
45
|
+
metadata?: {
|
|
46
|
+
/** Human-readable name (e.g., "SQLite", "PostgreSQL") */
|
|
47
|
+
displayName: string;
|
|
48
|
+
/** Brief description of this storage backend */
|
|
49
|
+
description: string;
|
|
50
|
+
/** Whether this provider requires network connectivity */
|
|
51
|
+
requiresNetwork?: boolean;
|
|
52
|
+
/** Whether this provider supports list operations (append/getRange) */
|
|
53
|
+
supportsListOperations?: boolean;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/storage/database/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB,CAC7B,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,OAAO,SAAS;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GAAG,GAAG;IAErC;;;OAGG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;;;;;;OAOG;IACH,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE3C;;;;;;;;;OASG;IACH,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE5E;;OAEG;IACH,QAAQ,CAAC,EAAE;QACP,yDAAyD;QACzD,WAAW,EAAE,MAAM,CAAC;QACpB,gDAAgD;QAChD,WAAW,EAAE,MAAM,CAAC;QACpB,0DAA0D;QAC1D,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,uEAAuE;QACvE,sBAAsB,CAAC,EAAE,OAAO,CAAC;KACpC,CAAC;CACL"}
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
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 providers_exports = {};
|
|
20
|
+
__export(providers_exports, {
|
|
21
|
+
inMemoryDatabaseProvider: () => import_memory.inMemoryDatabaseProvider,
|
|
22
|
+
postgresDatabaseProvider: () => import_postgres.postgresDatabaseProvider,
|
|
23
|
+
sqliteDatabaseProvider: () => import_sqlite.sqliteDatabaseProvider
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(providers_exports);
|
|
26
|
+
var import_memory = require("./memory.js");
|
|
27
|
+
var import_sqlite = require("./sqlite.js");
|
|
28
|
+
var import_postgres = require("./postgres.js");
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
inMemoryDatabaseProvider,
|
|
32
|
+
postgresDatabaseProvider,
|
|
33
|
+
sqliteDatabaseProvider
|
|
34
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in database providers.
|
|
3
|
+
*
|
|
4
|
+
* These providers are automatically registered when importing from @dexto/core.
|
|
5
|
+
*/
|
|
6
|
+
export { inMemoryDatabaseProvider } from './memory.js';
|
|
7
|
+
export { sqliteDatabaseProvider } from './sqlite.js';
|
|
8
|
+
export { postgresDatabaseProvider } from './postgres.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/database/providers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { inMemoryDatabaseProvider } from "./memory.js";
|
|
3
|
+
import { sqliteDatabaseProvider } from "./sqlite.js";
|
|
4
|
+
import { postgresDatabaseProvider } from "./postgres.js";
|
|
5
|
+
export {
|
|
6
|
+
inMemoryDatabaseProvider,
|
|
7
|
+
postgresDatabaseProvider,
|
|
8
|
+
sqliteDatabaseProvider
|
|
9
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 memory_exports = {};
|
|
20
|
+
__export(memory_exports, {
|
|
21
|
+
inMemoryDatabaseProvider: () => inMemoryDatabaseProvider
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(memory_exports);
|
|
24
|
+
var import_schemas = require("../schemas.js");
|
|
25
|
+
var import_memory_database_store = require("../memory-database-store.js");
|
|
26
|
+
const inMemoryDatabaseProvider = {
|
|
27
|
+
type: "in-memory",
|
|
28
|
+
configSchema: import_schemas.InMemoryDatabaseSchema,
|
|
29
|
+
create: (_config, _logger) => new import_memory_database_store.MemoryDatabaseStore(),
|
|
30
|
+
metadata: {
|
|
31
|
+
displayName: "In-Memory",
|
|
32
|
+
description: "Store data in RAM (ephemeral, for testing and development)",
|
|
33
|
+
requiresNetwork: false,
|
|
34
|
+
supportsListOperations: true
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
inMemoryDatabaseProvider
|
|
40
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DatabaseProvider } from '../provider.js';
|
|
2
|
+
import type { InMemoryDatabaseConfig } from '../schemas.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provider for in-memory database storage.
|
|
5
|
+
*
|
|
6
|
+
* This provider stores data in RAM and is ideal for development,
|
|
7
|
+
* testing, and ephemeral use cases where persistence is not required.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Zero external dependencies
|
|
11
|
+
* - Fast in-memory operations
|
|
12
|
+
* - No network required
|
|
13
|
+
* - Data is lost on restart
|
|
14
|
+
*/
|
|
15
|
+
export declare const inMemoryDatabaseProvider: DatabaseProvider<'in-memory', InMemoryDatabaseConfig>;
|
|
16
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/storage/database/providers/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAI5D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,EAAE,gBAAgB,CAAC,WAAW,EAAE,sBAAsB,CAU1F,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "../../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { InMemoryDatabaseSchema } from "../schemas.js";
|
|
3
|
+
import { MemoryDatabaseStore } from "../memory-database-store.js";
|
|
4
|
+
const inMemoryDatabaseProvider = {
|
|
5
|
+
type: "in-memory",
|
|
6
|
+
configSchema: InMemoryDatabaseSchema,
|
|
7
|
+
create: (_config, _logger) => new MemoryDatabaseStore(),
|
|
8
|
+
metadata: {
|
|
9
|
+
displayName: "In-Memory",
|
|
10
|
+
description: "Store data in RAM (ephemeral, for testing and development)",
|
|
11
|
+
requiresNetwork: false,
|
|
12
|
+
supportsListOperations: true
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
inMemoryDatabaseProvider
|
|
17
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
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 postgres_exports = {};
|
|
30
|
+
__export(postgres_exports, {
|
|
31
|
+
postgresDatabaseProvider: () => postgresDatabaseProvider
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(postgres_exports);
|
|
34
|
+
var import_schemas = require("../schemas.js");
|
|
35
|
+
var import_errors = require("../../errors.js");
|
|
36
|
+
const postgresDatabaseProvider = {
|
|
37
|
+
type: "postgres",
|
|
38
|
+
configSchema: import_schemas.PostgresDatabaseSchema,
|
|
39
|
+
create: async (config, logger) => {
|
|
40
|
+
try {
|
|
41
|
+
const module2 = await import("../postgres-store.js");
|
|
42
|
+
logger.info("Connecting to PostgreSQL database");
|
|
43
|
+
return new module2.PostgresStore(config, logger);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
const err = error;
|
|
46
|
+
if (err.code === "ERR_MODULE_NOT_FOUND") {
|
|
47
|
+
throw import_errors.StorageError.dependencyNotInstalled("PostgreSQL", "pg", "npm install pg");
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
metadata: {
|
|
53
|
+
displayName: "PostgreSQL",
|
|
54
|
+
description: "Production PostgreSQL database with connection pooling",
|
|
55
|
+
requiresNetwork: true,
|
|
56
|
+
supportsListOperations: true
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
postgresDatabaseProvider
|
|
62
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DatabaseProvider } from '../provider.js';
|
|
2
|
+
import type { PostgresDatabaseConfig } from '../schemas.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provider for PostgreSQL database storage.
|
|
5
|
+
*
|
|
6
|
+
* This provider stores data in a PostgreSQL database server using the pg package.
|
|
7
|
+
* It's ideal for production deployments requiring scalability and multi-machine access.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Connection pooling for efficient resource usage
|
|
11
|
+
* - JSONB storage for flexible data types
|
|
12
|
+
* - Transaction support
|
|
13
|
+
* - Suitable for distributed deployments
|
|
14
|
+
*
|
|
15
|
+
* Note: pg is an optional dependency. Install it with:
|
|
16
|
+
* npm install pg
|
|
17
|
+
*/
|
|
18
|
+
export declare const postgresDatabaseProvider: DatabaseProvider<'postgres', PostgresDatabaseConfig>;
|
|
19
|
+
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../../src/storage/database/providers/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAI5D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,EAAE,gBAAgB,CAAC,UAAU,EAAE,sBAAsB,CAsBzF,CAAC"}
|