@myrialabs/clopen 0.4.49 → 0.4.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/README.md +2 -1
- package/backend/chat/attachments.test.ts +106 -17
- package/backend/chat/attachments.ts +131 -34
- package/backend/chat/background-wait.test.ts +28 -0
- package/backend/chat/engine-handoff.ts +42 -6
- package/backend/chat/message-pages.test.ts +17 -0
- package/backend/chat/message-pages.ts +6 -2
- package/backend/chat/stream-manager.ts +114 -19
- package/backend/containers/actions.ts +22 -0
- package/backend/control/actions/projects.ts +93 -37
- package/backend/control/folders.test.ts +27 -2
- package/backend/control/index.ts +2 -1
- package/backend/database/migrations/056_support_mssql_driver.ts +7 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +7 -0
- package/backend/database/migrations/086_single_owner.ts +66 -73
- package/backend/database/migrations/088_create_messages_fts_map.ts +52 -0
- package/backend/database/migrations/089_add_memory_layout_tiles.ts +58 -0
- package/backend/database/migrations/090_create_storage_tables.ts +83 -0
- package/backend/database/migrations/index.ts +25 -2
- package/backend/database/queries/graph-queries.ts +392 -135
- package/backend/database/queries/integration-queries.ts +10 -0
- package/backend/database/queries/memory-queue-queries.ts +11 -0
- package/backend/database/queries/message-fts.test.ts +120 -0
- package/backend/database/queries/message-queries.ts +45 -9
- package/backend/database/queries/project-queries.ts +6 -0
- package/backend/database/queries/session-queries.ts +6 -2
- package/backend/database/queries/utils-queries.ts +3 -0
- package/backend/database/utils/migration-runner.test.ts +196 -0
- package/backend/database/utils/migration-runner.ts +61 -16
- package/backend/database/utils/seeder-runner.ts +22 -16
- package/backend/engine/adapters/claude/environment.ts +4 -0
- package/backend/engine/adapters/claude/input-gate.test.ts +59 -0
- package/backend/engine/adapters/claude/input-gate.ts +74 -0
- package/backend/engine/adapters/claude/message-converter.test.ts +16 -0
- package/backend/engine/adapters/claude/message-converter.ts +8 -0
- package/backend/engine/adapters/claude/stream.ts +20 -0
- package/backend/engine/adapters/cursor/environment.ts +1 -1
- package/backend/engine/adapters/qwen/session-store.ts +10 -1
- package/backend/engine/types.ts +7 -0
- package/backend/git/identity/cli.ts +35 -0
- package/backend/git/identity/env.test.ts +52 -1
- package/backend/git/identity/env.ts +69 -10
- package/backend/git/identity/index.ts +25 -6
- package/backend/git/identity/resolve.ts +2 -1
- package/backend/git/identity/scope-config.test.ts +7 -4
- package/backend/git/identity/scope-config.ts +13 -7
- package/backend/git-hosts/accounts.ts +106 -0
- package/backend/git-hosts/auth/client-ids.ts +34 -0
- package/backend/git-hosts/auth/connect.ts +110 -0
- package/backend/git-hosts/auth/endpoints.ts +130 -0
- package/backend/git-hosts/auth/flows.ts +355 -0
- package/backend/git-hosts/auth/local.ts +152 -0
- package/backend/git-hosts/ci.ts +18 -0
- package/backend/git-hosts/cli.test.ts +82 -0
- package/backend/git-hosts/cli.ts +342 -0
- package/backend/git-hosts/credentials.ts +173 -0
- package/backend/git-hosts/git-credential.ts +30 -0
- package/backend/git-hosts/health.ts +39 -0
- package/backend/git-hosts/http.ts +174 -0
- package/backend/git-hosts/index.ts +34 -0
- package/backend/git-hosts/providers/bitbucket.ts +186 -0
- package/backend/git-hosts/providers/gitea.ts +208 -0
- package/backend/git-hosts/providers/github.ts +270 -0
- package/backend/git-hosts/providers/gitlab-client.ts +70 -0
- package/backend/git-hosts/providers/gitlab.ts +285 -0
- package/backend/git-hosts/providers/locators.test.ts +68 -0
- package/backend/git-hosts/registry.ts +50 -0
- package/backend/git-hosts/service.ts +432 -0
- package/backend/git-hosts/types.ts +82 -0
- package/backend/git-hosts/urls.test.ts +42 -0
- package/backend/git-hosts/urls.ts +69 -0
- package/backend/index.ts +84 -17
- package/backend/integrations/accounts.ts +50 -3
- package/backend/integrations/registry/define.ts +9 -0
- package/backend/integrations/registry/index.ts +11 -0
- package/backend/integrations/registry/providers/bitbucket.ts +51 -0
- package/backend/integrations/registry/providers/gitea.ts +53 -0
- package/backend/integrations/registry/providers/github.ts +24 -7
- package/backend/integrations/registry/providers/gitlab.ts +57 -0
- package/backend/integrations/registry/types.ts +13 -1
- package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +115 -31
- package/backend/mcp/internal/servers/browser-automation/description.ts +5 -0
- package/backend/memory/README.md +7 -4
- package/backend/memory/layout.test.ts +377 -0
- package/backend/memory/layout.ts +1029 -265
- package/backend/memory/view.ts +257 -386
- package/backend/mentions/diff.ts +63 -0
- package/backend/mentions/index.ts +109 -0
- package/backend/mentions/mentions.test.ts +27 -0
- package/backend/mentions/shared.ts +82 -0
- package/backend/mentions/sources/ai-changes.ts +140 -0
- package/backend/mentions/sources/chats.ts +122 -0
- package/backend/mentions/sources/database.ts +211 -0
- package/backend/mentions/sources/files.ts +240 -0
- package/backend/mentions/sources/git.ts +308 -0
- package/backend/mentions/sources/notes-memory.ts +121 -0
- package/backend/mentions/sources/ops.ts +125 -0
- package/backend/mentions/sources/preview.ts +153 -0
- package/backend/mentions/sources/projects.ts +114 -0
- package/backend/mentions/sources/system.ts +135 -0
- package/backend/mentions/sources/terminal.ts +50 -0
- package/backend/mentions/types.ts +75 -0
- package/backend/preview/browser/bot-check-frames.test.ts +49 -0
- package/backend/preview/browser/bot-check-frames.ts +66 -0
- package/backend/preview/browser/browser-dialog-handler.ts +6 -5
- package/backend/preview/browser/browser-host-bridge.ts +4 -2
- package/backend/preview/browser/browser-native-ui-handler.ts +21 -0
- package/backend/preview/browser/browser-pool.ts +26 -17
- package/backend/preview/browser/browser-preview-service.ts +164 -2
- package/backend/preview/browser/browser-screenshot.test.ts +113 -0
- package/backend/preview/browser/browser-screenshot.ts +396 -0
- package/backend/preview/browser/browser-tab-manager.ts +35 -186
- package/backend/preview/browser/browser-video-capture.ts +12 -17
- package/backend/preview/browser/element-describe.ts +125 -0
- package/backend/preview/browser/page-binding.ts +141 -0
- package/backend/preview/browser/screenshot-files.test.ts +117 -0
- package/backend/preview/browser/screenshot-files.ts +134 -0
- package/backend/preview/browser/user-agent.test.ts +25 -0
- package/backend/preview/browser/user-agent.ts +100 -0
- package/backend/project/status-manager.ts +4 -2
- package/backend/projects/engine-transcripts.ts +153 -0
- package/backend/projects/folder-guard.ts +55 -0
- package/backend/projects/move.test.ts +208 -0
- package/backend/projects/move.ts +277 -0
- package/backend/projects/project-cleanup.integration.test.ts +3 -1
- package/backend/projects/project-cleanup.ts +10 -0
- package/backend/storage/actions.ts +260 -0
- package/backend/storage/chats.test.ts +57 -0
- package/backend/storage/chats.ts +170 -0
- package/backend/storage/database.ts +105 -0
- package/backend/storage/engine-homes.ts +145 -0
- package/backend/storage/fs-size.ts +111 -0
- package/backend/storage/history.ts +39 -0
- package/backend/storage/policy.ts +156 -0
- package/backend/storage/preview-profiles.ts +169 -0
- package/backend/storage/purge.ts +158 -0
- package/backend/storage/scanner.ts +339 -0
- package/backend/storage/session-index.ts +208 -0
- package/backend/storage/snapshots.ts +99 -0
- package/backend/storage/storage-flow.test.ts +137 -0
- package/backend/storage/transcripts/aliases.ts +75 -0
- package/backend/storage/transcripts/claude-dedupe.test.ts +101 -0
- package/backend/storage/transcripts/claude-dedupe.ts +152 -0
- package/backend/storage/transcripts/claude.ts +155 -0
- package/backend/storage/transcripts/cursor.ts +165 -0
- package/backend/storage/transcripts/file-stores.ts +224 -0
- package/backend/storage/transcripts/index.ts +207 -0
- package/backend/storage/transcripts/opencode.ts +124 -0
- package/backend/storage/transcripts/references.ts +42 -0
- package/backend/storage/transcripts/types.ts +58 -0
- package/backend/storage/worktrees.ts +114 -0
- package/backend/terminal/ptykit.ts +25 -0
- package/backend/update/registry.ts +24 -0
- package/backend/update/release-notes.test.ts +110 -0
- package/backend/update/release-notes.ts +132 -0
- package/backend/update/restart.ts +159 -0
- package/backend/utils/env.test.ts +64 -0
- package/backend/utils/env.ts +23 -55
- package/backend/utils/port-utils.ts +13 -0
- package/backend/work/index.ts +13 -2
- package/backend/work/providers/github/actions-logs.ts +1 -1
- package/backend/work/providers/github/adapter.ts +32 -1
- package/backend/work/providers/github/client.ts +7 -3
- package/backend/work/providers/gitlab/adapter.ts +770 -0
- package/backend/work/providers/gitlab/system-notes.test.ts +24 -0
- package/backend/work/service.ts +60 -36
- package/backend/work/start-work.ts +1 -1
- package/backend/work/types.ts +4 -0
- package/backend/worktrees/index.ts +1 -0
- package/backend/worktrees/service.ts +23 -2
- package/backend/ws/chat/composer.ts +47 -6
- package/backend/ws/chat/stream.ts +19 -10
- package/backend/ws/files/search.ts +1 -1
- package/backend/ws/files/write.ts +27 -0
- package/backend/ws/hosting/index.ts +231 -0
- package/backend/ws/index.ts +12 -2
- package/backend/ws/integrations/crud.ts +31 -5
- package/backend/ws/integrations/hosting-auth.ts +227 -0
- package/backend/ws/integrations/index.ts +2 -0
- package/backend/ws/memory/crud.ts +118 -81
- package/backend/ws/mentions/index.ts +81 -0
- package/backend/ws/messages/crud.ts +3 -1
- package/backend/ws/preview/browser/screenshot.ts +184 -0
- package/backend/ws/preview/index.ts +23 -0
- package/backend/ws/projects/crud.ts +66 -58
- package/backend/ws/sessions/crud.ts +7 -95
- package/backend/ws/snapshot/changes.ts +3 -3
- package/backend/ws/storage/index.ts +102 -0
- package/backend/ws/system/index.ts +7 -0
- package/backend/ws/system/operations.ts +125 -69
- package/backend/ws/work/context.ts +3 -4
- package/backend/ws/work/crud.ts +33 -0
- package/backend/ws/work/schemas.ts +4 -1
- package/bin/clopen.ts +18 -18
- package/dist/assets/{index-DD0-3EWg.js → index-B9rHDvjg.js} +1 -1
- package/dist/assets/index-B9rHDvjg.js.br +0 -0
- package/dist/assets/index-B9rHDvjg.js.gz +0 -0
- package/dist/assets/{index-CrVWZH_D.js → index-DFlwOd7k.js} +1 -1
- package/dist/assets/index-DFlwOd7k.js.br +0 -0
- package/dist/assets/index-DFlwOd7k.js.gz +0 -0
- package/dist/assets/main-Bz_brxxS.css +1 -0
- package/dist/assets/main-Bz_brxxS.css.br +0 -0
- package/dist/assets/main-Bz_brxxS.css.gz +0 -0
- package/dist/assets/main-DRcX9SHx.js +1273 -0
- package/dist/assets/main-DRcX9SHx.js.br +0 -0
- package/dist/assets/main-DRcX9SHx.js.gz +0 -0
- package/dist/assets/pdf-DfwfQPLy.js +57 -0
- package/dist/assets/pdf-DfwfQPLy.js.br +0 -0
- package/dist/assets/pdf-DfwfQPLy.js.gz +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.br +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.gz +0 -0
- package/dist/assets/pdf.worker.min-BOrSNwfp.js +1 -0
- package/dist/index.html +2 -2
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-H.bcmap +6 -0
- package/dist/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/LICENSE +36 -0
- package/dist/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/vendor/pdfjs/iccs/LICENSE +116 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QUICKJS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QUICKJS +22 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js +16 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.gz +0 -0
- package/package.json +8 -9
- package/scripts/start.ts +21 -4
- package/shared/constants/binary-extensions.ts +20 -4
- package/shared/constants/support.test.ts +27 -0
- package/shared/constants/support.ts +79 -0
- package/shared/constants/tool-icons.ts +7 -1
- package/shared/types/database/schema.ts +6 -0
- package/shared/types/git-hosting.ts +241 -0
- package/shared/types/integrations.ts +51 -1
- package/shared/types/memory.ts +96 -73
- package/shared/types/mentions.ts +96 -0
- package/shared/types/release-notes.ts +31 -0
- package/shared/types/storage.ts +175 -0
- package/shared/types/stores/settings.ts +16 -0
- package/shared/types/unified/index.ts +2 -0
- package/shared/types/unified/message.ts +26 -1
- package/shared/types/unified/stream.ts +22 -1
- package/shared/types/unified/tool.ts +4 -0
- package/shared/types/work.ts +6 -0
- package/shared/utils/attachment-mentions.test.ts +39 -0
- package/shared/utils/attachment-mentions.ts +100 -0
- package/shared/utils/context-document.test.ts +53 -0
- package/shared/utils/context-document.ts +226 -0
- package/shared/utils/device-frame.test.ts +73 -0
- package/shared/utils/device-frame.ts +320 -0
- package/shared/utils/fuzzy.ts +79 -0
- package/shared/utils/launcher-fingerprint.test.ts +73 -0
- package/shared/utils/launcher-fingerprint.ts +108 -0
- package/shared/utils/logger.ts +2 -0
- package/shared/utils/page-colors.test.ts +17 -0
- package/shared/utils/page-colors.ts +24 -0
- package/shared/utils/process-supervisor.test.ts +88 -1
- package/shared/utils/process-supervisor.ts +123 -29
- package/shared/utils/process-tree.ts +99 -0
- package/shared/utils/restart-intent.test.ts +57 -0
- package/shared/utils/restart-intent.ts +80 -0
- package/shared/utils/semver.test.ts +33 -0
- package/shared/utils/semver.ts +35 -0
- package/shared/utils/supervised-child.ts +44 -0
- package/shared/utils/supervisor-protocol.ts +20 -0
- package/.env.example +0 -9
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js +0 -1
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.br +0 -0
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.gz +0 -0
- package/dist/assets/index-CrVWZH_D.js.br +0 -0
- package/dist/assets/index-CrVWZH_D.js.gz +0 -0
- package/dist/assets/index-DD0-3EWg.js.br +0 -0
- package/dist/assets/index-DD0-3EWg.js.gz +0 -0
- package/dist/assets/main-D2_TmcwQ.js +0 -1240
- package/dist/assets/main-D2_TmcwQ.js.br +0 -0
- package/dist/assets/main-D2_TmcwQ.js.gz +0 -0
- package/dist/assets/main-Yucigcmf.css +0 -1
- package/dist/assets/main-Yucigcmf.css.br +0 -0
- package/dist/assets/main-Yucigcmf.css.gz +0 -0
|
@@ -11,6 +11,13 @@ import type { ActionDef } from './types';
|
|
|
11
11
|
import { commonFields } from './shared';
|
|
12
12
|
import { analyzePage } from './dom-analyze';
|
|
13
13
|
import { resolveWritePath } from '../paths';
|
|
14
|
+
import {
|
|
15
|
+
DEFAULT_JPEG_QUALITY,
|
|
16
|
+
type CapturedScreenshot,
|
|
17
|
+
type ScreenshotTarget
|
|
18
|
+
} from '$backend/preview/browser/browser-screenshot';
|
|
19
|
+
import { gitIgnoreState } from '$backend/preview/browser/screenshot-files';
|
|
20
|
+
import type { FrameSpec } from '$shared/utils/device-frame';
|
|
14
21
|
|
|
15
22
|
export const find: ActionDef = {
|
|
16
23
|
type: 'find',
|
|
@@ -90,18 +97,48 @@ export const analyzeDom: ActionDef = {
|
|
|
90
97
|
}
|
|
91
98
|
};
|
|
92
99
|
|
|
100
|
+
const DEVICES = ['mobile', 'tablet', 'laptop', 'desktop'] as const;
|
|
101
|
+
|
|
102
|
+
/** `shots/home.png` → `shots/home-mobile.png`, one file per device. */
|
|
103
|
+
function perDevicePath(saveTo: string, device: string, extension: string): string {
|
|
104
|
+
const dot = saveTo.lastIndexOf('.');
|
|
105
|
+
const stem = dot > saveTo.lastIndexOf('/') ? saveTo.slice(0, dot) : saveTo;
|
|
106
|
+
return `${stem}-${device}.${extension}`;
|
|
107
|
+
}
|
|
108
|
+
|
|
93
109
|
export const screenshot: ActionDef = {
|
|
94
110
|
type: 'screenshot',
|
|
95
111
|
kind: 'control',
|
|
96
112
|
activity: 'Taking a screenshot',
|
|
97
|
-
doc: `screenshot {fullPage?, selector?, format?, quality?, saveTo?, return?} — capture the page.
|
|
113
|
+
doc: `screenshot {fullPage?, selector?, point?, region?, devices?, deviceFrame?, format?, quality?, saveTo?, return?} — capture the page.
|
|
98
114
|
Needed for what the DOM cannot express: canvases, charts, iframes, captchas, and any visual check of layout or styling.
|
|
99
|
-
|
|
115
|
+
What to capture — at most one of: fullPage (whole scrollable page), selector (one element), point {x,y,depth?} (the element under a viewport point, depth ancestors up), region {x,y,width,height} (a viewport rectangle), devices (the page laid out on each listed device — mobile, tablet, laptop, desktop — in a hidden page, without touching the tab). Default: the visible viewport.
|
|
116
|
+
deviceFrame draws the device mockup around a viewport or devices capture, as the user's preview shows it.
|
|
117
|
+
saveTo writes a file under the project directory (with devices, one file per device: name-mobile.png …); with return:"file" the image is not sent back at all, which is what makes "capture twenty pages" affordable.
|
|
100
118
|
format:"jpeg" with quality is much smaller than the default PNG when only the gist matters.`,
|
|
101
119
|
schema: z.object({
|
|
102
120
|
type: z.literal('screenshot'),
|
|
103
121
|
fullPage: z.boolean().optional().describe('Capture the whole scrollable page instead of the viewport.'),
|
|
104
122
|
selector: z.string().optional().describe('Capture just this element.'),
|
|
123
|
+
point: z
|
|
124
|
+
.object({
|
|
125
|
+
x: z.number(),
|
|
126
|
+
y: z.number(),
|
|
127
|
+
depth: z.number().int().min(0).optional().describe('Ancestors to step up from the innermost element (default 0).')
|
|
128
|
+
})
|
|
129
|
+
.optional()
|
|
130
|
+
.describe('Capture the element under this viewport point.'),
|
|
131
|
+
region: z
|
|
132
|
+
.object({ x: z.number(), y: z.number(), width: z.number().positive(), height: z.number().positive() })
|
|
133
|
+
.optional()
|
|
134
|
+
.describe('Capture this rectangle of the viewport, in CSS pixels.'),
|
|
135
|
+
devices: z
|
|
136
|
+
.array(z.enum(DEVICES))
|
|
137
|
+
.min(1)
|
|
138
|
+
.max(4)
|
|
139
|
+
.optional()
|
|
140
|
+
.describe('Capture the page as laid out on each of these devices.'),
|
|
141
|
+
deviceFrame: z.boolean().optional().describe('Draw the device mockup around a viewport or devices capture.'),
|
|
105
142
|
format: z.enum(['png', 'jpeg']).optional().describe('Image format (default: png).'),
|
|
106
143
|
quality: z.number().int().min(1).max(100).optional().describe('JPEG quality (default: 80). Ignored for PNG.'),
|
|
107
144
|
saveTo: z.string().optional().describe('Project-relative path to write the image to.'),
|
|
@@ -110,36 +147,85 @@ export const screenshot: ActionDef = {
|
|
|
110
147
|
}),
|
|
111
148
|
run: async (args, ctx) => {
|
|
112
149
|
const format = args.format ?? 'png';
|
|
150
|
+
const options = { format, quality: args.quality ?? DEFAULT_JPEG_QUALITY } as const;
|
|
113
151
|
const mode = args.return ?? (args.saveTo ? 'both' : 'inline');
|
|
114
152
|
|
|
115
153
|
if (mode !== 'inline' && !args.saveTo) throw new Error('return:"file"/"both" needs saveTo');
|
|
116
154
|
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
155
|
+
const targets = [args.fullPage, args.selector, args.point, args.region, args.devices].filter((value) => value !== undefined && value !== false);
|
|
156
|
+
if (targets.length > 1) throw new Error('Use at most one of fullPage, selector, point, region and devices');
|
|
157
|
+
if (args.deviceFrame && (args.fullPage || args.selector || args.point || args.region)) {
|
|
158
|
+
throw new Error('deviceFrame only applies to a viewport or devices capture — the frame holds a whole screen');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Each capture with what it is called and the device it can be framed in.
|
|
162
|
+
let shots: Array<{ image: CapturedScreenshot; label: string; device?: string; spec: FrameSpec | null }>;
|
|
163
|
+
|
|
164
|
+
if (args.devices) {
|
|
165
|
+
// The tab's own colours are the best guess for how the page frames on another device.
|
|
166
|
+
const pageColors = ctx.service.screenshotFrameSpec(ctx.tab.id)?.pageColors;
|
|
167
|
+
const taken = await ctx.service.takeResponsiveScreenshots(ctx.tab.id, [...args.devices], args.deviceFrame ? { format: 'png' } : options);
|
|
168
|
+
shots = taken.map((shot) => ({
|
|
169
|
+
image: shot.image,
|
|
170
|
+
label: `${shot.deviceSize} (${shot.viewport.width}×${shot.viewport.height})`,
|
|
171
|
+
device: shot.deviceSize,
|
|
172
|
+
spec: { deviceSize: shot.deviceSize, viewport: shot.viewport, deviceModel: shot.deviceModel, pageColors }
|
|
173
|
+
}));
|
|
132
174
|
} else {
|
|
133
|
-
|
|
175
|
+
// The same capture the viewer's screenshot button uses, so every viewer
|
|
176
|
+
// of the tab sees the shutter when the agent takes one too.
|
|
177
|
+
const target: ScreenshotTarget = args.selector
|
|
178
|
+
? { kind: 'selector', selector: args.selector }
|
|
179
|
+
: args.point
|
|
180
|
+
? { kind: 'element', x: args.point.x, y: args.point.y, depth: args.point.depth }
|
|
181
|
+
: args.region
|
|
182
|
+
? { kind: 'region', ...args.region }
|
|
183
|
+
: args.fullPage
|
|
184
|
+
? { kind: 'fullPage' }
|
|
185
|
+
: { kind: 'viewport' };
|
|
186
|
+
const image = await ctx.service.takeScreenshot(ctx.tab.id, target, args.deviceFrame ? { format: 'png' } : options, 'agent');
|
|
187
|
+
const label = args.selector
|
|
188
|
+
? `screenshot of ${args.selector}`
|
|
189
|
+
: args.point
|
|
190
|
+
? 'screenshot of the element at the point'
|
|
191
|
+
: args.region
|
|
192
|
+
? 'screenshot of the region'
|
|
193
|
+
: 'screenshot';
|
|
194
|
+
shots = [{ image, label, spec: ctx.service.screenshotFrameSpec(ctx.tab.id) }];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (args.deviceFrame) {
|
|
198
|
+
// Captured lossless above; the format asked for is applied once, after framing.
|
|
199
|
+
const framed = await ctx.service.frameScreenshots(
|
|
200
|
+
shots.map((shot) => {
|
|
201
|
+
if (!shot.spec) throw new Error('That tab is no longer open');
|
|
202
|
+
return { image: shot.image, spec: shot.spec };
|
|
203
|
+
}),
|
|
204
|
+
options
|
|
205
|
+
);
|
|
206
|
+
shots = shots.map((shot, index) => ({ ...shot, image: framed[index], label: `${shot.label}, framed` }));
|
|
134
207
|
}
|
|
135
208
|
|
|
136
|
-
const parts: string[] = [
|
|
209
|
+
const parts: string[] = [];
|
|
210
|
+
const root = args.saveTo ? projectQueries.getById(ctx.projectId)?.path : undefined;
|
|
211
|
+
let tracked = 0;
|
|
137
212
|
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
213
|
+
for (const shot of shots) {
|
|
214
|
+
const { image } = shot;
|
|
215
|
+
const line = `${shot.device ? `${shot.device}: ` : ''}${format}, ${image.width}×${image.height}, ${Math.round(image.data.byteLength / 1024)}KB`;
|
|
216
|
+
if (!args.saveTo) {
|
|
217
|
+
parts.push(line);
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const target = shot.device ? perDevicePath(args.saveTo, shot.device, format === 'jpeg' ? 'jpg' : 'png') : args.saveTo;
|
|
221
|
+
const absolute = await resolveWritePath(target, ctx.projectId);
|
|
222
|
+
await writeFile(absolute, image.data);
|
|
223
|
+
if (root && (await gitIgnoreState(root, absolute)) === 'not-ignored') tracked += 1;
|
|
224
|
+
parts.push(`${line} saved to ${root ? relative(root, absolute) : absolute}`);
|
|
225
|
+
}
|
|
226
|
+
if (args.fullPage) parts[0] += ', full page';
|
|
227
|
+
if (tracked > 0) {
|
|
228
|
+
parts.push(`git will track ${tracked === 1 ? 'this file' : 'these files'} — keep screenshots in an ignored folder unless they belong in the repository`);
|
|
143
229
|
}
|
|
144
230
|
|
|
145
231
|
return {
|
|
@@ -147,13 +233,11 @@ export const screenshot: ActionDef = {
|
|
|
147
233
|
images:
|
|
148
234
|
mode === 'file'
|
|
149
235
|
? undefined
|
|
150
|
-
:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
]
|
|
236
|
+
: shots.map((shot) => ({
|
|
237
|
+
data: Buffer.from(shot.image.data).toString('base64'),
|
|
238
|
+
mimeType: shot.image.mimeType,
|
|
239
|
+
label: shot.label
|
|
240
|
+
}))
|
|
157
241
|
};
|
|
158
242
|
}
|
|
159
243
|
};
|
|
@@ -39,6 +39,11 @@ Fill a form
|
|
|
39
39
|
Check a layout on mobile
|
|
40
40
|
[{set_viewport, device:"iphone-16"}, {wait_for, state:"networkIdle"}, {screenshot}]
|
|
41
41
|
Same page on Android in dark mode: [{set_viewport, device:"galaxy-s24", colorScheme:"dark"}, {screenshot}]
|
|
42
|
+
Every device at once, without changing the tab: [{screenshot, devices:["mobile","tablet","laptop","desktop"]}]
|
|
43
|
+
|
|
44
|
+
Screenshots to show the user
|
|
45
|
+
[{screenshot, deviceFrame:true, saveTo:"screenshots/home.png"}] — the page inside its device mockup.
|
|
46
|
+
One part of the page: {screenshot, selector:"#pricing"}, or what is under a point: {screenshot, point:{x:640, y:300}}.
|
|
42
47
|
|
|
43
48
|
Debug a page that misbehaves
|
|
44
49
|
[{clear_console}, {click, selector:"#save"}, {wait, ms:500}, {console_logs, level:"error"}]`;
|
package/backend/memory/README.md
CHANGED
|
@@ -308,7 +308,8 @@ graph_node_entities subjects a memory is about (an ATTRIBUTE, not nodes)
|
|
|
308
308
|
graph_node_paths files a memory is about (likewise)
|
|
309
309
|
graph_vectors one int8 vector per node, 260 bytes at 256 dims
|
|
310
310
|
graph_nodes_fts FTS5 mirror for BM25
|
|
311
|
-
graph_layout persisted positions and
|
|
311
|
+
graph_layout persisted positions, communities and degree (067, 089)
|
|
312
|
+
graph_layout_edges derived edges the layout pass laid out on (089)
|
|
312
313
|
memory_extraction_queue durable queue of turns awaiting summarisation
|
|
313
314
|
```
|
|
314
315
|
|
|
@@ -349,8 +350,9 @@ of sentences all shaped "X is a project that does Y", every pair is similar in
|
|
|
349
350
|
shape rather than in subject, so 144 of one graph's 371 edges were pairings like
|
|
350
351
|
*"Vantum monorepo phase 1.8"* ↔ *"ChatKit runs on Node.js 18+"*. The fault was
|
|
351
352
|
never that they connected memories — it was that **cosine chose which**. Edges are
|
|
352
|
-
now derived
|
|
353
|
-
|
|
353
|
+
now derived from the subjects extraction already recorded. They are never stored
|
|
354
|
+
as relations; the layout pass keeps the set it laid out on in
|
|
355
|
+
`graph_layout_edges`, which is disposable like the rest of the arrangement.
|
|
354
356
|
|
|
355
357
|
---
|
|
356
358
|
|
|
@@ -364,7 +366,8 @@ bootstrap.ts startup; idempotent, also re-run after Clear All Data
|
|
|
364
366
|
|
|
365
367
|
retrieval.ts BM25 + vector, RRF fusion, spreading activation
|
|
366
368
|
context.ts builds the injected block; standing instructions
|
|
367
|
-
|
|
369
|
+
layout.ts background arrangement: cold passes, warm arrival placement, the world
|
|
370
|
+
view.ts the graph view as map tiles, plus locate and node detail
|
|
368
371
|
|
|
369
372
|
extract/
|
|
370
373
|
scheduler.ts durable queue, retries, concurrency
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory graph layout + tile tests.
|
|
3
|
+
*
|
|
4
|
+
* Run against a REAL in-memory SQLite database with the graph migrations
|
|
5
|
+
* applied, because what is under test is the arrangement the pass leaves in the
|
|
6
|
+
* table and what the tile queries read back out of it.
|
|
7
|
+
*
|
|
8
|
+
* The regression these exist for: warm passes used to re-settle the whole map
|
|
9
|
+
* from its own previous result, which inflated it by ~1.4× per pass until the
|
|
10
|
+
* coordinates overflowed to NaN and every pass failed on the NOT NULL
|
|
11
|
+
* constraint. Stability across passes is therefore asserted EXACTLY, not
|
|
12
|
+
* approximately.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { beforeEach, describe, expect, it, mock } from 'bun:test';
|
|
16
|
+
import { Database } from 'bun:sqlite';
|
|
17
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
18
|
+
import * as migration005 from '$backend/database/migrations/005_create_settings_table';
|
|
19
|
+
import * as migration066 from '$backend/database/migrations/066_create_memory_graph';
|
|
20
|
+
import * as migration067 from '$backend/database/migrations/067_add_memory_graph_layout';
|
|
21
|
+
import * as migration076 from '$backend/database/migrations/076_remove_memory_code_graph';
|
|
22
|
+
import * as migration089 from '$backend/database/migrations/089_add_memory_layout_tiles';
|
|
23
|
+
|
|
24
|
+
let db: Database;
|
|
25
|
+
|
|
26
|
+
// The whole module surface, not just `getDatabase` — see retrieval.test.ts.
|
|
27
|
+
mock.module('$backend/database', () => ({
|
|
28
|
+
getDatabase: () => db,
|
|
29
|
+
initializeDatabase: async () => db,
|
|
30
|
+
closeDatabase: () => {},
|
|
31
|
+
resetDatabase: async () => {},
|
|
32
|
+
getDatabaseInfo: async () => ({}),
|
|
33
|
+
vacuumDatabase: async () => {}
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
// The pass announces its result over the WebSocket, which has no server here.
|
|
37
|
+
mock.module('$backend/memory/notify', () => ({
|
|
38
|
+
notifyGraphChanged: () => {},
|
|
39
|
+
broadcastGraphChanged: () => {},
|
|
40
|
+
notifyMemoryStatus: () => {},
|
|
41
|
+
notifyMemoryReadiness: () => {}
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
const { graphQueries, graphLayoutQueries } = await import('$backend/database/queries/graph-queries');
|
|
45
|
+
const { runGraphLayout, resetGraphLayoutState, getLayoutState, alignTo } = await import('./layout');
|
|
46
|
+
const { buildGraphMeta, buildGraphTiles, locateNodes } = await import('./view');
|
|
47
|
+
|
|
48
|
+
const PROJECT = 'project-a';
|
|
49
|
+
|
|
50
|
+
function resetDatabase(): void {
|
|
51
|
+
db = new Database(':memory:');
|
|
52
|
+
db.exec('PRAGMA foreign_keys = ON');
|
|
53
|
+
const connection = db as unknown as DatabaseConnection;
|
|
54
|
+
migration005.up(connection);
|
|
55
|
+
migration066.up(connection);
|
|
56
|
+
migration067.up(connection);
|
|
57
|
+
migration076.up(connection);
|
|
58
|
+
migration089.up(connection);
|
|
59
|
+
resetGraphLayoutState();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A store with structure: subjects that group memories, a few stored edges, and loners. */
|
|
63
|
+
function seed(subjects = 6, perSubject = 12, loners = 8): string[] {
|
|
64
|
+
const ids: string[] = [];
|
|
65
|
+
for (let s = 0; s < subjects; s++) {
|
|
66
|
+
const members: string[] = [];
|
|
67
|
+
for (let m = 0; m < perSubject; m++) {
|
|
68
|
+
const node = graphQueries.upsert({
|
|
69
|
+
subkind: 'decision',
|
|
70
|
+
projectId: PROJECT,
|
|
71
|
+
label: `Subject ${s} decision ${m}`
|
|
72
|
+
});
|
|
73
|
+
graphQueries.setEntities(node.id, [{ key: `subject-${s}`, name: `Subject ${s}` }]);
|
|
74
|
+
members.push(node.id);
|
|
75
|
+
}
|
|
76
|
+
// A stored edge between neighbouring subjects, so the graph is one mass
|
|
77
|
+
// with lobes rather than six islands.
|
|
78
|
+
if (s > 0) graphQueries.link({ srcId: ids[ids.length - 1], dstId: members[0], rel: 'relates_to' });
|
|
79
|
+
ids.push(...members);
|
|
80
|
+
}
|
|
81
|
+
for (let l = 0; l < loners; l++) {
|
|
82
|
+
ids.push(graphQueries.upsert({ subkind: 'observation', projectId: PROJECT, label: `Loner ${l}` }).id);
|
|
83
|
+
}
|
|
84
|
+
return ids;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function positions(): Map<string, { x: number; y: number; community: number }> {
|
|
88
|
+
const rows = db.prepare('SELECT node_id AS id, x, y, community FROM graph_layout').all() as {
|
|
89
|
+
id: string;
|
|
90
|
+
x: number;
|
|
91
|
+
y: number;
|
|
92
|
+
community: number;
|
|
93
|
+
}[];
|
|
94
|
+
return new Map(rows.map(row => [row.id, { x: row.x, y: row.y, community: row.community }]));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Force the next pass to do real work rather than skip on an unchanged fingerprint. */
|
|
98
|
+
async function pass(): Promise<void> {
|
|
99
|
+
resetGraphLayoutState();
|
|
100
|
+
await runGraphLayout();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
beforeEach(() => {
|
|
104
|
+
resetDatabase();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('memory layout', () => {
|
|
108
|
+
it('lays out every live memory with finite positions inside the world', async () => {
|
|
109
|
+
const ids = seed();
|
|
110
|
+
await pass();
|
|
111
|
+
|
|
112
|
+
const placed = positions();
|
|
113
|
+
const state = getLayoutState();
|
|
114
|
+
expect(placed.size).toBe(ids.length);
|
|
115
|
+
expect(state.world).not.toBeNull();
|
|
116
|
+
expect(state.coldNodes).toBe(ids.length);
|
|
117
|
+
// What the view sizes nodes by: the median room a memory has.
|
|
118
|
+
expect(state.spacing).toBeGreaterThan(0);
|
|
119
|
+
expect(Number.isFinite(state.spacing)).toBe(true);
|
|
120
|
+
|
|
121
|
+
const world = state.world!;
|
|
122
|
+
for (const point of placed.values()) {
|
|
123
|
+
expect(Number.isFinite(point.x) && Number.isFinite(point.y)).toBe(true);
|
|
124
|
+
expect(point.x).toBeGreaterThanOrEqual(world.minX);
|
|
125
|
+
expect(point.y).toBeGreaterThanOrEqual(world.minY);
|
|
126
|
+
expect(point.x).toBeLessThan(world.minX + world.size);
|
|
127
|
+
expect(point.y).toBeLessThan(world.minY + world.size);
|
|
128
|
+
}
|
|
129
|
+
// Derived edges are kept for the view to draw.
|
|
130
|
+
const derived = (db.prepare('SELECT COUNT(*) AS c FROM graph_layout_edges').get() as { c: number }).c;
|
|
131
|
+
expect(derived).toBeGreaterThan(0);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('leaves the map exactly where it was across passes over unchanged data', async () => {
|
|
135
|
+
seed();
|
|
136
|
+
await pass();
|
|
137
|
+
const first = positions();
|
|
138
|
+
const epoch = getLayoutState().epoch;
|
|
139
|
+
|
|
140
|
+
for (let i = 0; i < 4; i++) await pass();
|
|
141
|
+
|
|
142
|
+
const later = positions();
|
|
143
|
+
for (const [id, point] of first) expect(later.get(id)).toEqual(point);
|
|
144
|
+
expect(getLayoutState().epoch).toBe(epoch);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('places arrivals next to what they connect to without moving anything else', async () => {
|
|
148
|
+
seed(6, 12, 8);
|
|
149
|
+
await pass();
|
|
150
|
+
const before = positions();
|
|
151
|
+
const stamp = getLayoutState().stamp;
|
|
152
|
+
|
|
153
|
+
// Two arrivals about an existing subject — under the re-arrangement threshold.
|
|
154
|
+
const arrivals = [0, 1].map(i => {
|
|
155
|
+
const node = graphQueries.upsert({ subkind: 'decision', projectId: PROJECT, label: `Arrival ${i}` });
|
|
156
|
+
graphQueries.setEntities(node.id, [{ key: 'subject-0', name: 'Subject 0' }]);
|
|
157
|
+
return node.id;
|
|
158
|
+
});
|
|
159
|
+
await pass();
|
|
160
|
+
|
|
161
|
+
const after = positions();
|
|
162
|
+
for (const [id, point] of before) expect(after.get(id)).toEqual(point);
|
|
163
|
+
for (const id of arrivals) {
|
|
164
|
+
const point = after.get(id);
|
|
165
|
+
expect(point).toBeDefined();
|
|
166
|
+
expect(Number.isFinite(point!.x) && Number.isFinite(point!.y)).toBe(true);
|
|
167
|
+
// Next to what it connects to, not flung across the map: at the centre
|
|
168
|
+
// of the memories its edges lead to, within a neighbour's distance or
|
|
169
|
+
// two. Measured against its EDGES rather than its subject's members,
|
|
170
|
+
// because Louvain is free to split one subject across several lobes.
|
|
171
|
+
const partners = (
|
|
172
|
+
db
|
|
173
|
+
.prepare(
|
|
174
|
+
`SELECT CASE WHEN src_id = ? THEN dst_id ELSE src_id END AS id FROM graph_layout_edges
|
|
175
|
+
WHERE src_id = ? OR dst_id = ?`
|
|
176
|
+
)
|
|
177
|
+
.all(id, id, id) as { id: string }[]
|
|
178
|
+
)
|
|
179
|
+
.map(row => row.id)
|
|
180
|
+
.filter(partner => !arrivals.includes(partner))
|
|
181
|
+
.map(partner => before.get(partner)!);
|
|
182
|
+
expect(partners.length).toBeGreaterThan(0);
|
|
183
|
+
const cx = partners.reduce((sum, partner) => sum + partner.x, 0) / partners.length;
|
|
184
|
+
const cy = partners.reduce((sum, partner) => sum + partner.y, 0) / partners.length;
|
|
185
|
+
expect(Math.hypot(point!.x - cx, point!.y - cy)).toBeLessThan(getLayoutState().spacing * 2);
|
|
186
|
+
|
|
187
|
+
// And it takes the colour most of them carry.
|
|
188
|
+
const votes = new Map<number, number>();
|
|
189
|
+
for (const partner of partners) votes.set(partner.community, (votes.get(partner.community) ?? 0) + 1);
|
|
190
|
+
const top = Math.max(...votes.values());
|
|
191
|
+
expect(votes.get(point!.community)).toBe(top);
|
|
192
|
+
}
|
|
193
|
+
expect(getLayoutState().arrivals).toBe(2);
|
|
194
|
+
// The stamp is what tells a client its tiles are out of date.
|
|
195
|
+
expect(getLayoutState().stamp).toBeGreaterThan(stamp);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('recovers from a diverged arrangement by laying out from scratch', async () => {
|
|
199
|
+
seed();
|
|
200
|
+
await pass();
|
|
201
|
+
const epoch = getLayoutState().epoch;
|
|
202
|
+
|
|
203
|
+
// What the old warm passes compounded to: coordinates near the float range.
|
|
204
|
+
db.exec('UPDATE graph_layout SET x = x * 1e34, y = y * 1e34');
|
|
205
|
+
await pass();
|
|
206
|
+
|
|
207
|
+
const bounds = graphLayoutQueries.bounds();
|
|
208
|
+
expect(bounds).not.toBeNull();
|
|
209
|
+
expect(bounds!.magnitude).toBeLessThan(1e6);
|
|
210
|
+
expect(getLayoutState().epoch).toBeGreaterThan(epoch);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('re-arranges once the store outgrows its arrangement, keeping its colours', async () => {
|
|
214
|
+
const ids = seed(6, 12, 8);
|
|
215
|
+
await pass();
|
|
216
|
+
const before = positions();
|
|
217
|
+
const epoch = getLayoutState().epoch;
|
|
218
|
+
|
|
219
|
+
// Well past a fifth of the store, all joining existing subjects.
|
|
220
|
+
for (let i = 0; i < 24; i++) {
|
|
221
|
+
const node = graphQueries.upsert({ subkind: 'pattern', projectId: PROJECT, label: `Growth ${i}` });
|
|
222
|
+
graphQueries.setEntities(node.id, [{ key: `subject-${i % 6}`, name: `Subject ${i % 6}` }]);
|
|
223
|
+
}
|
|
224
|
+
await pass();
|
|
225
|
+
|
|
226
|
+
const state = getLayoutState();
|
|
227
|
+
expect(state.epoch).toBeGreaterThan(epoch);
|
|
228
|
+
expect(state.arrivals).toBe(0);
|
|
229
|
+
expect(state.coldNodes).toBe(ids.length + 24);
|
|
230
|
+
|
|
231
|
+
// Most memories keep the community NUMBER they had, so their colour holds
|
|
232
|
+
// even though Louvain numbered the new communities however it liked.
|
|
233
|
+
const after = positions();
|
|
234
|
+
let sameColour = 0;
|
|
235
|
+
for (const [id, point] of before) if (after.get(id)?.community === point.community) sameColour++;
|
|
236
|
+
expect(sameColour / before.size).toBeGreaterThan(0.6);
|
|
237
|
+
|
|
238
|
+
const bounds = graphLayoutQueries.bounds();
|
|
239
|
+
expect(bounds!.magnitude).toBeLessThan(1e6);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('turns a fresh arrangement to face the way the previous one did, without scaling it', () => {
|
|
243
|
+
const old = new Map<string, { nodeId: string; community: number; x: number; y: number; placed: number; degree: number }>();
|
|
244
|
+
const fresh: { nodeId: string; community: number; x: number; y: number; placed: number; degree: number }[] = [];
|
|
245
|
+
const angle = 1.27;
|
|
246
|
+
for (let i = 0; i < 40; i++) {
|
|
247
|
+
const x = Math.cos(i * 0.7) * (100 + i * 13);
|
|
248
|
+
const y = Math.sin(i * 1.3) * (60 + i * 7);
|
|
249
|
+
old.set(`n${i}`, { nodeId: `n${i}`, community: 0, x, y, placed: 1, degree: 0 });
|
|
250
|
+
// The same arrangement mirrored, rotated and moved — what a fresh
|
|
251
|
+
// simulation of the same graph is free to come back as.
|
|
252
|
+
const mx = x;
|
|
253
|
+
const my = -y;
|
|
254
|
+
fresh.push({
|
|
255
|
+
nodeId: `n${i}`,
|
|
256
|
+
community: 0,
|
|
257
|
+
x: Math.cos(angle) * mx - Math.sin(angle) * my + 5_000,
|
|
258
|
+
y: Math.sin(angle) * mx + Math.cos(angle) * my - 3_000,
|
|
259
|
+
placed: 1,
|
|
260
|
+
degree: 0
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
alignTo(fresh, old);
|
|
265
|
+
|
|
266
|
+
for (const row of fresh) {
|
|
267
|
+
const target = old.get(row.nodeId)!;
|
|
268
|
+
expect(Math.abs(row.x - target.x)).toBeLessThan(1e-6);
|
|
269
|
+
expect(Math.abs(row.y - target.y)).toBeLessThan(1e-6);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('gives archived memories a place so "show archived" can draw them', async () => {
|
|
274
|
+
const ids = seed();
|
|
275
|
+
graphQueries.archive(ids[3]);
|
|
276
|
+
await pass();
|
|
277
|
+
|
|
278
|
+
expect(positions().has(ids[3])).toBe(true);
|
|
279
|
+
const meta = buildGraphMeta({ includeArchived: true });
|
|
280
|
+
expect(meta.total).toBe(ids.length);
|
|
281
|
+
expect(meta.unplaced).toBe(0);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
describe('graph tiles', () => {
|
|
286
|
+
const allTiles = (z: number) => {
|
|
287
|
+
const tiles: { x: number; y: number }[] = [];
|
|
288
|
+
for (let x = 0; x < 2 ** z; x++) for (let y = 0; y < 2 ** z; y++) tiles.push({ x, y });
|
|
289
|
+
return tiles;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
it('serves every memory individually when the screen can afford them', async () => {
|
|
293
|
+
const ids = seed();
|
|
294
|
+
await pass();
|
|
295
|
+
const meta = buildGraphMeta({});
|
|
296
|
+
|
|
297
|
+
for (const z of [0, 1, 2]) {
|
|
298
|
+
const response = buildGraphTiles({ epoch: meta.epoch, z, tiles: allTiles(z), budget: 12_000 });
|
|
299
|
+
expect(response.stale).toBe(false);
|
|
300
|
+
const nodes = response.tiles.flatMap(tile => tile.nodes.map(node => node.id));
|
|
301
|
+
expect(new Set(nodes).size).toBe(ids.length);
|
|
302
|
+
expect(response.tiles.every(tile => tile.clusters.length === 0)).toBe(true);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('folds crowded tiles when the budget is small, without losing a memory', async () => {
|
|
307
|
+
const ids = seed(8, 40, 10);
|
|
308
|
+
await pass();
|
|
309
|
+
const meta = buildGraphMeta({});
|
|
310
|
+
|
|
311
|
+
const response = buildGraphTiles({ epoch: meta.epoch, z: 0, tiles: [{ x: 0, y: 0 }], budget: 256 });
|
|
312
|
+
const [tile] = response.tiles;
|
|
313
|
+
expect(tile.cells).toBeGreaterThan(0);
|
|
314
|
+
expect(tile.clusters.length).toBeGreaterThan(0);
|
|
315
|
+
expect(tile.nodes.length + tile.clusters.length).toBeLessThanOrEqual(256);
|
|
316
|
+
|
|
317
|
+
const covered = tile.nodes.length + tile.clusters.reduce((sum, cluster) => sum + cluster.members, 0);
|
|
318
|
+
expect(covered).toBe(ids.length);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('answers stale instead of serving tiles from another map', async () => {
|
|
322
|
+
seed();
|
|
323
|
+
await pass();
|
|
324
|
+
const meta = buildGraphMeta({});
|
|
325
|
+
|
|
326
|
+
const response = buildGraphTiles({ epoch: meta.epoch + 1, z: 0, tiles: [{ x: 0, y: 0 }], budget: 12_000 });
|
|
327
|
+
expect(response.stale).toBe(true);
|
|
328
|
+
expect(response.tiles).toHaveLength(0);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('sends each edge once per request, with where its far end is', async () => {
|
|
332
|
+
seed();
|
|
333
|
+
await pass();
|
|
334
|
+
const meta = buildGraphMeta({});
|
|
335
|
+
|
|
336
|
+
const response = buildGraphTiles({ epoch: meta.epoch, z: 2, tiles: allTiles(2), budget: 12_000 });
|
|
337
|
+
const pairs = response.tiles.flatMap(tile =>
|
|
338
|
+
tile.edges.map(edge => (edge.source < edge.target ? `${edge.source}|${edge.target}` : `${edge.target}|${edge.source}`))
|
|
339
|
+
);
|
|
340
|
+
expect(pairs.length).toBeGreaterThan(0);
|
|
341
|
+
expect(new Set(pairs).size).toBe(pairs.length);
|
|
342
|
+
|
|
343
|
+
const placed = positions();
|
|
344
|
+
for (const tile of response.tiles) {
|
|
345
|
+
for (const edge of tile.edges) {
|
|
346
|
+
const far = placed.get(edge.target)!;
|
|
347
|
+
expect(Math.abs(edge.targetX - far.x)).toBeLessThan(0.1);
|
|
348
|
+
expect(Math.abs(edge.targetY - far.y)).toBeLessThan(0.1);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('narrows tiles and counts by the filter', async () => {
|
|
354
|
+
seed();
|
|
355
|
+
const other = graphQueries.upsert({ subkind: 'decision', projectId: 'project-b', label: 'Elsewhere' });
|
|
356
|
+
await pass();
|
|
357
|
+
|
|
358
|
+
const meta = buildGraphMeta({ projectIds: ['project-b'] });
|
|
359
|
+
expect(meta.total).toBe(1);
|
|
360
|
+
const response = buildGraphTiles({
|
|
361
|
+
epoch: meta.epoch,
|
|
362
|
+
z: 0,
|
|
363
|
+
tiles: [{ x: 0, y: 0 }],
|
|
364
|
+
budget: 12_000,
|
|
365
|
+
projectIds: ['project-b']
|
|
366
|
+
});
|
|
367
|
+
expect(response.tiles[0].nodes.map(node => node.id)).toEqual([other.id]);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('locates memories by id for going to one that is not drawn', async () => {
|
|
371
|
+
const ids = seed();
|
|
372
|
+
await pass();
|
|
373
|
+
const located = locateNodes([ids[5], 'missing-id']);
|
|
374
|
+
expect(located.map(node => node.id)).toEqual([ids[5]]);
|
|
375
|
+
expect(Number.isFinite(located[0].x)).toBe(true);
|
|
376
|
+
});
|
|
377
|
+
});
|