@dexto/core 1.5.8 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -8
- package/dist/agent/DextoAgent.cjs +318 -159
- package/dist/agent/DextoAgent.d.ts +94 -56
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +315 -156
- package/dist/{context/compaction/provider.cjs → agent/agent-options.cjs} +2 -2
- package/dist/agent/agent-options.d.ts +53 -0
- package/dist/agent/agent-options.d.ts.map +1 -0
- package/dist/agent/agentCard.cjs +1 -1
- package/dist/agent/errors.cjs +2 -2
- package/dist/agent/errors.d.ts.map +1 -1
- package/dist/agent/index.cjs +1 -6
- package/dist/agent/index.d.ts +3 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +1 -7
- package/dist/{storage/blob/provider.cjs → agent/runtime-config.cjs} +2 -2
- package/dist/agent/runtime-config.d.ts +53 -0
- package/dist/agent/runtime-config.d.ts.map +1 -0
- package/dist/agent/schemas.cjs +2 -104
- package/dist/agent/schemas.d.ts +8 -9197
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/agent/schemas.js +1 -109
- package/dist/agent/state-manager.d.ts +5 -5
- package/dist/agent/state-manager.d.ts.map +1 -1
- package/dist/approval/error-codes.cjs +1 -1
- package/dist/approval/error-codes.d.ts +1 -1
- package/dist/approval/error-codes.d.ts.map +1 -1
- package/dist/approval/error-codes.js +1 -1
- package/dist/approval/errors.cjs +5 -5
- package/dist/approval/errors.d.ts +2 -2
- package/dist/approval/errors.d.ts.map +1 -1
- package/dist/approval/errors.js +5 -5
- package/dist/approval/index.cjs +8 -8
- package/dist/approval/index.d.ts +2 -2
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +8 -8
- package/dist/approval/manager.cjs +163 -83
- package/dist/approval/manager.d.ts +50 -43
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +161 -81
- package/dist/approval/schemas.cjs +47 -32
- package/dist/approval/schemas.d.ts +291 -97
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +43 -28
- package/dist/approval/types.cjs +1 -1
- package/dist/approval/types.d.ts +14 -14
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +1 -1
- package/dist/context/compaction/index.cjs +2 -23
- package/dist/context/compaction/index.d.ts +1 -7
- package/dist/context/compaction/index.d.ts.map +1 -1
- package/dist/context/compaction/index.js +1 -16
- package/dist/context/compaction/strategies/noop.cjs +19 -1
- package/dist/context/compaction/strategies/noop.d.ts +13 -3
- package/dist/context/compaction/strategies/noop.d.ts.map +1 -1
- package/dist/context/compaction/strategies/noop.js +19 -1
- package/dist/context/compaction/strategies/{reactive-overflow.cjs → reactive-overflow-compaction.cjs} +67 -64
- package/dist/context/compaction/strategies/{reactive-overflow.d.ts → reactive-overflow-compaction.d.ts} +19 -36
- package/dist/context/compaction/strategies/reactive-overflow-compaction.d.ts.map +1 -0
- package/dist/context/compaction/strategies/{reactive-overflow.js → reactive-overflow-compaction.js} +63 -60
- package/dist/context/compaction/types.d.ts +40 -8
- package/dist/context/compaction/types.d.ts.map +1 -1
- package/dist/context/manager.cjs +4 -2
- package/dist/context/manager.d.ts +5 -3
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +4 -2
- package/dist/context/types.d.ts +3 -0
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/utils.cjs +2 -2
- package/dist/context/utils.d.ts +14 -14
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/errors/result-bridge.d.ts +2 -2
- package/dist/errors/result-bridge.d.ts.map +1 -1
- package/dist/errors/types.cjs +1 -1
- package/dist/errors/types.d.ts +3 -3
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/errors/types.js +1 -1
- package/dist/events/index.cjs +11 -1
- package/dist/events/index.d.ts +48 -7
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +11 -1
- package/dist/{plugins → hooks}/builtins/content-policy.cjs +7 -6
- package/dist/hooks/builtins/content-policy.d.ts +24 -0
- package/dist/hooks/builtins/content-policy.d.ts.map +1 -0
- package/dist/{plugins → hooks}/builtins/content-policy.js +6 -5
- package/dist/{plugins → hooks}/builtins/response-sanitizer.cjs +3 -3
- package/dist/hooks/builtins/response-sanitizer.d.ts +22 -0
- package/dist/hooks/builtins/response-sanitizer.d.ts.map +1 -0
- package/dist/{plugins → hooks}/builtins/response-sanitizer.js +2 -2
- package/dist/hooks/error-codes.cjs +43 -0
- package/dist/hooks/error-codes.d.ts +34 -0
- package/dist/hooks/error-codes.d.ts.map +1 -0
- package/dist/hooks/error-codes.js +20 -0
- package/dist/{storage/cache/providers/memory.cjs → hooks/index.cjs} +15 -18
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/manager.cjs +354 -0
- package/dist/hooks/manager.d.ts +103 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +331 -0
- package/dist/{plugins → hooks}/types.d.ts +26 -45
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/index.browser.cjs +13 -12
- package/dist/index.browser.d.ts +5 -5
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +8 -7
- package/dist/index.cjs +5 -7
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/llm/errors.cjs +1 -1
- package/dist/llm/executor/stream-processor.cjs +131 -11
- package/dist/llm/executor/stream-processor.d.ts +8 -5
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +131 -11
- package/dist/llm/executor/turn-executor.cjs +49 -54
- package/dist/llm/executor/turn-executor.d.ts +7 -8
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +49 -54
- package/dist/llm/formatters/vercel.cjs +2 -2
- package/dist/llm/formatters/vercel.d.ts +2 -2
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/providers/local/schemas.d.ts +12 -12
- package/dist/llm/registry/auto-update.d.ts +2 -2
- package/dist/llm/registry/auto-update.d.ts.map +1 -1
- package/dist/llm/registry/index.d.ts +3 -3
- package/dist/llm/registry/index.d.ts.map +1 -1
- package/dist/llm/resolver.cjs +2 -2
- package/dist/llm/resolver.d.ts +4 -4
- package/dist/llm/resolver.d.ts.map +1 -1
- package/dist/llm/schemas.cjs +67 -104
- package/dist/llm/schemas.d.ts +10 -149
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +64 -101
- package/dist/llm/services/factory.cjs +2 -3
- package/dist/llm/services/factory.d.ts +3 -4
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +2 -3
- package/dist/llm/services/vercel.cjs +8 -15
- package/dist/llm/services/vercel.d.ts +6 -7
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +8 -15
- package/dist/llm/validation.cjs +1 -1
- package/dist/llm/validation.d.ts +2 -2
- package/dist/llm/validation.d.ts.map +1 -1
- package/dist/logger/browser.cjs +4 -4
- package/dist/logger/browser.d.ts +4 -4
- package/dist/logger/browser.d.ts.map +1 -1
- package/dist/logger/browser.js +3 -3
- package/dist/{context/compaction/providers/noop-provider.cjs → logger/default-logger-factory.cjs} +16 -22
- package/dist/logger/default-logger-factory.d.ts +301 -0
- package/dist/logger/default-logger-factory.d.ts.map +1 -0
- package/dist/logger/default-logger-factory.js +18 -0
- package/dist/logger/factory.d.ts +2 -2
- package/dist/logger/factory.d.ts.map +1 -1
- package/dist/logger/index.cjs +7 -2
- package/dist/logger/index.d.ts +5 -3
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +8 -2
- package/dist/logger/logger.cjs +4 -4
- package/dist/logger/logger.d.ts +4 -4
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +3 -3
- package/dist/logger/v2/dexto-logger.cjs +35 -0
- package/dist/logger/v2/dexto-logger.d.ts +22 -3
- package/dist/logger/v2/dexto-logger.d.ts.map +1 -1
- package/dist/logger/v2/dexto-logger.js +35 -0
- package/dist/logger/v2/schemas.d.ts +6 -6
- package/dist/logger/v2/test-utils.cjs +2 -0
- package/dist/logger/v2/test-utils.d.ts +5 -5
- package/dist/logger/v2/test-utils.d.ts.map +1 -1
- package/dist/logger/v2/test-utils.js +2 -0
- package/dist/logger/v2/transport-factory.d.ts +3 -3
- package/dist/logger/v2/transport-factory.d.ts.map +1 -1
- package/dist/logger/v2/transports/console-transport.d.ts +2 -2
- package/dist/logger/v2/transports/console-transport.d.ts.map +1 -1
- package/dist/logger/v2/transports/file-transport.d.ts +2 -2
- package/dist/logger/v2/transports/file-transport.d.ts.map +1 -1
- package/dist/logger/v2/transports/silent-transport.d.ts +2 -2
- package/dist/logger/v2/transports/silent-transport.d.ts.map +1 -1
- package/dist/logger/v2/types.cjs +1 -1
- package/dist/logger/v2/types.d.ts +22 -9
- package/dist/logger/v2/types.d.ts.map +1 -1
- package/dist/logger/v2/types.js +1 -1
- package/dist/mcp/errors.cjs +2 -2
- package/dist/mcp/errors.d.ts.map +1 -1
- package/dist/mcp/manager.cjs +16 -11
- package/dist/mcp/manager.d.ts +16 -13
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +17 -12
- package/dist/mcp/mcp-client.cjs +25 -20
- package/dist/mcp/mcp-client.d.ts +5 -5
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +20 -15
- package/dist/mcp/resolver.cjs +1 -1
- package/dist/mcp/schemas.cjs +5 -5
- package/dist/mcp/schemas.d.ts +19 -19
- package/dist/mcp/schemas.js +2 -2
- package/dist/mcp/types.d.ts +7 -7
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/memory/manager.d.ts +2 -2
- package/dist/memory/manager.d.ts.map +1 -1
- package/dist/memory/schemas.d.ts +2 -2
- package/dist/prompts/errors.cjs +3 -3
- package/dist/prompts/errors.d.ts.map +1 -1
- package/dist/prompts/prompt-manager.d.ts +3 -3
- package/dist/prompts/prompt-manager.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.cjs +15 -29
- package/dist/prompts/providers/config-prompt-provider.d.ts +3 -3
- package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.js +15 -29
- package/dist/prompts/providers/custom-prompt-provider.d.ts +2 -2
- package/dist/prompts/providers/custom-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/mcp-prompt-provider.d.ts +2 -2
- package/dist/prompts/providers/mcp-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/schemas.d.ts +7 -7
- package/dist/resources/{internal-provider.cjs → agent-resources-provider.cjs} +16 -16
- package/dist/resources/{internal-provider.d.ts → agent-resources-provider.d.ts} +6 -6
- package/dist/resources/agent-resources-provider.d.ts.map +1 -0
- package/dist/resources/{internal-provider.js → agent-resources-provider.js} +13 -13
- package/dist/resources/errors.cjs +2 -2
- package/dist/resources/errors.d.ts.map +1 -1
- package/dist/resources/handlers/blob-handler.d.ts +2 -2
- package/dist/resources/handlers/blob-handler.d.ts.map +1 -1
- package/dist/resources/handlers/factory.d.ts +3 -3
- package/dist/resources/handlers/factory.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.d.ts +2 -2
- package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
- package/dist/resources/index.cjs +7 -9
- package/dist/resources/index.d.ts +3 -3
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +5 -10
- package/dist/resources/manager.cjs +77 -74
- package/dist/resources/manager.d.ts +16 -7
- package/dist/resources/manager.d.ts.map +1 -1
- package/dist/resources/manager.js +77 -74
- package/dist/resources/schemas.cjs +6 -26
- package/dist/resources/schemas.d.ts +8 -100
- package/dist/resources/schemas.d.ts.map +1 -1
- package/dist/resources/schemas.js +4 -23
- package/dist/search/search-service.d.ts +2 -2
- package/dist/search/search-service.d.ts.map +1 -1
- package/dist/session/chat-session.cjs +15 -25
- package/dist/session/chat-session.d.ts +7 -5
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +16 -26
- package/dist/session/errors.cjs +2 -2
- package/dist/session/errors.d.ts.map +1 -1
- package/dist/session/history/database.cjs +1 -1
- package/dist/session/history/database.d.ts +4 -4
- package/dist/session/history/database.d.ts.map +1 -1
- package/dist/session/history/factory.d.ts +3 -3
- package/dist/session/history/factory.d.ts.map +1 -1
- package/dist/session/history/memory.d.ts +4 -4
- package/dist/session/history/memory.d.ts.map +1 -1
- package/dist/session/history/types.d.ts +2 -2
- package/dist/session/history/types.d.ts.map +1 -1
- package/dist/session/index.cjs +3 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +2 -0
- package/dist/session/message-queue.d.ts +2 -2
- package/dist/session/message-queue.d.ts.map +1 -1
- package/dist/session/session-manager.cjs +67 -9
- package/dist/session/session-manager.d.ts +46 -7
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +67 -9
- package/dist/session/title-generator.cjs +2 -2
- package/dist/session/title-generator.d.ts +2 -2
- package/dist/session/title-generator.d.ts.map +1 -1
- package/dist/storage/blob/index.cjs +0 -40
- package/dist/storage/blob/index.d.ts +2 -44
- package/dist/storage/blob/index.d.ts.map +1 -1
- package/dist/storage/blob/index.js +0 -30
- package/dist/storage/cache/index.cjs +0 -37
- package/dist/storage/cache/index.d.ts +0 -42
- package/dist/storage/cache/index.d.ts.map +1 -1
- package/dist/storage/cache/index.js +0 -28
- package/dist/storage/database/index.cjs +0 -42
- package/dist/storage/database/index.d.ts +0 -43
- package/dist/storage/database/index.d.ts.map +1 -1
- package/dist/storage/database/index.js +0 -37
- package/dist/storage/error-codes.cjs +1 -6
- package/dist/storage/error-codes.d.ts +2 -7
- package/dist/storage/error-codes.d.ts.map +1 -1
- package/dist/storage/error-codes.js +1 -6
- package/dist/storage/errors.cjs +18 -82
- package/dist/storage/errors.d.ts +4 -24
- package/dist/storage/errors.d.ts.map +1 -1
- package/dist/storage/errors.js +16 -80
- package/dist/storage/index.cjs +8 -69
- package/dist/storage/index.d.ts +11 -66
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +6 -50
- package/dist/storage/storage-manager.cjs +9 -25
- package/dist/storage/storage-manager.d.ts +11 -15
- package/dist/storage/storage-manager.d.ts.map +1 -1
- package/dist/storage/storage-manager.js +8 -23
- package/dist/storage/types.d.ts +0 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/systemPrompt/contributors.d.ts +4 -4
- package/dist/systemPrompt/contributors.d.ts.map +1 -1
- package/dist/systemPrompt/errors.cjs +2 -2
- package/dist/systemPrompt/errors.d.ts.map +1 -1
- package/dist/systemPrompt/in-built-prompts.cjs +5 -5
- package/dist/systemPrompt/in-built-prompts.d.ts +1 -1
- package/dist/systemPrompt/in-built-prompts.d.ts.map +1 -1
- package/dist/systemPrompt/in-built-prompts.js +5 -5
- package/dist/systemPrompt/manager.cjs +1 -5
- package/dist/systemPrompt/manager.d.ts +2 -3
- package/dist/systemPrompt/manager.d.ts.map +1 -1
- package/dist/systemPrompt/manager.js +1 -5
- package/dist/systemPrompt/schemas.d.ts +5 -5
- package/dist/systemPrompt/types.d.ts +11 -0
- package/dist/systemPrompt/types.d.ts.map +1 -1
- package/dist/telemetry/index.cjs +3 -0
- package/dist/telemetry/index.d.ts +2 -0
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/utils.d.ts +4 -4
- package/dist/telemetry/utils.d.ts.map +1 -1
- package/dist/test-utils/in-memory-storage.cjs +288 -0
- package/dist/test-utils/in-memory-storage.js +252 -0
- package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts +3 -3
- package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/in-memory.d.ts +2 -2
- package/dist/tools/confirmation/allowed-tools-provider/in-memory.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts +4 -4
- package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/types.d.ts +2 -2
- package/dist/tools/confirmation/allowed-tools-provider/types.d.ts.map +1 -1
- package/dist/tools/{internal-tools/constants.cjs → define-tool.cjs} +8 -13
- package/dist/tools/define-tool.d.ts +11 -0
- package/dist/tools/define-tool.d.ts.map +1 -0
- package/dist/tools/define-tool.js +7 -0
- package/dist/tools/display-types.d.ts +10 -0
- package/dist/tools/display-types.d.ts.map +1 -1
- package/dist/tools/error-codes.cjs +2 -2
- package/dist/tools/error-codes.d.ts +2 -2
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +2 -2
- package/dist/tools/errors.cjs +11 -23
- package/dist/tools/errors.d.ts +4 -10
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +9 -21
- package/dist/tools/index.cjs +6 -9
- package/dist/tools/index.d.ts +3 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +3 -7
- package/dist/{storage/blob/providers/index.cjs → tools/pattern-utils.cjs} +11 -9
- package/dist/tools/pattern-utils.d.ts +20 -0
- package/dist/tools/pattern-utils.d.ts.map +1 -0
- package/dist/tools/pattern-utils.js +10 -0
- package/dist/{storage/cache/factory.cjs → tools/presentation.cjs} +26 -15
- package/dist/tools/presentation.d.ts +11 -0
- package/dist/tools/presentation.d.ts.map +1 -0
- package/dist/tools/presentation.js +24 -0
- package/dist/tools/schemas.cjs +14 -40
- package/dist/tools/schemas.d.ts +6 -50
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +11 -32
- package/dist/tools/tool-call-metadata.cjs +3 -3
- package/dist/tools/tool-call-metadata.d.ts +1 -1
- package/dist/tools/tool-call-metadata.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.js +3 -3
- package/dist/tools/tool-manager.cjs +608 -392
- package/dist/tools/tool-manager.d.ts +79 -98
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +608 -396
- package/dist/tools/types.d.ts +223 -45
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/error-conversion.d.ts +2 -2
- package/dist/utils/error-conversion.d.ts.map +1 -1
- package/dist/utils/path.cjs +10 -1
- package/dist/utils/path.d.ts +7 -4
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/path.js +10 -1
- package/dist/utils/result.cjs +1 -1
- package/dist/utils/result.d.ts.map +1 -1
- package/dist/utils/schema.cjs +9 -5
- package/dist/utils/schema.d.ts +4 -2
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +9 -5
- package/dist/utils/service-initializer.cjs +51 -56
- package/dist/utils/service-initializer.d.ts +17 -14
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +51 -56
- package/dist/{storage/cache/providers/index.cjs → workspace/error-codes.cjs} +8 -9
- package/dist/workspace/error-codes.d.ts +5 -0
- package/dist/workspace/error-codes.d.ts.map +1 -0
- package/dist/workspace/error-codes.js +7 -0
- package/dist/{storage/blob/factory.cjs → workspace/errors.cjs} +20 -14
- package/dist/workspace/errors.d.ts +5 -0
- package/dist/workspace/errors.d.ts.map +1 -0
- package/dist/workspace/errors.js +21 -0
- package/dist/{image → workspace}/index.cjs +12 -10
- package/dist/workspace/index.d.ts +5 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +9 -0
- package/dist/workspace/manager.cjs +113 -0
- package/dist/workspace/manager.d.ts +18 -0
- package/dist/workspace/manager.d.ts.map +1 -0
- package/dist/workspace/manager.js +90 -0
- package/dist/workspace/types.d.ts +14 -0
- package/dist/workspace/types.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/context/compaction/factory.cjs +0 -57
- package/dist/context/compaction/factory.d.ts +0 -17
- package/dist/context/compaction/factory.d.ts.map +0 -1
- package/dist/context/compaction/factory.js +0 -34
- package/dist/context/compaction/provider.d.ts +0 -48
- package/dist/context/compaction/provider.d.ts.map +0 -1
- package/dist/context/compaction/providers/noop-provider.d.ts +0 -24
- package/dist/context/compaction/providers/noop-provider.d.ts.map +0 -1
- package/dist/context/compaction/providers/noop-provider.js +0 -24
- package/dist/context/compaction/providers/reactive-overflow-provider.cjs +0 -76
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts +0 -51
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts.map +0 -1
- package/dist/context/compaction/providers/reactive-overflow-provider.js +0 -52
- package/dist/context/compaction/registry.cjs +0 -39
- package/dist/context/compaction/registry.d.ts +0 -19
- package/dist/context/compaction/registry.d.ts.map +0 -1
- package/dist/context/compaction/registry.js +0 -16
- package/dist/context/compaction/schemas.cjs +0 -58
- package/dist/context/compaction/schemas.d.ts +0 -69
- package/dist/context/compaction/schemas.d.ts.map +0 -1
- package/dist/context/compaction/schemas.js +0 -34
- package/dist/context/compaction/strategies/reactive-overflow.d.ts.map +0 -1
- package/dist/image/define-image.cjs +0 -146
- package/dist/image/define-image.d.ts +0 -71
- package/dist/image/define-image.d.ts.map +0 -1
- package/dist/image/define-image.js +0 -121
- package/dist/image/index.d.ts +0 -53
- package/dist/image/index.d.ts.map +0 -1
- package/dist/image/index.js +0 -7
- package/dist/image/types.d.ts +0 -246
- package/dist/image/types.d.ts.map +0 -1
- package/dist/llm/services/test-utils.integration.cjs +0 -237
- package/dist/llm/services/test-utils.integration.d.ts +0 -48
- package/dist/llm/services/test-utils.integration.d.ts.map +0 -1
- package/dist/llm/services/test-utils.integration.js +0 -214
- package/dist/plugins/builtins/content-policy.d.ts +0 -26
- package/dist/plugins/builtins/content-policy.d.ts.map +0 -1
- package/dist/plugins/builtins/response-sanitizer.d.ts +0 -25
- package/dist/plugins/builtins/response-sanitizer.d.ts.map +0 -1
- package/dist/plugins/error-codes.cjs +0 -43
- package/dist/plugins/error-codes.d.ts +0 -34
- package/dist/plugins/error-codes.d.ts.map +0 -1
- package/dist/plugins/error-codes.js +0 -20
- package/dist/plugins/index.cjs +0 -61
- package/dist/plugins/index.d.ts +0 -21
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -30
- package/dist/plugins/loader.cjs +0 -171
- package/dist/plugins/loader.d.ts +0 -30
- package/dist/plugins/loader.d.ts.map +0 -1
- package/dist/plugins/loader.js +0 -145
- package/dist/plugins/manager.cjs +0 -473
- package/dist/plugins/manager.d.ts +0 -106
- package/dist/plugins/manager.d.ts.map +0 -1
- package/dist/plugins/manager.js +0 -450
- package/dist/plugins/registrations/builtins.cjs +0 -51
- package/dist/plugins/registrations/builtins.d.ts +0 -17
- package/dist/plugins/registrations/builtins.d.ts.map +0 -1
- package/dist/plugins/registrations/builtins.js +0 -28
- package/dist/plugins/registry.cjs +0 -63
- package/dist/plugins/registry.d.ts +0 -101
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js +0 -39
- package/dist/plugins/schemas.cjs +0 -73
- package/dist/plugins/schemas.d.ts +0 -195
- package/dist/plugins/schemas.d.ts.map +0 -1
- package/dist/plugins/schemas.js +0 -47
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/providers/base-registry.cjs +0 -147
- package/dist/providers/base-registry.d.ts +0 -147
- package/dist/providers/base-registry.d.ts.map +0 -1
- package/dist/providers/base-registry.js +0 -123
- package/dist/providers/discovery.cjs +0 -109
- package/dist/providers/discovery.d.ts +0 -96
- package/dist/providers/discovery.d.ts.map +0 -1
- package/dist/providers/discovery.js +0 -84
- package/dist/providers/index.cjs +0 -24
- package/dist/providers/index.d.ts +0 -32
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -2
- package/dist/resources/internal-provider.d.ts.map +0 -1
- package/dist/storage/blob/factory.d.ts +0 -37
- package/dist/storage/blob/factory.d.ts.map +0 -1
- package/dist/storage/blob/factory.js +0 -15
- package/dist/storage/blob/local-blob-store.cjs +0 -496
- package/dist/storage/blob/local-blob-store.d.ts +0 -58
- package/dist/storage/blob/local-blob-store.d.ts.map +0 -1
- package/dist/storage/blob/local-blob-store.js +0 -463
- package/dist/storage/blob/memory-blob-store.cjs +0 -326
- package/dist/storage/blob/memory-blob-store.d.ts +0 -66
- package/dist/storage/blob/memory-blob-store.d.ts.map +0 -1
- package/dist/storage/blob/memory-blob-store.js +0 -303
- package/dist/storage/blob/provider.d.ts +0 -50
- package/dist/storage/blob/provider.d.ts.map +0 -1
- package/dist/storage/blob/providers/index.d.ts +0 -8
- package/dist/storage/blob/providers/index.d.ts.map +0 -1
- package/dist/storage/blob/providers/index.js +0 -7
- package/dist/storage/blob/providers/local.cjs +0 -39
- package/dist/storage/blob/providers/local.d.ts +0 -17
- package/dist/storage/blob/providers/local.d.ts.map +0 -1
- package/dist/storage/blob/providers/local.js +0 -16
- package/dist/storage/blob/providers/memory.cjs +0 -39
- package/dist/storage/blob/providers/memory.d.ts +0 -17
- package/dist/storage/blob/providers/memory.d.ts.map +0 -1
- package/dist/storage/blob/providers/memory.js +0 -16
- package/dist/storage/blob/registry.cjs +0 -50
- package/dist/storage/blob/registry.d.ts +0 -42
- package/dist/storage/blob/registry.d.ts.map +0 -1
- package/dist/storage/blob/registry.js +0 -26
- package/dist/storage/blob/schemas.cjs +0 -52
- package/dist/storage/blob/schemas.d.ts +0 -85
- package/dist/storage/blob/schemas.d.ts.map +0 -1
- package/dist/storage/blob/schemas.js +0 -26
- package/dist/storage/cache/factory.d.ts +0 -37
- package/dist/storage/cache/factory.d.ts.map +0 -1
- package/dist/storage/cache/factory.js +0 -15
- package/dist/storage/cache/memory-cache-store.cjs +0 -107
- package/dist/storage/cache/memory-cache-store.d.ts +0 -26
- package/dist/storage/cache/memory-cache-store.d.ts.map +0 -1
- package/dist/storage/cache/memory-cache-store.js +0 -84
- package/dist/storage/cache/provider.cjs +0 -16
- package/dist/storage/cache/provider.d.ts +0 -56
- package/dist/storage/cache/provider.d.ts.map +0 -1
- package/dist/storage/cache/provider.js +0 -0
- package/dist/storage/cache/providers/index.d.ts +0 -8
- package/dist/storage/cache/providers/index.d.ts.map +0 -1
- package/dist/storage/cache/providers/index.js +0 -7
- package/dist/storage/cache/providers/memory.d.ts +0 -17
- package/dist/storage/cache/providers/memory.d.ts.map +0 -1
- package/dist/storage/cache/providers/memory.js +0 -17
- package/dist/storage/cache/providers/redis.cjs +0 -66
- package/dist/storage/cache/providers/redis.d.ts +0 -20
- package/dist/storage/cache/providers/redis.d.ts.map +0 -1
- package/dist/storage/cache/providers/redis.js +0 -33
- package/dist/storage/cache/redis-store.cjs +0 -173
- package/dist/storage/cache/redis-store.d.ts +0 -32
- package/dist/storage/cache/redis-store.d.ts.map +0 -1
- package/dist/storage/cache/redis-store.js +0 -150
- package/dist/storage/cache/registry.cjs +0 -50
- package/dist/storage/cache/registry.d.ts +0 -42
- package/dist/storage/cache/registry.d.ts.map +0 -1
- package/dist/storage/cache/registry.js +0 -26
- package/dist/storage/cache/schemas.cjs +0 -81
- package/dist/storage/cache/schemas.d.ts +0 -150
- package/dist/storage/cache/schemas.d.ts.map +0 -1
- package/dist/storage/cache/schemas.js +0 -55
- package/dist/storage/database/factory.cjs +0 -38
- package/dist/storage/database/factory.d.ts +0 -39
- package/dist/storage/database/factory.d.ts.map +0 -1
- package/dist/storage/database/factory.js +0 -15
- package/dist/storage/database/memory-database-store.cjs +0 -122
- package/dist/storage/database/memory-database-store.d.ts +0 -29
- package/dist/storage/database/memory-database-store.d.ts.map +0 -1
- package/dist/storage/database/memory-database-store.js +0 -99
- package/dist/storage/database/postgres-store.cjs +0 -342
- package/dist/storage/database/postgres-store.d.ts +0 -55
- package/dist/storage/database/postgres-store.d.ts.map +0 -1
- package/dist/storage/database/postgres-store.js +0 -319
- package/dist/storage/database/provider.cjs +0 -16
- package/dist/storage/database/provider.d.ts +0 -56
- package/dist/storage/database/provider.d.ts.map +0 -1
- package/dist/storage/database/provider.js +0 -0
- package/dist/storage/database/providers/index.cjs +0 -34
- package/dist/storage/database/providers/index.d.ts +0 -9
- package/dist/storage/database/providers/index.d.ts.map +0 -1
- package/dist/storage/database/providers/index.js +0 -9
- package/dist/storage/database/providers/memory.cjs +0 -40
- package/dist/storage/database/providers/memory.d.ts +0 -16
- package/dist/storage/database/providers/memory.d.ts.map +0 -1
- package/dist/storage/database/providers/memory.js +0 -17
- package/dist/storage/database/providers/postgres.cjs +0 -62
- package/dist/storage/database/providers/postgres.d.ts +0 -19
- package/dist/storage/database/providers/postgres.d.ts.map +0 -1
- package/dist/storage/database/providers/postgres.js +0 -29
- package/dist/storage/database/providers/sqlite.cjs +0 -66
- package/dist/storage/database/providers/sqlite.d.ts +0 -20
- package/dist/storage/database/providers/sqlite.d.ts.map +0 -1
- package/dist/storage/database/providers/sqlite.js +0 -33
- package/dist/storage/database/registry.cjs +0 -50
- package/dist/storage/database/registry.d.ts +0 -42
- package/dist/storage/database/registry.d.ts.map +0 -1
- package/dist/storage/database/registry.js +0 -26
- package/dist/storage/database/schemas.cjs +0 -97
- package/dist/storage/database/schemas.d.ts +0 -226
- package/dist/storage/database/schemas.d.ts.map +0 -1
- package/dist/storage/database/schemas.js +0 -70
- package/dist/storage/database/sqlite-store.cjs +0 -270
- package/dist/storage/database/sqlite-store.d.ts +0 -33
- package/dist/storage/database/sqlite-store.d.ts.map +0 -1
- package/dist/storage/database/sqlite-store.js +0 -237
- package/dist/storage/schemas.cjs +0 -57
- package/dist/storage/schemas.d.ts +0 -347
- package/dist/storage/schemas.d.ts.map +0 -1
- package/dist/storage/schemas.js +0 -37
- package/dist/tools/bash-pattern-utils.cjs +0 -91
- package/dist/tools/bash-pattern-utils.d.ts +0 -58
- package/dist/tools/bash-pattern-utils.d.ts.map +0 -1
- package/dist/tools/bash-pattern-utils.js +0 -64
- package/dist/tools/custom-tool-registry.cjs +0 -64
- package/dist/tools/custom-tool-registry.d.ts +0 -126
- package/dist/tools/custom-tool-registry.d.ts.map +0 -1
- package/dist/tools/custom-tool-registry.js +0 -40
- package/dist/tools/custom-tool-schema-registry.cjs +0 -164
- package/dist/tools/custom-tool-schema-registry.d.ts +0 -86
- package/dist/tools/custom-tool-schema-registry.d.ts.map +0 -1
- package/dist/tools/custom-tool-schema-registry.js +0 -140
- package/dist/tools/internal-tools/constants.d.ts +0 -12
- package/dist/tools/internal-tools/constants.d.ts.map +0 -1
- package/dist/tools/internal-tools/constants.js +0 -12
- package/dist/tools/internal-tools/implementations/ask-user-tool.cjs +0 -57
- package/dist/tools/internal-tools/implementations/ask-user-tool.d.ts +0 -18
- package/dist/tools/internal-tools/implementations/ask-user-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/ask-user-tool.js +0 -34
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.cjs +0 -192
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.d.ts +0 -33
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/delegate-to-url-tool.js +0 -169
- package/dist/tools/internal-tools/implementations/get-resource-tool.cjs +0 -113
- package/dist/tools/internal-tools/implementations/get-resource-tool.d.ts +0 -30
- package/dist/tools/internal-tools/implementations/get-resource-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/get-resource-tool.js +0 -90
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.cjs +0 -140
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.d.ts +0 -24
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/invoke-skill-tool.js +0 -117
- package/dist/tools/internal-tools/implementations/list-resources-tool.cjs +0 -91
- package/dist/tools/internal-tools/implementations/list-resources-tool.d.ts +0 -24
- package/dist/tools/internal-tools/implementations/list-resources-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/list-resources-tool.js +0 -68
- package/dist/tools/internal-tools/implementations/search-history-tool.cjs +0 -61
- package/dist/tools/internal-tools/implementations/search-history-tool.d.ts +0 -7
- package/dist/tools/internal-tools/implementations/search-history-tool.d.ts.map +0 -1
- package/dist/tools/internal-tools/implementations/search-history-tool.js +0 -38
- package/dist/tools/internal-tools/index.cjs +0 -26
- package/dist/tools/internal-tools/index.d.ts +0 -4
- package/dist/tools/internal-tools/index.d.ts.map +0 -1
- package/dist/tools/internal-tools/index.js +0 -3
- package/dist/tools/internal-tools/provider.cjs +0 -324
- package/dist/tools/internal-tools/provider.d.ts +0 -116
- package/dist/tools/internal-tools/provider.d.ts.map +0 -1
- package/dist/tools/internal-tools/provider.js +0 -301
- package/dist/tools/internal-tools/registry.cjs +0 -71
- package/dist/tools/internal-tools/registry.d.ts +0 -91
- package/dist/tools/internal-tools/registry.d.ts.map +0 -1
- package/dist/tools/internal-tools/registry.js +0 -47
- /package/dist/{context/compaction/provider.js → agent/agent-options.js} +0 -0
- /package/dist/{image/types.js → agent/runtime-config.js} +0 -0
- /package/dist/{image → hooks}/types.cjs +0 -0
- /package/dist/{plugins → hooks}/types.js +0 -0
- /package/dist/{plugins → workspace}/types.cjs +0 -0
- /package/dist/{storage/blob/provider.js → workspace/types.js} +0 -0
|
@@ -16,13 +16,14 @@ 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 reactive_overflow_compaction_exports = {};
|
|
20
|
+
__export(reactive_overflow_compaction_exports, {
|
|
21
|
+
ReactiveOverflowCompactionStrategy: () => ReactiveOverflowCompactionStrategy
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(reactive_overflow_compaction_exports);
|
|
24
24
|
var import_ai = require("ai");
|
|
25
25
|
var import_types = require("../../types.js");
|
|
26
|
+
var import_overflow = require("../overflow.js");
|
|
26
27
|
const DEFAULT_OPTIONS = {
|
|
27
28
|
preserveLastNTurns: 2,
|
|
28
29
|
maxSummaryTokens: 2e3,
|
|
@@ -58,30 +59,43 @@ IMPORTANT: The assistant will continue working based on this summary. Ensure the
|
|
|
58
59
|
Conversation to summarize:
|
|
59
60
|
{conversation}`
|
|
60
61
|
};
|
|
61
|
-
class
|
|
62
|
+
class ReactiveOverflowCompactionStrategy {
|
|
62
63
|
name = "reactive-overflow";
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
settings;
|
|
65
|
+
strategyOptions;
|
|
66
|
+
constructor(options = {}) {
|
|
67
|
+
this.settings = {
|
|
68
|
+
enabled: options.enabled ?? true,
|
|
69
|
+
maxContextTokens: options.maxContextTokens,
|
|
70
|
+
thresholdPercent: options.thresholdPercent ?? 0.9
|
|
71
|
+
};
|
|
72
|
+
this.strategyOptions = {
|
|
73
|
+
...DEFAULT_OPTIONS,
|
|
74
|
+
...options.strategy ?? {}
|
|
75
|
+
};
|
|
70
76
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
getSettings() {
|
|
78
|
+
return this.settings;
|
|
79
|
+
}
|
|
80
|
+
getModelLimits(modelContextWindow) {
|
|
81
|
+
const capped = this.settings.enabled && this.settings.maxContextTokens !== void 0 ? Math.min(modelContextWindow, this.settings.maxContextTokens) : modelContextWindow;
|
|
82
|
+
return { contextWindow: capped };
|
|
83
|
+
}
|
|
84
|
+
shouldCompact(inputTokens, modelLimits) {
|
|
85
|
+
if (!this.settings.enabled) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return (0, import_overflow.isOverflow)({ inputTokens }, modelLimits, this.settings.thresholdPercent);
|
|
89
|
+
}
|
|
90
|
+
async compact(history, context) {
|
|
91
|
+
if (!this.settings.enabled) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const { model, logger } = context;
|
|
83
95
|
if (history.length <= 2) {
|
|
84
|
-
|
|
96
|
+
logger.debug(
|
|
97
|
+
"ReactiveOverflowCompactionStrategy: History too short, skipping compaction"
|
|
98
|
+
);
|
|
85
99
|
return [];
|
|
86
100
|
}
|
|
87
101
|
let existingSummaryIndex = -1;
|
|
@@ -95,26 +109,32 @@ class ReactiveOverflowStrategy {
|
|
|
95
109
|
if (existingSummaryIndex !== -1) {
|
|
96
110
|
const messagesAfterSummary = history.slice(existingSummaryIndex + 1);
|
|
97
111
|
if (messagesAfterSummary.length <= 4) {
|
|
98
|
-
|
|
99
|
-
`
|
|
112
|
+
logger.debug(
|
|
113
|
+
`ReactiveOverflowCompactionStrategy: Only ${messagesAfterSummary.length} messages after existing summary, skipping re-compaction`
|
|
100
114
|
);
|
|
101
115
|
return [];
|
|
102
116
|
}
|
|
103
|
-
|
|
104
|
-
`
|
|
117
|
+
logger.info(
|
|
118
|
+
`ReactiveOverflowCompactionStrategy: Found existing summary at index ${existingSummaryIndex}, working with ${messagesAfterSummary.length} messages after it`
|
|
119
|
+
);
|
|
120
|
+
return this.compactSubset(
|
|
121
|
+
messagesAfterSummary,
|
|
122
|
+
history,
|
|
123
|
+
existingSummaryIndex,
|
|
124
|
+
model,
|
|
125
|
+
logger
|
|
105
126
|
);
|
|
106
|
-
return this.compactSubset(messagesAfterSummary, history, existingSummaryIndex);
|
|
107
127
|
}
|
|
108
128
|
const { toSummarize, toKeep } = this.splitHistory(history);
|
|
109
129
|
if (toSummarize.length === 0) {
|
|
110
|
-
|
|
130
|
+
logger.debug("ReactiveOverflowCompactionStrategy: No messages to summarize");
|
|
111
131
|
return [];
|
|
112
132
|
}
|
|
113
133
|
const currentTaskMessage = this.findCurrentTaskMessage(history);
|
|
114
|
-
|
|
115
|
-
`
|
|
134
|
+
logger.info(
|
|
135
|
+
`ReactiveOverflowCompactionStrategy: Summarizing ${toSummarize.length} messages, keeping ${toKeep.length}`
|
|
116
136
|
);
|
|
117
|
-
const summary = await this.generateSummary(toSummarize, currentTaskMessage);
|
|
137
|
+
const summary = await this.generateSummary(toSummarize, currentTaskMessage, model, logger);
|
|
118
138
|
const summaryMessage = {
|
|
119
139
|
role: "assistant",
|
|
120
140
|
content: [{ type: "text", text: summary }],
|
|
@@ -133,23 +153,18 @@ class ReactiveOverflowStrategy {
|
|
|
133
153
|
* Handle re-compaction when there's already a summary in history.
|
|
134
154
|
* Only summarizes messages AFTER the existing summary, preventing
|
|
135
155
|
* cascading summaries of summaries.
|
|
136
|
-
*
|
|
137
|
-
* @param messagesAfterSummary Messages after the existing summary
|
|
138
|
-
* @param fullHistory The complete history (for current task detection)
|
|
139
|
-
* @param existingSummaryIndex Index of the existing summary in fullHistory
|
|
140
|
-
* @returns Array with single summary message, or empty if nothing to summarize
|
|
141
156
|
*/
|
|
142
|
-
async compactSubset(messagesAfterSummary, fullHistory, existingSummaryIndex) {
|
|
157
|
+
async compactSubset(messagesAfterSummary, fullHistory, existingSummaryIndex, model, logger) {
|
|
143
158
|
const { toSummarize, toKeep } = this.splitHistory(messagesAfterSummary);
|
|
144
159
|
if (toSummarize.length === 0) {
|
|
145
|
-
|
|
160
|
+
logger.debug("ReactiveOverflowCompactionStrategy: No messages to summarize in subset");
|
|
146
161
|
return [];
|
|
147
162
|
}
|
|
148
163
|
const currentTaskMessage = this.findCurrentTaskMessage(fullHistory);
|
|
149
|
-
|
|
150
|
-
`
|
|
164
|
+
logger.info(
|
|
165
|
+
`ReactiveOverflowCompactionStrategy (re-compact): Summarizing ${toSummarize.length} messages after existing summary, keeping ${toKeep.length}`
|
|
151
166
|
);
|
|
152
|
-
const summary = await this.generateSummary(toSummarize, currentTaskMessage);
|
|
167
|
+
const summary = await this.generateSummary(toSummarize, currentTaskMessage, model, logger);
|
|
153
168
|
const absoluteOriginalMessageCount = existingSummaryIndex + 1 + toSummarize.length;
|
|
154
169
|
const summaryMessage = {
|
|
155
170
|
role: "assistant",
|
|
@@ -160,7 +175,6 @@ class ReactiveOverflowStrategy {
|
|
|
160
175
|
summarizedAt: Date.now(),
|
|
161
176
|
originalMessageCount: absoluteOriginalMessageCount,
|
|
162
177
|
isRecompaction: true,
|
|
163
|
-
// Mark that this is a re-compaction
|
|
164
178
|
originalFirstTimestamp: toSummarize[0]?.timestamp,
|
|
165
179
|
originalLastTimestamp: toSummarize[toSummarize.length - 1]?.timestamp
|
|
166
180
|
}
|
|
@@ -169,7 +183,6 @@ class ReactiveOverflowStrategy {
|
|
|
169
183
|
}
|
|
170
184
|
/**
|
|
171
185
|
* Find the most recent user message that represents the current task.
|
|
172
|
-
* This helps preserve context about what the user is currently asking for.
|
|
173
186
|
*/
|
|
174
187
|
findCurrentTaskMessage(history) {
|
|
175
188
|
for (let i = history.length - 1; i >= 0; i--) {
|
|
@@ -191,13 +204,9 @@ class ReactiveOverflowStrategy {
|
|
|
191
204
|
}
|
|
192
205
|
/**
|
|
193
206
|
* Split history into messages to summarize and messages to keep.
|
|
194
|
-
* Keeps the last N turns (user + assistant pairs) intact.
|
|
195
|
-
*
|
|
196
|
-
* For long agentic conversations with many tool calls, this also ensures
|
|
197
|
-
* we don't try to keep too many messages even within preserved turns.
|
|
198
207
|
*/
|
|
199
208
|
splitHistory(history) {
|
|
200
|
-
const turnsToKeep = this.
|
|
209
|
+
const turnsToKeep = this.strategyOptions.preserveLastNTurns;
|
|
201
210
|
const userMessageIndices = [];
|
|
202
211
|
for (let i = history.length - 1; i >= 0; i--) {
|
|
203
212
|
if (history[i]?.role === "user") {
|
|
@@ -225,9 +234,6 @@ class ReactiveOverflowStrategy {
|
|
|
225
234
|
toKeep: history
|
|
226
235
|
};
|
|
227
236
|
}
|
|
228
|
-
this.logger.debug(
|
|
229
|
-
`splitHistory: Using fallback - keeping last ${keepCount} of ${history.length} messages`
|
|
230
|
-
);
|
|
231
237
|
return {
|
|
232
238
|
toSummarize: history.slice(0, -keepCount),
|
|
233
239
|
toKeep: history.slice(-keepCount)
|
|
@@ -235,11 +241,8 @@ class ReactiveOverflowStrategy {
|
|
|
235
241
|
}
|
|
236
242
|
/**
|
|
237
243
|
* Generate an LLM summary of the messages.
|
|
238
|
-
*
|
|
239
|
-
* @param messages Messages to summarize
|
|
240
|
-
* @param currentTask The most recent user message (current task context)
|
|
241
244
|
*/
|
|
242
|
-
async generateSummary(messages, currentTask) {
|
|
245
|
+
async generateSummary(messages, currentTask, model, logger) {
|
|
243
246
|
const formattedConversation = this.formatMessagesForSummary(messages);
|
|
244
247
|
let conversationWithContext = formattedConversation;
|
|
245
248
|
if (currentTask) {
|
|
@@ -248,21 +251,21 @@ class ReactiveOverflowStrategy {
|
|
|
248
251
|
--- CURRENT TASK (most recent user request) ---
|
|
249
252
|
${currentTask}`;
|
|
250
253
|
}
|
|
251
|
-
const prompt = this.
|
|
254
|
+
const prompt = this.strategyOptions.summaryPrompt.replace(
|
|
252
255
|
"{conversation}",
|
|
253
256
|
conversationWithContext
|
|
254
257
|
);
|
|
255
258
|
try {
|
|
256
259
|
const result = await (0, import_ai.generateText)({
|
|
257
|
-
model
|
|
260
|
+
model,
|
|
258
261
|
prompt,
|
|
259
|
-
maxOutputTokens: this.
|
|
262
|
+
maxOutputTokens: this.strategyOptions.maxSummaryTokens
|
|
260
263
|
});
|
|
261
264
|
return `[Session Compaction Summary]
|
|
262
265
|
${result.text}`;
|
|
263
266
|
} catch (error) {
|
|
264
|
-
|
|
265
|
-
`
|
|
267
|
+
logger.error(
|
|
268
|
+
`ReactiveOverflowCompactionStrategy: Failed to generate summary - ${error instanceof Error ? error.message : String(error)}`
|
|
266
269
|
);
|
|
267
270
|
return this.createFallbackSummary(messages, currentTask);
|
|
268
271
|
}
|
|
@@ -339,5 +342,5 @@ ${result.text}`;
|
|
|
339
342
|
}
|
|
340
343
|
// Annotate the CommonJS export names for ESM import in node:
|
|
341
344
|
0 && (module.exports = {
|
|
342
|
-
|
|
345
|
+
ReactiveOverflowCompactionStrategy
|
|
343
346
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { type LanguageModel } from 'ai';
|
|
2
|
-
import type { ICompactionStrategy } from '../types.js';
|
|
3
1
|
import type { InternalMessage } from '../../types.js';
|
|
4
|
-
import type
|
|
2
|
+
import { type ModelLimits } from '../overflow.js';
|
|
3
|
+
import type { CompactionRuntimeContext, CompactionSettings, CompactionStrategy } from '../types.js';
|
|
5
4
|
/**
|
|
6
|
-
* Configuration options for
|
|
5
|
+
* Configuration options for ReactiveOverflowCompactionStrategy.
|
|
7
6
|
*/
|
|
8
7
|
export interface ReactiveOverflowOptions {
|
|
9
8
|
/**
|
|
@@ -23,8 +22,14 @@ export interface ReactiveOverflowOptions {
|
|
|
23
22
|
*/
|
|
24
23
|
summaryPrompt?: string;
|
|
25
24
|
}
|
|
25
|
+
export interface ReactiveOverflowCompactionStrategyOptions {
|
|
26
|
+
enabled?: boolean | undefined;
|
|
27
|
+
maxContextTokens?: number | undefined;
|
|
28
|
+
thresholdPercent?: number | undefined;
|
|
29
|
+
strategy?: ReactiveOverflowOptions | undefined;
|
|
30
|
+
}
|
|
26
31
|
/**
|
|
27
|
-
*
|
|
32
|
+
* ReactiveOverflowCompactionStrategy implements reactive compaction.
|
|
28
33
|
*
|
|
29
34
|
* Key behaviors:
|
|
30
35
|
* - Triggers on overflow (after actual tokens exceed context limit)
|
|
@@ -42,53 +47,31 @@ export interface ReactiveOverflowOptions {
|
|
|
42
47
|
* and filterCompacted() handles excluding old messages at read-time.
|
|
43
48
|
* This preserves full history for audit/recovery purposes.
|
|
44
49
|
*/
|
|
45
|
-
export declare class
|
|
50
|
+
export declare class ReactiveOverflowCompactionStrategy implements CompactionStrategy {
|
|
46
51
|
readonly name = "reactive-overflow";
|
|
47
|
-
private readonly
|
|
48
|
-
private readonly
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
compact(history: readonly InternalMessage[]): Promise<InternalMessage[]>;
|
|
52
|
+
private readonly settings;
|
|
53
|
+
private readonly strategyOptions;
|
|
54
|
+
constructor(options?: ReactiveOverflowCompactionStrategyOptions);
|
|
55
|
+
getSettings(): CompactionSettings;
|
|
56
|
+
getModelLimits(modelContextWindow: number): ModelLimits;
|
|
57
|
+
shouldCompact(inputTokens: number, modelLimits: ModelLimits): boolean;
|
|
58
|
+
compact(history: readonly InternalMessage[], context: CompactionRuntimeContext): Promise<InternalMessage[]>;
|
|
63
59
|
/**
|
|
64
60
|
* Handle re-compaction when there's already a summary in history.
|
|
65
61
|
* Only summarizes messages AFTER the existing summary, preventing
|
|
66
62
|
* cascading summaries of summaries.
|
|
67
|
-
*
|
|
68
|
-
* @param messagesAfterSummary Messages after the existing summary
|
|
69
|
-
* @param fullHistory The complete history (for current task detection)
|
|
70
|
-
* @param existingSummaryIndex Index of the existing summary in fullHistory
|
|
71
|
-
* @returns Array with single summary message, or empty if nothing to summarize
|
|
72
63
|
*/
|
|
73
64
|
private compactSubset;
|
|
74
65
|
/**
|
|
75
66
|
* Find the most recent user message that represents the current task.
|
|
76
|
-
* This helps preserve context about what the user is currently asking for.
|
|
77
67
|
*/
|
|
78
68
|
private findCurrentTaskMessage;
|
|
79
69
|
/**
|
|
80
70
|
* Split history into messages to summarize and messages to keep.
|
|
81
|
-
* Keeps the last N turns (user + assistant pairs) intact.
|
|
82
|
-
*
|
|
83
|
-
* For long agentic conversations with many tool calls, this also ensures
|
|
84
|
-
* we don't try to keep too many messages even within preserved turns.
|
|
85
71
|
*/
|
|
86
72
|
private splitHistory;
|
|
87
73
|
/**
|
|
88
74
|
* Generate an LLM summary of the messages.
|
|
89
|
-
*
|
|
90
|
-
* @param messages Messages to summarize
|
|
91
|
-
* @param currentTask The most recent user message (current task context)
|
|
92
75
|
*/
|
|
93
76
|
private generateSummary;
|
|
94
77
|
/**
|
|
@@ -100,4 +83,4 @@ export declare class ReactiveOverflowStrategy implements ICompactionStrategy {
|
|
|
100
83
|
*/
|
|
101
84
|
private createFallbackSummary;
|
|
102
85
|
}
|
|
103
|
-
//# sourceMappingURL=reactive-overflow.d.ts.map
|
|
86
|
+
//# sourceMappingURL=reactive-overflow-compaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive-overflow-compaction.d.ts","sourceRoot":"","sources":["../../../../src/context/compaction/strategies/reactive-overflow-compaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAY,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEpG;;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;AAED,MAAM,WAAW,yCAAyC;IACtD,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAC;CAClD;AAsCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,kCAAmC,YAAW,kBAAkB;IACzE,QAAQ,CAAC,IAAI,uBAAuB;IAEpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoC;gBAExD,OAAO,GAAE,yCAA8C;IAYnE,WAAW,IAAI,kBAAkB;IAIjC,cAAc,CAAC,kBAAkB,EAAE,MAAM,GAAG,WAAW;IASvD,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO;IAO/D,OAAO,CACT,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,eAAe,EAAE,CAAC;IA+F7B;;;;OAIG;YACW,aAAa;IA8C3B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAsB9B;;OAEG;IACH,OAAO,CAAC,YAAY;IA8CpB;;OAEG;YACW,eAAe;IAkC7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAuChC;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAyDhC"}
|
package/dist/context/compaction/strategies/{reactive-overflow.js → reactive-overflow-compaction.js}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../../../chunk-PTJYTZNU.js";
|
|
2
2
|
import { generateText } from "ai";
|
|
3
3
|
import { isAssistantMessage, isToolMessage } from "../../types.js";
|
|
4
|
+
import { isOverflow } from "../overflow.js";
|
|
4
5
|
const DEFAULT_OPTIONS = {
|
|
5
6
|
preserveLastNTurns: 2,
|
|
6
7
|
maxSummaryTokens: 2e3,
|
|
@@ -36,30 +37,43 @@ IMPORTANT: The assistant will continue working based on this summary. Ensure the
|
|
|
36
37
|
Conversation to summarize:
|
|
37
38
|
{conversation}`
|
|
38
39
|
};
|
|
39
|
-
class
|
|
40
|
+
class ReactiveOverflowCompactionStrategy {
|
|
40
41
|
name = "reactive-overflow";
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
settings;
|
|
43
|
+
strategyOptions;
|
|
44
|
+
constructor(options = {}) {
|
|
45
|
+
this.settings = {
|
|
46
|
+
enabled: options.enabled ?? true,
|
|
47
|
+
maxContextTokens: options.maxContextTokens,
|
|
48
|
+
thresholdPercent: options.thresholdPercent ?? 0.9
|
|
49
|
+
};
|
|
50
|
+
this.strategyOptions = {
|
|
51
|
+
...DEFAULT_OPTIONS,
|
|
52
|
+
...options.strategy ?? {}
|
|
53
|
+
};
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
getSettings() {
|
|
56
|
+
return this.settings;
|
|
57
|
+
}
|
|
58
|
+
getModelLimits(modelContextWindow) {
|
|
59
|
+
const capped = this.settings.enabled && this.settings.maxContextTokens !== void 0 ? Math.min(modelContextWindow, this.settings.maxContextTokens) : modelContextWindow;
|
|
60
|
+
return { contextWindow: capped };
|
|
61
|
+
}
|
|
62
|
+
shouldCompact(inputTokens, modelLimits) {
|
|
63
|
+
if (!this.settings.enabled) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return isOverflow({ inputTokens }, modelLimits, this.settings.thresholdPercent);
|
|
67
|
+
}
|
|
68
|
+
async compact(history, context) {
|
|
69
|
+
if (!this.settings.enabled) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const { model, logger } = context;
|
|
61
73
|
if (history.length <= 2) {
|
|
62
|
-
|
|
74
|
+
logger.debug(
|
|
75
|
+
"ReactiveOverflowCompactionStrategy: History too short, skipping compaction"
|
|
76
|
+
);
|
|
63
77
|
return [];
|
|
64
78
|
}
|
|
65
79
|
let existingSummaryIndex = -1;
|
|
@@ -73,26 +87,32 @@ class ReactiveOverflowStrategy {
|
|
|
73
87
|
if (existingSummaryIndex !== -1) {
|
|
74
88
|
const messagesAfterSummary = history.slice(existingSummaryIndex + 1);
|
|
75
89
|
if (messagesAfterSummary.length <= 4) {
|
|
76
|
-
|
|
77
|
-
`
|
|
90
|
+
logger.debug(
|
|
91
|
+
`ReactiveOverflowCompactionStrategy: Only ${messagesAfterSummary.length} messages after existing summary, skipping re-compaction`
|
|
78
92
|
);
|
|
79
93
|
return [];
|
|
80
94
|
}
|
|
81
|
-
|
|
82
|
-
`
|
|
95
|
+
logger.info(
|
|
96
|
+
`ReactiveOverflowCompactionStrategy: Found existing summary at index ${existingSummaryIndex}, working with ${messagesAfterSummary.length} messages after it`
|
|
97
|
+
);
|
|
98
|
+
return this.compactSubset(
|
|
99
|
+
messagesAfterSummary,
|
|
100
|
+
history,
|
|
101
|
+
existingSummaryIndex,
|
|
102
|
+
model,
|
|
103
|
+
logger
|
|
83
104
|
);
|
|
84
|
-
return this.compactSubset(messagesAfterSummary, history, existingSummaryIndex);
|
|
85
105
|
}
|
|
86
106
|
const { toSummarize, toKeep } = this.splitHistory(history);
|
|
87
107
|
if (toSummarize.length === 0) {
|
|
88
|
-
|
|
108
|
+
logger.debug("ReactiveOverflowCompactionStrategy: No messages to summarize");
|
|
89
109
|
return [];
|
|
90
110
|
}
|
|
91
111
|
const currentTaskMessage = this.findCurrentTaskMessage(history);
|
|
92
|
-
|
|
93
|
-
`
|
|
112
|
+
logger.info(
|
|
113
|
+
`ReactiveOverflowCompactionStrategy: Summarizing ${toSummarize.length} messages, keeping ${toKeep.length}`
|
|
94
114
|
);
|
|
95
|
-
const summary = await this.generateSummary(toSummarize, currentTaskMessage);
|
|
115
|
+
const summary = await this.generateSummary(toSummarize, currentTaskMessage, model, logger);
|
|
96
116
|
const summaryMessage = {
|
|
97
117
|
role: "assistant",
|
|
98
118
|
content: [{ type: "text", text: summary }],
|
|
@@ -111,23 +131,18 @@ class ReactiveOverflowStrategy {
|
|
|
111
131
|
* Handle re-compaction when there's already a summary in history.
|
|
112
132
|
* Only summarizes messages AFTER the existing summary, preventing
|
|
113
133
|
* cascading summaries of summaries.
|
|
114
|
-
*
|
|
115
|
-
* @param messagesAfterSummary Messages after the existing summary
|
|
116
|
-
* @param fullHistory The complete history (for current task detection)
|
|
117
|
-
* @param existingSummaryIndex Index of the existing summary in fullHistory
|
|
118
|
-
* @returns Array with single summary message, or empty if nothing to summarize
|
|
119
134
|
*/
|
|
120
|
-
async compactSubset(messagesAfterSummary, fullHistory, existingSummaryIndex) {
|
|
135
|
+
async compactSubset(messagesAfterSummary, fullHistory, existingSummaryIndex, model, logger) {
|
|
121
136
|
const { toSummarize, toKeep } = this.splitHistory(messagesAfterSummary);
|
|
122
137
|
if (toSummarize.length === 0) {
|
|
123
|
-
|
|
138
|
+
logger.debug("ReactiveOverflowCompactionStrategy: No messages to summarize in subset");
|
|
124
139
|
return [];
|
|
125
140
|
}
|
|
126
141
|
const currentTaskMessage = this.findCurrentTaskMessage(fullHistory);
|
|
127
|
-
|
|
128
|
-
`
|
|
142
|
+
logger.info(
|
|
143
|
+
`ReactiveOverflowCompactionStrategy (re-compact): Summarizing ${toSummarize.length} messages after existing summary, keeping ${toKeep.length}`
|
|
129
144
|
);
|
|
130
|
-
const summary = await this.generateSummary(toSummarize, currentTaskMessage);
|
|
145
|
+
const summary = await this.generateSummary(toSummarize, currentTaskMessage, model, logger);
|
|
131
146
|
const absoluteOriginalMessageCount = existingSummaryIndex + 1 + toSummarize.length;
|
|
132
147
|
const summaryMessage = {
|
|
133
148
|
role: "assistant",
|
|
@@ -138,7 +153,6 @@ class ReactiveOverflowStrategy {
|
|
|
138
153
|
summarizedAt: Date.now(),
|
|
139
154
|
originalMessageCount: absoluteOriginalMessageCount,
|
|
140
155
|
isRecompaction: true,
|
|
141
|
-
// Mark that this is a re-compaction
|
|
142
156
|
originalFirstTimestamp: toSummarize[0]?.timestamp,
|
|
143
157
|
originalLastTimestamp: toSummarize[toSummarize.length - 1]?.timestamp
|
|
144
158
|
}
|
|
@@ -147,7 +161,6 @@ class ReactiveOverflowStrategy {
|
|
|
147
161
|
}
|
|
148
162
|
/**
|
|
149
163
|
* Find the most recent user message that represents the current task.
|
|
150
|
-
* This helps preserve context about what the user is currently asking for.
|
|
151
164
|
*/
|
|
152
165
|
findCurrentTaskMessage(history) {
|
|
153
166
|
for (let i = history.length - 1; i >= 0; i--) {
|
|
@@ -169,13 +182,9 @@ class ReactiveOverflowStrategy {
|
|
|
169
182
|
}
|
|
170
183
|
/**
|
|
171
184
|
* Split history into messages to summarize and messages to keep.
|
|
172
|
-
* Keeps the last N turns (user + assistant pairs) intact.
|
|
173
|
-
*
|
|
174
|
-
* For long agentic conversations with many tool calls, this also ensures
|
|
175
|
-
* we don't try to keep too many messages even within preserved turns.
|
|
176
185
|
*/
|
|
177
186
|
splitHistory(history) {
|
|
178
|
-
const turnsToKeep = this.
|
|
187
|
+
const turnsToKeep = this.strategyOptions.preserveLastNTurns;
|
|
179
188
|
const userMessageIndices = [];
|
|
180
189
|
for (let i = history.length - 1; i >= 0; i--) {
|
|
181
190
|
if (history[i]?.role === "user") {
|
|
@@ -203,9 +212,6 @@ class ReactiveOverflowStrategy {
|
|
|
203
212
|
toKeep: history
|
|
204
213
|
};
|
|
205
214
|
}
|
|
206
|
-
this.logger.debug(
|
|
207
|
-
`splitHistory: Using fallback - keeping last ${keepCount} of ${history.length} messages`
|
|
208
|
-
);
|
|
209
215
|
return {
|
|
210
216
|
toSummarize: history.slice(0, -keepCount),
|
|
211
217
|
toKeep: history.slice(-keepCount)
|
|
@@ -213,11 +219,8 @@ class ReactiveOverflowStrategy {
|
|
|
213
219
|
}
|
|
214
220
|
/**
|
|
215
221
|
* Generate an LLM summary of the messages.
|
|
216
|
-
*
|
|
217
|
-
* @param messages Messages to summarize
|
|
218
|
-
* @param currentTask The most recent user message (current task context)
|
|
219
222
|
*/
|
|
220
|
-
async generateSummary(messages, currentTask) {
|
|
223
|
+
async generateSummary(messages, currentTask, model, logger) {
|
|
221
224
|
const formattedConversation = this.formatMessagesForSummary(messages);
|
|
222
225
|
let conversationWithContext = formattedConversation;
|
|
223
226
|
if (currentTask) {
|
|
@@ -226,21 +229,21 @@ class ReactiveOverflowStrategy {
|
|
|
226
229
|
--- CURRENT TASK (most recent user request) ---
|
|
227
230
|
${currentTask}`;
|
|
228
231
|
}
|
|
229
|
-
const prompt = this.
|
|
232
|
+
const prompt = this.strategyOptions.summaryPrompt.replace(
|
|
230
233
|
"{conversation}",
|
|
231
234
|
conversationWithContext
|
|
232
235
|
);
|
|
233
236
|
try {
|
|
234
237
|
const result = await generateText({
|
|
235
|
-
model
|
|
238
|
+
model,
|
|
236
239
|
prompt,
|
|
237
|
-
maxOutputTokens: this.
|
|
240
|
+
maxOutputTokens: this.strategyOptions.maxSummaryTokens
|
|
238
241
|
});
|
|
239
242
|
return `[Session Compaction Summary]
|
|
240
243
|
${result.text}`;
|
|
241
244
|
} catch (error) {
|
|
242
|
-
|
|
243
|
-
`
|
|
245
|
+
logger.error(
|
|
246
|
+
`ReactiveOverflowCompactionStrategy: Failed to generate summary - ${error instanceof Error ? error.message : String(error)}`
|
|
244
247
|
);
|
|
245
248
|
return this.createFallbackSummary(messages, currentTask);
|
|
246
249
|
}
|
|
@@ -316,5 +319,5 @@ ${result.text}`;
|
|
|
316
319
|
}
|
|
317
320
|
}
|
|
318
321
|
export {
|
|
319
|
-
|
|
322
|
+
ReactiveOverflowCompactionStrategy
|
|
320
323
|
};
|
|
@@ -1,14 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LanguageModel } from 'ai';
|
|
2
|
+
import type { Logger } from '../../logger/v2/types.js';
|
|
3
|
+
import type { InternalMessage } from '../types.js';
|
|
4
|
+
import type { ModelLimits } from './overflow.js';
|
|
5
|
+
export interface CompactionSettings {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Optional cap on the model context window used for compaction decisions.
|
|
9
|
+
* When set, compaction will behave as if the model's context window is:
|
|
10
|
+
* `min(modelContextWindow, maxContextTokens)`.
|
|
11
|
+
*/
|
|
12
|
+
maxContextTokens?: number | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Percentage (0.1–1.0) of the effective context window at which compaction triggers.
|
|
15
|
+
* Example: 0.9 triggers at 90% of context usage.
|
|
16
|
+
*/
|
|
17
|
+
thresholdPercent: number;
|
|
18
|
+
}
|
|
19
|
+
export interface CompactionRuntimeContext {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
model: LanguageModel;
|
|
22
|
+
logger: Logger;
|
|
23
|
+
}
|
|
2
24
|
/**
|
|
3
|
-
* Compaction strategy
|
|
25
|
+
* Compaction strategy.
|
|
4
26
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
27
|
+
* This is the DI surface used by core runtime (TurnExecutor/VercelLLMService) to:
|
|
28
|
+
* - decide when to compact (budget + overflow logic)
|
|
29
|
+
* - execute compaction given per-session runtime context (model, logger, sessionId)
|
|
30
|
+
*
|
|
31
|
+
* Strategies are created by host layers (CLI/server/apps) via image factories.
|
|
32
|
+
* Core does not parse YAML, validate Zod schemas, or switch on `type` strings.
|
|
8
33
|
*/
|
|
9
|
-
export
|
|
34
|
+
export type CompactionStrategy = {
|
|
10
35
|
/** Human-readable name for logging/UI */
|
|
11
36
|
readonly name: string;
|
|
37
|
+
/** Effective budgeting settings for this strategy */
|
|
38
|
+
getSettings(): CompactionSettings;
|
|
39
|
+
/** Effective model limits after applying any strategy caps */
|
|
40
|
+
getModelLimits(modelContextWindow: number): ModelLimits;
|
|
41
|
+
/** Whether compaction should run given current input token usage */
|
|
42
|
+
shouldCompact(inputTokens: number, modelLimits: ModelLimits): boolean;
|
|
12
43
|
/**
|
|
13
44
|
* Compacts the provided message history.
|
|
14
45
|
*
|
|
@@ -25,8 +56,9 @@ export interface ICompactionStrategy {
|
|
|
25
56
|
* - `isSessionSummary: true` - Alternative to isSummary for session-level summaries
|
|
26
57
|
*
|
|
27
58
|
* @param history The current conversation history.
|
|
59
|
+
* @param context Per-session runtime context (model/logger/sessionId)
|
|
28
60
|
* @returns Summary messages to add to history. Empty array if nothing to compact.
|
|
29
61
|
*/
|
|
30
|
-
compact(history: readonly InternalMessage[]): Promise<InternalMessage[]
|
|
31
|
-
}
|
|
62
|
+
compact(history: readonly InternalMessage[], context: CompactionRuntimeContext): Promise<InternalMessage[]>;
|
|
63
|
+
};
|
|
32
64
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/context/compaction/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/context/compaction/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,qDAAqD;IACrD,WAAW,IAAI,kBAAkB,CAAC;IAElC,8DAA8D;IAC9D,cAAc,CAAC,kBAAkB,EAAE,MAAM,GAAG,WAAW,CAAC;IAExD,oEAAoE;IACpE,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC;IAEtE;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CACH,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACjC,CAAC"}
|