@superblocksteam/vite-plugin-file-sync 2.0.158 → 2.0.159-next.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/ai-service/agent/middleware.d.ts +1 -2
- package/dist/ai-service/agent/middleware.d.ts.map +1 -1
- package/dist/ai-service/agent/middleware.js +2 -3
- package/dist/ai-service/agent/middleware.js.map +1 -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 +5 -4
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
- package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
- package/dist/ai-service/agent/tool-message-utils.js +16 -1
- package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
- package/dist/ai-service/agent/tool-result-metrics.d.ts +29 -0
- package/dist/ai-service/agent/tool-result-metrics.d.ts.map +1 -0
- package/dist/ai-service/agent/tool-result-metrics.js +162 -0
- package/dist/ai-service/agent/tool-result-metrics.js.map +1 -0
- package/dist/ai-service/agent/tools/apis/test-api.d.ts +50 -1
- package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/test-api.js +132 -10
- package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -1
- package/dist/ai-service/agent/tools/build-delete-file.d.ts +1 -2
- package/dist/ai-service/agent/tools/build-delete-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-delete-file.js +2 -0
- package/dist/ai-service/agent/tools/build-delete-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-edit-file.d.ts +1 -2
- package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-edit-file.js +2 -0
- package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.d.ts +1 -0
- package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.js +123 -16
- package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
- package/dist/ai-service/agent/tools/build-lookup-npm-package.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-lookup-npm-package.js +4 -16
- package/dist/ai-service/agent/tools/build-lookup-npm-package.js.map +1 -1
- package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +11 -7
- package/dist/ai-service/agent/tools/build-manage-checklist.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-manage-checklist.js +18 -9
- 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 +1 -2
- 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 +2 -0
- package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-read-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-read-file.js +31 -18
- package/dist/ai-service/agent/tools/build-read-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-rename-file.d.ts +1 -2
- package/dist/ai-service/agent/tools/build-rename-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-rename-file.js +2 -0
- package/dist/ai-service/agent/tools/build-rename-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-write-file.d.ts +1 -2
- package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-write-file.js +2 -0
- package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts +3 -3
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.js +5 -7
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.js.map +1 -1
- package/dist/ai-service/agent/tools/debug-cache.d.ts +16 -14
- package/dist/ai-service/agent/tools/debug-cache.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/debug-cache.js +200 -42
- package/dist/ai-service/agent/tools/debug-cache.js.map +1 -1
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +13 -13
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/integrations/execute-request.js +52 -20
- package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -1
- package/dist/ai-service/agent/tools/integrations/sql-classification.d.ts +7 -1
- package/dist/ai-service/agent/tools/integrations/sql-classification.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/integrations/sql-classification.js +229 -11
- package/dist/ai-service/agent/tools/integrations/sql-classification.js.map +1 -1
- package/dist/ai-service/agent/tools/page-edit-guidance.d.ts +2 -0
- package/dist/ai-service/agent/tools/page-edit-guidance.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/page-edit-guidance.js +11 -0
- package/dist/ai-service/agent/tools/page-edit-guidance.js.map +1 -0
- package/dist/ai-service/agent/tools/report-security-findings.d.ts +5 -5
- package/dist/ai-service/agent/tools.d.ts +32 -0
- package/dist/ai-service/agent/tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools.js +54 -33
- package/dist/ai-service/agent/tools.js.map +1 -1
- package/dist/ai-service/agent/tools2/registry.d.ts +1 -1
- package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/registry.js +21 -4
- package/dist/ai-service/agent/tools2/registry.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/end-test-run.d.ts +2 -2
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +20 -11
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts +4 -0
- package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js +28 -8
- package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/update-test-case-status.d.ts +2 -2
- package/dist/ai-service/app-interface/cancellable-exec.d.ts +34 -0
- package/dist/ai-service/app-interface/cancellable-exec.d.ts.map +1 -0
- package/dist/ai-service/app-interface/cancellable-exec.js +98 -0
- package/dist/ai-service/app-interface/cancellable-exec.js.map +1 -0
- package/dist/ai-service/app-interface/shell.d.ts +20 -3
- package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
- package/dist/ai-service/app-interface/shell.js +139 -65
- package/dist/ai-service/app-interface/shell.js.map +1 -1
- package/dist/ai-service/attachment-upload.d.ts.map +1 -1
- package/dist/ai-service/attachment-upload.js +4 -1
- package/dist/ai-service/attachment-upload.js.map +1 -1
- package/dist/ai-service/attachments/parse-data-url.d.ts +5 -0
- package/dist/ai-service/attachments/parse-data-url.d.ts.map +1 -0
- package/dist/ai-service/attachments/parse-data-url.js +14 -0
- package/dist/ai-service/attachments/parse-data-url.js.map +1 -0
- package/dist/ai-service/chat/chat-session-store.d.ts +0 -8
- package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
- package/dist/ai-service/chat/chat-session-store.js +34 -611
- package/dist/ai-service/chat/chat-session-store.js.map +1 -1
- package/dist/ai-service/chat/utils.d.ts +2 -6
- package/dist/ai-service/chat/utils.d.ts.map +1 -1
- package/dist/ai-service/chat/utils.js +2 -95
- package/dist/ai-service/chat/utils.js.map +1 -1
- package/dist/ai-service/index.d.ts +3 -2
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +138 -48
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/integrations/mention-safe-tag-name.d.ts +12 -0
- package/dist/ai-service/integrations/mention-safe-tag-name.d.ts.map +1 -0
- package/dist/ai-service/integrations/mention-safe-tag-name.js +18 -0
- package/dist/ai-service/integrations/mention-safe-tag-name.js.map +1 -0
- package/dist/ai-service/integrations/store.d.ts +9 -0
- package/dist/ai-service/integrations/store.d.ts.map +1 -1
- package/dist/ai-service/integrations/store.js +11 -1
- package/dist/ai-service/integrations/store.js.map +1 -1
- package/dist/ai-service/llm/client.d.ts.map +1 -1
- package/dist/ai-service/llm/client.js +67 -4
- package/dist/ai-service/llm/client.js.map +1 -1
- package/dist/ai-service/llm/context-v2/adapter.d.ts +1 -0
- package/dist/ai-service/llm/context-v2/adapter.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/adapter.js +3 -0
- package/dist/ai-service/llm/context-v2/adapter.js.map +1 -1
- package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts +7 -0
- package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/compaction/client-side.js +28 -6
- package/dist/ai-service/llm/context-v2/compaction/client-side.js.map +1 -1
- package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts +12 -0
- package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/compactor.d.ts +8 -0
- package/dist/ai-service/llm/context-v2/compactor.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/compactor.js +15 -3
- package/dist/ai-service/llm/context-v2/compactor.js.map +1 -1
- package/dist/ai-service/llm/context-v2/config.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/config.js +1 -0
- package/dist/ai-service/llm/context-v2/config.js.map +1 -1
- package/dist/ai-service/llm/context-v2/context-metrics.d.ts +44 -1
- package/dist/ai-service/llm/context-v2/context-metrics.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/context-metrics.js +97 -12
- package/dist/ai-service/llm/context-v2/context-metrics.js.map +1 -1
- package/dist/ai-service/llm/context-v2/context.d.ts +125 -0
- package/dist/ai-service/llm/context-v2/context.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/context.js +478 -14
- package/dist/ai-service/llm/context-v2/context.js.map +1 -1
- package/dist/ai-service/llm/context-v2/conversation-context.d.ts +12 -0
- package/dist/ai-service/llm/context-v2/conversation-context.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js +2 -1
- package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js.map +1 -1
- package/dist/ai-service/llm/context-v2/phase2-session-summarizer.js +3 -3
- package/dist/ai-service/llm/context-v2/phase2-session-summarizer.js.map +1 -1
- package/dist/ai-service/llm/context-v2/token-tracker.d.ts +49 -1
- package/dist/ai-service/llm/context-v2/token-tracker.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/token-tracker.js +119 -0
- package/dist/ai-service/llm/context-v2/token-tracker.js.map +1 -1
- package/dist/ai-service/llm/context-v2/truncation-fallback.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/truncation-fallback.js +2 -1
- package/dist/ai-service/llm/context-v2/truncation-fallback.js.map +1 -1
- package/dist/ai-service/llm/context-v2/types.d.ts +9 -0
- package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/types.js.map +1 -1
- package/dist/ai-service/llm/context-v2/well-formed-text.d.ts +24 -0
- package/dist/ai-service/llm/context-v2/well-formed-text.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/well-formed-text.js +73 -0
- package/dist/ai-service/llm/context-v2/well-formed-text.js.map +1 -0
- package/dist/ai-service/llm/error.d.ts +22 -1
- package/dist/ai-service/llm/error.d.ts.map +1 -1
- package/dist/ai-service/llm/error.js +159 -22
- package/dist/ai-service/llm/error.js.map +1 -1
- package/dist/ai-service/llm/stream/empty-tool-call-tracker.d.ts +4 -3
- package/dist/ai-service/llm/stream/empty-tool-call-tracker.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/empty-tool-call-tracker.js +5 -4
- package/dist/ai-service/llm/stream/empty-tool-call-tracker.js.map +1 -1
- package/dist/ai-service/llm/stream/idle-monitor.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/idle-monitor.js +5 -0
- package/dist/ai-service/llm/stream/idle-monitor.js.map +1 -1
- package/dist/ai-service/llm/stream/observers/logging.d.ts +6 -0
- package/dist/ai-service/llm/stream/observers/logging.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/observers/logging.js +44 -3
- package/dist/ai-service/llm/stream/observers/logging.js.map +1 -1
- package/dist/ai-service/llm/stream/orchestrator.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/orchestrator.js +28 -4
- package/dist/ai-service/llm/stream/orchestrator.js.map +1 -1
- package/dist/ai-service/llm/stream/retry-engine.d.ts +1 -1
- package/dist/ai-service/llm/stream/retry-engine.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/retry-engine.js +9 -1
- package/dist/ai-service/llm/stream/retry-engine.js.map +1 -1
- package/dist/ai-service/llm/stream/session.d.ts +6 -0
- package/dist/ai-service/llm/stream/session.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/session.js +6 -0
- package/dist/ai-service/llm/stream/session.js.map +1 -1
- package/dist/ai-service/llm/stream/terminal-reason.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/terminal-reason.js +11 -1
- package/dist/ai-service/llm/stream/terminal-reason.js.map +1 -1
- package/dist/ai-service/llm/stream/wait-state-tracker.d.ts +4 -3
- package/dist/ai-service/llm/stream/wait-state-tracker.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/wait-state-tracker.js +12 -8
- package/dist/ai-service/llm/stream/wait-state-tracker.js.map +1 -1
- package/dist/ai-service/policy-agent-metrics.d.ts +2 -1
- package/dist/ai-service/policy-agent-metrics.d.ts.map +1 -1
- package/dist/ai-service/policy-agent-metrics.js +11 -2
- package/dist/ai-service/policy-agent-metrics.js.map +1 -1
- package/dist/ai-service/policy-gate-error.d.ts +3 -0
- package/dist/ai-service/policy-gate-error.d.ts.map +1 -0
- package/dist/ai-service/policy-gate-error.js +33 -0
- package/dist/ai-service/policy-gate-error.js.map +1 -0
- package/dist/ai-service/resolve-generation-state-for-ui.js +1 -1
- package/dist/ai-service/resolve-generation-state-for-ui.js.map +1 -1
- package/dist/ai-service/security/secret-scanner-service.d.ts +3 -6
- package/dist/ai-service/security/secret-scanner-service.d.ts.map +1 -1
- package/dist/ai-service/security/secret-scanner-service.js +229 -97
- package/dist/ai-service/security/secret-scanner-service.js.map +1 -1
- package/dist/ai-service/security/secret-scanner.d.ts +28 -5
- package/dist/ai-service/security/secret-scanner.d.ts.map +1 -1
- package/dist/ai-service/security/secret-scanner.js +197 -42
- package/dist/ai-service/security/secret-scanner.js.map +1 -1
- package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts +1 -1
- package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts.map +1 -1
- package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js +49 -0
- package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js.map +1 -1
- package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts +1 -1
- package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts.map +1 -1
- package/dist/ai-service/skills/system/third-party-migration/skill.generated.js +1 -0
- package/dist/ai-service/skills/system/third-party-migration/skill.generated.js.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.d.ts +2 -0
- package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.js +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 +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 +74 -3
- 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 +1 -11
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts +3 -2
- package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js +25 -5
- package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.js +1 -0
- package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.d.ts +4 -0
- package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.js +6 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -1
- package/dist/ai-service/test-utils/metrics-harness.d.ts +6 -0
- package/dist/ai-service/test-utils/metrics-harness.d.ts.map +1 -1
- package/dist/ai-service/test-utils/metrics-harness.js.map +1 -1
- package/dist/ai-service/transform/api-builder/shared.d.ts.map +1 -1
- package/dist/ai-service/transform/api-builder/shared.js +2 -1
- package/dist/ai-service/transform/api-builder/shared.js.map +1 -1
- package/dist/dev-server-ws-smoke-client.d.ts.map +1 -1
- package/dist/dev-server-ws-smoke-client.js +1 -0
- package/dist/dev-server-ws-smoke-client.js.map +1 -1
- package/dist/file-sync-vite-plugin.d.ts +21 -0
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +131 -11
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-helpers.d.ts +2 -2
- package/dist/file-system-helpers.d.ts.map +1 -1
- package/dist/file-system-helpers.js +2 -12
- package/dist/file-system-helpers.js.map +1 -1
- package/dist/migration-templates/app-fullstack/.gitignore +50 -0
- package/dist/parsing/jsx.d.ts +12 -0
- package/dist/parsing/jsx.d.ts.map +1 -1
- package/dist/parsing/jsx.js +30 -12
- package/dist/parsing/jsx.js.map +1 -1
- package/dist/parsing/page.d.ts.map +1 -1
- package/dist/parsing/page.js +16 -8
- package/dist/parsing/page.js.map +1 -1
- package/dist/parsing/parse-tsx-module.d.ts +4 -0
- package/dist/parsing/parse-tsx-module.d.ts.map +1 -0
- package/dist/parsing/parse-tsx-module.js +13 -0
- package/dist/parsing/parse-tsx-module.js.map +1 -0
- package/dist/plugin-options.d.ts +4 -0
- package/dist/plugin-options.d.ts.map +1 -1
- package/dist/plugin-options.js.map +1 -1
- package/dist/policy-gate-callback-mapper.d.ts +2 -1
- package/dist/policy-gate-callback-mapper.d.ts.map +1 -1
- package/dist/policy-gate-callback-mapper.js +3 -5
- package/dist/policy-gate-callback-mapper.js.map +1 -1
- package/dist/policy-gate-run-registry.d.ts +4 -2
- package/dist/policy-gate-run-registry.d.ts.map +1 -1
- package/dist/policy-gate-run-registry.js +17 -2
- package/dist/policy-gate-run-registry.js.map +1 -1
- package/dist/policy-gate-runner.d.ts +1 -1
- package/dist/policy-gate-runner.d.ts.map +1 -1
- package/dist/policy-gate-runner.js +41 -7
- package/dist/policy-gate-runner.js.map +1 -1
- package/dist/router-parser-metrics.d.ts +2 -0
- package/dist/router-parser-metrics.d.ts.map +1 -0
- package/dist/router-parser-metrics.js +13 -0
- package/dist/router-parser-metrics.js.map +1 -0
- package/dist/router-parser.d.ts +6 -1
- package/dist/router-parser.d.ts.map +1 -1
- package/dist/router-parser.js +72 -17
- package/dist/router-parser.js.map +1 -1
- package/dist/scan-scope-merge.d.ts +1 -1
- package/dist/scan-scope-merge.js +1 -1
- package/dist/source-tracker.d.ts.map +1 -1
- package/dist/source-tracker.js +2 -6
- package/dist/source-tracker.js.map +1 -1
- package/dist/sync-service/download.d.ts.map +1 -1
- package/dist/sync-service/download.js +10 -2
- package/dist/sync-service/download.js.map +1 -1
- package/dist/sync-service/index.d.ts +5 -0
- package/dist/sync-service/index.d.ts.map +1 -1
- package/dist/sync-service/index.js +66 -14
- package/dist/sync-service/index.js.map +1 -1
- package/dist/sync-service/list-dir.d.ts.map +1 -1
- package/dist/sync-service/list-dir.js +8 -4
- package/dist/sync-service/list-dir.js.map +1 -1
- package/dist/sync-service/snapshot/upload-snapshot.d.ts.map +1 -1
- package/dist/sync-service/snapshot/upload-snapshot.js +20 -0
- package/dist/sync-service/snapshot/upload-snapshot.js.map +1 -1
- package/dist/util/log-sanitizer.d.ts.map +1 -1
- package/dist/util/log-sanitizer.js +10 -8
- package/dist/util/log-sanitizer.js.map +1 -1
- package/dist/util/logger.d.ts +2 -0
- package/dist/util/logger.d.ts.map +1 -1
- package/dist/util/logger.js +357 -38
- package/dist/util/logger.js.map +1 -1
- package/dist/util.d.ts +3 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +2 -2
- package/dist/util.js.map +1 -1
- package/package.json +9 -9
|
@@ -32,7 +32,7 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
32
32
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
33
|
done = true;
|
|
34
34
|
};
|
|
35
|
-
import { EXCLUDED_MESSAGE_TYPES,
|
|
35
|
+
import { EVICTION_PROTECTED_MESSAGE_TYPES, EXCLUDED_MESSAGE_TYPES, parsePersistedChatMessage, } from "@superblocksteam/library-shared/types";
|
|
36
36
|
import { CHAT_PAYLOAD_PROMPT_ID_KEY, } from "@superblocksteam/shared";
|
|
37
37
|
import { getErrorMeta } from "../../util/logger.js";
|
|
38
38
|
import llmobs from "../llmobs/index.js";
|
|
@@ -41,7 +41,7 @@ import { recordChatGetMessages } from "./chat-session-store-metrics.js";
|
|
|
41
41
|
import { getLastUserMessage } from "./extract-history.js";
|
|
42
42
|
import { TranscriptBudget, } from "./transcript-budget.js";
|
|
43
43
|
import { ensureTranscriptInstruments, recordTranscriptEviction, recordTranscriptServerLoad, registerTranscriptResidentBytesSource, } from "./transcript-metrics.js";
|
|
44
|
-
import {
|
|
44
|
+
import { sanitizeAiProviderResponse, sanitizeToolOutput } from "./utils.js";
|
|
45
45
|
export function isAiChatMessage(item) {
|
|
46
46
|
return "role" in item && "content" in item;
|
|
47
47
|
}
|
|
@@ -68,24 +68,15 @@ const DEFAULT_MESSAGE_LIMIT = 3000;
|
|
|
68
68
|
*/
|
|
69
69
|
const EVICTION_WARN_THROTTLE_MS = 30_000;
|
|
70
70
|
/**
|
|
71
|
-
* Chat item types that are never evicted from the resident transcript.
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* sessions this budget targets, which re-fires the demo card mid-session.
|
|
79
|
-
* Summaries are protected separately via isAiChatSummary.
|
|
71
|
+
* Chat item types that are never evicted from the resident transcript. The list
|
|
72
|
+
* itself is EVICTION_PROTECTED_MESSAGE_TYPES in library-shared, which carries
|
|
73
|
+
* the rationale; it lives there because the editor's pod-reconcile merge has to
|
|
74
|
+
* exclude these types when it infers this pod's eviction frontier from a
|
|
75
|
+
* payload. Derived into a Set here because isEvictableChatItem is on the
|
|
76
|
+
* per-item path of every enforce() pass. Summaries are protected separately via
|
|
77
|
+
* isAiChatSummary.
|
|
80
78
|
*/
|
|
81
|
-
const EVICTION_PROTECTED_TYPES = new Set(
|
|
82
|
-
"aws_infra_demo",
|
|
83
|
-
"commitRestored",
|
|
84
|
-
"commitRestoring",
|
|
85
|
-
"draftAccepted",
|
|
86
|
-
"draftCommitted",
|
|
87
|
-
"draftRejected",
|
|
88
|
-
]);
|
|
79
|
+
const EVICTION_PROTECTED_TYPES = new Set(EVICTION_PROTECTED_MESSAGE_TYPES.filter((type) => type !== undefined));
|
|
89
80
|
function isEvictableChatItem(item) {
|
|
90
81
|
if (isAiChatSummary(item)) {
|
|
91
82
|
return false;
|
|
@@ -156,594 +147,16 @@ let ChatSessionStore = (() => {
|
|
|
156
147
|
// TODO(ai): consider replacing this with a queue-based approach
|
|
157
148
|
this.inFlightLoadFromServer = Promise.resolve();
|
|
158
149
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (!attachments) {
|
|
168
|
-
return [true, undefined];
|
|
169
|
-
}
|
|
170
|
-
if (typeof attachments !== "object" || !Array.isArray(attachments)) {
|
|
171
|
-
return [false, undefined];
|
|
172
|
-
}
|
|
173
|
-
const validAttachments = attachments
|
|
174
|
-
.map((attachment) => {
|
|
175
|
-
if (typeof attachment !== "object" || !("type" in attachment)) {
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
// Validate image attachment
|
|
179
|
-
if (attachment.type === "image") {
|
|
180
|
-
if (typeof attachment.image !== "string") {
|
|
181
|
-
return undefined;
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
type: attachment.type,
|
|
185
|
-
image: attachment.image,
|
|
186
|
-
fileName: typeof attachment.fileName === "string"
|
|
187
|
-
? attachment.fileName
|
|
188
|
-
: undefined,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
// Validate PDF attachment
|
|
192
|
-
if (attachment.type === "pdf") {
|
|
193
|
-
if (typeof attachment.data !== "string") {
|
|
194
|
-
return undefined;
|
|
195
|
-
}
|
|
196
|
-
return {
|
|
197
|
-
type: attachment.type,
|
|
198
|
-
data: attachment.data,
|
|
199
|
-
fileName: typeof attachment.fileName === "string"
|
|
200
|
-
? attachment.fileName
|
|
201
|
-
: undefined,
|
|
202
|
-
size: attachment.size,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
// Validate archive attachment (zip, tgz, gz)
|
|
206
|
-
if (attachment.type === "archive") {
|
|
207
|
-
if (typeof attachment.data !== "string") {
|
|
208
|
-
return undefined;
|
|
209
|
-
}
|
|
210
|
-
return {
|
|
211
|
-
type: attachment.type,
|
|
212
|
-
data: attachment.data,
|
|
213
|
-
fileName: typeof attachment.fileName === "string"
|
|
214
|
-
? attachment.fileName
|
|
215
|
-
: undefined,
|
|
216
|
-
size: attachment.size,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
const normalizedTextAttachmentType = typeof attachment.content === "string"
|
|
220
|
-
? inferTextAttachmentType({
|
|
221
|
-
attachmentType: attachment.type,
|
|
222
|
-
mimeType: attachment.mimeType,
|
|
223
|
-
fileName: typeof attachment.fileName === "string"
|
|
224
|
-
? attachment.fileName
|
|
225
|
-
: "",
|
|
226
|
-
})
|
|
227
|
-
: null;
|
|
228
|
-
// Validate text attachments and normalize any text-like subtype to the
|
|
229
|
-
// stable server-side text attachment shape.
|
|
230
|
-
if (normalizedTextAttachmentType) {
|
|
231
|
-
if (typeof attachment.content !== "string") {
|
|
232
|
-
return undefined;
|
|
233
|
-
}
|
|
234
|
-
return {
|
|
235
|
-
type: normalizedTextAttachmentType,
|
|
236
|
-
content: attachment.content,
|
|
237
|
-
fileName: typeof attachment.fileName === "string"
|
|
238
|
-
? attachment.fileName
|
|
239
|
-
: undefined,
|
|
240
|
-
mimeType: typeof attachment.mimeType === "string"
|
|
241
|
-
? attachment.mimeType
|
|
242
|
-
: TEXT_ATTACHMENT_MIME_TYPES[normalizedTextAttachmentType],
|
|
243
|
-
size: attachment.size,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
if (attachment.type === "uploaded") {
|
|
247
|
-
if (typeof attachment.url !== "string" ||
|
|
248
|
-
typeof attachment.mediaType !== "string") {
|
|
249
|
-
return undefined;
|
|
250
|
-
}
|
|
251
|
-
return {
|
|
252
|
-
type: "uploaded",
|
|
253
|
-
url: attachment.url,
|
|
254
|
-
signedUrl: typeof attachment.signedUrl === "string"
|
|
255
|
-
? attachment.signedUrl
|
|
256
|
-
: undefined,
|
|
257
|
-
mediaType: attachment.mediaType,
|
|
258
|
-
fileName: typeof attachment.fileName === "string"
|
|
259
|
-
? attachment.fileName
|
|
260
|
-
: undefined,
|
|
261
|
-
label: typeof attachment.label === "string"
|
|
262
|
-
? attachment.label
|
|
263
|
-
: undefined,
|
|
264
|
-
insight: typeof attachment.insight === "string"
|
|
265
|
-
? attachment.insight
|
|
266
|
-
: undefined,
|
|
267
|
-
storageKey: typeof attachment.storageKey === "string"
|
|
268
|
-
? attachment.storageKey
|
|
269
|
-
: undefined,
|
|
270
|
-
signedUrlExpiresAt: typeof attachment.signedUrlExpiresAt === "string"
|
|
271
|
-
? attachment.signedUrlExpiresAt
|
|
272
|
-
: undefined,
|
|
273
|
-
scopeType: attachment.scopeType === "app" || attachment.scopeType === "org"
|
|
274
|
-
? attachment.scopeType
|
|
275
|
-
: undefined,
|
|
276
|
-
applicationId: typeof attachment.applicationId === "string"
|
|
277
|
-
? attachment.applicationId
|
|
278
|
-
: undefined,
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
return undefined;
|
|
282
|
-
})
|
|
283
|
-
.filter(Boolean);
|
|
284
|
-
return [validAttachments.length === attachments.length, validAttachments];
|
|
285
|
-
}
|
|
286
|
-
validateChatMessageV1(payload) {
|
|
287
|
-
try {
|
|
288
|
-
if (!payload || typeof payload !== "object") {
|
|
289
|
-
return null;
|
|
290
|
-
}
|
|
291
|
-
const msg = payload;
|
|
292
|
-
// Validate required fields. Legacy roles "server" and "ai" (written by
|
|
293
|
-
// older server paths such as setApplicationHash for `draftCommitted`
|
|
294
|
-
// messages, and recognized as assistant-like in commitMessage.ts) are
|
|
295
|
-
// coerced to "assistant" so existing chat history keeps rendering.
|
|
296
|
-
if (typeof msg.role !== "string") {
|
|
297
|
-
this.logger.warn(`[ai-service] Invalid message role: ${msg.role}`);
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
const normalizedRole = msg.role === "server" || msg.role === "ai" ? "assistant" : msg.role;
|
|
301
|
-
if (!["user", "assistant", "system"].includes(normalizedRole)) {
|
|
302
|
-
this.logger.warn(`[ai-service] Invalid message role after normalize: ${msg.role}`);
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
msg.role = normalizedRole;
|
|
306
|
-
if (typeof msg.content !== "string") {
|
|
307
|
-
this.logger.warn(`[ai-service] Invalid message content (type=${typeof msg.content})`);
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
if (typeof msg.type !== "string") {
|
|
311
|
-
this.logger.warn(`[ai-service] Invalid message type: ${msg.type}`);
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
|
-
// Validate optional fields with defaults
|
|
315
|
-
const timestamp = typeof msg.timestamp === "number" ? msg.timestamp : Date.now();
|
|
316
|
-
const group = typeof msg.group === "string" ? msg.group : undefined;
|
|
317
|
-
const status = typeof msg.status === "string" ? msg.status : undefined;
|
|
318
|
-
const action = typeof msg.action === "string" ? msg.action : undefined;
|
|
319
|
-
const title = typeof msg.title === "string" ? msg.title : undefined;
|
|
320
|
-
const streaming = typeof msg.streaming === "boolean" ? msg.streaming : undefined;
|
|
321
|
-
const integrations = Array.isArray(msg.integrations)
|
|
322
|
-
? msg.integrations
|
|
323
|
-
: undefined;
|
|
324
|
-
const entities = Array.isArray(msg.entities)
|
|
325
|
-
? msg.entities
|
|
326
|
-
: undefined;
|
|
327
|
-
const [isAttachmentsValid, attachments] = this.validateAttachments(msg.attachments);
|
|
328
|
-
if (!isAttachmentsValid) {
|
|
329
|
-
this.logger.warn(`[ai-service] Invalid attachments`);
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
if (msg.type === "tool") {
|
|
333
|
-
return {
|
|
334
|
-
role: msg.role,
|
|
335
|
-
content: msg.content,
|
|
336
|
-
type: "tool",
|
|
337
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
338
|
-
timestamp,
|
|
339
|
-
status: status,
|
|
340
|
-
action: action,
|
|
341
|
-
args: msg.args,
|
|
342
|
-
tool: msg.tool,
|
|
343
|
-
toolCallId: typeof msg.toolCallId === "string" ? msg.toolCallId : undefined,
|
|
344
|
-
title,
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
else if (msg.type === "tool-result") {
|
|
348
|
-
if (typeof msg.toolCallId !== "string" ||
|
|
349
|
-
typeof msg.toolName !== "string") {
|
|
350
|
-
this.logger.warn(`[ai-service] Invalid tool-result message: missing required fields`);
|
|
351
|
-
return null;
|
|
352
|
-
}
|
|
353
|
-
return {
|
|
354
|
-
role: msg.role,
|
|
355
|
-
content: msg.content || "",
|
|
356
|
-
type: "tool-result",
|
|
357
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
358
|
-
timestamp,
|
|
359
|
-
status: status,
|
|
360
|
-
toolCallId: msg.toolCallId,
|
|
361
|
-
toolName: msg.toolName,
|
|
362
|
-
output: msg.output,
|
|
363
|
-
title,
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
else if (msg.type === "tool-error") {
|
|
367
|
-
if (typeof msg.toolCallId !== "string" ||
|
|
368
|
-
typeof msg.toolName !== "string") {
|
|
369
|
-
this.logger.warn(`[ai-service] Invalid tool-error message: missing required fields`);
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
372
|
-
return {
|
|
373
|
-
role: msg.role,
|
|
374
|
-
content: msg.content || "",
|
|
375
|
-
type: "tool-error",
|
|
376
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
377
|
-
timestamp,
|
|
378
|
-
status: status,
|
|
379
|
-
toolCallId: msg.toolCallId,
|
|
380
|
-
toolName: msg.toolName,
|
|
381
|
-
error: msg.error instanceof Error
|
|
382
|
-
? msg.error.message
|
|
383
|
-
: typeof msg.error === "string"
|
|
384
|
-
? msg.error
|
|
385
|
-
: (JSON.stringify(msg.error, null, 2) ?? "Unknown error"),
|
|
386
|
-
title,
|
|
387
|
-
errorCode: msg.errorCode,
|
|
388
|
-
errorSummary: typeof msg.errorSummary === "string"
|
|
389
|
-
? msg.errorSummary
|
|
390
|
-
: undefined,
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
else if (msg.group === "checklist") {
|
|
394
|
-
if (typeof msg.checklistData !== "object") {
|
|
395
|
-
this.logger.warn(`[ai-service] Invalid checklist data`);
|
|
396
|
-
return null;
|
|
397
|
-
}
|
|
398
|
-
return {
|
|
399
|
-
role: msg.role,
|
|
400
|
-
content: msg.content,
|
|
401
|
-
type: "tool",
|
|
402
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
403
|
-
timestamp,
|
|
404
|
-
group,
|
|
405
|
-
status,
|
|
406
|
-
action,
|
|
407
|
-
checklistData: msg.checklistData,
|
|
408
|
-
title,
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
else if (msg.type === "multi_choice") {
|
|
412
|
-
if (!Array.isArray(msg.choices) || msg.choices.length === 0) {
|
|
413
|
-
this.logger.warn(`[ai-service] Invalid choices for multi_choice message`);
|
|
414
|
-
return null;
|
|
415
|
-
}
|
|
416
|
-
return {
|
|
417
|
-
role: msg.role,
|
|
418
|
-
content: msg.content,
|
|
419
|
-
type: "multi_choice",
|
|
420
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
421
|
-
timestamp,
|
|
422
|
-
choices: msg.choices,
|
|
423
|
-
selectionType: typeof msg.selectionType === "string"
|
|
424
|
-
? msg.selectionType
|
|
425
|
-
: "single",
|
|
426
|
-
title,
|
|
427
|
-
questionType: typeof msg.questionType === "string"
|
|
428
|
-
? msg.questionType
|
|
429
|
-
: undefined,
|
|
430
|
-
subtitle: typeof msg.subtitle === "string" ? msg.subtitle : undefined,
|
|
431
|
-
details: typeof msg.details === "string" ? msg.details : undefined,
|
|
432
|
-
knowledgeCandidates: Array.isArray(msg.knowledgeCandidates)
|
|
433
|
-
? msg.knowledgeCandidates
|
|
434
|
-
: undefined,
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
else if (msg.type === "remember_knowledge_draft") {
|
|
438
|
-
if (!Array.isArray(msg.candidates) || msg.candidates.length === 0) {
|
|
439
|
-
this.logger.warn(`[ai-service] Invalid candidates for remember_knowledge_draft message`);
|
|
440
|
-
return null;
|
|
441
|
-
}
|
|
442
|
-
return {
|
|
443
|
-
role: msg.role,
|
|
444
|
-
content: msg.content,
|
|
445
|
-
type: "remember_knowledge_draft",
|
|
446
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
447
|
-
timestamp,
|
|
448
|
-
candidates: msg.candidates,
|
|
449
|
-
title,
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
else if (msg.type === "multi_choice_response") {
|
|
453
|
-
if (typeof msg.responseToMessageId !== "string") {
|
|
454
|
-
this.logger.warn(`[ai-service] Invalid responseToMessageId for multi_choice_response`);
|
|
455
|
-
return null;
|
|
456
|
-
}
|
|
457
|
-
if (!Array.isArray(msg.selectedChoiceIndices)) {
|
|
458
|
-
this.logger.warn(`[ai-service] Invalid selectedChoiceIndices for multi_choice_response`);
|
|
459
|
-
return null;
|
|
460
|
-
}
|
|
461
|
-
const response = {
|
|
462
|
-
role: msg.role,
|
|
463
|
-
content: msg.content,
|
|
464
|
-
type: "multi_choice_response",
|
|
465
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
466
|
-
timestamp,
|
|
467
|
-
responseToMessageId: msg.responseToMessageId,
|
|
468
|
-
selectedChoiceIndices: msg.selectedChoiceIndices,
|
|
469
|
-
selectedScopes: Array.isArray(msg.selectedScopes)
|
|
470
|
-
? msg.selectedScopes
|
|
471
|
-
: undefined,
|
|
472
|
-
savedFacts: Array.isArray(msg.savedFacts)
|
|
473
|
-
? msg.savedFacts
|
|
474
|
-
: undefined,
|
|
475
|
-
title,
|
|
476
|
-
};
|
|
477
|
-
return response;
|
|
478
|
-
}
|
|
479
|
-
else if (msg.type === "remember_knowledge_draft_response") {
|
|
480
|
-
if (typeof msg.responseToMessageId !== "string") {
|
|
481
|
-
this.logger.warn(`[ai-service] Invalid responseToMessageId for remember_knowledge_draft_response`);
|
|
482
|
-
return null;
|
|
483
|
-
}
|
|
484
|
-
if (!Array.isArray(msg.selectedCandidateIndices)) {
|
|
485
|
-
this.logger.warn(`[ai-service] Invalid selectedCandidateIndices for remember_knowledge_draft_response`);
|
|
486
|
-
return null;
|
|
487
|
-
}
|
|
488
|
-
return {
|
|
489
|
-
role: msg.role,
|
|
490
|
-
content: msg.content,
|
|
491
|
-
type: "remember_knowledge_draft_response",
|
|
492
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
493
|
-
timestamp,
|
|
494
|
-
responseToMessageId: msg.responseToMessageId,
|
|
495
|
-
selectedCandidateIndices: msg.selectedCandidateIndices,
|
|
496
|
-
selectedScopes: Array.isArray(msg.selectedScopes)
|
|
497
|
-
? msg.selectedScopes
|
|
498
|
-
: undefined,
|
|
499
|
-
savedFacts: Array.isArray(msg.savedFacts)
|
|
500
|
-
? msg.savedFacts
|
|
501
|
-
: undefined,
|
|
502
|
-
title,
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
else if (msg.type === "confirm") {
|
|
506
|
-
return {
|
|
507
|
-
role: msg.role,
|
|
508
|
-
content: msg.content,
|
|
509
|
-
type: "confirm",
|
|
510
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
511
|
-
timestamp,
|
|
512
|
-
knowledgeEntry: typeof msg.knowledgeEntry === "object" &&
|
|
513
|
-
msg.knowledgeEntry !== null
|
|
514
|
-
? msg.knowledgeEntry
|
|
515
|
-
: undefined,
|
|
516
|
-
title,
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
else if (msg.type === "searchable_dropdown") {
|
|
520
|
-
if (!Array.isArray(msg.options) || msg.options.length === 0) {
|
|
521
|
-
this.logger.warn(`[ai-service] Invalid options for searchable_dropdown message`);
|
|
522
|
-
return null;
|
|
523
|
-
}
|
|
524
|
-
return {
|
|
525
|
-
role: msg.role,
|
|
526
|
-
content: msg.content,
|
|
527
|
-
type: "searchable_dropdown",
|
|
528
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
529
|
-
timestamp,
|
|
530
|
-
options: msg.options,
|
|
531
|
-
placeholder: typeof msg.placeholder === "string" ? msg.placeholder : undefined,
|
|
532
|
-
title,
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
else if (msg.type === "searchable_dropdown_response") {
|
|
536
|
-
if (typeof msg.responseToMessageId !== "string") {
|
|
537
|
-
this.logger.warn(`[ai-service] Invalid responseToMessageId for searchable_dropdown_response`);
|
|
538
|
-
return null;
|
|
539
|
-
}
|
|
540
|
-
if (typeof msg.selectedValue !== "string") {
|
|
541
|
-
this.logger.warn(`[ai-service] Invalid selectedValue for searchable_dropdown_response`);
|
|
542
|
-
return null;
|
|
543
|
-
}
|
|
544
|
-
return {
|
|
545
|
-
role: msg.role,
|
|
546
|
-
content: msg.content,
|
|
547
|
-
type: "searchable_dropdown_response",
|
|
548
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
549
|
-
timestamp,
|
|
550
|
-
responseToMessageId: msg.responseToMessageId,
|
|
551
|
-
selectedValue: msg.selectedValue,
|
|
552
|
-
selectedLabel: typeof msg.selectedLabel === "string"
|
|
553
|
-
? msg.selectedLabel
|
|
554
|
-
: msg.selectedValue,
|
|
555
|
-
title,
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
else if (msg.type === "confirm_response") {
|
|
559
|
-
if (typeof msg.responseToMessageId !== "string") {
|
|
560
|
-
this.logger.warn(`[ai-service] Invalid responseToMessageId for confirm_response`);
|
|
561
|
-
return null;
|
|
562
|
-
}
|
|
563
|
-
return {
|
|
564
|
-
role: msg.role,
|
|
565
|
-
content: msg.content,
|
|
566
|
-
type: "confirm_response",
|
|
567
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
568
|
-
timestamp,
|
|
569
|
-
responseToMessageId: msg.responseToMessageId,
|
|
570
|
-
approved: Boolean(msg.approved),
|
|
571
|
-
selectedScopes: Array.isArray(msg.selectedScopes)
|
|
572
|
-
? msg.selectedScopes
|
|
573
|
-
: undefined,
|
|
574
|
-
savedFacts: Array.isArray(msg.savedFacts)
|
|
575
|
-
? msg.savedFacts
|
|
576
|
-
: undefined,
|
|
577
|
-
title,
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
|
-
else if (msg.type === "plan_response") {
|
|
581
|
-
if (typeof msg.responseToMessageId !== "string") {
|
|
582
|
-
this.logger.warn(`[ai-service] Invalid responseToMessageId for plan_response`);
|
|
583
|
-
return null;
|
|
584
|
-
}
|
|
585
|
-
return {
|
|
586
|
-
role: msg.role,
|
|
587
|
-
content: msg.content,
|
|
588
|
-
type: "plan_response",
|
|
589
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
590
|
-
timestamp,
|
|
591
|
-
responseToMessageId: msg.responseToMessageId,
|
|
592
|
-
title,
|
|
593
|
-
approved: typeof msg.approved === "boolean" ? msg.approved : undefined,
|
|
594
|
-
enableTesting: typeof msg.enableTesting === "boolean"
|
|
595
|
-
? msg.enableTesting
|
|
596
|
-
: undefined,
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
else if (msg.type === "test_run_start") {
|
|
600
|
-
if (typeof msg.testRunId !== "string") {
|
|
601
|
-
this.logger.warn(`[ai-service] Invalid test_run_start message: missing testRunId`);
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
return {
|
|
605
|
-
role: msg.role,
|
|
606
|
-
content: msg.content,
|
|
607
|
-
type: "test_run_start",
|
|
608
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
609
|
-
timestamp,
|
|
610
|
-
testRunId: msg.testRunId,
|
|
611
|
-
header: typeof msg.header === "string" ? msg.header : "End-to-end Testing",
|
|
612
|
-
testCases: Array.isArray(msg.testCases) ? msg.testCases : undefined,
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
else if (msg.type === "test_case_update") {
|
|
616
|
-
if (typeof msg.testRunId !== "string") {
|
|
617
|
-
this.logger.warn(`[ai-service] Invalid test_case_update message: missing testRunId`);
|
|
618
|
-
return null;
|
|
619
|
-
}
|
|
620
|
-
if (typeof msg.testCaseId !== "string") {
|
|
621
|
-
this.logger.warn(`[ai-service] Invalid test_case_update message: missing testCaseId`);
|
|
622
|
-
return null;
|
|
623
|
-
}
|
|
624
|
-
return {
|
|
625
|
-
role: msg.role,
|
|
626
|
-
content: msg.content,
|
|
627
|
-
type: "test_case_update",
|
|
628
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
629
|
-
timestamp,
|
|
630
|
-
testRunId: msg.testRunId,
|
|
631
|
-
testCaseId: msg.testCaseId,
|
|
632
|
-
testCaseStatus: msg.testCaseStatus,
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
else if (msg.type === "test_run_end") {
|
|
636
|
-
if (typeof msg.testRunId !== "string") {
|
|
637
|
-
this.logger.warn(`[ai-service] Invalid test_run_end message: missing testRunId`);
|
|
638
|
-
return null;
|
|
639
|
-
}
|
|
640
|
-
return {
|
|
641
|
-
role: msg.role,
|
|
642
|
-
content: msg.content,
|
|
643
|
-
type: "test_run_end",
|
|
644
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
645
|
-
timestamp,
|
|
646
|
-
testRunId: msg.testRunId,
|
|
647
|
-
testStatus: typeof msg.testStatus === "string"
|
|
648
|
-
? msg.testStatus
|
|
649
|
-
: "completed",
|
|
650
|
-
summary: typeof msg.summary === "string" ? msg.summary : undefined,
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
else if (msg.type === "retry_notification") {
|
|
654
|
-
return {
|
|
655
|
-
role: msg.role,
|
|
656
|
-
content: msg.content,
|
|
657
|
-
type: "retry_notification",
|
|
658
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
659
|
-
timestamp,
|
|
660
|
-
retryType: msg.retryType,
|
|
661
|
-
attempt: typeof msg.attempt === "number" ? msg.attempt : undefined,
|
|
662
|
-
delaySeconds: typeof msg.delaySeconds === "number" ? msg.delaySeconds : undefined,
|
|
663
|
-
fromProvider: typeof msg.fromProvider === "string" ? msg.fromProvider : undefined,
|
|
664
|
-
toProvider: typeof msg.toProvider === "string" ? msg.toProvider : undefined,
|
|
665
|
-
reason: typeof msg.reason === "string" ? msg.reason : undefined,
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
else if (msg.type === "knowledge") {
|
|
669
|
-
return {
|
|
670
|
-
role: msg.role,
|
|
671
|
-
content: msg.content,
|
|
672
|
-
type: "knowledge",
|
|
673
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
674
|
-
timestamp,
|
|
675
|
-
status,
|
|
676
|
-
facts: msg.facts,
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
else if (msg.type === "app_knowledge_saved") {
|
|
680
|
-
return {
|
|
681
|
-
role: msg.role,
|
|
682
|
-
content: msg.content,
|
|
683
|
-
type: "app_knowledge_saved",
|
|
684
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
685
|
-
timestamp,
|
|
686
|
-
knowledgeCount: typeof msg.knowledgeCount === "number" ? msg.knowledgeCount : 0,
|
|
687
|
-
responseToMessageId: typeof msg.responseToMessageId === "string"
|
|
688
|
-
? msg.responseToMessageId
|
|
689
|
-
: undefined,
|
|
690
|
-
savedFacts: Array.isArray(msg.savedFacts)
|
|
691
|
-
? msg.savedFacts
|
|
692
|
-
: undefined,
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
else if (msg.type === "next_steps") {
|
|
696
|
-
return {
|
|
697
|
-
role: msg.role,
|
|
698
|
-
content: msg.content,
|
|
699
|
-
type: "next_steps",
|
|
700
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
701
|
-
timestamp,
|
|
702
|
-
nextSteps: Array.isArray(msg.nextSteps) ? msg.nextSteps : [],
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
const baseMessage = {
|
|
706
|
-
role: msg.role,
|
|
707
|
-
content: msg.content,
|
|
708
|
-
type: msg.type,
|
|
709
|
-
id: typeof msg.id === "string" ? msg.id : undefined,
|
|
710
|
-
timestamp,
|
|
711
|
-
group,
|
|
712
|
-
status: status,
|
|
713
|
-
action: action,
|
|
714
|
-
attachments,
|
|
715
|
-
title,
|
|
716
|
-
};
|
|
717
|
-
if (msg.type === "plan") {
|
|
718
|
-
if (streaming !== undefined) {
|
|
719
|
-
baseMessage.streaming = streaming;
|
|
720
|
-
}
|
|
721
|
-
if (integrations) {
|
|
722
|
-
baseMessage.integrations = integrations;
|
|
723
|
-
}
|
|
724
|
-
if (entities) {
|
|
725
|
-
baseMessage.entities = entities;
|
|
726
|
-
}
|
|
727
|
-
if (msg.includesFreshDatabase === true) {
|
|
728
|
-
baseMessage.includesFreshDatabase = true;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
// Preserve commitId for commitRestored, commitRestoring, and draftCommitted messages
|
|
732
|
-
if ((msg.type === "commitRestored" ||
|
|
733
|
-
msg.type === "commitRestoring" ||
|
|
734
|
-
msg.type === "draftCommitted") &&
|
|
735
|
-
typeof msg.commitId === "string") {
|
|
736
|
-
baseMessage.commitId =
|
|
737
|
-
msg.commitId;
|
|
738
|
-
}
|
|
739
|
-
return baseMessage;
|
|
740
|
-
}
|
|
741
|
-
catch (error) {
|
|
742
|
-
this.logger.error("[ai-service] Failed to validate message payload", getErrorMeta(error));
|
|
743
|
-
return null;
|
|
744
|
-
}
|
|
150
|
+
validateChatMessageV1(payload, fallbackTimestamp) {
|
|
151
|
+
// Validation lives in library-shared so the editor's durable reader of the
|
|
152
|
+
// same rows accepts and normalizes exactly what this transcript does.
|
|
153
|
+
return parsePersistedChatMessage(payload, {
|
|
154
|
+
fallbackTimestamp,
|
|
155
|
+
onInvalid: (detail) => this.logger.warn(`[ai-service] ${detail}`),
|
|
156
|
+
onError: (error) => this.logger.error("[ai-service] Failed to validate message payload", getErrorMeta(error)),
|
|
157
|
+
});
|
|
745
158
|
}
|
|
746
|
-
validateChatSummaryV1(payload) {
|
|
159
|
+
validateChatSummaryV1(payload, fallbackTimestamp) {
|
|
747
160
|
try {
|
|
748
161
|
if (!payload || typeof payload !== "object") {
|
|
749
162
|
return null;
|
|
@@ -779,7 +192,9 @@ let ChatSessionStore = (() => {
|
|
|
779
192
|
return null;
|
|
780
193
|
}
|
|
781
194
|
// Validate optional fields with defaults
|
|
782
|
-
const timestamp =
|
|
195
|
+
const timestamp = Number.isFinite(summary.timestamp)
|
|
196
|
+
? summary.timestamp
|
|
197
|
+
: fallbackTimestamp;
|
|
783
198
|
return {
|
|
784
199
|
summary: summary.summary,
|
|
785
200
|
relevantFilePaths: summary.relevantFilePaths,
|
|
@@ -794,14 +209,14 @@ let ChatSessionStore = (() => {
|
|
|
794
209
|
return null;
|
|
795
210
|
}
|
|
796
211
|
}
|
|
797
|
-
validateChatItemV1(payload) {
|
|
212
|
+
validateChatItemV1(payload, fallbackTimestamp) {
|
|
798
213
|
// First try to validate as a message
|
|
799
|
-
const messageResult = this.validateChatMessageV1(payload);
|
|
214
|
+
const messageResult = this.validateChatMessageV1(payload, fallbackTimestamp);
|
|
800
215
|
if (messageResult) {
|
|
801
216
|
return messageResult;
|
|
802
217
|
}
|
|
803
218
|
// If not a valid message, try to validate as a summary
|
|
804
|
-
const summaryResult = this.validateChatSummaryV1(payload);
|
|
219
|
+
const summaryResult = this.validateChatSummaryV1(payload, fallbackTimestamp);
|
|
805
220
|
if (summaryResult) {
|
|
806
221
|
return summaryResult;
|
|
807
222
|
}
|
|
@@ -855,7 +270,15 @@ let ChatSessionStore = (() => {
|
|
|
855
270
|
});
|
|
856
271
|
const rawMessages = data?.messages ?? [];
|
|
857
272
|
const mapped = rawMessages.map((msg) => {
|
|
858
|
-
|
|
273
|
+
// The row's own created column, not Date.now(). This value is what
|
|
274
|
+
// the sort below orders on when a payload carries no timestamp, so
|
|
275
|
+
// inventing one here filed old rows at the end of history on every
|
|
276
|
+
// load. It is also half of the composite key the editor dedupes
|
|
277
|
+
// id-less rows on, which the durable reader derives the same way.
|
|
278
|
+
const persistedAt = msg.created
|
|
279
|
+
? Date.parse(msg.created)
|
|
280
|
+
: Date.now();
|
|
281
|
+
const chatItem = this.validateChatItemV1(msg.chatPayload, Number.isFinite(persistedAt) ? persistedAt : Date.now());
|
|
859
282
|
if (chatItem && isAiChatMessage(chatItem)) {
|
|
860
283
|
chatItem.authorEmail = msg.authorEmail;
|
|
861
284
|
chatItem.authorName = msg.authorName;
|