@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,585 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
import EventEmitter from 'bare-events';
|
|
4
|
+
import { attachmentFiles } from "./attachments.js";
|
|
5
|
+
import { isKnowledgeRoutedAttachment, getKnowledge, listKnowledge, getKnowledgeArtifact, listKnowledgeArtifactsByKnowledge, addKnowledgeArtifact, hasLiveSource, syncAttachmentChunk, syncKnowledgeTombstone, syncArtifactArrival, sweepTombstonedBlobs, referencedBlobs, scopedFile, attachmentRecord, isProcessorOutput, isProcessorArtifactId } from "./records/index.js";
|
|
6
|
+
import { knowledgeFiles } from "./knowledge.js";
|
|
7
|
+
import { randomId } from "../id.js";
|
|
8
|
+
import { getChunk, listChunks } from "../chunk.js";
|
|
9
|
+
import { settleFiles, isClaimLive, listIndexingByChat, FileState, FileProcessing } from "./processing/index.js";
|
|
10
|
+
import { DeadlineScheduler } from "../../deadline.js";
|
|
11
|
+
import { liveDeviceForWriter } from "../contract/activity.js";
|
|
12
|
+
import { BlobStore, parseBlobReference } from "./store/index.js";
|
|
13
|
+
import { AbortedError } from '@qvac/harness/race-abort';
|
|
14
|
+
import { RagProcessor } from "./rag/index.js";
|
|
15
|
+
import { PreviewProcessor, PREVIEW_VERSION, previewId } from "./preview/index.js";
|
|
16
|
+
export { fullTextBudgetChars, fullTextHits, retrieveRagKnowledge, searchRagChunks, referencesPendingFile } from "./rag/index.js";
|
|
17
|
+
export { isKnowledgeRoutedAttachment } from "./records/index.js";
|
|
18
|
+
export { assertRemovableAt } from "./records/index.js";
|
|
19
|
+
export { assertArtifactOutput } from "./records/index.js";
|
|
20
|
+
export { claimSource } from "./records/index.js";
|
|
21
|
+
export class Files extends EventEmitter {
|
|
22
|
+
_mesh;
|
|
23
|
+
_uploads = new Map();
|
|
24
|
+
state = new FileState();
|
|
25
|
+
_states = new Map([['rag', this.state]]);
|
|
26
|
+
_processors = new Map();
|
|
27
|
+
_store;
|
|
28
|
+
_deadline = new DeadlineScheduler(() => {
|
|
29
|
+
this._pruneUploads();
|
|
30
|
+
this._updated();
|
|
31
|
+
});
|
|
32
|
+
_updated = () => this.emit('update');
|
|
33
|
+
_model = null;
|
|
34
|
+
_paused = false;
|
|
35
|
+
closed = false;
|
|
36
|
+
constructor(mesh) {
|
|
37
|
+
super();
|
|
38
|
+
this._mesh = mesh;
|
|
39
|
+
mesh.watch(this._updated);
|
|
40
|
+
this._store = new BlobStore(mesh);
|
|
41
|
+
this._store.on('update', this._updated);
|
|
42
|
+
}
|
|
43
|
+
read(reference, options = {}) {
|
|
44
|
+
return this._store.read(reference, options);
|
|
45
|
+
}
|
|
46
|
+
readBytes(reference, options = {}) {
|
|
47
|
+
return this._store.readBytes(reference, options);
|
|
48
|
+
}
|
|
49
|
+
download(reference, options) {
|
|
50
|
+
return this._store.download(reference, options);
|
|
51
|
+
}
|
|
52
|
+
write(chunks, options = {}) {
|
|
53
|
+
return this._store.write(chunks, options);
|
|
54
|
+
}
|
|
55
|
+
put(bytes) {
|
|
56
|
+
return this._store.put(bytes);
|
|
57
|
+
}
|
|
58
|
+
inline(bytes, mimeType) {
|
|
59
|
+
return this._store.inline(bytes, mimeType);
|
|
60
|
+
}
|
|
61
|
+
reference(id) {
|
|
62
|
+
return this._store.reference(id);
|
|
63
|
+
}
|
|
64
|
+
clear(reference, id) {
|
|
65
|
+
return this._store.clear(reference, id);
|
|
66
|
+
}
|
|
67
|
+
attachments(options = {}) {
|
|
68
|
+
return attachmentFiles(this._mesh, options);
|
|
69
|
+
}
|
|
70
|
+
knowledge(options = {}) {
|
|
71
|
+
return knowledgeFiles(this._mesh, options);
|
|
72
|
+
}
|
|
73
|
+
listKnowledge(chatId) {
|
|
74
|
+
return listKnowledge(this._mesh, { chatId });
|
|
75
|
+
}
|
|
76
|
+
record(id) {
|
|
77
|
+
return getKnowledge(this._mesh, id);
|
|
78
|
+
}
|
|
79
|
+
async resolve(request) {
|
|
80
|
+
const snap = this._mesh.view.snapshot();
|
|
81
|
+
try {
|
|
82
|
+
return await scopedFile(snap, request);
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
await snap.close();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async *fileRead(request, options = {}) {
|
|
89
|
+
const file = await this.resolve(request);
|
|
90
|
+
if (options.signal?.aborted)
|
|
91
|
+
throw new AbortedError();
|
|
92
|
+
if (!file)
|
|
93
|
+
return;
|
|
94
|
+
yield { metadata: file };
|
|
95
|
+
if (!request.metadataOnly)
|
|
96
|
+
yield* this.read(file.blobId, options);
|
|
97
|
+
}
|
|
98
|
+
async preview(request) {
|
|
99
|
+
const file = await this.resolve(request);
|
|
100
|
+
if (!file || !this._processors.get('preview')?.processor.applies(file))
|
|
101
|
+
return {};
|
|
102
|
+
const output = await this.artifact(previewId(file));
|
|
103
|
+
if (!output || output.embedderVersion !== PREVIEW_VERSION)
|
|
104
|
+
return {};
|
|
105
|
+
const reference = parseBlobReference(output.artifactBlobId);
|
|
106
|
+
if (reference.inline?.mimeType !== 'image/jpeg')
|
|
107
|
+
throw new Error('invalid preview output');
|
|
108
|
+
return {
|
|
109
|
+
outputId: output.id,
|
|
110
|
+
mimeType: reference.inline.mimeType,
|
|
111
|
+
data: await this.readBytes(output.artifactBlobId)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async retry(request) {
|
|
115
|
+
const file = await this.resolve(request);
|
|
116
|
+
const entry = this._processors.get(request.processorId);
|
|
117
|
+
if (!file || !entry)
|
|
118
|
+
return;
|
|
119
|
+
this.processorState(request.processorId).retry(file.id);
|
|
120
|
+
await entry.work.enqueue([file.id]);
|
|
121
|
+
this._updated();
|
|
122
|
+
}
|
|
123
|
+
artifact(id) {
|
|
124
|
+
return getKnowledgeArtifact(this._mesh, id);
|
|
125
|
+
}
|
|
126
|
+
artifacts(id) {
|
|
127
|
+
return listKnowledgeArtifactsByKnowledge(this._mesh, { knowledgeId: id });
|
|
128
|
+
}
|
|
129
|
+
publish(input) {
|
|
130
|
+
return addKnowledgeArtifact(this._mesh, input);
|
|
131
|
+
}
|
|
132
|
+
hasLiveSource(chatId, reference) {
|
|
133
|
+
return hasLiveSource(this._mesh, chatId, reference);
|
|
134
|
+
}
|
|
135
|
+
syncAttachment(chunk) {
|
|
136
|
+
return syncAttachmentChunk(this._mesh, chunk);
|
|
137
|
+
}
|
|
138
|
+
syncKnowledge(row) {
|
|
139
|
+
return syncKnowledgeTombstone(this._mesh, row);
|
|
140
|
+
}
|
|
141
|
+
syncArtifact(row) {
|
|
142
|
+
return syncArtifactArrival(this._mesh, row);
|
|
143
|
+
}
|
|
144
|
+
sweepTombstones(deviceId = null) {
|
|
145
|
+
return sweepTombstonedBlobs(this._mesh, deviceId);
|
|
146
|
+
}
|
|
147
|
+
async sweepOrphans(coreLength) {
|
|
148
|
+
if (!coreLength)
|
|
149
|
+
return;
|
|
150
|
+
const references = await referencedBlobs(this._mesh);
|
|
151
|
+
if (!this._mesh.closing)
|
|
152
|
+
await this._store.sweep(references, coreLength);
|
|
153
|
+
}
|
|
154
|
+
processorState(id) {
|
|
155
|
+
let state = this._states.get(id);
|
|
156
|
+
if (!state)
|
|
157
|
+
this._states.set(id, (state = new FileState()));
|
|
158
|
+
return state;
|
|
159
|
+
}
|
|
160
|
+
start(options) {
|
|
161
|
+
this.startProcessor(new PreviewProcessor(options), options);
|
|
162
|
+
}
|
|
163
|
+
startProcessor(processor, options) {
|
|
164
|
+
if (this._processors.has(processor.id)) {
|
|
165
|
+
throw new Error(`processor already started: ${processor.id}`);
|
|
166
|
+
}
|
|
167
|
+
const work = new FileProcessing(this._mesh, { processor, ...options });
|
|
168
|
+
this._processors.set(processor.id, { processor, work });
|
|
169
|
+
if (this._paused)
|
|
170
|
+
void work.suspend();
|
|
171
|
+
work.start();
|
|
172
|
+
this._updated();
|
|
173
|
+
}
|
|
174
|
+
async stopProcessor(id) {
|
|
175
|
+
const entry = this._processors.get(id);
|
|
176
|
+
if (!entry)
|
|
177
|
+
return true;
|
|
178
|
+
await entry.work.suspend();
|
|
179
|
+
await entry.work.close();
|
|
180
|
+
this._processors.delete(id);
|
|
181
|
+
this.processorState(id).reset();
|
|
182
|
+
this._updated();
|
|
183
|
+
return entry.work.indexCleared;
|
|
184
|
+
}
|
|
185
|
+
get _processing() {
|
|
186
|
+
return this._processors.get('rag')?.work;
|
|
187
|
+
}
|
|
188
|
+
startProcessing(options) {
|
|
189
|
+
this.setModel(options.embedder.model);
|
|
190
|
+
this.startProcessor(new RagProcessor({
|
|
191
|
+
...options,
|
|
192
|
+
model: options.embedder.model
|
|
193
|
+
}), { deviceId: options.deviceId });
|
|
194
|
+
}
|
|
195
|
+
async stopProcessing() {
|
|
196
|
+
const cleared = await this.stopProcessor('rag');
|
|
197
|
+
this.setModel(null);
|
|
198
|
+
return cleared;
|
|
199
|
+
}
|
|
200
|
+
async suspend() {
|
|
201
|
+
this._paused = true;
|
|
202
|
+
await Promise.all([...this._processors.values()].map(({ work }) => work.suspend()));
|
|
203
|
+
}
|
|
204
|
+
resume() {
|
|
205
|
+
this._paused = false;
|
|
206
|
+
for (const { work } of this._processors.values())
|
|
207
|
+
work.resume();
|
|
208
|
+
}
|
|
209
|
+
async listIndexing(chatId) {
|
|
210
|
+
const rows = await listIndexingByChat(this._mesh, { chatId });
|
|
211
|
+
let statuses = rows
|
|
212
|
+
.filter((row) => !isProcessorArtifactId(row.id))
|
|
213
|
+
.map((row) => ({ ...row, claimLive: isClaimLive(row, Date.now()) }));
|
|
214
|
+
for (const file of (await this.status(chatId)).files) {
|
|
215
|
+
const processor = file.processors.find((entry) => entry.processorId === 'rag');
|
|
216
|
+
if (!processor || file.readyForChat || processor.state === 'not-applicable')
|
|
217
|
+
continue;
|
|
218
|
+
if (processor.claimedBy)
|
|
219
|
+
continue;
|
|
220
|
+
if (!processor.published && (this.state.get(file.fileId)?.sourceMisses ?? 0) < 2)
|
|
221
|
+
continue;
|
|
222
|
+
const attempts = statuses.filter((row) => row.knowledgeId === file.fileId);
|
|
223
|
+
const latest = attempts.reduce((current, row) => (!current || row.at > current.at ? row : current), undefined);
|
|
224
|
+
statuses = statuses.filter((row) => row.knowledgeId !== file.fileId);
|
|
225
|
+
statuses.push({
|
|
226
|
+
id: latest?.id ?? file.fileId,
|
|
227
|
+
knowledgeId: file.fileId,
|
|
228
|
+
chatId,
|
|
229
|
+
status: processor.state === 'running' ? 'indexing' : 'failed',
|
|
230
|
+
claimId: '',
|
|
231
|
+
claimedBy: Buffer.alloc(0),
|
|
232
|
+
at: Math.max(latest?.at ?? 0, processor.retryAt ?? 0),
|
|
233
|
+
expiresAt: 0,
|
|
234
|
+
error: processor.reason ?? 'waiting for local index',
|
|
235
|
+
claimLive: false
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return { statuses };
|
|
239
|
+
}
|
|
240
|
+
watch(listener) {
|
|
241
|
+
this.on('update', listener);
|
|
242
|
+
}
|
|
243
|
+
unwatch(listener) {
|
|
244
|
+
this.off('update', listener);
|
|
245
|
+
if (!this.listenerCount('update')) {
|
|
246
|
+
this._deadline.clear();
|
|
247
|
+
this._pruneUploads();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
setModel(model) {
|
|
251
|
+
if (model === this._model)
|
|
252
|
+
return;
|
|
253
|
+
this._model = model;
|
|
254
|
+
this.state.reset();
|
|
255
|
+
this._updated();
|
|
256
|
+
}
|
|
257
|
+
work(id, state, processorId = 'rag') {
|
|
258
|
+
const entry = this.processorState(processorId).document(id);
|
|
259
|
+
entry.sourceMisses = state.reason === 'source unavailable' ? (entry.sourceMisses ?? 0) + 1 : 0;
|
|
260
|
+
entry.work = state;
|
|
261
|
+
this._updated();
|
|
262
|
+
}
|
|
263
|
+
load(id, state, options = {}) {
|
|
264
|
+
const { artifactId, processorId = 'rag' } = options;
|
|
265
|
+
const entry = this.processorState(processorId).document(id);
|
|
266
|
+
if (entry.load?.state !== 'failed' || state.state !== 'pending')
|
|
267
|
+
entry.load = state;
|
|
268
|
+
if (!artifactId)
|
|
269
|
+
entry.loaded = undefined;
|
|
270
|
+
else if (entry.loaded?.artifactId !== artifactId)
|
|
271
|
+
entry.loaded = { artifactId };
|
|
272
|
+
this._updated();
|
|
273
|
+
}
|
|
274
|
+
clearLoaded(processorId = 'rag') {
|
|
275
|
+
this.processorState(processorId).clearLoaded();
|
|
276
|
+
this._updated();
|
|
277
|
+
}
|
|
278
|
+
hydratedArtifact(id) {
|
|
279
|
+
return this.state.get(id)?.loaded?.artifactId ?? null;
|
|
280
|
+
}
|
|
281
|
+
async settle(ids, options = {}) {
|
|
282
|
+
if (!this._processing)
|
|
283
|
+
return;
|
|
284
|
+
await settleFiles(this, {
|
|
285
|
+
...options,
|
|
286
|
+
ids,
|
|
287
|
+
processing: this._processing,
|
|
288
|
+
chatIds: async () => {
|
|
289
|
+
const rows = await Promise.all(ids.map((id) => getKnowledge(this._mesh, id)));
|
|
290
|
+
return [...new Set(rows.flatMap((row) => (row ? [row.chatId] : [])))];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
reconnect() {
|
|
295
|
+
for (const { work } of this._processors.values())
|
|
296
|
+
work.reconnect();
|
|
297
|
+
this._updated();
|
|
298
|
+
}
|
|
299
|
+
report = (update, processorId = 'rag') => {
|
|
300
|
+
if (this.closed)
|
|
301
|
+
return;
|
|
302
|
+
this.processorState(processorId).document(update.knowledgeId).progress = {
|
|
303
|
+
...update,
|
|
304
|
+
error: update.error ?? null
|
|
305
|
+
};
|
|
306
|
+
this._updated();
|
|
307
|
+
};
|
|
308
|
+
progress(chatId) {
|
|
309
|
+
return this.state.progress(chatId);
|
|
310
|
+
}
|
|
311
|
+
async beginUpload(input) {
|
|
312
|
+
const { chatId, fileName, mimeType } = input;
|
|
313
|
+
if (!chatId || !fileName || !mimeType)
|
|
314
|
+
throw new Error('upload metadata is incomplete');
|
|
315
|
+
const id = input.fileId || randomId();
|
|
316
|
+
this._pruneUploads();
|
|
317
|
+
const previous = this._uploads.get(id);
|
|
318
|
+
if (previous && !previous.expiresAt)
|
|
319
|
+
throw new Error('file id already exists');
|
|
320
|
+
this._uploads.set(id, {
|
|
321
|
+
status: {
|
|
322
|
+
fileId: id,
|
|
323
|
+
chatId,
|
|
324
|
+
fileName,
|
|
325
|
+
mimeType,
|
|
326
|
+
state: 'uploading',
|
|
327
|
+
processors: [],
|
|
328
|
+
readyForChat: false,
|
|
329
|
+
uploadProgress: {
|
|
330
|
+
completed: input.data?.length ?? 0,
|
|
331
|
+
total: input.totalBytes || undefined,
|
|
332
|
+
unit: 'bytes'
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
try {
|
|
337
|
+
if (input.fileId &&
|
|
338
|
+
((await getKnowledge(this._mesh, id)) ||
|
|
339
|
+
(await getChunk(this._mesh, id)) ||
|
|
340
|
+
(await listChunks(this._mesh, { chatId, type: 'attachment' })).some((chunk) => chunk.attachment?.id === id))) {
|
|
341
|
+
throw new Error('file id already exists');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
if (previous)
|
|
346
|
+
this._uploads.set(id, previous);
|
|
347
|
+
else
|
|
348
|
+
this._uploads.delete(id);
|
|
349
|
+
this._updated();
|
|
350
|
+
throw error;
|
|
351
|
+
}
|
|
352
|
+
this._updated();
|
|
353
|
+
return { id };
|
|
354
|
+
}
|
|
355
|
+
uploadProgress(id, bytes) {
|
|
356
|
+
const upload = this._uploads.get(id)?.status;
|
|
357
|
+
if (!upload?.uploadProgress)
|
|
358
|
+
return;
|
|
359
|
+
upload.uploadProgress.completed += bytes;
|
|
360
|
+
this._updated();
|
|
361
|
+
}
|
|
362
|
+
uploadComplete(id) {
|
|
363
|
+
const upload = this._uploads.get(id)?.status;
|
|
364
|
+
if (upload)
|
|
365
|
+
upload.state = 'pending';
|
|
366
|
+
this._updated();
|
|
367
|
+
}
|
|
368
|
+
uploadFailed(id, error) {
|
|
369
|
+
const upload = this._uploads.get(id)?.status;
|
|
370
|
+
if (!upload)
|
|
371
|
+
return;
|
|
372
|
+
upload.state = error instanceof AbortedError ? 'cancelled' : 'failed';
|
|
373
|
+
upload.reason = error instanceof Error ? error.message : String(error);
|
|
374
|
+
this._updated();
|
|
375
|
+
}
|
|
376
|
+
uploadClosed(id) {
|
|
377
|
+
const upload = this._uploads.get(id);
|
|
378
|
+
if (!upload || this.closed)
|
|
379
|
+
return;
|
|
380
|
+
upload.expiresAt = Date.now() + 60_000;
|
|
381
|
+
this._deadline.schedule(upload.expiresAt);
|
|
382
|
+
}
|
|
383
|
+
_pruneUploads() {
|
|
384
|
+
for (const [id, upload] of this._uploads) {
|
|
385
|
+
if (!upload.expiresAt)
|
|
386
|
+
continue;
|
|
387
|
+
if (upload.expiresAt <= Date.now())
|
|
388
|
+
this._uploads.delete(id);
|
|
389
|
+
else
|
|
390
|
+
this._deadline.schedule(upload.expiresAt);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
async status(chatId) {
|
|
394
|
+
this._pruneUploads();
|
|
395
|
+
const snap = this._mesh.view.snapshot();
|
|
396
|
+
const range = { gte: { chatId }, lte: { chatId } };
|
|
397
|
+
try {
|
|
398
|
+
const chat = await snap.get('@qvac/chats', { id: chatId });
|
|
399
|
+
if (!chat || chat.deletedAt)
|
|
400
|
+
return { files: [] };
|
|
401
|
+
const agent = await snap.get('@qvac/agents', { id: chat.agentId });
|
|
402
|
+
const knowledge = await snap
|
|
403
|
+
.find('@qvac/active-knowledge-by-chat', range)
|
|
404
|
+
.toArray();
|
|
405
|
+
const chunks = await snap.find('@qvac/chunks-by-chat', range).toArray();
|
|
406
|
+
const statuses = await snap
|
|
407
|
+
.find('@qvac/indexing-status-by-chat', range)
|
|
408
|
+
.toArray();
|
|
409
|
+
const sources = new Map(knowledge.map((row) => [row.id, row]));
|
|
410
|
+
const ragIds = new Set(sources.keys());
|
|
411
|
+
for (const chunk of chunks) {
|
|
412
|
+
const file = chunk.attachment;
|
|
413
|
+
if (file && !file.deletedAt && !sources.has(file.id)) {
|
|
414
|
+
sources.set(file.id, { ...file, chatId, updatedAt: file.createdAt });
|
|
415
|
+
if (!chunk.runId && isKnowledgeRoutedAttachment(file)) {
|
|
416
|
+
const record = await snap.get('@qvac/knowledge', { id: file.id });
|
|
417
|
+
if (!record?.deletedAt)
|
|
418
|
+
ragIds.add(file.id);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
const result = new Map();
|
|
423
|
+
for (const { status: upload } of this._uploads.values()) {
|
|
424
|
+
if (upload.chatId === chatId && upload.state !== 'pending') {
|
|
425
|
+
result.set(upload.fileId, {
|
|
426
|
+
...upload,
|
|
427
|
+
uploadProgress: upload.uploadProgress ? { ...upload.uploadProgress } : undefined
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
for (const [id, source] of sources) {
|
|
432
|
+
const rows = await snap
|
|
433
|
+
.find('@qvac/knowledge-artifacts-by-knowledge', {
|
|
434
|
+
gte: { knowledgeId: id },
|
|
435
|
+
lte: { knowledgeId: id }
|
|
436
|
+
})
|
|
437
|
+
.toArray();
|
|
438
|
+
const applicable = ragIds.has(id);
|
|
439
|
+
const local = this.state.get(id);
|
|
440
|
+
const output = rows.find((row) => !isProcessorOutput(row.embedderVersion) &&
|
|
441
|
+
(!this._model || row.embedderVersion.startsWith(`${this._model}|`)));
|
|
442
|
+
const published = !!output;
|
|
443
|
+
const attempts = statuses.filter((row) => row.knowledgeId === id && !isProcessorArtifactId(row.id));
|
|
444
|
+
const claim = attempts.find((row) => isClaimLive(row, Date.now()));
|
|
445
|
+
const failures = attempts.some((row) => row.status === 'ready')
|
|
446
|
+
? []
|
|
447
|
+
: attempts.filter((row) => row.status === 'failed');
|
|
448
|
+
const terminalFailure = failures.find((row) => row.error !== 'source unavailable' && row.error !== 'interrupted: suspend');
|
|
449
|
+
const failed = terminalFailure ?? failures[0];
|
|
450
|
+
const processor = {
|
|
451
|
+
processorId: 'rag',
|
|
452
|
+
state: 'pending',
|
|
453
|
+
published
|
|
454
|
+
};
|
|
455
|
+
processor.outputId = local?.loaded?.artifactId ?? output?.id;
|
|
456
|
+
if (!applicable)
|
|
457
|
+
processor.state = 'not-applicable';
|
|
458
|
+
else if (local?.loaded)
|
|
459
|
+
processor.state = 'ready';
|
|
460
|
+
else if (claim) {
|
|
461
|
+
processor.state = 'running';
|
|
462
|
+
processor.claimedBy = claim.claimedBy;
|
|
463
|
+
processor.expiresAt = claim.expiresAt;
|
|
464
|
+
this._deadline.schedule(claim.expiresAt);
|
|
465
|
+
const device = await liveDeviceForWriter(snap, claim.claimedBy);
|
|
466
|
+
if (device && agent && b4a.equals(device.id, agent.providerDeviceId)) {
|
|
467
|
+
processor.agentId = agent.id;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
else if (local?.work &&
|
|
471
|
+
!published &&
|
|
472
|
+
local.work.state !== 'running' &&
|
|
473
|
+
(!terminalFailure || local.work.state !== 'pending')) {
|
|
474
|
+
Object.assign(processor, local.work);
|
|
475
|
+
}
|
|
476
|
+
else if (local?.load && published)
|
|
477
|
+
Object.assign(processor, local.load);
|
|
478
|
+
else if (failed && !published && failed.error !== 'interrupted: suspend') {
|
|
479
|
+
processor.state = failed.error === 'source unavailable' ? 'pending' : 'failed';
|
|
480
|
+
processor.reason = failed.error || 'processing failed';
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
processor.reason = !this._model
|
|
484
|
+
? 'model unavailable on this device'
|
|
485
|
+
: published
|
|
486
|
+
? 'waiting for local index'
|
|
487
|
+
: 'waiting for agent';
|
|
488
|
+
}
|
|
489
|
+
if (local?.progress &&
|
|
490
|
+
processor.state !== 'not-applicable' &&
|
|
491
|
+
(!claim || b4a.equals(claim.claimedBy, this._mesh.localWriterKey))) {
|
|
492
|
+
processor.progress = {
|
|
493
|
+
completed: local.progress.processedChunks,
|
|
494
|
+
total: local.progress.totalChunks || undefined,
|
|
495
|
+
unit: 'chunks'
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
const readyForChat = applicable
|
|
499
|
+
? processor.state === 'ready'
|
|
500
|
+
: await this._store.available(source.blobId);
|
|
501
|
+
const processors = [processor];
|
|
502
|
+
for (const { processor: descriptor } of this._processors.values()) {
|
|
503
|
+
if (descriptor.id === 'rag')
|
|
504
|
+
continue;
|
|
505
|
+
const chunk = chunks.find((entry) => entry.attachment?.id === id);
|
|
506
|
+
const record = descriptor.input === 'attachment'
|
|
507
|
+
? chunk && attachmentRecord(chunk)
|
|
508
|
+
: knowledge.find((entry) => entry.id === id);
|
|
509
|
+
const input = record ? { ...record, kind: descriptor.input } : null;
|
|
510
|
+
processors.push(!input || !descriptor.applies(input)
|
|
511
|
+
? { processorId: descriptor.id, state: 'not-applicable', published: false }
|
|
512
|
+
: await this._processorStatus(descriptor, input, rows, statuses));
|
|
513
|
+
}
|
|
514
|
+
result.set(id, {
|
|
515
|
+
fileId: id,
|
|
516
|
+
chatId,
|
|
517
|
+
fileName: source.fileName,
|
|
518
|
+
mimeType: source.mimeType,
|
|
519
|
+
state: readyForChat ? 'ready' : applicable ? processor.state : 'pending',
|
|
520
|
+
reason: readyForChat
|
|
521
|
+
? undefined
|
|
522
|
+
: applicable
|
|
523
|
+
? processor.reason
|
|
524
|
+
: 'source unavailable on this device',
|
|
525
|
+
uploadProgress: this._uploads.get(id)?.status.uploadProgress
|
|
526
|
+
? { ...this._uploads.get(id).status.uploadProgress }
|
|
527
|
+
: undefined,
|
|
528
|
+
processors,
|
|
529
|
+
readyForChat
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
return { files: [...result.values()] };
|
|
533
|
+
}
|
|
534
|
+
finally {
|
|
535
|
+
await snap.close();
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
async _processorStatus(processor, file, rows, attempts) {
|
|
539
|
+
const output = rows.find((row) => processor.accepts ? processor.accepts(row, file) : row.embedderVersion === processor.version);
|
|
540
|
+
const local = this.processorState(processor.id).get(file.id);
|
|
541
|
+
const status = {
|
|
542
|
+
processorId: processor.id,
|
|
543
|
+
state: 'pending',
|
|
544
|
+
published: !!output,
|
|
545
|
+
outputId: output?.id
|
|
546
|
+
};
|
|
547
|
+
if (output &&
|
|
548
|
+
(processor.load ? !!local?.loaded : await this._store.available(output.artifactBlobId))) {
|
|
549
|
+
status.state = 'ready';
|
|
550
|
+
return status;
|
|
551
|
+
}
|
|
552
|
+
const claim = attempts.find((row) => row.knowledgeId === file.id &&
|
|
553
|
+
row.id.startsWith(`${processor.id}:`) &&
|
|
554
|
+
isClaimLive(row, Date.now()));
|
|
555
|
+
if (claim) {
|
|
556
|
+
Object.assign(status, {
|
|
557
|
+
state: 'running',
|
|
558
|
+
claimedBy: claim.claimedBy,
|
|
559
|
+
expiresAt: claim.expiresAt
|
|
560
|
+
});
|
|
561
|
+
this._deadline.schedule(claim.expiresAt);
|
|
562
|
+
}
|
|
563
|
+
else if (local?.work)
|
|
564
|
+
Object.assign(status, local.work);
|
|
565
|
+
else
|
|
566
|
+
status.reason = output ? 'output unavailable on this device' : 'waiting for processor';
|
|
567
|
+
return status;
|
|
568
|
+
}
|
|
569
|
+
async close() {
|
|
570
|
+
this.closed = true;
|
|
571
|
+
await Promise.all([...this._processors.keys()].map((id) => this.stopProcessor(id)));
|
|
572
|
+
this._mesh.unwatch(this._updated);
|
|
573
|
+
this._deadline.clear();
|
|
574
|
+
this._uploads.clear();
|
|
575
|
+
for (const state of this._states.values())
|
|
576
|
+
state.close();
|
|
577
|
+
this._states.clear();
|
|
578
|
+
this.emit('close');
|
|
579
|
+
this.removeAllListeners();
|
|
580
|
+
await this._store.close();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from "./rag/index.js";
|
|
584
|
+
export { attachTurnDocumentIds, groupAttachmentsByMessage } from "./records/index.js";
|
|
585
|
+
export { CoreBlobServer } from "./store/index.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MAX_KNOWLEDGE_BYTES } from './rag/index.ts';
|
|
2
|
+
import type { Mesh } from '../mesh.ts';
|
|
3
|
+
import type { CapabilityHandlers } from '../../../spec/capabilities.d.ts';
|
|
4
|
+
export { MAX_KNOWLEDGE_BYTES };
|
|
5
|
+
export declare function knowledgeFiles(mesh: Mesh, { maxBytes, inactivityMs, deviceId }?: {
|
|
6
|
+
maxBytes?: number;
|
|
7
|
+
inactivityMs?: number;
|
|
8
|
+
deviceId?: Buffer | null;
|
|
9
|
+
}): Pick<CapabilityHandlers, 'uploadKnowledge' | 'downloadKnowledge' | 'listKnowledge' | 'removeKnowledge' | 'listIndexing'>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { listKnowledge, removeKnowledge } from "./records/index.js";
|
|
2
|
+
import { MAX_KNOWLEDGE_BYTES } from "./rag/index.js";
|
|
3
|
+
import { uploadFile } from "./upload.js";
|
|
4
|
+
export { MAX_KNOWLEDGE_BYTES };
|
|
5
|
+
export function knowledgeFiles(mesh, { maxBytes = MAX_KNOWLEDGE_BYTES, inactivityMs, deviceId } = {}) {
|
|
6
|
+
const list = async ({ chatId }) => ({
|
|
7
|
+
knowledge: await listKnowledge(mesh, { chatId })
|
|
8
|
+
});
|
|
9
|
+
const indexingList = async ({ chatId }) => mesh.files.listIndexing(chatId);
|
|
10
|
+
return {
|
|
11
|
+
async *uploadKnowledge(frames) {
|
|
12
|
+
for await (const frame of uploadFile(mesh, frames, {
|
|
13
|
+
kind: 'knowledge',
|
|
14
|
+
maxBytes,
|
|
15
|
+
deviceId,
|
|
16
|
+
inactivityMs
|
|
17
|
+
})) {
|
|
18
|
+
yield {
|
|
19
|
+
bytesWritten: frame.bytesWritten,
|
|
20
|
+
knowledge: 'knowledge' in frame ? frame.knowledge : undefined
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
downloadKnowledge: async function* ({ blobId }) {
|
|
25
|
+
yield* mesh.files.read(blobId);
|
|
26
|
+
},
|
|
27
|
+
listKnowledge: list,
|
|
28
|
+
listIndexing: indexingList,
|
|
29
|
+
removeKnowledge: async ({ knowledgeId, at }) => removeKnowledge(mesh, { knowledgeId, at })
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
import { AbortedError } from '@qvac/harness/race-abort';
|
|
3
|
+
import { MAX_INLINE_BYTES } from "../store/index.js";
|
|
4
|
+
export async function previewEncoder() {
|
|
5
|
+
let media;
|
|
6
|
+
try {
|
|
7
|
+
media = await import('bare-media');
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return async (bytes, signal) => {
|
|
13
|
+
const decoded = await media.image.decode(bytes, { maxFrames: 1 });
|
|
14
|
+
if (signal.aborted)
|
|
15
|
+
throw new AbortedError();
|
|
16
|
+
const first = decoded.frames ? decoded.frames[0] : decoded;
|
|
17
|
+
if (!first)
|
|
18
|
+
throw new Error('image has no frames');
|
|
19
|
+
const upright = await media.image.orientate(first, { file: bytes });
|
|
20
|
+
const resized = await media.image.resize(upright, { maxWidth: 768, maxHeight: 768 });
|
|
21
|
+
if (signal.aborted)
|
|
22
|
+
throw new AbortedError();
|
|
23
|
+
try {
|
|
24
|
+
return Buffer.from(await media.image.encode(resized, {
|
|
25
|
+
mimetype: 'image/jpeg',
|
|
26
|
+
quality: 75,
|
|
27
|
+
maxBytes: 80 * 1024
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (!(error instanceof Error) ||
|
|
32
|
+
!error.message.startsWith('Could not create preview under maxBytes')) {
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
return Buffer.from(await media.image.encode(resized, {
|
|
36
|
+
mimetype: 'image/jpeg',
|
|
37
|
+
quality: 60,
|
|
38
|
+
maxBytes: MAX_INLINE_BYTES
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|