@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,91 @@
|
|
|
1
|
+
import { decodeLatin1, decodeUtf16 } from "./utf.js";
|
|
2
|
+
const UTF16_LE_BOM = [0xff, 0xfe];
|
|
3
|
+
const UTF16_BE_BOM = [0xfe, 0xff];
|
|
4
|
+
const UTF8_BOM = [0xef, 0xbb, 0xbf];
|
|
5
|
+
const LATIN1_LABEL = /^(?:iso-8859-1|iso8859-1|iso88591|latin-1|latin1)$/;
|
|
6
|
+
const HTML_CHARSET = /<meta\s+[^>]*charset\s*=\s*["']?\s*([A-Za-z0-9._-]+)/i;
|
|
7
|
+
const CONTENT_TYPE_CHARSET = /<meta\s+[^>]*http-equiv\s*=\s*["']?content-type["']?[^>]*content\s*=\s*["'][^"']*charset=([A-Za-z0-9._-]+)/i;
|
|
8
|
+
export function decodeTextBytes(bytes) {
|
|
9
|
+
return decodeWithEncoding(bytes, detectEncoding(bytes) ?? 'utf-8');
|
|
10
|
+
}
|
|
11
|
+
function detectEncoding(bytes) {
|
|
12
|
+
return detectBom(bytes) ?? detectUtf16ByNuls(bytes) ?? detectHtmlCharset(bytes);
|
|
13
|
+
}
|
|
14
|
+
function detectBom(bytes) {
|
|
15
|
+
if (startsWith(bytes, UTF16_LE_BOM))
|
|
16
|
+
return 'utf-16le';
|
|
17
|
+
if (startsWith(bytes, UTF16_BE_BOM))
|
|
18
|
+
return 'utf-16be';
|
|
19
|
+
return startsWith(bytes, UTF8_BOM) ? 'utf-8' : null;
|
|
20
|
+
}
|
|
21
|
+
function startsWith(bytes, prefix) {
|
|
22
|
+
return prefix.every((value, index) => bytes[index] === value);
|
|
23
|
+
}
|
|
24
|
+
function detectUtf16ByNuls(bytes) {
|
|
25
|
+
const sampleLength = Math.min(bytes.length, 512);
|
|
26
|
+
let evenNuls = 0;
|
|
27
|
+
let oddNuls = 0;
|
|
28
|
+
for (let index = 0; index < sampleLength; index++) {
|
|
29
|
+
if (bytes[index] !== 0)
|
|
30
|
+
continue;
|
|
31
|
+
if (index % 2 === 0) {
|
|
32
|
+
evenNuls++;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
oddNuls++;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const threshold = Math.max(8, Math.floor(sampleLength / 8));
|
|
39
|
+
if (oddNuls >= threshold && oddNuls > evenNuls * 2)
|
|
40
|
+
return 'utf-16le';
|
|
41
|
+
return evenNuls >= threshold && evenNuls > oddNuls * 2 ? 'utf-16be' : null;
|
|
42
|
+
}
|
|
43
|
+
function detectHtmlCharset(bytes) {
|
|
44
|
+
const sample = decodeUtf8(bytes.slice(0, 4096));
|
|
45
|
+
const match = HTML_CHARSET.exec(sample) ?? CONTENT_TYPE_CHARSET.exec(sample);
|
|
46
|
+
return normalizeEncoding(match?.[1] ?? null);
|
|
47
|
+
}
|
|
48
|
+
function normalizeEncoding(value) {
|
|
49
|
+
if (!value)
|
|
50
|
+
return null;
|
|
51
|
+
const normalized = value.trim().toLowerCase().replace(/_/g, '-');
|
|
52
|
+
if (normalized === 'utf8')
|
|
53
|
+
return 'utf-8';
|
|
54
|
+
if (LATIN1_LABEL.test(normalized))
|
|
55
|
+
return 'latin1';
|
|
56
|
+
if (normalized === 'utf16' || normalized === 'utf-16')
|
|
57
|
+
return 'utf-16le';
|
|
58
|
+
if (normalized === 'utf16le')
|
|
59
|
+
return 'utf-16le';
|
|
60
|
+
if (normalized === 'utf16be')
|
|
61
|
+
return 'utf-16be';
|
|
62
|
+
return normalized;
|
|
63
|
+
}
|
|
64
|
+
function decodeWithEncoding(bytes, encoding) {
|
|
65
|
+
const normalized = normalizeEncoding(encoding) ?? 'utf-8';
|
|
66
|
+
if (normalized === 'utf-16le')
|
|
67
|
+
return decodeUtf16(bytes, true).replace(/^\uFEFF/, '');
|
|
68
|
+
if (normalized === 'utf-16be')
|
|
69
|
+
return decodeUtf16(bytes, false).replace(/^\uFEFF/, '');
|
|
70
|
+
if (normalized === 'latin1')
|
|
71
|
+
return decodeLatin1(bytes);
|
|
72
|
+
return decodeWithTextDecoder(bytes, normalized);
|
|
73
|
+
}
|
|
74
|
+
function decodeUtf8(bytes) {
|
|
75
|
+
return decodeWithTextDecoder(bytes, 'utf-8');
|
|
76
|
+
}
|
|
77
|
+
const TextDecoderCtor = globalThis
|
|
78
|
+
.TextDecoder;
|
|
79
|
+
function decodeWithTextDecoder(bytes, encoding) {
|
|
80
|
+
if (TextDecoderCtor) {
|
|
81
|
+
try {
|
|
82
|
+
return new TextDecoderCtor(encoding).decode(bytes).replace(/^\uFEFF/, '');
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return new TextDecoderCtor('utf-8').decode(bytes).replace(/^\uFEFF/, '');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
89
|
+
.toString('utf8')
|
|
90
|
+
.replace(/^\uFEFF/, '');
|
|
91
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type RagDocumentInput = {
|
|
2
|
+
readonly id?: string;
|
|
3
|
+
readonly blobId?: string;
|
|
4
|
+
readonly title: string;
|
|
5
|
+
readonly content: string;
|
|
6
|
+
readonly sourcePath?: string;
|
|
7
|
+
readonly sourceUrl?: string;
|
|
8
|
+
readonly mimeType?: string;
|
|
9
|
+
readonly artifactId?: string;
|
|
10
|
+
readonly attachmentId?: string;
|
|
11
|
+
readonly messageId?: string;
|
|
12
|
+
readonly chatId?: string;
|
|
13
|
+
};
|
|
14
|
+
export type RagFileInput = {
|
|
15
|
+
readonly id?: string;
|
|
16
|
+
readonly blobId?: string;
|
|
17
|
+
readonly title?: string;
|
|
18
|
+
readonly fileName?: string;
|
|
19
|
+
readonly mimeType?: string;
|
|
20
|
+
readonly sourcePath?: string;
|
|
21
|
+
readonly sourceUrl?: string;
|
|
22
|
+
readonly bytes?: Uint8Array;
|
|
23
|
+
readonly artifactId?: string;
|
|
24
|
+
readonly attachmentId?: string;
|
|
25
|
+
readonly messageId?: string;
|
|
26
|
+
readonly chatId?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const RAG_EXTRACT_ERROR_CODE: {
|
|
29
|
+
readonly unsupportedFile: "RAG_UNSUPPORTED_FILE";
|
|
30
|
+
readonly extractionFailed: "RAG_EXTRACTION_FAILED";
|
|
31
|
+
};
|
|
32
|
+
export type RagExtractErrorCode = (typeof RAG_EXTRACT_ERROR_CODE)[keyof typeof RAG_EXTRACT_ERROR_CODE];
|
|
33
|
+
export declare class RagExtractError extends Error {
|
|
34
|
+
readonly code: RagExtractErrorCode;
|
|
35
|
+
constructor(code: RagExtractErrorCode, message: string);
|
|
36
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const RAG_EXTRACT_ERROR_CODE = {
|
|
2
|
+
unsupportedFile: 'RAG_UNSUPPORTED_FILE',
|
|
3
|
+
extractionFailed: 'RAG_EXTRACTION_FAILED'
|
|
4
|
+
};
|
|
5
|
+
export class RagExtractError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
constructor(code, message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'RagExtractError';
|
|
10
|
+
this.code = code;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
export function decodeUtf16(bytes, littleEndian) {
|
|
3
|
+
let out = '';
|
|
4
|
+
const chunk = [];
|
|
5
|
+
for (let i = 0; i + 1 < bytes.length; i += 2) {
|
|
6
|
+
const a = bytes[i];
|
|
7
|
+
const b = bytes[i + 1];
|
|
8
|
+
chunk.push(littleEndian ? a | (b << 8) : (a << 8) | b);
|
|
9
|
+
if (chunk.length >= 8192) {
|
|
10
|
+
out += String.fromCharCode(...chunk);
|
|
11
|
+
chunk.length = 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return out + String.fromCharCode(...chunk);
|
|
15
|
+
}
|
|
16
|
+
export function decodeLatin1(bytes) {
|
|
17
|
+
return b4a.toString(b4a.from(bytes), 'latin1');
|
|
18
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
|
+
import type { QvacKnowledge } from '../../../../spec/mesh/hyperschema/types.d.ts';
|
|
3
|
+
import type { RagExtractors } from './extract/extract.ts';
|
|
4
|
+
import type { VectorIndex } from './vector/types.ts';
|
|
5
|
+
import { type IndexingEmbedder } from './produce.ts';
|
|
6
|
+
import type { Mesh } from '../../mesh.ts';
|
|
7
|
+
import type { FileDocument, FileProcessor } from '../processing/index.ts';
|
|
8
|
+
export declare class RagProcessor implements FileProcessor {
|
|
9
|
+
readonly id = "rag";
|
|
10
|
+
readonly input = "knowledge";
|
|
11
|
+
readonly output = "blob";
|
|
12
|
+
readonly version: string;
|
|
13
|
+
private readonly _producer;
|
|
14
|
+
readonly load?: (document: FileDocument, signal: AbortSignal) => Promise<void>;
|
|
15
|
+
private readonly _index;
|
|
16
|
+
constructor(options: {
|
|
17
|
+
model: string;
|
|
18
|
+
embedder?: IndexingEmbedder;
|
|
19
|
+
index?: VectorIndex | null;
|
|
20
|
+
extractors?: RagExtractors;
|
|
21
|
+
});
|
|
22
|
+
applies(_document: QvacKnowledge): boolean;
|
|
23
|
+
canProduce(document: QvacKnowledge, host: {
|
|
24
|
+
mesh: Mesh;
|
|
25
|
+
deviceId: Buffer | null;
|
|
26
|
+
}): Promise<boolean>;
|
|
27
|
+
produce(document: FileDocument, signal: AbortSignal): Promise<void>;
|
|
28
|
+
close(): Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
export { encodeRagArtifact } from './artifact/codec.ts';
|
|
31
|
+
export type { RagArtifactPayload } from './artifact/types.ts';
|
|
32
|
+
export { isSupportedRagDocument } from './extract/document-types.ts';
|
|
33
|
+
export type { RagExtractors } from './extract/extract.ts';
|
|
34
|
+
export { MAX_KNOWLEDGE_BYTES } from './limits.ts';
|
|
35
|
+
export { canIndexChat } from './policy.ts';
|
|
36
|
+
export type { IndexingEmbedder, IndexingProgress } from './produce.ts';
|
|
37
|
+
export { citedByPhraseOverlap } from './retrieval/citation-match.ts';
|
|
38
|
+
export { formatRagContext } from './retrieval/format.ts';
|
|
39
|
+
export { formatFullDocumentContext, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.ts';
|
|
40
|
+
export { RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, chooseRagNotice } from './retrieval/notices.ts';
|
|
41
|
+
export { createRagSourceTagFilter } from './retrieval/source-tag-filter.ts';
|
|
42
|
+
export { sourcesFromHits } from './retrieval/sources.ts';
|
|
43
|
+
export type { RagSource } from './retrieval/sources.ts';
|
|
44
|
+
export { WEB_TOOLS, webSourcesFromToolResult, withoutDataChannel } from './retrieval/web-sources.ts';
|
|
45
|
+
export { MemoryVectorIndex } from './vector/memory.ts';
|
|
46
|
+
export type { VectorIndex } from './vector/types.ts';
|
|
47
|
+
export { fullTextBudgetChars, fullTextHits } from './retrieval/full-text.ts';
|
|
48
|
+
export { retrieveRagKnowledge } from './retrieval/knowledge.ts';
|
|
49
|
+
export { searchRagChunks } from './retrieval/search.ts';
|
|
50
|
+
export { referencesPendingFile } from './retrieval/target.ts';
|
|
51
|
+
export type { RagDocumentRef } from './retrieval/target.ts';
|
|
52
|
+
export type { VectorHit } from './vector/types.ts';
|
|
53
|
+
export { isWholeDocumentQuery } from './retrieval/whole-document-query.ts';
|
|
54
|
+
export { referencedDocuments } from './retrieval/target.ts';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import ScopeLock from 'scope-lock';
|
|
2
|
+
import { pipelineVersionFor } from "./artifact/id.js";
|
|
3
|
+
import { AbortedError } from '@qvac/harness/race-abort';
|
|
4
|
+
import { IndexingPass } from "./produce.js";
|
|
5
|
+
import { HydratePass } from "./load.js";
|
|
6
|
+
import { canIndexChat } from "./policy.js";
|
|
7
|
+
export class RagProcessor {
|
|
8
|
+
id = 'rag';
|
|
9
|
+
input = 'knowledge';
|
|
10
|
+
output = 'blob';
|
|
11
|
+
version;
|
|
12
|
+
_producer;
|
|
13
|
+
load;
|
|
14
|
+
_index;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.version = pipelineVersionFor(options.model);
|
|
17
|
+
this._index = options.index ?? null;
|
|
18
|
+
const lock = new ScopeLock();
|
|
19
|
+
const source = options.embedder;
|
|
20
|
+
const embedder = source && {
|
|
21
|
+
model: source.model,
|
|
22
|
+
embed: async (input) => {
|
|
23
|
+
await lock.lock();
|
|
24
|
+
try {
|
|
25
|
+
if (input.signal?.aborted)
|
|
26
|
+
throw new AbortedError();
|
|
27
|
+
return await source.embed(input);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
lock.unlock();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
this._producer = embedder ? new IndexingPass(embedder, options.extractors) : null;
|
|
35
|
+
if (this._index) {
|
|
36
|
+
const loader = new HydratePass({ ...options, index: this._index, embedder });
|
|
37
|
+
this.load = (document, signal) => loader.run(document, signal);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
applies(_document) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
async canProduce(document, host) {
|
|
44
|
+
return (!!this._producer &&
|
|
45
|
+
!document.deletedAt &&
|
|
46
|
+
(await canIndexChat(host.mesh, host.deviceId, document.chatId)));
|
|
47
|
+
}
|
|
48
|
+
async produce(document, signal) {
|
|
49
|
+
await this._producer?.run(document, signal);
|
|
50
|
+
}
|
|
51
|
+
async close() {
|
|
52
|
+
try {
|
|
53
|
+
await this._index?.clear();
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
logger.warn('rag', 'vector index clear failed on close; it must not be reused', { err });
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export { encodeRagArtifact } from "./artifact/codec.js";
|
|
63
|
+
export { isSupportedRagDocument } from "./extract/document-types.js";
|
|
64
|
+
export { MAX_KNOWLEDGE_BYTES } from "./limits.js";
|
|
65
|
+
export { canIndexChat } from "./policy.js";
|
|
66
|
+
export { citedByPhraseOverlap } from "./retrieval/citation-match.js";
|
|
67
|
+
export { formatRagContext } from "./retrieval/format.js";
|
|
68
|
+
export { formatFullDocumentContext, isFullTextHit, isTruncatedFullTextHit } from "./retrieval/full-text.js";
|
|
69
|
+
export { RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, chooseRagNotice } from "./retrieval/notices.js";
|
|
70
|
+
export { createRagSourceTagFilter } from "./retrieval/source-tag-filter.js";
|
|
71
|
+
export { sourcesFromHits } from "./retrieval/sources.js";
|
|
72
|
+
export { WEB_TOOLS, webSourcesFromToolResult, withoutDataChannel } from "./retrieval/web-sources.js";
|
|
73
|
+
export { MemoryVectorIndex } from "./vector/memory.js";
|
|
74
|
+
export { fullTextBudgetChars, fullTextHits } from "./retrieval/full-text.js";
|
|
75
|
+
export { retrieveRagKnowledge } from "./retrieval/knowledge.js";
|
|
76
|
+
export { searchRagChunks } from "./retrieval/search.js";
|
|
77
|
+
export { referencesPendingFile } from "./retrieval/target.js";
|
|
78
|
+
export { isWholeDocumentQuery } from "./retrieval/whole-document-query.js";
|
|
79
|
+
export { referencedDocuments } from "./retrieval/target.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { QvacKnowledgeArtifact } from '../../../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
import type { VectorIndex } from './vector/types.ts';
|
|
3
|
+
import type { FileDocument } from '../processing/index.ts';
|
|
4
|
+
import type { AbortSignal } from 'bare-abort-controller';
|
|
5
|
+
import { type BuildEmbedder } from './build.ts';
|
|
6
|
+
import type { RagExtractors } from './extract/extract.ts';
|
|
7
|
+
export type HydratePassOptions = {
|
|
8
|
+
model: string;
|
|
9
|
+
index: VectorIndex;
|
|
10
|
+
embedder?: BuildEmbedder;
|
|
11
|
+
extractors?: RagExtractors;
|
|
12
|
+
};
|
|
13
|
+
export declare function pickArtifact(rows: QvacKnowledgeArtifact[], opts: {
|
|
14
|
+
model: string;
|
|
15
|
+
pinnedDimensions: number | null;
|
|
16
|
+
failed: (id: string) => string | undefined;
|
|
17
|
+
localCoreKey?: string;
|
|
18
|
+
skip: ReadonlySet<string>;
|
|
19
|
+
}): QvacKnowledgeArtifact | null;
|
|
20
|
+
export declare class HydratePass {
|
|
21
|
+
private readonly _model;
|
|
22
|
+
private readonly _index;
|
|
23
|
+
private readonly _embedder;
|
|
24
|
+
private readonly _extractors;
|
|
25
|
+
constructor(opts: HydratePassOptions);
|
|
26
|
+
run(document: FileDocument, signal: AbortSignal): Promise<void>;
|
|
27
|
+
private _rebuild;
|
|
28
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { decodeRagArtifact } from "./artifact/codec.js";
|
|
2
|
+
import { pipelineVersionFor, contentHash } from "./artifact/id.js";
|
|
3
|
+
import { compareBlobReferences } from "../store/index.js";
|
|
4
|
+
import { buildArtifactPayload, EmbedderFailure } from "./build.js";
|
|
5
|
+
import { EMBED_RETRY_LIMIT } from "./produce.js";
|
|
6
|
+
export function pickArtifact(rows, opts) {
|
|
7
|
+
const candidates = rows.filter((row) => !opts.skip.has(row.id) &&
|
|
8
|
+
!sameReference(opts.failed(row.id), row.artifactBlobId, opts.localCoreKey) &&
|
|
9
|
+
row.embedderVersion.startsWith(`${opts.model}|`) &&
|
|
10
|
+
(opts.pinnedDimensions === null || row.dimensions === opts.pinnedDimensions));
|
|
11
|
+
if (candidates.length === 0)
|
|
12
|
+
return null;
|
|
13
|
+
const exactVersion = pipelineVersionFor(opts.model);
|
|
14
|
+
const exact = candidates.filter((row) => row.embedderVersion === exactVersion);
|
|
15
|
+
const pool = exact.length > 0 ? exact : candidates;
|
|
16
|
+
return pool.reduce((newest, row) => (row.createdAt > newest.createdAt ? row : newest));
|
|
17
|
+
}
|
|
18
|
+
export class HydratePass {
|
|
19
|
+
_model;
|
|
20
|
+
_index;
|
|
21
|
+
_embedder;
|
|
22
|
+
_extractors;
|
|
23
|
+
constructor(opts) {
|
|
24
|
+
this._model = opts.model;
|
|
25
|
+
this._index = opts.index;
|
|
26
|
+
this._embedder = opts.embedder;
|
|
27
|
+
this._extractors = opts.extractors;
|
|
28
|
+
}
|
|
29
|
+
async run(document, signal) {
|
|
30
|
+
const knowledge = document.record;
|
|
31
|
+
const local = document.state;
|
|
32
|
+
let entry = local.loaded;
|
|
33
|
+
if (knowledge.deletedAt) {
|
|
34
|
+
if (!entry)
|
|
35
|
+
return;
|
|
36
|
+
if (entry.evict)
|
|
37
|
+
await this._index.remove(entry.evict);
|
|
38
|
+
await this._index.remove(entry.artifactId);
|
|
39
|
+
local.loaded = undefined;
|
|
40
|
+
document.load({ state: 'pending' });
|
|
41
|
+
document.output(entry.artifactId, entry.blobRef ?? '').clear();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const rows = await document.artifacts();
|
|
45
|
+
const localCoreKey = document.localCoreKey;
|
|
46
|
+
const skip = new Set();
|
|
47
|
+
for (;;) {
|
|
48
|
+
const pick = pickArtifact(rows, {
|
|
49
|
+
model: this._model,
|
|
50
|
+
pinnedDimensions: this._index.info().dimensions,
|
|
51
|
+
failed: (id) => document.readArtifact(id)?.failedReference,
|
|
52
|
+
localCoreKey,
|
|
53
|
+
skip
|
|
54
|
+
});
|
|
55
|
+
if (!pick) {
|
|
56
|
+
if (entry)
|
|
57
|
+
document.load({ state: 'ready' }, entry.artifactId);
|
|
58
|
+
const repair = rows.find((row) => {
|
|
59
|
+
const artifact = document.readArtifact(row.id);
|
|
60
|
+
return (row.embedderVersion === pipelineVersionFor(this._model) &&
|
|
61
|
+
(sameReference(artifact?.failedReference, row.artifactBlobId, localCoreKey) ||
|
|
62
|
+
(sameReference(artifact?.unavailable?.blobRef, row.artifactBlobId, localCoreKey) &&
|
|
63
|
+
artifact?.unavailable?.repeated)));
|
|
64
|
+
});
|
|
65
|
+
if (!entry && repair && signal)
|
|
66
|
+
await this._rebuild(document, repair, signal);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (entry &&
|
|
70
|
+
entry.artifactId === pick.id &&
|
|
71
|
+
sameReference(entry.blobRef, pick.artifactBlobId, localCoreKey)) {
|
|
72
|
+
if (entry.evict) {
|
|
73
|
+
await this._index.remove(entry.evict);
|
|
74
|
+
local.loaded = { artifactId: entry.artifactId, blobRef: entry.blobRef };
|
|
75
|
+
}
|
|
76
|
+
document.load({ state: 'ready' }, entry.artifactId);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const retryAt = document.output(pick.id, pick.artifactBlobId).blockedUntil();
|
|
80
|
+
if (retryAt !== null) {
|
|
81
|
+
document.schedule(retryAt);
|
|
82
|
+
skip.add(pick.id);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (document.paused() || document.closed())
|
|
86
|
+
return;
|
|
87
|
+
const read = await document.output(pick.id, pick.artifactBlobId).read(signal);
|
|
88
|
+
if (read.kind === 'malformed') {
|
|
89
|
+
document.load({ state: 'failed', reason: 'invalid output reference' }, entry?.artifactId);
|
|
90
|
+
document.artifact(pick.id).failedReference = pick.artifactBlobId;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (read.kind === 'missing') {
|
|
94
|
+
const artifact = document.artifact(pick.id);
|
|
95
|
+
artifact.unavailable = {
|
|
96
|
+
blobRef: pick.artifactBlobId,
|
|
97
|
+
repeated: sameReference(artifact.unavailable?.blobRef, pick.artifactBlobId, localCoreKey)
|
|
98
|
+
};
|
|
99
|
+
const { retryAt } = read;
|
|
100
|
+
document.schedule(retryAt);
|
|
101
|
+
document.load({
|
|
102
|
+
state: 'pending',
|
|
103
|
+
reason: 'output unavailable on this device',
|
|
104
|
+
retryAt
|
|
105
|
+
}, entry?.artifactId);
|
|
106
|
+
skip.add(pick.id);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
document.output(pick.id, pick.artifactBlobId).clear();
|
|
110
|
+
document.artifact(pick.id).unavailable = undefined;
|
|
111
|
+
let chunks;
|
|
112
|
+
try {
|
|
113
|
+
const payload = decodeRagArtifact(read.bytes);
|
|
114
|
+
if (payload.dimensions !== pick.dimensions || payload.modelName !== this._model) {
|
|
115
|
+
throw new Error(`artifact payload is ${payload.modelName} at ${payload.dimensions} dimensions, ` +
|
|
116
|
+
`the row says ${this._model} at ${pick.dimensions}`);
|
|
117
|
+
}
|
|
118
|
+
chunks = payload.chunks;
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
document.artifact(pick.id).failedReference = pick.artifactBlobId;
|
|
122
|
+
logger.warn('rag', 'artifact undecodable, pinned for the session', { id: pick.id, err });
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (document.paused() || document.closed())
|
|
126
|
+
return;
|
|
127
|
+
const live = await document.current();
|
|
128
|
+
if (!live || live.deletedAt || signal?.aborted)
|
|
129
|
+
return;
|
|
130
|
+
try {
|
|
131
|
+
await this._index.upsert(pick.id, chunks);
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
document.artifact(pick.id).failedReference = pick.artifactBlobId;
|
|
135
|
+
logger.warn('rag', 'artifact rejected by the vector index', { id: pick.id, err });
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const evict = entry && entry.artifactId !== pick.id ? entry.artifactId : undefined;
|
|
139
|
+
local.loaded = { artifactId: pick.id, blobRef: pick.artifactBlobId, evict };
|
|
140
|
+
if (signal.aborted || document.closed())
|
|
141
|
+
return;
|
|
142
|
+
document.load({ state: 'ready' }, pick.id);
|
|
143
|
+
entry = undefined;
|
|
144
|
+
if (evict) {
|
|
145
|
+
await this._index.remove(evict);
|
|
146
|
+
local.loaded = { artifactId: pick.id, blobRef: pick.artifactBlobId };
|
|
147
|
+
}
|
|
148
|
+
logger.info('rag', 'hydrated knowledge into the vector index', {
|
|
149
|
+
artifactId: pick.id,
|
|
150
|
+
chunks: chunks.length
|
|
151
|
+
});
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async _rebuild(document, artifact, signal) {
|
|
156
|
+
const knowledge = document.record;
|
|
157
|
+
const local = document.artifact(artifact.id);
|
|
158
|
+
if (!this._embedder ||
|
|
159
|
+
(local.rebuildFailures ?? 0) > EMBED_RETRY_LIMIT ||
|
|
160
|
+
document.paused() ||
|
|
161
|
+
document.closed() ||
|
|
162
|
+
signal.aborted) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const retryAt = document.output(knowledge.id, knowledge.blobId).blockedUntil();
|
|
166
|
+
if (retryAt !== null) {
|
|
167
|
+
document.schedule(retryAt);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const read = await document.output(knowledge.id, knowledge.blobId).read(signal);
|
|
171
|
+
if (read.kind === 'malformed') {
|
|
172
|
+
local.rebuildFailures = Infinity;
|
|
173
|
+
document.load({ state: 'failed', reason: 'invalid source reference' });
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (read.kind !== 'bytes') {
|
|
177
|
+
document.schedule(read.retryAt);
|
|
178
|
+
document.load({
|
|
179
|
+
state: 'pending',
|
|
180
|
+
reason: 'source and output unavailable',
|
|
181
|
+
retryAt: read.retryAt
|
|
182
|
+
});
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
if (contentHash(read.bytes) !== artifact.sourceHash) {
|
|
187
|
+
throw new Error('source does not match the published output');
|
|
188
|
+
}
|
|
189
|
+
document.load({ state: 'running', reason: 'rebuilding local index' });
|
|
190
|
+
const payload = await buildArtifactPayload({
|
|
191
|
+
embedder: this._embedder,
|
|
192
|
+
extractors: this._extractors,
|
|
193
|
+
knowledge,
|
|
194
|
+
artifactId: artifact.id,
|
|
195
|
+
bytes: read.bytes,
|
|
196
|
+
signal,
|
|
197
|
+
onProgress: (processedChunks, totalChunks) => document.report({
|
|
198
|
+
stage: 'embedding',
|
|
199
|
+
processedChunks,
|
|
200
|
+
totalChunks
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
const live = await document.current();
|
|
204
|
+
if (!live || live.deletedAt || signal.aborted || document.paused() || document.closed()) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (payload.dimensions !== artifact.dimensions) {
|
|
208
|
+
throw new Error('rebuilt output has incompatible dimensions');
|
|
209
|
+
}
|
|
210
|
+
await this._index.upsert(artifact.id, payload.chunks);
|
|
211
|
+
document.state.loaded = {
|
|
212
|
+
artifactId: artifact.id,
|
|
213
|
+
blobRef: artifact.artifactBlobId
|
|
214
|
+
};
|
|
215
|
+
if (signal.aborted || document.closed())
|
|
216
|
+
return;
|
|
217
|
+
document.output(knowledge.id, knowledge.blobId).clear();
|
|
218
|
+
local.rebuildFailures = undefined;
|
|
219
|
+
document.load({ state: 'ready' }, artifact.id);
|
|
220
|
+
document.report({
|
|
221
|
+
stage: 'ready',
|
|
222
|
+
processedChunks: payload.chunks.length,
|
|
223
|
+
totalChunks: payload.chunks.length
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
if (document.closed())
|
|
228
|
+
return;
|
|
229
|
+
if (signal.aborted || document.paused()) {
|
|
230
|
+
document.load({ state: 'pending', reason: 'processing interrupted' });
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const failures = error instanceof EmbedderFailure ? (local.rebuildFailures ?? 0) + 1 : Infinity;
|
|
234
|
+
local.rebuildFailures = failures;
|
|
235
|
+
const retryAt = failures <= EMBED_RETRY_LIMIT
|
|
236
|
+
? document.output(knowledge.id, knowledge.blobId).miss()
|
|
237
|
+
: undefined;
|
|
238
|
+
if (retryAt)
|
|
239
|
+
document.schedule(retryAt);
|
|
240
|
+
document.load({
|
|
241
|
+
state: 'failed',
|
|
242
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
243
|
+
retryAt
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function sameReference(left, right, localCoreKey) {
|
|
249
|
+
return left !== undefined && (compareBlobReferences(left, right, localCoreKey) ?? left === right);
|
|
250
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_RAG_MODEL = "EMBEDDINGGEMMA_300M_Q4_0";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_RAG_MODEL = 'EMBEDDINGGEMMA_300M_Q4_0';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { toolsetEnabled } from '@qvac/harness/lib/tools/toolsets.ts';
|
|
2
|
+
import { getAgent, isOrphaned } from "../../agent.js";
|
|
3
|
+
import { getChat } from "../../chat.js";
|
|
4
|
+
export async function canIndexChat(mesh, deviceId, chatId) {
|
|
5
|
+
if (!deviceId) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const chat = await getChat(mesh, chatId);
|
|
9
|
+
if (!chat) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const agent = await getAgent(mesh, chat.agentId);
|
|
13
|
+
if (!agent) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (!toolsetEnabled('knowledge', agent.disabledToolsets)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (await isOrphaned(mesh, agent)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return agent.providerDeviceId.equals(deviceId);
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
|
+
import type { RagExtractors } from './extract/extract.ts';
|
|
3
|
+
import { type BuildEmbedder } from './build.ts';
|
|
4
|
+
import { type FileDocument } from '../processing/index.ts';
|
|
5
|
+
export interface IndexingEmbedder extends BuildEmbedder {
|
|
6
|
+
}
|
|
7
|
+
export type IndexingProgress = (update: {
|
|
8
|
+
knowledgeId: string;
|
|
9
|
+
chatId: string;
|
|
10
|
+
stage: 'embedding' | 'ready' | 'failed';
|
|
11
|
+
processedChunks: number;
|
|
12
|
+
totalChunks: number;
|
|
13
|
+
error?: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
export declare const EMBED_RETRY_LIMIT = 5;
|
|
16
|
+
export declare class IndexingPass {
|
|
17
|
+
private readonly _embedder;
|
|
18
|
+
private readonly _extractors;
|
|
19
|
+
constructor(embedder: IndexingEmbedder, extractors?: RagExtractors);
|
|
20
|
+
run(document: FileDocument, signal: AbortSignal): Promise<void>;
|
|
21
|
+
}
|