@dexto/core 1.5.7 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -8
- package/dist/agent/DextoAgent.cjs +383 -153
- package/dist/agent/DextoAgent.d.ts +112 -60
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +380 -150
- package/dist/{context/compaction/provider.cjs → agent/agent-options.cjs} +2 -2
- package/dist/agent/agent-options.d.ts +53 -0
- package/dist/agent/agent-options.d.ts.map +1 -0
- package/dist/agent/agentCard.cjs +1 -1
- package/dist/agent/errors.cjs +2 -2
- package/dist/agent/errors.d.ts.map +1 -1
- package/dist/agent/index.cjs +1 -6
- package/dist/agent/index.d.ts +3 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +1 -7
- package/dist/{storage/blob/provider.cjs → agent/runtime-config.cjs} +2 -2
- package/dist/agent/runtime-config.d.ts +53 -0
- package/dist/agent/runtime-config.d.ts.map +1 -0
- package/dist/agent/schemas.cjs +2 -99
- package/dist/agent/schemas.d.ts +10 -9160
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/agent/schemas.js +1 -104
- package/dist/agent/state-manager.d.ts +5 -5
- package/dist/agent/state-manager.d.ts.map +1 -1
- package/dist/approval/error-codes.cjs +1 -1
- package/dist/approval/error-codes.d.ts +1 -1
- package/dist/approval/error-codes.d.ts.map +1 -1
- package/dist/approval/error-codes.js +1 -1
- package/dist/approval/errors.cjs +5 -5
- package/dist/approval/errors.d.ts +2 -2
- package/dist/approval/errors.d.ts.map +1 -1
- package/dist/approval/errors.js +5 -5
- package/dist/approval/index.cjs +8 -8
- package/dist/approval/index.d.ts +2 -2
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +8 -8
- package/dist/approval/manager.cjs +77 -57
- package/dist/approval/manager.d.ts +41 -43
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +75 -55
- package/dist/approval/schemas.cjs +26 -25
- package/dist/approval/schemas.d.ts +35 -15
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +22 -21
- package/dist/approval/types.cjs +1 -1
- package/dist/approval/types.d.ts +14 -14
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +1 -1
- package/dist/context/compaction/index.cjs +2 -23
- package/dist/context/compaction/index.d.ts +1 -7
- package/dist/context/compaction/index.d.ts.map +1 -1
- package/dist/context/compaction/index.js +1 -16
- package/dist/context/compaction/strategies/noop.cjs +19 -1
- package/dist/context/compaction/strategies/noop.d.ts +13 -3
- package/dist/context/compaction/strategies/noop.d.ts.map +1 -1
- package/dist/context/compaction/strategies/noop.js +19 -1
- package/dist/context/compaction/strategies/{reactive-overflow.cjs → reactive-overflow-compaction.cjs} +67 -64
- package/dist/context/compaction/strategies/{reactive-overflow.d.ts → reactive-overflow-compaction.d.ts} +19 -36
- package/dist/context/compaction/strategies/reactive-overflow-compaction.d.ts.map +1 -0
- package/dist/context/compaction/strategies/{reactive-overflow.js → reactive-overflow-compaction.js} +63 -60
- package/dist/context/compaction/types.d.ts +40 -8
- package/dist/context/compaction/types.d.ts.map +1 -1
- package/dist/context/manager.cjs +5 -3
- package/dist/context/manager.d.ts +4 -3
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +5 -3
- package/dist/context/types.d.ts +2 -0
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/utils.cjs +70 -43
- package/dist/context/utils.d.ts +14 -14
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +69 -42
- package/dist/errors/result-bridge.d.ts +2 -2
- package/dist/errors/result-bridge.d.ts.map +1 -1
- package/dist/errors/types.cjs +1 -1
- package/dist/errors/types.d.ts +3 -3
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/errors/types.js +1 -1
- package/dist/events/index.cjs +15 -2
- package/dist/events/index.d.ts +78 -7
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +15 -2
- package/dist/{plugins → hooks}/builtins/content-policy.cjs +7 -6
- package/dist/hooks/builtins/content-policy.d.ts +24 -0
- package/dist/hooks/builtins/content-policy.d.ts.map +1 -0
- package/dist/{plugins → hooks}/builtins/content-policy.js +6 -5
- package/dist/{plugins → hooks}/builtins/response-sanitizer.cjs +3 -3
- package/dist/hooks/builtins/response-sanitizer.d.ts +22 -0
- package/dist/hooks/builtins/response-sanitizer.d.ts.map +1 -0
- package/dist/{plugins → hooks}/builtins/response-sanitizer.js +2 -2
- package/dist/hooks/error-codes.cjs +43 -0
- package/dist/hooks/error-codes.d.ts +34 -0
- package/dist/hooks/error-codes.d.ts.map +1 -0
- package/dist/hooks/error-codes.js +20 -0
- package/dist/{storage/cache/providers/memory.cjs → hooks/index.cjs} +15 -18
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/manager.cjs +354 -0
- package/dist/hooks/manager.d.ts +103 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +331 -0
- package/dist/{plugins → hooks}/types.d.ts +36 -34
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/index.browser.cjs +13 -12
- package/dist/index.browser.d.ts +6 -6
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +8 -7
- package/dist/index.cjs +5 -7
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/llm/curation-config.cjs +82 -0
- package/dist/llm/curation-config.d.ts +13 -0
- package/dist/llm/curation-config.d.ts.map +1 -0
- package/dist/llm/curation-config.js +59 -0
- package/dist/llm/curation.cjs +57 -0
- package/dist/llm/curation.d.ts +16 -0
- package/dist/llm/curation.d.ts.map +1 -0
- package/dist/llm/curation.js +34 -0
- package/dist/llm/errors.cjs +2 -2
- package/dist/llm/errors.d.ts +8 -8
- package/dist/llm/errors.js +1 -1
- package/dist/llm/executor/provider-options.cjs +1 -1
- package/dist/llm/executor/provider-options.js +1 -1
- package/dist/llm/executor/stream-processor.cjs +131 -11
- package/dist/llm/executor/stream-processor.d.ts +7 -5
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +131 -11
- package/dist/llm/executor/turn-executor.cjs +57 -56
- package/dist/llm/executor/turn-executor.d.ts +7 -8
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +57 -56
- package/dist/llm/formatters/vercel.cjs +2 -2
- package/dist/llm/formatters/vercel.d.ts +2 -2
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/index.cjs +14 -3
- package/dist/llm/index.d.ts +3 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +13 -2
- package/dist/llm/providers/local/schemas.d.ts +10 -10
- package/dist/llm/registry/auto-update.cjs +263 -0
- package/dist/llm/registry/auto-update.d.ts +27 -0
- package/dist/llm/registry/auto-update.d.ts.map +1 -0
- package/dist/llm/registry/auto-update.js +227 -0
- package/dist/llm/registry/index.cjs +806 -0
- package/dist/llm/{registry.d.ts → registry/index.d.ts} +21 -43
- package/dist/llm/registry/index.d.ts.map +1 -0
- package/dist/llm/registry/index.js +756 -0
- package/dist/llm/registry/models.generated.cjs +4861 -0
- package/dist/llm/registry/models.generated.d.ts +431 -0
- package/dist/llm/registry/models.generated.d.ts.map +1 -0
- package/dist/llm/registry/models.generated.js +4838 -0
- package/dist/{storage/database/providers/index.cjs → llm/registry/models.manual.cjs} +22 -12
- package/dist/llm/registry/models.manual.d.ts +22 -0
- package/dist/llm/registry/models.manual.d.ts.map +1 -0
- package/dist/llm/registry/models.manual.js +21 -0
- package/dist/llm/registry/sync.cjs +354 -0
- package/dist/llm/registry/sync.d.ts +41 -0
- package/dist/llm/registry/sync.d.ts.map +1 -0
- package/dist/llm/registry/sync.js +328 -0
- package/dist/llm/resolver.cjs +29 -20
- package/dist/llm/resolver.d.ts +4 -4
- package/dist/llm/resolver.d.ts.map +1 -1
- package/dist/llm/resolver.js +28 -20
- package/dist/llm/schemas.cjs +69 -94
- package/dist/llm/schemas.d.ts +19 -158
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +67 -91
- package/dist/llm/services/factory.cjs +6 -7
- package/dist/llm/services/factory.d.ts +3 -4
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +6 -7
- package/dist/llm/services/vercel.cjs +11 -15
- package/dist/llm/services/vercel.d.ts +7 -7
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +11 -15
- package/dist/llm/types.cjs +1 -1
- package/dist/llm/types.d.ts +1 -1
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js +1 -1
- package/dist/llm/validation.cjs +2 -2
- package/dist/llm/validation.d.ts +2 -2
- package/dist/llm/validation.d.ts.map +1 -1
- package/dist/llm/validation.js +1 -1
- package/dist/logger/browser.cjs +4 -4
- package/dist/logger/browser.d.ts +4 -4
- package/dist/logger/browser.d.ts.map +1 -1
- package/dist/logger/browser.js +3 -3
- package/dist/{context/compaction/providers/noop-provider.cjs → logger/default-logger-factory.cjs} +16 -22
- package/dist/logger/default-logger-factory.d.ts +301 -0
- package/dist/logger/default-logger-factory.d.ts.map +1 -0
- package/dist/logger/default-logger-factory.js +18 -0
- package/dist/logger/factory.d.ts +2 -2
- package/dist/logger/factory.d.ts.map +1 -1
- package/dist/logger/index.cjs +7 -2
- package/dist/logger/index.d.ts +5 -3
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +8 -2
- package/dist/logger/logger.cjs +4 -4
- package/dist/logger/logger.d.ts +4 -4
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +3 -3
- package/dist/logger/v2/dexto-logger.d.ts +3 -3
- package/dist/logger/v2/dexto-logger.d.ts.map +1 -1
- package/dist/logger/v2/schemas.d.ts +12 -12
- package/dist/logger/v2/test-utils.d.ts +5 -5
- package/dist/logger/v2/test-utils.d.ts.map +1 -1
- package/dist/logger/v2/transport-factory.d.ts +3 -3
- package/dist/logger/v2/transport-factory.d.ts.map +1 -1
- package/dist/logger/v2/transports/console-transport.d.ts +2 -2
- package/dist/logger/v2/transports/console-transport.d.ts.map +1 -1
- package/dist/logger/v2/transports/file-transport.d.ts +2 -2
- package/dist/logger/v2/transports/file-transport.d.ts.map +1 -1
- package/dist/logger/v2/transports/silent-transport.d.ts +2 -2
- package/dist/logger/v2/transports/silent-transport.d.ts.map +1 -1
- package/dist/logger/v2/types.cjs +1 -1
- package/dist/logger/v2/types.d.ts +8 -8
- package/dist/logger/v2/types.d.ts.map +1 -1
- package/dist/logger/v2/types.js +1 -1
- package/dist/mcp/errors.cjs +2 -2
- package/dist/mcp/errors.d.ts.map +1 -1
- package/dist/mcp/manager.cjs +16 -11
- package/dist/mcp/manager.d.ts +16 -13
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +17 -12
- package/dist/mcp/mcp-client.cjs +25 -20
- package/dist/mcp/mcp-client.d.ts +5 -5
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +20 -15
- package/dist/mcp/resolver.cjs +1 -1
- package/dist/mcp/schemas.cjs +5 -5
- package/dist/mcp/schemas.d.ts +4 -4
- package/dist/mcp/schemas.js +2 -2
- package/dist/mcp/types.d.ts +7 -7
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/memory/manager.d.ts +2 -2
- package/dist/memory/manager.d.ts.map +1 -1
- package/dist/memory/schemas.d.ts +2 -2
- package/dist/prompts/errors.cjs +3 -3
- package/dist/prompts/errors.d.ts.map +1 -1
- package/dist/prompts/prompt-manager.d.ts +3 -3
- package/dist/prompts/prompt-manager.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.cjs +15 -29
- package/dist/prompts/providers/config-prompt-provider.d.ts +3 -3
- package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.js +15 -29
- package/dist/prompts/providers/custom-prompt-provider.d.ts +2 -2
- package/dist/prompts/providers/custom-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/mcp-prompt-provider.d.ts +2 -2
- package/dist/prompts/providers/mcp-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/schemas.d.ts +4 -4
- package/dist/resources/{internal-provider.cjs → agent-resources-provider.cjs} +16 -16
- package/dist/resources/{internal-provider.d.ts → agent-resources-provider.d.ts} +6 -6
- package/dist/resources/agent-resources-provider.d.ts.map +1 -0
- package/dist/resources/{internal-provider.js → agent-resources-provider.js} +13 -13
- package/dist/resources/errors.cjs +2 -2
- package/dist/resources/errors.d.ts.map +1 -1
- package/dist/resources/handlers/blob-handler.d.ts +2 -2
- package/dist/resources/handlers/blob-handler.d.ts.map +1 -1
- package/dist/resources/handlers/factory.d.ts +3 -3
- package/dist/resources/handlers/factory.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.cjs +25 -0
- package/dist/resources/handlers/filesystem-handler.d.ts +3 -2
- package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.js +25 -0
- package/dist/resources/index.cjs +7 -9
- package/dist/resources/index.d.ts +3 -3
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +5 -10
- package/dist/resources/manager.cjs +77 -74
- package/dist/resources/manager.d.ts +16 -7
- package/dist/resources/manager.d.ts.map +1 -1
- package/dist/resources/manager.js +77 -74
- package/dist/resources/schemas.cjs +6 -26
- package/dist/resources/schemas.d.ts +8 -100
- package/dist/resources/schemas.d.ts.map +1 -1
- package/dist/resources/schemas.js +4 -23
- package/dist/search/search-service.d.ts +2 -2
- package/dist/search/search-service.d.ts.map +1 -1
- package/dist/session/chat-session.cjs +16 -26
- package/dist/session/chat-session.d.ts +7 -5
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +17 -27
- package/dist/session/errors.cjs +2 -2
- package/dist/session/errors.d.ts.map +1 -1
- package/dist/session/history/database.cjs +1 -1
- package/dist/session/history/database.d.ts +4 -4
- package/dist/session/history/database.d.ts.map +1 -1
- package/dist/session/history/factory.d.ts +3 -3
- package/dist/session/history/factory.d.ts.map +1 -1
- package/dist/session/history/memory.d.ts +4 -4
- package/dist/session/history/memory.d.ts.map +1 -1
- package/dist/session/history/types.d.ts +2 -2
- package/dist/session/history/types.d.ts.map +1 -1
- package/dist/session/index.cjs +3 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +2 -0
- package/dist/session/message-queue.cjs +29 -5
- package/dist/session/message-queue.d.ts +5 -3
- package/dist/session/message-queue.d.ts.map +1 -1
- package/dist/session/message-queue.js +29 -5
- package/dist/session/session-manager.cjs +107 -12
- package/dist/session/session-manager.d.ts +49 -8
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +97 -12
- package/dist/session/title-generator.cjs +2 -2
- package/dist/session/title-generator.d.ts +2 -2
- package/dist/session/title-generator.d.ts.map +1 -1
- package/dist/session/types.d.ts +1 -0
- package/dist/session/types.d.ts.map +1 -1
- package/dist/storage/blob/index.cjs +0 -40
- package/dist/storage/blob/index.d.ts +2 -44
- package/dist/storage/blob/index.d.ts.map +1 -1
- package/dist/storage/blob/index.js +0 -30
- package/dist/storage/cache/index.cjs +0 -37
- package/dist/storage/cache/index.d.ts +0 -42
- package/dist/storage/cache/index.d.ts.map +1 -1
- package/dist/storage/cache/index.js +0 -28
- package/dist/storage/database/index.cjs +0 -42
- package/dist/storage/database/index.d.ts +0 -43
- package/dist/storage/database/index.d.ts.map +1 -1
- package/dist/storage/database/index.js +0 -37
- package/dist/storage/error-codes.cjs +1 -6
- package/dist/storage/error-codes.d.ts +2 -7
- package/dist/storage/error-codes.d.ts.map +1 -1
- package/dist/storage/error-codes.js +1 -6
- package/dist/storage/errors.cjs +18 -82
- package/dist/storage/errors.d.ts +4 -24
- package/dist/storage/errors.d.ts.map +1 -1
- package/dist/storage/errors.js +16 -80
- package/dist/storage/index.cjs +8 -69
- package/dist/storage/index.d.ts +11 -66
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +6 -50
- package/dist/storage/storage-manager.cjs +9 -25
- package/dist/storage/storage-manager.d.ts +11 -15
- package/dist/storage/storage-manager.d.ts.map +1 -1
- package/dist/storage/storage-manager.js +8 -23
- package/dist/storage/types.d.ts +0 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/systemPrompt/contributors.d.ts +4 -4
- package/dist/systemPrompt/contributors.d.ts.map +1 -1
- package/dist/systemPrompt/errors.cjs +2 -2
- package/dist/systemPrompt/errors.d.ts.map +1 -1
- package/dist/systemPrompt/manager.cjs +1 -5
- package/dist/systemPrompt/manager.d.ts +2 -3
- package/dist/systemPrompt/manager.d.ts.map +1 -1
- package/dist/systemPrompt/manager.js +1 -5
- package/dist/telemetry/index.cjs +3 -0
- package/dist/telemetry/index.d.ts +2 -0
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/utils.d.ts +4 -4
- package/dist/telemetry/utils.d.ts.map +1 -1
- package/dist/test-utils/in-memory-storage.cjs +288 -0
- package/dist/test-utils/in-memory-storage.js +252 -0
- package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts +3 -3
- package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/in-memory.d.ts +2 -2
- package/dist/tools/confirmation/allowed-tools-provider/in-memory.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts +4 -4
- package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/types.d.ts +2 -2
- package/dist/tools/confirmation/allowed-tools-provider/types.d.ts.map +1 -1
- package/dist/tools/{internal-tools/constants.cjs → define-tool.cjs} +8 -13
- package/dist/tools/define-tool.d.ts +11 -0
- package/dist/tools/define-tool.d.ts.map +1 -0
- package/dist/tools/define-tool.js +7 -0
- package/dist/tools/error-codes.cjs +2 -2
- package/dist/tools/error-codes.d.ts +2 -2
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +2 -2
- package/dist/tools/errors.cjs +11 -23
- package/dist/tools/errors.d.ts +4 -10
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +9 -21
- package/dist/tools/index.cjs +3 -8
- package/dist/tools/index.d.ts +2 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -7
- package/dist/{storage/blob/providers/index.cjs → tools/pattern-utils.cjs} +11 -9
- package/dist/tools/pattern-utils.d.ts +20 -0
- package/dist/tools/pattern-utils.d.ts.map +1 -0
- package/dist/tools/pattern-utils.js +10 -0
- package/dist/tools/schemas.cjs +14 -40
- package/dist/tools/schemas.d.ts +6 -50
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +11 -32
- package/dist/tools/tool-call-metadata.cjs +75 -0
- package/dist/tools/tool-call-metadata.d.ts +16 -0
- package/dist/tools/tool-call-metadata.d.ts.map +1 -0
- package/dist/tools/tool-call-metadata.js +51 -0
- package/dist/tools/tool-manager.cjs +578 -302
- package/dist/tools/tool-manager.d.ts +105 -81
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +578 -306
- package/dist/tools/types.d.ts +112 -13
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/api-key-resolver.cjs +1 -1
- package/dist/utils/api-key-resolver.js +1 -1
- package/dist/utils/env.cjs +49 -0
- package/dist/utils/env.d.ts +4 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +24 -0
- package/dist/utils/error-conversion.d.ts +2 -2
- package/dist/utils/error-conversion.d.ts.map +1 -1
- package/dist/utils/index.cjs +3 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/path.d.ts +2 -2
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/result.cjs +1 -1
- package/dist/utils/result.d.ts.map +1 -1
- package/dist/utils/schema.cjs +9 -5
- package/dist/utils/schema.d.ts +4 -2
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +9 -5
- package/dist/utils/service-initializer.cjs +58 -51
- package/dist/utils/service-initializer.d.ts +31 -9
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +58 -51
- package/dist/{storage/cache/providers/index.cjs → workspace/error-codes.cjs} +8 -9
- package/dist/workspace/error-codes.d.ts +5 -0
- package/dist/workspace/error-codes.d.ts.map +1 -0
- package/dist/workspace/error-codes.js +7 -0
- package/dist/{storage/blob/factory.cjs → workspace/errors.cjs} +20 -14
- package/dist/workspace/errors.d.ts +5 -0
- package/dist/workspace/errors.d.ts.map +1 -0
- package/dist/workspace/errors.js +21 -0
- package/dist/{image → workspace}/index.cjs +12 -10
- package/dist/workspace/index.d.ts +5 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +9 -0
- package/dist/workspace/manager.cjs +113 -0
- package/dist/workspace/manager.d.ts +18 -0
- package/dist/workspace/manager.d.ts.map +1 -0
- package/dist/workspace/manager.js +90 -0
- package/dist/workspace/types.d.ts +14 -0
- package/dist/workspace/types.d.ts.map +1 -0
- package/package.json +7 -3
- package/dist/context/compaction/factory.cjs +0 -57
- package/dist/context/compaction/factory.d.ts +0 -17
- package/dist/context/compaction/factory.d.ts.map +0 -1
- package/dist/context/compaction/factory.js +0 -34
- package/dist/context/compaction/provider.d.ts +0 -48
- package/dist/context/compaction/provider.d.ts.map +0 -1
- package/dist/context/compaction/providers/noop-provider.d.ts +0 -24
- package/dist/context/compaction/providers/noop-provider.d.ts.map +0 -1
- package/dist/context/compaction/providers/noop-provider.js +0 -24
- package/dist/context/compaction/providers/reactive-overflow-provider.cjs +0 -76
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts +0 -51
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts.map +0 -1
- package/dist/context/compaction/providers/reactive-overflow-provider.js +0 -52
- package/dist/context/compaction/registry.cjs +0 -39
- package/dist/context/compaction/registry.d.ts +0 -19
- package/dist/context/compaction/registry.d.ts.map +0 -1
- package/dist/context/compaction/registry.js +0 -16
- package/dist/context/compaction/schemas.cjs +0 -58
- package/dist/context/compaction/schemas.d.ts +0 -69
- package/dist/context/compaction/schemas.d.ts.map +0 -1
- package/dist/context/compaction/schemas.js +0 -34
- package/dist/context/compaction/strategies/reactive-overflow.d.ts.map +0 -1
- package/dist/image/define-image.cjs +0 -146
- package/dist/image/define-image.d.ts +0 -71
- package/dist/image/define-image.d.ts.map +0 -1
- package/dist/image/define-image.js +0 -121
- package/dist/image/index.d.ts +0 -53
- package/dist/image/index.d.ts.map +0 -1
- package/dist/image/index.js +0 -7
- package/dist/image/types.d.ts +0 -246
- package/dist/image/types.d.ts.map +0 -1
- package/dist/llm/registry.cjs +0 -2075
- package/dist/llm/registry.d.ts.map +0 -1
- package/dist/llm/registry.js +0 -2025
- package/dist/llm/services/test-utils.integration.cjs +0 -237
- package/dist/llm/services/test-utils.integration.d.ts +0 -48
- package/dist/llm/services/test-utils.integration.d.ts.map +0 -1
- package/dist/llm/services/test-utils.integration.js +0 -214
- package/dist/plugins/builtins/content-policy.d.ts +0 -26
- package/dist/plugins/builtins/content-policy.d.ts.map +0 -1
- package/dist/plugins/builtins/response-sanitizer.d.ts +0 -25
- package/dist/plugins/builtins/response-sanitizer.d.ts.map +0 -1
- package/dist/plugins/error-codes.cjs +0 -43
- package/dist/plugins/error-codes.d.ts +0 -34
- package/dist/plugins/error-codes.d.ts.map +0 -1
- package/dist/plugins/error-codes.js +0 -20
- package/dist/plugins/index.cjs +0 -61
- package/dist/plugins/index.d.ts +0 -21
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -30
- package/dist/plugins/loader.cjs +0 -171
- package/dist/plugins/loader.d.ts +0 -30
- package/dist/plugins/loader.d.ts.map +0 -1
- package/dist/plugins/loader.js +0 -145
- package/dist/plugins/manager.cjs +0 -473
- package/dist/plugins/manager.d.ts +0 -106
- package/dist/plugins/manager.d.ts.map +0 -1
- package/dist/plugins/manager.js +0 -450
- package/dist/plugins/registrations/builtins.cjs +0 -51
- package/dist/plugins/registrations/builtins.d.ts +0 -17
- package/dist/plugins/registrations/builtins.d.ts.map +0 -1
- package/dist/plugins/registrations/builtins.js +0 -28
- package/dist/plugins/registry.cjs +0 -63
- package/dist/plugins/registry.d.ts +0 -101
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js +0 -39
- package/dist/plugins/schemas.cjs +0 -73
- package/dist/plugins/schemas.d.ts +0 -195
- package/dist/plugins/schemas.d.ts.map +0 -1
- package/dist/plugins/schemas.js +0 -47
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/providers/base-registry.cjs +0 -147
- package/dist/providers/base-registry.d.ts +0 -147
- package/dist/providers/base-registry.d.ts.map +0 -1
- package/dist/providers/base-registry.js +0 -123
- package/dist/providers/discovery.cjs +0 -109
- package/dist/providers/discovery.d.ts +0 -96
- package/dist/providers/discovery.d.ts.map +0 -1
- package/dist/providers/discovery.js +0 -84
- package/dist/providers/index.cjs +0 -24
- package/dist/providers/index.d.ts +0 -32
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -2
- package/dist/resources/internal-provider.d.ts.map +0 -1
- package/dist/storage/blob/factory.d.ts +0 -37
- package/dist/storage/blob/factory.d.ts.map +0 -1
- package/dist/storage/blob/factory.js +0 -15
- package/dist/storage/blob/local-blob-store.cjs +0 -496
- package/dist/storage/blob/local-blob-store.d.ts +0 -58
- package/dist/storage/blob/local-blob-store.d.ts.map +0 -1
- package/dist/storage/blob/local-blob-store.js +0 -463
- package/dist/storage/blob/memory-blob-store.cjs +0 -326
- package/dist/storage/blob/memory-blob-store.d.ts +0 -66
- package/dist/storage/blob/memory-blob-store.d.ts.map +0 -1
- package/dist/storage/blob/memory-blob-store.js +0 -303
- package/dist/storage/blob/provider.d.ts +0 -50
- package/dist/storage/blob/provider.d.ts.map +0 -1
- package/dist/storage/blob/providers/index.d.ts +0 -8
- package/dist/storage/blob/providers/index.d.ts.map +0 -1
- package/dist/storage/blob/providers/index.js +0 -7
- package/dist/storage/blob/providers/local.cjs +0 -39
- package/dist/storage/blob/providers/local.d.ts +0 -17
- package/dist/storage/blob/providers/local.d.ts.map +0 -1
- package/dist/storage/blob/providers/local.js +0 -16
- package/dist/storage/blob/providers/memory.cjs +0 -39
- package/dist/storage/blob/providers/memory.d.ts +0 -17
- package/dist/storage/blob/providers/memory.d.ts.map +0 -1
- package/dist/storage/blob/providers/memory.js +0 -16
- package/dist/storage/blob/registry.cjs +0 -50
- package/dist/storage/blob/registry.d.ts +0 -42
- package/dist/storage/blob/registry.d.ts.map +0 -1
- package/dist/storage/blob/registry.js +0 -26
- package/dist/storage/blob/schemas.cjs +0 -52
- package/dist/storage/blob/schemas.d.ts +0 -85
- package/dist/storage/blob/schemas.d.ts.map +0 -1
- package/dist/storage/blob/schemas.js +0 -26
- package/dist/storage/cache/factory.cjs +0 -38
- package/dist/storage/cache/factory.d.ts +0 -37
- package/dist/storage/cache/factory.d.ts.map +0 -1
- package/dist/storage/cache/factory.js +0 -15
- package/dist/storage/cache/memory-cache-store.cjs +0 -107
- package/dist/storage/cache/memory-cache-store.d.ts +0 -26
- package/dist/storage/cache/memory-cache-store.d.ts.map +0 -1
- package/dist/storage/cache/memory-cache-store.js +0 -84
- package/dist/storage/cache/provider.cjs +0 -16
- package/dist/storage/cache/provider.d.ts +0 -56
- package/dist/storage/cache/provider.d.ts.map +0 -1
- package/dist/storage/cache/provider.js +0 -0
- package/dist/storage/cache/providers/index.d.ts +0 -8
- package/dist/storage/cache/providers/index.d.ts.map +0 -1
- package/dist/storage/cache/providers/index.js +0 -7
- package/dist/storage/cache/providers/memory.d.ts +0 -17
- package/dist/storage/cache/providers/memory.d.ts.map +0 -1
- package/dist/storage/cache/providers/memory.js +0 -17
- package/dist/storage/cache/providers/redis.cjs +0 -66
- package/dist/storage/cache/providers/redis.d.ts +0 -20
- package/dist/storage/cache/providers/redis.d.ts.map +0 -1
- package/dist/storage/cache/providers/redis.js +0 -33
- package/dist/storage/cache/redis-store.cjs +0 -173
- package/dist/storage/cache/redis-store.d.ts +0 -32
- package/dist/storage/cache/redis-store.d.ts.map +0 -1
- package/dist/storage/cache/redis-store.js +0 -150
- package/dist/storage/cache/registry.cjs +0 -50
- package/dist/storage/cache/registry.d.ts +0 -42
- package/dist/storage/cache/registry.d.ts.map +0 -1
- package/dist/storage/cache/registry.js +0 -26
- package/dist/storage/cache/schemas.cjs +0 -81
- package/dist/storage/cache/schemas.d.ts +0 -150
- package/dist/storage/cache/schemas.d.ts.map +0 -1
- package/dist/storage/cache/schemas.js +0 -55
- package/dist/storage/database/factory.cjs +0 -38
- package/dist/storage/database/factory.d.ts +0 -39
- package/dist/storage/database/factory.d.ts.map +0 -1
- package/dist/storage/database/factory.js +0 -15
- package/dist/storage/database/memory-database-store.cjs +0 -122
- package/dist/storage/database/memory-database-store.d.ts +0 -29
- package/dist/storage/database/memory-database-store.d.ts.map +0 -1
- package/dist/storage/database/memory-database-store.js +0 -99
- package/dist/storage/database/postgres-store.cjs +0 -342
- package/dist/storage/database/postgres-store.d.ts +0 -55
- package/dist/storage/database/postgres-store.d.ts.map +0 -1
- package/dist/storage/database/postgres-store.js +0 -319
- package/dist/storage/database/provider.cjs +0 -16
- package/dist/storage/database/provider.d.ts +0 -56
- package/dist/storage/database/provider.d.ts.map +0 -1
- package/dist/storage/database/provider.js +0 -0
- package/dist/storage/database/providers/index.d.ts +0 -9
- package/dist/storage/database/providers/index.d.ts.map +0 -1
- package/dist/storage/database/providers/index.js +0 -9
- package/dist/storage/database/providers/memory.cjs +0 -40
- package/dist/storage/database/providers/memory.d.ts +0 -16
- package/dist/storage/database/providers/memory.d.ts.map +0 -1
- package/dist/storage/database/providers/memory.js +0 -17
- package/dist/storage/database/providers/postgres.cjs +0 -62
- package/dist/storage/database/providers/postgres.d.ts +0 -19
- package/dist/storage/database/providers/postgres.d.ts.map +0 -1
- package/dist/storage/database/providers/postgres.js +0 -29
- package/dist/storage/database/providers/sqlite.cjs +0 -66
- package/dist/storage/database/providers/sqlite.d.ts +0 -20
- package/dist/storage/database/providers/sqlite.d.ts.map +0 -1
- package/dist/storage/database/providers/sqlite.js +0 -33
- package/dist/storage/database/registry.cjs +0 -50
- package/dist/storage/database/registry.d.ts +0 -42
- package/dist/storage/database/registry.d.ts.map +0 -1
- package/dist/storage/database/registry.js +0 -26
- package/dist/storage/database/schemas.cjs +0 -97
- package/dist/storage/database/schemas.d.ts +0 -226
- package/dist/storage/database/schemas.d.ts.map +0 -1
- package/dist/storage/database/schemas.js +0 -70
- package/dist/storage/database/sqlite-store.cjs +0 -270
- package/dist/storage/database/sqlite-store.d.ts +0 -33
- package/dist/storage/database/sqlite-store.d.ts.map +0 -1
- package/dist/storage/database/sqlite-store.js +0 -237
- package/dist/storage/schemas.cjs +0 -57
- package/dist/storage/schemas.d.ts +0 -347
- package/dist/storage/schemas.d.ts.map +0 -1
- package/dist/storage/schemas.js +0 -37
- package/dist/tools/bash-pattern-utils.cjs +0 -91
- package/dist/tools/bash-pattern-utils.d.ts +0 -58
- package/dist/tools/bash-pattern-utils.d.ts.map +0 -1
- package/dist/tools/bash-pattern-utils.js +0 -64
- package/dist/tools/custom-tool-registry.cjs +0 -64
- package/dist/tools/custom-tool-registry.d.ts +0 -126
- package/dist/tools/custom-tool-registry.d.ts.map +0 -1
- package/dist/tools/custom-tool-registry.js +0 -40
- package/dist/tools/custom-tool-schema-registry.cjs +0 -164
- package/dist/tools/custom-tool-schema-registry.d.ts +0 -86
- package/dist/tools/custom-tool-schema-registry.d.ts.map +0 -1
- package/dist/tools/custom-tool-schema-registry.js +0 -140
- package/dist/tools/internal-tools/constants.d.ts +0 -12
- package/dist/tools/internal-tools/constants.d.ts.map +0 -1
- package/dist/tools/internal-tools/constants.js +0 -12
- package/dist/tools/internal-tools/implementations/ask-user-tool.cjs +0 -57
- package/dist/tools/internal-tools/implementations/ask-user-tool.d.ts +0 -18
- package/dist/tools/internal-tools/implementations/ask-user-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/ask-user-tool.js +0 -34
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.cjs +0 -192
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.d.ts +0 -33
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.js +0 -169
- package/dist/tools/internal-tools/implementations/get-resource-tool.cjs +0 -113
- package/dist/tools/internal-tools/implementations/get-resource-tool.d.ts +0 -30
- package/dist/tools/internal-tools/implementations/get-resource-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/get-resource-tool.js +0 -90
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.cjs +0 -140
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.d.ts +0 -24
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.js +0 -117
- package/dist/tools/internal-tools/implementations/list-resources-tool.cjs +0 -91
- package/dist/tools/internal-tools/implementations/list-resources-tool.d.ts +0 -24
- package/dist/tools/internal-tools/implementations/list-resources-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/list-resources-tool.js +0 -68
- package/dist/tools/internal-tools/implementations/search-history-tool.cjs +0 -61
- package/dist/tools/internal-tools/implementations/search-history-tool.d.ts +0 -7
- package/dist/tools/internal-tools/implementations/search-history-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/search-history-tool.js +0 -38
- package/dist/tools/internal-tools/index.cjs +0 -26
- package/dist/tools/internal-tools/index.d.ts +0 -4
- package/dist/tools/internal-tools/index.d.ts.map +0 -1
- package/dist/tools/internal-tools/index.js +0 -3
- package/dist/tools/internal-tools/provider.cjs +0 -324
- package/dist/tools/internal-tools/provider.d.ts +0 -114
- package/dist/tools/internal-tools/provider.d.ts.map +0 -1
- package/dist/tools/internal-tools/provider.js +0 -301
- package/dist/tools/internal-tools/registry.cjs +0 -71
- package/dist/tools/internal-tools/registry.d.ts +0 -91
- package/dist/tools/internal-tools/registry.d.ts.map +0 -1
- package/dist/tools/internal-tools/registry.js +0 -47
- /package/dist/{context/compaction/provider.js → agent/agent-options.js} +0 -0
- /package/dist/{image/types.js → agent/runtime-config.js} +0 -0
- /package/dist/{image → hooks}/types.cjs +0 -0
- /package/dist/{plugins → hooks}/types.js +0 -0
- /package/dist/{plugins → workspace}/types.cjs +0 -0
- /package/dist/{storage/blob/provider.js → workspace/types.js} +0 -0
|
@@ -0,0 +1,263 @@
|
|
|
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 auto_update_exports = {};
|
|
30
|
+
__export(auto_update_exports, {
|
|
31
|
+
getLlmRegistryAutoUpdateStatus: () => getLlmRegistryAutoUpdateStatus,
|
|
32
|
+
loadLlmRegistryCache: () => loadLlmRegistryCache,
|
|
33
|
+
refreshLlmRegistryCache: () => refreshLlmRegistryCache,
|
|
34
|
+
startLlmRegistryAutoUpdate: () => startLlmRegistryAutoUpdate
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(auto_update_exports);
|
|
37
|
+
var import_node_fs = require("node:fs");
|
|
38
|
+
var import_node_fs2 = require("node:fs");
|
|
39
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
40
|
+
var import_path = require("../../utils/path.js");
|
|
41
|
+
var import_logger = require("../../logger/logger.js");
|
|
42
|
+
var import_types = require("../types.js");
|
|
43
|
+
var import_index = require("./index.js");
|
|
44
|
+
var import_sync = require("./sync.js");
|
|
45
|
+
const CACHE_SUBDIR = "cache";
|
|
46
|
+
const CACHE_FILENAME = "llm-registry-models.json";
|
|
47
|
+
const CACHE_SCHEMA_VERSION = 1;
|
|
48
|
+
const DEFAULT_TTL_MS = 1e3 * 60 * 60;
|
|
49
|
+
const MIN_REFRESH_INTERVAL_MS = 1e3 * 60 * 5;
|
|
50
|
+
const UPDATABLE_PROVIDERS = [
|
|
51
|
+
"openai",
|
|
52
|
+
"anthropic",
|
|
53
|
+
"google",
|
|
54
|
+
"groq",
|
|
55
|
+
"xai",
|
|
56
|
+
"cohere",
|
|
57
|
+
"minimax",
|
|
58
|
+
"glm",
|
|
59
|
+
"vertex",
|
|
60
|
+
"bedrock"
|
|
61
|
+
];
|
|
62
|
+
function truthyEnv(name) {
|
|
63
|
+
const v = process.env[name];
|
|
64
|
+
if (!v) return false;
|
|
65
|
+
return v === "1" || v === "true" || v === "yes" || v === "on";
|
|
66
|
+
}
|
|
67
|
+
function getTtlMs() {
|
|
68
|
+
const raw = process.env.DEXTO_LLM_REGISTRY_TTL_MS;
|
|
69
|
+
if (!raw) return DEFAULT_TTL_MS;
|
|
70
|
+
const n = Number(raw);
|
|
71
|
+
return Number.isFinite(n) && n > 0 ? n : DEFAULT_TTL_MS;
|
|
72
|
+
}
|
|
73
|
+
function getCachePath() {
|
|
74
|
+
return (0, import_path.getDextoGlobalPath)(CACHE_SUBDIR, CACHE_FILENAME);
|
|
75
|
+
}
|
|
76
|
+
function isModelInfo(value) {
|
|
77
|
+
if (typeof value !== "object" || value === null) return false;
|
|
78
|
+
const name = value.name;
|
|
79
|
+
return typeof name === "string" && name.trim() !== "";
|
|
80
|
+
}
|
|
81
|
+
function applyModelsByProvider(modelsByProvider) {
|
|
82
|
+
for (const provider of UPDATABLE_PROVIDERS) {
|
|
83
|
+
const incoming = modelsByProvider[provider] ?? [];
|
|
84
|
+
const existing = import_index.LLM_REGISTRY[provider].models ?? [];
|
|
85
|
+
const incomingByName = /* @__PURE__ */ new Map();
|
|
86
|
+
for (const m of incoming) {
|
|
87
|
+
incomingByName.set(m.name.toLowerCase(), m);
|
|
88
|
+
}
|
|
89
|
+
const existingDefault = existing.find((m) => m.default)?.name.toLowerCase();
|
|
90
|
+
const incomingDefault = incoming.find((m) => m.default)?.name.toLowerCase();
|
|
91
|
+
const merged = [];
|
|
92
|
+
const seen = /* @__PURE__ */ new Set();
|
|
93
|
+
for (const m of existing) {
|
|
94
|
+
const key = m.name.toLowerCase();
|
|
95
|
+
const updated = incomingByName.get(key);
|
|
96
|
+
if (!updated) {
|
|
97
|
+
merged.push(m);
|
|
98
|
+
} else {
|
|
99
|
+
const name = updated.name ?? m.name;
|
|
100
|
+
const maxInputTokens = typeof updated.maxInputTokens === "number" && updated.maxInputTokens > 0 ? updated.maxInputTokens : m.maxInputTokens;
|
|
101
|
+
const supportedFileTypes = Array.isArray(updated.supportedFileTypes) ? updated.supportedFileTypes : m.supportedFileTypes;
|
|
102
|
+
const displayName = updated.displayName ?? m.displayName;
|
|
103
|
+
const pricing = updated.pricing ?? m.pricing;
|
|
104
|
+
merged.push({
|
|
105
|
+
name,
|
|
106
|
+
maxInputTokens,
|
|
107
|
+
supportedFileTypes,
|
|
108
|
+
...displayName ? { displayName } : {},
|
|
109
|
+
...pricing ? { pricing } : {}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
seen.add(key);
|
|
113
|
+
}
|
|
114
|
+
const newModels = incoming.filter((m) => !seen.has(m.name.toLowerCase()));
|
|
115
|
+
newModels.sort((a, b) => a.name.localeCompare(b.name));
|
|
116
|
+
merged.push(...newModels);
|
|
117
|
+
const chosenDefault = incomingDefault ?? existingDefault ?? merged[0]?.name.toLowerCase();
|
|
118
|
+
const finalMerged = merged.map((m) => {
|
|
119
|
+
const copy = { ...m };
|
|
120
|
+
delete copy.default;
|
|
121
|
+
return copy;
|
|
122
|
+
});
|
|
123
|
+
if (chosenDefault) {
|
|
124
|
+
const idx = finalMerged.findIndex((m) => m.name.toLowerCase() === chosenDefault);
|
|
125
|
+
if (idx >= 0) {
|
|
126
|
+
finalMerged[idx] = { ...finalMerged[idx], default: true };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
import_index.LLM_REGISTRY[provider].models = finalMerged;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function normalizeModelsByProvider(raw) {
|
|
133
|
+
const out = {};
|
|
134
|
+
for (const p of import_types.LLM_PROVIDERS) {
|
|
135
|
+
const value = raw[p];
|
|
136
|
+
out[p] = Array.isArray(value) ? value.filter(isModelInfo) : [];
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
function tryLoadCacheFromDisk(log) {
|
|
141
|
+
const cachePath = getCachePath();
|
|
142
|
+
if (!(0, import_node_fs2.existsSync)(cachePath)) return null;
|
|
143
|
+
try {
|
|
144
|
+
const text = (0, import_node_fs2.readFileSync)(cachePath, "utf-8");
|
|
145
|
+
const parsed = JSON.parse(text);
|
|
146
|
+
if (parsed.schemaVersion !== CACHE_SCHEMA_VERSION) return null;
|
|
147
|
+
if (!parsed.fetchedAt || typeof parsed.fetchedAt !== "string") return null;
|
|
148
|
+
if (!parsed.modelsByProvider || typeof parsed.modelsByProvider !== "object") return null;
|
|
149
|
+
const fetchedAt = Date.parse(parsed.fetchedAt);
|
|
150
|
+
if (!Number.isFinite(fetchedAt)) return null;
|
|
151
|
+
const modelsByProvider = normalizeModelsByProvider(
|
|
152
|
+
parsed.modelsByProvider
|
|
153
|
+
);
|
|
154
|
+
return { fetchedAt, modelsByProvider };
|
|
155
|
+
} catch (e) {
|
|
156
|
+
log?.warn?.(
|
|
157
|
+
`Failed to load LLM registry cache (${cachePath}): ${e instanceof Error ? e.message : String(e)}`
|
|
158
|
+
);
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
let refreshPromise = null;
|
|
163
|
+
let lastRefreshAttemptAt = null;
|
|
164
|
+
let lastFetchedAt = null;
|
|
165
|
+
let lastSource = "snapshot";
|
|
166
|
+
let autoRefreshStarted = false;
|
|
167
|
+
function isFresh(now, fetchedAt, ttlMs) {
|
|
168
|
+
return now - fetchedAt < ttlMs;
|
|
169
|
+
}
|
|
170
|
+
function getLlmRegistryAutoUpdateStatus() {
|
|
171
|
+
const cachePath = getCachePath();
|
|
172
|
+
const fetchedAt = lastFetchedAt ? new Date(lastFetchedAt) : null;
|
|
173
|
+
const now = Date.now();
|
|
174
|
+
return {
|
|
175
|
+
cachePath,
|
|
176
|
+
lastFetchedAt: fetchedAt,
|
|
177
|
+
isFresh: lastFetchedAt ? isFresh(now, lastFetchedAt, getTtlMs()) : false,
|
|
178
|
+
source: lastSource
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function loadLlmRegistryCache(options) {
|
|
182
|
+
const cache = tryLoadCacheFromDisk(options?.logger);
|
|
183
|
+
if (!cache) return false;
|
|
184
|
+
applyModelsByProvider(cache.modelsByProvider);
|
|
185
|
+
lastFetchedAt = cache.fetchedAt;
|
|
186
|
+
lastSource = "cache";
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
async function writeCacheFile(cachePath, modelsByProvider) {
|
|
190
|
+
await import_node_fs.promises.mkdir(import_node_path.default.dirname(cachePath), { recursive: true });
|
|
191
|
+
const payload = {
|
|
192
|
+
schemaVersion: CACHE_SCHEMA_VERSION,
|
|
193
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
194
|
+
modelsByProvider
|
|
195
|
+
};
|
|
196
|
+
const tmpPath = `${cachePath}.tmp`;
|
|
197
|
+
await import_node_fs.promises.writeFile(tmpPath, JSON.stringify(payload), "utf-8");
|
|
198
|
+
await import_node_fs.promises.rename(tmpPath, cachePath);
|
|
199
|
+
}
|
|
200
|
+
async function refreshLlmRegistryCache(options) {
|
|
201
|
+
if (truthyEnv("DEXTO_LLM_REGISTRY_DISABLE_FETCH") || !options?.allowInTests && (process.env.NODE_ENV === "test" || truthyEnv("VITEST"))) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (refreshPromise && !options?.force) {
|
|
205
|
+
await refreshPromise;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const now = Date.now();
|
|
209
|
+
if (!options?.force && lastRefreshAttemptAt && now - lastRefreshAttemptAt < MIN_REFRESH_INTERVAL_MS) {
|
|
210
|
+
if (refreshPromise) await refreshPromise;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
lastRefreshAttemptAt = now;
|
|
214
|
+
const log = options?.logger ?? import_logger.logger;
|
|
215
|
+
refreshPromise = (async () => {
|
|
216
|
+
const modelsByProvider = await (0, import_sync.buildModelsByProviderFromRemote)({
|
|
217
|
+
userAgent: "dexto-llm-registry",
|
|
218
|
+
timeoutMs: 3e4
|
|
219
|
+
});
|
|
220
|
+
const cachePath = getCachePath();
|
|
221
|
+
await writeCacheFile(cachePath, modelsByProvider);
|
|
222
|
+
applyModelsByProvider(modelsByProvider);
|
|
223
|
+
lastFetchedAt = Date.now();
|
|
224
|
+
lastSource = "remote";
|
|
225
|
+
log?.debug?.(`Refreshed LLM registry cache (${cachePath})`);
|
|
226
|
+
})().catch((e) => {
|
|
227
|
+
log?.warn?.(
|
|
228
|
+
`Failed to refresh LLM registry cache: ${e instanceof Error ? e.message : String(e)}`
|
|
229
|
+
);
|
|
230
|
+
}).finally(() => {
|
|
231
|
+
refreshPromise = null;
|
|
232
|
+
});
|
|
233
|
+
await refreshPromise;
|
|
234
|
+
}
|
|
235
|
+
function startLlmRegistryAutoUpdate(options) {
|
|
236
|
+
if (autoRefreshStarted) return;
|
|
237
|
+
autoRefreshStarted = true;
|
|
238
|
+
const log = options?.logger ?? import_logger.logger;
|
|
239
|
+
const loaded = loadLlmRegistryCache({ logger: log });
|
|
240
|
+
if (loaded) {
|
|
241
|
+
log?.debug?.(`Loaded LLM registry cache from disk (${getCachePath()})`);
|
|
242
|
+
}
|
|
243
|
+
if (options?.refreshOnStart !== false) {
|
|
244
|
+
void refreshLlmRegistryCache({ logger: log });
|
|
245
|
+
}
|
|
246
|
+
const timer = setInterval(
|
|
247
|
+
() => {
|
|
248
|
+
const ttlMs = getTtlMs();
|
|
249
|
+
const now = Date.now();
|
|
250
|
+
if (lastFetchedAt && isFresh(now, lastFetchedAt, ttlMs)) return;
|
|
251
|
+
void refreshLlmRegistryCache({ logger: log });
|
|
252
|
+
},
|
|
253
|
+
Math.min(getTtlMs(), DEFAULT_TTL_MS)
|
|
254
|
+
);
|
|
255
|
+
timer.unref?.();
|
|
256
|
+
}
|
|
257
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
258
|
+
0 && (module.exports = {
|
|
259
|
+
getLlmRegistryAutoUpdateStatus,
|
|
260
|
+
loadLlmRegistryCache,
|
|
261
|
+
refreshLlmRegistryCache,
|
|
262
|
+
startLlmRegistryAutoUpdate
|
|
263
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Logger } from '../../logger/v2/types.js';
|
|
2
|
+
type LogLike = Pick<Logger, 'debug' | 'info' | 'warn' | 'error'>;
|
|
3
|
+
export type LlmRegistryAutoUpdateStatus = {
|
|
4
|
+
cachePath: string;
|
|
5
|
+
lastFetchedAt: Date | null;
|
|
6
|
+
isFresh: boolean;
|
|
7
|
+
source: 'snapshot' | 'cache' | 'remote';
|
|
8
|
+
};
|
|
9
|
+
export declare function getLlmRegistryAutoUpdateStatus(): LlmRegistryAutoUpdateStatus;
|
|
10
|
+
export declare function loadLlmRegistryCache(options?: {
|
|
11
|
+
logger?: LogLike;
|
|
12
|
+
}): boolean;
|
|
13
|
+
export declare function refreshLlmRegistryCache(options?: {
|
|
14
|
+
logger?: LogLike;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Test-only escape hatch to validate refresh behavior with mocks while keeping
|
|
18
|
+
* network fetch disabled by default in CI/unit tests.
|
|
19
|
+
*/
|
|
20
|
+
allowInTests?: boolean;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
export declare function startLlmRegistryAutoUpdate(options?: {
|
|
23
|
+
logger?: LogLike;
|
|
24
|
+
refreshOnStart?: boolean;
|
|
25
|
+
}): void;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=auto-update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-update.d.ts","sourceRoot":"","sources":["../../../src/llm/registry/auto-update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAOvD,KAAK,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAuKjE,MAAM,MAAM,2BAA2B,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC3C,CAAC;AAMF,wBAAgB,8BAA8B,IAAI,2BAA2B,CAU5E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAO5E;AAiBD,wBAAsB,uBAAuB,CAAC,OAAO,CAAC,EAAE;IACpD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CAiDhB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,CAAC,EAAE;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,GAAG,IAAI,CA6BP"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import "../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { getDextoGlobalPath } from "../../utils/path.js";
|
|
6
|
+
import { logger as defaultLogger } from "../../logger/logger.js";
|
|
7
|
+
import { LLM_PROVIDERS } from "../types.js";
|
|
8
|
+
import { LLM_REGISTRY } from "./index.js";
|
|
9
|
+
import { buildModelsByProviderFromRemote } from "./sync.js";
|
|
10
|
+
const CACHE_SUBDIR = "cache";
|
|
11
|
+
const CACHE_FILENAME = "llm-registry-models.json";
|
|
12
|
+
const CACHE_SCHEMA_VERSION = 1;
|
|
13
|
+
const DEFAULT_TTL_MS = 1e3 * 60 * 60;
|
|
14
|
+
const MIN_REFRESH_INTERVAL_MS = 1e3 * 60 * 5;
|
|
15
|
+
const UPDATABLE_PROVIDERS = [
|
|
16
|
+
"openai",
|
|
17
|
+
"anthropic",
|
|
18
|
+
"google",
|
|
19
|
+
"groq",
|
|
20
|
+
"xai",
|
|
21
|
+
"cohere",
|
|
22
|
+
"minimax",
|
|
23
|
+
"glm",
|
|
24
|
+
"vertex",
|
|
25
|
+
"bedrock"
|
|
26
|
+
];
|
|
27
|
+
function truthyEnv(name) {
|
|
28
|
+
const v = process.env[name];
|
|
29
|
+
if (!v) return false;
|
|
30
|
+
return v === "1" || v === "true" || v === "yes" || v === "on";
|
|
31
|
+
}
|
|
32
|
+
function getTtlMs() {
|
|
33
|
+
const raw = process.env.DEXTO_LLM_REGISTRY_TTL_MS;
|
|
34
|
+
if (!raw) return DEFAULT_TTL_MS;
|
|
35
|
+
const n = Number(raw);
|
|
36
|
+
return Number.isFinite(n) && n > 0 ? n : DEFAULT_TTL_MS;
|
|
37
|
+
}
|
|
38
|
+
function getCachePath() {
|
|
39
|
+
return getDextoGlobalPath(CACHE_SUBDIR, CACHE_FILENAME);
|
|
40
|
+
}
|
|
41
|
+
function isModelInfo(value) {
|
|
42
|
+
if (typeof value !== "object" || value === null) return false;
|
|
43
|
+
const name = value.name;
|
|
44
|
+
return typeof name === "string" && name.trim() !== "";
|
|
45
|
+
}
|
|
46
|
+
function applyModelsByProvider(modelsByProvider) {
|
|
47
|
+
for (const provider of UPDATABLE_PROVIDERS) {
|
|
48
|
+
const incoming = modelsByProvider[provider] ?? [];
|
|
49
|
+
const existing = LLM_REGISTRY[provider].models ?? [];
|
|
50
|
+
const incomingByName = /* @__PURE__ */ new Map();
|
|
51
|
+
for (const m of incoming) {
|
|
52
|
+
incomingByName.set(m.name.toLowerCase(), m);
|
|
53
|
+
}
|
|
54
|
+
const existingDefault = existing.find((m) => m.default)?.name.toLowerCase();
|
|
55
|
+
const incomingDefault = incoming.find((m) => m.default)?.name.toLowerCase();
|
|
56
|
+
const merged = [];
|
|
57
|
+
const seen = /* @__PURE__ */ new Set();
|
|
58
|
+
for (const m of existing) {
|
|
59
|
+
const key = m.name.toLowerCase();
|
|
60
|
+
const updated = incomingByName.get(key);
|
|
61
|
+
if (!updated) {
|
|
62
|
+
merged.push(m);
|
|
63
|
+
} else {
|
|
64
|
+
const name = updated.name ?? m.name;
|
|
65
|
+
const maxInputTokens = typeof updated.maxInputTokens === "number" && updated.maxInputTokens > 0 ? updated.maxInputTokens : m.maxInputTokens;
|
|
66
|
+
const supportedFileTypes = Array.isArray(updated.supportedFileTypes) ? updated.supportedFileTypes : m.supportedFileTypes;
|
|
67
|
+
const displayName = updated.displayName ?? m.displayName;
|
|
68
|
+
const pricing = updated.pricing ?? m.pricing;
|
|
69
|
+
merged.push({
|
|
70
|
+
name,
|
|
71
|
+
maxInputTokens,
|
|
72
|
+
supportedFileTypes,
|
|
73
|
+
...displayName ? { displayName } : {},
|
|
74
|
+
...pricing ? { pricing } : {}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
seen.add(key);
|
|
78
|
+
}
|
|
79
|
+
const newModels = incoming.filter((m) => !seen.has(m.name.toLowerCase()));
|
|
80
|
+
newModels.sort((a, b) => a.name.localeCompare(b.name));
|
|
81
|
+
merged.push(...newModels);
|
|
82
|
+
const chosenDefault = incomingDefault ?? existingDefault ?? merged[0]?.name.toLowerCase();
|
|
83
|
+
const finalMerged = merged.map((m) => {
|
|
84
|
+
const copy = { ...m };
|
|
85
|
+
delete copy.default;
|
|
86
|
+
return copy;
|
|
87
|
+
});
|
|
88
|
+
if (chosenDefault) {
|
|
89
|
+
const idx = finalMerged.findIndex((m) => m.name.toLowerCase() === chosenDefault);
|
|
90
|
+
if (idx >= 0) {
|
|
91
|
+
finalMerged[idx] = { ...finalMerged[idx], default: true };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
LLM_REGISTRY[provider].models = finalMerged;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function normalizeModelsByProvider(raw) {
|
|
98
|
+
const out = {};
|
|
99
|
+
for (const p of LLM_PROVIDERS) {
|
|
100
|
+
const value = raw[p];
|
|
101
|
+
out[p] = Array.isArray(value) ? value.filter(isModelInfo) : [];
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
function tryLoadCacheFromDisk(log) {
|
|
106
|
+
const cachePath = getCachePath();
|
|
107
|
+
if (!existsSync(cachePath)) return null;
|
|
108
|
+
try {
|
|
109
|
+
const text = readFileSync(cachePath, "utf-8");
|
|
110
|
+
const parsed = JSON.parse(text);
|
|
111
|
+
if (parsed.schemaVersion !== CACHE_SCHEMA_VERSION) return null;
|
|
112
|
+
if (!parsed.fetchedAt || typeof parsed.fetchedAt !== "string") return null;
|
|
113
|
+
if (!parsed.modelsByProvider || typeof parsed.modelsByProvider !== "object") return null;
|
|
114
|
+
const fetchedAt = Date.parse(parsed.fetchedAt);
|
|
115
|
+
if (!Number.isFinite(fetchedAt)) return null;
|
|
116
|
+
const modelsByProvider = normalizeModelsByProvider(
|
|
117
|
+
parsed.modelsByProvider
|
|
118
|
+
);
|
|
119
|
+
return { fetchedAt, modelsByProvider };
|
|
120
|
+
} catch (e) {
|
|
121
|
+
log?.warn?.(
|
|
122
|
+
`Failed to load LLM registry cache (${cachePath}): ${e instanceof Error ? e.message : String(e)}`
|
|
123
|
+
);
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
let refreshPromise = null;
|
|
128
|
+
let lastRefreshAttemptAt = null;
|
|
129
|
+
let lastFetchedAt = null;
|
|
130
|
+
let lastSource = "snapshot";
|
|
131
|
+
let autoRefreshStarted = false;
|
|
132
|
+
function isFresh(now, fetchedAt, ttlMs) {
|
|
133
|
+
return now - fetchedAt < ttlMs;
|
|
134
|
+
}
|
|
135
|
+
function getLlmRegistryAutoUpdateStatus() {
|
|
136
|
+
const cachePath = getCachePath();
|
|
137
|
+
const fetchedAt = lastFetchedAt ? new Date(lastFetchedAt) : null;
|
|
138
|
+
const now = Date.now();
|
|
139
|
+
return {
|
|
140
|
+
cachePath,
|
|
141
|
+
lastFetchedAt: fetchedAt,
|
|
142
|
+
isFresh: lastFetchedAt ? isFresh(now, lastFetchedAt, getTtlMs()) : false,
|
|
143
|
+
source: lastSource
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function loadLlmRegistryCache(options) {
|
|
147
|
+
const cache = tryLoadCacheFromDisk(options?.logger);
|
|
148
|
+
if (!cache) return false;
|
|
149
|
+
applyModelsByProvider(cache.modelsByProvider);
|
|
150
|
+
lastFetchedAt = cache.fetchedAt;
|
|
151
|
+
lastSource = "cache";
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
async function writeCacheFile(cachePath, modelsByProvider) {
|
|
155
|
+
await fs.mkdir(path.dirname(cachePath), { recursive: true });
|
|
156
|
+
const payload = {
|
|
157
|
+
schemaVersion: CACHE_SCHEMA_VERSION,
|
|
158
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
159
|
+
modelsByProvider
|
|
160
|
+
};
|
|
161
|
+
const tmpPath = `${cachePath}.tmp`;
|
|
162
|
+
await fs.writeFile(tmpPath, JSON.stringify(payload), "utf-8");
|
|
163
|
+
await fs.rename(tmpPath, cachePath);
|
|
164
|
+
}
|
|
165
|
+
async function refreshLlmRegistryCache(options) {
|
|
166
|
+
if (truthyEnv("DEXTO_LLM_REGISTRY_DISABLE_FETCH") || !options?.allowInTests && (process.env.NODE_ENV === "test" || truthyEnv("VITEST"))) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (refreshPromise && !options?.force) {
|
|
170
|
+
await refreshPromise;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const now = Date.now();
|
|
174
|
+
if (!options?.force && lastRefreshAttemptAt && now - lastRefreshAttemptAt < MIN_REFRESH_INTERVAL_MS) {
|
|
175
|
+
if (refreshPromise) await refreshPromise;
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
lastRefreshAttemptAt = now;
|
|
179
|
+
const log = options?.logger ?? defaultLogger;
|
|
180
|
+
refreshPromise = (async () => {
|
|
181
|
+
const modelsByProvider = await buildModelsByProviderFromRemote({
|
|
182
|
+
userAgent: "dexto-llm-registry",
|
|
183
|
+
timeoutMs: 3e4
|
|
184
|
+
});
|
|
185
|
+
const cachePath = getCachePath();
|
|
186
|
+
await writeCacheFile(cachePath, modelsByProvider);
|
|
187
|
+
applyModelsByProvider(modelsByProvider);
|
|
188
|
+
lastFetchedAt = Date.now();
|
|
189
|
+
lastSource = "remote";
|
|
190
|
+
log?.debug?.(`Refreshed LLM registry cache (${cachePath})`);
|
|
191
|
+
})().catch((e) => {
|
|
192
|
+
log?.warn?.(
|
|
193
|
+
`Failed to refresh LLM registry cache: ${e instanceof Error ? e.message : String(e)}`
|
|
194
|
+
);
|
|
195
|
+
}).finally(() => {
|
|
196
|
+
refreshPromise = null;
|
|
197
|
+
});
|
|
198
|
+
await refreshPromise;
|
|
199
|
+
}
|
|
200
|
+
function startLlmRegistryAutoUpdate(options) {
|
|
201
|
+
if (autoRefreshStarted) return;
|
|
202
|
+
autoRefreshStarted = true;
|
|
203
|
+
const log = options?.logger ?? defaultLogger;
|
|
204
|
+
const loaded = loadLlmRegistryCache({ logger: log });
|
|
205
|
+
if (loaded) {
|
|
206
|
+
log?.debug?.(`Loaded LLM registry cache from disk (${getCachePath()})`);
|
|
207
|
+
}
|
|
208
|
+
if (options?.refreshOnStart !== false) {
|
|
209
|
+
void refreshLlmRegistryCache({ logger: log });
|
|
210
|
+
}
|
|
211
|
+
const timer = setInterval(
|
|
212
|
+
() => {
|
|
213
|
+
const ttlMs = getTtlMs();
|
|
214
|
+
const now = Date.now();
|
|
215
|
+
if (lastFetchedAt && isFresh(now, lastFetchedAt, ttlMs)) return;
|
|
216
|
+
void refreshLlmRegistryCache({ logger: log });
|
|
217
|
+
},
|
|
218
|
+
Math.min(getTtlMs(), DEFAULT_TTL_MS)
|
|
219
|
+
);
|
|
220
|
+
timer.unref?.();
|
|
221
|
+
}
|
|
222
|
+
export {
|
|
223
|
+
getLlmRegistryAutoUpdateStatus,
|
|
224
|
+
loadLlmRegistryCache,
|
|
225
|
+
refreshLlmRegistryCache,
|
|
226
|
+
startLlmRegistryAutoUpdate
|
|
227
|
+
};
|