@dexto/core 1.2.6 → 1.4.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 +55 -13
- package/dist/agent/DextoAgent.cjs +627 -228
- package/dist/agent/DextoAgent.d.ts +157 -34
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +625 -227
- 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.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/agent/schemas.cjs +4 -1
- package/dist/agent/schemas.d.ts +92 -55
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/agent/schemas.js +7 -3
- 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 -11
- 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 +69 -3
- package/dist/approval/manager.d.ts +41 -3
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +70 -4
- package/dist/approval/schemas.cjs +20 -5
- package/dist/approval/schemas.d.ts +127 -52
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +21 -6
- package/dist/approval/types.d.ts +6 -0
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +1 -1
- package/dist/{chunk-C6A6W6XS.js → chunk-PTJYTZNU.js} +44 -1
- package/dist/{llm/tokenizer/factory.cjs → context/compression/overflow.cjs} +20 -21
- package/dist/context/compression/overflow.d.ts +33 -0
- package/dist/context/compression/overflow.d.ts.map +1 -0
- package/dist/context/compression/overflow.js +19 -0
- package/dist/context/compression/reactive-overflow.cjs +201 -0
- package/dist/context/compression/reactive-overflow.d.ts +81 -0
- package/dist/context/compression/reactive-overflow.d.ts.map +1 -0
- package/dist/context/compression/reactive-overflow.js +178 -0
- package/dist/context/compression/types.d.ts +9 -7
- package/dist/context/compression/types.d.ts.map +1 -1
- package/dist/context/error-codes.cjs +3 -0
- package/dist/context/error-codes.d.ts +4 -1
- package/dist/context/error-codes.d.ts.map +1 -1
- package/dist/context/error-codes.js +4 -1
- package/dist/context/errors.cjs +28 -0
- package/dist/context/errors.d.ts +7 -0
- package/dist/context/errors.d.ts.map +1 -1
- package/dist/context/errors.js +29 -1
- package/dist/context/index.js +1 -1
- package/dist/context/manager.cjs +287 -323
- package/dist/context/manager.d.ts +65 -111
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +287 -328
- package/dist/context/media-helpers.js +1 -1
- package/dist/context/types.cjs +49 -0
- package/dist/context/types.d.ts +185 -72
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/types.js +35 -0
- package/dist/context/utils.cjs +266 -283
- package/dist/context/utils.d.ts +32 -18
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +266 -283
- 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.js +1 -1
- package/dist/errors/types.cjs +1 -0
- package/dist/errors/types.d.ts +4 -2
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/errors/types.js +2 -1
- package/dist/events/index.cjs +22 -2
- package/dist/events/index.d.ts +170 -62
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +23 -3
- package/dist/filesystem/error-codes.js +1 -1
- package/dist/filesystem/errors.js +1 -1
- package/dist/filesystem/filesystem-service.js +1 -1
- package/dist/filesystem/index.js +1 -1
- package/dist/filesystem/path-validator.js +1 -1
- 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.js +1 -1
- package/dist/llm/error-codes.cjs +0 -1
- package/dist/llm/error-codes.d.ts +0 -1
- package/dist/llm/error-codes.d.ts.map +1 -1
- package/dist/llm/error-codes.js +1 -2
- package/dist/llm/errors.cjs +10 -10
- package/dist/llm/errors.d.ts +5 -6
- package/dist/llm/errors.d.ts.map +1 -1
- package/dist/llm/errors.js +12 -12
- package/dist/llm/executor/stream-processor.cjs +367 -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 +344 -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 +753 -0
- package/dist/llm/executor/turn-executor.d.ts +166 -0
- package/dist/llm/executor/turn-executor.d.ts.map +1 -0
- package/dist/llm/executor/turn-executor.js +684 -0
- package/dist/llm/executor/types.d.ts +27 -0
- package/dist/llm/executor/types.d.ts.map +1 -0
- package/dist/llm/formatters/vercel.cjs +20 -186
- 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 +19 -185
- package/dist/llm/registry.cjs +36 -45
- package/dist/llm/registry.d.ts +53 -39
- package/dist/llm/registry.d.ts.map +1 -1
- package/dist/llm/registry.js +34 -42
- package/dist/llm/resolver.cjs +1 -31
- package/dist/llm/resolver.d.ts.map +1 -1
- package/dist/llm/resolver.js +2 -34
- package/dist/llm/schemas.cjs +2 -17
- package/dist/llm/schemas.d.ts +10 -23
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +5 -22
- package/dist/llm/services/factory.cjs +3 -92
- package/dist/llm/services/factory.d.ts +14 -4
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +4 -83
- package/dist/llm/services/test-utils.integration.cjs +6 -8
- package/dist/llm/services/test-utils.integration.d.ts.map +1 -1
- package/dist/llm/services/test-utils.integration.js +7 -9
- 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 +54 -468
- package/dist/llm/services/vercel.d.ts +38 -21
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +56 -475
- package/dist/llm/types.cjs +0 -3
- package/dist/llm/types.d.ts +8 -8
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js +1 -3
- 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.cjs +1 -1
- package/dist/logger/v2/schemas.js +2 -2
- 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 +4 -0
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +5 -1
- package/dist/mcp/mcp-client.js +1 -1
- 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 +2 -2
- 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 +1 -0
- package/dist/plugins/error-codes.d.ts +3 -1
- package/dist/plugins/error-codes.d.ts.map +1 -1
- package/dist/plugins/error-codes.js +2 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/loader.cjs +25 -5
- package/dist/plugins/loader.d.ts.map +1 -1
- package/dist/plugins/loader.js +26 -6
- package/dist/plugins/manager.js +1 -1
- package/dist/plugins/registrations/builtins.js +1 -1
- package/dist/plugins/schemas.d.ts +3 -3
- package/dist/plugins/schemas.js +1 -1
- 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.cjs +2 -2
- package/dist/prompts/providers/custom-prompt-provider.d.ts +1 -1
- package/dist/prompts/providers/custom-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/custom-prompt-provider.js +3 -3
- 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/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.js +1 -1
- 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 +149 -51
- 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 +150 -52
- 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.js +1 -1
- package/dist/storage/blob/local-blob-store.js +1 -1
- package/dist/storage/blob/memory-blob-store.js +1 -1
- package/dist/storage/blob/schemas.js +1 -1
- package/dist/storage/cache/factory.cjs +6 -2
- package/dist/storage/cache/factory.d.ts +2 -1
- package/dist/storage/cache/factory.d.ts.map +1 -1
- package/dist/storage/cache/factory.js +7 -3
- package/dist/storage/cache/memory-cache-store.js +1 -1
- package/dist/storage/cache/redis-store.js +1 -1
- package/dist/storage/cache/schemas.js +1 -1
- package/dist/storage/database/factory.cjs +11 -17
- package/dist/storage/database/factory.d.ts +2 -1
- package/dist/storage/database/factory.d.ts.map +1 -1
- package/dist/storage/database/factory.js +12 -18
- 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/schemas.js +1 -1
- package/dist/storage/database/sqlite-store.cjs +8 -0
- package/dist/storage/database/sqlite-store.d.ts.map +1 -1
- package/dist/storage/database/sqlite-store.js +9 -1
- package/dist/storage/error-codes.cjs +1 -0
- package/dist/storage/error-codes.d.ts +1 -0
- package/dist/storage/error-codes.d.ts.map +1 -1
- package/dist/storage/error-codes.js +2 -1
- package/dist/storage/errors.cjs +17 -0
- package/dist/storage/errors.d.ts +9 -0
- package/dist/storage/errors.d.ts.map +1 -1
- package/dist/storage/errors.js +18 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/schemas.js +1 -1
- package/dist/storage/storage-manager.js +1 -1
- 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.js +1 -1
- package/dist/systemPrompt/index.js +1 -1
- package/dist/systemPrompt/manager.js +1 -1
- package/dist/systemPrompt/registry.js +1 -1
- package/dist/systemPrompt/schemas.d.ts +5 -5
- package/dist/systemPrompt/schemas.js +1 -1
- package/dist/telemetry/decorators.js +1 -1
- package/dist/{llm/tokenizer/default.cjs → telemetry/error-codes.cjs} +14 -19
- package/dist/telemetry/error-codes.d.ts +13 -0
- package/dist/telemetry/error-codes.d.ts.map +1 -0
- package/dist/telemetry/error-codes.js +13 -0
- package/dist/telemetry/errors.cjs +105 -0
- package/dist/telemetry/errors.d.ts +28 -0
- package/dist/telemetry/errors.d.ts.map +1 -0
- package/dist/telemetry/errors.js +82 -0
- 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.cjs +92 -26
- package/dist/telemetry/telemetry.d.ts +1 -1
- package/dist/telemetry/telemetry.d.ts.map +1 -1
- package/dist/telemetry/telemetry.js +75 -19
- 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/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 +2 -0
- package/dist/tools/error-codes.d.ts +3 -1
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +3 -1
- package/dist/tools/errors.cjs +30 -0
- package/dist/tools/errors.d.ts +16 -0
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +31 -1
- package/dist/tools/index.cjs +2 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/internal-tools/constants.js +1 -1
- 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/bash-exec-tool.cjs +42 -18
- package/dist/tools/internal-tools/implementations/bash-exec-tool.d.ts +3 -3
- package/dist/tools/internal-tools/implementations/bash-exec-tool.d.ts.map +1 -1
- package/dist/tools/internal-tools/implementations/bash-exec-tool.js +43 -19
- package/dist/tools/internal-tools/implementations/bash-output-tool.js +1 -1
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.js +1 -1
- package/dist/tools/internal-tools/implementations/edit-file-tool.cjs +66 -1
- package/dist/tools/internal-tools/implementations/edit-file-tool.d.ts.map +1 -1
- package/dist/tools/internal-tools/implementations/edit-file-tool.js +67 -2
- package/dist/tools/internal-tools/implementations/glob-files-tool.cjs +14 -1
- package/dist/tools/internal-tools/implementations/glob-files-tool.d.ts.map +1 -1
- package/dist/tools/internal-tools/implementations/glob-files-tool.js +15 -2
- package/dist/tools/internal-tools/implementations/grep-content-tool.cjs +16 -1
- package/dist/tools/internal-tools/implementations/grep-content-tool.d.ts.map +1 -1
- package/dist/tools/internal-tools/implementations/grep-content-tool.js +17 -2
- package/dist/tools/internal-tools/implementations/kill-process-tool.js +1 -1
- package/dist/tools/internal-tools/implementations/read-file-tool.cjs +9 -1
- package/dist/tools/internal-tools/implementations/read-file-tool.d.ts.map +1 -1
- package/dist/tools/internal-tools/implementations/read-file-tool.js +10 -2
- package/dist/tools/internal-tools/implementations/search-history-tool.js +1 -1
- package/dist/tools/internal-tools/implementations/write-file-tool.cjs +69 -1
- package/dist/tools/internal-tools/implementations/write-file-tool.d.ts.map +1 -1
- package/dist/tools/internal-tools/implementations/write-file-tool.js +72 -2
- package/dist/tools/internal-tools/provider.cjs +27 -10
- package/dist/tools/internal-tools/provider.d.ts +8 -5
- package/dist/tools/internal-tools/provider.d.ts.map +1 -1
- package/dist/tools/internal-tools/provider.js +28 -11
- package/dist/tools/internal-tools/registry.cjs +4 -3
- package/dist/tools/internal-tools/registry.d.ts +28 -7
- package/dist/tools/internal-tools/registry.d.ts.map +1 -1
- package/dist/tools/internal-tools/registry.js +5 -4
- package/dist/tools/schemas.cjs +17 -7
- package/dist/tools/schemas.d.ts +31 -4
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +15 -7
- package/dist/tools/tool-manager.cjs +140 -18
- package/dist/tools/tool-manager.d.ts +23 -1
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +145 -19
- package/dist/tools/types.d.ts +20 -11
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/api-key-resolver.js +1 -1
- package/dist/utils/async-context.js +1 -1
- package/dist/utils/debug.js +1 -1
- package/dist/{llm/tokenizer/types.cjs → utils/defer.cjs} +19 -10
- 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/env-file.js +1 -1
- 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 -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.js +1 -1
- package/dist/utils/redactor.js +1 -1
- 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.d.ts +6 -0
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +1 -1
- package/dist/utils/service-initializer.cjs +6 -2
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +7 -3
- package/dist/utils/user-info.js +1 -1
- package/dist/utils/zod-schema-converter.js +1 -1
- package/package.json +54 -17
- 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/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 -196
- 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 -177
- 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.cjs +0 -43
- 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.cjs +0 -52
- 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 -33
- 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/llm/{formatters → executor}/types.cjs +0 -0
- /package/dist/llm/{formatters → executor}/types.js +0 -0
package/dist/approval/schemas.js
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-PTJYTZNU.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { ApprovalType, ApprovalStatus, DenialReason } from "./types.js";
|
|
4
|
+
import { isValidDisplayData } from "../tools/display-types.js";
|
|
5
|
+
const JsonSchema7Schema = z.record(z.unknown());
|
|
4
6
|
const ApprovalTypeSchema = z.nativeEnum(ApprovalType);
|
|
5
7
|
const ApprovalStatusSchema = z.nativeEnum(ApprovalStatus);
|
|
6
8
|
const DenialReasonSchema = z.nativeEnum(DenialReason);
|
|
9
|
+
const ToolDisplayDataSchema = z.custom((val) => isValidDisplayData(val), {
|
|
10
|
+
message: "Invalid ToolDisplayData"
|
|
11
|
+
});
|
|
7
12
|
const ToolConfirmationMetadataSchema = z.object({
|
|
8
13
|
toolName: z.string().describe("Name of the tool to confirm"),
|
|
14
|
+
toolCallId: z.string().describe("Unique tool call ID for tracking parallel tool calls"),
|
|
9
15
|
args: z.record(z.unknown()).describe("Arguments for the tool"),
|
|
10
|
-
description: z.string().optional().describe("Description of the tool")
|
|
16
|
+
description: z.string().optional().describe("Description of the tool"),
|
|
17
|
+
displayPreview: ToolDisplayDataSchema.optional().describe(
|
|
18
|
+
"Preview display data for approval UI (e.g., diff preview)"
|
|
19
|
+
),
|
|
20
|
+
suggestedPatterns: z.array(z.string()).optional().describe(
|
|
21
|
+
'Suggested patterns for session approval (for bash commands). E.g., ["git push *", "git *"] for command "git push origin main"'
|
|
22
|
+
)
|
|
11
23
|
}).strict().describe("Tool confirmation metadata");
|
|
12
24
|
const CommandConfirmationMetadataSchema = z.object({
|
|
13
25
|
toolName: z.string().describe("Name of the tool executing the command"),
|
|
@@ -15,7 +27,7 @@ const CommandConfirmationMetadataSchema = z.object({
|
|
|
15
27
|
originalCommand: z.string().optional().describe("The original command before normalization")
|
|
16
28
|
}).strict().describe("Command confirmation metadata");
|
|
17
29
|
const ElicitationMetadataSchema = z.object({
|
|
18
|
-
schema:
|
|
30
|
+
schema: JsonSchema7Schema.describe("JSON Schema for the form"),
|
|
19
31
|
prompt: z.string().describe("Prompt to show the user"),
|
|
20
32
|
serverName: z.string().describe("MCP server requesting input"),
|
|
21
33
|
context: z.record(z.unknown()).optional().describe("Additional context")
|
|
@@ -25,7 +37,7 @@ const BaseApprovalRequestSchema = z.object({
|
|
|
25
37
|
approvalId: z.string().uuid().describe("Unique approval identifier"),
|
|
26
38
|
type: ApprovalTypeSchema.describe("Type of approval"),
|
|
27
39
|
sessionId: z.string().optional().describe("Session identifier"),
|
|
28
|
-
timeout: z.number().int().positive().describe("Timeout in milliseconds"),
|
|
40
|
+
timeout: z.number().int().positive().optional().describe("Timeout in milliseconds (optional - no timeout if not specified)"),
|
|
29
41
|
timestamp: z.date().describe("When the request was created")
|
|
30
42
|
}).describe("Base approval request");
|
|
31
43
|
const ToolConfirmationRequestSchema = BaseApprovalRequestSchema.extend({
|
|
@@ -51,7 +63,10 @@ const ApprovalRequestSchema = z.discriminatedUnion("type", [
|
|
|
51
63
|
CustomApprovalRequestSchema
|
|
52
64
|
]);
|
|
53
65
|
const ToolConfirmationResponseDataSchema = z.object({
|
|
54
|
-
rememberChoice: z.boolean().optional().describe("Remember this
|
|
66
|
+
rememberChoice: z.boolean().optional().describe("Remember this tool for the session (approves ALL uses of this tool)"),
|
|
67
|
+
rememberPattern: z.string().optional().describe(
|
|
68
|
+
'Remember a command pattern for bash commands (e.g., "git *"). Only applicable for bash_exec tool approvals.'
|
|
69
|
+
)
|
|
55
70
|
}).strict().describe("Tool confirmation response data");
|
|
56
71
|
const CommandConfirmationResponseDataSchema = z.object({
|
|
57
72
|
// Command confirmations don't have remember choice - they're per-command
|
|
@@ -92,7 +107,7 @@ const ApprovalResponseSchema = z.union([
|
|
|
92
107
|
const ApprovalRequestDetailsSchema = z.object({
|
|
93
108
|
type: ApprovalTypeSchema,
|
|
94
109
|
sessionId: z.string().optional(),
|
|
95
|
-
timeout: z.number().int().positive(),
|
|
110
|
+
timeout: z.number().int().positive().optional().describe("Timeout in milliseconds (optional - no timeout if not specified)"),
|
|
96
111
|
metadata: z.union([
|
|
97
112
|
ToolConfirmationMetadataSchema,
|
|
98
113
|
CommandConfirmationMetadataSchema,
|
package/dist/approval/types.d.ts
CHANGED
|
@@ -214,5 +214,11 @@ export interface ApprovalHandler {
|
|
|
214
214
|
* @remarks Not all handlers track pending requests (e.g., auto-approve handlers)
|
|
215
215
|
*/
|
|
216
216
|
getPending?(): string[];
|
|
217
|
+
/**
|
|
218
|
+
* Get full pending approval requests (optional)
|
|
219
|
+
* @returns Array of pending approval requests
|
|
220
|
+
* @remarks Not all handlers track pending requests (e.g., auto-approve handlers)
|
|
221
|
+
*/
|
|
222
|
+
getPendingRequests?(): ApprovalRequest[];
|
|
217
223
|
}
|
|
218
224
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/approval/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EACR,8BAA8B,EAC9B,iCAAiC,EACjC,yBAAyB,EACzB,4BAA4B,EAC5B,yBAAyB,EACzB,6BAA6B,EAC7B,gCAAgC,EAChC,wBAAwB,E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AEnF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAMvE;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,eAAe;IAC5B;;;;OAIG;IACH,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEtD;;;;OAIG;IACH,MAAM,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAElC;;;OAGG;IACH,SAAS,CAAC,IAAI,IAAI,CAAC;IAEnB;;;;OAIG;IACH,UAAU,CAAC,IAAI,MAAM,EAAE,CAAC;IAExB;;;;OAIG;IACH,kBAAkB,CAAC,IAAI,eAAe,EAAE,CAAC;CAC5C"}
|
package/dist/approval/types.js
CHANGED
|
@@ -45,9 +45,52 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
|
|
|
45
45
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
46
46
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
47
47
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
48
|
+
var __using = (stack, value, async) => {
|
|
49
|
+
if (value != null) {
|
|
50
|
+
if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
|
|
51
|
+
var dispose, inner;
|
|
52
|
+
if (async) dispose = value[__knownSymbol("asyncDispose")];
|
|
53
|
+
if (dispose === void 0) {
|
|
54
|
+
dispose = value[__knownSymbol("dispose")];
|
|
55
|
+
if (async) inner = dispose;
|
|
56
|
+
}
|
|
57
|
+
if (typeof dispose !== "function") __typeError("Object not disposable");
|
|
58
|
+
if (inner) dispose = function() {
|
|
59
|
+
try {
|
|
60
|
+
inner.call(this);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
return Promise.reject(e);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
stack.push([async, dispose, value]);
|
|
66
|
+
} else if (async) {
|
|
67
|
+
stack.push([async]);
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
};
|
|
71
|
+
var __callDispose = (stack, error, hasError) => {
|
|
72
|
+
var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
|
|
73
|
+
return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
|
|
74
|
+
};
|
|
75
|
+
var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
|
|
76
|
+
var next = (it) => {
|
|
77
|
+
while (it = stack.pop()) {
|
|
78
|
+
try {
|
|
79
|
+
var result = it[1] && it[1].call(it[2]);
|
|
80
|
+
if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
|
|
81
|
+
} catch (e) {
|
|
82
|
+
fail(e);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (hasError) throw error;
|
|
86
|
+
};
|
|
87
|
+
return next();
|
|
88
|
+
};
|
|
48
89
|
|
|
49
90
|
export {
|
|
50
91
|
__decoratorStart,
|
|
51
92
|
__runInitializers,
|
|
52
|
-
__decorateElement
|
|
93
|
+
__decorateElement,
|
|
94
|
+
__using,
|
|
95
|
+
__callDispose
|
|
53
96
|
};
|
|
@@ -16,29 +16,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var overflow_exports = {};
|
|
20
|
+
__export(overflow_exports, {
|
|
21
|
+
getCompressionTarget: () => getCompressionTarget,
|
|
22
|
+
isOverflow: () => isOverflow
|
|
22
23
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
default:
|
|
38
|
-
return new import_default.DefaultTokenizer();
|
|
39
|
-
}
|
|
24
|
+
module.exports = __toCommonJS(overflow_exports);
|
|
25
|
+
const DEFAULT_OUTPUT_BUFFER = 16e3;
|
|
26
|
+
function isOverflow(tokens, modelLimits) {
|
|
27
|
+
const { contextWindow, maxOutput } = modelLimits;
|
|
28
|
+
const outputBuffer = Math.min(maxOutput, DEFAULT_OUTPUT_BUFFER);
|
|
29
|
+
const usableTokens = contextWindow - outputBuffer;
|
|
30
|
+
const inputTokens = tokens.inputTokens ?? 0;
|
|
31
|
+
return inputTokens > usableTokens;
|
|
32
|
+
}
|
|
33
|
+
function getCompressionTarget(modelLimits, targetPercentage = 0.7) {
|
|
34
|
+
const { contextWindow, maxOutput } = modelLimits;
|
|
35
|
+
const outputBuffer = Math.min(maxOutput, DEFAULT_OUTPUT_BUFFER);
|
|
36
|
+
const usableTokens = contextWindow - outputBuffer;
|
|
37
|
+
return Math.floor(usableTokens * targetPercentage);
|
|
40
38
|
}
|
|
41
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
40
|
0 && (module.exports = {
|
|
43
|
-
|
|
41
|
+
getCompressionTarget,
|
|
42
|
+
isOverflow
|
|
44
43
|
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TokenUsage } from '../../llm/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Model limits configuration for overflow detection.
|
|
4
|
+
* These limits define the context window boundaries.
|
|
5
|
+
*/
|
|
6
|
+
export interface ModelLimits {
|
|
7
|
+
/** Maximum context window size in tokens */
|
|
8
|
+
contextWindow: number;
|
|
9
|
+
/** Maximum output tokens the model can generate */
|
|
10
|
+
maxOutput: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Determines if the context has overflowed based on actual token usage from the API.
|
|
14
|
+
*
|
|
15
|
+
* Overflow is detected when:
|
|
16
|
+
* used tokens > (contextWindow - outputBuffer)
|
|
17
|
+
*
|
|
18
|
+
* The outputBuffer ensures we always have room for the model's response.
|
|
19
|
+
*
|
|
20
|
+
* @param tokens The actual token usage from the last LLM API call
|
|
21
|
+
* @param modelLimits The model's context window and output limits
|
|
22
|
+
* @returns true if context has overflowed and compression is needed
|
|
23
|
+
*/
|
|
24
|
+
export declare function isOverflow(tokens: TokenUsage, modelLimits: ModelLimits): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Calculate the compression target - how many tokens we need to reduce to.
|
|
27
|
+
*
|
|
28
|
+
* @param modelLimits The model's context window and output limits
|
|
29
|
+
* @param targetPercentage What percentage of usable context to target (default 70%)
|
|
30
|
+
* @returns The target token count after compression
|
|
31
|
+
*/
|
|
32
|
+
export declare function getCompressionTarget(modelLimits: ModelLimits, targetPercentage?: number): number;
|
|
33
|
+
//# sourceMappingURL=overflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overflow.d.ts","sourceRoot":"","sources":["../../../src/context/compression/overflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,WAAW;IACxB,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;CACrB;AAQD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAYhF;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAChC,WAAW,EAAE,WAAW,EACxB,gBAAgB,GAAE,MAAY,GAC/B,MAAM,CAMR"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "../../chunk-PTJYTZNU.js";
|
|
2
|
+
const DEFAULT_OUTPUT_BUFFER = 16e3;
|
|
3
|
+
function isOverflow(tokens, modelLimits) {
|
|
4
|
+
const { contextWindow, maxOutput } = modelLimits;
|
|
5
|
+
const outputBuffer = Math.min(maxOutput, DEFAULT_OUTPUT_BUFFER);
|
|
6
|
+
const usableTokens = contextWindow - outputBuffer;
|
|
7
|
+
const inputTokens = tokens.inputTokens ?? 0;
|
|
8
|
+
return inputTokens > usableTokens;
|
|
9
|
+
}
|
|
10
|
+
function getCompressionTarget(modelLimits, targetPercentage = 0.7) {
|
|
11
|
+
const { contextWindow, maxOutput } = modelLimits;
|
|
12
|
+
const outputBuffer = Math.min(maxOutput, DEFAULT_OUTPUT_BUFFER);
|
|
13
|
+
const usableTokens = contextWindow - outputBuffer;
|
|
14
|
+
return Math.floor(usableTokens * targetPercentage);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
getCompressionTarget,
|
|
18
|
+
isOverflow
|
|
19
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var reactive_overflow_exports = {};
|
|
20
|
+
__export(reactive_overflow_exports, {
|
|
21
|
+
ReactiveOverflowStrategy: () => ReactiveOverflowStrategy
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(reactive_overflow_exports);
|
|
24
|
+
var import_ai = require("ai");
|
|
25
|
+
var import_types = require("../types.js");
|
|
26
|
+
const DEFAULT_OPTIONS = {
|
|
27
|
+
preserveLastNTurns: 2,
|
|
28
|
+
maxSummaryTokens: 2e3,
|
|
29
|
+
summaryPrompt: `You are a conversation summarizer. Summarize the following conversation history concisely, focusing on:
|
|
30
|
+
- What tasks were attempted and their outcomes
|
|
31
|
+
- Current state and context the assistant needs to remember
|
|
32
|
+
- Any important decisions or information discovered
|
|
33
|
+
- What the user was trying to accomplish
|
|
34
|
+
|
|
35
|
+
Be concise but preserve essential context. Output only the summary, no preamble.
|
|
36
|
+
|
|
37
|
+
Conversation:
|
|
38
|
+
{conversation}`
|
|
39
|
+
};
|
|
40
|
+
class ReactiveOverflowStrategy {
|
|
41
|
+
name = "reactive-overflow";
|
|
42
|
+
model;
|
|
43
|
+
options;
|
|
44
|
+
logger;
|
|
45
|
+
constructor(model, options = {}, logger) {
|
|
46
|
+
this.model = model;
|
|
47
|
+
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
48
|
+
this.logger = logger;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Generate a summary message for the old portion of history.
|
|
52
|
+
*
|
|
53
|
+
* IMPORTANT: This does NOT replace history. It returns a summary message
|
|
54
|
+
* that the caller should ADD to history via contextManager.addMessage().
|
|
55
|
+
* Read-time filtering (filterCompacted) will then exclude pre-summary
|
|
56
|
+
* messages when formatting for LLM.
|
|
57
|
+
*
|
|
58
|
+
* @param history The full conversation history
|
|
59
|
+
* @returns Array with single summary message to add, or empty if nothing to summarize
|
|
60
|
+
*/
|
|
61
|
+
async compress(history) {
|
|
62
|
+
if (history.length <= 2) {
|
|
63
|
+
this.logger.debug("ReactiveOverflowStrategy: History too short, skipping compression");
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
const { toSummarize, toKeep } = this.splitHistory(history);
|
|
67
|
+
if (toSummarize.length === 0) {
|
|
68
|
+
this.logger.debug("ReactiveOverflowStrategy: No messages to summarize");
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
this.logger.info(
|
|
72
|
+
`ReactiveOverflowStrategy: Summarizing ${toSummarize.length} messages, keeping ${toKeep.length}`
|
|
73
|
+
);
|
|
74
|
+
const summary = await this.generateSummary(toSummarize);
|
|
75
|
+
const summaryMessage = {
|
|
76
|
+
role: "assistant",
|
|
77
|
+
content: [{ type: "text", text: summary }],
|
|
78
|
+
timestamp: Date.now(),
|
|
79
|
+
metadata: {
|
|
80
|
+
isSummary: true,
|
|
81
|
+
summarizedAt: Date.now(),
|
|
82
|
+
summarizedMessageCount: toSummarize.length,
|
|
83
|
+
originalFirstTimestamp: toSummarize[0]?.timestamp,
|
|
84
|
+
originalLastTimestamp: toSummarize[toSummarize.length - 1]?.timestamp
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return [summaryMessage];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Split history into messages to summarize and messages to keep.
|
|
91
|
+
* Keeps the last N turns (user + assistant pairs) intact.
|
|
92
|
+
*/
|
|
93
|
+
splitHistory(history) {
|
|
94
|
+
const turnsToKeep = this.options.preserveLastNTurns;
|
|
95
|
+
const userMessageIndices = [];
|
|
96
|
+
for (let i = history.length - 1; i >= 0; i--) {
|
|
97
|
+
if (history[i]?.role === "user") {
|
|
98
|
+
userMessageIndices.unshift(i);
|
|
99
|
+
if (userMessageIndices.length >= turnsToKeep) {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (userMessageIndices.length > 0) {
|
|
105
|
+
const splitIndex = userMessageIndices[0];
|
|
106
|
+
if (splitIndex !== void 0) {
|
|
107
|
+
if (splitIndex === 0) {
|
|
108
|
+
return {
|
|
109
|
+
toSummarize: [],
|
|
110
|
+
toKeep: history
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
toSummarize: history.slice(0, splitIndex),
|
|
115
|
+
toKeep: history.slice(splitIndex)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const keepCount = Math.min(4, history.length);
|
|
120
|
+
return {
|
|
121
|
+
toSummarize: history.slice(0, -keepCount),
|
|
122
|
+
toKeep: history.slice(-keepCount)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Generate an LLM summary of the messages.
|
|
127
|
+
*/
|
|
128
|
+
async generateSummary(messages) {
|
|
129
|
+
const formattedConversation = this.formatMessagesForSummary(messages);
|
|
130
|
+
const prompt = this.options.summaryPrompt.replace("{conversation}", formattedConversation);
|
|
131
|
+
try {
|
|
132
|
+
const result = await (0, import_ai.generateText)({
|
|
133
|
+
model: this.model,
|
|
134
|
+
prompt,
|
|
135
|
+
maxOutputTokens: this.options.maxSummaryTokens
|
|
136
|
+
});
|
|
137
|
+
return `[Previous conversation summary]
|
|
138
|
+
${result.text}`;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
this.logger.error("ReactiveOverflowStrategy: Failed to generate summary", { error });
|
|
141
|
+
return this.createFallbackSummary(messages);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Format messages for the summary prompt.
|
|
146
|
+
*/
|
|
147
|
+
formatMessagesForSummary(messages) {
|
|
148
|
+
return messages.map((msg) => {
|
|
149
|
+
const role = msg.role.toUpperCase();
|
|
150
|
+
let content;
|
|
151
|
+
if (typeof msg.content === "string") {
|
|
152
|
+
content = msg.content;
|
|
153
|
+
} else if (Array.isArray(msg.content)) {
|
|
154
|
+
content = msg.content.filter(
|
|
155
|
+
(part) => part.type === "text"
|
|
156
|
+
).map((part) => part.text).join("\n");
|
|
157
|
+
} else {
|
|
158
|
+
content = "[no content]";
|
|
159
|
+
}
|
|
160
|
+
if (content.length > 2e3) {
|
|
161
|
+
content = content.slice(0, 2e3) + "... [truncated]";
|
|
162
|
+
}
|
|
163
|
+
if ((0, import_types.isAssistantMessage)(msg) && msg.toolCalls && msg.toolCalls.length > 0) {
|
|
164
|
+
const toolNames = msg.toolCalls.map((tc) => tc.function.name).join(", ");
|
|
165
|
+
content += `
|
|
166
|
+
[Used tools: ${toolNames}]`;
|
|
167
|
+
}
|
|
168
|
+
if ((0, import_types.isToolMessage)(msg)) {
|
|
169
|
+
return `TOOL (${msg.name}): ${content.slice(0, 500)}${content.length > 500 ? "..." : ""}`;
|
|
170
|
+
}
|
|
171
|
+
return `${role}: ${content}`;
|
|
172
|
+
}).join("\n\n");
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Create a fallback summary if LLM call fails.
|
|
176
|
+
*/
|
|
177
|
+
createFallbackSummary(messages) {
|
|
178
|
+
const userMessages = messages.filter((m) => m.role === "user");
|
|
179
|
+
const assistantWithTools = messages.filter(
|
|
180
|
+
(m) => (0, import_types.isAssistantMessage)(m) && !!m.toolCalls && m.toolCalls.length > 0
|
|
181
|
+
);
|
|
182
|
+
const userTopics = userMessages.slice(-3).map((m) => {
|
|
183
|
+
const text = typeof m.content === "string" ? m.content : Array.isArray(m.content) ? m.content.filter(
|
|
184
|
+
(p) => p.type === "text"
|
|
185
|
+
).map((p) => p.text).join(" ") : "";
|
|
186
|
+
return text.slice(0, 100);
|
|
187
|
+
}).join("; ");
|
|
188
|
+
const toolsUsed = [
|
|
189
|
+
...new Set(
|
|
190
|
+
assistantWithTools.flatMap((m) => m.toolCalls.map((tc) => tc.function.name))
|
|
191
|
+
)
|
|
192
|
+
].join(", ");
|
|
193
|
+
return `[Previous conversation summary - fallback]
|
|
194
|
+
User discussed: ${userTopics || "various topics"}
|
|
195
|
+
Tools used: ${toolsUsed || "none"}`;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
199
|
+
0 && (module.exports = {
|
|
200
|
+
ReactiveOverflowStrategy
|
|
201
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type LanguageModel } from 'ai';
|
|
2
|
+
import type { ICompressionStrategy } from './types.js';
|
|
3
|
+
import type { InternalMessage } from '../types.js';
|
|
4
|
+
import type { IDextoLogger } from '../../logger/v2/types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for ReactiveOverflowStrategy.
|
|
7
|
+
*/
|
|
8
|
+
export interface ReactiveOverflowOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Number of recent turns to preserve (not summarize).
|
|
11
|
+
* A "turn" is a user message + assistant response pair.
|
|
12
|
+
* Default: 2
|
|
13
|
+
*/
|
|
14
|
+
preserveLastNTurns?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum tokens for the summary output.
|
|
17
|
+
* Default: 2000
|
|
18
|
+
*/
|
|
19
|
+
maxSummaryTokens?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Custom summary prompt template.
|
|
22
|
+
* Use {conversation} as placeholder for formatted messages.
|
|
23
|
+
*/
|
|
24
|
+
summaryPrompt?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* ReactiveOverflowStrategy implements reactive compression.
|
|
28
|
+
*
|
|
29
|
+
* Key behaviors:
|
|
30
|
+
* - Triggers on overflow (after actual tokens exceed context limit)
|
|
31
|
+
* - Uses LLM to generate intelligent summary of older messages
|
|
32
|
+
* - Returns summary message to ADD to history (not replace)
|
|
33
|
+
* - Read-time filtering via filterCompacted() excludes pre-summary messages
|
|
34
|
+
*
|
|
35
|
+
* This strategy is designed to work with TurnExecutor's main loop:
|
|
36
|
+
* 1. After each step, check if overflow occurred
|
|
37
|
+
* 2. If yes, generate summary and ADD it to history
|
|
38
|
+
* 3. filterCompacted() in getFormattedMessages() excludes old messages
|
|
39
|
+
* 4. Continue with fresh context (summary + recent messages)
|
|
40
|
+
*
|
|
41
|
+
* NOTE: This does NOT replace history. The summary message is ADDED,
|
|
42
|
+
* and filterCompacted() handles excluding old messages at read-time.
|
|
43
|
+
* This preserves full history for audit/recovery purposes.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ReactiveOverflowStrategy implements ICompressionStrategy {
|
|
46
|
+
readonly name = "reactive-overflow";
|
|
47
|
+
private readonly model;
|
|
48
|
+
private readonly options;
|
|
49
|
+
private readonly logger;
|
|
50
|
+
constructor(model: LanguageModel, options: ReactiveOverflowOptions | undefined, logger: IDextoLogger);
|
|
51
|
+
/**
|
|
52
|
+
* Generate a summary message for the old portion of history.
|
|
53
|
+
*
|
|
54
|
+
* IMPORTANT: This does NOT replace history. It returns a summary message
|
|
55
|
+
* that the caller should ADD to history via contextManager.addMessage().
|
|
56
|
+
* Read-time filtering (filterCompacted) will then exclude pre-summary
|
|
57
|
+
* messages when formatting for LLM.
|
|
58
|
+
*
|
|
59
|
+
* @param history The full conversation history
|
|
60
|
+
* @returns Array with single summary message to add, or empty if nothing to summarize
|
|
61
|
+
*/
|
|
62
|
+
compress(history: readonly InternalMessage[]): Promise<InternalMessage[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Split history into messages to summarize and messages to keep.
|
|
65
|
+
* Keeps the last N turns (user + assistant pairs) intact.
|
|
66
|
+
*/
|
|
67
|
+
private splitHistory;
|
|
68
|
+
/**
|
|
69
|
+
* Generate an LLM summary of the messages.
|
|
70
|
+
*/
|
|
71
|
+
private generateSummary;
|
|
72
|
+
/**
|
|
73
|
+
* Format messages for the summary prompt.
|
|
74
|
+
*/
|
|
75
|
+
private formatMessagesForSummary;
|
|
76
|
+
/**
|
|
77
|
+
* Create a fallback summary if LLM call fails.
|
|
78
|
+
*/
|
|
79
|
+
private createFallbackSummary;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=reactive-overflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive-overflow.d.ts","sourceRoot":"","sources":["../../../src/context/compression/reactive-overflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,IAAI,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAY,MAAM,aAAa,CAAC;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAiBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,wBAAyB,YAAW,oBAAoB;IACjE,QAAQ,CAAC,IAAI,uBAAuB;IAEpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,uBAAuB,YAAK,EAAE,MAAM,EAAE,YAAY;IAM7F;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA0C/E;;;OAGG;IACH,OAAO,CAAC,YAAY;IA2CpB;;OAEG;YACW,eAAe;IAmB7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA2ChC;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAiChC"}
|