@qvac/core 0.5.0 → 0.6.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/CHANGELOG.md +75 -1
- package/dist-lib/lib/api/agents.js +3 -2
- package/dist-lib/lib/api/app-config.d.ts +1 -1
- package/dist-lib/lib/api/app-config.js +54 -15
- package/dist-lib/lib/api/attachments.d.ts +6 -5
- package/dist-lib/lib/api/attachments.js +4 -2
- package/dist-lib/lib/api/chat.d.ts +7 -3
- package/dist-lib/lib/api/chat.js +4 -4
- package/dist-lib/lib/api/chunks.js +3 -3
- package/dist-lib/lib/api/config.js +2 -2
- package/dist-lib/lib/api/current-mesh.d.ts +3 -4
- package/dist-lib/lib/api/current-mesh.js +9 -4
- package/dist-lib/lib/api/custom-models.d.ts +8 -1
- package/dist-lib/lib/api/custom-models.js +53 -16
- package/dist-lib/lib/api/devices.d.ts +14 -5
- package/dist-lib/lib/api/devices.js +13 -8
- package/dist-lib/lib/api/diagnostics.d.ts +1 -0
- package/dist-lib/lib/api/diagnostics.js +1 -1
- package/dist-lib/lib/api/effective-ctx-size.d.ts +6 -1
- package/dist-lib/lib/api/effective-ctx-size.js +5 -3
- package/dist-lib/lib/api/execution.js +2 -1
- package/dist-lib/lib/api/files.js +2 -1
- package/dist-lib/lib/api/index.d.ts +5 -1
- package/dist-lib/lib/api/index.js +101 -102
- package/dist-lib/lib/api/instrument.js +29 -20
- package/dist-lib/lib/api/knowledge.d.ts +6 -5
- package/dist-lib/lib/api/knowledge.js +8 -6
- package/dist-lib/lib/api/local-files.js +1 -1
- package/dist-lib/lib/api/logs.js +6 -3
- package/dist-lib/lib/api/members.js +22 -13
- package/dist-lib/lib/api/mesh.js +3 -3
- package/dist-lib/lib/api/model-download.js +1 -1
- package/dist-lib/lib/api/network.d.ts +1 -0
- package/dist-lib/lib/api/network.js +1 -1
- package/dist-lib/lib/api/notifications.js +23 -13
- package/dist-lib/lib/api/rag.d.ts +6 -1
- package/dist-lib/lib/api/rag.js +20 -11
- package/dist-lib/lib/api/range.d.ts +2 -2
- package/dist-lib/lib/api/sync.js +1 -1
- package/dist-lib/lib/api/tool-activity.js +7 -3
- package/dist-lib/lib/api/tool-configs.js +2 -4
- package/dist-lib/lib/api/upload-frames.d.ts +7 -8
- package/dist-lib/lib/api/upload-frames.js +2 -1
- package/dist-lib/lib/api/watchable.d.ts +6 -1
- package/dist-lib/lib/api/watchable.js +23 -14
- package/dist-lib/lib/assistant/fetch-body.js +4 -2
- package/dist-lib/lib/assistant/harness.d.ts +48 -27
- package/dist-lib/lib/assistant/harness.js +40 -16
- package/dist-lib/lib/assistant/history.d.ts +9 -7
- package/dist-lib/lib/assistant/history.js +77 -42
- package/dist-lib/lib/assistant/message.d.ts +5 -3
- package/dist-lib/lib/assistant/message.js +4 -2
- package/dist-lib/lib/assistant/skill-encode.d.ts +3 -1
- package/dist-lib/lib/assistant/skill-encode.js +52 -62
- package/dist-lib/lib/assistant-client.js +7 -4
- package/dist-lib/lib/assistant-tree.js +27 -11
- package/dist-lib/lib/assistant.d.ts +30 -11
- package/dist-lib/lib/assistant.js +824 -378
- package/dist-lib/lib/audio-format.d.ts +1 -1
- package/dist-lib/lib/audio-format.js +1 -1
- package/dist-lib/lib/chat-title.js +9 -4
- package/dist-lib/lib/client.js +3 -2
- package/dist-lib/lib/collabora/convert.d.ts +2 -2
- package/dist-lib/lib/collabora/convert.js +6 -3
- package/dist-lib/lib/collabora/entry.js +9 -5
- package/dist-lib/lib/collabora/protocol.d.ts +2 -2
- package/dist-lib/lib/collabora/protocol.js +14 -7
- package/dist-lib/lib/collabora/worker.js +14 -7
- package/dist-lib/lib/compaction.d.ts +5 -6
- package/dist-lib/lib/compaction.js +14 -7
- package/dist-lib/lib/core/account-recovery.d.ts +4 -3
- package/dist-lib/lib/core/account-recovery.js +7 -4
- package/dist-lib/lib/core/agent.js +17 -15
- package/dist-lib/lib/core/approval-rules.d.ts +7 -6
- package/dist-lib/lib/core/approval-rules.js +12 -6
- package/dist-lib/lib/core/archived-mesh.d.ts +7 -5
- package/dist-lib/lib/core/archived-mesh.js +25 -22
- package/dist-lib/lib/core/async-iterable.js +10 -5
- package/dist-lib/lib/core/attachment-link.d.ts +2 -2
- package/dist-lib/lib/core/audio-attachment.js +1 -1
- package/dist-lib/lib/core/blind-peers.d.ts +2 -2
- package/dist-lib/lib/core/chat-activity.d.ts +2 -2
- package/dist-lib/lib/core/chat-activity.js +42 -21
- package/dist-lib/lib/core/chat-group.d.ts +8 -6
- package/dist-lib/lib/core/chat-group.js +17 -10
- package/dist-lib/lib/core/chat-order.d.ts +11 -9
- package/dist-lib/lib/core/chat-order.js +1 -3
- package/dist-lib/lib/core/chat-search.d.ts +4 -4
- package/dist-lib/lib/core/chat-search.js +38 -24
- package/dist-lib/lib/core/chat.d.ts +20 -14
- package/dist-lib/lib/core/chat.js +42 -28
- package/dist-lib/lib/core/chunk.d.ts +19 -23
- package/dist-lib/lib/core/chunk.js +27 -21
- package/dist-lib/lib/core/collections.d.ts +69 -0
- package/dist-lib/lib/core/collections.js +69 -0
- package/dist-lib/lib/core/contract/activity.d.ts +6 -2
- package/dist-lib/lib/core/contract/activity.js +15 -12
- package/dist-lib/lib/core/contract/agents.js +3 -2
- package/dist-lib/lib/core/contract/approval-rules.js +1 -1
- package/dist-lib/lib/core/contract/attestations.js +1 -1
- package/dist-lib/lib/core/contract/chat-group.js +1 -1
- package/dist-lib/lib/core/contract/chat.js +1 -1
- package/dist-lib/lib/core/contract/chunks.js +10 -9
- package/dist-lib/lib/core/contract/compute.js +2 -1
- package/dist-lib/lib/core/contract/devices.js +6 -5
- package/dist-lib/lib/core/contract/grant-order.js +5 -6
- package/dist-lib/lib/core/contract/index.js +4 -2
- package/dist-lib/lib/core/contract/indexing.js +3 -3
- package/dist-lib/lib/core/contract/invites.d.ts +8 -3
- package/dist-lib/lib/core/contract/invites.js +52 -26
- package/dist-lib/lib/core/contract/joined-meshes.js +3 -3
- package/dist-lib/lib/core/contract/knowledge.js +5 -5
- package/dist-lib/lib/core/contract/members.d.ts +13 -2
- package/dist-lib/lib/core/contract/members.js +46 -25
- package/dist-lib/lib/core/contract/mesh-kind.js +9 -8
- package/dist-lib/lib/core/contract/seal.js +1 -1
- package/dist-lib/lib/core/contract/seed-defaults.js +1 -3
- package/dist-lib/lib/core/contract/tool-activity.js +5 -5
- package/dist-lib/lib/core/contract/tool-configs.js +1 -2
- package/dist-lib/lib/core/contract/writers.d.ts +6 -1
- package/dist-lib/lib/core/contract/writers.js +55 -34
- package/dist-lib/lib/core/departures.js +16 -8
- package/dist-lib/lib/core/device-invites.js +3 -2
- package/dist-lib/lib/core/devices.js +6 -3
- package/dist-lib/lib/core/document-attachment.d.ts +20 -11
- package/dist-lib/lib/core/document-attachment.js +10 -5
- package/dist-lib/lib/core/files/attachments.d.ts +2 -5
- package/dist-lib/lib/core/files/attachments.js +6 -3
- package/dist-lib/lib/core/files/index.d.ts +44 -52
- package/dist-lib/lib/core/files/index.js +142 -93
- package/dist-lib/lib/core/files/knowledge.d.ts +2 -5
- package/dist-lib/lib/core/files/local-index.js +9 -5
- package/dist-lib/lib/core/files/preview/image.d.ts +0 -1
- package/dist-lib/lib/core/files/preview/image.js +9 -6
- package/dist-lib/lib/core/files/preview/index.d.ts +8 -11
- package/dist-lib/lib/core/files/preview/index.js +20 -15
- package/dist-lib/lib/core/files/processing/claims.d.ts +6 -5
- package/dist-lib/lib/core/files/processing/claims.js +16 -8
- package/dist-lib/lib/core/files/processing/document.d.ts +21 -50
- package/dist-lib/lib/core/files/processing/index.d.ts +18 -13
- package/dist-lib/lib/core/files/processing/index.js +65 -37
- package/dist-lib/lib/core/files/processing/ownership.d.ts +8 -1
- package/dist-lib/lib/core/files/processing/ownership.js +1 -1
- package/dist-lib/lib/core/files/processing/protocol.d.ts +19 -19
- package/dist-lib/lib/core/files/processing/protocol.js +5 -5
- package/dist-lib/lib/core/files/processing/settle.d.ts +10 -7
- package/dist-lib/lib/core/files/processing/settle.js +22 -11
- package/dist-lib/lib/core/files/processing/source.js +14 -8
- package/dist-lib/lib/core/files/processing/state.d.ts +13 -11
- package/dist-lib/lib/core/files/processing/state.js +19 -12
- package/dist-lib/lib/core/files/rag/build.d.ts +2 -2
- package/dist-lib/lib/core/files/rag/build.js +2 -1
- package/dist-lib/lib/core/files/rag/document-types.d.ts +4 -6
- package/dist-lib/lib/core/files/rag/index.d.ts +10 -13
- package/dist-lib/lib/core/files/rag/index.js +3 -2
- package/dist-lib/lib/core/files/rag/load.d.ts +10 -9
- package/dist-lib/lib/core/files/rag/load.js +26 -13
- package/dist-lib/lib/core/files/rag/policy.js +2 -1
- package/dist-lib/lib/core/files/rag/produce.js +33 -19
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +5 -3
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +30 -10
- package/dist-lib/lib/core/files/records/chunks.js +4 -2
- package/dist-lib/lib/core/files/records/knowledge.d.ts +10 -11
- package/dist-lib/lib/core/files/records/knowledge.js +9 -8
- package/dist-lib/lib/core/files/records/linkage.js +6 -3
- package/dist-lib/lib/core/files/records/output.d.ts +5 -4
- package/dist-lib/lib/core/files/records/output.js +8 -4
- package/dist-lib/lib/core/files/records/reclaim.js +41 -25
- package/dist-lib/lib/core/files/records/routing.d.ts +4 -6
- package/dist-lib/lib/core/files/records/routing.js +15 -8
- package/dist-lib/lib/core/files/records/source.d.ts +5 -4
- package/dist-lib/lib/core/files/records/source.js +20 -14
- package/dist-lib/lib/core/files/records/sweep.js +1 -3
- package/dist-lib/lib/core/files/store/blob.d.ts +10 -10
- package/dist-lib/lib/core/files/store/blob.js +25 -19
- package/dist-lib/lib/core/files/store/index.d.ts +1 -6
- package/dist-lib/lib/core/files/store/index.js +4 -4
- package/dist-lib/lib/core/files/store/inline.d.ts +2 -2
- package/dist-lib/lib/core/files/store/inline.js +6 -3
- package/dist-lib/lib/core/files/store/reference.d.ts +6 -9
- package/dist-lib/lib/core/files/store/reference.js +25 -17
- package/dist-lib/lib/core/files/store/server.d.ts +7 -6
- package/dist-lib/lib/core/files/store/server.js +22 -11
- package/dist-lib/lib/core/files/store/sweep.js +13 -7
- package/dist-lib/lib/core/files/upload-input.d.ts +4 -12
- package/dist-lib/lib/core/files/upload-input.js +10 -5
- package/dist-lib/lib/core/files/upload.d.ts +27 -24
- package/dist-lib/lib/core/files/upload.js +74 -51
- package/dist-lib/lib/core/fs-drives.js +4 -2
- package/dist-lib/lib/core/grant-expiry.js +12 -7
- package/dist-lib/lib/core/handoff-channel.js +27 -13
- package/dist-lib/lib/core/harness-loan.js +35 -17
- package/dist-lib/lib/core/helpers/index.js +6 -2
- package/dist-lib/lib/core/hosted-agents.js +19 -12
- package/dist-lib/lib/core/id.js +1 -1
- package/dist-lib/lib/core/identity.js +6 -3
- package/dist-lib/lib/core/image/cache-sweep.d.ts +12 -10
- package/dist-lib/lib/core/image/cache-sweep.js +11 -6
- package/dist-lib/lib/core/image/normalize.d.ts +6 -0
- package/dist-lib/lib/core/image/normalize.js +12 -2
- package/dist-lib/lib/core/image/sniff.js +42 -21
- package/dist-lib/lib/core/inference-calls-receiver.js +7 -4
- package/dist-lib/lib/core/invite-grants.js +4 -2
- package/dist-lib/lib/core/invite.js +2 -1
- package/dist-lib/lib/core/local/files.js +20 -19
- package/dist-lib/lib/core/local/index.d.ts +69 -46
- package/dist-lib/lib/core/local/index.js +146 -129
- package/dist-lib/lib/core/membership.d.ts +12 -2
- package/dist-lib/lib/core/membership.js +55 -33
- package/dist-lib/lib/core/mesh-seed-handoff.js +7 -1
- package/dist-lib/lib/core/mesh.d.ts +37 -27
- package/dist-lib/lib/core/mesh.js +131 -73
- package/dist-lib/lib/core/migrations/agent-catalog.js +3 -2
- package/dist-lib/lib/core/migrations/agent-indexes.js +3 -3
- package/dist-lib/lib/core/migrations/file-index.js +7 -4
- package/dist-lib/lib/core/migrations/index.d.ts +4 -3
- package/dist-lib/lib/core/migrations/membership.js +9 -4
- package/dist-lib/lib/core/migrations/seal.js +3 -2
- package/dist-lib/lib/core/min-version.js +4 -2
- package/dist-lib/lib/core/next-frame.d.ts +5 -4
- package/dist-lib/lib/core/next-frame.js +6 -3
- package/dist-lib/lib/core/notification.d.ts +5 -1
- package/dist-lib/lib/core/notification.js +89 -77
- package/dist-lib/lib/core/ota-config.js +2 -1
- package/dist-lib/lib/core/pdf/rasterize.d.ts +18 -0
- package/dist-lib/lib/core/pdf/rasterize.js +57 -0
- package/dist-lib/lib/core/prompt-history.js +4 -2
- package/dist-lib/lib/core/range.d.ts +4 -4
- package/dist-lib/lib/core/range.js +12 -6
- package/dist-lib/lib/core/rank.d.ts +5 -4
- package/dist-lib/lib/core/rank.js +2 -1
- package/dist-lib/lib/core/send.d.ts +4 -4
- package/dist-lib/lib/core/send.js +6 -3
- package/dist-lib/lib/core/skill-overlay-receiver.js +7 -4
- package/dist-lib/lib/core/skill-secrets.js +16 -9
- package/dist-lib/lib/core/sync/chunks.js +2 -1
- package/dist-lib/lib/core/sync/devices.js +3 -1
- package/dist-lib/lib/core/sync/files.d.ts +2 -4
- package/dist-lib/lib/core/sync/files.js +28 -20
- package/dist-lib/lib/core/sync/index.d.ts +2 -5
- package/dist-lib/lib/core/sync/index.js +20 -15
- package/dist-lib/lib/core/sync-status.js +10 -7
- package/dist-lib/lib/core/system-info.js +4 -2
- package/dist-lib/lib/core/tool-activity.d.ts +4 -3
- package/dist-lib/lib/core/tool-activity.js +1 -1
- package/dist-lib/lib/core/tool-configs.js +12 -7
- package/dist-lib/lib/core.d.ts +38 -26
- package/dist-lib/lib/core.js +987 -539
- package/dist-lib/lib/credential-pusher.d.ts +12 -17
- package/dist-lib/lib/credential-pusher.js +61 -42
- package/dist-lib/lib/custom-model-pusher.d.ts +7 -3
- package/dist-lib/lib/custom-model-pusher.js +15 -7
- package/dist-lib/lib/custom-model-task.d.ts +1 -0
- package/dist-lib/lib/custom-model-task.js +12 -0
- package/dist-lib/lib/deadline.js +4 -2
- package/dist-lib/lib/diagnostics.d.ts +1 -5
- package/dist-lib/lib/frame-readable.d.ts +3 -0
- package/dist-lib/lib/frame-readable.js +3 -0
- package/dist-lib/lib/fs-drive-bridge.js +24 -14
- package/dist-lib/lib/fs-grants.js +13 -8
- package/dist-lib/lib/guards.d.ts +3 -0
- package/dist-lib/lib/guards.js +9 -0
- package/dist-lib/lib/inference-calls.d.ts +28 -23
- package/dist-lib/lib/inference-calls.js +25 -13
- package/dist-lib/lib/integrations/mcp-providers.d.ts +2 -2
- package/dist-lib/lib/integrations/setup-routes.d.ts +2 -2
- package/dist-lib/lib/knowledge-search.d.ts +6 -5
- package/dist-lib/lib/knowledge-search.js +26 -18
- package/dist-lib/lib/kv-cache-reclaim.js +4 -2
- package/dist-lib/lib/kv-cache.js +8 -4
- package/dist-lib/lib/legacy-core-domain.d.ts +42 -42
- package/dist-lib/lib/log-buffer.js +2 -1
- package/dist-lib/lib/log.js +25 -15
- package/dist-lib/lib/mesh-scoped-engine.js +12 -4
- package/dist-lib/lib/model-catalog-revision.js +6 -3
- package/dist-lib/lib/model-clamp.js +6 -3
- package/dist-lib/lib/model-context.d.ts +8 -3
- package/dist-lib/lib/model-context.js +13 -5
- package/dist-lib/lib/model-download-status.js +4 -2
- package/dist-lib/lib/model-download.d.ts +12 -4
- package/dist-lib/lib/model-download.js +200 -103
- package/dist-lib/lib/model-idle-pusher.d.ts +2 -2
- package/dist-lib/lib/model-idle-pusher.js +3 -4
- package/dist-lib/lib/oauth/browser-connect.d.ts +10 -8
- package/dist-lib/lib/oauth/browser-connect.js +33 -20
- package/dist-lib/lib/oauth/client.d.ts +2 -2
- package/dist-lib/lib/oauth/flow-core.js +23 -9
- package/dist-lib/lib/oauth/flow.d.ts +1 -3
- package/dist-lib/lib/oauth/flow.js +9 -5
- package/dist-lib/lib/oauth/keys.d.ts +4 -4
- package/dist-lib/lib/oauth/keys.js +18 -12
- package/dist-lib/lib/oauth/loopback.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.js +147 -107
- package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.stub.js +1 -1
- package/dist-lib/lib/oauth/pkce.d.ts +4 -2
- package/dist-lib/lib/oauth/pkce.js +10 -0
- package/dist-lib/lib/oauth/providers.js +5 -5
- package/dist-lib/lib/oauth/redirect-types.d.ts +12 -7
- package/dist-lib/lib/oauth/register.js +3 -2
- package/dist-lib/lib/oauth/registry.d.ts +2 -2
- package/dist-lib/lib/oauth/registry.js +2 -1
- package/dist-lib/lib/oauth/resolve.d.ts +30 -10
- package/dist-lib/lib/oauth/resolve.js +12 -6
- package/dist-lib/lib/oauth/token-exchange-core.d.ts +12 -4
- package/dist-lib/lib/oauth/token-exchange-core.js +1 -1
- package/dist-lib/lib/oauth/types.d.ts +12 -12
- package/dist-lib/lib/oauth.d.ts +4 -5
- package/dist-lib/lib/oauth.js +2 -3
- package/dist-lib/lib/reconnecting-watch.d.ts +1 -1
- package/dist-lib/lib/reconnecting-watch.js +6 -6
- package/dist-lib/lib/retry-budget.js +6 -3
- package/dist-lib/lib/run-notices.d.ts +1 -0
- package/dist-lib/lib/run-notices.js +5 -2
- package/dist-lib/lib/run-transcript.d.ts +2 -4
- package/dist-lib/lib/run-transcript.js +4 -2
- package/dist-lib/lib/skill-readiness.js +4 -2
- package/dist-lib/lib/skill-types.d.ts +16 -16
- package/dist-lib/lib/suspend-lifecycle.d.ts +4 -4
- package/dist-lib/lib/suspend-lifecycle.js +10 -5
- package/dist-lib/lib/task.js +22 -12
- package/dist-lib/lib/unref.d.ts +3 -2
- package/dist-lib/lib/unref.js +2 -1
- package/dist-lib/lib/wav-duration.js +10 -5
- package/dist-lib/lib/write-queue.d.ts +5 -4
- package/dist-lib/lib/write-queue.js +2 -1
- package/dist-lib/schema/build.js +10 -6
- package/dist-lib/schema/config.d.ts +2 -3
- package/dist-lib/schema/content.d.ts +17 -2
- package/dist-lib/schema/content.js +2 -1
- package/dist-lib/schema/engine.d.ts +3 -2
- package/dist-lib/schema/engine.js +95 -6
- package/dist-lib/schema/field-order.js +22 -11
- package/dist-lib/schema/indexes.d.ts +22 -0
- package/dist-lib/schema/{helpers.js → indexes.js} +14 -57
- package/dist-lib/schema/local.d.ts +3 -2
- package/dist-lib/schema/local.js +7 -2
- package/dist-lib/schema/media-kind.d.ts +8 -0
- package/dist-lib/schema/media-kind.js +52 -0
- package/dist-lib/schema/qvac.d.ts +12 -9
- package/dist-lib/schema/qvac.js +8 -4
- package/dist-lib/spec/bind.js +12 -0
- package/dist-lib/spec/calls.js +4 -0
- package/dist-lib/spec/capabilities.d.ts +12 -4
- package/dist-lib/spec/hrpc/hrpc.json +54 -2
- package/dist-lib/spec/hrpc/index.js +53 -5
- package/dist-lib/spec/hrpc/messages.js +783 -494
- package/dist-lib/spec/hyperschema/index.js +783 -494
- package/dist-lib/spec/hyperschema/schema.json +247 -1
- package/dist-lib/spec/hyperschema/types.d.ts +69 -1
- package/dist-lib/spec/local/hyperdb/index.js +1 -1
- package/dist-lib/spec/local/hyperdb/messages.js +82 -14
- package/dist-lib/spec/local/hyperschema/index.js +42 -8
- package/dist-lib/spec/local/hyperschema/schema.json +27 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +6 -1
- package/dist-lib/spec/mesh/hyperdb/index.js +1 -1
- package/package.json +7 -3
- package/tui/app.mjs +2424 -941
- package/tui/boot.mjs +17 -46
- package/tui/index.mjs +10 -5
- package/tui/lib/boot-timing.mjs +8 -8
- package/tui/lib/busy-words.mjs +21 -22
- package/tui/lib/export.mjs +100 -32
- package/tui/lib/knowledge-command.mjs +64 -19
- package/tui/lib/knowledge-import.mjs +52 -18
- package/tui/lib/render.mjs +65 -33
- package/tui/lib/save-file.mjs +30 -13
- package/tui/lib/select.mjs +23 -5
- package/tui/lib/selection.mjs +6 -4
- package/tui/lib/setup.mjs +11 -19
- package/tui/lib/sidebar.mjs +23 -13
- package/tui/lib/splash.mjs +6 -7
- package/tui/lib/upload-frames.mjs +1 -2
- package/tui/lib/usage.mjs +13 -9
- package/tui/lib/wrap.mjs +35 -6
- package/tui/main.mjs +54 -78
- package/worker/assistant-sidecar.mjs +5 -10
- package/worker/stow-entry.mjs +7 -4
- package/dist-lib/lib/custom-model-source.d.ts +0 -15
- package/dist-lib/lib/custom-model-source.js +0 -46
- package/dist-lib/lib/oauth/common.d.ts +0 -38
- package/dist-lib/lib/oauth/common.js +0 -34
- package/dist-lib/schema/helpers.d.ts +0 -33
|
@@ -22,12 +22,13 @@ import { registerRoutes } from './contract/index.js';
|
|
|
22
22
|
import { createSyncActivity } from './sync-status.js';
|
|
23
23
|
import { buildHealthAssistant } from './health-assistant.js';
|
|
24
24
|
import b4a from 'b4a';
|
|
25
|
+
import { errorMessage, isRecord } from '../guards.js';
|
|
26
|
+
import { ACTIVE_AGENTS, ACTIVE_CHATS, DEVICES, LIVE_WRITERS_BY_MOST_RECENT, MEMBERS, MESH_KINDS } from './collections.js';
|
|
25
27
|
const [MESH_KEYPAIR, MESH_ENCRYPTION, MESH_DEVICE] = crypto.namespace('qvac-assistant/mesh', 3);
|
|
26
28
|
export function meshPublicKeyFromSeed(seed) {
|
|
27
29
|
return crypto.keyPair(crypto.hash([MESH_KEYPAIR, seed])).publicKey;
|
|
28
30
|
}
|
|
29
31
|
const GENESIS_POLL_MS = 250;
|
|
30
|
-
const LIVE_WRITERS_BY_MOST_RECENT = '@qvac/live-writers-by-most-recent';
|
|
31
32
|
const WARMUP_COLLECTIONS = [
|
|
32
33
|
'@qvac/devices',
|
|
33
34
|
'@qvac/active-agents',
|
|
@@ -36,11 +37,13 @@ const WARMUP_COLLECTIONS = [
|
|
|
36
37
|
];
|
|
37
38
|
export async function isOurTrustedWriter(snap, writerKey, ourMemberId) {
|
|
38
39
|
const device = await liveDeviceForWriter(snap, writerKey);
|
|
39
|
-
if (!device)
|
|
40
|
+
if (!device) {
|
|
40
41
|
return false;
|
|
41
|
-
|
|
42
|
+
}
|
|
43
|
+
if (!ourMemberId) {
|
|
42
44
|
return true;
|
|
43
|
-
|
|
45
|
+
}
|
|
46
|
+
return !!device.memberId && b4a.equals(device.memberId, ourMemberId);
|
|
44
47
|
}
|
|
45
48
|
export function claimableDevice(row) {
|
|
46
49
|
return {
|
|
@@ -88,10 +91,19 @@ export class Mesh extends ReadyResource {
|
|
|
88
91
|
_deviceId;
|
|
89
92
|
_grantExpiry;
|
|
90
93
|
_admitted = false;
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
_autobee = null;
|
|
95
|
+
_blobs = null;
|
|
96
|
+
_syncActivity = null;
|
|
93
97
|
discoveryKey;
|
|
94
|
-
|
|
98
|
+
get autobee() {
|
|
99
|
+
return openedPart(this._autobee, 'autobee');
|
|
100
|
+
}
|
|
101
|
+
get blobs() {
|
|
102
|
+
return openedPart(this._blobs, 'blobs');
|
|
103
|
+
}
|
|
104
|
+
get syncActivity() {
|
|
105
|
+
return openedPart(this._syncActivity, 'syncActivity');
|
|
106
|
+
}
|
|
95
107
|
get publicKey() {
|
|
96
108
|
return this._keyPair.publicKey;
|
|
97
109
|
}
|
|
@@ -118,8 +130,9 @@ export class Mesh extends ReadyResource {
|
|
|
118
130
|
}
|
|
119
131
|
blindPeerStats() {
|
|
120
132
|
const peering = this._blindPeering;
|
|
121
|
-
if (!peering?.blindPeers)
|
|
133
|
+
if (!peering?.blindPeers) {
|
|
122
134
|
return [];
|
|
135
|
+
}
|
|
123
136
|
return [...peering.blindPeers.values()].map((bp) => ({
|
|
124
137
|
key: b4a.toHex(bp.remotePublicKey).slice(0, 16),
|
|
125
138
|
connected: bp.connected,
|
|
@@ -143,15 +156,19 @@ export class Mesh extends ReadyResource {
|
|
|
143
156
|
let attested = 0;
|
|
144
157
|
let unattested = 0;
|
|
145
158
|
let revoked = 0;
|
|
146
|
-
for await (const _member of snap.find(
|
|
159
|
+
for await (const _member of snap.find(MEMBERS)) {
|
|
147
160
|
members++;
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
}
|
|
162
|
+
for await (const device of snap.find(DEVICES)) {
|
|
163
|
+
if (device.revoked) {
|
|
150
164
|
revoked++;
|
|
151
|
-
|
|
165
|
+
}
|
|
166
|
+
else if (device.memberId) {
|
|
152
167
|
attested++;
|
|
153
|
-
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
154
170
|
unattested++;
|
|
171
|
+
}
|
|
155
172
|
}
|
|
156
173
|
this._membership = {
|
|
157
174
|
members,
|
|
@@ -167,17 +184,23 @@ export class Mesh extends ReadyResource {
|
|
|
167
184
|
async refreshOurMember() {
|
|
168
185
|
if (!this._deviceId)
|
|
169
186
|
return;
|
|
170
|
-
const own = await this.view.get(
|
|
187
|
+
const own = await this.view.get(DEVICES, { id: this._deviceId });
|
|
171
188
|
this._ourMemberId = own?.memberId ?? null;
|
|
172
|
-
if (own?.memberId && own.memberProof)
|
|
173
|
-
|
|
189
|
+
if (own?.memberId && own.memberProof) {
|
|
190
|
+
const membership = {
|
|
191
|
+
memberId: own.memberId,
|
|
192
|
+
proof: own.memberProof,
|
|
193
|
+
attestedAt: own.attestedAt || 0
|
|
194
|
+
};
|
|
195
|
+
this.emit('membership', membership);
|
|
196
|
+
}
|
|
174
197
|
}
|
|
175
198
|
refreshGrantExpiry() {
|
|
176
199
|
return this._grantExpiry.refresh();
|
|
177
200
|
}
|
|
178
201
|
async bornKind() {
|
|
179
|
-
for await (const _device of this.view.find(
|
|
180
|
-
return (await this.view.get(
|
|
202
|
+
for await (const _device of this.view.find(DEVICES)) {
|
|
203
|
+
return (await this.view.get(MESH_KINDS, { id: 'mesh' }))?.kind ?? null;
|
|
181
204
|
}
|
|
182
205
|
return undefined;
|
|
183
206
|
}
|
|
@@ -186,8 +209,9 @@ export class Mesh extends ReadyResource {
|
|
|
186
209
|
let kind = await this.bornKind();
|
|
187
210
|
while (kind === undefined && Date.now() < deadline) {
|
|
188
211
|
await new Promise((resolve) => setTimeout(resolve, GENESIS_POLL_MS));
|
|
189
|
-
if (this.closing)
|
|
212
|
+
if (this.closing) {
|
|
190
213
|
return undefined;
|
|
214
|
+
}
|
|
191
215
|
await this.autobee.update();
|
|
192
216
|
kind = await this.bornKind();
|
|
193
217
|
}
|
|
@@ -227,12 +251,13 @@ export class Mesh extends ReadyResource {
|
|
|
227
251
|
this._log?.info(this._scope, 'opening');
|
|
228
252
|
const namespace = this._store.namespace(this.discoveryKey);
|
|
229
253
|
const blobCore = namespace.get({ name: 'qvac-blobs', encryptionKey: this._encryptionKey });
|
|
230
|
-
|
|
254
|
+
const blobs = new Hyperblobs(blobCore);
|
|
255
|
+
this._blobs = blobs;
|
|
231
256
|
try {
|
|
232
|
-
await raceResource(
|
|
257
|
+
await raceResource(blobs.core, blobs.ready(), 'blobs');
|
|
233
258
|
this._log?.info(this._scope, 'blob store opened');
|
|
234
259
|
const writerKeyPair = await namespace.createKeyPair(this._writerSeed ?? 'local');
|
|
235
|
-
|
|
260
|
+
const autobee = new Autobee(namespace, this._key, {
|
|
236
261
|
open: this._autobeeOpen.bind(this),
|
|
237
262
|
apply: this._autobeeApply.bind(this),
|
|
238
263
|
update: this._autobeeUpdate.bind(this),
|
|
@@ -247,6 +272,7 @@ export class Mesh extends ReadyResource {
|
|
|
247
272
|
fastForward: { boot: this._bootFrom ? { head: this._bootFrom } : null },
|
|
248
273
|
strictReindex: true
|
|
249
274
|
});
|
|
275
|
+
this._autobee = autobee;
|
|
250
276
|
this.autobee.on('error', (err) => this._log?.warn(this._scope, 'autobee error', err));
|
|
251
277
|
this.autobee.on('writable', () => void this.checkOwnAdmission().catch(noop));
|
|
252
278
|
this.autobee.on('move-to', (to, from) => this._log?.info(this._scope, 'fast-forwarded onto a head', {
|
|
@@ -256,19 +282,20 @@ export class Mesh extends ReadyResource {
|
|
|
256
282
|
}));
|
|
257
283
|
this.autobee.on('interrupt', (err) => this._log?.warn(this._scope, 'autobee interrupt', err));
|
|
258
284
|
this.autobee.on('writable', () => void this._grantExpiry.refresh());
|
|
259
|
-
if (this._bootInterrupted)
|
|
285
|
+
if (this._bootInterrupted) {
|
|
260
286
|
void this.autobee.close().catch(noop);
|
|
287
|
+
}
|
|
261
288
|
await raceResource(this.autobee, this.autobee.ready(), 'autobee');
|
|
262
289
|
}
|
|
263
290
|
catch (err) {
|
|
264
|
-
await this.
|
|
265
|
-
await
|
|
291
|
+
await this._autobee?.close().catch(noop);
|
|
292
|
+
await blobs.close().catch(noop);
|
|
266
293
|
throw err;
|
|
267
294
|
}
|
|
268
295
|
this.autobee.local.on('upload', (index) => {
|
|
269
296
|
this._localWriterUploadedLength = Math.max(this._localWriterUploadedLength, index + 1);
|
|
270
297
|
});
|
|
271
|
-
this.
|
|
298
|
+
this._syncActivity = createSyncActivity(this);
|
|
272
299
|
void this.refreshOurMember().catch((err) => this._log?.warn(this._scope, 'reading our member failed', err));
|
|
273
300
|
void this._grantExpiry.refresh();
|
|
274
301
|
this._log?.info(this._scope, 'autobee opened', {
|
|
@@ -279,18 +306,19 @@ export class Mesh extends ReadyResource {
|
|
|
279
306
|
this.files.start({ deviceId: this._deviceId });
|
|
280
307
|
}
|
|
281
308
|
startBlindPeering(dht) {
|
|
282
|
-
if (this.closing || this._blindPeering || !this.
|
|
309
|
+
if (this.closing || this._blindPeering || !this._autobee || !this._blobs) {
|
|
283
310
|
return;
|
|
311
|
+
}
|
|
284
312
|
this._blindPeering = new BlindPeering(dht, this._store, {
|
|
285
313
|
pick: 2,
|
|
286
314
|
wakeup: this._wakeup,
|
|
287
315
|
...this._blindPeeringOpts
|
|
288
316
|
});
|
|
289
|
-
this._blindPeering.addAutobaseBackground(this.
|
|
317
|
+
this._blindPeering.addAutobaseBackground(this._autobee, {
|
|
290
318
|
target: this._keyPair.publicKey,
|
|
291
319
|
keys: this._blindPeerKeys
|
|
292
320
|
});
|
|
293
|
-
this._blindPeering.addCoreBackground(this.
|
|
321
|
+
this._blindPeering.addCoreBackground(this._blobs.core, {
|
|
294
322
|
target: this._keyPair.publicKey,
|
|
295
323
|
keys: this._blindPeerKeys
|
|
296
324
|
});
|
|
@@ -304,8 +332,9 @@ export class Mesh extends ReadyResource {
|
|
|
304
332
|
}
|
|
305
333
|
interruptBoot() {
|
|
306
334
|
this._bootInterrupted = true;
|
|
307
|
-
if (this.
|
|
308
|
-
void this.
|
|
335
|
+
if (this._autobee) {
|
|
336
|
+
void this._autobee.close().catch(noop);
|
|
337
|
+
}
|
|
309
338
|
}
|
|
310
339
|
async _close() {
|
|
311
340
|
this._log?.info(this._scope, 'closing');
|
|
@@ -323,9 +352,10 @@ export class Mesh extends ReadyResource {
|
|
|
323
352
|
this._log?.info(this._scope, 'orphaned blob sweep finished');
|
|
324
353
|
}
|
|
325
354
|
catch (err) {
|
|
326
|
-
if (this.closing)
|
|
355
|
+
if (this.closing) {
|
|
327
356
|
return;
|
|
328
|
-
|
|
357
|
+
}
|
|
358
|
+
const error = errorMessage(err);
|
|
329
359
|
this._orphanedBlobSweepStatus = { state: 'failed', error };
|
|
330
360
|
this._log?.warn(this._scope, 'orphaned blob sweep failed', err);
|
|
331
361
|
}
|
|
@@ -345,7 +375,7 @@ export class Mesh extends ReadyResource {
|
|
|
345
375
|
});
|
|
346
376
|
}
|
|
347
377
|
get minted() {
|
|
348
|
-
return this.autobee.key
|
|
378
|
+
return b4a.equals(this.autobee.key, this.autobee.local.key);
|
|
349
379
|
}
|
|
350
380
|
get writable() {
|
|
351
381
|
return this.autobee.writable;
|
|
@@ -360,7 +390,7 @@ export class Mesh extends ReadyResource {
|
|
|
360
390
|
batch() {
|
|
361
391
|
return new MeshBatch(this.autobee, { compute: this._compute });
|
|
362
392
|
}
|
|
363
|
-
async appendBirthOp(identity, device, member, claim,
|
|
393
|
+
async appendBirthOp(identity, device, { member, claim, sharing = false, grantSecret, recovery, vouched = false } = {}) {
|
|
364
394
|
if (this.autobee.local.length > 0)
|
|
365
395
|
return;
|
|
366
396
|
const { publicKey: deviceId, secretKey } = 'secretKey' in identity ? identity : { publicKey: identity, secretKey: null };
|
|
@@ -372,12 +402,14 @@ export class Mesh extends ReadyResource {
|
|
|
372
402
|
if (this._key === null) {
|
|
373
403
|
const birth = this.batch();
|
|
374
404
|
birth.dispatch('add-writer', { writerKey: localKey, device: row, deviceSignature });
|
|
375
|
-
if (sharing)
|
|
405
|
+
if (sharing) {
|
|
376
406
|
birth.dispatch('mint-mesh-kind', { id: 'mesh', kind: 'shared' });
|
|
407
|
+
}
|
|
377
408
|
if (row) {
|
|
378
409
|
birth.dispatch('attest-device', this.attestDevice(deviceId));
|
|
379
|
-
if (member)
|
|
410
|
+
if (member) {
|
|
380
411
|
birth.dispatch('mint-member', member);
|
|
412
|
+
}
|
|
381
413
|
if (!this._compute && !sharing) {
|
|
382
414
|
birth.dispatch('seed-defaults', buildDefaultSeed(row, this._blindPeerKeys));
|
|
383
415
|
birth.dispatch('put-agent', { agent: buildHealthAssistant(row) });
|
|
@@ -408,8 +440,9 @@ export class Mesh extends ReadyResource {
|
|
|
408
440
|
});
|
|
409
441
|
}
|
|
410
442
|
else if (recovery) {
|
|
411
|
-
if (!device || !secretKey)
|
|
443
|
+
if (!device || !secretKey) {
|
|
412
444
|
throw new Error('A recovery needs this device row and its key');
|
|
445
|
+
}
|
|
413
446
|
join.dispatch('recover-device', {
|
|
414
447
|
signature,
|
|
415
448
|
deviceId,
|
|
@@ -431,10 +464,12 @@ export class Mesh extends ReadyResource {
|
|
|
431
464
|
deviceSignature
|
|
432
465
|
});
|
|
433
466
|
}
|
|
434
|
-
if (row)
|
|
467
|
+
if (row) {
|
|
435
468
|
join.dispatch('attest-device', this.attestDevice(deviceId));
|
|
436
|
-
|
|
469
|
+
}
|
|
470
|
+
if (row && member && !grantSecret) {
|
|
437
471
|
join.dispatch('join-member', member);
|
|
472
|
+
}
|
|
438
473
|
await join.flush({ optimistic: true });
|
|
439
474
|
}
|
|
440
475
|
await this.autobee.update();
|
|
@@ -444,8 +479,9 @@ export class Mesh extends ReadyResource {
|
|
|
444
479
|
return this.autobee.interrupted;
|
|
445
480
|
}
|
|
446
481
|
throwIfInterrupted() {
|
|
447
|
-
if (this.interrupted)
|
|
482
|
+
if (this.interrupted) {
|
|
448
483
|
throw this.interrupted;
|
|
484
|
+
}
|
|
449
485
|
}
|
|
450
486
|
async waitForWritable(timeout) {
|
|
451
487
|
if (this.closing || this.autobee.writable)
|
|
@@ -464,19 +500,22 @@ export class Mesh extends ReadyResource {
|
|
|
464
500
|
}
|
|
465
501
|
pendingUploads() {
|
|
466
502
|
const peers = this.autobee.local.peers;
|
|
467
|
-
if (this.closing || peers.length === 0)
|
|
503
|
+
if (this.closing || peers.length === 0) {
|
|
468
504
|
return 0;
|
|
505
|
+
}
|
|
469
506
|
const taken = Math.max(this._localWriterUploadedLength, ...peers.map((peer) => peer.remoteLength));
|
|
470
507
|
return Math.max(0, this.autobee.local.length - taken);
|
|
471
508
|
}
|
|
472
509
|
async suspend() {
|
|
473
510
|
await this._files?.suspend();
|
|
474
|
-
if (this._blindPeering)
|
|
511
|
+
if (this._blindPeering) {
|
|
475
512
|
await this._blindPeering.suspend();
|
|
513
|
+
}
|
|
476
514
|
}
|
|
477
515
|
async resume() {
|
|
478
|
-
if (this._blindPeering)
|
|
516
|
+
if (this._blindPeering) {
|
|
479
517
|
await this._blindPeering.resume();
|
|
518
|
+
}
|
|
480
519
|
this._files?.resume();
|
|
481
520
|
}
|
|
482
521
|
syncChatOrder = null;
|
|
@@ -548,34 +587,40 @@ export class Mesh extends ReadyResource {
|
|
|
548
587
|
for (const node of nodes) {
|
|
549
588
|
if (!node.value)
|
|
550
589
|
continue;
|
|
551
|
-
|
|
552
|
-
await this.router.dispatch(node.value, {
|
|
553
|
-
tx,
|
|
554
|
-
host,
|
|
555
|
-
node,
|
|
556
|
-
meshPublicKey: this.publicKey,
|
|
557
|
-
meshDevicePublicKey: this.devicePublicKey,
|
|
558
|
-
log: this._log
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
catch (err) {
|
|
562
|
-
if (!isFromANewerBuild(err))
|
|
563
|
-
throw err;
|
|
564
|
-
this._halt(err, host);
|
|
565
|
-
}
|
|
590
|
+
await this._applyNode(node, { tx, host });
|
|
566
591
|
}
|
|
567
592
|
await tx.flush();
|
|
568
593
|
}
|
|
569
594
|
catch (err) {
|
|
570
595
|
await tx.close();
|
|
571
|
-
if (isInterrupt(err))
|
|
596
|
+
if (isInterrupt(err)) {
|
|
572
597
|
throw err;
|
|
573
|
-
|
|
598
|
+
}
|
|
599
|
+
if (isFromANewerBuild(err)) {
|
|
574
600
|
this._halt(err, host);
|
|
601
|
+
}
|
|
575
602
|
this._log?.error(this._scope, 'autobee apply', err);
|
|
576
603
|
throw err;
|
|
577
604
|
}
|
|
578
605
|
}
|
|
606
|
+
async _applyNode(node, { tx, host }) {
|
|
607
|
+
try {
|
|
608
|
+
await this.router.dispatch(node.value, {
|
|
609
|
+
tx,
|
|
610
|
+
host,
|
|
611
|
+
node,
|
|
612
|
+
meshPublicKey: this.publicKey,
|
|
613
|
+
meshDevicePublicKey: this.devicePublicKey,
|
|
614
|
+
log: this._log
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
catch (err) {
|
|
618
|
+
if (!isFromANewerBuild(err)) {
|
|
619
|
+
throw err;
|
|
620
|
+
}
|
|
621
|
+
this._halt(err, host);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
579
624
|
_halt(err, host) {
|
|
580
625
|
this._log?.warn(this._scope, 'halting apply: the mesh moved past this build', err);
|
|
581
626
|
return host.interrupt(err);
|
|
@@ -584,14 +629,16 @@ export class Mesh extends ReadyResource {
|
|
|
584
629
|
if (this.closing)
|
|
585
630
|
return;
|
|
586
631
|
const change = changes.get('view');
|
|
587
|
-
if (!change)
|
|
632
|
+
if (!change) {
|
|
588
633
|
return;
|
|
634
|
+
}
|
|
589
635
|
const shared = change.shared;
|
|
590
636
|
const from = shared?.key ? { key: shared.key, length: shared.length } : change.from;
|
|
591
637
|
try {
|
|
592
638
|
await syncChanges(this, view, from);
|
|
593
|
-
if (this._admitted && !this.autobee.writable)
|
|
639
|
+
if (this._admitted && !this.autobee.writable) {
|
|
594
640
|
await this.checkOwnAdmission();
|
|
641
|
+
}
|
|
595
642
|
}
|
|
596
643
|
catch (err) {
|
|
597
644
|
this._log?.warn(this._scope, 'change sync failed', err);
|
|
@@ -602,20 +649,23 @@ export class Mesh extends ReadyResource {
|
|
|
602
649
|
this._admitted = true;
|
|
603
650
|
return;
|
|
604
651
|
}
|
|
605
|
-
if (!this._admitted || !this._deviceId)
|
|
652
|
+
if (!this._admitted || !this._deviceId) {
|
|
606
653
|
return;
|
|
607
|
-
|
|
654
|
+
}
|
|
655
|
+
if (!(await this.autobee.system.get(this.localWriterKey, { unflushed: true }))) {
|
|
608
656
|
return;
|
|
609
|
-
|
|
610
|
-
|
|
657
|
+
}
|
|
658
|
+
const own = await this.view.get(DEVICES, { id: this._deviceId });
|
|
659
|
+
if (own?.writerKey && b4a.equals(own?.writerKey, this.localWriterKey)) {
|
|
611
660
|
return;
|
|
661
|
+
}
|
|
612
662
|
this._admitted = false;
|
|
613
663
|
this.emit('kicked');
|
|
614
664
|
}
|
|
615
665
|
async checkResumedRevocation() {
|
|
616
666
|
const snap = this.view.snapshot();
|
|
617
667
|
try {
|
|
618
|
-
for await (const device of snap.find(
|
|
668
|
+
for await (const device of snap.find(DEVICES)) {
|
|
619
669
|
if (!isOwnRevokedRow(this, device))
|
|
620
670
|
continue;
|
|
621
671
|
return isOwnKickedRow(this, device) ? 'kicked' : 'left';
|
|
@@ -628,11 +678,13 @@ export class Mesh extends ReadyResource {
|
|
|
628
678
|
}
|
|
629
679
|
async ownWriterRefused() {
|
|
630
680
|
const info = await this.autobee.system.get(this.localWriterKey, { unflushed: true });
|
|
631
|
-
if (!info?.isRemoved)
|
|
681
|
+
if (!info?.isRemoved) {
|
|
632
682
|
return false;
|
|
633
|
-
|
|
634
|
-
|
|
683
|
+
}
|
|
684
|
+
for await (const device of this.view.find(DEVICES)) {
|
|
685
|
+
if (device.writerKey && b4a.equals(device.writerKey, this.localWriterKey)) {
|
|
635
686
|
return false;
|
|
687
|
+
}
|
|
636
688
|
}
|
|
637
689
|
return true;
|
|
638
690
|
}
|
|
@@ -661,10 +713,16 @@ export class MeshBatch {
|
|
|
661
713
|
}
|
|
662
714
|
}
|
|
663
715
|
function noop() { }
|
|
716
|
+
function openedPart(part, name) {
|
|
717
|
+
if (part === null)
|
|
718
|
+
throw new Error(`mesh ${name} read before open`);
|
|
719
|
+
return part;
|
|
720
|
+
}
|
|
664
721
|
async function drain(stream) {
|
|
665
722
|
let count = 0;
|
|
666
|
-
for await (const _row of stream)
|
|
723
|
+
for await (const _row of stream) {
|
|
667
724
|
count++;
|
|
725
|
+
}
|
|
668
726
|
return count;
|
|
669
727
|
}
|
|
670
728
|
const NEWER_BUILD_MESSAGES = new Set(['Unsupported version', 'Unknown enum', 'Out of bounds']);
|
|
@@ -672,7 +730,7 @@ function isInterrupt(err) {
|
|
|
672
730
|
return err instanceof Error && err.message === 'Apply interrupted';
|
|
673
731
|
}
|
|
674
732
|
function isFromANewerBuild(err) {
|
|
675
|
-
if (
|
|
733
|
+
if (isRecord(err) && 'code' in err) {
|
|
676
734
|
return err.code === ERRORS.HANDLER_NOT_FOUND_BY_ID;
|
|
677
735
|
}
|
|
678
736
|
return err instanceof Error && NEWER_BUILD_MESSAGES.has(err.message);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { buildHealthAssistant, HEALTH_ASSISTANT_ID } from '../health-assistant.js';
|
|
2
|
-
|
|
2
|
+
import { AGENTS } from '../collections.js';
|
|
3
3
|
const MIGRATION_BASELINE_AT = 0;
|
|
4
4
|
export async function migrateAgentCatalog(mesh, { device }) {
|
|
5
5
|
const snap = mesh.view.snapshot();
|
|
6
6
|
try {
|
|
7
|
-
if (await snap.get(AGENTS, { id: HEALTH_ASSISTANT_ID }))
|
|
7
|
+
if (await snap.get(AGENTS, { id: HEALTH_ASSISTANT_ID })) {
|
|
8
8
|
return false;
|
|
9
|
+
}
|
|
9
10
|
}
|
|
10
11
|
finally {
|
|
11
12
|
await snap.close();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
const AGENTS_BY_PROVIDER = '@qvac/agents-by-provider';
|
|
1
|
+
import { ACTIVE_AGENTS, AGENTS_BY_PROVIDER } from '../collections.js';
|
|
3
2
|
export async function reindexAgents(mesh) {
|
|
4
3
|
if (!mesh.writable)
|
|
5
4
|
return false;
|
|
6
5
|
const missing = await unindexedAgentIds(mesh);
|
|
7
|
-
if (missing.length === 0)
|
|
6
|
+
if (missing.length === 0) {
|
|
8
7
|
return false;
|
|
8
|
+
}
|
|
9
9
|
await mesh.dispatch('reindex-agents', { agentIds: missing });
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { CHUNKS } from '../collections.js';
|
|
2
2
|
const BATCH = 256;
|
|
3
3
|
export async function backfillFileIndex(mesh) {
|
|
4
4
|
const index = mesh.fileIndex;
|
|
5
|
-
if (!index)
|
|
5
|
+
if (!index) {
|
|
6
6
|
return;
|
|
7
|
+
}
|
|
7
8
|
const snapshot = mesh.view.snapshot();
|
|
8
9
|
try {
|
|
9
10
|
let batch = [];
|
|
@@ -13,13 +14,15 @@ export async function backfillFileIndex(mesh) {
|
|
|
13
14
|
if (chunk.type !== 'attachment')
|
|
14
15
|
continue;
|
|
15
16
|
batch.push(chunk);
|
|
16
|
-
if (batch.length < BATCH)
|
|
17
|
+
if (batch.length < BATCH) {
|
|
17
18
|
continue;
|
|
19
|
+
}
|
|
18
20
|
await index.record(batch);
|
|
19
21
|
batch = [];
|
|
20
22
|
}
|
|
21
|
-
if (batch.length > 0)
|
|
23
|
+
if (batch.length > 0) {
|
|
22
24
|
await index.record(batch);
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
finally {
|
|
25
28
|
await snapshot.close();
|
|
@@ -2,6 +2,7 @@ import type { Mesh } from '../mesh.ts';
|
|
|
2
2
|
import { type AgentCatalogMigrationContext } from './agent-catalog.ts';
|
|
3
3
|
import { type MembershipMigrationContext } from './membership.ts';
|
|
4
4
|
export type MigrationContext = MembershipMigrationContext & AgentCatalogMigrationContext;
|
|
5
|
-
export
|
|
6
|
-
catalog?: boolean;
|
|
7
|
-
}
|
|
5
|
+
export interface RunMigrationsOptions {
|
|
6
|
+
readonly catalog?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function runMigrations(mesh: Mesh, context: MigrationContext, { catalog }?: RunMigrationsOptions): Promise<boolean>;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { attestDeviceProof } from '../identity.js';
|
|
2
2
|
import { membershipView } from '../membership.js';
|
|
3
|
+
import b4a from 'b4a';
|
|
3
4
|
export async function migrateMembership(mesh, { deviceKeyPair, deviceName, mintRoot, log }) {
|
|
4
5
|
const { members, own, unattested } = await membershipView(mesh, deviceKeyPair.publicKey);
|
|
5
|
-
if (!own)
|
|
6
|
+
if (!own) {
|
|
6
7
|
return false;
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
}
|
|
9
|
+
const { memberId } = own;
|
|
10
|
+
const resuming = !!memberId && members === 1 && unattested.length > 0;
|
|
11
|
+
if (!resuming && (members > 0 || memberId)) {
|
|
9
12
|
return false;
|
|
13
|
+
}
|
|
10
14
|
const now = Date.now();
|
|
11
15
|
const root = await mintRoot(own.id, now);
|
|
12
|
-
if (resuming && !
|
|
16
|
+
if (resuming && !b4a.equals(memberId, root.publicKey)) {
|
|
13
17
|
return false;
|
|
18
|
+
}
|
|
14
19
|
if (!resuming) {
|
|
15
20
|
await mesh.dispatch('mint-member', {
|
|
16
21
|
member: { id: root.publicKey, name: deviceName, joinedAt: now, updatedAt: now },
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { claimableDevice } from '../mesh.js';
|
|
2
2
|
import { sealed } from '../contract/seal.js';
|
|
3
|
-
|
|
3
|
+
import { DEVICES } from '../collections.js';
|
|
4
4
|
export async function sealDeviceRows(mesh, { deviceKeyPair, deviceName, log }) {
|
|
5
5
|
if (!mesh.writable)
|
|
6
6
|
return false;
|
|
7
7
|
const own = await mesh.view.get(DEVICES, { id: deviceKeyPair.publicKey });
|
|
8
|
-
if (!own || (await sealed(mesh.view)))
|
|
8
|
+
if (!own || (await sealed(mesh.view))) {
|
|
9
9
|
return false;
|
|
10
|
+
}
|
|
10
11
|
const joinedAt = Date.now();
|
|
11
12
|
const { id, capabilityProfile, recommendedModelName } = own;
|
|
12
13
|
await mesh.dispatch('add-writer', {
|
|
@@ -4,16 +4,18 @@ export function releaseVersion(version) {
|
|
|
4
4
|
.trim()
|
|
5
5
|
.replace(/^[vV]/, '')
|
|
6
6
|
.match(/^\d+\.\d+\.\d+/);
|
|
7
|
-
if (!match)
|
|
7
|
+
if (!match) {
|
|
8
8
|
throw new Error(`unparseable version: ${version}`);
|
|
9
|
+
}
|
|
9
10
|
return match[0];
|
|
10
11
|
}
|
|
11
12
|
export function updateRequired({ range, appVersion }) {
|
|
12
13
|
if (!range || !appVersion)
|
|
13
14
|
return false;
|
|
14
15
|
const floor = parseRange(range);
|
|
15
|
-
if (!floor)
|
|
16
|
+
if (!floor) {
|
|
16
17
|
return false;
|
|
18
|
+
}
|
|
17
19
|
try {
|
|
18
20
|
return !satisfies(Version.parse(releaseVersion(appVersion)), floor);
|
|
19
21
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
2
|
export declare const UPLOAD_INACTIVITY_MS = 30000;
|
|
3
|
-
export
|
|
4
|
-
signal?: AbortSignal;
|
|
5
|
-
inactivityMs?: number;
|
|
6
|
-
}
|
|
3
|
+
export interface NextFrameOptions {
|
|
4
|
+
readonly signal?: AbortSignal;
|
|
5
|
+
readonly inactivityMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function nextFrame<T>(iterator: AsyncIterator<T>, { signal, inactivityMs }?: NextFrameOptions): Promise<IteratorResult<T>>;
|
|
@@ -2,8 +2,9 @@ import { AbortedError } from '@qvac/harness/race-abort';
|
|
|
2
2
|
import { unref } from '../unref.js';
|
|
3
3
|
export const UPLOAD_INACTIVITY_MS = 30_000;
|
|
4
4
|
export function nextFrame(iterator, { signal, inactivityMs = UPLOAD_INACTIVITY_MS } = {}) {
|
|
5
|
-
if (signal?.aborted)
|
|
5
|
+
if (signal?.aborted) {
|
|
6
6
|
return Promise.reject(new AbortedError());
|
|
7
|
+
}
|
|
7
8
|
return new Promise((resolve, reject) => {
|
|
8
9
|
const timer = setTimeout(() => finish(new Error('upload source timed out')), inactivityMs);
|
|
9
10
|
unref(timer);
|
|
@@ -11,10 +12,12 @@ export function nextFrame(iterator, { signal, inactivityMs = UPLOAD_INACTIVITY_M
|
|
|
11
12
|
const finish = (error, result) => {
|
|
12
13
|
clearTimeout(timer);
|
|
13
14
|
signal?.removeEventListener('abort', abort);
|
|
14
|
-
if (error)
|
|
15
|
+
if (error) {
|
|
15
16
|
reject(error);
|
|
16
|
-
|
|
17
|
+
}
|
|
18
|
+
else if (result) {
|
|
17
19
|
resolve(result);
|
|
20
|
+
}
|
|
18
21
|
};
|
|
19
22
|
signal?.addEventListener('abort', abort, { once: true });
|
|
20
23
|
try {
|
|
@@ -2,5 +2,9 @@ import type { AssistantNotificationList } from '../../spec/hyperschema/types.d.t
|
|
|
2
2
|
import type { openLocalStore } from './local/index.ts';
|
|
3
3
|
import type { Mesh } from './mesh.ts';
|
|
4
4
|
type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
|
|
5
|
-
export
|
|
5
|
+
export interface DeriveNotificationsOptions {
|
|
6
|
+
readonly limit?: number;
|
|
7
|
+
readonly deviceId?: Buffer | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function deriveNotifications(mesh: Mesh, local: LocalStore, { limit: requestedLimit, deviceId }?: DeriveNotificationsOptions): Promise<AssistantNotificationList>;
|
|
6
10
|
export {};
|