@dexto/core 1.7.2 → 1.8.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/dist/agent/DextoAgent.cjs +157 -62
- package/dist/agent/DextoAgent.d.ts +71 -17
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +161 -63
- package/dist/agent/agent-options.d.ts +6 -10
- package/dist/agent/agent-options.d.ts.map +1 -1
- package/dist/agent/agentCard.js +1 -1
- package/dist/agent/error-codes.js +1 -1
- package/dist/agent/errors.js +1 -1
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/agent/schemas.d.ts +2 -2
- package/dist/agent/schemas.js +1 -1
- package/dist/agent/state-manager.js +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 +2 -2
- package/dist/approval/errors.cjs +2 -5
- package/dist/approval/errors.d.ts.map +1 -1
- package/dist/approval/errors.js +3 -6
- package/dist/approval/factory.cjs +19 -4
- package/dist/approval/factory.d.ts +4 -1
- package/dist/approval/factory.d.ts.map +1 -1
- package/dist/approval/factory.js +19 -5
- package/dist/approval/index.d.ts +1 -1
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +1 -1
- package/dist/approval/manager.cjs +168 -26
- package/dist/approval/manager.d.ts +46 -12
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +177 -29
- package/dist/approval/schemas.cjs +26 -26
- package/dist/approval/schemas.d.ts +29 -29
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +23 -23
- package/dist/approval/types.cjs +5 -5
- package/dist/approval/types.d.ts +18 -18
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +6 -6
- package/dist/{chunk-PTJYTZNU.js → chunk-C6A6W6XS.js} +1 -44
- package/dist/config/index.cjs +75 -0
- package/dist/config/index.d.ts +15 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +50 -0
- package/dist/context/compaction/overflow.js +1 -1
- package/dist/context/compaction/strategies/noop.js +1 -1
- package/dist/context/compaction/strategies/reactive-overflow-compaction.js +1 -1
- package/dist/context/content-clone.cjs +131 -0
- package/dist/context/content-clone.d.ts +7 -0
- package/dist/context/content-clone.d.ts.map +1 -0
- package/dist/context/content-clone.js +104 -0
- package/dist/context/error-codes.js +1 -1
- package/dist/context/errors.js +1 -1
- package/dist/context/index.cjs +2 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -1
- package/dist/context/manager.cjs +44 -33
- package/dist/context/manager.d.ts +7 -7
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +45 -34
- package/dist/context/media-helpers.js +1 -1
- package/dist/context/schemas.cjs +77 -0
- package/dist/context/schemas.d.ts +5 -0
- package/dist/context/schemas.d.ts.map +1 -0
- package/dist/context/schemas.js +53 -0
- package/dist/context/types.js +1 -1
- package/dist/context/utils.cjs +70 -69
- package/dist/context/utils.d.ts +3 -3
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +71 -70
- 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.js +1 -1
- package/dist/events/index.cjs +9 -1
- package/dist/events/index.d.ts +20 -8
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +10 -2
- package/dist/hooks/builtins/content-policy.js +1 -1
- package/dist/hooks/builtins/response-sanitizer.js +1 -1
- package/dist/hooks/error-codes.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/manager.cjs +1 -1
- package/dist/hooks/manager.d.ts +2 -2
- package/dist/hooks/manager.d.ts.map +1 -1
- package/dist/hooks/manager.js +2 -2
- package/dist/hooks/types.d.ts +2 -2
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/llm/curation-config.js +1 -1
- package/dist/llm/curation.js +1 -1
- package/dist/llm/error-codes.js +1 -1
- package/dist/llm/errors.js +1 -1
- package/dist/llm/executor/index.cjs +32 -0
- package/dist/llm/executor/index.d.ts +2 -0
- package/dist/llm/executor/index.d.ts.map +1 -0
- package/dist/llm/executor/index.js +11 -0
- package/dist/llm/executor/provider-options.js +1 -1
- package/dist/llm/executor/stream-processor.cjs +28 -139
- package/dist/llm/executor/stream-processor.d.ts +2 -13
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +29 -140
- package/dist/{session/history/memory.cjs → llm/executor/tool-definitions.cjs} +21 -33
- package/dist/llm/executor/tool-definitions.d.ts +4 -0
- package/dist/llm/executor/tool-definitions.d.ts.map +1 -0
- package/dist/llm/executor/tool-definitions.js +22 -0
- package/dist/llm/executor/tool-output-truncator.js +1 -1
- package/dist/llm/executor/turn-executor.cjs +1093 -458
- package/dist/llm/executor/turn-executor.d.ts +269 -43
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +1079 -405
- package/dist/llm/executor/types.d.ts +6 -0
- package/dist/llm/executor/types.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +1 -1
- package/dist/llm/index.cjs +2 -0
- package/dist/llm/index.d.ts +1 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +2 -1
- package/dist/llm/providers/codex-app-server.cjs +22 -2
- package/dist/llm/providers/codex-app-server.d.ts.map +1 -1
- package/dist/llm/providers/codex-app-server.js +23 -3
- package/dist/llm/providers/codex-base-url.js +1 -1
- package/dist/llm/providers/local/ai-sdk-adapter.js +1 -1
- package/dist/llm/providers/local/downloader.js +1 -1
- package/dist/llm/providers/local/error-codes.js +1 -1
- package/dist/llm/providers/local/errors.js +1 -1
- package/dist/llm/providers/local/gpu-detector.js +1 -1
- package/dist/llm/providers/local/index.js +1 -1
- package/dist/llm/providers/local/node-llama-provider.js +1 -1
- package/dist/llm/providers/local/ollama-provider.js +1 -1
- package/dist/llm/providers/local/registry.js +1 -1
- package/dist/llm/providers/local/schemas.js +1 -1
- package/dist/llm/providers/openrouter-model-registry.js +1 -1
- package/dist/llm/reasoning/anthropic-betas.js +1 -1
- package/dist/llm/reasoning/anthropic-thinking.js +1 -1
- package/dist/llm/reasoning/openai-reasoning-effort.js +1 -1
- package/dist/llm/reasoning/profile.js +1 -1
- package/dist/llm/reasoning/profiles/anthropic.js +1 -1
- package/dist/llm/reasoning/profiles/bedrock.js +1 -1
- package/dist/llm/reasoning/profiles/google.js +1 -1
- package/dist/llm/reasoning/profiles/openai-compatible.js +1 -1
- package/dist/llm/reasoning/profiles/openai.js +1 -1
- package/dist/llm/reasoning/profiles/openrouter.js +1 -1
- package/dist/llm/reasoning/profiles/shared.js +1 -1
- package/dist/llm/reasoning/profiles/vertex.js +1 -1
- package/dist/llm/registry/auto-update.js +1 -1
- package/dist/llm/registry/index.js +1 -1
- package/dist/llm/registry/models.generated.js +1 -1
- package/dist/llm/registry/models.manual.js +1 -1
- package/dist/llm/registry/sync.js +1 -1
- package/dist/llm/resolver.js +1 -1
- package/dist/llm/schemas.js +1 -1
- package/dist/llm/services/factory.cjs +5 -4
- package/dist/llm/services/factory.d.ts +3 -3
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +6 -5
- package/dist/llm/services/types.d.ts +10 -1
- package/dist/llm/services/types.d.ts.map +1 -1
- package/dist/llm/services/vercel.cjs +23 -8
- package/dist/llm/services/vercel.d.ts +11 -7
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +24 -9
- package/dist/llm/types.js +1 -1
- package/dist/llm/usage-metadata.cjs +20 -3
- package/dist/llm/usage-metadata.d.ts +1 -0
- package/dist/llm/usage-metadata.d.ts.map +1 -1
- package/dist/llm/usage-metadata.js +19 -3
- package/dist/llm/usage-scope.js +1 -1
- package/dist/llm/usage-summary.js +1 -1
- package/dist/llm/validation.js +1 -1
- package/dist/logger/browser.js +1 -1
- package/dist/logger/default-logger-factory.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.js +1 -1
- package/dist/logger/v2/error-codes.js +1 -1
- package/dist/logger/v2/errors.js +1 -1
- package/dist/logger/v2/schemas.js +1 -1
- package/dist/logger/v2/test-utils.js +1 -1
- 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.js +1 -1
- package/dist/logger/v2/transports/silent-transport.js +1 -1
- package/dist/logger/v2/types.js +1 -1
- package/dist/mcp/bundled-config.js +1 -1
- package/dist/mcp/error-codes.js +1 -1
- package/dist/mcp/errors.js +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/manager.js +1 -1
- package/dist/mcp/mcp-client.js +1 -1
- package/dist/mcp/resolver.js +1 -1
- package/dist/mcp/schemas.js +1 -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.cjs +7 -27
- package/dist/memory/manager.d.ts +4 -12
- package/dist/memory/manager.d.ts.map +1 -1
- package/dist/memory/manager.js +8 -28
- package/dist/memory/schemas.js +1 -1
- package/dist/prompts/error-codes.js +1 -1
- package/dist/prompts/errors.js +1 -1
- package/dist/prompts/index.js +1 -1
- package/dist/prompts/name-validation.js +1 -1
- package/dist/prompts/prompt-manager.cjs +9 -38
- package/dist/prompts/prompt-manager.d.ts +2 -10
- package/dist/prompts/prompt-manager.d.ts.map +1 -1
- package/dist/prompts/prompt-manager.js +10 -39
- package/dist/prompts/providers/config-prompt-provider.cjs +8 -87
- package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.js +9 -88
- package/dist/prompts/providers/custom-prompt-provider.cjs +21 -22
- package/dist/prompts/providers/custom-prompt-provider.d.ts +19 -4
- package/dist/prompts/providers/custom-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/custom-prompt-provider.js +22 -23
- package/dist/prompts/providers/mcp-prompt-provider.js +1 -1
- package/dist/prompts/schemas.cjs +2 -24
- package/dist/prompts/schemas.d.ts +0 -52
- package/dist/prompts/schemas.d.ts.map +1 -1
- package/dist/prompts/schemas.js +3 -25
- package/dist/prompts/types.d.ts +5 -32
- package/dist/prompts/types.d.ts.map +1 -1
- package/dist/prompts/utils.js +1 -1
- package/dist/resources/agent-resources-provider.js +1 -1
- package/dist/resources/error-codes.js +1 -1
- package/dist/resources/errors.js +1 -1
- package/dist/resources/handlers/blob-handler.cjs +14 -11
- package/dist/resources/handlers/blob-handler.d.ts +4 -4
- package/dist/resources/handlers/blob-handler.d.ts.map +1 -1
- package/dist/resources/handlers/blob-handler.js +15 -12
- package/dist/resources/handlers/factory.cjs +3 -3
- package/dist/resources/handlers/factory.js +4 -4
- package/dist/resources/handlers/filesystem-handler.js +1 -1
- package/dist/resources/handlers/types.d.ts +2 -2
- package/dist/resources/handlers/types.d.ts.map +1 -1
- package/dist/resources/index.js +1 -1
- package/dist/resources/manager.cjs +10 -7
- package/dist/resources/manager.d.ts +4 -4
- package/dist/resources/manager.d.ts.map +1 -1
- package/dist/resources/manager.js +11 -8
- package/dist/resources/reference-parser.js +1 -1
- package/dist/resources/schemas.cjs +1 -1
- package/dist/resources/schemas.d.ts +2 -2
- package/dist/resources/schemas.js +2 -2
- package/dist/runtime/host-runtime.js +1 -1
- package/dist/runtime/index.cjs +3 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/run-context.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/search/search-service.cjs +6 -13
- package/dist/search/search-service.d.ts +5 -3
- package/dist/search/search-service.d.ts.map +1 -1
- package/dist/search/search-service.js +7 -14
- package/dist/session/chat-session.cjs +264 -108
- package/dist/session/chat-session.d.ts +75 -21
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +268 -108
- package/dist/session/error-codes.js +1 -1
- package/dist/session/errors.js +1 -1
- package/dist/session/index.cjs +19 -2
- package/dist/session/index.d.ts +4 -3
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +19 -3
- package/dist/session/message-queue.cjs +82 -51
- package/dist/session/message-queue.d.ts +13 -8
- package/dist/session/message-queue.d.ts.map +1 -1
- package/dist/session/message-queue.js +83 -52
- package/dist/session/queue-clone.cjs +50 -0
- package/dist/session/queue-clone.d.ts +5 -0
- package/dist/session/queue-clone.d.ts.map +1 -0
- package/dist/session/queue-clone.js +25 -0
- package/dist/session/schemas.cjs +74 -2
- package/dist/session/schemas.d.ts +94 -0
- package/dist/session/schemas.d.ts.map +1 -1
- package/dist/session/schemas.js +69 -2
- package/dist/session/session-manager.cjs +107 -123
- package/dist/session/session-manager.d.ts +7 -6
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +108 -124
- package/dist/session/title-generator.cjs +14 -26
- package/dist/session/title-generator.d.ts +4 -6
- package/dist/session/title-generator.d.ts.map +1 -1
- package/dist/session/title-generator.js +16 -28
- package/dist/session/types.cjs +28 -0
- package/dist/session/types.d.ts +5 -1
- package/dist/session/types.d.ts.map +1 -1
- package/dist/session/types.js +19 -0
- package/dist/{session/history/factory.cjs → skills/index.cjs} +9 -9
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +7 -0
- package/dist/skills/skill-manager.cjs +76 -0
- package/dist/skills/skill-manager.d.ts +13 -0
- package/dist/skills/skill-manager.d.ts.map +1 -0
- package/dist/skills/skill-manager.js +53 -0
- package/dist/skills/types.d.ts +24 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/workspace-skill-source.cjs +120 -0
- package/dist/skills/workspace-skill-source.d.ts +16 -0
- package/dist/skills/workspace-skill-source.d.ts.map +1 -0
- package/dist/skills/workspace-skill-source.js +97 -0
- package/dist/storage/approvals/types.cjs +38 -0
- package/dist/storage/approvals/types.d.ts +54 -0
- package/dist/storage/approvals/types.d.ts.map +1 -0
- package/dist/storage/approvals/types.js +14 -0
- package/dist/storage/artifacts/types.d.ts +73 -0
- package/dist/storage/artifacts/types.d.ts.map +1 -0
- package/dist/storage/conversation/database.cjs +233 -0
- package/dist/storage/conversation/database.d.ts +38 -0
- package/dist/storage/conversation/database.d.ts.map +1 -0
- package/dist/storage/conversation/database.js +210 -0
- package/dist/storage/conversation/types.cjs +16 -0
- package/dist/storage/conversation/types.d.ts +21 -0
- package/dist/storage/conversation/types.d.ts.map +1 -0
- package/dist/storage/conversation/types.js +0 -0
- package/dist/storage/database/types.d.ts +4 -0
- package/dist/storage/database/types.d.ts.map +1 -1
- package/dist/storage/error-codes.js +1 -1
- package/dist/storage/errors.cjs +6 -6
- package/dist/storage/errors.d.ts +2 -2
- package/dist/storage/errors.js +7 -7
- package/dist/storage/index.cjs +42 -5
- package/dist/storage/index.d.ts +19 -8
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +39 -4
- package/dist/storage/memories/types.cjs +16 -0
- package/dist/storage/memories/types.d.ts +17 -0
- package/dist/storage/memories/types.d.ts.map +1 -0
- package/dist/storage/memories/types.js +0 -0
- package/dist/storage/message-queue/types.cjs +16 -0
- package/dist/storage/message-queue/types.d.ts +15 -0
- package/dist/storage/message-queue/types.d.ts.map +1 -0
- package/dist/storage/message-queue/types.js +0 -0
- package/dist/storage/prompts/types.cjs +16 -0
- package/dist/storage/prompts/types.d.ts +14 -0
- package/dist/storage/prompts/types.d.ts.map +1 -0
- package/dist/storage/prompts/types.js +0 -0
- package/dist/storage/runtime-events/types.cjs +16 -0
- package/dist/storage/runtime-events/types.d.ts +19 -0
- package/dist/storage/runtime-events/types.d.ts.map +1 -0
- package/dist/storage/runtime-events/types.js +0 -0
- package/dist/storage/sessions/types.cjs +16 -0
- package/dist/storage/sessions/types.d.ts +19 -0
- package/dist/storage/sessions/types.d.ts.map +1 -0
- package/dist/storage/sessions/types.js +0 -0
- package/dist/storage/stores/backend.cjs +702 -0
- package/dist/storage/stores/backend.d.ts +303 -0
- package/dist/storage/stores/backend.d.ts.map +1 -0
- package/dist/storage/stores/backend.js +677 -0
- package/dist/storage/stores/in-memory.cjs +510 -0
- package/dist/storage/stores/in-memory.d.ts +11 -0
- package/dist/storage/stores/in-memory.d.ts.map +1 -0
- package/dist/storage/stores/in-memory.js +487 -0
- package/dist/storage/stores/types.cjs +16 -0
- package/dist/storage/stores/types.d.ts +36 -0
- package/dist/storage/stores/types.d.ts.map +1 -0
- package/dist/storage/stores/types.js +0 -0
- package/dist/storage/tool-executions/types.cjs +127 -0
- package/dist/storage/tool-executions/types.d.ts +193 -0
- package/dist/storage/tool-executions/types.d.ts.map +1 -0
- package/dist/storage/tool-executions/types.js +96 -0
- package/dist/storage/tool-preferences/types.cjs +16 -0
- package/dist/storage/tool-preferences/types.d.ts +29 -0
- package/dist/storage/tool-preferences/types.d.ts.map +1 -0
- package/dist/storage/tool-preferences/types.js +0 -0
- package/dist/storage/tool-state/types.cjs +16 -0
- package/dist/storage/tool-state/types.d.ts +20 -0
- package/dist/storage/tool-state/types.d.ts.map +1 -0
- package/dist/storage/tool-state/types.js +0 -0
- package/dist/storage/workspaces/types.cjs +16 -0
- package/dist/storage/workspaces/types.d.ts +19 -0
- package/dist/storage/workspaces/types.d.ts.map +1 -0
- package/dist/storage/workspaces/types.js +0 -0
- package/dist/systemPrompt/contributors.cjs +10 -14
- package/dist/systemPrompt/contributors.d.ts +3 -3
- package/dist/systemPrompt/contributors.d.ts.map +1 -1
- package/dist/systemPrompt/contributors.js +11 -15
- 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.js +1 -1
- package/dist/telemetry/decorators.js +1 -1
- package/dist/telemetry/error-codes.js +1 -1
- package/dist/telemetry/errors.js +1 -1
- package/dist/telemetry/exporters.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/schemas.js +1 -1
- package/dist/telemetry/telemetry.js +1 -1
- package/dist/telemetry/utils.js +1 -1
- package/dist/test-utils/in-memory-storage.cjs +9 -17
- package/dist/test-utils/in-memory-storage.js +9 -16
- package/dist/test-utils/session-state-stores.cjs +21 -24
- package/dist/test-utils/session-state-stores.js +22 -24
- package/dist/tools/{confirmation → approval}/allowed-tools-provider/factory.cjs +1 -1
- package/dist/tools/{confirmation → approval}/allowed-tools-provider/factory.d.ts +2 -2
- package/dist/tools/approval/allowed-tools-provider/factory.d.ts.map +1 -0
- package/dist/tools/{confirmation → approval}/allowed-tools-provider/factory.js +2 -2
- package/dist/tools/approval/allowed-tools-provider/in-memory.d.ts.map +1 -0
- package/dist/tools/{confirmation → approval}/allowed-tools-provider/in-memory.js +1 -1
- package/dist/tools/approval/allowed-tools-provider/storage.cjs +66 -0
- package/dist/tools/{confirmation → approval}/allowed-tools-provider/storage.d.ts +4 -10
- package/dist/tools/approval/allowed-tools-provider/storage.d.ts.map +1 -0
- package/dist/tools/approval/allowed-tools-provider/storage.js +43 -0
- package/dist/tools/approval/allowed-tools-provider/types.cjs +16 -0
- package/dist/tools/approval/allowed-tools-provider/types.d.ts.map +1 -0
- package/dist/tools/approval/allowed-tools-provider/types.js +0 -0
- package/dist/tools/approval/session-tool-policy.cjs +269 -0
- package/dist/tools/approval/session-tool-policy.d.ts +43 -0
- package/dist/tools/approval/session-tool-policy.d.ts.map +1 -0
- package/dist/tools/approval/session-tool-policy.js +245 -0
- package/dist/tools/define-tool.js +1 -1
- package/dist/tools/display-types.js +1 -1
- package/dist/tools/error-codes.cjs +3 -3
- package/dist/tools/error-codes.d.ts +4 -4
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +4 -4
- package/dist/tools/errors.cjs +12 -12
- package/dist/tools/errors.d.ts +6 -6
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +13 -13
- package/dist/tools/index.cjs +3 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/pattern-utils.js +1 -1
- package/dist/tools/presentation/tool-presentation.cjs +182 -0
- package/dist/tools/presentation/tool-presentation.d.ts +51 -0
- package/dist/tools/presentation/tool-presentation.d.ts.map +1 -0
- package/dist/tools/presentation/tool-presentation.js +159 -0
- package/dist/tools/presentation.js +1 -1
- package/dist/tools/schemas.cjs +5 -10
- package/dist/tools/schemas.d.ts +1 -4
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +6 -11
- package/dist/tools/session-tool-preferences-store.cjs +12 -28
- package/dist/tools/session-tool-preferences-store.d.ts +4 -7
- package/dist/tools/session-tool-preferences-store.d.ts.map +1 -1
- package/dist/tools/session-tool-preferences-store.js +12 -29
- package/dist/tools/tool-call-metadata.js +1 -1
- package/dist/tools/tool-manager.cjs +871 -834
- package/dist/tools/tool-manager.d.ts +94 -96
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +876 -833
- package/dist/tools/types.d.ts +10 -14
- 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/utils/defer.js +1 -1
- package/dist/utils/env.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/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.js +1 -1
- package/dist/utils/service-initializer.cjs +37 -33
- package/dist/utils/service-initializer.d.ts +9 -5
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +38 -34
- package/dist/utils/zod-schema-converter.js +1 -1
- package/dist/workspace/error-codes.cjs +5 -1
- package/dist/workspace/error-codes.d.ts +4 -0
- package/dist/workspace/error-codes.d.ts.map +1 -1
- package/dist/workspace/error-codes.js +6 -2
- package/dist/workspace/errors.cjs +43 -0
- package/dist/workspace/errors.d.ts +9 -0
- package/dist/workspace/errors.d.ts.map +1 -1
- package/dist/workspace/errors.js +44 -1
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/manager.cjs +21 -29
- package/dist/workspace/manager.d.ts +6 -6
- package/dist/workspace/manager.d.ts.map +1 -1
- package/dist/workspace/manager.js +22 -30
- package/dist/workspace/types.d.ts +47 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/package.json +114 -2
- package/dist/approval/session-approval-store.cjs +0 -91
- package/dist/approval/session-approval-store.d.ts +0 -37
- package/dist/approval/session-approval-store.d.ts.map +0 -1
- package/dist/approval/session-approval-store.js +0 -68
- package/dist/session/history/database.cjs +0 -232
- package/dist/session/history/database.d.ts +0 -41
- package/dist/session/history/database.d.ts.map +0 -1
- package/dist/session/history/database.js +0 -209
- package/dist/session/history/factory.d.ts +0 -11
- package/dist/session/history/factory.d.ts.map +0 -1
- package/dist/session/history/factory.js +0 -8
- package/dist/session/history/memory.d.ts +0 -22
- package/dist/session/history/memory.d.ts.map +0 -1
- package/dist/session/history/memory.js +0 -34
- package/dist/session/history/types.d.ts +0 -26
- package/dist/session/history/types.d.ts.map +0 -1
- package/dist/session/message-queue-store.cjs +0 -75
- package/dist/session/message-queue-store.d.ts +0 -16
- package/dist/session/message-queue-store.d.ts.map +0 -1
- package/dist/session/message-queue-store.js +0 -52
- package/dist/storage/storage-manager.cjs +0 -209
- package/dist/storage/storage-manager.d.ts +0 -77
- package/dist/storage/storage-manager.d.ts.map +0 -1
- package/dist/storage/storage-manager.js +0 -186
- package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts.map +0 -1
- package/dist/tools/confirmation/allowed-tools-provider/in-memory.d.ts.map +0 -1
- package/dist/tools/confirmation/allowed-tools-provider/storage.cjs +0 -69
- package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts.map +0 -1
- package/dist/tools/confirmation/allowed-tools-provider/storage.js +0 -46
- package/dist/tools/confirmation/allowed-tools-provider/types.d.ts.map +0 -1
- /package/dist/{session/history → skills}/types.cjs +0 -0
- /package/dist/{session/history → skills}/types.js +0 -0
- /package/dist/{tools/confirmation/allowed-tools-provider → storage/artifacts}/types.cjs +0 -0
- /package/dist/{tools/confirmation/allowed-tools-provider → storage/artifacts}/types.js +0 -0
- /package/dist/tools/{confirmation → approval}/allowed-tools-provider/in-memory.cjs +0 -0
- /package/dist/tools/{confirmation → approval}/allowed-tools-provider/in-memory.d.ts +0 -0
- /package/dist/tools/{confirmation → approval}/allowed-tools-provider/types.d.ts +0 -0
|
@@ -1,91 +0,0 @@
|
|
|
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 session_approval_store_exports = {};
|
|
20
|
-
__export(session_approval_store_exports, {
|
|
21
|
-
SessionApprovalStore: () => SessionApprovalStore
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(session_approval_store_exports);
|
|
24
|
-
var import_zod = require("zod");
|
|
25
|
-
const ApprovedDirectoryTypeSchema = import_zod.z.enum(["session", "once"]);
|
|
26
|
-
const PersistedApprovedDirectorySchema = import_zod.z.object({
|
|
27
|
-
path: import_zod.z.string(),
|
|
28
|
-
type: ApprovedDirectoryTypeSchema
|
|
29
|
-
}).strict();
|
|
30
|
-
const SessionApprovalStateSchema = import_zod.z.object({
|
|
31
|
-
toolPatterns: import_zod.z.record(import_zod.z.string(), import_zod.z.array(import_zod.z.string())).default({}),
|
|
32
|
-
approvedDirectories: import_zod.z.array(PersistedApprovedDirectorySchema).default([])
|
|
33
|
-
}).strict();
|
|
34
|
-
const DEFAULT_APPROVAL_STATE = {
|
|
35
|
-
toolPatterns: {},
|
|
36
|
-
approvedDirectories: []
|
|
37
|
-
};
|
|
38
|
-
class SessionApprovalStore {
|
|
39
|
-
constructor(storageManager, logger, options = {}) {
|
|
40
|
-
this.storageManager = storageManager;
|
|
41
|
-
this.logger = logger;
|
|
42
|
-
const cacheTtlMs = options.cacheTtlMs ?? 36e5;
|
|
43
|
-
this.cacheTtlSeconds = Math.max(1, Math.floor(cacheTtlMs / 1e3));
|
|
44
|
-
}
|
|
45
|
-
cacheTtlSeconds;
|
|
46
|
-
buildKey(sessionId) {
|
|
47
|
-
return sessionId ? `session-approvals:${sessionId}` : "session-approvals:global";
|
|
48
|
-
}
|
|
49
|
-
async load(sessionId) {
|
|
50
|
-
const key = this.buildKey(sessionId);
|
|
51
|
-
const cached = await this.storageManager.getCache().get(key);
|
|
52
|
-
if (cached !== void 0) {
|
|
53
|
-
return this.parseState(cached, key);
|
|
54
|
-
}
|
|
55
|
-
const stored = await this.storageManager.getDatabase().get(key);
|
|
56
|
-
if (stored === void 0) {
|
|
57
|
-
return structuredClone(DEFAULT_APPROVAL_STATE);
|
|
58
|
-
}
|
|
59
|
-
const parsed = this.parseState(stored, key);
|
|
60
|
-
await this.storageManager.getCache().set(key, parsed, this.cacheTtlSeconds);
|
|
61
|
-
return parsed;
|
|
62
|
-
}
|
|
63
|
-
async save(sessionId, state) {
|
|
64
|
-
const key = this.buildKey(sessionId);
|
|
65
|
-
const normalized = SessionApprovalStateSchema.parse(state);
|
|
66
|
-
await this.storageManager.getDatabase().set(key, normalized);
|
|
67
|
-
await this.storageManager.getCache().set(key, normalized, this.cacheTtlSeconds);
|
|
68
|
-
}
|
|
69
|
-
async delete(sessionId) {
|
|
70
|
-
const key = this.buildKey(sessionId);
|
|
71
|
-
await Promise.all([
|
|
72
|
-
this.storageManager.getDatabase().delete(key),
|
|
73
|
-
this.storageManager.getCache().delete(key)
|
|
74
|
-
]);
|
|
75
|
-
}
|
|
76
|
-
parseState(value, key) {
|
|
77
|
-
const result = SessionApprovalStateSchema.safeParse(value);
|
|
78
|
-
if (result.success) {
|
|
79
|
-
return result.data;
|
|
80
|
-
}
|
|
81
|
-
this.logger.warn("Invalid persisted approval state encountered; using defaults", {
|
|
82
|
-
key,
|
|
83
|
-
error: result.error.message
|
|
84
|
-
});
|
|
85
|
-
return structuredClone(DEFAULT_APPROVAL_STATE);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
-
0 && (module.exports = {
|
|
90
|
-
SessionApprovalStore
|
|
91
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { StorageManager } from '../storage/index.js';
|
|
3
|
-
import type { Logger } from '../logger/v2/types.js';
|
|
4
|
-
declare const PersistedApprovedDirectorySchema: z.ZodObject<{
|
|
5
|
-
path: z.ZodString;
|
|
6
|
-
type: z.ZodEnum<{
|
|
7
|
-
session: "session";
|
|
8
|
-
once: "once";
|
|
9
|
-
}>;
|
|
10
|
-
}, z.core.$strict>;
|
|
11
|
-
declare const SessionApprovalStateSchema: z.ZodObject<{
|
|
12
|
-
toolPatterns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
13
|
-
approvedDirectories: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
14
|
-
path: z.ZodString;
|
|
15
|
-
type: z.ZodEnum<{
|
|
16
|
-
session: "session";
|
|
17
|
-
once: "once";
|
|
18
|
-
}>;
|
|
19
|
-
}, z.core.$strict>>>;
|
|
20
|
-
}, z.core.$strict>;
|
|
21
|
-
export type PersistedApprovedDirectory = z.output<typeof PersistedApprovedDirectorySchema>;
|
|
22
|
-
export type SessionApprovalState = z.output<typeof SessionApprovalStateSchema>;
|
|
23
|
-
export declare class SessionApprovalStore {
|
|
24
|
-
private readonly storageManager;
|
|
25
|
-
private readonly logger;
|
|
26
|
-
private readonly cacheTtlSeconds;
|
|
27
|
-
constructor(storageManager: StorageManager, logger: Logger, options?: {
|
|
28
|
-
cacheTtlMs?: number;
|
|
29
|
-
});
|
|
30
|
-
private buildKey;
|
|
31
|
-
load(sessionId?: string): Promise<SessionApprovalState>;
|
|
32
|
-
save(sessionId: string | undefined, state: SessionApprovalState): Promise<void>;
|
|
33
|
-
delete(sessionId?: string): Promise<void>;
|
|
34
|
-
private parseState;
|
|
35
|
-
}
|
|
36
|
-
export {};
|
|
37
|
-
//# sourceMappingURL=session-approval-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-approval-store.d.ts","sourceRoot":"","sources":["../../src/approval/session-approval-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,QAAA,MAAM,gCAAgC;;;;;;kBAKzB,CAAC;AAEd,QAAA,MAAM,0BAA0B;;;;;;;;;kBAKnB,CAAC;AAEd,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAC3F,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAO/E,qBAAa,oBAAoB;IAIzB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJ3B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAGpB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,EAC/B,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO;IAMzC,OAAO,CAAC,QAAQ;IAIV,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiBvD,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/E,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/C,OAAO,CAAC,UAAU;CAYrB"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import "../chunk-PTJYTZNU.js";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
const ApprovedDirectoryTypeSchema = z.enum(["session", "once"]);
|
|
4
|
-
const PersistedApprovedDirectorySchema = z.object({
|
|
5
|
-
path: z.string(),
|
|
6
|
-
type: ApprovedDirectoryTypeSchema
|
|
7
|
-
}).strict();
|
|
8
|
-
const SessionApprovalStateSchema = z.object({
|
|
9
|
-
toolPatterns: z.record(z.string(), z.array(z.string())).default({}),
|
|
10
|
-
approvedDirectories: z.array(PersistedApprovedDirectorySchema).default([])
|
|
11
|
-
}).strict();
|
|
12
|
-
const DEFAULT_APPROVAL_STATE = {
|
|
13
|
-
toolPatterns: {},
|
|
14
|
-
approvedDirectories: []
|
|
15
|
-
};
|
|
16
|
-
class SessionApprovalStore {
|
|
17
|
-
constructor(storageManager, logger, options = {}) {
|
|
18
|
-
this.storageManager = storageManager;
|
|
19
|
-
this.logger = logger;
|
|
20
|
-
const cacheTtlMs = options.cacheTtlMs ?? 36e5;
|
|
21
|
-
this.cacheTtlSeconds = Math.max(1, Math.floor(cacheTtlMs / 1e3));
|
|
22
|
-
}
|
|
23
|
-
cacheTtlSeconds;
|
|
24
|
-
buildKey(sessionId) {
|
|
25
|
-
return sessionId ? `session-approvals:${sessionId}` : "session-approvals:global";
|
|
26
|
-
}
|
|
27
|
-
async load(sessionId) {
|
|
28
|
-
const key = this.buildKey(sessionId);
|
|
29
|
-
const cached = await this.storageManager.getCache().get(key);
|
|
30
|
-
if (cached !== void 0) {
|
|
31
|
-
return this.parseState(cached, key);
|
|
32
|
-
}
|
|
33
|
-
const stored = await this.storageManager.getDatabase().get(key);
|
|
34
|
-
if (stored === void 0) {
|
|
35
|
-
return structuredClone(DEFAULT_APPROVAL_STATE);
|
|
36
|
-
}
|
|
37
|
-
const parsed = this.parseState(stored, key);
|
|
38
|
-
await this.storageManager.getCache().set(key, parsed, this.cacheTtlSeconds);
|
|
39
|
-
return parsed;
|
|
40
|
-
}
|
|
41
|
-
async save(sessionId, state) {
|
|
42
|
-
const key = this.buildKey(sessionId);
|
|
43
|
-
const normalized = SessionApprovalStateSchema.parse(state);
|
|
44
|
-
await this.storageManager.getDatabase().set(key, normalized);
|
|
45
|
-
await this.storageManager.getCache().set(key, normalized, this.cacheTtlSeconds);
|
|
46
|
-
}
|
|
47
|
-
async delete(sessionId) {
|
|
48
|
-
const key = this.buildKey(sessionId);
|
|
49
|
-
await Promise.all([
|
|
50
|
-
this.storageManager.getDatabase().delete(key),
|
|
51
|
-
this.storageManager.getCache().delete(key)
|
|
52
|
-
]);
|
|
53
|
-
}
|
|
54
|
-
parseState(value, key) {
|
|
55
|
-
const result = SessionApprovalStateSchema.safeParse(value);
|
|
56
|
-
if (result.success) {
|
|
57
|
-
return result.data;
|
|
58
|
-
}
|
|
59
|
-
this.logger.warn("Invalid persisted approval state encountered; using defaults", {
|
|
60
|
-
key,
|
|
61
|
-
error: result.error.message
|
|
62
|
-
});
|
|
63
|
-
return structuredClone(DEFAULT_APPROVAL_STATE);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
SessionApprovalStore
|
|
68
|
-
};
|
|
@@ -1,232 +0,0 @@
|
|
|
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 database_exports = {};
|
|
20
|
-
__export(database_exports, {
|
|
21
|
-
DatabaseHistoryProvider: () => DatabaseHistoryProvider
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(database_exports);
|
|
24
|
-
var import_types = require("../../logger/v2/types.js");
|
|
25
|
-
var import_errors = require("../errors.js");
|
|
26
|
-
class DatabaseHistoryProvider {
|
|
27
|
-
// Debounce window for batching updates
|
|
28
|
-
constructor(sessionId, database, logger) {
|
|
29
|
-
this.sessionId = sessionId;
|
|
30
|
-
this.database = database;
|
|
31
|
-
this.logger = logger.createChild(import_types.DextoLogComponent.SESSION);
|
|
32
|
-
}
|
|
33
|
-
logger;
|
|
34
|
-
// Cache state
|
|
35
|
-
cache = null;
|
|
36
|
-
pendingUpdates = /* @__PURE__ */ new Map();
|
|
37
|
-
flushTimer = null;
|
|
38
|
-
flushPromise = null;
|
|
39
|
-
// Flush configuration
|
|
40
|
-
static FLUSH_DELAY_MS = 100;
|
|
41
|
-
async getHistory() {
|
|
42
|
-
if (this.cache === null) {
|
|
43
|
-
const key = this.getMessagesKey();
|
|
44
|
-
try {
|
|
45
|
-
const limit = 1e4;
|
|
46
|
-
const rawMessages = await this.database.getRange(key, 0, limit);
|
|
47
|
-
if (rawMessages.length === limit) {
|
|
48
|
-
this.logger.warn(
|
|
49
|
-
`DatabaseHistoryProvider: Session ${this.sessionId} hit message limit (${limit}), history may be truncated`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
const seenIndexes = /* @__PURE__ */ new Map();
|
|
53
|
-
this.cache = [];
|
|
54
|
-
let duplicateCount = 0;
|
|
55
|
-
for (const msg of rawMessages) {
|
|
56
|
-
const seenIndex = msg.id ? seenIndexes.get(msg.id) : void 0;
|
|
57
|
-
if (seenIndex !== void 0) {
|
|
58
|
-
duplicateCount++;
|
|
59
|
-
this.cache[seenIndex] = msg;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (msg.id) {
|
|
63
|
-
seenIndexes.set(msg.id, this.cache.length);
|
|
64
|
-
}
|
|
65
|
-
this.cache.push(msg);
|
|
66
|
-
}
|
|
67
|
-
if (duplicateCount > 0) {
|
|
68
|
-
this.logger.warn(
|
|
69
|
-
`DatabaseHistoryProvider: Found ${duplicateCount} duplicate message updates for session ${this.sessionId}, deduped to ${this.cache.length}`
|
|
70
|
-
);
|
|
71
|
-
} else {
|
|
72
|
-
this.logger.debug(
|
|
73
|
-
`DatabaseHistoryProvider: Loaded ${this.cache.length} messages for session ${this.sessionId}`
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
} catch (error) {
|
|
77
|
-
this.logger.error(
|
|
78
|
-
`DatabaseHistoryProvider: Error loading messages for session ${this.sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
79
|
-
);
|
|
80
|
-
throw import_errors.SessionError.storageFailed(
|
|
81
|
-
this.sessionId,
|
|
82
|
-
"load history",
|
|
83
|
-
error instanceof Error ? error.message : String(error)
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return [...this.cache];
|
|
88
|
-
}
|
|
89
|
-
async saveMessage(message) {
|
|
90
|
-
const key = this.getMessagesKey();
|
|
91
|
-
if (this.cache === null) {
|
|
92
|
-
await this.getHistory();
|
|
93
|
-
}
|
|
94
|
-
if (message.id && this.cache.some((m) => m.id === message.id)) {
|
|
95
|
-
this.logger.debug(
|
|
96
|
-
`DatabaseHistoryProvider: Message ${message.id} already exists, skipping`
|
|
97
|
-
);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
this.cache.push(message);
|
|
101
|
-
try {
|
|
102
|
-
await this.database.append(key, message);
|
|
103
|
-
this.logger.debug(
|
|
104
|
-
`DatabaseHistoryProvider: Saved message ${message.id} (${message.role}) for session ${this.sessionId}`
|
|
105
|
-
);
|
|
106
|
-
} catch (error) {
|
|
107
|
-
this.cache.pop();
|
|
108
|
-
this.logger.error(
|
|
109
|
-
`DatabaseHistoryProvider: Error saving message for session ${this.sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
110
|
-
);
|
|
111
|
-
throw import_errors.SessionError.storageFailed(
|
|
112
|
-
this.sessionId,
|
|
113
|
-
"save message",
|
|
114
|
-
error instanceof Error ? error.message : String(error)
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
async updateMessage(message) {
|
|
119
|
-
if (!message.id) {
|
|
120
|
-
this.logger.warn(
|
|
121
|
-
`DatabaseHistoryProvider: Ignoring update for message without id in session ${this.sessionId}`
|
|
122
|
-
);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (this.cache === null) {
|
|
126
|
-
await this.getHistory();
|
|
127
|
-
}
|
|
128
|
-
const cache = this.cache;
|
|
129
|
-
if (cache === null) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const index = cache.findIndex((m) => m.id === message.id);
|
|
133
|
-
if (index !== -1) {
|
|
134
|
-
cache[index] = message;
|
|
135
|
-
this.pendingUpdates.set(message.id, message);
|
|
136
|
-
this.scheduleFlush();
|
|
137
|
-
this.logger.debug(
|
|
138
|
-
`DatabaseHistoryProvider: Updated message ${message.id} in cache for session ${this.sessionId}`
|
|
139
|
-
);
|
|
140
|
-
} else {
|
|
141
|
-
this.logger.warn(
|
|
142
|
-
`DatabaseHistoryProvider: Message ${message.id} not found for update in session ${this.sessionId}`
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
async clearHistory() {
|
|
147
|
-
this.cancelPendingFlush();
|
|
148
|
-
this.cache = [];
|
|
149
|
-
this.pendingUpdates.clear();
|
|
150
|
-
const key = this.getMessagesKey();
|
|
151
|
-
try {
|
|
152
|
-
await this.database.delete(key);
|
|
153
|
-
this.logger.debug(
|
|
154
|
-
`DatabaseHistoryProvider: Cleared history for session ${this.sessionId}`
|
|
155
|
-
);
|
|
156
|
-
} catch (error) {
|
|
157
|
-
this.logger.error(
|
|
158
|
-
`DatabaseHistoryProvider: Error clearing session ${this.sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
159
|
-
);
|
|
160
|
-
throw import_errors.SessionError.resetFailed(
|
|
161
|
-
this.sessionId,
|
|
162
|
-
error instanceof Error ? error.message : String(error)
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
async flush() {
|
|
167
|
-
if (this.flushPromise) {
|
|
168
|
-
await this.flushPromise;
|
|
169
|
-
}
|
|
170
|
-
this.cancelPendingFlush();
|
|
171
|
-
while (this.pendingUpdates.size > 0) {
|
|
172
|
-
this.flushPromise = this.flushPendingUpdates();
|
|
173
|
-
try {
|
|
174
|
-
await this.flushPromise;
|
|
175
|
-
} finally {
|
|
176
|
-
this.flushPromise = null;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
async flushPendingUpdates() {
|
|
181
|
-
const key = this.getMessagesKey();
|
|
182
|
-
const updates = [...this.pendingUpdates.values()];
|
|
183
|
-
this.pendingUpdates.clear();
|
|
184
|
-
this.logger.debug(
|
|
185
|
-
`DatabaseHistoryProvider: FLUSH UPDATES key=${key} count=${updates.length} ids=[${updates.map((m) => m.id).join(",")}]`
|
|
186
|
-
);
|
|
187
|
-
let failedIndex = updates.length;
|
|
188
|
-
try {
|
|
189
|
-
for (const [index, message] of updates.entries()) {
|
|
190
|
-
failedIndex = index;
|
|
191
|
-
await this.database.append(key, message);
|
|
192
|
-
}
|
|
193
|
-
} catch (error) {
|
|
194
|
-
for (const message of updates.slice(failedIndex)) {
|
|
195
|
-
if (message.id && !this.pendingUpdates.has(message.id)) {
|
|
196
|
-
this.pendingUpdates.set(message.id, message);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
this.logger.error(
|
|
200
|
-
`DatabaseHistoryProvider: Error flushing message updates for session ${this.sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
201
|
-
);
|
|
202
|
-
throw import_errors.SessionError.storageFailed(
|
|
203
|
-
this.sessionId,
|
|
204
|
-
"flush message updates",
|
|
205
|
-
error instanceof Error ? error.message : String(error)
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
scheduleFlush() {
|
|
210
|
-
if (this.flushTimer) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
this.flushTimer = setTimeout(() => {
|
|
214
|
-
this.flushTimer = null;
|
|
215
|
-
this.flush().catch(() => {
|
|
216
|
-
});
|
|
217
|
-
}, DatabaseHistoryProvider.FLUSH_DELAY_MS);
|
|
218
|
-
}
|
|
219
|
-
cancelPendingFlush() {
|
|
220
|
-
if (this.flushTimer) {
|
|
221
|
-
clearTimeout(this.flushTimer);
|
|
222
|
-
this.flushTimer = null;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
getMessagesKey() {
|
|
226
|
-
return `messages:${this.sessionId}`;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
230
|
-
0 && (module.exports = {
|
|
231
|
-
DatabaseHistoryProvider
|
|
232
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '../../logger/v2/types.js';
|
|
2
|
-
import type { Database } from '../../storage/types.js';
|
|
3
|
-
import type { InternalMessage } from '../../context/types.js';
|
|
4
|
-
import type { ConversationHistoryProvider } from './types.js';
|
|
5
|
-
/**
|
|
6
|
-
* History provider that works directly with DatabaseBackend.
|
|
7
|
-
* Uses write-through caching for read performance while maintaining durability.
|
|
8
|
-
*
|
|
9
|
-
* Caching strategy:
|
|
10
|
-
* - getHistory(): Returns cached messages after first load (eliminates repeated DB reads)
|
|
11
|
-
* - saveMessage(): Updates cache AND writes to DB immediately (new messages are critical)
|
|
12
|
-
* - updateMessage(): Updates cache immediately, debounces DB writes (batches rapid updates)
|
|
13
|
-
* - flush(): Appends the latest pending updates to DB (called at turn boundaries)
|
|
14
|
-
* - clearHistory(): Clears cache and DB immediately
|
|
15
|
-
*
|
|
16
|
-
* Durability guarantees:
|
|
17
|
-
* - New messages (saveMessage) are always immediately durable
|
|
18
|
-
* - Updates (updateMessage) are durable within flush interval or on explicit flush()
|
|
19
|
-
* - Worst case on crash: lose updates from last flush interval (typically <100ms)
|
|
20
|
-
*/
|
|
21
|
-
export declare class DatabaseHistoryProvider implements ConversationHistoryProvider {
|
|
22
|
-
private sessionId;
|
|
23
|
-
private database;
|
|
24
|
-
private logger;
|
|
25
|
-
private cache;
|
|
26
|
-
private pendingUpdates;
|
|
27
|
-
private flushTimer;
|
|
28
|
-
private flushPromise;
|
|
29
|
-
private static readonly FLUSH_DELAY_MS;
|
|
30
|
-
constructor(sessionId: string, database: Database, logger: Logger);
|
|
31
|
-
getHistory(): Promise<InternalMessage[]>;
|
|
32
|
-
saveMessage(message: InternalMessage): Promise<void>;
|
|
33
|
-
updateMessage(message: InternalMessage): Promise<void>;
|
|
34
|
-
clearHistory(): Promise<void>;
|
|
35
|
-
flush(): Promise<void>;
|
|
36
|
-
private flushPendingUpdates;
|
|
37
|
-
private scheduleFlush;
|
|
38
|
-
private cancelPendingFlush;
|
|
39
|
-
private getMessagesKey;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=database.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/session/history/database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,uBAAwB,YAAW,2BAA2B;IAanE,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,QAAQ;IAbpB,OAAO,CAAC,MAAM,CAAS;IAGvB,OAAO,CAAC,KAAK,CAAkC;IAC/C,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,YAAY,CAA8B;IAGlD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAO;gBAGjC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAC1B,MAAM,EAAE,MAAM;IAKZ,UAAU,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAyDxC,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAwCpD,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCtD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBd,mBAAmB;IAgCjC,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,cAAc;CAGzB"}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import "../../chunk-PTJYTZNU.js";
|
|
2
|
-
import { DextoLogComponent } from "../../logger/v2/types.js";
|
|
3
|
-
import { SessionError } from "../errors.js";
|
|
4
|
-
class DatabaseHistoryProvider {
|
|
5
|
-
// Debounce window for batching updates
|
|
6
|
-
constructor(sessionId, database, logger) {
|
|
7
|
-
this.sessionId = sessionId;
|
|
8
|
-
this.database = database;
|
|
9
|
-
this.logger = logger.createChild(DextoLogComponent.SESSION);
|
|
10
|
-
}
|
|
11
|
-
logger;
|
|
12
|
-
// Cache state
|
|
13
|
-
cache = null;
|
|
14
|
-
pendingUpdates = /* @__PURE__ */ new Map();
|
|
15
|
-
flushTimer = null;
|
|
16
|
-
flushPromise = null;
|
|
17
|
-
// Flush configuration
|
|
18
|
-
static FLUSH_DELAY_MS = 100;
|
|
19
|
-
async getHistory() {
|
|
20
|
-
if (this.cache === null) {
|
|
21
|
-
const key = this.getMessagesKey();
|
|
22
|
-
try {
|
|
23
|
-
const limit = 1e4;
|
|
24
|
-
const rawMessages = await this.database.getRange(key, 0, limit);
|
|
25
|
-
if (rawMessages.length === limit) {
|
|
26
|
-
this.logger.warn(
|
|
27
|
-
`DatabaseHistoryProvider: Session ${this.sessionId} hit message limit (${limit}), history may be truncated`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
const seenIndexes = /* @__PURE__ */ new Map();
|
|
31
|
-
this.cache = [];
|
|
32
|
-
let duplicateCount = 0;
|
|
33
|
-
for (const msg of rawMessages) {
|
|
34
|
-
const seenIndex = msg.id ? seenIndexes.get(msg.id) : void 0;
|
|
35
|
-
if (seenIndex !== void 0) {
|
|
36
|
-
duplicateCount++;
|
|
37
|
-
this.cache[seenIndex] = msg;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (msg.id) {
|
|
41
|
-
seenIndexes.set(msg.id, this.cache.length);
|
|
42
|
-
}
|
|
43
|
-
this.cache.push(msg);
|
|
44
|
-
}
|
|
45
|
-
if (duplicateCount > 0) {
|
|
46
|
-
this.logger.warn(
|
|
47
|
-
`DatabaseHistoryProvider: Found ${duplicateCount} duplicate message updates for session ${this.sessionId}, deduped to ${this.cache.length}`
|
|
48
|
-
);
|
|
49
|
-
} else {
|
|
50
|
-
this.logger.debug(
|
|
51
|
-
`DatabaseHistoryProvider: Loaded ${this.cache.length} messages for session ${this.sessionId}`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
} catch (error) {
|
|
55
|
-
this.logger.error(
|
|
56
|
-
`DatabaseHistoryProvider: Error loading messages for session ${this.sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
57
|
-
);
|
|
58
|
-
throw SessionError.storageFailed(
|
|
59
|
-
this.sessionId,
|
|
60
|
-
"load history",
|
|
61
|
-
error instanceof Error ? error.message : String(error)
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return [...this.cache];
|
|
66
|
-
}
|
|
67
|
-
async saveMessage(message) {
|
|
68
|
-
const key = this.getMessagesKey();
|
|
69
|
-
if (this.cache === null) {
|
|
70
|
-
await this.getHistory();
|
|
71
|
-
}
|
|
72
|
-
if (message.id && this.cache.some((m) => m.id === message.id)) {
|
|
73
|
-
this.logger.debug(
|
|
74
|
-
`DatabaseHistoryProvider: Message ${message.id} already exists, skipping`
|
|
75
|
-
);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.cache.push(message);
|
|
79
|
-
try {
|
|
80
|
-
await this.database.append(key, message);
|
|
81
|
-
this.logger.debug(
|
|
82
|
-
`DatabaseHistoryProvider: Saved message ${message.id} (${message.role}) for session ${this.sessionId}`
|
|
83
|
-
);
|
|
84
|
-
} catch (error) {
|
|
85
|
-
this.cache.pop();
|
|
86
|
-
this.logger.error(
|
|
87
|
-
`DatabaseHistoryProvider: Error saving message for session ${this.sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
88
|
-
);
|
|
89
|
-
throw SessionError.storageFailed(
|
|
90
|
-
this.sessionId,
|
|
91
|
-
"save message",
|
|
92
|
-
error instanceof Error ? error.message : String(error)
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
async updateMessage(message) {
|
|
97
|
-
if (!message.id) {
|
|
98
|
-
this.logger.warn(
|
|
99
|
-
`DatabaseHistoryProvider: Ignoring update for message without id in session ${this.sessionId}`
|
|
100
|
-
);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (this.cache === null) {
|
|
104
|
-
await this.getHistory();
|
|
105
|
-
}
|
|
106
|
-
const cache = this.cache;
|
|
107
|
-
if (cache === null) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const index = cache.findIndex((m) => m.id === message.id);
|
|
111
|
-
if (index !== -1) {
|
|
112
|
-
cache[index] = message;
|
|
113
|
-
this.pendingUpdates.set(message.id, message);
|
|
114
|
-
this.scheduleFlush();
|
|
115
|
-
this.logger.debug(
|
|
116
|
-
`DatabaseHistoryProvider: Updated message ${message.id} in cache for session ${this.sessionId}`
|
|
117
|
-
);
|
|
118
|
-
} else {
|
|
119
|
-
this.logger.warn(
|
|
120
|
-
`DatabaseHistoryProvider: Message ${message.id} not found for update in session ${this.sessionId}`
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
async clearHistory() {
|
|
125
|
-
this.cancelPendingFlush();
|
|
126
|
-
this.cache = [];
|
|
127
|
-
this.pendingUpdates.clear();
|
|
128
|
-
const key = this.getMessagesKey();
|
|
129
|
-
try {
|
|
130
|
-
await this.database.delete(key);
|
|
131
|
-
this.logger.debug(
|
|
132
|
-
`DatabaseHistoryProvider: Cleared history for session ${this.sessionId}`
|
|
133
|
-
);
|
|
134
|
-
} catch (error) {
|
|
135
|
-
this.logger.error(
|
|
136
|
-
`DatabaseHistoryProvider: Error clearing session ${this.sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
137
|
-
);
|
|
138
|
-
throw SessionError.resetFailed(
|
|
139
|
-
this.sessionId,
|
|
140
|
-
error instanceof Error ? error.message : String(error)
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async flush() {
|
|
145
|
-
if (this.flushPromise) {
|
|
146
|
-
await this.flushPromise;
|
|
147
|
-
}
|
|
148
|
-
this.cancelPendingFlush();
|
|
149
|
-
while (this.pendingUpdates.size > 0) {
|
|
150
|
-
this.flushPromise = this.flushPendingUpdates();
|
|
151
|
-
try {
|
|
152
|
-
await this.flushPromise;
|
|
153
|
-
} finally {
|
|
154
|
-
this.flushPromise = null;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
async flushPendingUpdates() {
|
|
159
|
-
const key = this.getMessagesKey();
|
|
160
|
-
const updates = [...this.pendingUpdates.values()];
|
|
161
|
-
this.pendingUpdates.clear();
|
|
162
|
-
this.logger.debug(
|
|
163
|
-
`DatabaseHistoryProvider: FLUSH UPDATES key=${key} count=${updates.length} ids=[${updates.map((m) => m.id).join(",")}]`
|
|
164
|
-
);
|
|
165
|
-
let failedIndex = updates.length;
|
|
166
|
-
try {
|
|
167
|
-
for (const [index, message] of updates.entries()) {
|
|
168
|
-
failedIndex = index;
|
|
169
|
-
await this.database.append(key, message);
|
|
170
|
-
}
|
|
171
|
-
} catch (error) {
|
|
172
|
-
for (const message of updates.slice(failedIndex)) {
|
|
173
|
-
if (message.id && !this.pendingUpdates.has(message.id)) {
|
|
174
|
-
this.pendingUpdates.set(message.id, message);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
this.logger.error(
|
|
178
|
-
`DatabaseHistoryProvider: Error flushing message updates for session ${this.sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
179
|
-
);
|
|
180
|
-
throw SessionError.storageFailed(
|
|
181
|
-
this.sessionId,
|
|
182
|
-
"flush message updates",
|
|
183
|
-
error instanceof Error ? error.message : String(error)
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
scheduleFlush() {
|
|
188
|
-
if (this.flushTimer) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
this.flushTimer = setTimeout(() => {
|
|
192
|
-
this.flushTimer = null;
|
|
193
|
-
this.flush().catch(() => {
|
|
194
|
-
});
|
|
195
|
-
}, DatabaseHistoryProvider.FLUSH_DELAY_MS);
|
|
196
|
-
}
|
|
197
|
-
cancelPendingFlush() {
|
|
198
|
-
if (this.flushTimer) {
|
|
199
|
-
clearTimeout(this.flushTimer);
|
|
200
|
-
this.flushTimer = null;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
getMessagesKey() {
|
|
204
|
-
return `messages:${this.sessionId}`;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
export {
|
|
208
|
-
DatabaseHistoryProvider
|
|
209
|
-
};
|