@superblocksteam/vite-plugin-file-sync 2.0.42-next.5 → 2.0.42-next.51
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/ai-service/agent/prompts/build-base-system-prompt.d.ts +2 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js +31 -2
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
- package/dist/ai-service/agent/subagents/apis/example-selector.d.ts +24 -0
- package/dist/ai-service/agent/subagents/apis/example-selector.d.ts.map +1 -0
- package/dist/ai-service/agent/subagents/apis/example-selector.js +104 -0
- package/dist/ai-service/agent/subagents/apis/example-selector.js.map +1 -0
- package/dist/ai-service/agent/subagents/apis/examples.d.ts +55 -0
- package/dist/ai-service/agent/subagents/apis/examples.d.ts.map +1 -0
- package/dist/ai-service/agent/subagents/apis/examples.js +1229 -0
- package/dist/ai-service/agent/subagents/apis/examples.js.map +1 -0
- package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts +83 -0
- package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts.map +1 -0
- package/dist/ai-service/agent/{apis.js → subagents/apis/generate-api-source.js} +131 -99
- package/dist/ai-service/agent/subagents/apis/generate-api-source.js.map +1 -0
- package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts +39 -0
- package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts.map +1 -0
- package/dist/ai-service/agent/subagents/apis/prompt-builder.js +115 -0
- package/dist/ai-service/agent/subagents/apis/prompt-builder.js.map +1 -0
- package/dist/ai-service/agent/{apis-static-analysis.d.ts → subagents/apis/static-analysis.d.ts} +1 -1
- package/dist/ai-service/agent/subagents/apis/static-analysis.d.ts.map +1 -0
- package/dist/ai-service/agent/{apis-static-analysis.js → subagents/apis/static-analysis.js} +3 -2
- package/dist/ai-service/agent/subagents/apis/static-analysis.js.map +1 -0
- package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts +3 -0
- package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts.map +1 -0
- package/dist/ai-service/agent/{apis-system-prompt.js → subagents/apis/system-prompt.js} +67 -31
- package/dist/ai-service/agent/{apis-system-prompt.js.map → subagents/apis/system-prompt.js.map} +1 -1
- package/dist/ai-service/agent/tool-message-utils.d.ts +6 -15
- package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
- package/dist/ai-service/agent/tool-message-utils.js +75 -248
- package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
- package/dist/ai-service/agent/tools/build-add-event.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-add-event.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-add-event.js +9 -8
- package/dist/ai-service/agent/tools/build-add-event.js.map +1 -1
- package/dist/ai-service/agent/tools/build-add-state-var.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-add-state-var.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-add-state-var.js +6 -5
- package/dist/ai-service/agent/tools/build-add-state-var.js.map +1 -1
- package/dist/ai-service/agent/tools/build-add-timer.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-add-timer.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-add-timer.js +7 -6
- package/dist/ai-service/agent/tools/build-add-timer.js.map +1 -1
- package/dist/ai-service/agent/tools/build-create-page.d.ts +2 -3
- package/dist/ai-service/agent/tools/build-create-page.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-create-page.js +11 -10
- package/dist/ai-service/agent/tools/build-create-page.js.map +1 -1
- package/dist/ai-service/agent/tools/build-debug.d.ts +1 -3
- package/dist/ai-service/agent/tools/build-debug.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-debug.js +7 -5
- package/dist/ai-service/agent/tools/build-debug.js.map +1 -1
- package/dist/ai-service/agent/tools/build-edit-file.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-edit-file.js +10 -7
- package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-finalize.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-finalize.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-finalize.js +7 -6
- package/dist/ai-service/agent/tools/build-finalize.js.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.js +7 -6
- package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
- package/dist/ai-service/agent/tools/build-list-available-components.d.ts +3 -8
- package/dist/ai-service/agent/tools/build-list-available-components.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-list-available-components.js +30 -9
- package/dist/ai-service/agent/tools/build-list-available-components.js.map +1 -1
- package/dist/ai-service/agent/tools/build-list-files.d.ts +2 -3
- package/dist/ai-service/agent/tools/build-list-files.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-list-files.js +10 -8
- package/dist/ai-service/agent/tools/build-list-files.js.map +1 -1
- package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +3 -3
- package/dist/ai-service/agent/tools/build-manage-checklist.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-manage-checklist.js +9 -8
- package/dist/ai-service/agent/tools/build-manage-checklist.js.map +1 -1
- package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-multi-edit-file.js +9 -6
- package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-read-files.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-read-files.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-read-files.js +10 -8
- package/dist/ai-service/agent/tools/build-read-files.js.map +1 -1
- package/dist/ai-service/agent/tools/build-register-component-name.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-register-component-name.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-register-component-name.js +9 -8
- package/dist/ai-service/agent/tools/build-register-component-name.js.map +1 -1
- package/dist/ai-service/agent/tools/build-rename-page.d.ts +2 -3
- package/dist/ai-service/agent/tools/build-rename-page.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-rename-page.js +6 -5
- package/dist/ai-service/agent/tools/build-rename-page.js.map +1 -1
- package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-set-api-triggers.js +6 -5
- package/dist/ai-service/agent/tools/build-set-api-triggers.js.map +1 -1
- package/dist/ai-service/agent/tools/build-update-state-var.d.ts +2 -3
- package/dist/ai-service/agent/tools/build-update-state-var.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-update-state-var.js +6 -5
- package/dist/ai-service/agent/tools/build-update-state-var.js.map +1 -1
- package/dist/ai-service/agent/tools/build-validate-icons.d.ts +2 -3
- package/dist/ai-service/agent/tools/build-validate-icons.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-validate-icons.js +8 -6
- package/dist/ai-service/agent/tools/build-validate-icons.js.map +1 -1
- package/dist/ai-service/agent/tools/build-write-file.d.ts +2 -4
- package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-write-file.js +6 -5
- package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
- package/dist/ai-service/agent/tools/debug-cache.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/debug-cache.js +3 -0
- package/dist/ai-service/agent/tools/debug-cache.js.map +1 -1
- package/dist/ai-service/agent/tools/index.d.ts +23 -20
- package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/index.js +23 -20
- package/dist/ai-service/agent/tools/index.js.map +1 -1
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +25 -0
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/integrations/execute-request.js +213 -0
- package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -0
- package/dist/ai-service/agent/tools/integrations/index.d.ts +4 -0
- package/dist/ai-service/agent/tools/integrations/index.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/integrations/index.js +4 -0
- package/dist/ai-service/agent/tools/integrations/index.js.map +1 -0
- package/dist/ai-service/agent/tools/integrations/internal.d.ts +3 -0
- package/dist/ai-service/agent/tools/integrations/internal.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/integrations/internal.js +11 -0
- package/dist/ai-service/agent/tools/integrations/internal.js.map +1 -0
- package/dist/ai-service/agent/tools/integrations/metadata.d.ts +9 -0
- package/dist/ai-service/agent/tools/integrations/metadata.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/integrations/metadata.js +57 -0
- package/dist/ai-service/agent/tools/integrations/metadata.js.map +1 -0
- package/dist/ai-service/agent/tools/integrations/run-code.d.ts +5 -0
- package/dist/ai-service/agent/tools/integrations/run-code.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/integrations/run-code.js +32 -0
- package/dist/ai-service/agent/tools/integrations/run-code.js.map +1 -0
- package/dist/ai-service/agent/tools/study-current-app-state.d.ts +2 -4
- package/dist/ai-service/agent/tools/study-current-app-state.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/study-current-app-state.js +10 -8
- package/dist/ai-service/agent/tools/study-current-app-state.js.map +1 -1
- package/dist/ai-service/agent/tools.d.ts +3 -280
- package/dist/ai-service/agent/tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools.js +68 -55
- package/dist/ai-service/agent/tools.js.map +1 -1
- package/dist/ai-service/agent/tools2/access-control.d.ts +119 -0
- package/dist/ai-service/agent/tools2/access-control.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/access-control.js +216 -0
- package/dist/ai-service/agent/tools2/access-control.js.map +1 -0
- package/dist/ai-service/agent/tools2/example.d.ts +13 -0
- package/dist/ai-service/agent/tools2/example.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/example.js +143 -0
- package/dist/ai-service/agent/tools2/example.js.map +1 -0
- package/dist/ai-service/agent/tools2/index.d.ts +16 -0
- package/dist/ai-service/agent/tools2/index.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/index.js +18 -0
- package/dist/ai-service/agent/tools2/index.js.map +1 -0
- package/dist/ai-service/agent/tools2/registry.d.ts +167 -0
- package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/registry.js +305 -0
- package/dist/ai-service/agent/tools2/registry.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts +12 -0
- package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js +73 -0
- package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/bash.d.ts +34 -0
- package/dist/ai-service/agent/tools2/tools/bash.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/bash.js +76 -0
- package/dist/ai-service/agent/tools2/tools/bash.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/edit.d.ts +14 -0
- package/dist/ai-service/agent/tools2/tools/edit.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/edit.js +60 -0
- package/dist/ai-service/agent/tools2/tools/edit.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts +10 -0
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +66 -0
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/glob.d.ts +11 -0
- package/dist/ai-service/agent/tools2/tools/glob.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/glob.js +44 -0
- package/dist/ai-service/agent/tools2/tools/glob.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/grep.d.ts +21 -0
- package/dist/ai-service/agent/tools2/tools/grep.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/grep.js +100 -0
- package/dist/ai-service/agent/tools2/tools/grep.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/index.d.ts +13 -0
- package/dist/ai-service/agent/tools2/tools/index.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/index.js +13 -0
- package/dist/ai-service/agent/tools2/tools/index.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/read.d.ts +9 -0
- package/dist/ai-service/agent/tools2/tools/read.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/read.js +43 -0
- package/dist/ai-service/agent/tools2/tools/read.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/write.d.ts +11 -0
- package/dist/ai-service/agent/tools2/tools/write.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/write.js +28 -0
- package/dist/ai-service/agent/tools2/tools/write.js.map +1 -0
- package/dist/ai-service/agent/tools2/types.d.ts +148 -0
- package/dist/ai-service/agent/tools2/types.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/types.js +55 -0
- package/dist/ai-service/agent/tools2/types.js.map +1 -0
- package/dist/ai-service/agent/utils.d.ts +2 -3
- package/dist/ai-service/agent/utils.d.ts.map +1 -1
- package/dist/ai-service/agent/utils.js +14 -13
- package/dist/ai-service/agent/utils.js.map +1 -1
- package/dist/ai-service/chat/chat-session-store.d.ts +5 -0
- package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
- package/dist/ai-service/chat/chat-session-store.js +484 -345
- package/dist/ai-service/chat/chat-session-store.js.map +1 -1
- package/dist/ai-service/chat/extract-history.d.ts +1 -0
- package/dist/ai-service/chat/extract-history.d.ts.map +1 -1
- package/dist/ai-service/chat/extract-history.js +12 -1
- package/dist/ai-service/chat/extract-history.js.map +1 -1
- package/dist/ai-service/const.d.ts +2 -1
- package/dist/ai-service/const.d.ts.map +1 -1
- package/dist/ai-service/const.js +7 -1
- package/dist/ai-service/const.js.map +1 -1
- package/dist/ai-service/index.d.ts +9 -8
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +7 -0
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/integrations/store.d.ts +24 -1
- package/dist/ai-service/integrations/store.d.ts.map +1 -1
- package/dist/ai-service/integrations/store.js +86 -2
- package/dist/ai-service/integrations/store.js.map +1 -1
- package/dist/ai-service/llm/context/caching/constants.d.ts +27 -0
- package/dist/ai-service/llm/context/caching/constants.d.ts.map +1 -0
- package/dist/ai-service/llm/context/caching/constants.js +20 -0
- package/dist/ai-service/llm/context/caching/constants.js.map +1 -0
- package/dist/ai-service/llm/context/caching/factory.d.ts +12 -0
- package/dist/ai-service/llm/context/caching/factory.d.ts.map +1 -0
- package/dist/ai-service/llm/context/caching/factory.js +28 -0
- package/dist/ai-service/llm/context/caching/factory.js.map +1 -0
- package/dist/ai-service/llm/context/caching/index.d.ts +10 -0
- package/dist/ai-service/llm/context/caching/index.d.ts.map +1 -0
- package/dist/ai-service/llm/context/caching/index.js +9 -0
- package/dist/ai-service/llm/context/caching/index.js.map +1 -0
- package/dist/ai-service/llm/context/caching/quantized-strategy.d.ts +22 -0
- package/dist/ai-service/llm/context/caching/quantized-strategy.d.ts.map +1 -0
- package/dist/ai-service/llm/context/caching/quantized-strategy.js +48 -0
- package/dist/ai-service/llm/context/caching/quantized-strategy.js.map +1 -0
- package/dist/ai-service/llm/context/caching/strategy.d.ts +20 -0
- package/dist/ai-service/llm/context/caching/strategy.d.ts.map +1 -0
- package/dist/ai-service/llm/context/caching/strategy.js +5 -0
- package/dist/ai-service/llm/context/caching/strategy.js.map +1 -0
- package/dist/ai-service/llm/context/caching/types.d.ts +34 -0
- package/dist/ai-service/llm/context/caching/types.d.ts.map +1 -0
- package/dist/ai-service/llm/context/caching/types.js +8 -0
- package/dist/ai-service/llm/context/caching/types.js.map +1 -0
- package/dist/ai-service/llm/context/config.d.ts +51 -0
- package/dist/ai-service/llm/context/config.d.ts.map +1 -0
- package/dist/ai-service/llm/context/config.js +58 -0
- package/dist/ai-service/llm/context/config.js.map +1 -0
- package/dist/ai-service/llm/context/constants.d.ts +106 -0
- package/dist/ai-service/llm/context/constants.d.ts.map +1 -0
- package/dist/ai-service/llm/context/constants.js +106 -0
- package/dist/ai-service/llm/context/constants.js.map +1 -0
- package/dist/ai-service/llm/context/context.d.ts +207 -0
- package/dist/ai-service/llm/context/context.d.ts.map +1 -0
- package/dist/ai-service/llm/context/context.js +742 -0
- package/dist/ai-service/llm/context/context.js.map +1 -0
- package/dist/ai-service/llm/context/errors.d.ts +45 -0
- package/dist/ai-service/llm/context/errors.d.ts.map +1 -0
- package/dist/ai-service/llm/context/errors.js +56 -0
- package/dist/ai-service/llm/context/errors.js.map +1 -0
- package/dist/ai-service/llm/context/index.d.ts +13 -0
- package/dist/ai-service/llm/context/index.d.ts.map +1 -0
- package/dist/ai-service/llm/context/index.js +17 -0
- package/dist/ai-service/llm/context/index.js.map +1 -0
- package/dist/ai-service/llm/context/internal-types.d.ts +52 -0
- package/dist/ai-service/llm/context/internal-types.d.ts.map +1 -0
- package/dist/ai-service/llm/context/internal-types.js +28 -0
- package/dist/ai-service/llm/context/internal-types.js.map +1 -0
- package/dist/ai-service/llm/context/levels/index.d.ts +12 -0
- package/dist/ai-service/llm/context/levels/index.d.ts.map +1 -0
- package/dist/ai-service/llm/context/levels/index.js +12 -0
- package/dist/ai-service/llm/context/levels/index.js.map +1 -0
- package/dist/ai-service/llm/context/levels/l1.d.ts +83 -0
- package/dist/ai-service/llm/context/levels/l1.d.ts.map +1 -0
- package/dist/ai-service/llm/context/levels/l1.js +143 -0
- package/dist/ai-service/llm/context/levels/l1.js.map +1 -0
- package/dist/ai-service/llm/context/levels/l2.d.ts +60 -0
- package/dist/ai-service/llm/context/levels/l2.d.ts.map +1 -0
- package/dist/ai-service/llm/context/levels/l2.js +96 -0
- package/dist/ai-service/llm/context/levels/l2.js.map +1 -0
- package/dist/ai-service/llm/context/levels/l3.d.ts +46 -0
- package/dist/ai-service/llm/context/levels/l3.d.ts.map +1 -0
- package/dist/ai-service/llm/context/levels/l3.js +70 -0
- package/dist/ai-service/llm/context/levels/l3.js.map +1 -0
- package/dist/ai-service/llm/context/logger.d.ts +17 -0
- package/dist/ai-service/llm/context/logger.d.ts.map +1 -0
- package/dist/ai-service/llm/context/logger.js +26 -0
- package/dist/ai-service/llm/context/logger.js.map +1 -0
- package/dist/ai-service/llm/context/manager.d.ts +79 -0
- package/dist/ai-service/llm/context/manager.d.ts.map +1 -0
- package/dist/ai-service/llm/context/manager.js +136 -0
- package/dist/ai-service/llm/context/manager.js.map +1 -0
- package/dist/ai-service/llm/context/options.d.ts +43 -0
- package/dist/ai-service/llm/context/options.d.ts.map +1 -0
- package/dist/ai-service/llm/context/options.js +81 -0
- package/dist/ai-service/llm/context/options.js.map +1 -0
- package/dist/ai-service/llm/context/serialization.d.ts +56 -0
- package/dist/ai-service/llm/context/serialization.d.ts.map +1 -0
- package/dist/ai-service/llm/context/serialization.js +9 -0
- package/dist/ai-service/llm/context/serialization.js.map +1 -0
- package/dist/ai-service/llm/context/storage/index.d.ts +10 -0
- package/dist/ai-service/llm/context/storage/index.d.ts.map +1 -0
- package/dist/ai-service/llm/context/storage/index.js +2 -0
- package/dist/ai-service/llm/context/storage/index.js.map +1 -0
- package/dist/ai-service/llm/context/storage/local.d.ts +22 -0
- package/dist/ai-service/llm/context/storage/local.d.ts.map +1 -0
- package/dist/ai-service/llm/context/storage/local.js +42 -0
- package/dist/ai-service/llm/context/storage/local.js.map +1 -0
- package/dist/ai-service/llm/context/types.d.ts +125 -0
- package/dist/ai-service/llm/context/types.d.ts.map +1 -0
- package/dist/ai-service/llm/context/types.js +5 -0
- package/dist/ai-service/llm/context/types.js.map +1 -0
- package/dist/ai-service/llm/context/utils/content-compaction.d.ts +26 -0
- package/dist/ai-service/llm/context/utils/content-compaction.d.ts.map +1 -0
- package/dist/ai-service/llm/context/utils/content-compaction.js +52 -0
- package/dist/ai-service/llm/context/utils/content-compaction.js.map +1 -0
- package/dist/ai-service/llm/context/utils/index.d.ts +10 -0
- package/dist/ai-service/llm/context/utils/index.d.ts.map +1 -0
- package/dist/ai-service/llm/context/utils/index.js +10 -0
- package/dist/ai-service/llm/context/utils/index.js.map +1 -0
- package/dist/ai-service/llm/context/utils/message-utils.d.ts +34 -0
- package/dist/ai-service/llm/context/utils/message-utils.d.ts.map +1 -0
- package/dist/ai-service/llm/context/utils/message-utils.js +68 -0
- package/dist/ai-service/llm/context/utils/message-utils.js.map +1 -0
- package/dist/ai-service/llm/context/utils/token-estimation.d.ts +31 -0
- package/dist/ai-service/llm/context/utils/token-estimation.d.ts.map +1 -0
- package/dist/ai-service/llm/context/utils/token-estimation.js +52 -0
- package/dist/ai-service/llm/context/utils/token-estimation.js.map +1 -0
- package/dist/ai-service/llm/context/utils/visualization.d.ts +40 -0
- package/dist/ai-service/llm/context/utils/visualization.d.ts.map +1 -0
- package/dist/ai-service/llm/context/utils/visualization.js +516 -0
- package/dist/ai-service/llm/context/utils/visualization.js.map +1 -0
- package/dist/ai-service/llm/impl/anthropic.js +2 -2
- package/dist/ai-service/llm/impl/anthropic.js.map +1 -1
- package/dist/ai-service/llmobs/helpers.d.ts.map +1 -1
- package/dist/ai-service/llmobs/helpers.js +10 -19
- package/dist/ai-service/llmobs/helpers.js.map +1 -1
- package/dist/ai-service/llmobs/middleware/stream-text.js +4 -1
- package/dist/ai-service/llmobs/middleware/stream-text.js.map +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ButtonPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/CheckboxPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ColumnPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ContainerPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DatePickerPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DropdownPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/IconPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ImagePropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/InputPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ModalPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/PagePropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SectionPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SlideoutPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SwitchPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TablePropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TextPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/Dim.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/EventFlow.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/TextStyleWithVariant.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/full-examples.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-api.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-components-rules.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-custom-components.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-data-filtering.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-event-flow.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-forms.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-layouts.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-page.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-rbac.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-routes.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-state.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-theming-chakra-new.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-base.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-incremental.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-specific-edit.js +1 -1
- package/dist/ai-service/state-machine/clark-fsm.d.ts +9 -5
- package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.js +36 -9
- package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.js +154 -104
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/context-id.d.ts +4 -0
- package/dist/ai-service/state-machine/helpers/context-id.d.ts.map +1 -0
- package/dist/ai-service/state-machine/helpers/context-id.js +16 -0
- package/dist/ai-service/state-machine/helpers/context-id.js.map +1 -0
- package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/peer.js +7 -4
- package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
- package/dist/ai-service/state-machine/mocks.d.ts +2 -3
- package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
- package/dist/ai-service/state-machine/mocks.js.map +1 -1
- package/dist/ai-service/types.d.ts +3 -0
- package/dist/ai-service/types.d.ts.map +1 -1
- package/dist/ai-service/types.js.map +1 -1
- package/dist/ai-service/util/parse-jwt.d.ts +12 -0
- package/dist/ai-service/util/parse-jwt.d.ts.map +1 -0
- package/dist/ai-service/util/parse-jwt.js +30 -0
- package/dist/ai-service/util/parse-jwt.js.map +1 -0
- package/dist/ai-service/util/safe-stringify.d.ts +1 -1
- package/dist/ai-service/util/safe-stringify.d.ts.map +1 -1
- package/dist/ai-service/util/safe-stringify.js +3 -3
- package/dist/ai-service/util/safe-stringify.js.map +1 -1
- package/dist/binding-extraction/extract-js-identifiers.d.ts.map +1 -1
- package/dist/binding-extraction/extract-js-identifiers.js +1 -1
- package/dist/binding-extraction/extract-js-identifiers.js.map +1 -1
- package/dist/component-docs-service/index.d.ts.map +1 -1
- package/dist/component-docs-service/index.js +0 -2
- package/dist/component-docs-service/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/ai-service/agent/apis-static-analysis.d.ts.map +0 -1
- package/dist/ai-service/agent/apis-static-analysis.js.map +0 -1
- package/dist/ai-service/agent/apis-system-prompt.d.ts +0 -3
- package/dist/ai-service/agent/apis-system-prompt.d.ts.map +0 -1
- package/dist/ai-service/agent/apis.d.ts +0 -55
- package/dist/ai-service/agent/apis.d.ts.map +0 -1
- package/dist/ai-service/agent/apis.js.map +0 -1
|
@@ -1,4 +1,39 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
1
35
|
import { getErrorMeta } from "../../util/logger.js";
|
|
36
|
+
import llmobs from "../llmobs/index.js";
|
|
2
37
|
import { extractProductiveHistoryForContext, getLastUserMessage, } from "./extract-history.js";
|
|
3
38
|
export function isAiChatMessage(item) {
|
|
4
39
|
return "role" in item && "content" in item;
|
|
@@ -6,401 +41,505 @@ export function isAiChatMessage(item) {
|
|
|
6
41
|
export function isAiChatSummary(item) {
|
|
7
42
|
return "summary" in item && "relevantFilePaths" in item;
|
|
8
43
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* Validates and sanitizes the attachments array
|
|
28
|
-
* @param attachments - The attachments array to validate
|
|
29
|
-
* @returns A tuple containing:
|
|
30
|
-
* - a boolean indicating if the attachments are valid
|
|
31
|
-
* - the sanitized attachments array
|
|
32
|
-
*/
|
|
33
|
-
validateAttachments(attachments) {
|
|
34
|
-
if (!attachments) {
|
|
35
|
-
return [true, undefined];
|
|
44
|
+
let ChatSessionStore = (() => {
|
|
45
|
+
let _instanceExtraInitializers = [];
|
|
46
|
+
let _getMessages_decorators;
|
|
47
|
+
let _getLatestSummary_decorators;
|
|
48
|
+
return class ChatSessionStore {
|
|
49
|
+
static {
|
|
50
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
51
|
+
_getMessages_decorators = [llmobs.decorate({
|
|
52
|
+
kind: "task",
|
|
53
|
+
name: "ChatSessionStore.getMessages",
|
|
54
|
+
})];
|
|
55
|
+
_getLatestSummary_decorators = [llmobs.decorate({
|
|
56
|
+
kind: "task",
|
|
57
|
+
name: "ChatSessionStore.getLatestSummary",
|
|
58
|
+
})];
|
|
59
|
+
__esDecorate(this, null, _getMessages_decorators, { kind: "method", name: "getMessages", static: false, private: false, access: { has: obj => "getMessages" in obj, get: obj => obj.getMessages }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
60
|
+
__esDecorate(this, null, _getLatestSummary_decorators, { kind: "method", name: "getLatestSummary", static: false, private: false, access: { has: obj => "getLatestSummary" in obj, get: obj => obj.getLatestSummary }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
61
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
36
62
|
}
|
|
37
|
-
|
|
38
|
-
|
|
63
|
+
// Approximate number of characters per token for estimating token usage
|
|
64
|
+
static CHARS_PER_TOKEN = 3.5;
|
|
65
|
+
applicationId = __runInitializers(this, _instanceExtraInitializers);
|
|
66
|
+
rpcClient;
|
|
67
|
+
logger;
|
|
68
|
+
messages;
|
|
69
|
+
inFlightLoadFromServer;
|
|
70
|
+
loadedFromServer = "no";
|
|
71
|
+
constructor(config) {
|
|
72
|
+
this.rpcClient = config.rpcClient;
|
|
73
|
+
this.applicationId = config.applicationId;
|
|
74
|
+
this.messages = [];
|
|
75
|
+
this.logger = config.logger;
|
|
76
|
+
// NOTE: This is used to serialize messages to be after any load.
|
|
77
|
+
// We initialize it as resolved to handle the prompt-from-empty-state case.
|
|
78
|
+
// TODO(ai): consider replacing this with a queue-based approach
|
|
79
|
+
this.inFlightLoadFromServer = Promise.resolve();
|
|
39
80
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
81
|
+
/***
|
|
82
|
+
* Validates and sanitizes the attachments array
|
|
83
|
+
* @param attachments - The attachments array to validate
|
|
84
|
+
* @returns A tuple containing:
|
|
85
|
+
* - a boolean indicating if the attachments are valid
|
|
86
|
+
* - the sanitized attachments array
|
|
87
|
+
*/
|
|
88
|
+
validateAttachments(attachments) {
|
|
89
|
+
if (!attachments) {
|
|
90
|
+
return [true, undefined];
|
|
44
91
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
92
|
+
if (typeof attachments !== "object" || !Array.isArray(attachments)) {
|
|
93
|
+
return [false, undefined];
|
|
94
|
+
}
|
|
95
|
+
const validAttachments = attachments
|
|
96
|
+
.map((attachment) => {
|
|
97
|
+
if (typeof attachment !== "object" || !("type" in attachment)) {
|
|
48
98
|
return undefined;
|
|
49
99
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
if (typeof msg.type !== "string") {
|
|
78
|
-
this.logger.warn(`[ai-service] Invalid message type: ${msg.type}`);
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
// Validate optional fields with defaults
|
|
82
|
-
const timestamp = typeof msg.timestamp === "number" ? msg.timestamp : Date.now();
|
|
83
|
-
const group = typeof msg.group === "string" ? msg.group : undefined;
|
|
84
|
-
const status = typeof msg.status === "string" ? msg.status : undefined;
|
|
85
|
-
const action = typeof msg.action === "string" ? msg.action : undefined;
|
|
86
|
-
const [isAttachmentsValid, attachments] = this.validateAttachments(msg.attachments);
|
|
87
|
-
if (!isAttachmentsValid) {
|
|
88
|
-
this.logger.warn(`[ai-service] Invalid attachments`);
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
if (msg.type === "tool") {
|
|
92
|
-
if (typeof msg.data !== "object") {
|
|
93
|
-
this.logger.warn(`[ai-service] Invalid message data`);
|
|
100
|
+
// Validate image attachment
|
|
101
|
+
if (attachment.type === "image") {
|
|
102
|
+
if (typeof attachment.image !== "string") {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
type: attachment.type,
|
|
107
|
+
image: attachment.image,
|
|
108
|
+
fileName: attachment.fileName,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
})
|
|
113
|
+
.filter(Boolean);
|
|
114
|
+
return [validAttachments.length === attachments.length, validAttachments];
|
|
115
|
+
}
|
|
116
|
+
validateChatMessageV1(payload) {
|
|
117
|
+
try {
|
|
118
|
+
if (!payload || typeof payload !== "object") {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const msg = payload;
|
|
122
|
+
// Validate required fields
|
|
123
|
+
if (typeof msg.role !== "string" ||
|
|
124
|
+
!["user", "assistant", "server"].includes(msg.role)) {
|
|
125
|
+
this.logger.warn(`[ai-service] Invalid message role: ${msg.role}`);
|
|
94
126
|
return null;
|
|
95
127
|
}
|
|
128
|
+
if (typeof msg.content !== "string") {
|
|
129
|
+
this.logger.warn(`[ai-service] Invalid message content`);
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
if (typeof msg.type !== "string") {
|
|
133
|
+
this.logger.warn(`[ai-service] Invalid message type: ${msg.type}`);
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
// Validate optional fields with defaults
|
|
137
|
+
const timestamp = typeof msg.timestamp === "number" ? msg.timestamp : Date.now();
|
|
138
|
+
const group = typeof msg.group === "string" ? msg.group : undefined;
|
|
139
|
+
const status = typeof msg.status === "string" ? msg.status : undefined;
|
|
140
|
+
const action = typeof msg.action === "string" ? msg.action : undefined;
|
|
141
|
+
const [isAttachmentsValid, attachments] = this.validateAttachments(msg.attachments);
|
|
142
|
+
if (!isAttachmentsValid) {
|
|
143
|
+
this.logger.warn(`[ai-service] Invalid attachments`);
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
if (msg.type === "tool") {
|
|
147
|
+
return {
|
|
148
|
+
role: msg.role,
|
|
149
|
+
content: msg.content,
|
|
150
|
+
type: "tool",
|
|
151
|
+
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
152
|
+
timestamp,
|
|
153
|
+
status: status,
|
|
154
|
+
action: action,
|
|
155
|
+
args: msg.args,
|
|
156
|
+
tool: msg.tool,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
else if (msg.group === "checklist") {
|
|
160
|
+
if (typeof msg.checklistData !== "object") {
|
|
161
|
+
this.logger.warn(`[ai-service] Invalid checklist data`);
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
role: msg.role,
|
|
166
|
+
content: msg.content,
|
|
167
|
+
type: "tool",
|
|
168
|
+
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
169
|
+
timestamp,
|
|
170
|
+
group,
|
|
171
|
+
status,
|
|
172
|
+
action,
|
|
173
|
+
checklistData: msg.checklistData,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
else if (msg.type === "multi_choice") {
|
|
177
|
+
if (!Array.isArray(msg.choices) || msg.choices.length === 0) {
|
|
178
|
+
this.logger.warn(`[ai-service] Invalid choices for multi_choice message`);
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
role: msg.role,
|
|
183
|
+
content: msg.content,
|
|
184
|
+
type: "multi_choice",
|
|
185
|
+
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
186
|
+
timestamp,
|
|
187
|
+
choices: msg.choices,
|
|
188
|
+
selectionType: typeof msg.selectionType === "string"
|
|
189
|
+
? msg.selectionType
|
|
190
|
+
: "single",
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
else if (msg.type === "multi_choice_response") {
|
|
194
|
+
if (typeof msg.responseToMessageId !== "string") {
|
|
195
|
+
this.logger.warn(`[ai-service] Invalid responseToMessageId for multi_choice_response`);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
if (!Array.isArray(msg.selectedChoiceIndices)) {
|
|
199
|
+
this.logger.warn(`[ai-service] Invalid selectedChoiceIndices for multi_choice_response`);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
role: msg.role,
|
|
204
|
+
content: msg.content,
|
|
205
|
+
type: "multi_choice_response",
|
|
206
|
+
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
207
|
+
timestamp,
|
|
208
|
+
responseToMessageId: msg.responseToMessageId,
|
|
209
|
+
selectedChoiceIndices: msg.selectedChoiceIndices,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else if (msg.type === "plan_response") {
|
|
213
|
+
if (typeof msg.responseToMessageId !== "string") {
|
|
214
|
+
this.logger.warn(`[ai-service] Invalid responseToMessageId for plan_response`);
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
role: msg.role,
|
|
219
|
+
content: msg.content,
|
|
220
|
+
type: "plan_response",
|
|
221
|
+
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
222
|
+
timestamp,
|
|
223
|
+
responseToMessageId: msg.responseToMessageId,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
96
226
|
return {
|
|
97
227
|
role: msg.role,
|
|
98
228
|
content: msg.content,
|
|
99
|
-
type:
|
|
229
|
+
type: msg.type,
|
|
230
|
+
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
100
231
|
timestamp,
|
|
232
|
+
group,
|
|
101
233
|
status: status,
|
|
102
234
|
action: action,
|
|
103
|
-
|
|
235
|
+
attachments,
|
|
104
236
|
};
|
|
105
237
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
238
|
+
catch (error) {
|
|
239
|
+
this.logger.error("[ai-service] Failed to validate message payload", getErrorMeta(error));
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
validateChatSummaryV1(payload) {
|
|
244
|
+
try {
|
|
245
|
+
if (!payload || typeof payload !== "object") {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
const summary = payload;
|
|
249
|
+
// Validate required fields
|
|
250
|
+
if (typeof summary.summary !== "string") {
|
|
251
|
+
this.logger.warn(`[ai-service] Invalid summary content`);
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
if (!Array.isArray(summary.relevantFilePaths)) {
|
|
255
|
+
this.logger.warn(`[ai-service] Invalid relevantFilePaths - must be array`);
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
if (!summary.relevantFilePaths.every((path) => typeof path === "string")) {
|
|
259
|
+
this.logger.warn(`[ai-service] Invalid relevantFilePaths - all items must be strings`);
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
if (!Array.isArray(summary.goals)) {
|
|
263
|
+
this.logger.warn(`[ai-service] Invalid goals - must be array`);
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
if (!summary.goals.every((goal) => typeof goal === "string")) {
|
|
267
|
+
this.logger.warn(`[ai-service] Invalid goals - all items must be strings`);
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
if (!Array.isArray(summary.decisions)) {
|
|
271
|
+
this.logger.warn(`[ai-service] Invalid decisions - must be array`);
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
if (!summary.decisions.every((decision) => typeof decision === "string")) {
|
|
275
|
+
this.logger.warn(`[ai-service] Invalid decisions - all items must be strings`);
|
|
109
276
|
return null;
|
|
110
277
|
}
|
|
278
|
+
// Validate optional fields with defaults
|
|
279
|
+
const timestamp = typeof summary.timestamp === "number" ? summary.timestamp : Date.now();
|
|
111
280
|
return {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
281
|
+
summary: summary.summary,
|
|
282
|
+
relevantFilePaths: summary.relevantFilePaths,
|
|
283
|
+
goals: summary.goals,
|
|
284
|
+
decisions: summary.decisions,
|
|
285
|
+
adviceToAgents: summary.adviceToAgents,
|
|
115
286
|
timestamp,
|
|
116
|
-
group,
|
|
117
|
-
status,
|
|
118
|
-
action,
|
|
119
|
-
checklistData: msg.checklistData,
|
|
120
287
|
};
|
|
121
288
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
content: msg.content,
|
|
125
|
-
type: msg.type,
|
|
126
|
-
timestamp,
|
|
127
|
-
group,
|
|
128
|
-
status: status,
|
|
129
|
-
action: action,
|
|
130
|
-
attachments,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
catch (error) {
|
|
134
|
-
this.logger.error("[ai-service] Failed to validate message payload", getErrorMeta(error));
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
validateChatSummaryV1(payload) {
|
|
139
|
-
try {
|
|
140
|
-
if (!payload || typeof payload !== "object") {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
const summary = payload;
|
|
144
|
-
// Validate required fields
|
|
145
|
-
if (typeof summary.summary !== "string") {
|
|
146
|
-
this.logger.warn(`[ai-service] Invalid summary content`);
|
|
289
|
+
catch (error) {
|
|
290
|
+
this.logger.error("[ai-service] Failed to validate summary payload", getErrorMeta(error));
|
|
147
291
|
return null;
|
|
148
292
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
return null;
|
|
293
|
+
}
|
|
294
|
+
validateChatItemV1(payload) {
|
|
295
|
+
// First try to validate as a message
|
|
296
|
+
const messageResult = this.validateChatMessageV1(payload);
|
|
297
|
+
if (messageResult) {
|
|
298
|
+
return messageResult;
|
|
156
299
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
300
|
+
// If not a valid message, try to validate as a summary
|
|
301
|
+
const summaryResult = this.validateChatSummaryV1(payload);
|
|
302
|
+
if (summaryResult) {
|
|
303
|
+
return summaryResult;
|
|
160
304
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
async ensureLoadedFromServer() {
|
|
308
|
+
// NOTE: we will want to re-evaluate this if/when the auth token associated with this sandbox is changed
|
|
309
|
+
// the existing solution is that each time the page loaded by the client, we re-fetch from the server,
|
|
310
|
+
// so this may be a non-issue.
|
|
311
|
+
if (this.loadedFromServer === "loaded" ||
|
|
312
|
+
this.loadedFromServer === "loading") {
|
|
313
|
+
await this.inFlightLoadFromServer;
|
|
314
|
+
return;
|
|
164
315
|
}
|
|
165
|
-
|
|
166
|
-
this.
|
|
167
|
-
|
|
316
|
+
try {
|
|
317
|
+
this.loadedFromServer = "loading";
|
|
318
|
+
this.inFlightLoadFromServer = this.rpcClient.call(async (client) => {
|
|
319
|
+
const applicationId = this.applicationId;
|
|
320
|
+
const { data } = await client.call.v1.ai.chat.getMessages({
|
|
321
|
+
applicationId,
|
|
322
|
+
});
|
|
323
|
+
this.messages =
|
|
324
|
+
data?.messages
|
|
325
|
+
.map((msg) => this.validateChatItemV1(msg.chatPayload))
|
|
326
|
+
.filter((item) => item !== null)
|
|
327
|
+
.sort((a, b) => {
|
|
328
|
+
return (a.timestamp || 0) - (b.timestamp || 0);
|
|
329
|
+
}) ?? [];
|
|
330
|
+
});
|
|
331
|
+
await this.inFlightLoadFromServer;
|
|
332
|
+
this.loadedFromServer = "loaded";
|
|
168
333
|
}
|
|
169
|
-
|
|
170
|
-
this.logger.
|
|
171
|
-
return null;
|
|
334
|
+
catch (error) {
|
|
335
|
+
this.logger.error("[ai-service] Failed to load chat messages from server", getErrorMeta(error));
|
|
172
336
|
}
|
|
173
|
-
// Validate optional fields with defaults
|
|
174
|
-
const timestamp = typeof summary.timestamp === "number" ? summary.timestamp : Date.now();
|
|
175
|
-
return {
|
|
176
|
-
summary: summary.summary,
|
|
177
|
-
relevantFilePaths: summary.relevantFilePaths,
|
|
178
|
-
goals: summary.goals,
|
|
179
|
-
decisions: summary.decisions,
|
|
180
|
-
adviceToAgents: summary.adviceToAgents,
|
|
181
|
-
timestamp,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
this.logger.error("[ai-service] Failed to validate summary payload", getErrorMeta(error));
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
validateChatItemV1(payload) {
|
|
190
|
-
// First try to validate as a message
|
|
191
|
-
const messageResult = this.validateChatMessageV1(payload);
|
|
192
|
-
if (messageResult) {
|
|
193
|
-
return messageResult;
|
|
194
337
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return summaryResult;
|
|
199
|
-
}
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
async ensureLoadedFromServer() {
|
|
203
|
-
// NOTE: we will want to re-evaluate this if/when the auth token associated with this sandbox is changed
|
|
204
|
-
// the existing solution is that each time the page loaded by the client, we re-fetch from the server,
|
|
205
|
-
// so this may be a non-issue.
|
|
206
|
-
if (this.loadedFromServer === "loaded" ||
|
|
207
|
-
this.loadedFromServer === "loading") {
|
|
208
|
-
await this.inFlightLoadFromServer;
|
|
209
|
-
return;
|
|
338
|
+
getLastUserMessage() {
|
|
339
|
+
const messages = this.messages.filter(isAiChatMessage);
|
|
340
|
+
return getLastUserMessage(messages);
|
|
210
341
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
});
|
|
218
|
-
this.messages =
|
|
219
|
-
data?.messages
|
|
220
|
-
.map((msg) => this.validateChatItemV1(msg.chatPayload))
|
|
221
|
-
.filter((item) => item !== null)
|
|
222
|
-
.sort((a, b) => {
|
|
223
|
-
return (a.timestamp || 0) - (b.timestamp || 0);
|
|
224
|
-
}) ?? [];
|
|
342
|
+
getRecentExchanges() {
|
|
343
|
+
// Filter out summaries but keep regular messages for the existing logic
|
|
344
|
+
const messages = this.messages.filter(isAiChatMessage);
|
|
345
|
+
return extractProductiveHistoryForContext(messages, {
|
|
346
|
+
maxAcceptedExchanges: 2,
|
|
347
|
+
includeRecentUnknown: true,
|
|
225
348
|
});
|
|
226
|
-
await this.inFlightLoadFromServer;
|
|
227
|
-
this.loadedFromServer = "loaded";
|
|
228
349
|
}
|
|
229
|
-
|
|
230
|
-
this.
|
|
350
|
+
async getMessages() {
|
|
351
|
+
await this.ensureLoadedFromServer();
|
|
352
|
+
return this.messages.filter(isAiChatMessage);
|
|
231
353
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
async getMessages() {
|
|
246
|
-
await this.ensureLoadedFromServer();
|
|
247
|
-
return this.messages.filter(isAiChatMessage);
|
|
248
|
-
}
|
|
249
|
-
async newChat() {
|
|
250
|
-
try {
|
|
251
|
-
await this.rpcClient.call(async (client) => {
|
|
252
|
-
const applicationId = this.applicationId;
|
|
253
|
-
return await client.call.v1.ai.chat.new({ applicationId });
|
|
254
|
-
});
|
|
255
|
-
this.messages = [];
|
|
354
|
+
async newChat() {
|
|
355
|
+
try {
|
|
356
|
+
await this.rpcClient.call(async (client) => {
|
|
357
|
+
const applicationId = this.applicationId;
|
|
358
|
+
return await client.call.v1.ai.chat.new({ applicationId });
|
|
359
|
+
});
|
|
360
|
+
this.messages = [];
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
this.logger.error("[ai-service] Failed to create new chat", getErrorMeta(error));
|
|
364
|
+
}
|
|
256
365
|
}
|
|
257
|
-
|
|
258
|
-
|
|
366
|
+
async recordUser(text, options = {}) {
|
|
367
|
+
const message = {
|
|
368
|
+
role: "user",
|
|
369
|
+
content: text,
|
|
370
|
+
id: crypto.randomUUID(),
|
|
371
|
+
timestamp: Date.now(),
|
|
372
|
+
type: "text",
|
|
373
|
+
};
|
|
374
|
+
if (options.attachments) {
|
|
375
|
+
message.attachments = options.attachments;
|
|
376
|
+
}
|
|
377
|
+
await this.appendMessage(message);
|
|
259
378
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
message.attachments = options.attachments;
|
|
379
|
+
async recordUserAcceptance() {
|
|
380
|
+
const message = {
|
|
381
|
+
role: "user",
|
|
382
|
+
content: "",
|
|
383
|
+
id: crypto.randomUUID(),
|
|
384
|
+
timestamp: Date.now(),
|
|
385
|
+
type: "draftAccepted",
|
|
386
|
+
};
|
|
387
|
+
await this.appendMessage(message);
|
|
270
388
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
content: "",
|
|
277
|
-
timestamp: Date.now(),
|
|
278
|
-
type: "draftAccepted",
|
|
279
|
-
};
|
|
280
|
-
await this.appendMessage(message);
|
|
281
|
-
}
|
|
282
|
-
async recordUserRejection() {
|
|
283
|
-
const message = {
|
|
284
|
-
role: "user",
|
|
285
|
-
content: "",
|
|
286
|
-
timestamp: Date.now(),
|
|
287
|
-
type: "draftRejected",
|
|
288
|
-
};
|
|
289
|
-
await this.appendMessage(message);
|
|
290
|
-
}
|
|
291
|
-
async recordAssistant(payload) {
|
|
292
|
-
let message;
|
|
293
|
-
if ("checklistData" in payload) {
|
|
294
|
-
message = {
|
|
295
|
-
role: "assistant",
|
|
296
|
-
content: payload.text,
|
|
297
|
-
type: "tool",
|
|
298
|
-
group: "checklist",
|
|
299
|
-
status: payload.status,
|
|
389
|
+
async recordUserRejection() {
|
|
390
|
+
const message = {
|
|
391
|
+
role: "user",
|
|
392
|
+
content: "",
|
|
393
|
+
id: crypto.randomUUID(),
|
|
300
394
|
timestamp: Date.now(),
|
|
301
|
-
|
|
395
|
+
type: "draftRejected",
|
|
302
396
|
};
|
|
397
|
+
await this.appendMessage(message);
|
|
303
398
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
role: "
|
|
307
|
-
content:
|
|
308
|
-
|
|
309
|
-
status: payload.status,
|
|
399
|
+
async recordUserResponse(text, responseType, metadata) {
|
|
400
|
+
const baseMessage = {
|
|
401
|
+
role: "user",
|
|
402
|
+
content: text,
|
|
403
|
+
id: crypto.randomUUID(),
|
|
310
404
|
timestamp: Date.now(),
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
name: payload.name,
|
|
314
|
-
displayType: payload.displayType,
|
|
315
|
-
},
|
|
405
|
+
type: responseType,
|
|
406
|
+
responseToMessageId: metadata.responseToMessageId,
|
|
316
407
|
};
|
|
408
|
+
if (responseType === "multi_choice_response" &&
|
|
409
|
+
metadata.selectedChoiceIndices) {
|
|
410
|
+
baseMessage.selectedChoiceIndices =
|
|
411
|
+
metadata.selectedChoiceIndices;
|
|
412
|
+
}
|
|
413
|
+
await this.appendMessage(baseMessage);
|
|
414
|
+
}
|
|
415
|
+
async recordAssistant(payload) {
|
|
416
|
+
let message;
|
|
417
|
+
// Use ID from payload if present, otherwise generate new one
|
|
418
|
+
const messageId = payload.id ?? crypto.randomUUID();
|
|
419
|
+
if ("checklistData" in payload) {
|
|
420
|
+
message = {
|
|
421
|
+
role: "assistant",
|
|
422
|
+
content: payload.text,
|
|
423
|
+
type: "tool",
|
|
424
|
+
group: "checklist",
|
|
425
|
+
status: payload.status,
|
|
426
|
+
id: messageId,
|
|
427
|
+
timestamp: Date.now(),
|
|
428
|
+
checklistData: payload.checklistData,
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
else if (payload.type === "tool") {
|
|
432
|
+
message = {
|
|
433
|
+
role: "assistant",
|
|
434
|
+
content: "",
|
|
435
|
+
type: "tool",
|
|
436
|
+
status: payload.status,
|
|
437
|
+
id: messageId,
|
|
438
|
+
timestamp: Date.now(),
|
|
439
|
+
args: payload.args,
|
|
440
|
+
tool: payload.tool,
|
|
441
|
+
group: "group" in payload ? payload.group : "",
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
message = {
|
|
446
|
+
role: "assistant",
|
|
447
|
+
content: payload.text,
|
|
448
|
+
type: payload.type || "text",
|
|
449
|
+
group: "group" in payload ? payload.group : "",
|
|
450
|
+
status: payload.status,
|
|
451
|
+
id: messageId,
|
|
452
|
+
timestamp: Date.now(),
|
|
453
|
+
...("choices" in payload && payload.choices
|
|
454
|
+
? { choices: payload.choices }
|
|
455
|
+
: {}),
|
|
456
|
+
...("selectionType" in payload && payload.selectionType
|
|
457
|
+
? { selectionType: payload.selectionType }
|
|
458
|
+
: {}),
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
await this.appendMessage(message);
|
|
317
462
|
}
|
|
318
|
-
|
|
319
|
-
message = {
|
|
463
|
+
async recordAssistantChangeInfo(payload) {
|
|
464
|
+
const message = {
|
|
320
465
|
role: "assistant",
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
466
|
+
group: payload.type,
|
|
467
|
+
content: payload.name,
|
|
468
|
+
action: payload.action,
|
|
324
469
|
status: payload.status,
|
|
470
|
+
type: "changeInfo",
|
|
471
|
+
id: crypto.randomUUID(),
|
|
325
472
|
timestamp: Date.now(),
|
|
326
473
|
};
|
|
474
|
+
await this.appendMessage(message);
|
|
327
475
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
async appendMessage(payload) {
|
|
343
|
-
await this.ensureLoadedFromServer();
|
|
344
|
-
this.messages.push(payload);
|
|
345
|
-
try {
|
|
346
|
-
await this.rpcClient.call(async (client) => {
|
|
347
|
-
const applicationId = this.applicationId;
|
|
348
|
-
return await client.call.v1.ai.chat.pushMessage({
|
|
349
|
-
applicationId,
|
|
350
|
-
payload: payload,
|
|
476
|
+
async appendMessage(message) {
|
|
477
|
+
await this.ensureLoadedFromServer();
|
|
478
|
+
this.messages.push(message);
|
|
479
|
+
const payload = {
|
|
480
|
+
...message,
|
|
481
|
+
};
|
|
482
|
+
try {
|
|
483
|
+
await this.rpcClient.call(async (client) => {
|
|
484
|
+
const applicationId = this.applicationId;
|
|
485
|
+
return await client.call.v1.ai.chat.pushMessage({
|
|
486
|
+
applicationId,
|
|
487
|
+
payload,
|
|
488
|
+
});
|
|
351
489
|
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
determineSummaryOutcome(summary, allMessages) {
|
|
359
|
-
// Find the index of this summary in all messages
|
|
360
|
-
const summaryIndex = allMessages.findIndex((item) => isAiChatSummary(item) &&
|
|
361
|
-
item.timestamp === summary.timestamp &&
|
|
362
|
-
item.summary === summary.summary);
|
|
363
|
-
if (summaryIndex === -1) {
|
|
364
|
-
return "unknown";
|
|
490
|
+
}
|
|
491
|
+
catch (error) {
|
|
492
|
+
this.logger.error("[ai-service] Failed to write chat message to server", getErrorMeta(error));
|
|
493
|
+
}
|
|
365
494
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
495
|
+
determineSummaryOutcome(summary, allMessages) {
|
|
496
|
+
// Find the index of this summary in all messages
|
|
497
|
+
const summaryIndex = allMessages.findIndex((item) => isAiChatSummary(item) &&
|
|
498
|
+
item.timestamp === summary.timestamp &&
|
|
499
|
+
item.summary === summary.summary);
|
|
500
|
+
if (summaryIndex === -1) {
|
|
501
|
+
return "unknown";
|
|
502
|
+
}
|
|
503
|
+
// Look for acceptance/rejection messages after this summary
|
|
504
|
+
const messagesAfterSummary = allMessages.slice(summaryIndex + 1);
|
|
505
|
+
for (const item of messagesAfterSummary) {
|
|
506
|
+
if (isAiChatMessage(item) && item.role === "user") {
|
|
507
|
+
if (item.type === "draftAccepted") {
|
|
508
|
+
return "accepted";
|
|
509
|
+
}
|
|
510
|
+
if (item.type === "draftRejected") {
|
|
511
|
+
return "rejected";
|
|
512
|
+
}
|
|
375
513
|
}
|
|
376
514
|
}
|
|
515
|
+
return "unknown";
|
|
377
516
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
.
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
517
|
+
async recordSummary(summaryData) {
|
|
518
|
+
const summaryPayload = {
|
|
519
|
+
...summaryData,
|
|
520
|
+
timestamp: Date.now(),
|
|
521
|
+
};
|
|
522
|
+
await this.appendMessage(summaryPayload);
|
|
523
|
+
}
|
|
524
|
+
async getSummaries() {
|
|
525
|
+
await this.ensureLoadedFromServer();
|
|
526
|
+
return this.messages.filter(isAiChatSummary);
|
|
527
|
+
}
|
|
528
|
+
async getLatestSummary() {
|
|
529
|
+
return (await this.getLatestSummaries(1))[0];
|
|
530
|
+
}
|
|
531
|
+
async getLatestSummaries(count) {
|
|
532
|
+
const summaries = await this.getSummaries();
|
|
533
|
+
const sortedSummaries = summaries
|
|
534
|
+
.sort((a, b) => (b.timestamp || 0) - (a.timestamp || 0))
|
|
535
|
+
.slice(0, count);
|
|
536
|
+
// Add outcome information to each summary
|
|
537
|
+
return sortedSummaries.map((summary) => ({
|
|
538
|
+
...summary,
|
|
539
|
+
outcome: this.determineSummaryOutcome(summary, this.messages),
|
|
540
|
+
}));
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
})();
|
|
544
|
+
export { ChatSessionStore };
|
|
406
545
|
//# sourceMappingURL=chat-session-store.js.map
|