@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,149 @@
|
|
|
1
|
+
const HEIF_BRANDS = new Set([
|
|
2
|
+
'heic',
|
|
3
|
+
'heix',
|
|
4
|
+
'heim',
|
|
5
|
+
'heis',
|
|
6
|
+
'hevc',
|
|
7
|
+
'hevm',
|
|
8
|
+
'hevs',
|
|
9
|
+
'mif1',
|
|
10
|
+
'msf1'
|
|
11
|
+
]);
|
|
12
|
+
const AVIF_BRANDS = new Set(['avif', 'avis']);
|
|
13
|
+
export function detectImageMime(bytes) {
|
|
14
|
+
if (isPng(bytes))
|
|
15
|
+
return 'image/png';
|
|
16
|
+
if (isJpeg(bytes))
|
|
17
|
+
return 'image/jpeg';
|
|
18
|
+
if (isAvif(bytes))
|
|
19
|
+
return 'image/avif';
|
|
20
|
+
if (isHeif(bytes))
|
|
21
|
+
return 'image/heic';
|
|
22
|
+
if (isWebp(bytes))
|
|
23
|
+
return 'image/webp';
|
|
24
|
+
if (isGif(bytes))
|
|
25
|
+
return 'image/gif';
|
|
26
|
+
if (isBmp(bytes))
|
|
27
|
+
return 'image/bmp';
|
|
28
|
+
if (isTiff(bytes))
|
|
29
|
+
return 'image/tiff';
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
export function mapDeclaredToSniffed(declared) {
|
|
33
|
+
const normalized = declared.toLowerCase();
|
|
34
|
+
if (normalized === 'image/png')
|
|
35
|
+
return 'image/png';
|
|
36
|
+
if (normalized === 'image/jpeg' || normalized === 'image/jpg')
|
|
37
|
+
return 'image/jpeg';
|
|
38
|
+
if (normalized === 'image/heic' || normalized === 'image/heif')
|
|
39
|
+
return 'image/heic';
|
|
40
|
+
if (normalized === 'image/avif')
|
|
41
|
+
return 'image/avif';
|
|
42
|
+
if (normalized === 'image/webp')
|
|
43
|
+
return 'image/webp';
|
|
44
|
+
if (normalized === 'image/gif')
|
|
45
|
+
return 'image/gif';
|
|
46
|
+
if (normalized === 'image/bmp' || normalized === 'image/x-ms-bmp')
|
|
47
|
+
return 'image/bmp';
|
|
48
|
+
if (normalized === 'image/tiff' || normalized === 'image/tif')
|
|
49
|
+
return 'image/tiff';
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function isPng(bytes) {
|
|
53
|
+
return (bytes.length >= 8 &&
|
|
54
|
+
bytes[0] === 0x89 &&
|
|
55
|
+
bytes[1] === 0x50 &&
|
|
56
|
+
bytes[2] === 0x4e &&
|
|
57
|
+
bytes[3] === 0x47 &&
|
|
58
|
+
bytes[4] === 0x0d &&
|
|
59
|
+
bytes[5] === 0x0a &&
|
|
60
|
+
bytes[6] === 0x1a &&
|
|
61
|
+
bytes[7] === 0x0a);
|
|
62
|
+
}
|
|
63
|
+
function isJpeg(bytes) {
|
|
64
|
+
return bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff;
|
|
65
|
+
}
|
|
66
|
+
function isHeif(bytes) {
|
|
67
|
+
if (bytes.length < 12)
|
|
68
|
+
return false;
|
|
69
|
+
if (bytes[4] !== 0x66 || bytes[5] !== 0x74 || bytes[6] !== 0x79 || bytes[7] !== 0x70) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const b8 = bytes[8];
|
|
73
|
+
const b9 = bytes[9];
|
|
74
|
+
const b10 = bytes[10];
|
|
75
|
+
const b11 = bytes[11];
|
|
76
|
+
if (b8 === undefined || b9 === undefined || b10 === undefined || b11 === undefined)
|
|
77
|
+
return false;
|
|
78
|
+
const brand = String.fromCharCode(b8, b9, b10, b11).toLowerCase();
|
|
79
|
+
return HEIF_BRANDS.has(brand);
|
|
80
|
+
}
|
|
81
|
+
function isAvif(bytes) {
|
|
82
|
+
if (bytes.length < 12)
|
|
83
|
+
return false;
|
|
84
|
+
if (bytes[4] !== 0x66 || bytes[5] !== 0x74 || bytes[6] !== 0x79 || bytes[7] !== 0x70) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const major = brandAt(bytes, 8);
|
|
88
|
+
if (major && AVIF_BRANDS.has(major))
|
|
89
|
+
return true;
|
|
90
|
+
const end = ftypBoxEnd(bytes);
|
|
91
|
+
for (let offset = 16; offset + 4 <= end; offset += 4) {
|
|
92
|
+
const compatible = brandAt(bytes, offset);
|
|
93
|
+
if (compatible && AVIF_BRANDS.has(compatible))
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
function brandAt(bytes, offset) {
|
|
99
|
+
const a = bytes[offset];
|
|
100
|
+
const b = bytes[offset + 1];
|
|
101
|
+
const c = bytes[offset + 2];
|
|
102
|
+
const d = bytes[offset + 3];
|
|
103
|
+
if (a === undefined || b === undefined || c === undefined || d === undefined)
|
|
104
|
+
return null;
|
|
105
|
+
return String.fromCharCode(a, b, c, d).toLowerCase();
|
|
106
|
+
}
|
|
107
|
+
function ftypBoxEnd(bytes) {
|
|
108
|
+
const s0 = bytes[0];
|
|
109
|
+
const s1 = bytes[1];
|
|
110
|
+
const s2 = bytes[2];
|
|
111
|
+
const s3 = bytes[3];
|
|
112
|
+
if (s0 === undefined || s1 === undefined || s2 === undefined || s3 === undefined) {
|
|
113
|
+
return bytes.length;
|
|
114
|
+
}
|
|
115
|
+
const declared = s0 * 0x1000000 + (s1 << 16) + (s2 << 8) + s3;
|
|
116
|
+
return declared > 8 && declared <= bytes.length ? declared : bytes.length;
|
|
117
|
+
}
|
|
118
|
+
function isWebp(bytes) {
|
|
119
|
+
return (bytes.length >= 12 &&
|
|
120
|
+
bytes[0] === 0x52 &&
|
|
121
|
+
bytes[1] === 0x49 &&
|
|
122
|
+
bytes[2] === 0x46 &&
|
|
123
|
+
bytes[3] === 0x46 &&
|
|
124
|
+
bytes[8] === 0x57 &&
|
|
125
|
+
bytes[9] === 0x45 &&
|
|
126
|
+
bytes[10] === 0x42 &&
|
|
127
|
+
bytes[11] === 0x50);
|
|
128
|
+
}
|
|
129
|
+
function isGif(bytes) {
|
|
130
|
+
if (bytes.length < 6)
|
|
131
|
+
return false;
|
|
132
|
+
if (bytes[0] !== 0x47 || bytes[1] !== 0x49 || bytes[2] !== 0x46)
|
|
133
|
+
return false;
|
|
134
|
+
if (bytes[3] !== 0x38 || bytes[5] !== 0x61)
|
|
135
|
+
return false;
|
|
136
|
+
return bytes[4] === 0x37 || bytes[4] === 0x39;
|
|
137
|
+
}
|
|
138
|
+
function isBmp(bytes) {
|
|
139
|
+
return bytes.length >= 2 && bytes[0] === 0x42 && bytes[1] === 0x4d;
|
|
140
|
+
}
|
|
141
|
+
function isTiff(bytes) {
|
|
142
|
+
if (bytes.length < 4)
|
|
143
|
+
return false;
|
|
144
|
+
if (bytes[0] === 0x49 && bytes[1] === 0x49)
|
|
145
|
+
return bytes[2] === 0x2a && bytes[3] === 0x00;
|
|
146
|
+
if (bytes[0] === 0x4d && bytes[1] === 0x4d)
|
|
147
|
+
return bytes[2] === 0x00 && bytes[3] === 0x2a;
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { QvacAutobeeHead } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
export interface MeshInviteNode {
|
|
3
|
+
readonly host: string;
|
|
4
|
+
readonly port: number;
|
|
5
|
+
}
|
|
6
|
+
export interface MeshInvite {
|
|
7
|
+
readonly baseKey: Buffer;
|
|
8
|
+
readonly seed: Buffer;
|
|
9
|
+
readonly fastForward: QvacAutobeeHead | null;
|
|
10
|
+
readonly additionalNodes?: ReadonlyArray<MeshInviteNode>;
|
|
11
|
+
readonly blindPeers?: ReadonlyArray<Buffer>;
|
|
12
|
+
}
|
|
13
|
+
export declare function encodeMeshInvite(invite: MeshInvite): string;
|
|
14
|
+
export declare function decodeMeshInvite(raw: string): MeshInvite | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as z32 from 'z32';
|
|
2
|
+
import { decode as decodeStruct, encode as encodeStruct } from '../../spec/mesh/hyperschema/index.js';
|
|
3
|
+
const INVITE_STRUCT = '@qvac/mesh-invite';
|
|
4
|
+
const INVITE_PREFIX = 'qvac://mesh/';
|
|
5
|
+
export function encodeMeshInvite(invite) {
|
|
6
|
+
const payload = {
|
|
7
|
+
meshKey: invite.baseKey,
|
|
8
|
+
seed: invite.seed,
|
|
9
|
+
fastForward: invite.fastForward,
|
|
10
|
+
additionalNodes: [...(invite.additionalNodes ?? [])],
|
|
11
|
+
blindPeers: [...(invite.blindPeers ?? [])]
|
|
12
|
+
};
|
|
13
|
+
return INVITE_PREFIX + z32.encode(encodeStruct(INVITE_STRUCT, payload));
|
|
14
|
+
}
|
|
15
|
+
export function decodeMeshInvite(raw) {
|
|
16
|
+
const value = raw.trim().toLowerCase();
|
|
17
|
+
if (!value.startsWith(INVITE_PREFIX))
|
|
18
|
+
return null;
|
|
19
|
+
let payload;
|
|
20
|
+
try {
|
|
21
|
+
payload = decodeStruct(INVITE_STRUCT, z32.decode(value.slice(INVITE_PREFIX.length)));
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
baseKey: payload.meshKey,
|
|
28
|
+
seed: payload.seed,
|
|
29
|
+
fastForward: payload.fastForward ? payload.fastForward : null,
|
|
30
|
+
additionalNodes: (payload.additionalNodes ?? []).map((node) => ({
|
|
31
|
+
host: node.host,
|
|
32
|
+
port: node.port
|
|
33
|
+
})),
|
|
34
|
+
blindPeers: payload.blindPeers ?? []
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import CorestoreStorage from 'hypercore-storage';
|
|
2
|
+
import HyperDB from 'hyperdb';
|
|
3
|
+
import type { LocalAppConfig, LocalCapabilityProfile, LocalChatNotify, LocalCustomModel, LocalIdentity, LocalMembership, LocalMeshDeparture, LocalModelDownload, LocalModelNotify } from '../../../spec/local/hyperschema/types.d.ts';
|
|
4
|
+
import type { DeviceMetadata } from '../mesh.ts';
|
|
5
|
+
export interface ResolvedSession {
|
|
6
|
+
readonly seed: Buffer;
|
|
7
|
+
readonly baseKey: Buffer | undefined;
|
|
8
|
+
readonly writerSeed: string | undefined;
|
|
9
|
+
readonly creator: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function openLocalStore(storage: CorestoreStorage): LocalStore;
|
|
12
|
+
declare class LocalStore {
|
|
13
|
+
private readonly _db;
|
|
14
|
+
private readonly _writeLock;
|
|
15
|
+
constructor(db: HyperDB);
|
|
16
|
+
private _locked;
|
|
17
|
+
get(key: string): Promise<unknown>;
|
|
18
|
+
set(key: string, value: unknown): Promise<void>;
|
|
19
|
+
setAll(entries: ReadonlyArray<{
|
|
20
|
+
readonly key: string;
|
|
21
|
+
readonly value: unknown;
|
|
22
|
+
}>): Promise<void>;
|
|
23
|
+
deleteAll(keys: ReadonlyArray<string>): Promise<void>;
|
|
24
|
+
getAppConfigRow(): Promise<LocalAppConfig | null>;
|
|
25
|
+
updateAppConfigRow(mutate: (current: LocalAppConfig | null) => Omit<LocalAppConfig, 'id'>): Promise<LocalAppConfig>;
|
|
26
|
+
getChatNotify(chatId: string): Promise<LocalChatNotify | null>;
|
|
27
|
+
ackChatNotify(chatId: string, seq: number): Promise<void>;
|
|
28
|
+
clearChatNotify(chatId: string): Promise<void>;
|
|
29
|
+
beginModelTransfer(name: string, { transferred }?: {
|
|
30
|
+
transferred?: boolean;
|
|
31
|
+
}): Promise<LocalModelNotify>;
|
|
32
|
+
completeModelTransfer({ name, transferId, downloaded }: {
|
|
33
|
+
name: string;
|
|
34
|
+
transferId: string;
|
|
35
|
+
downloaded?: boolean;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
getModelNotifications(): Promise<LocalModelNotify[]>;
|
|
38
|
+
ackModelNotification(notificationId: string): Promise<void>;
|
|
39
|
+
getModelDownloadRows(): Promise<LocalModelDownload[]>;
|
|
40
|
+
putModelDownloadRow(row: LocalModelDownload): Promise<void>;
|
|
41
|
+
deleteModelDownloadRow(name: string): Promise<void>;
|
|
42
|
+
getCustomModelRows(): Promise<LocalCustomModel[]>;
|
|
43
|
+
putCustomModelRow(row: LocalCustomModel): Promise<void>;
|
|
44
|
+
deleteCustomModelRow(name: string): Promise<void>;
|
|
45
|
+
ensureDevice(publicKey: Buffer, seed?: DeviceMetadata): Promise<DeviceMetadata | null>;
|
|
46
|
+
renameDevice(publicKey: Buffer, name: string): Promise<void>;
|
|
47
|
+
saveDeviceProfile(publicKey: Buffer, capabilityProfile: LocalCapabilityProfile, recommendedModelName: string, platform?: string): Promise<void>;
|
|
48
|
+
readIdentity(): Promise<LocalIdentity | null>;
|
|
49
|
+
readMembership(): Promise<LocalMembership | null>;
|
|
50
|
+
recordMembership(link: Omit<LocalMembership, 'id'>): Promise<void>;
|
|
51
|
+
ensureIdentity(devicePublicKey: Buffer, createdAt: number): Promise<{
|
|
52
|
+
identity: LocalIdentity;
|
|
53
|
+
mnemonic: string | null;
|
|
54
|
+
}>;
|
|
55
|
+
resolveSession(deviceId: Buffer, opts?: {
|
|
56
|
+
seed?: Buffer;
|
|
57
|
+
baseKey?: Buffer;
|
|
58
|
+
new?: boolean;
|
|
59
|
+
writerSeed?: string;
|
|
60
|
+
creator?: boolean;
|
|
61
|
+
}): Promise<ResolvedSession>;
|
|
62
|
+
createCandidateSession(seed: Buffer, baseKey: Buffer): ResolvedSession;
|
|
63
|
+
recordMesh(deviceId: Buffer, key: Buffer, seed: Buffer, creator: boolean, writerSeed: string | undefined): Promise<void>;
|
|
64
|
+
recordDeparture(key: Buffer): Promise<void>;
|
|
65
|
+
departures(): Promise<LocalMeshDeparture[]>;
|
|
66
|
+
deleteDeparture(key: Buffer): Promise<void>;
|
|
67
|
+
watch(listener: () => void): void;
|
|
68
|
+
unwatch(listener: () => void): void;
|
|
69
|
+
close(): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import CorestoreStorage from 'hypercore-storage';
|
|
2
|
+
import HyperDB from 'hyperdb';
|
|
3
|
+
import crypto from 'hypercore-crypto';
|
|
4
|
+
import ScopeLock from 'scope-lock';
|
|
5
|
+
import { generateMnemonic, mintIdentity } from "../identity.js";
|
|
6
|
+
import LocalDatabaseSpec from '../../../spec/local/hyperdb/index.js';
|
|
7
|
+
const CONFIG = '@local/config';
|
|
8
|
+
const MESH_SESSION = '@local/mesh-session';
|
|
9
|
+
const MESH_HISTORY = '@local/mesh-history';
|
|
10
|
+
const MESH_DEPARTURE = '@local/mesh-departure';
|
|
11
|
+
const DEVICE = '@local/device';
|
|
12
|
+
const APP_CONFIG = '@local/app-config';
|
|
13
|
+
const MODEL_DOWNLOAD = '@local/model-download';
|
|
14
|
+
const CUSTOM_MODEL = '@local/custom-model';
|
|
15
|
+
const IDENTITY = '@local/identity';
|
|
16
|
+
const IDENTITY_ID = 'identity';
|
|
17
|
+
const MEMBERSHIP = '@local/membership';
|
|
18
|
+
const MEMBERSHIP_ID = 'membership';
|
|
19
|
+
const CHAT_NOTIFY = '@local/chat-notify';
|
|
20
|
+
const MODEL_NOTIFY = '@local/model-notify';
|
|
21
|
+
const APP_CONFIG_ID = 'default';
|
|
22
|
+
function freshWriterSeed() {
|
|
23
|
+
return `local-${crypto.randomBytes(8).toString('hex')}`;
|
|
24
|
+
}
|
|
25
|
+
export function openLocalStore(storage) {
|
|
26
|
+
const db = HyperDB.rocks(storage.rocks.columnFamily('assistant/local'), LocalDatabaseSpec);
|
|
27
|
+
return new LocalStore(db);
|
|
28
|
+
}
|
|
29
|
+
class LocalStore {
|
|
30
|
+
_db;
|
|
31
|
+
_writeLock = new ScopeLock();
|
|
32
|
+
constructor(db) {
|
|
33
|
+
this._db = db;
|
|
34
|
+
}
|
|
35
|
+
async _locked(fn) {
|
|
36
|
+
await this._writeLock.lock();
|
|
37
|
+
try {
|
|
38
|
+
return await fn();
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
this._writeLock.unlock();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async get(key) {
|
|
45
|
+
const row = await this._db.get(CONFIG, { key });
|
|
46
|
+
return row ? row.value : null;
|
|
47
|
+
}
|
|
48
|
+
set(key, value) {
|
|
49
|
+
return this._locked(async () => {
|
|
50
|
+
const tx = this._db.transaction();
|
|
51
|
+
await tx.insert(CONFIG, { key, value });
|
|
52
|
+
await tx.flush();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
setAll(entries) {
|
|
56
|
+
return this._locked(async () => {
|
|
57
|
+
const tx = this._db.transaction();
|
|
58
|
+
for (const { key, value } of entries)
|
|
59
|
+
await tx.insert(CONFIG, { key, value });
|
|
60
|
+
await tx.flush();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
deleteAll(keys) {
|
|
64
|
+
return this._locked(async () => {
|
|
65
|
+
const tx = this._db.transaction();
|
|
66
|
+
for (const key of keys)
|
|
67
|
+
await tx.delete(CONFIG, { key });
|
|
68
|
+
await tx.flush();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
getAppConfigRow() {
|
|
72
|
+
return this._db.get(APP_CONFIG, { id: APP_CONFIG_ID });
|
|
73
|
+
}
|
|
74
|
+
updateAppConfigRow(mutate) {
|
|
75
|
+
return this._locked(async () => {
|
|
76
|
+
const tx = this._db.transaction();
|
|
77
|
+
const current = await tx.get(APP_CONFIG, { id: APP_CONFIG_ID });
|
|
78
|
+
const next = { id: APP_CONFIG_ID, ...mutate(current) };
|
|
79
|
+
await tx.insert(APP_CONFIG, next);
|
|
80
|
+
await tx.flush();
|
|
81
|
+
return next;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
getChatNotify(chatId) {
|
|
85
|
+
return this._locked(() => this._db.get(CHAT_NOTIFY, { chatId }));
|
|
86
|
+
}
|
|
87
|
+
ackChatNotify(chatId, seq) {
|
|
88
|
+
return this._locked(async () => {
|
|
89
|
+
const tx = this._db.transaction();
|
|
90
|
+
const current = await tx.get(CHAT_NOTIFY, { chatId });
|
|
91
|
+
const ackedThrough = Math.max(current?.ackedThrough ?? 0, seq + 1);
|
|
92
|
+
await tx.insert(CHAT_NOTIFY, { chatId, ackedThrough });
|
|
93
|
+
await tx.flush();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
clearChatNotify(chatId) {
|
|
97
|
+
return this._locked(async () => {
|
|
98
|
+
const tx = this._db.transaction();
|
|
99
|
+
await tx.delete(CHAT_NOTIFY, { chatId });
|
|
100
|
+
await tx.flush();
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
beginModelTransfer(name, { transferred = false } = {}) {
|
|
104
|
+
return this._locked(async () => {
|
|
105
|
+
const current = await this._db.get(MODEL_NOTIFY, { name });
|
|
106
|
+
const pending = current && current.transferId !== current.notificationId;
|
|
107
|
+
if (pending && (!transferred || current.transferred))
|
|
108
|
+
return current;
|
|
109
|
+
const next = {
|
|
110
|
+
name,
|
|
111
|
+
transferId: pending ? current.transferId : crypto.randomBytes(16).toString('hex'),
|
|
112
|
+
notificationId: current?.notificationId,
|
|
113
|
+
completedAt: current?.completedAt,
|
|
114
|
+
acknowledged: current?.acknowledged,
|
|
115
|
+
transferred
|
|
116
|
+
};
|
|
117
|
+
const tx = this._db.transaction();
|
|
118
|
+
await tx.insert(MODEL_NOTIFY, next);
|
|
119
|
+
await tx.flush();
|
|
120
|
+
return next;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
completeModelTransfer({ name, transferId, downloaded = true }) {
|
|
124
|
+
return this._locked(async () => {
|
|
125
|
+
const current = await this._db.get(MODEL_NOTIFY, { name });
|
|
126
|
+
if (!current || current.transferId !== transferId || current.notificationId === transferId) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (!downloaded && !current.transferred)
|
|
130
|
+
return;
|
|
131
|
+
const tx = this._db.transaction();
|
|
132
|
+
await tx.insert(MODEL_NOTIFY, {
|
|
133
|
+
name,
|
|
134
|
+
transferId,
|
|
135
|
+
notificationId: transferId,
|
|
136
|
+
completedAt: Date.now(),
|
|
137
|
+
acknowledged: false,
|
|
138
|
+
transferred: true
|
|
139
|
+
});
|
|
140
|
+
await tx.flush();
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
getModelNotifications() {
|
|
144
|
+
return this._locked(() => this._db.find(MODEL_NOTIFY).toArray());
|
|
145
|
+
}
|
|
146
|
+
ackModelNotification(notificationId) {
|
|
147
|
+
return this._locked(async () => {
|
|
148
|
+
const rows = await this._db.find(MODEL_NOTIFY).toArray();
|
|
149
|
+
const current = rows.find((row) => row.notificationId === notificationId);
|
|
150
|
+
if (!current || current.acknowledged)
|
|
151
|
+
return;
|
|
152
|
+
const tx = this._db.transaction();
|
|
153
|
+
await tx.insert(MODEL_NOTIFY, {
|
|
154
|
+
name: current.name,
|
|
155
|
+
transferId: current.transferId,
|
|
156
|
+
notificationId: current.notificationId,
|
|
157
|
+
completedAt: current.completedAt,
|
|
158
|
+
transferred: current.transferred,
|
|
159
|
+
acknowledged: true
|
|
160
|
+
});
|
|
161
|
+
await tx.flush();
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
async getModelDownloadRows() {
|
|
165
|
+
const rows = [];
|
|
166
|
+
for await (const row of this._db.find(MODEL_DOWNLOAD))
|
|
167
|
+
rows.push(row);
|
|
168
|
+
return rows;
|
|
169
|
+
}
|
|
170
|
+
putModelDownloadRow(row) {
|
|
171
|
+
return this._locked(async () => {
|
|
172
|
+
const tx = this._db.transaction();
|
|
173
|
+
await tx.insert(MODEL_DOWNLOAD, row);
|
|
174
|
+
await tx.flush();
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
deleteModelDownloadRow(name) {
|
|
178
|
+
return this._locked(async () => {
|
|
179
|
+
const tx = this._db.transaction();
|
|
180
|
+
await tx.delete(MODEL_DOWNLOAD, { name });
|
|
181
|
+
await tx.flush();
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
async getCustomModelRows() {
|
|
185
|
+
const rows = [];
|
|
186
|
+
for await (const row of this._db.find(CUSTOM_MODEL))
|
|
187
|
+
rows.push(row);
|
|
188
|
+
return rows;
|
|
189
|
+
}
|
|
190
|
+
putCustomModelRow(row) {
|
|
191
|
+
return this._locked(async () => {
|
|
192
|
+
const tx = this._db.transaction();
|
|
193
|
+
await tx.insert(CUSTOM_MODEL, row);
|
|
194
|
+
await tx.flush();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
deleteCustomModelRow(name) {
|
|
198
|
+
return this._locked(async () => {
|
|
199
|
+
const tx = this._db.transaction();
|
|
200
|
+
await tx.delete(CUSTOM_MODEL, { name });
|
|
201
|
+
await tx.flush();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
ensureDevice(publicKey, seed) {
|
|
205
|
+
return this._locked(async () => {
|
|
206
|
+
const existing = await this._db.get(DEVICE, { publicKey });
|
|
207
|
+
if (existing) {
|
|
208
|
+
return {
|
|
209
|
+
name: existing.name,
|
|
210
|
+
capabilityProfile: existing.capabilityProfile,
|
|
211
|
+
recommendedModelName: existing.recommendedModelName,
|
|
212
|
+
platform: existing.platform ?? undefined
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
if (!seed)
|
|
216
|
+
return null;
|
|
217
|
+
const tx = this._db.transaction();
|
|
218
|
+
await tx.insert(DEVICE, { publicKey, ...seed });
|
|
219
|
+
await tx.flush();
|
|
220
|
+
return seed;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
renameDevice(publicKey, name) {
|
|
224
|
+
return this._locked(async () => {
|
|
225
|
+
const existing = await this._db.get(DEVICE, { publicKey });
|
|
226
|
+
if (!existing)
|
|
227
|
+
return;
|
|
228
|
+
const tx = this._db.transaction();
|
|
229
|
+
await tx.insert(DEVICE, { ...existing, name });
|
|
230
|
+
await tx.flush();
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
saveDeviceProfile(publicKey, capabilityProfile, recommendedModelName, platform) {
|
|
234
|
+
return this._locked(async () => {
|
|
235
|
+
const existing = await this._db.get(DEVICE, { publicKey });
|
|
236
|
+
if (!existing)
|
|
237
|
+
return;
|
|
238
|
+
const tx = this._db.transaction();
|
|
239
|
+
await tx.insert(DEVICE, {
|
|
240
|
+
...existing,
|
|
241
|
+
capabilityProfile,
|
|
242
|
+
recommendedModelName,
|
|
243
|
+
platform: platform ?? existing.platform
|
|
244
|
+
});
|
|
245
|
+
await tx.flush();
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
readIdentity() {
|
|
249
|
+
return this._db.get(IDENTITY, { id: IDENTITY_ID });
|
|
250
|
+
}
|
|
251
|
+
readMembership() {
|
|
252
|
+
return this._db.get(MEMBERSHIP, { id: MEMBERSHIP_ID });
|
|
253
|
+
}
|
|
254
|
+
recordMembership(link) {
|
|
255
|
+
return this._locked(async () => {
|
|
256
|
+
const existing = await this._db.get(MEMBERSHIP, { id: MEMBERSHIP_ID });
|
|
257
|
+
if (existing && existing.attestedAt >= link.attestedAt)
|
|
258
|
+
return;
|
|
259
|
+
const tx = this._db.transaction();
|
|
260
|
+
await tx.insert(MEMBERSHIP, { id: MEMBERSHIP_ID, ...link });
|
|
261
|
+
await tx.flush();
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
ensureIdentity(devicePublicKey, createdAt) {
|
|
265
|
+
return this._locked(async () => {
|
|
266
|
+
const existing = await this._db.get(IDENTITY, { id: IDENTITY_ID });
|
|
267
|
+
if (existing)
|
|
268
|
+
return { identity: existing, mnemonic: null };
|
|
269
|
+
const mnemonic = await generateMnemonic();
|
|
270
|
+
const minted = await mintIdentity(mnemonic, devicePublicKey);
|
|
271
|
+
const identity = {
|
|
272
|
+
id: IDENTITY_ID,
|
|
273
|
+
publicKey: minted.publicKey,
|
|
274
|
+
proof: minted.proof,
|
|
275
|
+
createdAt
|
|
276
|
+
};
|
|
277
|
+
const tx = this._db.transaction();
|
|
278
|
+
await tx.insert(IDENTITY, identity);
|
|
279
|
+
await tx.flush();
|
|
280
|
+
return { identity, mnemonic };
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
resolveSession(deviceId, opts = {}) {
|
|
284
|
+
return this._locked(async () => {
|
|
285
|
+
const tx = this._db.transaction();
|
|
286
|
+
const session = await tx.get(MESH_SESSION, { deviceId });
|
|
287
|
+
const sameSeed = Boolean(opts.seed && session?.meshSeed?.equals(opts.seed));
|
|
288
|
+
if (opts.seed && !sameSeed) {
|
|
289
|
+
await tx.insert(MESH_SESSION, {
|
|
290
|
+
deviceId,
|
|
291
|
+
meshSeed: opts.seed,
|
|
292
|
+
meshKey: opts.baseKey ?? null,
|
|
293
|
+
meshCreator: opts.creator ?? false
|
|
294
|
+
});
|
|
295
|
+
await tx.flush();
|
|
296
|
+
return {
|
|
297
|
+
seed: opts.seed,
|
|
298
|
+
baseKey: opts.baseKey,
|
|
299
|
+
writerSeed: opts.writerSeed ?? freshWriterSeed(),
|
|
300
|
+
creator: opts.creator ?? false
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
if (session?.meshSeed && !opts.new) {
|
|
304
|
+
const baseKey = !session.meshCreator && session.meshKey ? session.meshKey : undefined;
|
|
305
|
+
const history = await tx.findOne(MESH_HISTORY);
|
|
306
|
+
await tx.close();
|
|
307
|
+
return {
|
|
308
|
+
seed: session.meshSeed,
|
|
309
|
+
baseKey,
|
|
310
|
+
writerSeed: history?.writerSeed ?? undefined,
|
|
311
|
+
creator: session.meshCreator ?? false
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
const seed = crypto.randomBytes(32);
|
|
315
|
+
await tx.insert(MESH_SESSION, {
|
|
316
|
+
deviceId,
|
|
317
|
+
meshSeed: seed,
|
|
318
|
+
meshKey: null,
|
|
319
|
+
meshCreator: true
|
|
320
|
+
});
|
|
321
|
+
await tx.flush();
|
|
322
|
+
return { seed, baseKey: undefined, writerSeed: undefined, creator: true };
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
createCandidateSession(seed, baseKey) {
|
|
326
|
+
return {
|
|
327
|
+
seed,
|
|
328
|
+
baseKey,
|
|
329
|
+
writerSeed: freshWriterSeed(),
|
|
330
|
+
creator: false
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
recordMesh(deviceId, key, seed, creator, writerSeed) {
|
|
334
|
+
return this._locked(async () => {
|
|
335
|
+
const tx = this._db.transaction();
|
|
336
|
+
const current = await tx.findOne(MESH_HISTORY);
|
|
337
|
+
if (current && !current.key.equals(key)) {
|
|
338
|
+
await tx.delete(MESH_HISTORY, { key: current.key });
|
|
339
|
+
}
|
|
340
|
+
await tx.insert(MESH_HISTORY, { key, seed, creator, writerSeed });
|
|
341
|
+
const session = await tx.get(MESH_SESSION, { deviceId });
|
|
342
|
+
await tx.insert(MESH_SESSION, {
|
|
343
|
+
...session,
|
|
344
|
+
deviceId,
|
|
345
|
+
meshSeed: seed,
|
|
346
|
+
meshKey: key,
|
|
347
|
+
meshCreator: creator
|
|
348
|
+
});
|
|
349
|
+
await tx.flush();
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
recordDeparture(key) {
|
|
353
|
+
return this._locked(async () => {
|
|
354
|
+
const tx = this._db.transaction();
|
|
355
|
+
const history = await tx.get(MESH_HISTORY, { key });
|
|
356
|
+
if (!history) {
|
|
357
|
+
await tx.close();
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
await tx.insert(MESH_DEPARTURE, {
|
|
361
|
+
key: history.key,
|
|
362
|
+
seed: history.seed,
|
|
363
|
+
creator: history.creator,
|
|
364
|
+
writerSeed: history.writerSeed
|
|
365
|
+
});
|
|
366
|
+
await tx.flush();
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
async departures() {
|
|
370
|
+
const rows = [];
|
|
371
|
+
for await (const row of this._db.find(MESH_DEPARTURE))
|
|
372
|
+
rows.push(row);
|
|
373
|
+
return rows;
|
|
374
|
+
}
|
|
375
|
+
deleteDeparture(key) {
|
|
376
|
+
return this._locked(async () => {
|
|
377
|
+
const tx = this._db.transaction();
|
|
378
|
+
await tx.delete(MESH_DEPARTURE, { key });
|
|
379
|
+
await tx.flush();
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
watch(listener) {
|
|
383
|
+
this._db.watch(listener);
|
|
384
|
+
}
|
|
385
|
+
unwatch(listener) {
|
|
386
|
+
this._db.unwatch(listener);
|
|
387
|
+
}
|
|
388
|
+
async close() {
|
|
389
|
+
await this._locked(() => this._db.close());
|
|
390
|
+
}
|
|
391
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { KeyPair } from 'hyperswarm';
|
|
2
|
+
import type { Logger } from '../../index.ts';
|
|
3
|
+
import type { QvacDevice } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
4
|
+
import type { Mesh } from './mesh.ts';
|
|
5
|
+
export interface MembershipView {
|
|
6
|
+
readonly members: number;
|
|
7
|
+
readonly own: QvacDevice | null;
|
|
8
|
+
readonly unattested: ReadonlyArray<Buffer>;
|
|
9
|
+
}
|
|
10
|
+
export interface MembershipContext {
|
|
11
|
+
readonly deviceKeyPair: KeyPair;
|
|
12
|
+
readonly log: Logger | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function membershipView(mesh: Mesh, deviceId: Buffer): Promise<MembershipView>;
|
|
15
|
+
export declare function attestUnattestedDevices(mesh: Mesh, { deviceKeyPair, log }: MembershipContext): Promise<void>;
|