@dexto/core 1.3.0 → 1.5.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 +53 -9
- package/dist/agent/DextoAgent.cjs +570 -210
- package/dist/agent/DextoAgent.d.ts +175 -35
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +568 -208
- package/dist/agent/agentCard.js +1 -1
- package/dist/agent/error-codes.cjs +1 -0
- package/dist/agent/error-codes.d.ts +2 -1
- package/dist/agent/error-codes.d.ts.map +1 -1
- package/dist/agent/error-codes.js +2 -1
- package/dist/agent/errors.cjs +13 -0
- package/dist/agent/errors.d.ts +4 -0
- package/dist/agent/errors.d.ts.map +1 -1
- package/dist/agent/errors.js +14 -1
- package/dist/agent/index.cjs +4 -1
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +6 -2
- package/dist/agent/schemas.cjs +90 -68
- package/dist/agent/schemas.d.ts +5998 -146
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/agent/schemas.js +90 -65
- package/dist/agent/state-manager.cjs +5 -5
- package/dist/agent/state-manager.d.ts +4 -4
- package/dist/agent/state-manager.js +6 -6
- package/dist/agent/types.d.ts +24 -10
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/approval/error-codes.js +1 -1
- package/dist/approval/errors.js +1 -1
- package/dist/approval/factory.js +1 -1
- package/dist/approval/index.js +1 -1
- package/dist/approval/manager.cjs +234 -4
- package/dist/approval/manager.d.ts +131 -4
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +225 -5
- package/dist/approval/schemas.cjs +57 -7
- package/dist/approval/schemas.d.ts +344 -33
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +54 -8
- package/dist/approval/types.cjs +1 -0
- package/dist/approval/types.d.ts +32 -1
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +2 -1
- package/dist/{chunk-C6A6W6XS.js → chunk-PTJYTZNU.js} +44 -1
- 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/compaction/overflow.cjs +43 -0
- package/dist/context/compaction/overflow.d.ts +33 -0
- package/dist/context/compaction/overflow.d.ts.map +1 -0
- package/dist/context/compaction/overflow.js +19 -0
- 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/{llm/tokenizer/factory.cjs → context/compaction/registry.cjs} +15 -20
- 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/{llm/tokenizer/types.cjs → context/compaction/strategies/noop.cjs} +12 -9
- 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/compaction/strategies/reactive-overflow.cjs +201 -0
- package/dist/context/compaction/strategies/reactive-overflow.d.ts +81 -0
- package/dist/context/compaction/strategies/reactive-overflow.d.ts.map +1 -0
- package/dist/context/compaction/strategies/reactive-overflow.js +178 -0
- package/dist/context/compaction/types.d.ts +20 -0
- package/dist/context/compaction/types.d.ts.map +1 -0
- package/dist/context/error-codes.cjs +7 -0
- package/dist/context/error-codes.d.ts +8 -1
- package/dist/context/error-codes.d.ts.map +1 -1
- package/dist/context/error-codes.js +8 -1
- package/dist/context/errors.cjs +68 -0
- package/dist/context/errors.d.ts +21 -0
- package/dist/context/errors.d.ts.map +1 -1
- package/dist/context/errors.js +69 -1
- 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 +2 -1
- package/dist/context/manager.cjs +280 -323
- package/dist/context/manager.d.ts +65 -111
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +280 -328
- package/dist/context/media-helpers.js +1 -1
- package/dist/context/types.cjs +49 -0
- package/dist/context/types.d.ts +187 -72
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/types.js +35 -0
- package/dist/context/utils.cjs +293 -290
- package/dist/context/utils.d.ts +32 -18
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +293 -290
- package/dist/errors/DextoBaseError.js +1 -1
- package/dist/errors/DextoRuntimeError.js +1 -1
- package/dist/errors/DextoValidationError.js +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/errors/result-bridge.cjs +2 -3
- package/dist/errors/result-bridge.d.ts.map +1 -1
- package/dist/errors/result-bridge.js +3 -4
- package/dist/errors/types.js +1 -1
- package/dist/events/index.cjs +18 -1
- package/dist/events/index.d.ts +149 -12
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +19 -2
- package/dist/filesystem/error-codes.js +1 -1
- package/dist/filesystem/errors.js +1 -1
- 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 +40 -1
- package/dist/filesystem/index.d.ts +1 -1
- package/dist/filesystem/index.d.ts.map +1 -1
- package/dist/filesystem/index.js +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 +70 -2
- 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/{llm/tokenizer/default.cjs → image/index.cjs} +10 -19
- 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.d.ts +231 -0
- package/dist/image/types.d.ts.map +1 -0
- package/dist/image/types.js +0 -0
- package/dist/index.browser.cjs +23 -8
- package/dist/index.browser.d.ts +4 -3
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +20 -3
- 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 +3 -1
- package/dist/llm/error-codes.cjs +1 -1
- package/dist/llm/error-codes.d.ts +1 -1
- package/dist/llm/error-codes.d.ts.map +1 -1
- package/dist/llm/error-codes.js +2 -2
- package/dist/llm/errors.cjs +34 -10
- package/dist/llm/errors.d.ts +23 -11
- package/dist/llm/errors.d.ts.map +1 -1
- package/dist/llm/errors.js +36 -12
- package/dist/llm/executor/stream-processor.cjs +375 -0
- package/dist/llm/executor/stream-processor.d.ts +55 -0
- package/dist/llm/executor/stream-processor.d.ts.map +1 -0
- package/dist/llm/executor/stream-processor.js +352 -0
- package/dist/llm/executor/tool-output-truncator.cjs +75 -0
- package/dist/llm/executor/tool-output-truncator.d.ts +27 -0
- package/dist/llm/executor/tool-output-truncator.d.ts.map +1 -0
- package/dist/llm/executor/tool-output-truncator.js +48 -0
- package/dist/llm/executor/turn-executor.cjs +780 -0
- package/dist/llm/executor/turn-executor.d.ts +167 -0
- package/dist/llm/executor/turn-executor.d.ts.map +1 -0
- package/dist/llm/executor/turn-executor.js +711 -0
- package/dist/llm/executor/types.cjs +16 -0
- package/dist/llm/executor/types.d.ts +27 -0
- package/dist/llm/executor/types.d.ts.map +1 -0
- package/dist/llm/executor/types.js +0 -0
- package/dist/llm/formatters/vercel.cjs +26 -188
- package/dist/llm/formatters/vercel.d.ts +2 -14
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +25 -187
- 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 +569 -52
- package/dist/llm/registry.d.ts +79 -39
- package/dist/llm/registry.d.ts.map +1 -1
- package/dist/llm/registry.js +564 -49
- package/dist/llm/resolver.cjs +62 -34
- package/dist/llm/resolver.d.ts +3 -3
- package/dist/llm/resolver.d.ts.map +1 -1
- package/dist/llm/resolver.js +69 -38
- package/dist/llm/schemas.cjs +92 -97
- package/dist/llm/schemas.d.ts +162 -39
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +93 -100
- package/dist/llm/services/factory.cjs +88 -103
- package/dist/llm/services/factory.d.ts +17 -4
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +87 -93
- package/dist/llm/services/test-utils.integration.cjs +28 -10
- 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 +33 -12
- package/dist/llm/services/types.d.ts +1 -28
- package/dist/llm/services/types.d.ts.map +1 -1
- package/dist/llm/services/vercel.cjs +58 -469
- package/dist/llm/services/vercel.d.ts +39 -21
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +60 -476
- package/dist/llm/types.cjs +11 -4
- package/dist/llm/types.d.ts +9 -9
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js +12 -4
- package/dist/llm/validation.js +1 -1
- package/dist/logger/browser.js +1 -1
- package/dist/logger/factory.js +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/logger.js +1 -1
- package/dist/logger/v2/dexto-logger.cjs +34 -6
- package/dist/logger/v2/dexto-logger.d.ts +20 -2
- package/dist/logger/v2/dexto-logger.d.ts.map +1 -1
- package/dist/logger/v2/dexto-logger.js +35 -7
- package/dist/logger/v2/error-codes.js +1 -1
- package/dist/logger/v2/errors.js +1 -1
- package/dist/logger/v2/schemas.js +1 -1
- package/dist/logger/v2/test-utils.cjs +70 -0
- package/dist/logger/v2/test-utils.d.ts +17 -0
- package/dist/logger/v2/test-utils.d.ts.map +1 -0
- package/dist/logger/v2/test-utils.js +46 -0
- package/dist/logger/v2/transport-factory.js +1 -1
- package/dist/logger/v2/transports/console-transport.js +1 -1
- package/dist/logger/v2/transports/file-transport.cjs +6 -0
- package/dist/logger/v2/transports/file-transport.d.ts +4 -0
- package/dist/logger/v2/transports/file-transport.d.ts.map +1 -1
- package/dist/logger/v2/transports/file-transport.js +7 -1
- package/dist/logger/v2/types.cjs +1 -0
- package/dist/logger/v2/types.d.ts +18 -2
- package/dist/logger/v2/types.d.ts.map +1 -1
- package/dist/logger/v2/types.js +2 -1
- package/dist/mcp/error-codes.cjs +1 -0
- package/dist/mcp/error-codes.d.ts +1 -0
- package/dist/mcp/error-codes.d.ts.map +1 -1
- package/dist/mcp/error-codes.js +2 -1
- package/dist/mcp/errors.cjs +13 -0
- package/dist/mcp/errors.d.ts +7 -0
- package/dist/mcp/errors.d.ts.map +1 -1
- package/dist/mcp/errors.js +14 -1
- package/dist/mcp/manager.cjs +12 -0
- package/dist/mcp/manager.d.ts +17 -0
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +13 -1
- package/dist/mcp/mcp-client.cjs +0 -3
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +1 -4
- package/dist/mcp/resolver.js +1 -1
- package/dist/mcp/schemas.cjs +6 -0
- package/dist/mcp/schemas.d.ts +52 -0
- package/dist/mcp/schemas.d.ts.map +1 -1
- package/dist/mcp/schemas.js +6 -1
- package/dist/memory/error-codes.js +1 -1
- package/dist/memory/errors.js +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/memory/manager.js +1 -1
- package/dist/memory/schemas.d.ts +3 -3
- package/dist/memory/schemas.js +1 -1
- package/dist/plugins/builtins/content-policy.js +1 -1
- package/dist/plugins/builtins/response-sanitizer.js +1 -1
- 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 +4 -1
- 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 +7 -2
- package/dist/plugins/loader.js +1 -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 +93 -8
- package/dist/plugins/registrations/builtins.js +1 -1
- 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 +65 -8
- package/dist/plugins/schemas.d.ts.map +1 -1
- package/dist/plugins/schemas.js +16 -5
- package/dist/plugins/types.d.ts +0 -1
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/process/command-validator.js +1 -1
- package/dist/process/error-codes.js +1 -1
- package/dist/process/errors.js +1 -1
- package/dist/process/index.js +1 -1
- package/dist/process/process-service.cjs +78 -26
- package/dist/process/process-service.d.ts +6 -1
- package/dist/process/process-service.d.ts.map +1 -1
- package/dist/process/process-service.js +79 -27
- package/dist/process/types.d.ts +2 -2
- package/dist/process/types.d.ts.map +1 -1
- package/dist/prompts/error-codes.cjs +1 -0
- package/dist/prompts/error-codes.d.ts +2 -1
- package/dist/prompts/error-codes.d.ts.map +1 -1
- package/dist/prompts/error-codes.js +2 -1
- package/dist/prompts/errors.cjs +15 -0
- package/dist/prompts/errors.d.ts +4 -0
- package/dist/prompts/errors.d.ts.map +1 -1
- package/dist/prompts/errors.js +16 -1
- package/dist/prompts/index.js +1 -1
- package/dist/prompts/name-validation.js +1 -1
- package/dist/prompts/prompt-manager.cjs +13 -2
- package/dist/prompts/prompt-manager.d.ts +7 -0
- package/dist/prompts/prompt-manager.d.ts.map +1 -1
- package/dist/prompts/prompt-manager.js +14 -3
- package/dist/prompts/providers/config-prompt-provider.cjs +12 -3
- package/dist/prompts/providers/config-prompt-provider.d.ts +2 -1
- package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.js +13 -4
- package/dist/prompts/providers/custom-prompt-provider.js +1 -1
- package/dist/prompts/providers/mcp-prompt-provider.js +1 -1
- package/dist/prompts/schemas.d.ts +12 -0
- package/dist/prompts/schemas.d.ts.map +1 -1
- package/dist/prompts/schemas.js +1 -1
- package/dist/prompts/types.d.ts +2 -0
- package/dist/prompts/types.d.ts.map +1 -1
- package/dist/prompts/utils.js +1 -1
- 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 +95 -0
- package/dist/providers/discovery.d.ts +94 -0
- package/dist/providers/discovery.d.ts.map +1 -0
- package/dist/providers/discovery.js +70 -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/error-codes.js +1 -1
- package/dist/resources/errors.js +1 -1
- package/dist/resources/handlers/blob-handler.js +1 -1
- package/dist/resources/handlers/factory.js +1 -1
- package/dist/resources/handlers/filesystem-handler.js +1 -1
- package/dist/resources/index.js +1 -1
- package/dist/resources/internal-provider.js +1 -1
- package/dist/resources/manager.js +1 -1
- package/dist/resources/reference-parser.cjs +3 -3
- package/dist/resources/reference-parser.d.ts.map +1 -1
- package/dist/resources/reference-parser.js +4 -4
- package/dist/resources/schemas.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/search/search-service.js +1 -1
- package/dist/session/chat-session.cjs +169 -54
- package/dist/session/chat-session.d.ts +69 -29
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +171 -56
- package/dist/session/error-codes.js +1 -1
- package/dist/session/errors.js +1 -1
- package/dist/session/history/database.cjs +134 -21
- package/dist/session/history/database.d.ts +37 -8
- package/dist/session/history/database.d.ts.map +1 -1
- package/dist/session/history/database.js +135 -22
- package/dist/session/history/factory.js +1 -1
- package/dist/session/history/memory.cjs +18 -0
- package/dist/session/history/memory.d.ts +8 -0
- package/dist/session/history/memory.d.ts.map +1 -1
- package/dist/session/history/memory.js +19 -1
- package/dist/session/history/types.d.ts +13 -1
- package/dist/session/history/types.d.ts.map +1 -1
- package/dist/session/index.cjs +3 -0
- package/dist/session/index.d.ts +3 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +3 -1
- package/dist/session/message-queue.cjs +201 -0
- package/dist/session/message-queue.d.ts +114 -0
- package/dist/session/message-queue.d.ts.map +1 -0
- package/dist/session/message-queue.js +178 -0
- package/dist/session/schemas.js +1 -1
- package/dist/session/session-manager.cjs +57 -7
- package/dist/session/session-manager.d.ts +18 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +58 -8
- package/dist/session/title-generator.cjs +4 -8
- package/dist/session/title-generator.d.ts +1 -2
- package/dist/session/title-generator.d.ts.map +1 -1
- package/dist/session/title-generator.js +5 -9
- package/dist/session/types.cjs +16 -0
- package/dist/session/types.d.ts +14 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +0 -0
- 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 +9 -12
- 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/local-blob-store.js +1 -1
- package/dist/storage/blob/memory-blob-store.js +1 -1
- 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 +7 -12
- 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 +9 -27
- 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/memory-cache-store.js +1 -1
- 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/redis-store.js +1 -1
- package/dist/{llm/tokenizer/google.cjs → storage/cache/registry.cjs} +23 -25
- 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 +4 -2
- 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 +9 -38
- 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/memory-database-store.js +1 -1
- package/dist/storage/database/postgres-store.cjs +12 -0
- package/dist/storage/database/postgres-store.d.ts.map +1 -1
- package/dist/storage/database/postgres-store.js +13 -1
- 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 +8 -2
- package/dist/storage/database/schemas.d.ts +3 -4
- package/dist/storage/database/schemas.d.ts.map +1 -1
- package/dist/storage/database/schemas.js +5 -2
- package/dist/storage/database/sqlite-store.js +1 -1
- 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 +7 -1
- 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 +81 -1
- 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 +33 -4
- package/dist/storage/schemas.cjs +4 -0
- package/dist/storage/schemas.d.ts +17 -50
- package/dist/storage/schemas.d.ts.map +1 -1
- package/dist/storage/schemas.js +6 -2
- package/dist/storage/storage-manager.cjs +6 -6
- package/dist/storage/storage-manager.d.ts.map +1 -1
- package/dist/storage/storage-manager.js +4 -4
- package/dist/systemPrompt/contributors.js +1 -1
- package/dist/systemPrompt/error-codes.js +1 -1
- package/dist/systemPrompt/errors.js +1 -1
- 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 +7 -6
- package/dist/systemPrompt/index.js +1 -1
- package/dist/systemPrompt/manager.js +1 -1
- 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 +3 -3
- package/dist/systemPrompt/schemas.cjs +2 -2
- package/dist/systemPrompt/schemas.d.ts +18 -18
- package/dist/systemPrompt/schemas.js +3 -3
- package/dist/telemetry/decorators.js +1 -1
- package/dist/telemetry/error-codes.js +1 -1
- package/dist/telemetry/errors.js +1 -1
- package/dist/telemetry/exporters.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/schemas.js +1 -1
- package/dist/telemetry/telemetry.js +1 -1
- package/dist/telemetry/utils.js +1 -1
- package/dist/tools/bash-pattern-utils.cjs +91 -0
- package/dist/tools/bash-pattern-utils.d.ts +58 -0
- package/dist/tools/bash-pattern-utils.d.ts.map +1 -0
- package/dist/tools/bash-pattern-utils.js +64 -0
- package/dist/tools/confirmation/allowed-tools-provider/factory.js +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/in-memory.js +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/storage.js +1 -1
- package/dist/tools/custom-tool-registry.cjs +64 -0
- package/dist/tools/custom-tool-registry.d.ts +120 -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/display-types.cjs +60 -0
- package/dist/tools/display-types.d.ts +133 -0
- package/dist/tools/display-types.d.ts.map +1 -0
- package/dist/tools/display-types.js +32 -0
- package/dist/tools/error-codes.cjs +5 -0
- package/dist/tools/error-codes.d.ts +6 -1
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +6 -1
- package/dist/tools/errors.cjs +71 -0
- package/dist/tools/errors.d.ts +33 -0
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +72 -1
- package/dist/tools/index.cjs +15 -1
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +13 -2
- 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 +4 -10
- package/dist/tools/internal-tools/implementations/ask-user-tool.cjs +1 -1
- package/dist/tools/internal-tools/implementations/ask-user-tool.js +2 -2
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.js +1 -1
- 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/implementations/search-history-tool.js +1 -1
- package/dist/tools/internal-tools/provider.cjs +175 -31
- package/dist/tools/internal-tools/provider.d.ts +62 -14
- package/dist/tools/internal-tools/provider.d.ts.map +1 -1
- package/dist/tools/internal-tools/provider.js +176 -32
- package/dist/tools/internal-tools/registry.cjs +19 -43
- package/dist/tools/internal-tools/registry.d.ts +32 -11
- package/dist/tools/internal-tools/registry.d.ts.map +1 -1
- package/dist/tools/internal-tools/registry.js +20 -44
- package/dist/tools/schemas.cjs +36 -6
- package/dist/tools/schemas.d.ts +74 -5
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +30 -6
- package/dist/tools/tool-manager.cjs +279 -30
- package/dist/tools/tool-manager.d.ts +45 -4
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +284 -31
- package/dist/tools/types.d.ts +63 -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 +20 -2
- package/dist/utils/async-context.js +1 -1
- package/dist/utils/debug.js +1 -1
- package/dist/{llm/tokenizer/anthropic.cjs → utils/defer.cjs} +19 -20
- package/dist/utils/defer.d.ts +63 -0
- package/dist/utils/defer.d.ts.map +1 -0
- package/dist/utils/defer.js +19 -0
- package/dist/utils/error-conversion.js +1 -1
- package/dist/utils/execution-context.js +1 -1
- package/dist/utils/fs-walk.js +1 -1
- package/dist/utils/index.cjs +3 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/path.js +1 -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 +19 -4
- package/dist/utils/result.js +1 -1
- package/dist/utils/safe-stringify.js +1 -1
- package/dist/utils/schema-metadata.js +1 -1
- package/dist/utils/schema.js +1 -1
- package/dist/utils/service-initializer.cjs +15 -37
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +16 -38
- package/dist/utils/user-info.js +1 -1
- package/dist/utils/zod-schema-converter.js +1 -1
- package/package.json +10 -8
- package/dist/context/compression/middle-removal.cjs +0 -95
- package/dist/context/compression/middle-removal.d.ts +0 -47
- package/dist/context/compression/middle-removal.d.ts.map +0 -1
- package/dist/context/compression/middle-removal.js +0 -72
- package/dist/context/compression/oldest-removal.cjs +0 -83
- package/dist/context/compression/oldest-removal.d.ts +0 -42
- package/dist/context/compression/oldest-removal.d.ts.map +0 -1
- package/dist/context/compression/oldest-removal.js +0 -60
- package/dist/context/compression/types.d.ts +0 -18
- package/dist/context/compression/types.d.ts.map +0 -1
- package/dist/llm/formatters/anthropic.cjs +0 -257
- package/dist/llm/formatters/anthropic.d.ts +0 -46
- package/dist/llm/formatters/anthropic.d.ts.map +0 -1
- package/dist/llm/formatters/anthropic.js +0 -239
- package/dist/llm/formatters/factory.cjs +0 -50
- package/dist/llm/formatters/factory.d.ts +0 -10
- package/dist/llm/formatters/factory.d.ts.map +0 -1
- package/dist/llm/formatters/factory.js +0 -27
- package/dist/llm/formatters/openai.cjs +0 -203
- package/dist/llm/formatters/openai.d.ts +0 -39
- package/dist/llm/formatters/openai.d.ts.map +0 -1
- package/dist/llm/formatters/openai.js +0 -184
- package/dist/llm/formatters/types.d.ts +0 -41
- package/dist/llm/formatters/types.d.ts.map +0 -1
- package/dist/llm/services/anthropic.cjs +0 -511
- package/dist/llm/services/anthropic.d.ts +0 -48
- package/dist/llm/services/anthropic.d.ts.map +0 -1
- package/dist/llm/services/anthropic.js +0 -447
- package/dist/llm/services/openai.cjs +0 -611
- package/dist/llm/services/openai.d.ts +0 -48
- package/dist/llm/services/openai.d.ts.map +0 -1
- package/dist/llm/services/openai.js +0 -547
- package/dist/llm/tokenizer/anthropic.d.ts +0 -19
- package/dist/llm/tokenizer/anthropic.d.ts.map +0 -1
- package/dist/llm/tokenizer/anthropic.js +0 -20
- package/dist/llm/tokenizer/default.d.ts +0 -14
- package/dist/llm/tokenizer/default.d.ts.map +0 -1
- package/dist/llm/tokenizer/default.js +0 -18
- package/dist/llm/tokenizer/factory.d.ts +0 -12
- package/dist/llm/tokenizer/factory.d.ts.map +0 -1
- package/dist/llm/tokenizer/factory.js +0 -21
- package/dist/llm/tokenizer/google.d.ts +0 -29
- package/dist/llm/tokenizer/google.d.ts.map +0 -1
- package/dist/llm/tokenizer/google.js +0 -29
- package/dist/llm/tokenizer/openai.cjs +0 -115
- package/dist/llm/tokenizer/openai.d.ts +0 -41
- package/dist/llm/tokenizer/openai.d.ts.map +0 -1
- package/dist/llm/tokenizer/openai.js +0 -91
- package/dist/llm/tokenizer/types.d.ts +0 -18
- package/dist/llm/tokenizer/types.d.ts.map +0 -1
- package/dist/llm/tokenizer/types.js +0 -10
- package/dist/tools/internal-tools/implementations/bash-exec-tool.cjs +0 -106
- 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 -73
- 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 -62
- 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 -39
- package/dist/tools/internal-tools/implementations/glob-files-tool.cjs +0 -57
- 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 -34
- package/dist/tools/internal-tools/implementations/grep-content-tool.cjs +0 -71
- 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 -48
- 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 -55
- 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 -32
- package/dist/tools/internal-tools/implementations/write-file-tool.cjs +0 -56
- 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 -33
- 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
- /package/dist/{llm/formatters → context/compaction}/types.js +0 -0
- /package/dist/{llm/formatters → image}/types.cjs +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContextManager } from '../context/index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VercelLLMService } from '../llm/services/vercel.js';
|
|
3
3
|
import type { SystemPromptManager } from '../systemPrompt/manager.js';
|
|
4
4
|
import type { ToolManager } from '../tools/tool-manager.js';
|
|
5
5
|
import type { ValidatedLLMConfig } from '../llm/schemas.js';
|
|
@@ -10,6 +10,8 @@ import type { MCPManager } from '../mcp/manager.js';
|
|
|
10
10
|
import { SessionEventBus, AgentEventBus } from '../events/index.js';
|
|
11
11
|
import type { IDextoLogger } from '../logger/v2/types.js';
|
|
12
12
|
import type { InternalMessage } from '../context/types.js';
|
|
13
|
+
import type { UserMessageInput } from './message-queue.js';
|
|
14
|
+
import type { ContentInput } from '../agent/types.js';
|
|
13
15
|
/**
|
|
14
16
|
* Represents an isolated conversation session within a Dexto agent.
|
|
15
17
|
*
|
|
@@ -52,7 +54,7 @@ import type { InternalMessage } from '../context/types.js';
|
|
|
52
54
|
*
|
|
53
55
|
* @see {@link SessionManager} for session lifecycle management
|
|
54
56
|
* @see {@link ContextManager} for conversation history management
|
|
55
|
-
* @see {@link
|
|
57
|
+
* @see {@link VercelLLMService} for AI model interaction
|
|
56
58
|
*/
|
|
57
59
|
export declare class ChatSession {
|
|
58
60
|
private services;
|
|
@@ -86,6 +88,10 @@ export declare class ChatSession {
|
|
|
86
88
|
* Stores the bound functions so they can be removed from the event bus.
|
|
87
89
|
*/
|
|
88
90
|
private forwarders;
|
|
91
|
+
/**
|
|
92
|
+
* Token accumulator listener for cleanup.
|
|
93
|
+
*/
|
|
94
|
+
private tokenAccumulatorListener;
|
|
89
95
|
/**
|
|
90
96
|
* AbortController for the currently running turn, if any.
|
|
91
97
|
* Calling cancel() aborts the in-flight LLM request and tool execution checks.
|
|
@@ -129,6 +135,11 @@ export declare class ChatSession {
|
|
|
129
135
|
* information when needed.
|
|
130
136
|
*/
|
|
131
137
|
private setupEventForwarding;
|
|
138
|
+
/**
|
|
139
|
+
* Sets up token usage accumulation by listening to llm:response events.
|
|
140
|
+
* Accumulates token usage and cost to session metadata for /stats tracking.
|
|
141
|
+
*/
|
|
142
|
+
private setupTokenAccumulation;
|
|
132
143
|
/**
|
|
133
144
|
* Initializes session-specific services.
|
|
134
145
|
*/
|
|
@@ -146,36 +157,33 @@ export declare class ChatSession {
|
|
|
146
157
|
*/
|
|
147
158
|
private saveBlockedInteraction;
|
|
148
159
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* This method:
|
|
152
|
-
* 1. Takes user input (text, optionally with image or file data)
|
|
153
|
-
* 2. Passes it to the LLM service for processing
|
|
154
|
-
* 3. Returns the AI's response text
|
|
160
|
+
* Stream a response for the given content.
|
|
161
|
+
* Primary method for running conversations with multi-image support.
|
|
155
162
|
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* @param input - The user's text input
|
|
160
|
-
* @param imageDataInput - Optional image data for multimodal input
|
|
161
|
-
* @param fileDataInput - Optional file data for file input
|
|
162
|
-
* @param stream - Optional flag to enable streaming responses
|
|
163
|
+
* @param content - String or ContentPart[] (text, images, files)
|
|
164
|
+
* @param options - { signal?: AbortSignal }
|
|
163
165
|
* @returns Promise that resolves to the AI's response text
|
|
164
166
|
*
|
|
165
167
|
* @example
|
|
166
168
|
* ```typescript
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
+
* // Text only
|
|
170
|
+
* const response = await session.stream('What is the weather?');
|
|
171
|
+
*
|
|
172
|
+
* // Multiple images
|
|
173
|
+
* const response = await session.stream([
|
|
174
|
+
* { type: 'text', text: 'Compare these images' },
|
|
175
|
+
* { type: 'image', image: base64Data1, mimeType: 'image/png' },
|
|
176
|
+
* { type: 'image', image: base64Data2, mimeType: 'image/png' }
|
|
177
|
+
* ]);
|
|
169
178
|
* ```
|
|
170
179
|
*/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}, stream?: boolean): Promise<string>;
|
|
180
|
+
stream(content: ContentInput, options?: {
|
|
181
|
+
signal?: AbortSignal;
|
|
182
|
+
}): Promise<string>;
|
|
183
|
+
/**
|
|
184
|
+
* Combine multiple abort signals into one.
|
|
185
|
+
*/
|
|
186
|
+
private combineSignals;
|
|
179
187
|
/**
|
|
180
188
|
* Retrieves the complete conversation history for this session.
|
|
181
189
|
*
|
|
@@ -231,15 +239,15 @@ export declare class ChatSession {
|
|
|
231
239
|
*
|
|
232
240
|
* @returns The LLMService for this session
|
|
233
241
|
*/
|
|
234
|
-
getLLMService():
|
|
242
|
+
getLLMService(): VercelLLMService;
|
|
235
243
|
/**
|
|
236
244
|
* Switches the LLM service for this session while preserving conversation history.
|
|
237
245
|
*
|
|
238
|
-
* This method creates a new LLM service with the specified configuration
|
|
246
|
+
* This method creates a new LLM service with the specified configuration,
|
|
239
247
|
* while maintaining the existing ContextManager and conversation history. This allows
|
|
240
248
|
* users to change AI models mid-conversation without losing context.
|
|
241
249
|
*
|
|
242
|
-
* @param newLLMConfig The new LLM configuration to use
|
|
250
|
+
* @param newLLMConfig The new LLM configuration to use
|
|
243
251
|
*
|
|
244
252
|
* @example
|
|
245
253
|
* ```typescript
|
|
@@ -248,7 +256,6 @@ export declare class ChatSession {
|
|
|
248
256
|
* provider: 'openai',
|
|
249
257
|
* model: 'gpt-5',
|
|
250
258
|
* apiKey: process.env.OPENAI_API_KEY,
|
|
251
|
-
* router: 'in-built'
|
|
252
259
|
* });
|
|
253
260
|
* ```
|
|
254
261
|
*/
|
|
@@ -267,6 +274,39 @@ export declare class ChatSession {
|
|
|
267
274
|
* Without this cleanup, sessions would remain in memory due to listener references.
|
|
268
275
|
*/
|
|
269
276
|
dispose(): void;
|
|
277
|
+
/**
|
|
278
|
+
* Check if this session is currently processing a message.
|
|
279
|
+
* Returns true if a run is in progress and has not been aborted.
|
|
280
|
+
*/
|
|
281
|
+
isBusy(): boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Queue a message for processing when the session is busy.
|
|
284
|
+
* The message will be injected into the conversation when the current turn completes.
|
|
285
|
+
*
|
|
286
|
+
* @param message The user message to queue
|
|
287
|
+
* @returns Queue position and message ID
|
|
288
|
+
*/
|
|
289
|
+
queueMessage(message: UserMessageInput): {
|
|
290
|
+
queued: true;
|
|
291
|
+
position: number;
|
|
292
|
+
id: string;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Get all messages currently in the queue.
|
|
296
|
+
* @returns Array of queued messages
|
|
297
|
+
*/
|
|
298
|
+
getQueuedMessages(): import('./types.js').QueuedMessage[];
|
|
299
|
+
/**
|
|
300
|
+
* Remove a queued message.
|
|
301
|
+
* @param id Message ID to remove
|
|
302
|
+
* @returns true if message was found and removed; false otherwise
|
|
303
|
+
*/
|
|
304
|
+
removeQueuedMessage(id: string): boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Clear all queued messages.
|
|
307
|
+
* @returns Number of messages that were cleared
|
|
308
|
+
*/
|
|
309
|
+
clearMessageQueue(): number;
|
|
270
310
|
/**
|
|
271
311
|
* Cancel the currently running turn for this session, if any.
|
|
272
312
|
* Returns true if a run was in progress and was signaled to abort.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-session.d.ts","sourceRoot":"","sources":["../../src/session/chat-session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat-session.d.ts","sourceRoot":"","sources":["../../src/session/chat-session.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACH,eAAe,EACf,aAAa,EAIhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBAAa,WAAW;IA6DhB,OAAO,CAAC,QAAQ;aAWA,EAAE,EAAE,MAAM;IAvE9B;;;;;;;;;;OAUG;IACH,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAE1C;;;OAGG;IACH,OAAO,CAAC,eAAe,CAAgC;IAEvD;;;;;OAKG;IACH,OAAO,CAAC,UAAU,CAAoB;IAEtC;;;OAGG;IACH,OAAO,CAAC,UAAU,CAA6D;IAE/E;;OAEG;IACH,OAAO,CAAC,wBAAwB,CACvB;IAET;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAAgC;IAE5D,OAAO,CAAC,MAAM,CAAe;IAE7B;;;;;;;;;;;OAWG;gBAES,QAAQ,EAAE;QACd,YAAY,EAAE,iBAAiB,CAAC;QAChC,mBAAmB,EAAE,mBAAmB,CAAC;QACzC,WAAW,EAAE,WAAW,CAAC;QACzB,aAAa,EAAE,aAAa,CAAC;QAC7B,cAAc,EAAE,cAAc,CAAC;QAC/B,eAAe,EAAE,OAAO,uBAAuB,EAAE,eAAe,CAAC;QACjE,aAAa,EAAE,aAAa,CAAC;QAC7B,UAAU,EAAE,UAAU,CAAC;QACvB,cAAc,EAAE,OAAO,sBAAsB,EAAE,cAAc,CAAC;KACjE,EACe,EAAE,EAAE,MAAM,EAC1B,MAAM,EAAE,YAAY;IAaxB;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IA4B5B;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAyB9B;;OAEG;YACW,kBAAkB;IAqChC;;;;;;;;;;OAUG;YACW,sBAAsB;IAoCpC;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,MAAM,CACf,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACnC,OAAO,CAAC,MAAM,CAAC;IAgKlB;;OAEG;IACH,OAAO,CAAC,cAAc;IAetB;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,UAAU;IAIvB;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAUnC;;;;OAIG;IACI,iBAAiB,IAAI,cAAc,CAAC,OAAO,CAAC;IAInD;;;;OAIG;IACI,aAAa,IAAI,gBAAgB;IAIxC;;;;;;;;;;;;;;;;;;OAkBG;IACU,SAAS,CAAC,YAAY,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8CvE;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBrC;;;;;;OAMG;IACI,OAAO,IAAI,IAAI;IAoBtB;;;OAGG;IACI,MAAM,IAAI,OAAO;IAIxB;;;;;;OAMG;IACI,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG;QAAE,MAAM,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE;IAI9F;;;OAGG;IACI,iBAAiB,IAAI,OAAO,YAAY,EAAE,aAAa,EAAE;IAIhE;;;;OAIG;IACI,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI/C;;;OAGG;IACI,iBAAiB,IAAI,MAAM;IAOlC;;;OAGG;IACI,MAAM,IAAI,OAAO;CAa3B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-PTJYTZNU.js";
|
|
2
2
|
import { createDatabaseHistoryProvider } from "./history/factory.js";
|
|
3
|
-
import { createLLMService } from "../llm/services/factory.js";
|
|
3
|
+
import { createLLMService, createVercelModel } from "../llm/services/factory.js";
|
|
4
|
+
import { createCompactionStrategy } from "../context/compaction/index.js";
|
|
4
5
|
import {
|
|
5
6
|
SessionEventBus,
|
|
6
7
|
SessionEventNames
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
8
9
|
import { DextoLogComponent } from "../logger/v2/types.js";
|
|
9
10
|
import { DextoRuntimeError, ErrorScope, ErrorType } from "../errors/index.js";
|
|
10
11
|
import { PluginErrorCode } from "../plugins/error-codes.js";
|
|
12
|
+
import { getModelPricing, calculateCost } from "../llm/registry.js";
|
|
11
13
|
class ChatSession {
|
|
12
14
|
/**
|
|
13
15
|
* Creates a new ChatSession instance.
|
|
@@ -58,6 +60,10 @@ class ChatSession {
|
|
|
58
60
|
* Stores the bound functions so they can be removed from the event bus.
|
|
59
61
|
*/
|
|
60
62
|
forwarders = /* @__PURE__ */ new Map();
|
|
63
|
+
/**
|
|
64
|
+
* Token accumulator listener for cleanup.
|
|
65
|
+
*/
|
|
66
|
+
tokenAccumulatorListener = null;
|
|
61
67
|
/**
|
|
62
68
|
* AbortController for the currently running turn, if any.
|
|
63
69
|
* Calling cancel() aborts the in-flight LLM request and tool execution checks.
|
|
@@ -88,23 +94,51 @@ class ChatSession {
|
|
|
88
94
|
this.forwarders.set(eventName, forwarder);
|
|
89
95
|
this.eventBus.on(eventName, forwarder);
|
|
90
96
|
});
|
|
97
|
+
this.setupTokenAccumulation();
|
|
91
98
|
this.logger.debug(
|
|
92
99
|
`[setupEventForwarding] Event forwarding setup complete for session=${this.id}`
|
|
93
100
|
);
|
|
94
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Sets up token usage accumulation by listening to llm:response events.
|
|
104
|
+
* Accumulates token usage and cost to session metadata for /stats tracking.
|
|
105
|
+
*/
|
|
106
|
+
setupTokenAccumulation() {
|
|
107
|
+
this.tokenAccumulatorListener = (payload) => {
|
|
108
|
+
if (payload.tokenUsage) {
|
|
109
|
+
let cost;
|
|
110
|
+
const llmConfig = this.services.stateManager.getLLMConfig(this.id);
|
|
111
|
+
const pricing = getModelPricing(llmConfig.provider, llmConfig.model);
|
|
112
|
+
if (pricing) {
|
|
113
|
+
cost = calculateCost(payload.tokenUsage, pricing);
|
|
114
|
+
}
|
|
115
|
+
this.services.sessionManager.accumulateTokenUsage(this.id, payload.tokenUsage, cost).catch((err) => {
|
|
116
|
+
this.logger.warn(
|
|
117
|
+
`Failed to accumulate token usage: ${err instanceof Error ? err.message : String(err)}`
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
this.eventBus.on("llm:response", this.tokenAccumulatorListener);
|
|
123
|
+
}
|
|
95
124
|
/**
|
|
96
125
|
* Initializes session-specific services.
|
|
97
126
|
*/
|
|
98
127
|
async initializeServices() {
|
|
99
|
-
const
|
|
128
|
+
const runtimeConfig = this.services.stateManager.getRuntimeConfig(this.id);
|
|
129
|
+
const llmConfig = runtimeConfig.llm;
|
|
100
130
|
this.historyProvider = createDatabaseHistoryProvider(
|
|
101
131
|
this.services.storageManager.getDatabase(),
|
|
102
132
|
this.id,
|
|
103
133
|
this.logger
|
|
104
134
|
);
|
|
135
|
+
const model = createVercelModel(llmConfig);
|
|
136
|
+
const compactionStrategy = await createCompactionStrategy(runtimeConfig.compaction, {
|
|
137
|
+
logger: this.logger,
|
|
138
|
+
model
|
|
139
|
+
});
|
|
105
140
|
this.llmService = createLLMService(
|
|
106
141
|
llmConfig,
|
|
107
|
-
llmConfig.router,
|
|
108
142
|
this.services.toolManager,
|
|
109
143
|
this.services.systemPromptManager,
|
|
110
144
|
this.historyProvider,
|
|
@@ -114,8 +148,10 @@ class ChatSession {
|
|
|
114
148
|
this.id,
|
|
115
149
|
this.services.resourceManager,
|
|
116
150
|
// Pass ResourceManager for blob storage
|
|
117
|
-
this.logger
|
|
151
|
+
this.logger,
|
|
118
152
|
// Pass logger for dependency injection
|
|
153
|
+
compactionStrategy
|
|
154
|
+
// Pass compaction strategy
|
|
119
155
|
);
|
|
120
156
|
this.logger.debug(`ChatSession ${this.id}: Services initialized with storage`);
|
|
121
157
|
}
|
|
@@ -133,12 +169,12 @@ class ChatSession {
|
|
|
133
169
|
async saveBlockedInteraction(userInput, errorMessage, _imageData, _fileData) {
|
|
134
170
|
const userMessage = {
|
|
135
171
|
role: "user",
|
|
136
|
-
content: "[Blocked by content policy: input redacted]"
|
|
172
|
+
content: [{ type: "text", text: "[Blocked by content policy: input redacted]" }]
|
|
137
173
|
};
|
|
138
174
|
const errorContent = `Error: ${errorMessage}`;
|
|
139
175
|
const assistantMessage = {
|
|
140
176
|
role: "assistant",
|
|
141
|
-
content: errorContent
|
|
177
|
+
content: [{ type: "text", text: errorContent }]
|
|
142
178
|
};
|
|
143
179
|
await this.historyProvider.saveMessage(userMessage);
|
|
144
180
|
await this.historyProvider.saveMessage(assistantMessage);
|
|
@@ -146,44 +182,61 @@ class ChatSession {
|
|
|
146
182
|
this.eventBus.emit("llm:response", {
|
|
147
183
|
content: errorContent,
|
|
148
184
|
provider: llmConfig.provider,
|
|
149
|
-
model: llmConfig.model
|
|
150
|
-
router: llmConfig.router
|
|
185
|
+
model: llmConfig.model
|
|
151
186
|
});
|
|
152
187
|
}
|
|
153
188
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* This method:
|
|
157
|
-
* 1. Takes user input (text, optionally with image or file data)
|
|
158
|
-
* 2. Passes it to the LLM service for processing
|
|
159
|
-
* 3. Returns the AI's response text
|
|
160
|
-
*
|
|
161
|
-
* The method handles both text-only and multimodal input (text + images/files).
|
|
162
|
-
* Tool calls and conversation management are handled internally by the LLM service.
|
|
189
|
+
* Stream a response for the given content.
|
|
190
|
+
* Primary method for running conversations with multi-image support.
|
|
163
191
|
*
|
|
164
|
-
* @param
|
|
165
|
-
* @param
|
|
166
|
-
* @param fileDataInput - Optional file data for file input
|
|
167
|
-
* @param stream - Optional flag to enable streaming responses
|
|
192
|
+
* @param content - String or ContentPart[] (text, images, files)
|
|
193
|
+
* @param options - { signal?: AbortSignal }
|
|
168
194
|
* @returns Promise that resolves to the AI's response text
|
|
169
195
|
*
|
|
170
196
|
* @example
|
|
171
197
|
* ```typescript
|
|
172
|
-
*
|
|
173
|
-
*
|
|
198
|
+
* // Text only
|
|
199
|
+
* const response = await session.stream('What is the weather?');
|
|
200
|
+
*
|
|
201
|
+
* // Multiple images
|
|
202
|
+
* const response = await session.stream([
|
|
203
|
+
* { type: 'text', text: 'Compare these images' },
|
|
204
|
+
* { type: 'image', image: base64Data1, mimeType: 'image/png' },
|
|
205
|
+
* { type: 'image', image: base64Data2, mimeType: 'image/png' }
|
|
206
|
+
* ]);
|
|
174
207
|
* ```
|
|
175
208
|
*/
|
|
176
|
-
async
|
|
209
|
+
async stream(content, options) {
|
|
210
|
+
const parts = typeof content === "string" ? [{ type: "text", text: content }] : content;
|
|
211
|
+
const textParts = parts.filter(
|
|
212
|
+
(p) => p.type === "text"
|
|
213
|
+
);
|
|
214
|
+
const imageParts = parts.filter((p) => p.type === "image");
|
|
215
|
+
const fileParts = parts.filter((p) => p.type === "file");
|
|
177
216
|
this.logger.debug(
|
|
178
|
-
`
|
|
217
|
+
`Streaming session ${this.id} | textParts=${textParts.length} | images=${imageParts.length} | files=${fileParts.length}`
|
|
179
218
|
);
|
|
180
219
|
this.currentRunController = new AbortController();
|
|
181
|
-
const signal = this.currentRunController.signal;
|
|
220
|
+
const signal = options?.signal ? this.combineSignals(options.signal, this.currentRunController.signal) : this.currentRunController.signal;
|
|
182
221
|
try {
|
|
222
|
+
const textContent = textParts.map((p) => p.text).join("\n");
|
|
223
|
+
const firstImage = imageParts[0];
|
|
224
|
+
const firstFile = fileParts[0];
|
|
183
225
|
const beforeLLMPayload = {
|
|
184
|
-
text:
|
|
185
|
-
...
|
|
186
|
-
|
|
226
|
+
text: textContent,
|
|
227
|
+
...firstImage && {
|
|
228
|
+
imageData: {
|
|
229
|
+
image: typeof firstImage.image === "string" ? firstImage.image : "[binary]",
|
|
230
|
+
mimeType: firstImage.mimeType || "image/jpeg"
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
...firstFile && {
|
|
234
|
+
fileData: {
|
|
235
|
+
data: typeof firstFile.data === "string" ? firstFile.data : "[binary]",
|
|
236
|
+
mimeType: firstFile.mimeType,
|
|
237
|
+
...firstFile.filename && { filename: firstFile.filename }
|
|
238
|
+
}
|
|
239
|
+
},
|
|
187
240
|
sessionId: this.id
|
|
188
241
|
};
|
|
189
242
|
const modifiedBeforePayload = await this.services.pluginManager.executePlugins(
|
|
@@ -198,22 +251,17 @@ class ChatSession {
|
|
|
198
251
|
abortSignal: signal
|
|
199
252
|
}
|
|
200
253
|
);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
finalImageData,
|
|
208
|
-
finalFileData,
|
|
209
|
-
stream
|
|
210
|
-
);
|
|
254
|
+
let modifiedParts = [...parts];
|
|
255
|
+
if (modifiedBeforePayload.text !== textContent && textParts.length > 0) {
|
|
256
|
+
modifiedParts = modifiedParts.filter((p) => p.type !== "text");
|
|
257
|
+
modifiedParts.unshift({ type: "text", text: modifiedBeforePayload.text });
|
|
258
|
+
}
|
|
259
|
+
const response = await this.llmService.stream(modifiedParts, { signal });
|
|
211
260
|
const llmConfig = this.services.stateManager.getLLMConfig(this.id);
|
|
212
261
|
const beforeResponsePayload = {
|
|
213
262
|
content: response,
|
|
214
263
|
provider: llmConfig.provider,
|
|
215
264
|
model: llmConfig.model,
|
|
216
|
-
router: llmConfig.router,
|
|
217
265
|
sessionId: this.id
|
|
218
266
|
};
|
|
219
267
|
const modifiedResponsePayload = await this.services.pluginManager.executePlugins(
|
|
@@ -237,16 +285,21 @@ class ChatSession {
|
|
|
237
285
|
context: "user_cancelled",
|
|
238
286
|
recoverable: true
|
|
239
287
|
});
|
|
288
|
+
try {
|
|
289
|
+
const history = await this.getHistory();
|
|
290
|
+
const lastAssistant = history.filter((m) => m.role === "assistant").pop();
|
|
291
|
+
if (lastAssistant && typeof lastAssistant.content === "string") {
|
|
292
|
+
return lastAssistant.content;
|
|
293
|
+
}
|
|
294
|
+
} catch {
|
|
295
|
+
this.logger.debug("Failed to retrieve partial response from history on cancel");
|
|
296
|
+
}
|
|
240
297
|
return "";
|
|
241
298
|
}
|
|
242
299
|
if (error instanceof DextoRuntimeError && error.code === PluginErrorCode.PLUGIN_BLOCKED_EXECUTION && error.scope === ErrorScope.PLUGIN && error.type === ErrorType.FORBIDDEN) {
|
|
300
|
+
const textContent = parts.filter((p) => p.type === "text").map((p) => p.text).join("\n");
|
|
243
301
|
try {
|
|
244
|
-
await this.saveBlockedInteraction(
|
|
245
|
-
input,
|
|
246
|
-
error.message,
|
|
247
|
-
imageDataInput,
|
|
248
|
-
fileDataInput
|
|
249
|
-
);
|
|
302
|
+
await this.saveBlockedInteraction(textContent, error.message);
|
|
250
303
|
this.logger.debug(
|
|
251
304
|
`ChatSession ${this.id}: Saved blocked interaction to history`
|
|
252
305
|
);
|
|
@@ -257,15 +310,27 @@ class ChatSession {
|
|
|
257
310
|
}
|
|
258
311
|
return error.message;
|
|
259
312
|
}
|
|
260
|
-
const errortype = error instanceof Error ? "object" : "string";
|
|
261
313
|
this.logger.error(
|
|
262
|
-
`Error in ChatSession.
|
|
314
|
+
`Error in ChatSession.stream: ${error instanceof Error ? error.message : String(error)}`
|
|
263
315
|
);
|
|
264
316
|
throw error;
|
|
265
317
|
} finally {
|
|
266
318
|
this.currentRunController = null;
|
|
267
319
|
}
|
|
268
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Combine multiple abort signals into one.
|
|
323
|
+
*/
|
|
324
|
+
combineSignals(signal1, signal2) {
|
|
325
|
+
const controller = new AbortController();
|
|
326
|
+
const onAbort = () => controller.abort();
|
|
327
|
+
signal1.addEventListener("abort", onAbort);
|
|
328
|
+
signal2.addEventListener("abort", onAbort);
|
|
329
|
+
if (signal1.aborted || signal2.aborted) {
|
|
330
|
+
controller.abort();
|
|
331
|
+
}
|
|
332
|
+
return controller.signal;
|
|
333
|
+
}
|
|
269
334
|
/**
|
|
270
335
|
* Retrieves the complete conversation history for this session.
|
|
271
336
|
*
|
|
@@ -336,11 +401,11 @@ class ChatSession {
|
|
|
336
401
|
/**
|
|
337
402
|
* Switches the LLM service for this session while preserving conversation history.
|
|
338
403
|
*
|
|
339
|
-
* This method creates a new LLM service with the specified configuration
|
|
404
|
+
* This method creates a new LLM service with the specified configuration,
|
|
340
405
|
* while maintaining the existing ContextManager and conversation history. This allows
|
|
341
406
|
* users to change AI models mid-conversation without losing context.
|
|
342
407
|
*
|
|
343
|
-
* @param newLLMConfig The new LLM configuration to use
|
|
408
|
+
* @param newLLMConfig The new LLM configuration to use
|
|
344
409
|
*
|
|
345
410
|
* @example
|
|
346
411
|
* ```typescript
|
|
@@ -349,16 +414,19 @@ class ChatSession {
|
|
|
349
414
|
* provider: 'openai',
|
|
350
415
|
* model: 'gpt-5',
|
|
351
416
|
* apiKey: process.env.OPENAI_API_KEY,
|
|
352
|
-
* router: 'in-built'
|
|
353
417
|
* });
|
|
354
418
|
* ```
|
|
355
419
|
*/
|
|
356
420
|
async switchLLM(newLLMConfig) {
|
|
357
421
|
try {
|
|
358
|
-
const
|
|
422
|
+
const runtimeConfig = this.services.stateManager.getRuntimeConfig(this.id);
|
|
423
|
+
const model = createVercelModel(newLLMConfig);
|
|
424
|
+
const compactionStrategy = await createCompactionStrategy(runtimeConfig.compaction, {
|
|
425
|
+
logger: this.logger,
|
|
426
|
+
model
|
|
427
|
+
});
|
|
359
428
|
const newLLMService = createLLMService(
|
|
360
429
|
newLLMConfig,
|
|
361
|
-
router,
|
|
362
430
|
this.services.toolManager,
|
|
363
431
|
this.services.systemPromptManager,
|
|
364
432
|
this.historyProvider,
|
|
@@ -367,7 +435,9 @@ class ChatSession {
|
|
|
367
435
|
// Use session event bus
|
|
368
436
|
this.id,
|
|
369
437
|
this.services.resourceManager,
|
|
370
|
-
this.logger
|
|
438
|
+
this.logger,
|
|
439
|
+
compactionStrategy
|
|
440
|
+
// Pass compaction strategy
|
|
371
441
|
);
|
|
372
442
|
this.llmService = newLLMService;
|
|
373
443
|
this.logger.info(
|
|
@@ -375,7 +445,6 @@ class ChatSession {
|
|
|
375
445
|
);
|
|
376
446
|
this.eventBus.emit("llm:switched", {
|
|
377
447
|
newConfig: newLLMConfig,
|
|
378
|
-
router,
|
|
379
448
|
historyRetained: true
|
|
380
449
|
});
|
|
381
450
|
} catch (error) {
|
|
@@ -416,8 +485,54 @@ class ChatSession {
|
|
|
416
485
|
this.eventBus.off(eventName, forwarder);
|
|
417
486
|
});
|
|
418
487
|
this.forwarders.clear();
|
|
488
|
+
if (this.tokenAccumulatorListener) {
|
|
489
|
+
this.eventBus.off("llm:response", this.tokenAccumulatorListener);
|
|
490
|
+
this.tokenAccumulatorListener = null;
|
|
491
|
+
}
|
|
419
492
|
this.logger.debug(`Session ${this.id} disposed successfully`);
|
|
420
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* Check if this session is currently processing a message.
|
|
496
|
+
* Returns true if a run is in progress and has not been aborted.
|
|
497
|
+
*/
|
|
498
|
+
isBusy() {
|
|
499
|
+
return this.currentRunController !== null && !this.currentRunController.signal.aborted;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Queue a message for processing when the session is busy.
|
|
503
|
+
* The message will be injected into the conversation when the current turn completes.
|
|
504
|
+
*
|
|
505
|
+
* @param message The user message to queue
|
|
506
|
+
* @returns Queue position and message ID
|
|
507
|
+
*/
|
|
508
|
+
queueMessage(message) {
|
|
509
|
+
return this.llmService.getMessageQueue().enqueue(message);
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Get all messages currently in the queue.
|
|
513
|
+
* @returns Array of queued messages
|
|
514
|
+
*/
|
|
515
|
+
getQueuedMessages() {
|
|
516
|
+
return this.llmService.getMessageQueue().getAll();
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Remove a queued message.
|
|
520
|
+
* @param id Message ID to remove
|
|
521
|
+
* @returns true if message was found and removed; false otherwise
|
|
522
|
+
*/
|
|
523
|
+
removeQueuedMessage(id) {
|
|
524
|
+
return this.llmService.getMessageQueue().remove(id);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Clear all queued messages.
|
|
528
|
+
* @returns Number of messages that were cleared
|
|
529
|
+
*/
|
|
530
|
+
clearMessageQueue() {
|
|
531
|
+
const queue = this.llmService.getMessageQueue();
|
|
532
|
+
const count = queue.pendingCount();
|
|
533
|
+
queue.clear();
|
|
534
|
+
return count;
|
|
535
|
+
}
|
|
421
536
|
/**
|
|
422
537
|
* Cancel the currently running turn for this session, if any.
|
|
423
538
|
* Returns true if a run was in progress and was signaled to abort.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-PTJYTZNU.js";
|
|
2
2
|
var SessionErrorCode = /* @__PURE__ */ ((SessionErrorCode2) => {
|
|
3
3
|
SessionErrorCode2["SESSION_NOT_FOUND"] = "session_not_found";
|
|
4
4
|
SessionErrorCode2["SESSION_INITIALIZATION_FAILED"] = "session_initialization_failed";
|
package/dist/session/errors.js
CHANGED