@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,6 @@
|
|
|
1
|
+
import { type HealthAssistantHost } from '../health-assistant.ts';
|
|
2
|
+
import type { Mesh } from '../mesh.ts';
|
|
3
|
+
export interface AgentCatalogMigrationContext {
|
|
4
|
+
readonly device: HealthAssistantHost;
|
|
5
|
+
}
|
|
6
|
+
export declare function migrateAgentCatalog(mesh: Mesh, { device }: AgentCatalogMigrationContext): Promise<boolean>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { buildHealthAssistant, HEALTH_ASSISTANT_ID } from "../health-assistant.js";
|
|
2
|
+
const AGENTS = '@qvac/agents';
|
|
3
|
+
const MIGRATION_BASELINE_AT = 0;
|
|
4
|
+
export async function migrateAgentCatalog(mesh, { device }) {
|
|
5
|
+
const snap = mesh.view.snapshot();
|
|
6
|
+
try {
|
|
7
|
+
if (await snap.get(AGENTS, { id: HEALTH_ASSISTANT_ID }))
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
finally {
|
|
11
|
+
await snap.close();
|
|
12
|
+
}
|
|
13
|
+
await mesh.dispatch('migrate-agent-catalog', {
|
|
14
|
+
agent: buildHealthAssistant(device, { at: MIGRATION_BASELINE_AT })
|
|
15
|
+
});
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Mesh } from '../mesh.ts';
|
|
2
|
+
import { type AgentCatalogMigrationContext } from './agent-catalog.ts';
|
|
3
|
+
import { type MembershipMigrationContext } from './membership.ts';
|
|
4
|
+
export type MigrationContext = MembershipMigrationContext & AgentCatalogMigrationContext;
|
|
5
|
+
export declare function runMigrations(mesh: Mesh, context: MigrationContext): Promise<boolean>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { migrateAgentCatalog } from "./agent-catalog.js";
|
|
2
|
+
import { migrateMembership } from "./membership.js";
|
|
3
|
+
export async function runMigrations(mesh, context) {
|
|
4
|
+
const membership = await migrateMembership(mesh, context);
|
|
5
|
+
const agents = await migrateAgentCatalog(mesh, context);
|
|
6
|
+
return membership || agents;
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type MembershipContext } from '../membership.ts';
|
|
2
|
+
import type { Mesh } from '../mesh.ts';
|
|
3
|
+
export interface MintedRoot {
|
|
4
|
+
readonly publicKey: Buffer;
|
|
5
|
+
readonly proof: Buffer;
|
|
6
|
+
}
|
|
7
|
+
export interface MembershipMigrationContext extends MembershipContext {
|
|
8
|
+
readonly deviceName: string;
|
|
9
|
+
readonly mintRoot: (deviceId: Buffer, at: number) => Promise<MintedRoot>;
|
|
10
|
+
}
|
|
11
|
+
export declare function migrateMembership(mesh: Mesh, { deviceKeyPair, deviceName, mintRoot, log }: MembershipMigrationContext): Promise<boolean>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { attestDeviceProof } from "../identity.js";
|
|
2
|
+
import { membershipView } from "../membership.js";
|
|
3
|
+
export async function migrateMembership(mesh, { deviceKeyPair, deviceName, mintRoot, log }) {
|
|
4
|
+
const { members, own, unattested } = await membershipView(mesh, deviceKeyPair.publicKey);
|
|
5
|
+
if (members > 0 || !own || own.memberId)
|
|
6
|
+
return false;
|
|
7
|
+
const now = Date.now();
|
|
8
|
+
const root = await mintRoot(own.id, now);
|
|
9
|
+
const batch = mesh.batch();
|
|
10
|
+
batch.dispatch('mint-member', {
|
|
11
|
+
member: { id: root.publicKey, name: deviceName, joinedAt: now, updatedAt: now },
|
|
12
|
+
proof: root.proof
|
|
13
|
+
});
|
|
14
|
+
for (const id of unattested) {
|
|
15
|
+
batch.dispatch('attest-member-device', {
|
|
16
|
+
deviceId: id,
|
|
17
|
+
memberId: root.publicKey,
|
|
18
|
+
proof: await attestDeviceProof(id, deviceKeyPair, root.proof),
|
|
19
|
+
attestedAt: now
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
await batch.flush();
|
|
23
|
+
await mesh.refreshOurMember();
|
|
24
|
+
log?.info(['p2p', 'mesh'], 'migrated: minted the member this mesh predates, every device we hold is attested to our member', { attested: unattested.length });
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface VersionFloor {
|
|
2
|
+
readonly range: string | null | undefined;
|
|
3
|
+
readonly appVersion: string | null | undefined;
|
|
4
|
+
}
|
|
5
|
+
export declare function releaseVersion(version: string): string;
|
|
6
|
+
export declare function updateRequired({ range, appVersion }: VersionFloor): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Range, Version, satisfies } from 'bare-semver';
|
|
2
|
+
export function releaseVersion(version) {
|
|
3
|
+
const match = version
|
|
4
|
+
.trim()
|
|
5
|
+
.replace(/^[vV]/, '')
|
|
6
|
+
.match(/^\d+\.\d+\.\d+/);
|
|
7
|
+
if (!match)
|
|
8
|
+
throw new Error(`unparseable version: ${version}`);
|
|
9
|
+
return match[0];
|
|
10
|
+
}
|
|
11
|
+
export function updateRequired({ range, appVersion }) {
|
|
12
|
+
if (!range || !appVersion)
|
|
13
|
+
return false;
|
|
14
|
+
const floor = parseRange(range);
|
|
15
|
+
if (!floor)
|
|
16
|
+
return false;
|
|
17
|
+
try {
|
|
18
|
+
return !satisfies(Version.parse(releaseVersion(appVersion)), floor);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function parseRange(range) {
|
|
25
|
+
try {
|
|
26
|
+
return Range.parse(range);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
|
+
export declare const UPLOAD_INACTIVITY_MS = 30000;
|
|
3
|
+
export declare function nextFrame<T>(iterator: AsyncIterator<T>, { signal, inactivityMs }?: {
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
inactivityMs?: number;
|
|
6
|
+
}): Promise<IteratorResult<T>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AbortedError } from '@qvac/harness/race-abort';
|
|
2
|
+
import { unref } from "../unref.js";
|
|
3
|
+
export const UPLOAD_INACTIVITY_MS = 30_000;
|
|
4
|
+
export function nextFrame(iterator, { signal, inactivityMs = UPLOAD_INACTIVITY_MS } = {}) {
|
|
5
|
+
if (signal?.aborted)
|
|
6
|
+
return Promise.reject(new AbortedError());
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const timer = setTimeout(() => finish(new Error('upload source timed out')), inactivityMs);
|
|
9
|
+
unref(timer);
|
|
10
|
+
const abort = () => finish(new AbortedError());
|
|
11
|
+
const finish = (error, result) => {
|
|
12
|
+
clearTimeout(timer);
|
|
13
|
+
signal?.removeEventListener('abort', abort);
|
|
14
|
+
if (error)
|
|
15
|
+
reject(error);
|
|
16
|
+
else if (result)
|
|
17
|
+
resolve(result);
|
|
18
|
+
};
|
|
19
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
20
|
+
try {
|
|
21
|
+
iterator.next().then((result) => finish(undefined, result), finish);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
finish(error);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AssistantNotificationList } from '../../spec/hyperschema/types.d.ts';
|
|
2
|
+
import type { openLocalStore } from './local/index.ts';
|
|
3
|
+
import type { Mesh } from './mesh.ts';
|
|
4
|
+
type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
|
|
5
|
+
export declare function deriveNotifications(mesh: Mesh, local: LocalStore, requestedLimit?: number, deviceId?: Buffer | null): Promise<AssistantNotificationList>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { diagramRepairLinks, isDiagramRepairPrompt } from '@qvac/harness/lib/diagram-repair.ts';
|
|
2
|
+
import { findChunksOfType } from "./chunk.js";
|
|
3
|
+
const ACTIVE_CHATS = '@qvac/active-chats';
|
|
4
|
+
const AGENTS = '@qvac/agents';
|
|
5
|
+
const CHUNK_COUNTERS = '@qvac/chunk-counters';
|
|
6
|
+
const DEFAULT_LIMIT = 200;
|
|
7
|
+
const PREVIEW_LIMIT = 280;
|
|
8
|
+
export async function deriveNotifications(mesh, local, requestedLimit, deviceId) {
|
|
9
|
+
const limit = requestedLimit || DEFAULT_LIMIT;
|
|
10
|
+
const snap = mesh.view.snapshot();
|
|
11
|
+
try {
|
|
12
|
+
const chats = await snap.find(ACTIVE_CHATS).toArray();
|
|
13
|
+
const candidates = [];
|
|
14
|
+
const own = deviceId ? await snap.get('@qvac/devices', { id: deviceId }) : null;
|
|
15
|
+
for (const chat of chats) {
|
|
16
|
+
const counter = await snap.get(CHUNK_COUNTERS, { chatId: chat.id });
|
|
17
|
+
const ackedThrough = (await local.getChatNotify(chat.id))?.ackedThrough ?? 0;
|
|
18
|
+
const [statuses, approvals, messages] = await Promise.all([
|
|
19
|
+
(counter?.count ?? 0) <= ackedThrough
|
|
20
|
+
? []
|
|
21
|
+
: findChunksOfType(snap, chat.id, 'run-status', { fromSeq: ackedThrough }),
|
|
22
|
+
findChunksOfType(snap, chat.id, 'approval-request'),
|
|
23
|
+
(counter?.count ?? 0) <= ackedThrough
|
|
24
|
+
? []
|
|
25
|
+
: findChunksOfType(snap, chat.id, 'user-message', { fromSeq: ackedThrough })
|
|
26
|
+
]);
|
|
27
|
+
const terminalStatuses = statuses.filter((chunk) => {
|
|
28
|
+
const state = chunk.runStatus?.state;
|
|
29
|
+
return state === 'completed' || state === 'failed';
|
|
30
|
+
});
|
|
31
|
+
for (const chunk of messages) {
|
|
32
|
+
if (deviceId?.equals(chunk.originDeviceId))
|
|
33
|
+
continue;
|
|
34
|
+
const text = chunk.userMessage?.text ?? '';
|
|
35
|
+
if (isDiagramRepairPrompt(text))
|
|
36
|
+
continue;
|
|
37
|
+
const sender = await snap.get('@qvac/devices', { id: chunk.originDeviceId });
|
|
38
|
+
if (own?.memberId && sender?.memberId?.equals(own.memberId))
|
|
39
|
+
continue;
|
|
40
|
+
const member = sender?.memberId
|
|
41
|
+
? await snap.get('@qvac/members', { id: sender.memberId })
|
|
42
|
+
: null;
|
|
43
|
+
candidates.push({
|
|
44
|
+
chatId: chat.id,
|
|
45
|
+
agentId: chat.agentId,
|
|
46
|
+
chunkId: chunk.id,
|
|
47
|
+
kind: 'user-message',
|
|
48
|
+
seq: chunk.seq,
|
|
49
|
+
createdAt: chunk.createdAt,
|
|
50
|
+
senderDeviceId: chunk.originDeviceId,
|
|
51
|
+
senderMemberId: sender?.memberId,
|
|
52
|
+
senderName: member?.name ?? sender?.name,
|
|
53
|
+
chatTitle: chat.title,
|
|
54
|
+
preview: Array.from(text).slice(0, PREVIEW_LIMIT).join('') || undefined
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
for (const chunk of terminalStatuses) {
|
|
58
|
+
candidates.push({
|
|
59
|
+
chatId: chat.id,
|
|
60
|
+
agentId: chat.agentId,
|
|
61
|
+
chunkId: chunk.id,
|
|
62
|
+
kind: chunk.runStatus?.state === 'completed' ? 'assistant-reply' : 'run-failed',
|
|
63
|
+
seq: chunk.seq,
|
|
64
|
+
createdAt: chunk.createdAt,
|
|
65
|
+
runId: chunk.runId ?? undefined
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
for (const chunk of approvals) {
|
|
69
|
+
if (chunk.approvalRequest?.status !== 'pending')
|
|
70
|
+
continue;
|
|
71
|
+
candidates.push({
|
|
72
|
+
chatId: chat.id,
|
|
73
|
+
agentId: chat.agentId,
|
|
74
|
+
chunkId: chunk.id,
|
|
75
|
+
kind: 'approval-required',
|
|
76
|
+
seq: chunk.seq,
|
|
77
|
+
createdAt: chunk.createdAt,
|
|
78
|
+
runId: chunk.runId ?? undefined
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
candidates.sort((left, right) => right.createdAt - left.createdAt || right.seq - left.seq);
|
|
83
|
+
const maxSeqByChat = new Map();
|
|
84
|
+
for (const candidate of candidates) {
|
|
85
|
+
maxSeqByChat.set(candidate.chatId, Math.max(maxSeqByChat.get(candidate.chatId) ?? 0, candidate.seq));
|
|
86
|
+
}
|
|
87
|
+
const repairRunIdsByChat = new Map();
|
|
88
|
+
const selected = [];
|
|
89
|
+
let truncated = false;
|
|
90
|
+
for (const candidate of candidates) {
|
|
91
|
+
let repairRunIds = repairRunIdsByChat.get(candidate.chatId);
|
|
92
|
+
if (!repairRunIds) {
|
|
93
|
+
const maxSeq = maxSeqByChat.get(candidate.chatId);
|
|
94
|
+
repairRunIds = await diagramRepairRunIds(snap, candidate.chatId, maxSeq);
|
|
95
|
+
repairRunIdsByChat.set(candidate.chatId, repairRunIds);
|
|
96
|
+
}
|
|
97
|
+
if (candidate.runId && repairRunIds.has(candidate.runId))
|
|
98
|
+
continue;
|
|
99
|
+
if (selected.length >= limit) {
|
|
100
|
+
truncated = true;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
selected.push(candidate);
|
|
104
|
+
}
|
|
105
|
+
const terminalSeqByChat = new Map();
|
|
106
|
+
for (const candidate of selected) {
|
|
107
|
+
if (candidate.kind === 'approval-required' || !candidate.runId)
|
|
108
|
+
continue;
|
|
109
|
+
terminalSeqByChat.set(candidate.chatId, Math.max(terminalSeqByChat.get(candidate.chatId) ?? 0, candidate.seq));
|
|
110
|
+
}
|
|
111
|
+
const contentByChat = new Map();
|
|
112
|
+
for (const [chatId, terminalSeq] of terminalSeqByChat) {
|
|
113
|
+
contentByChat.set(chatId, await findChunksOfType(snap, chatId, 'content', { toSeq: terminalSeq }));
|
|
114
|
+
}
|
|
115
|
+
const agentNameById = new Map();
|
|
116
|
+
for (const agentId of new Set(selected.map((candidate) => candidate.agentId))) {
|
|
117
|
+
agentNameById.set(agentId, (await snap.get(AGENTS, { id: agentId }))?.name);
|
|
118
|
+
}
|
|
119
|
+
const notifications = selected.map((candidate) => {
|
|
120
|
+
const content = candidate.kind === 'approval-required' ? undefined : contentByChat.get(candidate.chatId);
|
|
121
|
+
const preview = candidate.runId && content ? runPreview(content, candidate.runId, candidate.seq) : undefined;
|
|
122
|
+
const { runId, ...event } = candidate;
|
|
123
|
+
return {
|
|
124
|
+
...event,
|
|
125
|
+
agentName: agentNameById.get(candidate.agentId),
|
|
126
|
+
preview: candidate.preview ?? preview
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
notifications,
|
|
131
|
+
truncated: truncated || undefined
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
await snap.close();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function diagramRepairRunIds(snap, chatId, toSeq) {
|
|
139
|
+
const [users, requests] = await Promise.all([
|
|
140
|
+
findChunksOfType(snap, chatId, 'user-message', { toSeq }),
|
|
141
|
+
findChunksOfType(snap, chatId, 'run-request', { toSeq })
|
|
142
|
+
]);
|
|
143
|
+
const records = [...users, ...requests];
|
|
144
|
+
const repairs = diagramRepairLinks(records, (chunk) => chunk.userMessage?.text ?? null);
|
|
145
|
+
const runIds = new Set();
|
|
146
|
+
for (const chunk of records) {
|
|
147
|
+
if (chunk.runId && isDiagramRepairPrompt(chunk.userMessage?.text ?? '')) {
|
|
148
|
+
runIds.add(chunk.runId);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
for (const repair of repairs)
|
|
152
|
+
runIds.add(repair.runId);
|
|
153
|
+
return runIds;
|
|
154
|
+
}
|
|
155
|
+
function runPreview(content, runId, terminalSeq) {
|
|
156
|
+
const text = content
|
|
157
|
+
.filter((chunk) => chunk.seq <= terminalSeq && chunk.runId === runId)
|
|
158
|
+
.map((chunk) => chunk.content?.text ?? '')
|
|
159
|
+
.join('')
|
|
160
|
+
.slice(0, PREVIEW_LIMIT);
|
|
161
|
+
return text || undefined;
|
|
162
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Hyperconf from 'hyperconf';
|
|
2
|
+
import type Corestore from 'corestore';
|
|
3
|
+
import type { Hypercore } from 'corestore';
|
|
4
|
+
import { type ReleaseLane } from './app-build.ts';
|
|
5
|
+
import { type ConfConfig } from '../../spec/config/hyperconf/index.js';
|
|
6
|
+
export type ConfigChannel = ReleaseLane;
|
|
7
|
+
export interface ConfigCore {
|
|
8
|
+
readonly key: string;
|
|
9
|
+
readonly minLength: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function resolveConfigChannel(channel?: string | null): ConfigChannel | null;
|
|
12
|
+
export declare function configCoreFor(channel: ConfigChannel): ConfigCore;
|
|
13
|
+
export declare function vendoredMinSupportedVersion(): string;
|
|
14
|
+
export declare class OtaConfigReader extends Hyperconf<ConfConfig> {
|
|
15
|
+
constructor(store: Corestore, { key, minLength }: ConfigCore);
|
|
16
|
+
get minSupportedVersion(): string | null;
|
|
17
|
+
}
|
|
18
|
+
export declare function readOtaConfig(core: Hypercore): Promise<ConfConfig | null>;
|
|
19
|
+
export declare function publishOtaConfig(core: Hypercore, config: ConfConfig): Promise<number>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { Range } from 'bare-semver';
|
|
3
|
+
import c from 'compact-encoding';
|
|
4
|
+
import Hyperconf from 'hyperconf';
|
|
5
|
+
import HypercoreId from 'hypercore-id-encoding';
|
|
6
|
+
import { RELEASE_LANES } from "./app-build.js";
|
|
7
|
+
import spec, {} from '../../spec/config/hyperconf/index.js';
|
|
8
|
+
const CONFIG_CORES = {
|
|
9
|
+
dev: { key: 'e5g337qdk4qachns5nsnu63wjp96twyc34ainucherhq1zodanmy', minLength: 1 },
|
|
10
|
+
staging: { key: '89mz9t33g1c8e4nsjuzafjcbsdht74akzouw3ptfzewnuathpkcy', minLength: 1 },
|
|
11
|
+
prod: { key: 'enuaa7ybdsp3ons73yrazrno9gwrejx4tum3kdws6rps1p1bekgo', minLength: 1 }
|
|
12
|
+
};
|
|
13
|
+
export function resolveConfigChannel(channel) {
|
|
14
|
+
return RELEASE_LANES.find((lane) => lane === channel) ?? null;
|
|
15
|
+
}
|
|
16
|
+
export function configCoreFor(channel) {
|
|
17
|
+
return CONFIG_CORES[channel];
|
|
18
|
+
}
|
|
19
|
+
export function vendoredMinSupportedVersion() {
|
|
20
|
+
return spec.production.minSupportedVersion;
|
|
21
|
+
}
|
|
22
|
+
export class OtaConfigReader extends Hyperconf {
|
|
23
|
+
constructor(store, { key, minLength }) {
|
|
24
|
+
super(spec, store.get(HypercoreId.decode(key)), { minLength, production: true });
|
|
25
|
+
}
|
|
26
|
+
get minSupportedVersion() {
|
|
27
|
+
const range = this.current?.minSupportedVersion;
|
|
28
|
+
return typeof range === 'string' && range.length > 0 ? range : null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function readOtaConfig(core) {
|
|
32
|
+
await core.ready();
|
|
33
|
+
if (!core.length)
|
|
34
|
+
return null;
|
|
35
|
+
const block = await core.get(core.length - 1);
|
|
36
|
+
return block ? c.decode(spec.productionEncoding, block) : null;
|
|
37
|
+
}
|
|
38
|
+
export async function publishOtaConfig(core, config) {
|
|
39
|
+
Range.parse(config.minSupportedVersion);
|
|
40
|
+
await core.ready();
|
|
41
|
+
await core.append(c.encode(spec.productionEncoding, config));
|
|
42
|
+
await core.setUserData('hyperconf', b4a.from(String(core.length)));
|
|
43
|
+
return core.length;
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DiagramRepairLink } from '@qvac/harness/lib/diagram-repair.ts';
|
|
2
|
+
import type { AssistantChunk } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
+
export interface HistoryBranches {
|
|
4
|
+
readonly repairs: ReadonlyArray<DiagramRepairLink>;
|
|
5
|
+
readonly repairByRunId: ReadonlyMap<string, DiagramRepairLink>;
|
|
6
|
+
readonly hiddenChunkIds: ReadonlySet<string>;
|
|
7
|
+
readonly rejectedRunIds: ReadonlySet<string>;
|
|
8
|
+
readonly deadRanges: ReadonlyArray<readonly [number, number]>;
|
|
9
|
+
}
|
|
10
|
+
export declare function historyBranches(all: ReadonlyArray<AssistantChunk>, currentRunId?: string): HistoryBranches;
|
|
11
|
+
export declare function isPromptChunk(chunk: AssistantChunk, branches: HistoryBranches): boolean;
|
|
12
|
+
export declare function acceptedRepairCount(branches: HistoryBranches, currentRunId?: string): number;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { diagramRepairAccepted, diagramRepairLinks, isDiagramRepairPrompt } from '@qvac/harness/lib/diagram-repair.ts';
|
|
2
|
+
export function historyBranches(all, currentRunId) {
|
|
3
|
+
const seqById = new Map(all.map((chunk) => [chunk.id, chunk.seq]));
|
|
4
|
+
const repairs = diagramRepairLinks(all.filter((chunk) => chunk.type === 'user-message' || chunk.type === 'run-request'), (chunk) => chunk.userMessage?.text ?? null);
|
|
5
|
+
const repairByRunId = new Map(repairs.map((repair) => [repair.runId, repair]));
|
|
6
|
+
const hiddenChunkIds = new Set(all
|
|
7
|
+
.filter((chunk) => isDiagramRepairPrompt(chunk.userMessage?.text ?? ''))
|
|
8
|
+
.map((chunk) => chunk.id));
|
|
9
|
+
const replyText = (target) => all
|
|
10
|
+
.filter((chunk) => chunk.runId === target && chunk.content)
|
|
11
|
+
.map((chunk) => chunk.content?.text ?? '')
|
|
12
|
+
.join('');
|
|
13
|
+
const completed = (target) => all.some((chunk) => chunk.type === 'run-status' &&
|
|
14
|
+
chunk.runId === target &&
|
|
15
|
+
chunk.runStatus?.state === 'completed');
|
|
16
|
+
const rejectedRunIds = new Set(repairs
|
|
17
|
+
.filter((repair) => repair.runId !== currentRunId &&
|
|
18
|
+
!(completed(repair.runId) && diagramRepairAccepted(replyText(repair.runId))))
|
|
19
|
+
.map((repair) => repair.runId));
|
|
20
|
+
const deadRanges = [];
|
|
21
|
+
for (const chunk of all) {
|
|
22
|
+
const repair = chunk.runId ? repairByRunId.get(chunk.runId) : undefined;
|
|
23
|
+
if (repair && (repair.runId === currentRunId || rejectedRunIds.has(repair.runId)))
|
|
24
|
+
continue;
|
|
25
|
+
const start = chunk.parentId ? seqById.get(chunk.parentId) : undefined;
|
|
26
|
+
if (start !== undefined)
|
|
27
|
+
deadRanges.push([start, chunk.seq]);
|
|
28
|
+
}
|
|
29
|
+
return { repairs, repairByRunId, hiddenChunkIds, rejectedRunIds, deadRanges };
|
|
30
|
+
}
|
|
31
|
+
export function isPromptChunk(chunk, branches) {
|
|
32
|
+
if (chunk.compaction)
|
|
33
|
+
return true;
|
|
34
|
+
return (!branches.hiddenChunkIds.has(chunk.id) &&
|
|
35
|
+
!(chunk.runId && branches.rejectedRunIds.has(chunk.runId)) &&
|
|
36
|
+
!branches.deadRanges.some(([start, end]) => chunk.seq >= start && chunk.seq < end));
|
|
37
|
+
}
|
|
38
|
+
export function acceptedRepairCount(branches, currentRunId) {
|
|
39
|
+
return branches.repairs.filter((repair) => repair.runId !== currentRunId && !branches.rejectedRunIds.has(repair.runId)).length;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function foldSearchText(text: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE, type HandoffStream } from './handoff-channel.ts';
|
|
2
|
+
import type { AssistantPushSkillSecretRequest, AssistantSkillSecretValue } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
+
export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE, type HandoffStream };
|
|
4
|
+
export type SecretValue = AssistantSkillSecretValue;
|
|
5
|
+
export type SecretRequest = AssistantPushSkillSecretRequest;
|
|
6
|
+
export type SecretRequestHandler = (request: SecretRequest, fromDeviceId: Uint8Array) => Promise<void>;
|
|
7
|
+
export interface SecretHandoffOptions {
|
|
8
|
+
readonly onrequest: SecretRequestHandler;
|
|
9
|
+
readonly ackTimeoutMs?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class SecretHandoff {
|
|
12
|
+
private readonly _channel;
|
|
13
|
+
constructor(opts: SecretHandoffOptions);
|
|
14
|
+
addStream(stream: HandoffStream): void;
|
|
15
|
+
send(hostDeviceId: Uint8Array, request: SecretRequest): Promise<void>;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getStruct } from '../../spec/hyperschema/index.js';
|
|
2
|
+
import { ACK_TIMEOUT_MS, HandoffChannel, HOST_SILENT, HOST_UNREACHABLE } from "./handoff-channel.js";
|
|
3
|
+
const PROTOCOL = 'qvac/secret-handoff';
|
|
4
|
+
export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE };
|
|
5
|
+
const handoff = getStruct('@assistant/skill-secret-handoff');
|
|
6
|
+
const handoffAck = getStruct('@assistant/skill-secret-handoff-ack');
|
|
7
|
+
export class SecretHandoff {
|
|
8
|
+
_channel;
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this._channel = new HandoffChannel({
|
|
11
|
+
protocol: PROTOCOL,
|
|
12
|
+
requestEncoding: handoff,
|
|
13
|
+
ackEncoding: handoffAck,
|
|
14
|
+
onrequest: opts.onrequest,
|
|
15
|
+
buildAck: (id, error) => ({ id, error }),
|
|
16
|
+
readAck: (ack) => ({ error: ack.error ?? '', result: undefined }),
|
|
17
|
+
ackTimeoutMs: opts.ackTimeoutMs
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
addStream(stream) {
|
|
21
|
+
this._channel.addStream(stream);
|
|
22
|
+
}
|
|
23
|
+
send(hostDeviceId, request) {
|
|
24
|
+
return this._channel.send(hostDeviceId, request);
|
|
25
|
+
}
|
|
26
|
+
destroy() {
|
|
27
|
+
this._channel.destroy();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { QvacChat } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
import type { Mesh } from './mesh.ts';
|
|
3
|
+
export type SendMessageInput = {
|
|
4
|
+
text: string;
|
|
5
|
+
originDeviceId: Buffer;
|
|
6
|
+
chatId?: string;
|
|
7
|
+
agentId?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
parentRunId?: string;
|
|
10
|
+
};
|
|
11
|
+
export type SendMessageResult = {
|
|
12
|
+
chatId: string;
|
|
13
|
+
chunkId: string;
|
|
14
|
+
runId: string;
|
|
15
|
+
chat?: QvacChat;
|
|
16
|
+
};
|
|
17
|
+
export declare function sendMessage(mesh: Mesh, input: SendMessageInput): Promise<SendMessageResult>;
|
|
18
|
+
export declare function parentRequestId(mesh: Mesh, chatId: string, parentRunId: string): Promise<string>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { buildChat, enrichChat, mustGetActiveChat } from "./chat.js";
|
|
2
|
+
import { appendChunk, listChunks } from "./chunk.js";
|
|
3
|
+
import { randomId } from "./id.js";
|
|
4
|
+
export async function sendMessage(mesh, input) {
|
|
5
|
+
const existing = input.chatId ? await mustGetActiveChat(mesh, input.chatId) : null;
|
|
6
|
+
const agentId = input.agentId ?? existing?.agentId;
|
|
7
|
+
if (!agentId)
|
|
8
|
+
throw new Error('send-message: agentId is required to mint a chat');
|
|
9
|
+
const chat = existing ?? buildChat({ agentId, title: input.title ?? '' });
|
|
10
|
+
const chatId = chat.id;
|
|
11
|
+
const parentId = input.parentRunId
|
|
12
|
+
? await parentRequestId(mesh, chatId, input.parentRunId)
|
|
13
|
+
: undefined;
|
|
14
|
+
const runId = randomId();
|
|
15
|
+
const batch = mesh.batch();
|
|
16
|
+
if (!existing)
|
|
17
|
+
batch.dispatch('put-chat', { chat });
|
|
18
|
+
const { id: chunkId } = await appendChunk(mesh, {
|
|
19
|
+
chatId,
|
|
20
|
+
type: 'user-message',
|
|
21
|
+
userMessage: { text: input.text },
|
|
22
|
+
originDeviceId: input.originDeviceId
|
|
23
|
+
}, batch);
|
|
24
|
+
await appendChunk(mesh, {
|
|
25
|
+
chatId,
|
|
26
|
+
runId,
|
|
27
|
+
type: 'run-request',
|
|
28
|
+
runRequest: { agentId },
|
|
29
|
+
parentId,
|
|
30
|
+
originDeviceId: input.originDeviceId
|
|
31
|
+
}, batch);
|
|
32
|
+
await batch.flush();
|
|
33
|
+
return {
|
|
34
|
+
chatId,
|
|
35
|
+
chunkId,
|
|
36
|
+
runId,
|
|
37
|
+
chat: existing ? undefined : await enrichChat(mesh, chat)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export async function parentRequestId(mesh, chatId, parentRunId) {
|
|
41
|
+
const requests = await listChunks(mesh, { chatId, type: 'run-request' });
|
|
42
|
+
const parent = requests.find((chunk) => chunk.runId === parentRunId);
|
|
43
|
+
if (!parent)
|
|
44
|
+
throw new Error(`run not found: ${parentRunId}`);
|
|
45
|
+
return parent.id;
|
|
46
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE, type HandoffStream } from './handoff-channel.ts';
|
|
2
|
+
import type { AssistantManagedSkill, AssistantSkillOverlayOp } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
+
export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE, type HandoffStream };
|
|
4
|
+
export type SkillOverlayOp = AssistantSkillOverlayOp;
|
|
5
|
+
export interface SkillOverlayResult {
|
|
6
|
+
readonly skills?: ReadonlyArray<AssistantManagedSkill>;
|
|
7
|
+
readonly found?: boolean;
|
|
8
|
+
readonly content?: string | null;
|
|
9
|
+
readonly origin?: string | null;
|
|
10
|
+
readonly ok?: boolean;
|
|
11
|
+
readonly copied?: boolean;
|
|
12
|
+
readonly removed?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type SkillOverlayHandler = (op: SkillOverlayOp, fromDeviceId: Uint8Array) => Promise<SkillOverlayResult>;
|
|
15
|
+
export interface SkillOverlayHandoffOptions {
|
|
16
|
+
readonly onrequest: SkillOverlayHandler;
|
|
17
|
+
readonly ackTimeoutMs?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class SkillOverlayHandoff {
|
|
20
|
+
private readonly _channel;
|
|
21
|
+
constructor(opts: SkillOverlayHandoffOptions);
|
|
22
|
+
addStream(stream: HandoffStream): void;
|
|
23
|
+
send(hostDeviceId: Uint8Array, op: SkillOverlayOp): Promise<SkillOverlayResult>;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getStruct } from '../../spec/hyperschema/index.js';
|
|
2
|
+
import { ACK_TIMEOUT_MS, HandoffChannel, HOST_SILENT, HOST_UNREACHABLE } from "./handoff-channel.js";
|
|
3
|
+
const PROTOCOL = 'qvac/skill-overlay-handoff';
|
|
4
|
+
export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE };
|
|
5
|
+
const handoff = getStruct('@assistant/skill-overlay-handoff');
|
|
6
|
+
const handoffAck = getStruct('@assistant/skill-overlay-handoff-ack');
|
|
7
|
+
export class SkillOverlayHandoff {
|
|
8
|
+
_channel;
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this._channel = new HandoffChannel({
|
|
11
|
+
protocol: PROTOCOL,
|
|
12
|
+
requestEncoding: handoff,
|
|
13
|
+
ackEncoding: handoffAck,
|
|
14
|
+
onrequest: opts.onrequest,
|
|
15
|
+
buildAck: (id, error, result) => ({
|
|
16
|
+
id,
|
|
17
|
+
error,
|
|
18
|
+
skills: result?.skills ? [...result.skills] : undefined,
|
|
19
|
+
found: result?.found,
|
|
20
|
+
content: result?.content ?? undefined,
|
|
21
|
+
origin: result?.origin ?? undefined,
|
|
22
|
+
ok: result?.ok,
|
|
23
|
+
copied: result?.copied,
|
|
24
|
+
removed: result?.removed
|
|
25
|
+
}),
|
|
26
|
+
readAck: (ack) => ({
|
|
27
|
+
error: ack.error ?? '',
|
|
28
|
+
result: {
|
|
29
|
+
skills: ack.skills ?? undefined,
|
|
30
|
+
found: ack.found,
|
|
31
|
+
content: ack.content ?? undefined,
|
|
32
|
+
origin: ack.origin ?? undefined,
|
|
33
|
+
ok: ack.ok,
|
|
34
|
+
copied: ack.copied,
|
|
35
|
+
removed: ack.removed
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
ackTimeoutMs: opts.ackTimeoutMs
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
addStream(stream) {
|
|
42
|
+
this._channel.addStream(stream);
|
|
43
|
+
}
|
|
44
|
+
send(hostDeviceId, op) {
|
|
45
|
+
return this._channel.send(hostDeviceId, op);
|
|
46
|
+
}
|
|
47
|
+
destroy() {
|
|
48
|
+
this._channel.destroy();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Mesh } from './mesh.ts';
|
|
2
|
+
import type { SkillOverlayHandler, SkillOverlayOp, SkillOverlayResult } from './skill-overlay-handoff.ts';
|
|
3
|
+
export interface SkillOverlayReceiverOptions {
|
|
4
|
+
readonly mesh: Mesh;
|
|
5
|
+
readonly deviceId: Uint8Array;
|
|
6
|
+
readonly runLocal: (op: SkillOverlayOp) => Promise<SkillOverlayResult>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createSkillOverlayReceiver(opts: SkillOverlayReceiverOptions): SkillOverlayHandler;
|