@qvac/core 0.0.0 → 0.1.1
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 +47257 -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/helpers.d.ts +28 -0
- package/dist-lib/schema/helpers.js +176 -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/schema/vendor.d.ts +5 -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 +336 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type Corestore from 'corestore';
|
|
2
|
+
import ReadyResource from 'ready-resource';
|
|
3
|
+
import type { LinkableAttachment } from '../../attachment-link.ts';
|
|
4
|
+
import type Hyperblobs from 'hyperblobs';
|
|
5
|
+
export type CurrentMeshKeys = () => {
|
|
6
|
+
blobs: Hyperblobs;
|
|
7
|
+
encryptionKey: Buffer;
|
|
8
|
+
} | null;
|
|
9
|
+
export declare class CoreBlobServer extends ReadyResource {
|
|
10
|
+
private readonly _store;
|
|
11
|
+
private readonly _mesh;
|
|
12
|
+
private readonly _server;
|
|
13
|
+
private readonly _probes;
|
|
14
|
+
private readonly _readTimeoutMs;
|
|
15
|
+
private _suspended;
|
|
16
|
+
constructor(store: Corestore, mesh: CurrentMeshKeys, { readTimeoutMs }?: {
|
|
17
|
+
readTimeoutMs?: number | undefined;
|
|
18
|
+
});
|
|
19
|
+
get port(): number;
|
|
20
|
+
link({ blobId, mimeType }: LinkableAttachment): string | null;
|
|
21
|
+
suspend(): Promise<void>;
|
|
22
|
+
resume(): Promise<void>;
|
|
23
|
+
_open(): Promise<void>;
|
|
24
|
+
_close(): Promise<void>;
|
|
25
|
+
private _resolve;
|
|
26
|
+
private _parse;
|
|
27
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import BlobServer, {} from 'hypercore-blob-server';
|
|
2
|
+
import ReadyResource from 'ready-resource';
|
|
3
|
+
import { isInvalidBlobReferenceError, parseBlobReference } from "./reference.js";
|
|
4
|
+
export class CoreBlobServer extends ReadyResource {
|
|
5
|
+
_store;
|
|
6
|
+
_mesh;
|
|
7
|
+
_server;
|
|
8
|
+
_probes = new Set();
|
|
9
|
+
_readTimeoutMs;
|
|
10
|
+
_suspended = false;
|
|
11
|
+
constructor(store, mesh, { readTimeoutMs = 15_000 } = {}) {
|
|
12
|
+
super();
|
|
13
|
+
this._store = store.session();
|
|
14
|
+
this._mesh = mesh;
|
|
15
|
+
this._readTimeoutMs = readTimeoutMs;
|
|
16
|
+
this._server = new BlobServer(this._store, {
|
|
17
|
+
resolve: (key, info) => this._resolve(key, info)
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
get port() {
|
|
21
|
+
return this._server.port;
|
|
22
|
+
}
|
|
23
|
+
link({ blobId, mimeType }) {
|
|
24
|
+
if (!this.opened || this.closing)
|
|
25
|
+
return null;
|
|
26
|
+
const current = this._mesh();
|
|
27
|
+
if (!current)
|
|
28
|
+
return null;
|
|
29
|
+
const parsed = this._parse(blobId);
|
|
30
|
+
if (!parsed || parsed.inline)
|
|
31
|
+
return null;
|
|
32
|
+
return this._server.getLink(parsed.coreKey ?? current.blobs.core.key.toString('hex'), {
|
|
33
|
+
blob: parsed.blobId,
|
|
34
|
+
type: mimeType || 'application/octet-stream'
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async suspend() {
|
|
38
|
+
if (this.closing)
|
|
39
|
+
return;
|
|
40
|
+
this._suspended = true;
|
|
41
|
+
if (!this.opened)
|
|
42
|
+
await this.ready();
|
|
43
|
+
await Promise.all([...this._probes].map((core) => core.close()));
|
|
44
|
+
await this._server.suspend();
|
|
45
|
+
}
|
|
46
|
+
async resume() {
|
|
47
|
+
if (this.closing)
|
|
48
|
+
return;
|
|
49
|
+
if (!this.opened)
|
|
50
|
+
await this.ready();
|
|
51
|
+
if (this.closing)
|
|
52
|
+
return;
|
|
53
|
+
this._suspended = false;
|
|
54
|
+
const before = this._server.port;
|
|
55
|
+
await this._server.resume();
|
|
56
|
+
if (this._server.port !== before)
|
|
57
|
+
this.emit('rebound', this._server.port);
|
|
58
|
+
}
|
|
59
|
+
async _open() {
|
|
60
|
+
await this._server.listen();
|
|
61
|
+
}
|
|
62
|
+
async _close() {
|
|
63
|
+
await Promise.all([...this._probes].map((core) => core.close()));
|
|
64
|
+
await this._server.close();
|
|
65
|
+
await this._store.close();
|
|
66
|
+
}
|
|
67
|
+
async _resolve(key, info) {
|
|
68
|
+
const current = this._mesh();
|
|
69
|
+
if (!current || this.closing || this._suspended)
|
|
70
|
+
return null;
|
|
71
|
+
const keys = { encryptionKey: current.encryptionKey };
|
|
72
|
+
const { blob, range } = info;
|
|
73
|
+
if (!blob || info.head || blob.byteLength === 0)
|
|
74
|
+
return keys;
|
|
75
|
+
const start = range?.start ?? 0;
|
|
76
|
+
const end = !range || range.end === -1 ? blob.byteLength - 1 : Math.min(range.end, blob.byteLength - 1);
|
|
77
|
+
if (start > end)
|
|
78
|
+
return keys;
|
|
79
|
+
const core = this._store.get({ key, ...keys });
|
|
80
|
+
const deadline = Date.now() + this._readTimeoutMs;
|
|
81
|
+
this._probes.add(core);
|
|
82
|
+
try {
|
|
83
|
+
await core.ready();
|
|
84
|
+
if (this.closing || this._suspended || Date.now() >= deadline)
|
|
85
|
+
return null;
|
|
86
|
+
const position = start === 0
|
|
87
|
+
? [blob.blockOffset, 0]
|
|
88
|
+
: await core.seek(blob.byteOffset + start, {
|
|
89
|
+
timeout: Math.max(1, deadline - Date.now())
|
|
90
|
+
});
|
|
91
|
+
if (!position || this.closing || this._suspended || Date.now() >= deadline)
|
|
92
|
+
return null;
|
|
93
|
+
const bytes = await core.get(position[0], { timeout: Math.max(1, deadline - Date.now()) });
|
|
94
|
+
return bytes && this._mesh() === current && !this.closing && !this._suspended ? keys : null;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
this._probes.delete(core);
|
|
101
|
+
await core.close();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
_parse(blobReference) {
|
|
105
|
+
try {
|
|
106
|
+
return parseBlobReference(blobReference);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
if (isInvalidBlobReferenceError(err))
|
|
110
|
+
return null;
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { parseBlobReference, parseBlobReferenceCoreKey } from "./reference.js";
|
|
2
|
+
export async function sweepUnreferenced(blobs, references, coreLength) {
|
|
3
|
+
const ranges = [];
|
|
4
|
+
const key = blobs.core.key.toString('hex');
|
|
5
|
+
for (const reference of references)
|
|
6
|
+
addLocalRange(ranges, reference, key, coreLength);
|
|
7
|
+
await clearGaps(blobs, mergeRanges(ranges), coreLength);
|
|
8
|
+
}
|
|
9
|
+
function addLocalRange(ranges, reference, localCoreKey, coreLength) {
|
|
10
|
+
const coreKey = parseBlobReferenceCoreKey(reference);
|
|
11
|
+
if (coreKey && coreKey !== localCoreKey)
|
|
12
|
+
return;
|
|
13
|
+
const { blobId } = parseBlobReference(reference);
|
|
14
|
+
const end = blobId.blockOffset + blobId.blockLength;
|
|
15
|
+
if (!Number.isSafeInteger(end) || end > coreLength) {
|
|
16
|
+
throw new TypeError('blob reference exceeds local core');
|
|
17
|
+
}
|
|
18
|
+
if (blobId.blockLength > 0)
|
|
19
|
+
ranges.push({ start: blobId.blockOffset, end });
|
|
20
|
+
}
|
|
21
|
+
function mergeRanges(ranges) {
|
|
22
|
+
const sorted = [...ranges].sort((a, b) => a.start - b.start || a.end - b.end);
|
|
23
|
+
const merged = [];
|
|
24
|
+
for (const range of sorted) {
|
|
25
|
+
const previous = merged.at(-1);
|
|
26
|
+
if (!previous || range.start > previous.end) {
|
|
27
|
+
merged.push(range);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (range.end > previous.end) {
|
|
31
|
+
merged[merged.length - 1] = { start: previous.start, end: range.end };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return merged;
|
|
35
|
+
}
|
|
36
|
+
async function clearGaps(blobs, ranges, coreLength) {
|
|
37
|
+
let cursor = 0;
|
|
38
|
+
for (const range of ranges) {
|
|
39
|
+
if (cursor < range.start)
|
|
40
|
+
await blobs.core.clear(cursor, range.start);
|
|
41
|
+
cursor = range.end;
|
|
42
|
+
}
|
|
43
|
+
if (cursor < coreLength)
|
|
44
|
+
await blobs.core.clear(cursor, coreLength);
|
|
45
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HandlerFrames } from '../../../spec/capabilities.d.ts';
|
|
2
|
+
type UploadFrames<T> = HandlerFrames<T> & {
|
|
3
|
+
readonly writeStream?: {
|
|
4
|
+
readonly destroyed: boolean;
|
|
5
|
+
readonly destroying: boolean;
|
|
6
|
+
on(event: 'close', listener: () => void): void;
|
|
7
|
+
off(event: 'close', listener: () => void): void;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare class UploadInput<T extends {
|
|
11
|
+
data?: Buffer | null;
|
|
12
|
+
}> {
|
|
13
|
+
readonly iterator: AsyncIterator<T>;
|
|
14
|
+
private readonly _abort;
|
|
15
|
+
private readonly _frames;
|
|
16
|
+
private readonly _source;
|
|
17
|
+
private readonly _onClose;
|
|
18
|
+
onData: ((bytes: number) => void) | null;
|
|
19
|
+
onFailure: ((error: unknown) => void) | null;
|
|
20
|
+
constructor(frames: AsyncIterable<T> | UploadFrames<T>, options: {
|
|
21
|
+
inactivityMs?: number;
|
|
22
|
+
});
|
|
23
|
+
check(): void;
|
|
24
|
+
fail(error: unknown): void;
|
|
25
|
+
close(): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AbortController } from 'bare-abort-controller';
|
|
2
|
+
import { toAsyncIterable } from "../async-iterable.js";
|
|
3
|
+
import { nextFrame } from "../next-frame.js";
|
|
4
|
+
import { AbortedError } from '@qvac/harness/race-abort';
|
|
5
|
+
export class UploadInput {
|
|
6
|
+
iterator;
|
|
7
|
+
_abort = new AbortController();
|
|
8
|
+
_frames;
|
|
9
|
+
_source;
|
|
10
|
+
_onClose = () => {
|
|
11
|
+
const error = new AbortedError();
|
|
12
|
+
this._abort.abort(error);
|
|
13
|
+
this.fail(error);
|
|
14
|
+
};
|
|
15
|
+
onData = null;
|
|
16
|
+
onFailure = null;
|
|
17
|
+
constructor(frames, options) {
|
|
18
|
+
this._frames = frames;
|
|
19
|
+
const source = toAsyncIterable(frames)[Symbol.asyncIterator]();
|
|
20
|
+
this._source = source;
|
|
21
|
+
this.iterator = {
|
|
22
|
+
next: async () => {
|
|
23
|
+
this.check();
|
|
24
|
+
const frame = await nextFrame(source, { ...options, signal: this._abort.signal });
|
|
25
|
+
if (!frame.done && frame.value.data)
|
|
26
|
+
this.onData?.(frame.value.data.length);
|
|
27
|
+
return frame;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
if ('writeStream' in frames)
|
|
31
|
+
frames.writeStream?.on('close', this._onClose);
|
|
32
|
+
}
|
|
33
|
+
check() {
|
|
34
|
+
if (this._abort.signal.aborted)
|
|
35
|
+
throw new AbortedError();
|
|
36
|
+
if ('writeStream' in this._frames) {
|
|
37
|
+
const stream = this._frames.writeStream;
|
|
38
|
+
if (stream?.destroyed || stream?.destroying)
|
|
39
|
+
throw new AbortedError();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
fail(error) {
|
|
43
|
+
this.onFailure?.(error);
|
|
44
|
+
this.onFailure = null;
|
|
45
|
+
}
|
|
46
|
+
close() {
|
|
47
|
+
this.fail(new AbortedError());
|
|
48
|
+
if ('writeStream' in this._frames)
|
|
49
|
+
this._frames.writeStream?.off('close', this._onClose);
|
|
50
|
+
void this._source.return?.().catch(() => { });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AssistantUploadAttachmentRequest } from '../../../spec/hyperschema/types.d.ts';
|
|
2
|
+
import type { HandlerFrames } from '../../../spec/capabilities.d.ts';
|
|
3
|
+
import type { Mesh } from '../mesh.ts';
|
|
4
|
+
export declare function uploadFile(mesh: Mesh, frames: AsyncIterable<AssistantUploadAttachmentRequest> | HandlerFrames<AssistantUploadAttachmentRequest>, { kind, maxBytes, deviceId, inactivityMs }: {
|
|
5
|
+
kind: 'attachment' | 'knowledge';
|
|
6
|
+
maxBytes: number;
|
|
7
|
+
deviceId?: Buffer | null;
|
|
8
|
+
inactivityMs?: number;
|
|
9
|
+
}): AsyncGenerator<{
|
|
10
|
+
bytesWritten: number;
|
|
11
|
+
attachment?: undefined;
|
|
12
|
+
knowledge?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
bytesWritten: number;
|
|
15
|
+
attachment: {
|
|
16
|
+
id: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
mimeType: string;
|
|
19
|
+
byteLength: number;
|
|
20
|
+
blobId: string;
|
|
21
|
+
createdAt: number;
|
|
22
|
+
};
|
|
23
|
+
knowledge: import("../../../spec/index").QvacKnowledge | undefined;
|
|
24
|
+
}, void, unknown>;
|
|
25
|
+
export declare function capped(chunks: AsyncIterable<Buffer>, maxBytes: number, message: string): AsyncGenerator<Buffer>;
|
|
26
|
+
export declare function dataFrames<T extends {
|
|
27
|
+
data?: Buffer | null;
|
|
28
|
+
}>(rest: AsyncIterator<T>, firstData: Buffer | null | undefined): AsyncGenerator<Buffer>;
|
|
29
|
+
export declare function peekHead(it: AsyncIterable<Buffer>, n: number): Promise<{
|
|
30
|
+
head: Buffer;
|
|
31
|
+
rest: AsyncIterable<Buffer>;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { isKnowledgeRoutedAttachment, routeAttachmentToKnowledge, removeKnowledge, syncAttachmentChunk } from "./records/index.js";
|
|
3
|
+
import { normalizeImageForModel, IMAGE_MIMES } from "../image/normalize.js";
|
|
4
|
+
import { detectImageMime, mapDeclaredToSniffed } from "../image/sniff.js";
|
|
5
|
+
import { isSupportedRagDocument } from "./rag/index.js";
|
|
6
|
+
import { appendChunk, updateChunk } from "../chunk.js";
|
|
7
|
+
import { UploadInput } from "./upload-input.js";
|
|
8
|
+
const MODEL_NATIVE_IMAGE_MIMES = new Set([
|
|
9
|
+
'image/png',
|
|
10
|
+
'image/jpeg',
|
|
11
|
+
'image/webp',
|
|
12
|
+
'image/gif',
|
|
13
|
+
'image/bmp'
|
|
14
|
+
]);
|
|
15
|
+
const noop = () => { };
|
|
16
|
+
export async function* uploadFile(mesh, frames, { kind, maxBytes, deviceId, inactivityMs }) {
|
|
17
|
+
const input = new UploadInput(frames, { inactivityMs });
|
|
18
|
+
const it = input.iterator;
|
|
19
|
+
let uploadId;
|
|
20
|
+
try {
|
|
21
|
+
const first = await it.next();
|
|
22
|
+
if (first.done)
|
|
23
|
+
return;
|
|
24
|
+
const { chatId, runId, fileName, mimeType, raw } = first.value;
|
|
25
|
+
const originDeviceId = kind === 'knowledge' ? deviceId : first.value.originDeviceId;
|
|
26
|
+
if (typeof chatId !== 'string' ||
|
|
27
|
+
typeof fileName !== 'string' ||
|
|
28
|
+
typeof mimeType !== 'string' ||
|
|
29
|
+
!originDeviceId) {
|
|
30
|
+
throw new Error(`upload${kind === 'knowledge' ? 'Knowledge' : 'Attachment'}: first frame must carry chatId, fileName, mimeType${kind === 'attachment' ? ', originDeviceId' : ''}`);
|
|
31
|
+
}
|
|
32
|
+
const upload = await mesh.files.beginUpload(first.value);
|
|
33
|
+
uploadId = upload.id;
|
|
34
|
+
input.onData = (bytes) => mesh.files.uploadProgress(upload.id, bytes);
|
|
35
|
+
input.onFailure = (error) => mesh.files.uploadFailed(upload.id, error);
|
|
36
|
+
const source = capped(dataFrames(it, first.value.data), maxBytes, `${kind} too large ${kind === 'attachment' ? '—' : '-'} the limit is ${maxBytes} bytes`);
|
|
37
|
+
let stream = source;
|
|
38
|
+
let storedMime = mimeType;
|
|
39
|
+
const declaredSniffed = mapDeclaredToSniffed(storedMime);
|
|
40
|
+
if (kind === 'knowledge') {
|
|
41
|
+
const { head, rest } = await peekHead(source, 4096);
|
|
42
|
+
if (declaredSniffed !== null && detectImageMime(head) !== declaredSniffed) {
|
|
43
|
+
throw new Error(`uploadKnowledge: bytes do not match declared mime ${mimeType}`);
|
|
44
|
+
}
|
|
45
|
+
if (!isSupportedRagDocument({ fileName, mimeType, bytes: head })) {
|
|
46
|
+
throw new Error(`${fileName} is not a supported Knowledge file.`);
|
|
47
|
+
}
|
|
48
|
+
stream = rest;
|
|
49
|
+
}
|
|
50
|
+
else if (declaredSniffed !== null) {
|
|
51
|
+
const { head, rest } = await peekHead(source, 12);
|
|
52
|
+
const sniffed = detectImageMime(head);
|
|
53
|
+
if (raw) {
|
|
54
|
+
if (sniffed !== declaredSniffed) {
|
|
55
|
+
throw new Error(`uploadAttachment: bytes do not match declared mime ${storedMime}`);
|
|
56
|
+
}
|
|
57
|
+
stream = rest;
|
|
58
|
+
}
|
|
59
|
+
else if (sniffed === null) {
|
|
60
|
+
throw new Error(`uploadAttachment: bytes are not a valid image for ${storedMime}`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const pieces = [];
|
|
64
|
+
let received = 0;
|
|
65
|
+
const chunks = rest[Symbol.asyncIterator]();
|
|
66
|
+
let next = await chunks.next();
|
|
67
|
+
while (!next.done) {
|
|
68
|
+
pieces.push(next.value);
|
|
69
|
+
received += next.value.length;
|
|
70
|
+
next = await chunks.next();
|
|
71
|
+
if (!next.done)
|
|
72
|
+
yield { bytesWritten: received };
|
|
73
|
+
}
|
|
74
|
+
const original = b4a.concat(pieces);
|
|
75
|
+
const bytes = await normalizeImageForModel(original);
|
|
76
|
+
if (bytes !== original) {
|
|
77
|
+
storedMime = 'image/jpeg';
|
|
78
|
+
}
|
|
79
|
+
else if (MODEL_NATIVE_IMAGE_MIMES.has(sniffed)) {
|
|
80
|
+
storedMime = sniffed;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw new Error(`uploadAttachment: could not decode ${sniffed} image (it may be corrupt)`);
|
|
84
|
+
}
|
|
85
|
+
stream = (async function* () {
|
|
86
|
+
yield bytes;
|
|
87
|
+
})();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let written;
|
|
91
|
+
for await (const frame of mesh.files.write(stream, { inactivityMs })) {
|
|
92
|
+
written = frame;
|
|
93
|
+
if (!('blobId' in frame))
|
|
94
|
+
yield { bytesWritten: frame.bytesWritten };
|
|
95
|
+
}
|
|
96
|
+
const final = written;
|
|
97
|
+
const attachment = {
|
|
98
|
+
id: upload.id,
|
|
99
|
+
fileName,
|
|
100
|
+
mimeType: storedMime,
|
|
101
|
+
byteLength: final.byteLength,
|
|
102
|
+
blobId: mesh.files.reference(final.blobId),
|
|
103
|
+
createdAt: Date.now()
|
|
104
|
+
};
|
|
105
|
+
let chunkId;
|
|
106
|
+
try {
|
|
107
|
+
input.check();
|
|
108
|
+
const preview = IMAGE_MIMES.has(storedMime.toLowerCase());
|
|
109
|
+
const appended = await appendChunk(mesh, {
|
|
110
|
+
id: preview ? upload.id : undefined,
|
|
111
|
+
display: preview ? { preview: true } : undefined,
|
|
112
|
+
chatId,
|
|
113
|
+
runId,
|
|
114
|
+
type: 'attachment',
|
|
115
|
+
attachment,
|
|
116
|
+
originDeviceId
|
|
117
|
+
});
|
|
118
|
+
chunkId = appended.id;
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
await mesh.files.clear(attachment.blobId, attachment.id).catch(noop);
|
|
122
|
+
throw err;
|
|
123
|
+
}
|
|
124
|
+
let knowledge;
|
|
125
|
+
try {
|
|
126
|
+
input.check();
|
|
127
|
+
if (kind === 'knowledge' || (!runId && isKnowledgeRoutedAttachment(attachment))) {
|
|
128
|
+
knowledge = await routeAttachmentToKnowledge(mesh, chatId, attachment);
|
|
129
|
+
}
|
|
130
|
+
input.check();
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
await removeKnowledge(mesh, { knowledgeId: upload.id, at: Date.now() }).catch(noop);
|
|
134
|
+
const tombstone = await updateChunk(mesh, {
|
|
135
|
+
id: chunkId,
|
|
136
|
+
attachment: { ...attachment, deletedAt: Date.now() }
|
|
137
|
+
}).catch(noop);
|
|
138
|
+
if (tombstone)
|
|
139
|
+
await syncAttachmentChunk(mesh, tombstone).catch(noop);
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
mesh.files.uploadComplete(upload.id);
|
|
143
|
+
input.onFailure = null;
|
|
144
|
+
yield {
|
|
145
|
+
bytesWritten: written.bytesWritten,
|
|
146
|
+
attachment,
|
|
147
|
+
knowledge
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
input.fail(error);
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
input.close();
|
|
156
|
+
if (uploadId)
|
|
157
|
+
mesh.files.uploadClosed(uploadId);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export async function* capped(chunks, maxBytes, message) {
|
|
161
|
+
let total = 0;
|
|
162
|
+
for await (const chunk of chunks) {
|
|
163
|
+
total += chunk.length;
|
|
164
|
+
if (total > maxBytes)
|
|
165
|
+
throw new Error(message);
|
|
166
|
+
yield chunk;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
export async function* dataFrames(rest, firstData) {
|
|
170
|
+
if (firstData)
|
|
171
|
+
yield firstData;
|
|
172
|
+
let next = await rest.next();
|
|
173
|
+
while (!next.done) {
|
|
174
|
+
if (next.value.data)
|
|
175
|
+
yield next.value.data;
|
|
176
|
+
next = await rest.next();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
export async function peekHead(it, n) {
|
|
180
|
+
const iterator = it[Symbol.asyncIterator]();
|
|
181
|
+
const pieces = [];
|
|
182
|
+
let collected = 0;
|
|
183
|
+
while (collected < n) {
|
|
184
|
+
const next = await iterator.next();
|
|
185
|
+
if (next.done)
|
|
186
|
+
break;
|
|
187
|
+
pieces.push(next.value);
|
|
188
|
+
collected += next.value.length;
|
|
189
|
+
}
|
|
190
|
+
const head = Buffer.concat(pieces).subarray(0, Math.min(collected, n));
|
|
191
|
+
const rest = (async function* () {
|
|
192
|
+
for (const piece of pieces)
|
|
193
|
+
yield piece;
|
|
194
|
+
let step = await iterator.next();
|
|
195
|
+
while (!step.done) {
|
|
196
|
+
yield step.value;
|
|
197
|
+
step = await iterator.next();
|
|
198
|
+
}
|
|
199
|
+
})();
|
|
200
|
+
return { head, rest };
|
|
201
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Hyperdrive from 'hyperdrive';
|
|
2
|
+
import type Corestore from 'corestore';
|
|
3
|
+
import type Hyperswarm from 'hyperswarm';
|
|
4
|
+
import type { BlindPeeringOpts } from './blind-peers.ts';
|
|
5
|
+
export interface AcquiredDrive {
|
|
6
|
+
readonly drive: Hyperdrive;
|
|
7
|
+
readonly writable: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface DriveHost {
|
|
10
|
+
acquire(key: string): Promise<AcquiredDrive>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface DriveHostOptions {
|
|
14
|
+
readonly swarm: Hyperswarm;
|
|
15
|
+
readonly blindPeerKeys: ReadonlyArray<Buffer>;
|
|
16
|
+
readonly blindPeeringOpts?: BlindPeeringOpts;
|
|
17
|
+
}
|
|
18
|
+
export declare function createFsDriveHost(store: Corestore, opts: DriveHostOptions): DriveHost;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import BlindPeering from 'blind-peering';
|
|
2
|
+
import Hyperdrive from 'hyperdrive';
|
|
3
|
+
import HypercoreId from 'hypercore-id-encoding';
|
|
4
|
+
const NAMESPACE = 'fs-drives';
|
|
5
|
+
const DRIVE_OPEN_TIMEOUT_MS = 15_000;
|
|
6
|
+
function withDeadline(promise, ms) {
|
|
7
|
+
const { promise: gated, resolve, reject } = Promise.withResolvers();
|
|
8
|
+
const timer = setTimeout(() => reject(new Error('drive open timed out on the host')), ms);
|
|
9
|
+
promise.then((value) => {
|
|
10
|
+
clearTimeout(timer);
|
|
11
|
+
resolve(value);
|
|
12
|
+
}, (err) => {
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
reject(err);
|
|
15
|
+
});
|
|
16
|
+
return gated;
|
|
17
|
+
}
|
|
18
|
+
async function openDrive(store, swarm, key) {
|
|
19
|
+
const drive = new Hyperdrive(store, HypercoreId.decode(key));
|
|
20
|
+
await drive.ready();
|
|
21
|
+
const topic = swarm.join(drive.discoveryKey, { server: false, client: true });
|
|
22
|
+
const donePeering = drive.findingPeers();
|
|
23
|
+
topic.flushed().then(donePeering, donePeering);
|
|
24
|
+
return drive;
|
|
25
|
+
}
|
|
26
|
+
export function createFsDriveHost(store, opts) {
|
|
27
|
+
const namespaced = store.namespace(NAMESPACE);
|
|
28
|
+
const peering = new BlindPeering(opts.swarm.dht, namespaced, {
|
|
29
|
+
pick: 2,
|
|
30
|
+
...opts.blindPeeringOpts
|
|
31
|
+
});
|
|
32
|
+
const drives = new Map();
|
|
33
|
+
async function acquire(key) {
|
|
34
|
+
const cached = drives.get(key);
|
|
35
|
+
if (cached)
|
|
36
|
+
return cached;
|
|
37
|
+
const opening = withDeadline((async () => {
|
|
38
|
+
const drive = await openDrive(namespaced, opts.swarm, key);
|
|
39
|
+
const blobs = await drive.getBlobs();
|
|
40
|
+
peering.addCoreBackground(drive.core, { keys: opts.blindPeerKeys });
|
|
41
|
+
if (blobs)
|
|
42
|
+
peering.addCoreBackground(blobs.core, { keys: opts.blindPeerKeys });
|
|
43
|
+
return { drive, writable: drive.writable };
|
|
44
|
+
})(), DRIVE_OPEN_TIMEOUT_MS);
|
|
45
|
+
drives.set(key, opening);
|
|
46
|
+
opening.catch(() => drives.delete(key));
|
|
47
|
+
return opening;
|
|
48
|
+
}
|
|
49
|
+
async function close() {
|
|
50
|
+
const settled = await Promise.allSettled(drives.values());
|
|
51
|
+
drives.clear();
|
|
52
|
+
await Promise.all(settled
|
|
53
|
+
.filter((result) => result.status === 'fulfilled')
|
|
54
|
+
.map((result) => result.value.drive.close()));
|
|
55
|
+
await peering.close();
|
|
56
|
+
}
|
|
57
|
+
return { acquire, close };
|
|
58
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Codec } from 'compact-encoding';
|
|
2
|
+
export declare const HOST_UNREACHABLE = "the device hosting this agent is not connected";
|
|
3
|
+
export declare const HOST_SILENT = "the device hosting this agent did not answer";
|
|
4
|
+
export declare const ACK_TIMEOUT_MS = 60000;
|
|
5
|
+
export interface HandoffStream {
|
|
6
|
+
readonly remotePublicKey: Uint8Array;
|
|
7
|
+
readonly noiseStream: {
|
|
8
|
+
userData: unknown;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface HandoffChannelOptions<Req, Res, Ack extends {
|
|
12
|
+
id: number;
|
|
13
|
+
}> {
|
|
14
|
+
readonly protocol: string;
|
|
15
|
+
readonly requestEncoding: Codec<RequestMessage<Req>>;
|
|
16
|
+
readonly ackEncoding: Codec<Ack>;
|
|
17
|
+
readonly onrequest: (request: Req, from: Uint8Array) => Promise<Res>;
|
|
18
|
+
readonly buildAck: (id: number, error: string, result: Res | null) => Ack;
|
|
19
|
+
readonly readAck: (ack: Ack) => {
|
|
20
|
+
readonly error: string;
|
|
21
|
+
readonly result: Res;
|
|
22
|
+
};
|
|
23
|
+
readonly ackTimeoutMs?: number;
|
|
24
|
+
}
|
|
25
|
+
interface RequestMessage<Req> {
|
|
26
|
+
readonly id: number;
|
|
27
|
+
readonly request: Req;
|
|
28
|
+
}
|
|
29
|
+
export declare class HandoffChannel<Req, Res, Ack extends {
|
|
30
|
+
id: number;
|
|
31
|
+
}> {
|
|
32
|
+
private readonly _opts;
|
|
33
|
+
private readonly _ackTimeoutMs;
|
|
34
|
+
private readonly _peers;
|
|
35
|
+
private readonly _waiters;
|
|
36
|
+
private _nextId;
|
|
37
|
+
constructor(opts: HandoffChannelOptions<Req, Res, Ack>);
|
|
38
|
+
addStream(stream: HandoffStream): void;
|
|
39
|
+
send(hostDeviceId: Uint8Array, request: Req): Promise<Res>;
|
|
40
|
+
destroy(): void;
|
|
41
|
+
private _serve;
|
|
42
|
+
private _settle;
|
|
43
|
+
private _drop;
|
|
44
|
+
private _fail;
|
|
45
|
+
}
|
|
46
|
+
export {};
|