@qvac/core 0.0.0 → 0.1.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/LICENSE.md +198 -0
- package/NOTICE.md +13 -0
- package/README.md +694 -0
- package/SECURITY.md +6 -0
- package/dist/assistant.bundle +47256 -0
- package/dist/assistant.cjs +18 -0
- package/dist/assistant.d.ts +8 -0
- package/dist/prebuilds-manifest.json +380 -0
- package/dist-lib/client.d.ts +2 -0
- package/dist-lib/client.js +1 -0
- package/dist-lib/index.d.ts +13 -0
- package/dist-lib/index.js +10 -0
- package/dist-lib/lib/agent-icons.d.ts +3 -0
- package/dist-lib/lib/agent-icons.js +1 -0
- package/dist-lib/lib/api/agents.d.ts +5 -0
- package/dist-lib/lib/api/agents.js +38 -0
- package/dist-lib/lib/api/app-config.d.ts +5 -0
- package/dist-lib/lib/api/app-config.js +108 -0
- package/dist-lib/lib/api/approval-rules.d.ts +3 -0
- package/dist-lib/lib/api/approval-rules.js +9 -0
- package/dist-lib/lib/api/attachments.d.ts +8 -0
- package/dist-lib/lib/api/attachments.js +15 -0
- package/dist-lib/lib/api/chat-groups.d.ts +5 -0
- package/dist-lib/lib/api/chat-groups.js +12 -0
- package/dist-lib/lib/api/chat.d.ts +5 -0
- package/dist-lib/lib/api/chat.js +38 -0
- package/dist-lib/lib/api/chunks.d.ts +5 -0
- package/dist-lib/lib/api/chunks.js +61 -0
- package/dist-lib/lib/api/config.d.ts +5 -0
- package/dist-lib/lib/api/config.js +15 -0
- package/dist-lib/lib/api/current-mesh.d.ts +5 -0
- package/dist-lib/lib/api/current-mesh.js +12 -0
- package/dist-lib/lib/api/custom-models.d.ts +5 -0
- package/dist-lib/lib/api/custom-models.js +45 -0
- package/dist-lib/lib/api/devices.d.ts +8 -0
- package/dist-lib/lib/api/devices.js +125 -0
- package/dist-lib/lib/api/diagnostics.d.ts +7 -0
- package/dist-lib/lib/api/diagnostics.js +7 -0
- package/dist-lib/lib/api/effective-ctx-size.d.ts +2 -0
- package/dist-lib/lib/api/effective-ctx-size.js +10 -0
- package/dist-lib/lib/api/execution.d.ts +3 -0
- package/dist-lib/lib/api/execution.js +45 -0
- package/dist-lib/lib/api/files.d.ts +3 -0
- package/dist-lib/lib/api/files.js +48 -0
- package/dist-lib/lib/api/index.d.ts +62 -0
- package/dist-lib/lib/api/index.js +172 -0
- package/dist-lib/lib/api/instrument.d.ts +2 -0
- package/dist-lib/lib/api/instrument.js +86 -0
- package/dist-lib/lib/api/knowledge.d.ts +8 -0
- package/dist-lib/lib/api/knowledge.js +26 -0
- package/dist-lib/lib/api/logs.d.ts +14 -0
- package/dist-lib/lib/api/logs.js +116 -0
- package/dist-lib/lib/api/mesh.d.ts +13 -0
- package/dist-lib/lib/api/mesh.js +25 -0
- package/dist-lib/lib/api/model-download.d.ts +5 -0
- package/dist-lib/lib/api/model-download.js +47 -0
- package/dist-lib/lib/api/network.d.ts +8 -0
- package/dist-lib/lib/api/network.js +6 -0
- package/dist-lib/lib/api/notifications.d.ts +21 -0
- package/dist-lib/lib/api/notifications.js +108 -0
- package/dist-lib/lib/api/rag.d.ts +7 -0
- package/dist-lib/lib/api/rag.js +216 -0
- package/dist-lib/lib/api/sync.d.ts +3 -0
- package/dist-lib/lib/api/sync.js +6 -0
- package/dist-lib/lib/api/tool-activity.d.ts +5 -0
- package/dist-lib/lib/api/tool-activity.js +53 -0
- package/dist-lib/lib/api/tool-configs.d.ts +6 -0
- package/dist-lib/lib/api/tool-configs.js +27 -0
- package/dist-lib/lib/api/watchable.d.ts +12 -0
- package/dist-lib/lib/api/watchable.js +121 -0
- package/dist-lib/lib/assistant-client.d.ts +21 -0
- package/dist-lib/lib/assistant-client.js +52 -0
- package/dist-lib/lib/assistant-tree.d.ts +50 -0
- package/dist-lib/lib/assistant-tree.js +184 -0
- package/dist-lib/lib/assistant.d.ts +425 -0
- package/dist-lib/lib/assistant.js +2706 -0
- package/dist-lib/lib/audio-format.d.ts +4 -0
- package/dist-lib/lib/audio-format.js +4 -0
- package/dist-lib/lib/chat-title.d.ts +5 -0
- package/dist-lib/lib/chat-title.js +58 -0
- package/dist-lib/lib/client.d.ts +25 -0
- package/dist-lib/lib/client.js +53 -0
- package/dist-lib/lib/collabora/convert.d.ts +9 -0
- package/dist-lib/lib/collabora/convert.js +62 -0
- package/dist-lib/lib/collabora/entry.d.ts +1 -0
- package/dist-lib/lib/collabora/entry.js +44 -0
- package/dist-lib/lib/collabora/protocol.d.ts +15 -0
- package/dist-lib/lib/collabora/protocol.js +24 -0
- package/dist-lib/lib/collabora/worker.d.ts +5 -0
- package/dist-lib/lib/collabora/worker.js +111 -0
- package/dist-lib/lib/compaction.d.ts +30 -0
- package/dist-lib/lib/compaction.js +95 -0
- package/dist-lib/lib/constants.d.ts +4 -0
- package/dist-lib/lib/constants.js +4 -0
- package/dist-lib/lib/core/agent.d.ts +15 -0
- package/dist-lib/lib/core/agent.js +149 -0
- package/dist-lib/lib/core/app-build.d.ts +7 -0
- package/dist-lib/lib/core/app-build.js +1 -0
- package/dist-lib/lib/core/approval-rules.d.ts +15 -0
- package/dist-lib/lib/core/approval-rules.js +41 -0
- package/dist-lib/lib/core/async-iterable.d.ts +13 -0
- package/dist-lib/lib/core/async-iterable.js +65 -0
- package/dist-lib/lib/core/attachment-link.d.ts +7 -0
- package/dist-lib/lib/core/attachment-link.js +6 -0
- package/dist-lib/lib/core/audio-attachment.d.ts +1 -0
- package/dist-lib/lib/core/audio-attachment.js +4 -0
- package/dist-lib/lib/core/blind-peers.d.ts +6 -0
- package/dist-lib/lib/core/blind-peers.js +13 -0
- package/dist-lib/lib/core/chat-activity.d.ts +7 -0
- package/dist-lib/lib/core/chat-activity.js +244 -0
- package/dist-lib/lib/core/chat-group.d.ts +14 -0
- package/dist-lib/lib/core/chat-group.js +79 -0
- package/dist-lib/lib/core/chat-search.d.ts +17 -0
- package/dist-lib/lib/core/chat-search.js +199 -0
- package/dist-lib/lib/core/chat.d.ts +37 -0
- package/dist-lib/lib/core/chat.js +196 -0
- package/dist-lib/lib/core/chunk.d.ts +61 -0
- package/dist-lib/lib/core/chunk.js +212 -0
- package/dist-lib/lib/core/contract/activity.d.ts +11 -0
- package/dist-lib/lib/core/contract/activity.js +45 -0
- package/dist-lib/lib/core/contract/agents.d.ts +2 -0
- package/dist-lib/lib/core/contract/agents.js +29 -0
- package/dist-lib/lib/core/contract/approval-rules.d.ts +2 -0
- package/dist-lib/lib/core/contract/approval-rules.js +14 -0
- package/dist-lib/lib/core/contract/attestations.d.ts +2 -0
- package/dist-lib/lib/core/contract/attestations.js +14 -0
- package/dist-lib/lib/core/contract/chat-group.d.ts +2 -0
- package/dist-lib/lib/core/contract/chat-group.js +20 -0
- package/dist-lib/lib/core/contract/chat.d.ts +2 -0
- package/dist-lib/lib/core/contract/chat.js +18 -0
- package/dist-lib/lib/core/contract/chunks.d.ts +2 -0
- package/dist-lib/lib/core/contract/chunks.js +156 -0
- package/dist-lib/lib/core/contract/devices.d.ts +2 -0
- package/dist-lib/lib/core/contract/devices.js +110 -0
- package/dist-lib/lib/core/contract/index.d.ts +2 -0
- package/dist-lib/lib/core/contract/index.js +30 -0
- package/dist-lib/lib/core/contract/indexing.d.ts +4 -0
- package/dist-lib/lib/core/contract/indexing.js +82 -0
- package/dist-lib/lib/core/contract/knowledge.d.ts +2 -0
- package/dist-lib/lib/core/contract/knowledge.js +55 -0
- package/dist-lib/lib/core/contract/members.d.ts +2 -0
- package/dist-lib/lib/core/contract/members.js +96 -0
- package/dist-lib/lib/core/contract/seed-defaults.d.ts +2 -0
- package/dist-lib/lib/core/contract/seed-defaults.js +29 -0
- package/dist-lib/lib/core/contract/tool-activity.d.ts +2 -0
- package/dist-lib/lib/core/contract/tool-activity.js +25 -0
- package/dist-lib/lib/core/contract/tool-configs.d.ts +2 -0
- package/dist-lib/lib/core/contract/tool-configs.js +50 -0
- package/dist-lib/lib/core/contract/types.d.ts +11 -0
- package/dist-lib/lib/core/contract/types.js +1 -0
- package/dist-lib/lib/core/contract/writers.d.ts +2 -0
- package/dist-lib/lib/core/contract/writers.js +112 -0
- package/dist-lib/lib/core/cpu-info-node.d.ts +3 -0
- package/dist-lib/lib/core/cpu-info-node.js +2 -0
- package/dist-lib/lib/core/departures.d.ts +41 -0
- package/dist-lib/lib/core/departures.js +145 -0
- package/dist-lib/lib/core/device-attestation.d.ts +6 -0
- package/dist-lib/lib/core/device-attestation.js +12 -0
- package/dist-lib/lib/core/devices.d.ts +14 -0
- package/dist-lib/lib/core/devices.js +11 -0
- package/dist-lib/lib/core/document-attachment.d.ts +22 -0
- package/dist-lib/lib/core/document-attachment.js +35 -0
- package/dist-lib/lib/core/files/attachments.d.ts +8 -0
- package/dist-lib/lib/core/files/attachments.js +50 -0
- package/dist-lib/lib/core/files/index.d.ts +133 -0
- package/dist-lib/lib/core/files/index.js +585 -0
- package/dist-lib/lib/core/files/knowledge.d.ts +9 -0
- package/dist-lib/lib/core/files/knowledge.js +31 -0
- package/dist-lib/lib/core/files/preview/image.d.ts +4 -0
- package/dist-lib/lib/core/files/preview/image.js +42 -0
- package/dist-lib/lib/core/files/preview/index.d.ts +33 -0
- package/dist-lib/lib/core/files/preview/index.js +161 -0
- package/dist-lib/lib/core/files/processing/claims.d.ts +26 -0
- package/dist-lib/lib/core/files/processing/claims.js +89 -0
- package/dist-lib/lib/core/files/processing/document.d.ts +100 -0
- package/dist-lib/lib/core/files/processing/document.js +101 -0
- package/dist-lib/lib/core/files/processing/index.d.ts +75 -0
- package/dist-lib/lib/core/files/processing/index.js +295 -0
- package/dist-lib/lib/core/files/processing/ownership.d.ts +11 -0
- package/dist-lib/lib/core/files/processing/ownership.js +41 -0
- package/dist-lib/lib/core/files/processing/protocol.d.ts +29 -0
- package/dist-lib/lib/core/files/processing/protocol.js +70 -0
- package/dist-lib/lib/core/files/processing/settle.d.ts +10 -0
- package/dist-lib/lib/core/files/processing/settle.js +75 -0
- package/dist-lib/lib/core/files/processing/source.d.ts +36 -0
- package/dist-lib/lib/core/files/processing/source.js +96 -0
- package/dist-lib/lib/core/files/processing/state.d.ts +64 -0
- package/dist-lib/lib/core/files/processing/state.js +118 -0
- package/dist-lib/lib/core/files/rag/artifact/codec.d.ts +3 -0
- package/dist-lib/lib/core/files/rag/artifact/codec.js +172 -0
- package/dist-lib/lib/core/files/rag/artifact/id.d.ts +10 -0
- package/dist-lib/lib/core/files/rag/artifact/id.js +39 -0
- package/dist-lib/lib/core/files/rag/artifact/types.d.ts +24 -0
- package/dist-lib/lib/core/files/rag/artifact/types.js +41 -0
- package/dist-lib/lib/core/files/rag/build.d.ts +25 -0
- package/dist-lib/lib/core/files/rag/build.js +60 -0
- package/dist-lib/lib/core/files/rag/chunk/chunking.d.ts +12 -0
- package/dist-lib/lib/core/files/rag/chunk/chunking.js +117 -0
- package/dist-lib/lib/core/files/rag/chunk/metadata.d.ts +30 -0
- package/dist-lib/lib/core/files/rag/chunk/metadata.js +89 -0
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.d.ts +7 -0
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.js +18 -0
- package/dist-lib/lib/core/files/rag/document-types.d.ts +11 -0
- package/dist-lib/lib/core/files/rag/document-types.js +94 -0
- package/dist-lib/lib/core/files/rag/extract/csv-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/csv-text.js +117 -0
- package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +22 -0
- package/dist-lib/lib/core/files/rag/extract/document-types.js +152 -0
- package/dist-lib/lib/core/files/rag/extract/extract.d.ts +17 -0
- package/dist-lib/lib/core/files/rag/extract/extract.js +81 -0
- package/dist-lib/lib/core/files/rag/extract/html-table-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/html-table-text.js +125 -0
- package/dist-lib/lib/core/files/rag/extract/html-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/html-text.js +132 -0
- package/dist-lib/lib/core/files/rag/extract/office-collabora.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/extract/office-collabora.js +8 -0
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.d.ts +17 -0
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +141 -0
- package/dist-lib/lib/core/files/rag/extract/pdf-text.d.ts +12 -0
- package/dist-lib/lib/core/files/rag/extract/pdf-text.js +43 -0
- package/dist-lib/lib/core/files/rag/extract/rtf-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/rtf-text.js +15 -0
- package/dist-lib/lib/core/files/rag/extract/text-decoding.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/text-decoding.js +91 -0
- package/dist-lib/lib/core/files/rag/extract/types.d.ts +36 -0
- package/dist-lib/lib/core/files/rag/extract/types.js +12 -0
- package/dist-lib/lib/core/files/rag/extract/utf.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/extract/utf.js +18 -0
- package/dist-lib/lib/core/files/rag/index.d.ts +54 -0
- package/dist-lib/lib/core/files/rag/index.js +79 -0
- package/dist-lib/lib/core/files/rag/limits.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/limits.js +2 -0
- package/dist-lib/lib/core/files/rag/load.d.ts +28 -0
- package/dist-lib/lib/core/files/rag/load.js +250 -0
- package/dist-lib/lib/core/files/rag/models.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/models.js +1 -0
- package/dist-lib/lib/core/files/rag/policy.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/policy.js +23 -0
- package/dist-lib/lib/core/files/rag/produce.d.ts +21 -0
- package/dist-lib/lib/core/files/rag/produce.js +214 -0
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.js +16 -0
- package/dist-lib/lib/core/files/rag/retrieval/coverage.d.ts +4 -0
- package/dist-lib/lib/core/files/rag/retrieval/coverage.js +48 -0
- package/dist-lib/lib/core/files/rag/retrieval/diversity.d.ts +10 -0
- package/dist-lib/lib/core/files/rag/retrieval/diversity.js +37 -0
- package/dist-lib/lib/core/files/rag/retrieval/floor.d.ts +5 -0
- package/dist-lib/lib/core/files/rag/retrieval/floor.js +21 -0
- package/dist-lib/lib/core/files/rag/retrieval/format.d.ts +6 -0
- package/dist-lib/lib/core/files/rag/retrieval/format.js +21 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +22 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +137 -0
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +53 -0
- package/dist-lib/lib/core/files/rag/retrieval/notices.d.ts +16 -0
- package/dist-lib/lib/core/files/rag/retrieval/notices.js +27 -0
- package/dist-lib/lib/core/files/rag/retrieval/scoring.d.ts +8 -0
- package/dist-lib/lib/core/files/rag/retrieval/scoring.js +82 -0
- package/dist-lib/lib/core/files/rag/retrieval/search.d.ts +3 -0
- package/dist-lib/lib/core/files/rag/retrieval/search.js +46 -0
- package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +10 -0
- package/dist-lib/lib/core/files/rag/retrieval/selection.js +63 -0
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.d.ts +6 -0
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.js +79 -0
- package/dist-lib/lib/core/files/rag/retrieval/sources.d.ts +13 -0
- package/dist-lib/lib/core/files/rag/retrieval/sources.js +20 -0
- package/dist-lib/lib/core/files/rag/retrieval/target.d.ts +13 -0
- package/dist-lib/lib/core/files/rag/retrieval/target.js +89 -0
- package/dist-lib/lib/core/files/rag/retrieval/terms.d.ts +8 -0
- package/dist-lib/lib/core/files/rag/retrieval/terms.js +70 -0
- package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +28 -0
- package/dist-lib/lib/core/files/rag/retrieval/types.js +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.d.ts +8 -0
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +41 -0
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.js +96 -0
- package/dist-lib/lib/core/files/rag/vector/memory.d.ts +15 -0
- package/dist-lib/lib/core/files/rag/vector/memory.js +135 -0
- package/dist-lib/lib/core/files/rag/vector/types.d.ts +28 -0
- package/dist-lib/lib/core/files/rag/vector/types.js +1 -0
- package/dist-lib/lib/core/files/records/chunks.d.ts +3 -0
- package/dist-lib/lib/core/files/records/chunks.js +12 -0
- package/dist-lib/lib/core/files/records/index.d.ts +10 -0
- package/dist-lib/lib/core/files/records/index.js +8 -0
- package/dist-lib/lib/core/files/records/knowledge.d.ts +22 -0
- package/dist-lib/lib/core/files/records/knowledge.js +105 -0
- package/dist-lib/lib/core/files/records/linkage.d.ts +11 -0
- package/dist-lib/lib/core/files/records/linkage.js +27 -0
- package/dist-lib/lib/core/files/records/output.d.ts +8 -0
- package/dist-lib/lib/core/files/records/output.js +38 -0
- package/dist-lib/lib/core/files/records/reclaim.d.ts +5 -0
- package/dist-lib/lib/core/files/records/reclaim.js +73 -0
- package/dist-lib/lib/core/files/records/routing.d.ts +23 -0
- package/dist-lib/lib/core/files/records/routing.js +62 -0
- package/dist-lib/lib/core/files/records/source.d.ts +16 -0
- package/dist-lib/lib/core/files/records/source.js +70 -0
- package/dist-lib/lib/core/files/records/sweep.d.ts +2 -0
- package/dist-lib/lib/core/files/records/sweep.js +30 -0
- package/dist-lib/lib/core/files/store/blob.d.ts +29 -0
- package/dist-lib/lib/core/files/store/blob.js +98 -0
- package/dist-lib/lib/core/files/store/index.d.ts +36 -0
- package/dist-lib/lib/core/files/store/index.js +89 -0
- package/dist-lib/lib/core/files/store/inline.d.ts +8 -0
- package/dist-lib/lib/core/files/store/inline.js +38 -0
- package/dist-lib/lib/core/files/store/reference.d.ts +27 -0
- package/dist-lib/lib/core/files/store/reference.js +168 -0
- package/dist-lib/lib/core/files/store/server.d.ts +27 -0
- package/dist-lib/lib/core/files/store/server.js +114 -0
- package/dist-lib/lib/core/files/store/sweep.d.ts +2 -0
- package/dist-lib/lib/core/files/store/sweep.js +45 -0
- package/dist-lib/lib/core/files/upload-input.d.ts +27 -0
- package/dist-lib/lib/core/files/upload-input.js +52 -0
- package/dist-lib/lib/core/files/upload.d.ts +32 -0
- package/dist-lib/lib/core/files/upload.js +201 -0
- package/dist-lib/lib/core/fs-drives.d.ts +18 -0
- package/dist-lib/lib/core/fs-drives.js +58 -0
- package/dist-lib/lib/core/gpu-info-node.d.ts +3 -0
- package/dist-lib/lib/core/gpu-info-node.js +2 -0
- package/dist-lib/lib/core/handoff-channel.d.ts +46 -0
- package/dist-lib/lib/core/handoff-channel.js +102 -0
- package/dist-lib/lib/core/health-assistant.d.ts +7 -0
- package/dist-lib/lib/core/health-assistant.js +24 -0
- package/dist-lib/lib/core/helpers/index.d.ts +5 -0
- package/dist-lib/lib/core/helpers/index.js +74 -0
- package/dist-lib/lib/core/hosted-agents.d.ts +36 -0
- package/dist-lib/lib/core/hosted-agents.js +127 -0
- package/dist-lib/lib/core/id.d.ts +1 -0
- package/dist-lib/lib/core/id.js +5 -0
- package/dist-lib/lib/core/identity.d.ts +14 -0
- package/dist-lib/lib/core/identity.js +45 -0
- package/dist-lib/lib/core/image/cache-sweep.d.ts +12 -0
- package/dist-lib/lib/core/image/cache-sweep.js +67 -0
- package/dist-lib/lib/core/image/normalize.d.ts +3 -0
- package/dist-lib/lib/core/image/normalize.js +49 -0
- package/dist-lib/lib/core/image/sniff.d.ts +3 -0
- package/dist-lib/lib/core/image/sniff.js +149 -0
- package/dist-lib/lib/core/invite.d.ts +14 -0
- package/dist-lib/lib/core/invite.js +36 -0
- package/dist-lib/lib/core/local/index.d.ts +71 -0
- package/dist-lib/lib/core/local/index.js +391 -0
- package/dist-lib/lib/core/membership.d.ts +15 -0
- package/dist-lib/lib/core/membership.js +40 -0
- package/dist-lib/lib/core/mesh.d.ts +153 -0
- package/dist-lib/lib/core/mesh.js +509 -0
- package/dist-lib/lib/core/migrations/agent-catalog.d.ts +6 -0
- package/dist-lib/lib/core/migrations/agent-catalog.js +17 -0
- package/dist-lib/lib/core/migrations/index.d.ts +5 -0
- package/dist-lib/lib/core/migrations/index.js +7 -0
- package/dist-lib/lib/core/migrations/membership.d.ts +11 -0
- package/dist-lib/lib/core/migrations/membership.js +26 -0
- package/dist-lib/lib/core/min-version.d.ts +6 -0
- package/dist-lib/lib/core/min-version.js +31 -0
- package/dist-lib/lib/core/next-frame.d.ts +6 -0
- package/dist-lib/lib/core/next-frame.js +27 -0
- package/dist-lib/lib/core/notification.d.ts +6 -0
- package/dist-lib/lib/core/notification.js +162 -0
- package/dist-lib/lib/core/ota-config.d.ts +19 -0
- package/dist-lib/lib/core/ota-config.js +44 -0
- package/dist-lib/lib/core/prompt-history.d.ts +12 -0
- package/dist-lib/lib/core/prompt-history.js +40 -0
- package/dist-lib/lib/core/search-fold.d.ts +1 -0
- package/dist-lib/lib/core/search-fold.js +4 -0
- package/dist-lib/lib/core/secret-handoff.d.ts +17 -0
- package/dist-lib/lib/core/secret-handoff.js +29 -0
- package/dist-lib/lib/core/send.d.ts +18 -0
- package/dist-lib/lib/core/send.js +46 -0
- package/dist-lib/lib/core/skill-overlay-handoff.d.ts +25 -0
- package/dist-lib/lib/core/skill-overlay-handoff.js +50 -0
- package/dist-lib/lib/core/skill-overlay-receiver.d.ts +8 -0
- package/dist-lib/lib/core/skill-overlay-receiver.js +20 -0
- package/dist-lib/lib/core/skill-secrets.d.ts +25 -0
- package/dist-lib/lib/core/skill-secrets.js +79 -0
- package/dist-lib/lib/core/sync/chats.d.ts +3 -0
- package/dist-lib/lib/core/sync/chats.js +5 -0
- package/dist-lib/lib/core/sync/chunks.d.ts +9 -0
- package/dist-lib/lib/core/sync/chunks.js +16 -0
- package/dist-lib/lib/core/sync/devices.d.ts +4 -0
- package/dist-lib/lib/core/sync/devices.js +12 -0
- package/dist-lib/lib/core/sync/files.d.ts +16 -0
- package/dist-lib/lib/core/sync/files.js +109 -0
- package/dist-lib/lib/core/sync/index.d.ts +5 -0
- package/dist-lib/lib/core/sync/index.js +63 -0
- package/dist-lib/lib/core/sync-status.d.ts +17 -0
- package/dist-lib/lib/core/sync-status.js +129 -0
- package/dist-lib/lib/core/system-info.d.ts +24 -0
- package/dist-lib/lib/core/system-info.js +66 -0
- package/dist-lib/lib/core/tool-activity.d.ts +22 -0
- package/dist-lib/lib/core/tool-activity.js +39 -0
- package/dist-lib/lib/core/tool-configs.d.ts +13 -0
- package/dist-lib/lib/core/tool-configs.js +141 -0
- package/dist-lib/lib/core.d.ts +291 -0
- package/dist-lib/lib/core.js +2126 -0
- package/dist-lib/lib/credential-pusher.d.ts +67 -0
- package/dist-lib/lib/credential-pusher.js +290 -0
- package/dist-lib/lib/custom-model-pusher.d.ts +9 -0
- package/dist-lib/lib/custom-model-pusher.js +42 -0
- package/dist-lib/lib/custom-model-source.d.ts +15 -0
- package/dist-lib/lib/custom-model-source.js +46 -0
- package/dist-lib/lib/deadline.d.ts +9 -0
- package/dist-lib/lib/deadline.js +31 -0
- package/dist-lib/lib/diagnostics.d.ts +35 -0
- package/dist-lib/lib/diagnostics.js +14 -0
- package/dist-lib/lib/fetch-node.d.ts +1 -0
- package/dist-lib/lib/fetch-node.js +1 -0
- package/dist-lib/lib/fs-drive-bridge.d.ts +12 -0
- package/dist-lib/lib/fs-drive-bridge.js +186 -0
- package/dist-lib/lib/fs-grant-keys.d.ts +2 -0
- package/dist-lib/lib/fs-grant-keys.js +6 -0
- package/dist-lib/lib/fs-grants.d.ts +10 -0
- package/dist-lib/lib/fs-grants.js +44 -0
- package/dist-lib/lib/image-cache-dir.d.ts +1 -0
- package/dist-lib/lib/image-cache-dir.js +5 -0
- package/dist-lib/lib/integrations/index.d.ts +4 -0
- package/dist-lib/lib/integrations/index.js +3 -0
- package/dist-lib/lib/integrations/mcp-providers.d.ts +12 -0
- package/dist-lib/lib/integrations/mcp-providers.js +22 -0
- package/dist-lib/lib/integrations/oauth-providers.d.ts +14 -0
- package/dist-lib/lib/integrations/oauth-providers.js +116 -0
- package/dist-lib/lib/integrations/setup-routes.d.ts +12 -0
- package/dist-lib/lib/integrations/setup-routes.js +114 -0
- package/dist-lib/lib/knowledge-search.d.ts +7 -0
- package/dist-lib/lib/knowledge-search.js +53 -0
- package/dist-lib/lib/kv-cache-reclaim.d.ts +5 -0
- package/dist-lib/lib/kv-cache-reclaim.js +29 -0
- package/dist-lib/lib/kv-cache.d.ts +18 -0
- package/dist-lib/lib/kv-cache.js +33 -0
- package/dist-lib/lib/legacy-core-domain.d.ts +258 -0
- package/dist-lib/lib/legacy-core-domain.js +1 -0
- package/dist-lib/lib/llm-model-names.d.ts +1 -0
- package/dist-lib/lib/llm-model-names.js +1 -0
- package/dist-lib/lib/log-buffer.d.ts +7 -0
- package/dist-lib/lib/log-buffer.js +16 -0
- package/dist-lib/lib/log-levels.d.ts +7 -0
- package/dist-lib/lib/log-levels.js +1 -0
- package/dist-lib/lib/log.d.ts +60 -0
- package/dist-lib/lib/log.js +149 -0
- package/dist-lib/lib/logger-type.d.ts +13 -0
- package/dist-lib/lib/logger-type.js +1 -0
- package/dist-lib/lib/logger.d.ts +5 -0
- package/dist-lib/lib/logger.js +18 -0
- package/dist-lib/lib/model-catalog-revision.d.ts +9 -0
- package/dist-lib/lib/model-catalog-revision.js +65 -0
- package/dist-lib/lib/model-clamp.d.ts +6 -0
- package/dist-lib/lib/model-clamp.js +20 -0
- package/dist-lib/lib/model-context.d.ts +13 -0
- package/dist-lib/lib/model-context.js +71 -0
- package/dist-lib/lib/model-download-status.d.ts +29 -0
- package/dist-lib/lib/model-download-status.js +56 -0
- package/dist-lib/lib/model-download.d.ts +191 -0
- package/dist-lib/lib/model-download.js +787 -0
- package/dist-lib/lib/oauth/asana.d.ts +35 -0
- package/dist-lib/lib/oauth/asana.js +71 -0
- package/dist-lib/lib/oauth/browser-connect.d.ts +22 -0
- package/dist-lib/lib/oauth/browser-connect.js +83 -0
- package/dist-lib/lib/oauth/client.d.ts +9 -0
- package/dist-lib/lib/oauth/client.js +9 -0
- package/dist-lib/lib/oauth/common.d.ts +38 -0
- package/dist-lib/lib/oauth/common.js +36 -0
- package/dist-lib/lib/oauth/crypto.d.ts +3 -0
- package/dist-lib/lib/oauth/crypto.js +25 -0
- package/dist-lib/lib/oauth/fetch-platform.d.ts +1 -0
- package/dist-lib/lib/oauth/fetch-platform.js +1 -0
- package/dist-lib/lib/oauth/flow-core.d.ts +6 -0
- package/dist-lib/lib/oauth/flow-core.js +37 -0
- package/dist-lib/lib/oauth/flow.d.ts +3 -0
- package/dist-lib/lib/oauth/flow.js +24 -0
- package/dist-lib/lib/oauth/google.d.ts +37 -0
- package/dist-lib/lib/oauth/google.js +77 -0
- package/dist-lib/lib/oauth/host.d.ts +5 -0
- package/dist-lib/lib/oauth/host.js +3 -0
- package/dist-lib/lib/oauth/keys.d.ts +25 -0
- package/dist-lib/lib/oauth/keys.js +93 -0
- package/dist-lib/lib/oauth/loopback.d.ts +3 -0
- package/dist-lib/lib/oauth/loopback.js +119 -0
- package/dist-lib/lib/oauth/loopback.stub.d.ts +3 -0
- package/dist-lib/lib/oauth/loopback.stub.js +6 -0
- package/dist-lib/lib/oauth/notion.d.ts +34 -0
- package/dist-lib/lib/oauth/notion.js +82 -0
- package/dist-lib/lib/oauth/pkce-runtime.d.ts +3 -0
- package/dist-lib/lib/oauth/pkce-runtime.js +5 -0
- package/dist-lib/lib/oauth/pkce.d.ts +8 -0
- package/dist-lib/lib/oauth/pkce.js +6 -0
- package/dist-lib/lib/oauth/providers.d.ts +5 -0
- package/dist-lib/lib/oauth/providers.js +73 -0
- package/dist-lib/lib/oauth/redirect-types.d.ts +19 -0
- package/dist-lib/lib/oauth/redirect-types.js +1 -0
- package/dist-lib/lib/oauth/register.d.ts +3 -0
- package/dist-lib/lib/oauth/register.js +34 -0
- package/dist-lib/lib/oauth/resolve.d.ts +17 -0
- package/dist-lib/lib/oauth/resolve.js +57 -0
- package/dist-lib/lib/oauth/spotify.d.ts +32 -0
- package/dist-lib/lib/oauth/spotify.js +73 -0
- package/dist-lib/lib/oauth/token-exchange-core.d.ts +6 -0
- package/dist-lib/lib/oauth/token-exchange-core.js +97 -0
- package/dist-lib/lib/oauth/token-exchange.d.ts +5 -0
- package/dist-lib/lib/oauth/token-exchange.js +9 -0
- package/dist-lib/lib/oauth/types.d.ts +54 -0
- package/dist-lib/lib/oauth/types.js +1 -0
- package/dist-lib/lib/oauth.client.d.ts +5 -0
- package/dist-lib/lib/oauth.client.js +2 -0
- package/dist-lib/lib/oauth.d.ts +14 -0
- package/dist-lib/lib/oauth.js +12 -0
- package/dist-lib/lib/obsidian-key.d.ts +1 -0
- package/dist-lib/lib/obsidian-key.js +1 -0
- package/dist-lib/lib/race-resource.d.ts +5 -0
- package/dist-lib/lib/race-resource.js +25 -0
- package/dist-lib/lib/reconnecting-watch.d.ts +2 -0
- package/dist-lib/lib/reconnecting-watch.js +78 -0
- package/dist-lib/lib/retry-budget.d.ts +14 -0
- package/dist-lib/lib/retry-budget.js +39 -0
- package/dist-lib/lib/run-notices.d.ts +23 -0
- package/dist-lib/lib/run-notices.js +33 -0
- package/dist-lib/lib/run-transcript.d.ts +35 -0
- package/dist-lib/lib/run-transcript.js +106 -0
- package/dist-lib/lib/skill-readiness.d.ts +2 -0
- package/dist-lib/lib/skill-readiness.js +21 -0
- package/dist-lib/lib/skill-types.d.ts +70 -0
- package/dist-lib/lib/skill-types.js +1 -0
- package/dist-lib/lib/spec-loader.d.ts +14 -0
- package/dist-lib/lib/spec-loader.js +9 -0
- package/dist-lib/lib/suspend-lifecycle.d.ts +17 -0
- package/dist-lib/lib/suspend-lifecycle.js +33 -0
- package/dist-lib/lib/task.d.ts +26 -0
- package/dist-lib/lib/task.js +69 -0
- package/dist-lib/lib/unref.d.ts +3 -0
- package/dist-lib/lib/unref.js +4 -0
- package/dist-lib/lib/wav-duration.d.ts +1 -0
- package/dist-lib/lib/wav-duration.js +53 -0
- package/dist-lib/lib/write-queue.d.ts +22 -0
- package/dist-lib/lib/write-queue.js +39 -0
- package/dist-lib/schema/build.d.ts +1 -0
- package/dist-lib/schema/build.js +120 -0
- package/dist-lib/schema/config.d.ts +4 -0
- package/dist-lib/schema/config.js +7 -0
- package/dist-lib/schema/content.d.ts +20 -0
- package/dist-lib/schema/content.js +122 -0
- package/dist-lib/schema/engine.d.ts +2 -0
- package/dist-lib/schema/engine.js +2013 -0
- package/dist-lib/schema/field-order.d.ts +1 -0
- package/dist-lib/schema/field-order.js +95 -0
- package/dist-lib/schema/local.d.ts +2 -0
- package/dist-lib/schema/local.js +133 -0
- package/dist-lib/schema/qvac.d.ts +22 -0
- package/dist-lib/schema/qvac.js +722 -0
- package/dist-lib/spec/bind.d.ts +2 -0
- package/dist-lib/spec/bind.js +520 -0
- package/dist-lib/spec/calls.d.ts +3 -0
- package/dist-lib/spec/calls.js +129 -0
- package/dist-lib/spec/capabilities.d.ts +263 -0
- package/dist-lib/spec/config/hyperconf/index.d.ts +15 -0
- package/dist-lib/spec/config/hyperconf/index.js +24 -0
- package/dist-lib/spec/config/hyperconf/package.json +3 -0
- package/dist-lib/spec/config/hyperschema/index.js +81 -0
- package/dist-lib/spec/config/hyperschema/schema.json +19 -0
- package/dist-lib/spec/hrpc/hrpc.json +1500 -0
- package/dist-lib/spec/hrpc/index.d.ts +3 -0
- package/dist-lib/spec/hrpc/index.js +1545 -0
- package/dist-lib/spec/hrpc/messages.d.ts +4 -0
- package/dist-lib/spec/hrpc/messages.js +8373 -0
- package/dist-lib/spec/hyperschema/index.d.ts +20 -0
- package/dist-lib/spec/hyperschema/index.js +8373 -0
- package/dist-lib/spec/hyperschema/schema.json +6202 -0
- package/dist-lib/spec/hyperschema/types.d.ts +1545 -0
- package/dist-lib/spec/index.d.ts +36 -0
- package/dist-lib/spec/index.js +6 -0
- package/dist-lib/spec/local/hyperdb/db.json +186 -0
- package/dist-lib/spec/local/hyperdb/index.d.ts +9 -0
- package/dist-lib/spec/local/hyperdb/index.js +855 -0
- package/dist-lib/spec/local/hyperdb/messages.js +2189 -0
- package/dist-lib/spec/local/hyperschema/index.js +1208 -0
- package/dist-lib/spec/local/hyperschema/schema.json +639 -0
- package/dist-lib/spec/local/hyperschema/types.d.ts +159 -0
- package/dist-lib/spec/mesh/hyperdb/db.json +702 -0
- package/dist-lib/spec/mesh/hyperdb/index.d.ts +9 -0
- package/dist-lib/spec/mesh/hyperdb/index.js +2260 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +7453 -0
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +174 -0
- package/dist-lib/spec/mesh/hyperdispatch/index.d.ts +13 -0
- package/dist-lib/spec/mesh/hyperdispatch/index.js +566 -0
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +5713 -0
- package/dist-lib/spec/mesh/hyperschema/index.d.ts +14 -0
- package/dist-lib/spec/mesh/hyperschema/index.js +5713 -0
- package/dist-lib/spec/mesh/hyperschema/schema.json +3142 -0
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +754 -0
- package/ducks.png +0 -0
- package/package.json +332 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const SUMMARIZE_MARKERS = [
|
|
2
|
+
/\bsummar(?:ize|ise|y|ies)\b/,
|
|
3
|
+
/\btldr\b/,
|
|
4
|
+
/\boverview\b/,
|
|
5
|
+
/\bkey (?:points|takeaways)\b/,
|
|
6
|
+
/\bmain (?:points|ideas)\b/,
|
|
7
|
+
/\bgist\b/,
|
|
8
|
+
/\brecap\b/,
|
|
9
|
+
/\bwhat(?:'s| is| are)? (?:this|these|it) about\b/,
|
|
10
|
+
/\bwhat(?:'s| is| are) (?:in|on)\b/,
|
|
11
|
+
/\bwhat (?:do|does)\b.*\bcontain\b/
|
|
12
|
+
];
|
|
13
|
+
const FILLER = new Set([
|
|
14
|
+
'a',
|
|
15
|
+
'about',
|
|
16
|
+
'all',
|
|
17
|
+
'an',
|
|
18
|
+
'and',
|
|
19
|
+
'attached',
|
|
20
|
+
'brief',
|
|
21
|
+
'briefly',
|
|
22
|
+
'can',
|
|
23
|
+
'concise',
|
|
24
|
+
'content',
|
|
25
|
+
'contents',
|
|
26
|
+
'contain',
|
|
27
|
+
'do',
|
|
28
|
+
'does',
|
|
29
|
+
'doc',
|
|
30
|
+
'docs',
|
|
31
|
+
'document',
|
|
32
|
+
'documents',
|
|
33
|
+
'file',
|
|
34
|
+
'files',
|
|
35
|
+
'for',
|
|
36
|
+
'give',
|
|
37
|
+
'in',
|
|
38
|
+
'is',
|
|
39
|
+
'it',
|
|
40
|
+
'its',
|
|
41
|
+
'me',
|
|
42
|
+
'my',
|
|
43
|
+
'of',
|
|
44
|
+
'on',
|
|
45
|
+
'pdf',
|
|
46
|
+
'please',
|
|
47
|
+
'provide',
|
|
48
|
+
'short',
|
|
49
|
+
'some',
|
|
50
|
+
'the',
|
|
51
|
+
'their',
|
|
52
|
+
'them',
|
|
53
|
+
'these',
|
|
54
|
+
'this',
|
|
55
|
+
'those',
|
|
56
|
+
'to',
|
|
57
|
+
'up',
|
|
58
|
+
'us',
|
|
59
|
+
'what',
|
|
60
|
+
'whole',
|
|
61
|
+
'you',
|
|
62
|
+
'your'
|
|
63
|
+
]);
|
|
64
|
+
const MARKER_WORDS = new Set([
|
|
65
|
+
'are',
|
|
66
|
+
'dr',
|
|
67
|
+
'gist',
|
|
68
|
+
'ideas',
|
|
69
|
+
'key',
|
|
70
|
+
'main',
|
|
71
|
+
'overview',
|
|
72
|
+
'points',
|
|
73
|
+
'recap',
|
|
74
|
+
'summaries',
|
|
75
|
+
'summarise',
|
|
76
|
+
'summarize',
|
|
77
|
+
'summary',
|
|
78
|
+
'takeaways',
|
|
79
|
+
'tl',
|
|
80
|
+
'tldr'
|
|
81
|
+
]);
|
|
82
|
+
const CLAUSE_BOUNDARY = /[.!?;\n]+|\band\b|\balso\b|\bthen\b/;
|
|
83
|
+
export function isWholeDocumentQuery(query) {
|
|
84
|
+
const normalized = query
|
|
85
|
+
.toLowerCase()
|
|
86
|
+
.replace(/\bwhat's\b/g, 'what is')
|
|
87
|
+
.replace(/\btl[;:\s-]?dr\b/g, 'tldr')
|
|
88
|
+
.replace(/[_-]+/g, ' ');
|
|
89
|
+
return normalized.split(CLAUSE_BOUNDARY).some(isBareSummarizeClause);
|
|
90
|
+
}
|
|
91
|
+
function isBareSummarizeClause(clause) {
|
|
92
|
+
if (!SUMMARIZE_MARKERS.some((marker) => marker.test(clause)))
|
|
93
|
+
return false;
|
|
94
|
+
const words = clause.match(/[a-z0-9]+/g) ?? [];
|
|
95
|
+
return words.every((word) => FILLER.has(word) || MARKER_WORDS.has(word));
|
|
96
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { VectorCandidate, VectorChunk, VectorHit, VectorIndex, VectorIndexInfo } from './types.ts';
|
|
2
|
+
export declare class MemoryVectorIndex implements VectorIndex {
|
|
3
|
+
private readonly _artifacts;
|
|
4
|
+
private _chunks;
|
|
5
|
+
private _dimensions;
|
|
6
|
+
info(): VectorIndexInfo;
|
|
7
|
+
upsert(artifactId: string, chunks: ReadonlyArray<VectorChunk>): Promise<void>;
|
|
8
|
+
remove(artifactId: string): Promise<void>;
|
|
9
|
+
search(embedding: ReadonlyArray<number>, opts: {
|
|
10
|
+
readonly limit: number;
|
|
11
|
+
readonly filter?: (candidate: VectorCandidate) => boolean;
|
|
12
|
+
}): Promise<ReadonlyArray<VectorHit>>;
|
|
13
|
+
clear(): Promise<void>;
|
|
14
|
+
private _pack;
|
|
15
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export class MemoryVectorIndex {
|
|
2
|
+
_artifacts = new Map();
|
|
3
|
+
_chunks = 0;
|
|
4
|
+
_dimensions = null;
|
|
5
|
+
info() {
|
|
6
|
+
return { artifacts: this._artifacts.size, chunks: this._chunks, dimensions: this._dimensions };
|
|
7
|
+
}
|
|
8
|
+
upsert(artifactId, chunks) {
|
|
9
|
+
const packed = this._pack(chunks);
|
|
10
|
+
const prev = this._artifacts.get(artifactId);
|
|
11
|
+
if (prev)
|
|
12
|
+
this._chunks -= prev.ids.length;
|
|
13
|
+
this._artifacts.set(artifactId, packed.artifact);
|
|
14
|
+
this._chunks += packed.artifact.ids.length;
|
|
15
|
+
if (packed.dimensions !== null && this._dimensions === null) {
|
|
16
|
+
this._dimensions = packed.dimensions;
|
|
17
|
+
}
|
|
18
|
+
if (this._chunks === 0)
|
|
19
|
+
this._dimensions = null;
|
|
20
|
+
return Promise.resolve();
|
|
21
|
+
}
|
|
22
|
+
remove(artifactId) {
|
|
23
|
+
const prev = this._artifacts.get(artifactId);
|
|
24
|
+
if (!prev)
|
|
25
|
+
return Promise.resolve();
|
|
26
|
+
this._artifacts.delete(artifactId);
|
|
27
|
+
this._chunks -= prev.ids.length;
|
|
28
|
+
if (this._chunks === 0)
|
|
29
|
+
this._dimensions = null;
|
|
30
|
+
return Promise.resolve();
|
|
31
|
+
}
|
|
32
|
+
search(embedding, opts) {
|
|
33
|
+
if (this._chunks === 0 || opts.limit <= 0)
|
|
34
|
+
return Promise.resolve([]);
|
|
35
|
+
if (this._dimensions !== null && embedding.length !== this._dimensions) {
|
|
36
|
+
throw new Error(`vector index: query has ${embedding.length} dimensions, the index holds ${this._dimensions}`);
|
|
37
|
+
}
|
|
38
|
+
const dimensions = embedding.length;
|
|
39
|
+
const query = new Float64Array(dimensions);
|
|
40
|
+
let sum = 0;
|
|
41
|
+
for (let d = 0; d < dimensions; d++) {
|
|
42
|
+
const value = embedding[d];
|
|
43
|
+
if (!Number.isFinite(value))
|
|
44
|
+
throw new Error('vector index: query embedding is not finite');
|
|
45
|
+
query[d] = value;
|
|
46
|
+
sum += value * value;
|
|
47
|
+
}
|
|
48
|
+
const queryNorm = Math.sqrt(sum);
|
|
49
|
+
const scored = [];
|
|
50
|
+
for (const artifact of this._artifacts.values()) {
|
|
51
|
+
for (let i = 0; i < artifact.ids.length; i++) {
|
|
52
|
+
if (opts.filter) {
|
|
53
|
+
const candidate = {
|
|
54
|
+
id: artifact.ids[i],
|
|
55
|
+
content: artifact.contents[i],
|
|
56
|
+
metadataJson: artifact.metadataJsons[i]
|
|
57
|
+
};
|
|
58
|
+
if (!opts.filter(candidate))
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
let dot = 0;
|
|
62
|
+
const base = i * dimensions;
|
|
63
|
+
for (let d = 0; d < dimensions; d++)
|
|
64
|
+
dot += artifact.vectors[base + d] * query[d];
|
|
65
|
+
const denominator = artifact.norms[i] * queryNorm;
|
|
66
|
+
scored.push({
|
|
67
|
+
id: artifact.ids[i],
|
|
68
|
+
content: artifact.contents[i],
|
|
69
|
+
metadataJson: artifact.metadataJsons[i],
|
|
70
|
+
cosine: denominator > 0 ? dot / denominator : 0
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
scored.sort((a, b) => b.cosine - a.cosine);
|
|
75
|
+
const results = scored.slice(0, opts.limit).map((entry) => ({
|
|
76
|
+
id: entry.id,
|
|
77
|
+
content: entry.content,
|
|
78
|
+
metadataJson: entry.metadataJson,
|
|
79
|
+
score: Math.max(0, entry.cosine)
|
|
80
|
+
}));
|
|
81
|
+
return Promise.resolve(results);
|
|
82
|
+
}
|
|
83
|
+
clear() {
|
|
84
|
+
this._artifacts.clear();
|
|
85
|
+
this._chunks = 0;
|
|
86
|
+
this._dimensions = null;
|
|
87
|
+
return Promise.resolve();
|
|
88
|
+
}
|
|
89
|
+
_pack(chunks) {
|
|
90
|
+
if (chunks.length === 0) {
|
|
91
|
+
return {
|
|
92
|
+
artifact: {
|
|
93
|
+
ids: [],
|
|
94
|
+
contents: [],
|
|
95
|
+
metadataJsons: [],
|
|
96
|
+
vectors: new Float32Array(0),
|
|
97
|
+
norms: new Float64Array(0)
|
|
98
|
+
},
|
|
99
|
+
dimensions: null
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const dimensions = chunks[0].embedding.length;
|
|
103
|
+
if (dimensions === 0)
|
|
104
|
+
throw new Error('vector index: chunk embedding is empty');
|
|
105
|
+
if (this._dimensions !== null && dimensions !== this._dimensions) {
|
|
106
|
+
throw new Error(`vector index: artifact has ${dimensions} dimensions, the index holds ${this._dimensions}`);
|
|
107
|
+
}
|
|
108
|
+
const ids = [];
|
|
109
|
+
const contents = [];
|
|
110
|
+
const metadataJsons = [];
|
|
111
|
+
const vectors = new Float32Array(chunks.length * dimensions);
|
|
112
|
+
const norms = new Float64Array(chunks.length);
|
|
113
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
114
|
+
const chunk = chunks[i];
|
|
115
|
+
if (chunk.embedding.length !== dimensions) {
|
|
116
|
+
throw new Error(`vector index: chunk ${chunk.id} disagrees on dimensions`);
|
|
117
|
+
}
|
|
118
|
+
let sum = 0;
|
|
119
|
+
for (let d = 0; d < dimensions; d++) {
|
|
120
|
+
const value = chunk.embedding[d];
|
|
121
|
+
if (!Number.isFinite(value)) {
|
|
122
|
+
throw new Error(`vector index: chunk ${chunk.id} embedding is not finite`);
|
|
123
|
+
}
|
|
124
|
+
const stored = Math.fround(value);
|
|
125
|
+
vectors[i * dimensions + d] = stored;
|
|
126
|
+
sum += stored * stored;
|
|
127
|
+
}
|
|
128
|
+
norms[i] = Math.sqrt(sum);
|
|
129
|
+
ids.push(chunk.id);
|
|
130
|
+
contents.push(chunk.content);
|
|
131
|
+
metadataJsons.push(chunk.metadataJson);
|
|
132
|
+
}
|
|
133
|
+
return { artifact: { ids, contents, metadataJsons, vectors, norms }, dimensions };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type VectorChunk = {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly content: string;
|
|
4
|
+
readonly metadataJson: string;
|
|
5
|
+
readonly embedding: ReadonlyArray<number>;
|
|
6
|
+
};
|
|
7
|
+
export type VectorHit = {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly content: string;
|
|
10
|
+
readonly metadataJson: string;
|
|
11
|
+
readonly score: number;
|
|
12
|
+
};
|
|
13
|
+
export type VectorCandidate = Omit<VectorHit, 'score'>;
|
|
14
|
+
export type VectorIndexInfo = {
|
|
15
|
+
readonly artifacts: number;
|
|
16
|
+
readonly chunks: number;
|
|
17
|
+
readonly dimensions: number | null;
|
|
18
|
+
};
|
|
19
|
+
export interface VectorIndex {
|
|
20
|
+
info(): VectorIndexInfo;
|
|
21
|
+
upsert(artifactId: string, chunks: ReadonlyArray<VectorChunk>): Promise<void>;
|
|
22
|
+
remove(artifactId: string): Promise<void>;
|
|
23
|
+
search(embedding: ReadonlyArray<number>, opts: {
|
|
24
|
+
readonly limit: number;
|
|
25
|
+
readonly filter?: (candidate: VectorCandidate) => boolean;
|
|
26
|
+
}): Promise<ReadonlyArray<VectorHit>>;
|
|
27
|
+
clear(): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { hasLiveSource } from "./routing.js";
|
|
2
|
+
export async function syncAttachmentChunk(mesh, chunk) {
|
|
3
|
+
if (chunk.type !== 'attachment')
|
|
4
|
+
return;
|
|
5
|
+
const attachment = chunk.attachment;
|
|
6
|
+
if (!attachment?.deletedAt || typeof attachment.blobId !== 'string')
|
|
7
|
+
return;
|
|
8
|
+
if (await hasLiveSource(mesh, chunk.chatId, attachment.blobId))
|
|
9
|
+
return;
|
|
10
|
+
logger.debug('sync', 'attachment tombstone observed — reclaiming blob bytes', { id: chunk.id });
|
|
11
|
+
await mesh.files.clear(attachment.blobId, chunk.id);
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { addKnowledge, addKnowledgeArtifact, assertRemovableAt, findKnowledgeArtifactsByKnowledge, getKnowledge, getKnowledgeArtifact, listKnowledge, listKnowledgeArtifactsByKnowledge, removeKnowledge } from './knowledge.ts';
|
|
2
|
+
export type { AddKnowledgeInput, AddKnowledgeArtifactInput } from './knowledge.ts';
|
|
3
|
+
export { attachTurnDocumentIds, hasLiveSource, isKnowledgeRoutedAttachment, routeAttachmentToKnowledge } from './routing.ts';
|
|
4
|
+
export { groupAttachmentsByMessage } from './linkage.ts';
|
|
5
|
+
export { syncAttachmentChunk } from './chunks.ts';
|
|
6
|
+
export { sweepTombstonedBlobs, syncArtifactArrival, syncKnowledgeTombstone } from './reclaim.ts';
|
|
7
|
+
export { referencedBlobs } from './sweep.ts';
|
|
8
|
+
export { assertArtifactOutput, isProcessorOutput, processorArtifactId, isProcessorArtifactId } from './output.ts';
|
|
9
|
+
export { attachmentRecord, fileRecord, fileIds, scopedFile, claimSource } from './source.ts';
|
|
10
|
+
export type { FileInput, FileRecord } from './source.ts';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { addKnowledge, addKnowledgeArtifact, assertRemovableAt, findKnowledgeArtifactsByKnowledge, getKnowledge, getKnowledgeArtifact, listKnowledge, listKnowledgeArtifactsByKnowledge, removeKnowledge } from "./knowledge.js";
|
|
2
|
+
export { attachTurnDocumentIds, hasLiveSource, isKnowledgeRoutedAttachment, routeAttachmentToKnowledge } from "./routing.js";
|
|
3
|
+
export { groupAttachmentsByMessage } from "./linkage.js";
|
|
4
|
+
export { syncAttachmentChunk } from "./chunks.js";
|
|
5
|
+
export { sweepTombstonedBlobs, syncArtifactArrival, syncKnowledgeTombstone } from "./reclaim.js";
|
|
6
|
+
export { referencedBlobs } from "./sweep.js";
|
|
7
|
+
export { assertArtifactOutput, isProcessorOutput, processorArtifactId, isProcessorArtifactId } from "./output.js";
|
|
8
|
+
export { attachmentRecord, fileRecord, fileIds, scopedFile, claimSource } from "./source.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { QvacKnowledge, QvacKnowledgeArtifact } from '../../../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
import type { Mesh } from '../../mesh.ts';
|
|
3
|
+
export type AddKnowledgeInput = Pick<QvacKnowledge, 'chatId' | 'fileName' | 'mimeType' | 'byteLength' | 'blobId'> & Partial<Pick<QvacKnowledge, 'id'>>;
|
|
4
|
+
export declare function getKnowledge(store: Mesh, id: string): Promise<QvacKnowledge | null>;
|
|
5
|
+
export declare function listKnowledge(store: Mesh, { chatId }: {
|
|
6
|
+
chatId: string;
|
|
7
|
+
}): Promise<QvacKnowledge[]>;
|
|
8
|
+
export declare function addKnowledge(store: Mesh, input: AddKnowledgeInput): Promise<QvacKnowledge>;
|
|
9
|
+
export declare function assertRemovableAt(at: number): void;
|
|
10
|
+
export declare function removeKnowledge(store: Mesh, { knowledgeId, at }: {
|
|
11
|
+
knowledgeId: string;
|
|
12
|
+
at: number;
|
|
13
|
+
}): Promise<QvacKnowledge>;
|
|
14
|
+
export type AddKnowledgeArtifactInput = Omit<QvacKnowledgeArtifact, 'createdAt'>;
|
|
15
|
+
export declare function getKnowledgeArtifact(store: Mesh, id: string): Promise<QvacKnowledgeArtifact | null>;
|
|
16
|
+
type KnowledgeSnapshot = ReturnType<Mesh['view']['snapshot']>;
|
|
17
|
+
export declare function listKnowledgeArtifactsByKnowledge(store: Mesh, { knowledgeId }: {
|
|
18
|
+
knowledgeId: string;
|
|
19
|
+
}): Promise<QvacKnowledgeArtifact[]>;
|
|
20
|
+
export declare function findKnowledgeArtifactsByKnowledge(snap: KnowledgeSnapshot, knowledgeId: string): Promise<QvacKnowledgeArtifact[]>;
|
|
21
|
+
export declare function addKnowledgeArtifact(store: Mesh, input: AddKnowledgeArtifactInput): Promise<QvacKnowledgeArtifact>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { randomId } from "../../id.js";
|
|
2
|
+
import { assertArtifactOutput } from "./output.js";
|
|
3
|
+
const KNOWLEDGE = '@qvac/knowledge';
|
|
4
|
+
const ACTIVE_KNOWLEDGE_BY_CHAT = '@qvac/active-knowledge-by-chat';
|
|
5
|
+
const KNOWLEDGE_ARTIFACTS = '@qvac/knowledge-artifacts';
|
|
6
|
+
const KNOWLEDGE_ARTIFACTS_BY_KNOWLEDGE = '@qvac/knowledge-artifacts-by-knowledge';
|
|
7
|
+
export async function getKnowledge(store, id) {
|
|
8
|
+
const snap = store.view.snapshot();
|
|
9
|
+
try {
|
|
10
|
+
const row = await snap.get(KNOWLEDGE, { id });
|
|
11
|
+
return row;
|
|
12
|
+
}
|
|
13
|
+
finally {
|
|
14
|
+
await snap.close();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function mustGetKnowledge(store, id) {
|
|
18
|
+
const row = await getKnowledge(store, id);
|
|
19
|
+
if (!row)
|
|
20
|
+
throw new Error(`knowledge not found: ${id}`);
|
|
21
|
+
return row;
|
|
22
|
+
}
|
|
23
|
+
export async function listKnowledge(store, { chatId }) {
|
|
24
|
+
const snap = store.view.snapshot();
|
|
25
|
+
try {
|
|
26
|
+
const rows = await snap
|
|
27
|
+
.find(ACTIVE_KNOWLEDGE_BY_CHAT, { gte: { chatId }, lte: { chatId } })
|
|
28
|
+
.toArray();
|
|
29
|
+
return rows;
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
await snap.close();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export async function addKnowledge(store, input) {
|
|
36
|
+
const now = Date.now();
|
|
37
|
+
const knowledge = {
|
|
38
|
+
...input,
|
|
39
|
+
id: input.id ?? randomId(),
|
|
40
|
+
createdAt: now,
|
|
41
|
+
updatedAt: now
|
|
42
|
+
};
|
|
43
|
+
await store.dispatch('add-knowledge', { knowledge });
|
|
44
|
+
return await mustGetKnowledge(store, knowledge.id);
|
|
45
|
+
}
|
|
46
|
+
export function assertRemovableAt(at) {
|
|
47
|
+
if (!at || at < 0) {
|
|
48
|
+
throw new Error(`remove-knowledge needs a positive timestamp, got ${at}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export async function removeKnowledge(store, { knowledgeId, at }) {
|
|
52
|
+
assertRemovableAt(at);
|
|
53
|
+
const existing = await mustGetKnowledge(store, knowledgeId);
|
|
54
|
+
if (existing.deletedAt)
|
|
55
|
+
return existing;
|
|
56
|
+
await store.dispatch('remove-knowledge', { knowledgeId, at });
|
|
57
|
+
const removed = await mustGetKnowledge(store, knowledgeId);
|
|
58
|
+
return removed;
|
|
59
|
+
}
|
|
60
|
+
const ARTIFACT_STRING_FIELDS = [
|
|
61
|
+
'id',
|
|
62
|
+
'knowledgeId',
|
|
63
|
+
'sourceHash',
|
|
64
|
+
'embedderVersion',
|
|
65
|
+
'artifactBlobId'
|
|
66
|
+
];
|
|
67
|
+
export async function getKnowledgeArtifact(store, id) {
|
|
68
|
+
const snap = store.view.snapshot();
|
|
69
|
+
try {
|
|
70
|
+
const artifact = await snap.get(KNOWLEDGE_ARTIFACTS, { id });
|
|
71
|
+
return artifact;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
await snap.close();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export async function listKnowledgeArtifactsByKnowledge(store, { knowledgeId }) {
|
|
78
|
+
const snap = store.view.snapshot();
|
|
79
|
+
try {
|
|
80
|
+
return await findKnowledgeArtifactsByKnowledge(snap, knowledgeId);
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
await snap.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export async function findKnowledgeArtifactsByKnowledge(snap, knowledgeId) {
|
|
87
|
+
return await snap
|
|
88
|
+
.find(KNOWLEDGE_ARTIFACTS_BY_KNOWLEDGE, {
|
|
89
|
+
gte: { knowledgeId },
|
|
90
|
+
lte: { knowledgeId }
|
|
91
|
+
})
|
|
92
|
+
.toArray();
|
|
93
|
+
}
|
|
94
|
+
export async function addKnowledgeArtifact(store, input) {
|
|
95
|
+
for (const field of ARTIFACT_STRING_FIELDS) {
|
|
96
|
+
if (!input[field])
|
|
97
|
+
throw new Error(`knowledge-artifact needs a non-empty ${field}`);
|
|
98
|
+
}
|
|
99
|
+
assertArtifactOutput(input);
|
|
100
|
+
await store.dispatch('add-knowledge-artifact', { artifact: { ...input, createdAt: Date.now() } });
|
|
101
|
+
const row = await getKnowledgeArtifact(store, input.id);
|
|
102
|
+
if (!row)
|
|
103
|
+
throw new Error(`knowledge-artifact not found after add: ${input.id}`);
|
|
104
|
+
return row;
|
|
105
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const REPLY_MESSAGE_PREFIX = "reply-";
|
|
2
|
+
export declare function replyMessageId(runId: string): string;
|
|
3
|
+
interface LinkableChunk {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly runId?: string | null;
|
|
6
|
+
readonly seq: number;
|
|
7
|
+
readonly attachment?: unknown;
|
|
8
|
+
readonly userMessage?: unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare function groupAttachmentsByMessage<T extends LinkableChunk>(attachments: ReadonlyArray<T>, userMessages: ReadonlyArray<T>): Map<string, T[]>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const REPLY_MESSAGE_PREFIX = 'reply-';
|
|
2
|
+
export function replyMessageId(runId) {
|
|
3
|
+
return `${REPLY_MESSAGE_PREFIX}${runId}`;
|
|
4
|
+
}
|
|
5
|
+
export function groupAttachmentsByMessage(attachments, userMessages) {
|
|
6
|
+
const groups = new Map();
|
|
7
|
+
const push = (messageId, chunk) => {
|
|
8
|
+
const list = groups.get(messageId);
|
|
9
|
+
if (list)
|
|
10
|
+
list.push(chunk);
|
|
11
|
+
else
|
|
12
|
+
groups.set(messageId, [chunk]);
|
|
13
|
+
};
|
|
14
|
+
let boundary = 0;
|
|
15
|
+
for (const attachment of attachments) {
|
|
16
|
+
if (attachment.runId) {
|
|
17
|
+
push(replyMessageId(attachment.runId), attachment);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
while (boundary < userMessages.length && userMessages[boundary].seq <= attachment.seq) {
|
|
21
|
+
boundary++;
|
|
22
|
+
}
|
|
23
|
+
if (boundary < userMessages.length)
|
|
24
|
+
push(userMessages[boundary].id, attachment);
|
|
25
|
+
}
|
|
26
|
+
return groups;
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { QvacKnowledgeArtifact } from '../../../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
export declare function processorArtifactId({ processorId, hash }: {
|
|
3
|
+
processorId: string;
|
|
4
|
+
hash: string;
|
|
5
|
+
}): string;
|
|
6
|
+
export declare function isProcessorArtifactId(id: string): boolean;
|
|
7
|
+
export declare function isProcessorOutput(version: string): boolean;
|
|
8
|
+
export declare function assertArtifactOutput(output: Pick<QvacKnowledgeArtifact, 'embedderVersion' | 'dimensions' | 'artifactBlobId'>): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MAX_REFERENCE_CHARS, parseBlobReference } from "../store/index.js";
|
|
2
|
+
const PROCESSOR_ID_SEPARATOR = ':';
|
|
3
|
+
export function processorArtifactId({ processorId, hash }) {
|
|
4
|
+
return `${processorId}${PROCESSOR_ID_SEPARATOR}${hash}`;
|
|
5
|
+
}
|
|
6
|
+
export function isProcessorArtifactId(id) {
|
|
7
|
+
return id.includes(PROCESSOR_ID_SEPARATOR);
|
|
8
|
+
}
|
|
9
|
+
export function isProcessorOutput(version) {
|
|
10
|
+
return version.startsWith('processor:') && !version.includes('|');
|
|
11
|
+
}
|
|
12
|
+
export function assertArtifactOutput(output) {
|
|
13
|
+
const processor = isProcessorOutput(output.embedderVersion);
|
|
14
|
+
if (processor
|
|
15
|
+
? output.dimensions !== 0
|
|
16
|
+
: !Number.isInteger(output.dimensions) || output.dimensions <= 0) {
|
|
17
|
+
throw new Error(processor
|
|
18
|
+
? 'processor output needs zero dimensions'
|
|
19
|
+
: `knowledge-artifact needs positive integer dimensions, got ${output.dimensions}`);
|
|
20
|
+
}
|
|
21
|
+
if (output.artifactBlobId.length > MAX_REFERENCE_CHARS) {
|
|
22
|
+
throw new Error('inline output exceeds 512 KiB');
|
|
23
|
+
}
|
|
24
|
+
let value;
|
|
25
|
+
try {
|
|
26
|
+
value = JSON.parse(output.artifactBlobId);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
if (!processor)
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const inline = value !== null && typeof value === 'object' && 'inline' in value;
|
|
33
|
+
if (!processor && !inline)
|
|
34
|
+
return;
|
|
35
|
+
const parsed = parseBlobReference(output.artifactBlobId);
|
|
36
|
+
if (parsed.inline && !processor)
|
|
37
|
+
throw new Error('inline outputs need a processor identity');
|
|
38
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { QvacKnowledge, QvacKnowledgeArtifact } from '../../../../spec/mesh/hyperschema/types';
|
|
2
|
+
import type { Mesh } from '../../mesh.ts';
|
|
3
|
+
export declare function syncKnowledgeTombstone(mesh: Mesh, row: QvacKnowledge): Promise<void>;
|
|
4
|
+
export declare function syncArtifactArrival(mesh: Mesh, row: QvacKnowledgeArtifact): Promise<void>;
|
|
5
|
+
export declare function sweepTombstonedBlobs(mesh: Mesh, deviceId?: Buffer | null): Promise<void>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { hasLiveSource } from "./routing.js";
|
|
2
|
+
import { removeChatAttachments, removeChatKnowledge } from "../../chat.js";
|
|
3
|
+
import { listChunks } from "../../chunk.js";
|
|
4
|
+
import { getKnowledge, listKnowledgeArtifactsByKnowledge } from "./knowledge.js";
|
|
5
|
+
import { syncAttachmentChunk } from "./chunks.js";
|
|
6
|
+
export async function syncKnowledgeTombstone(mesh, row) {
|
|
7
|
+
if (!row.deletedAt)
|
|
8
|
+
return;
|
|
9
|
+
logger.debug('sync', 'knowledge tombstone observed - reclaiming blob bytes', { id: row.id });
|
|
10
|
+
if (typeof row.blobId === 'string' && !(await hasLiveSource(mesh, row.chatId, row.blobId))) {
|
|
11
|
+
await mesh.files.clear(row.blobId, row.id);
|
|
12
|
+
}
|
|
13
|
+
for (const artifact of await listKnowledgeArtifactsByKnowledge(mesh, { knowledgeId: row.id })) {
|
|
14
|
+
if (mesh.closing)
|
|
15
|
+
return;
|
|
16
|
+
await mesh.files.clear(artifact.artifactBlobId, artifact.id);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export async function syncArtifactArrival(mesh, row) {
|
|
20
|
+
const knowledge = await getKnowledge(mesh, row.knowledgeId);
|
|
21
|
+
if (!knowledge?.deletedAt)
|
|
22
|
+
return;
|
|
23
|
+
await mesh.files.clear(row.artifactBlobId, row.id);
|
|
24
|
+
}
|
|
25
|
+
export async function sweepTombstonedBlobs(mesh, deviceId = null) {
|
|
26
|
+
if (deviceId && mesh.writable) {
|
|
27
|
+
const chats = mesh.view.snapshot();
|
|
28
|
+
try {
|
|
29
|
+
for await (const chat of chats.find('@qvac/chats')) {
|
|
30
|
+
if (mesh.closing)
|
|
31
|
+
return;
|
|
32
|
+
if (!chat.deletedAt)
|
|
33
|
+
continue;
|
|
34
|
+
await removeChatAttachments(mesh, deviceId, chat.id, chat.deletedAt);
|
|
35
|
+
await removeChatKnowledge(mesh, chat.id, chat.deletedAt);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
logger.warn('sync', 'chat-tombstone sweep pass failed - continuing with local reclaims', {
|
|
40
|
+
error
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
await chats.close();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const knowledge = mesh.view.snapshot();
|
|
48
|
+
try {
|
|
49
|
+
for await (const row of knowledge.find('@qvac/knowledge')) {
|
|
50
|
+
if (mesh.closing)
|
|
51
|
+
return;
|
|
52
|
+
await syncKnowledgeTombstone(mesh, row);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await knowledge.close();
|
|
57
|
+
}
|
|
58
|
+
const counters = mesh.view.snapshot();
|
|
59
|
+
try {
|
|
60
|
+
for await (const counter of counters.find('@qvac/chunk-counters')) {
|
|
61
|
+
if (mesh.closing)
|
|
62
|
+
return;
|
|
63
|
+
for (const chunk of await listChunks(mesh, { chatId: counter.chatId, type: 'attachment' })) {
|
|
64
|
+
if (mesh.closing)
|
|
65
|
+
return;
|
|
66
|
+
await syncAttachmentChunk(mesh, chunk);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
await counters.close();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { QvacChunkContentAttachment } from '../../../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
import type { Mesh } from '../../mesh.ts';
|
|
3
|
+
export declare function isKnowledgeRoutedAttachment(input: {
|
|
4
|
+
readonly fileName: string;
|
|
5
|
+
readonly mimeType: string;
|
|
6
|
+
}): boolean;
|
|
7
|
+
export declare function routeAttachmentToKnowledge(mesh: Mesh, chatId: string, attachment: QvacChunkContentAttachment): Promise<import("../../../../spec/index").QvacKnowledge>;
|
|
8
|
+
export declare function hasLiveSource(mesh: Mesh, chatId: string, reference: string): Promise<boolean>;
|
|
9
|
+
interface AttachTurnChunk {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly seq: number;
|
|
12
|
+
readonly runId?: string | null;
|
|
13
|
+
readonly type?: string | null;
|
|
14
|
+
readonly attachment?: {
|
|
15
|
+
readonly id?: string | null;
|
|
16
|
+
readonly fileName?: string | null;
|
|
17
|
+
readonly mimeType?: string | null;
|
|
18
|
+
readonly deletedAt?: number | null;
|
|
19
|
+
} | null;
|
|
20
|
+
readonly userMessage?: unknown;
|
|
21
|
+
}
|
|
22
|
+
export declare function attachTurnDocumentIds(chunks: ReadonlyArray<AttachTurnChunk>): string[];
|
|
23
|
+
export {};
|