@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
|
@@ -49,8 +49,9 @@ export class HostedAgents {
|
|
|
49
49
|
if (!(await this._lock.lock()))
|
|
50
50
|
return;
|
|
51
51
|
try {
|
|
52
|
-
if (!this._closed && !this._mesh.closing)
|
|
52
|
+
if (!this._closed && !this._mesh.closing) {
|
|
53
53
|
await this._pass();
|
|
54
|
+
}
|
|
54
55
|
}
|
|
55
56
|
catch (err) {
|
|
56
57
|
this._log?.warn(SCOPE, 'hosted agent pass failed', err);
|
|
@@ -69,27 +70,31 @@ export class HostedAgents {
|
|
|
69
70
|
if (departed.length > 0) {
|
|
70
71
|
const catalog = await this._catalog();
|
|
71
72
|
for (const id of departed) {
|
|
72
|
-
|
|
73
|
-
if (await this._handOver(id, catalog))
|
|
74
|
-
holding.delete(id);
|
|
75
|
-
}
|
|
76
|
-
catch (err) {
|
|
73
|
+
const released = await this._handOver(id, catalog).catch((err) => {
|
|
77
74
|
this._log?.warn(SCOPE, 'skill values could not follow the agent', err);
|
|
75
|
+
return false;
|
|
76
|
+
});
|
|
77
|
+
if (released) {
|
|
78
|
+
holding.delete(id);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
|
-
if (!sameIds(held, holding))
|
|
82
|
+
if (!sameIds(held, holding)) {
|
|
82
83
|
await this._local.set(this._heldKey, [...holding]);
|
|
84
|
+
}
|
|
83
85
|
}
|
|
84
86
|
async _handOver(id, catalog) {
|
|
85
87
|
const agent = await getAgent(this._mesh, id);
|
|
86
|
-
if (!agent)
|
|
88
|
+
if (!agent) {
|
|
87
89
|
return false;
|
|
88
|
-
|
|
90
|
+
}
|
|
91
|
+
if (agent.deletedAt) {
|
|
89
92
|
return true;
|
|
93
|
+
}
|
|
90
94
|
const stored = await this._stored(agentSkillValues(catalog, agent));
|
|
91
|
-
if (stored.length === 0)
|
|
95
|
+
if (stored.length === 0) {
|
|
92
96
|
return true;
|
|
97
|
+
}
|
|
93
98
|
for (const [skillName, values] of bySkill(stored)) {
|
|
94
99
|
await this._send(agent.providerDeviceId, { agentId: id, skillName, values });
|
|
95
100
|
}
|
|
@@ -101,8 +106,9 @@ export class HostedAgents {
|
|
|
101
106
|
const stored = [];
|
|
102
107
|
for (const value of values) {
|
|
103
108
|
const held = await this._local.get(value.storageKey);
|
|
104
|
-
if (typeof held === 'string' && held !== '')
|
|
109
|
+
if (typeof held === 'string' && held !== '') {
|
|
105
110
|
stored.push({ ...value, value: held });
|
|
111
|
+
}
|
|
106
112
|
}
|
|
107
113
|
return stored;
|
|
108
114
|
}
|
|
@@ -112,8 +118,9 @@ export class HostedAgents {
|
|
|
112
118
|
const ids = new Set();
|
|
113
119
|
if (Array.isArray(stored)) {
|
|
114
120
|
for (const id of stored) {
|
|
115
|
-
if (typeof id === 'string')
|
|
121
|
+
if (typeof id === 'string') {
|
|
116
122
|
ids.add(id);
|
|
123
|
+
}
|
|
117
124
|
}
|
|
118
125
|
}
|
|
119
126
|
return ids;
|
package/dist-lib/lib/core/id.js
CHANGED
|
@@ -6,8 +6,9 @@ const [CLAIM_NAMESPACE] = crypto.namespace('@qvac/core/member-claim', 1);
|
|
|
6
6
|
const [INVITE_NAMESPACE] = crypto.namespace('@qvac/core/device-invite', 1);
|
|
7
7
|
let loaded = null;
|
|
8
8
|
async function identityKey() {
|
|
9
|
-
if (loaded === null)
|
|
9
|
+
if (loaded === null) {
|
|
10
10
|
loaded = await import('keet-identity-key');
|
|
11
|
+
}
|
|
11
12
|
return loaded.default;
|
|
12
13
|
}
|
|
13
14
|
export async function generateMnemonic() {
|
|
@@ -35,8 +36,9 @@ export async function verifyDeviceProof(proof, expected) {
|
|
|
35
36
|
catch {
|
|
36
37
|
return false;
|
|
37
38
|
}
|
|
38
|
-
if (decoded.data)
|
|
39
|
+
if (decoded.data) {
|
|
39
40
|
return false;
|
|
41
|
+
}
|
|
40
42
|
try {
|
|
41
43
|
const IdentityKey = await identityKey();
|
|
42
44
|
return !!IdentityKey.verify(proof, null, {
|
|
@@ -67,8 +69,9 @@ export async function verifyMemberClaim(proof, expected) {
|
|
|
67
69
|
catch {
|
|
68
70
|
return false;
|
|
69
71
|
}
|
|
70
|
-
if (!decoded.data)
|
|
72
|
+
if (!decoded.data) {
|
|
71
73
|
return false;
|
|
74
|
+
}
|
|
72
75
|
try {
|
|
73
76
|
const IdentityKey = await identityKey();
|
|
74
77
|
return !!IdentityKey.verify(proof, expected.attestation, {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export declare const IMAGE_CACHE_MAX_BYTES: number;
|
|
2
2
|
export declare const IMAGE_CACHE_MAX_AGE_MS: number;
|
|
3
|
-
export
|
|
4
|
-
blobId: string;
|
|
5
|
-
fileName: string;
|
|
6
|
-
}
|
|
3
|
+
export interface CachedImage {
|
|
4
|
+
readonly blobId: string;
|
|
5
|
+
readonly fileName: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function imageCacheName(image: CachedImage): string;
|
|
7
8
|
export declare function imageCacheKey(blobId: string): string;
|
|
8
|
-
export
|
|
9
|
-
maxBytes?: number;
|
|
10
|
-
maxAgeMs?: number;
|
|
11
|
-
keep?: ReadonlySet<string>;
|
|
12
|
-
inUse?: (name: string) => boolean;
|
|
13
|
-
}
|
|
9
|
+
export interface SweepImageCacheOptions {
|
|
10
|
+
readonly maxBytes?: number;
|
|
11
|
+
readonly maxAgeMs?: number;
|
|
12
|
+
readonly keep?: ReadonlySet<string>;
|
|
13
|
+
readonly inUse?: (name: string) => boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function sweepImageCache(dir: string, { maxBytes, maxAgeMs, keep, inUse }?: SweepImageCacheOptions): Promise<void>;
|
|
@@ -12,19 +12,21 @@ export function imageCacheName(image) {
|
|
|
12
12
|
return `${imageCacheKey(image.blobId)}-${name}`;
|
|
13
13
|
}
|
|
14
14
|
export function imageCacheKey(blobId) {
|
|
15
|
-
return b4a.toHex(crypto.hash(
|
|
15
|
+
return b4a.toHex(crypto.hash(b4a.from(blobId))).slice(0, CACHE_KEY_CHARS);
|
|
16
16
|
}
|
|
17
17
|
export async function sweepImageCache(dir, { maxBytes = IMAGE_CACHE_MAX_BYTES, maxAgeMs = IMAGE_CACHE_MAX_AGE_MS, keep, inUse } = {}) {
|
|
18
18
|
const names = await fs.promises.readdir(dir).catch(toNull);
|
|
19
|
-
if (!names)
|
|
19
|
+
if (!names) {
|
|
20
20
|
return;
|
|
21
|
+
}
|
|
21
22
|
const now = Date.now();
|
|
22
23
|
const entries = [];
|
|
23
24
|
let total = 0;
|
|
24
25
|
for (const entry of await liveEntries(dir, names, now)) {
|
|
25
26
|
total += entry.size;
|
|
26
|
-
if (inUse?.(entry.name))
|
|
27
|
+
if (inUse?.(entry.name)) {
|
|
27
28
|
continue;
|
|
29
|
+
}
|
|
28
30
|
if (keep && !keep.has(entry.name.slice(0, CACHE_KEY_CHARS))) {
|
|
29
31
|
await fs.promises.unlink(entry.file).catch(noop);
|
|
30
32
|
total -= entry.size;
|
|
@@ -37,8 +39,9 @@ export async function sweepImageCache(dir, { maxBytes = IMAGE_CACHE_MAX_BYTES, m
|
|
|
37
39
|
}
|
|
38
40
|
entries.push(entry);
|
|
39
41
|
}
|
|
40
|
-
if (total <= maxBytes)
|
|
42
|
+
if (total <= maxBytes) {
|
|
41
43
|
return;
|
|
44
|
+
}
|
|
42
45
|
entries.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
43
46
|
for (const entry of entries) {
|
|
44
47
|
if (total <= maxBytes)
|
|
@@ -54,11 +57,13 @@ async function liveEntries(dir, names, now) {
|
|
|
54
57
|
for (const name of names) {
|
|
55
58
|
const file = path.join(dir, name);
|
|
56
59
|
const stats = await fs.promises.stat(file).catch(toNull);
|
|
57
|
-
if (!stats?.isFile())
|
|
60
|
+
if (!stats?.isFile()) {
|
|
58
61
|
continue;
|
|
62
|
+
}
|
|
59
63
|
if (STAGING_SUFFIX.test(name)) {
|
|
60
|
-
if (now - stats.mtimeMs > STALE_PARTIAL_MS)
|
|
64
|
+
if (now - stats.mtimeMs > STALE_PARTIAL_MS) {
|
|
61
65
|
await fs.promises.unlink(file).catch(noop);
|
|
66
|
+
}
|
|
62
67
|
continue;
|
|
63
68
|
}
|
|
64
69
|
entries.push({ file, name, size: stats.size, mtimeMs: stats.mtimeMs });
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export declare const MAX_IMAGE_WIDTH = 768;
|
|
2
2
|
export declare const IMAGE_MIMES: Set<string>;
|
|
3
3
|
export declare function normalizeImageForModel(bytes: Uint8Array): Promise<Uint8Array>;
|
|
4
|
+
export interface Raster {
|
|
5
|
+
readonly width: number;
|
|
6
|
+
readonly height: number;
|
|
7
|
+
readonly data: Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
export declare function rasterToModelJpeg(raster: Raster): Promise<Uint8Array | null>;
|
|
@@ -27,8 +27,9 @@ async function loadMedia() {
|
|
|
27
27
|
}
|
|
28
28
|
export async function normalizeImageForModel(bytes) {
|
|
29
29
|
const mod = await loadMedia();
|
|
30
|
-
if (!mod)
|
|
30
|
+
if (!mod) {
|
|
31
31
|
return bytes;
|
|
32
|
+
}
|
|
32
33
|
try {
|
|
33
34
|
const frame = firstFrame(await mod.image.decode(bytes));
|
|
34
35
|
const oriented = await mod.image.orientate(frame, { file: bytes });
|
|
@@ -39,11 +40,20 @@ export async function normalizeImageForModel(bytes) {
|
|
|
39
40
|
return bytes;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
43
|
+
export async function rasterToModelJpeg(raster) {
|
|
44
|
+
const mod = await loadMedia();
|
|
45
|
+
if (!mod) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const resized = await mod.image.resize(raster, { maxWidth: MAX_IMAGE_WIDTH });
|
|
49
|
+
return mod.image.encode(resized, { mimetype: 'image/jpeg' });
|
|
50
|
+
}
|
|
42
51
|
function firstFrame(decoded) {
|
|
43
52
|
if (!decoded.frames)
|
|
44
53
|
return decoded;
|
|
45
54
|
const [first] = decoded.frames;
|
|
46
|
-
if (!first)
|
|
55
|
+
if (!first) {
|
|
47
56
|
throw new Error('decoded image had no frames');
|
|
57
|
+
}
|
|
48
58
|
return first;
|
|
49
59
|
}
|
|
@@ -15,38 +15,52 @@ export function detectImageMime(bytes) {
|
|
|
15
15
|
return 'image/png';
|
|
16
16
|
if (isJpeg(bytes))
|
|
17
17
|
return 'image/jpeg';
|
|
18
|
-
if (isAvif(bytes))
|
|
18
|
+
if (isAvif(bytes)) {
|
|
19
19
|
return 'image/avif';
|
|
20
|
-
|
|
20
|
+
}
|
|
21
|
+
if (isHeif(bytes)) {
|
|
21
22
|
return 'image/heic';
|
|
22
|
-
|
|
23
|
+
}
|
|
24
|
+
if (isWebp(bytes)) {
|
|
23
25
|
return 'image/webp';
|
|
24
|
-
|
|
26
|
+
}
|
|
27
|
+
if (isGif(bytes)) {
|
|
25
28
|
return 'image/gif';
|
|
26
|
-
|
|
29
|
+
}
|
|
30
|
+
if (isBmp(bytes)) {
|
|
27
31
|
return 'image/bmp';
|
|
28
|
-
|
|
32
|
+
}
|
|
33
|
+
if (isTiff(bytes)) {
|
|
29
34
|
return 'image/tiff';
|
|
35
|
+
}
|
|
30
36
|
return null;
|
|
31
37
|
}
|
|
32
38
|
export function mapDeclaredToSniffed(declared) {
|
|
33
39
|
const normalized = declared.toLowerCase();
|
|
34
|
-
if (normalized === 'image/png')
|
|
40
|
+
if (normalized === 'image/png') {
|
|
35
41
|
return 'image/png';
|
|
36
|
-
|
|
42
|
+
}
|
|
43
|
+
if (normalized === 'image/jpeg' || normalized === 'image/jpg') {
|
|
37
44
|
return 'image/jpeg';
|
|
38
|
-
|
|
45
|
+
}
|
|
46
|
+
if (normalized === 'image/heic' || normalized === 'image/heif') {
|
|
39
47
|
return 'image/heic';
|
|
40
|
-
|
|
48
|
+
}
|
|
49
|
+
if (normalized === 'image/avif') {
|
|
41
50
|
return 'image/avif';
|
|
42
|
-
|
|
51
|
+
}
|
|
52
|
+
if (normalized === 'image/webp') {
|
|
43
53
|
return 'image/webp';
|
|
44
|
-
|
|
54
|
+
}
|
|
55
|
+
if (normalized === 'image/gif') {
|
|
45
56
|
return 'image/gif';
|
|
46
|
-
|
|
57
|
+
}
|
|
58
|
+
if (normalized === 'image/bmp' || normalized === 'image/x-ms-bmp') {
|
|
47
59
|
return 'image/bmp';
|
|
48
|
-
|
|
60
|
+
}
|
|
61
|
+
if (normalized === 'image/tiff' || normalized === 'image/tif') {
|
|
49
62
|
return 'image/tiff';
|
|
63
|
+
}
|
|
50
64
|
return null;
|
|
51
65
|
}
|
|
52
66
|
function isPng(bytes) {
|
|
@@ -73,8 +87,9 @@ function isHeif(bytes) {
|
|
|
73
87
|
const b9 = bytes[9];
|
|
74
88
|
const b10 = bytes[10];
|
|
75
89
|
const b11 = bytes[11];
|
|
76
|
-
if (b8 === undefined || b9 === undefined || b10 === undefined || b11 === undefined)
|
|
90
|
+
if (b8 === undefined || b9 === undefined || b10 === undefined || b11 === undefined) {
|
|
77
91
|
return false;
|
|
92
|
+
}
|
|
78
93
|
const brand = String.fromCharCode(b8, b9, b10, b11).toLowerCase();
|
|
79
94
|
return HEIF_BRANDS.has(brand);
|
|
80
95
|
}
|
|
@@ -85,13 +100,15 @@ function isAvif(bytes) {
|
|
|
85
100
|
return false;
|
|
86
101
|
}
|
|
87
102
|
const major = brandAt(bytes, 8);
|
|
88
|
-
if (major && AVIF_BRANDS.has(major))
|
|
103
|
+
if (major && AVIF_BRANDS.has(major)) {
|
|
89
104
|
return true;
|
|
105
|
+
}
|
|
90
106
|
const end = ftypBoxEnd(bytes);
|
|
91
107
|
for (let offset = 16; offset + 4 <= end; offset += 4) {
|
|
92
108
|
const compatible = brandAt(bytes, offset);
|
|
93
|
-
if (compatible && AVIF_BRANDS.has(compatible))
|
|
109
|
+
if (compatible && AVIF_BRANDS.has(compatible)) {
|
|
94
110
|
return true;
|
|
111
|
+
}
|
|
95
112
|
}
|
|
96
113
|
return false;
|
|
97
114
|
}
|
|
@@ -100,8 +117,9 @@ function brandAt(bytes, offset) {
|
|
|
100
117
|
const b = bytes[offset + 1];
|
|
101
118
|
const c = bytes[offset + 2];
|
|
102
119
|
const d = bytes[offset + 3];
|
|
103
|
-
if (a === undefined || b === undefined || c === undefined || d === undefined)
|
|
120
|
+
if (a === undefined || b === undefined || c === undefined || d === undefined) {
|
|
104
121
|
return null;
|
|
122
|
+
}
|
|
105
123
|
return String.fromCharCode(a, b, c, d).toLowerCase();
|
|
106
124
|
}
|
|
107
125
|
function ftypBoxEnd(bytes) {
|
|
@@ -131,8 +149,9 @@ function isGif(bytes) {
|
|
|
131
149
|
return false;
|
|
132
150
|
if (bytes[0] !== 0x47 || bytes[1] !== 0x49 || bytes[2] !== 0x46)
|
|
133
151
|
return false;
|
|
134
|
-
if (bytes[3] !== 0x38 || bytes[5] !== 0x61)
|
|
152
|
+
if (bytes[3] !== 0x38 || bytes[5] !== 0x61) {
|
|
135
153
|
return false;
|
|
154
|
+
}
|
|
136
155
|
return bytes[4] === 0x37 || bytes[4] === 0x39;
|
|
137
156
|
}
|
|
138
157
|
function isBmp(bytes) {
|
|
@@ -141,9 +160,11 @@ function isBmp(bytes) {
|
|
|
141
160
|
function isTiff(bytes) {
|
|
142
161
|
if (bytes.length < 4)
|
|
143
162
|
return false;
|
|
144
|
-
if (bytes[0] === 0x49 && bytes[1] === 0x49)
|
|
163
|
+
if (bytes[0] === 0x49 && bytes[1] === 0x49) {
|
|
145
164
|
return bytes[2] === 0x2a && bytes[3] === 0x00;
|
|
146
|
-
|
|
165
|
+
}
|
|
166
|
+
if (bytes[0] === 0x4d && bytes[1] === 0x4d) {
|
|
147
167
|
return bytes[2] === 0x00 && bytes[3] === 0x2a;
|
|
168
|
+
}
|
|
148
169
|
return false;
|
|
149
170
|
}
|
|
@@ -2,21 +2,24 @@ import b4a from 'b4a';
|
|
|
2
2
|
import { getAgent } from './agent.js';
|
|
3
3
|
import { getChat } from './chat.js';
|
|
4
4
|
import { NO_SUCH_AGENT, NOT_THE_HOST, SENDER_REVOKED } from './skill-secrets.js';
|
|
5
|
-
|
|
5
|
+
import { DEVICES } from './collections.js';
|
|
6
6
|
export const NO_SUCH_CHAT = 'no such chat on the device hosting this agent';
|
|
7
7
|
export const NO_RECORD_STORE = 'the device hosting this agent is not recording prompts right now';
|
|
8
8
|
const MAX_ANSWER_BYTES = 2 * 1024 * 1024;
|
|
9
9
|
export function createInferenceCallsReceiver(opts) {
|
|
10
10
|
return async (request, fromDeviceId) => {
|
|
11
11
|
const sender = await opts.mesh.view.get(DEVICES, { id: fromDeviceId });
|
|
12
|
-
if (!sender || sender.revoked)
|
|
12
|
+
if (!sender || sender.revoked) {
|
|
13
13
|
throw new Error(SENDER_REVOKED);
|
|
14
|
+
}
|
|
14
15
|
const chat = await getChat(opts.mesh, request.chatId);
|
|
15
|
-
if (!chat)
|
|
16
|
+
if (!chat) {
|
|
16
17
|
throw new Error(NO_SUCH_CHAT);
|
|
18
|
+
}
|
|
17
19
|
const agent = await getAgent(opts.mesh, chat.agentId);
|
|
18
|
-
if (!agent)
|
|
20
|
+
if (!agent) {
|
|
19
21
|
throw new Error(NO_SUCH_AGENT);
|
|
22
|
+
}
|
|
20
23
|
if (!agent.providerDeviceId || !b4a.equals(agent.providerDeviceId, opts.deviceId)) {
|
|
21
24
|
throw new Error(NOT_THE_HOST);
|
|
22
25
|
}
|
|
@@ -20,10 +20,12 @@ function inviteClaimMessage(binding) {
|
|
|
20
20
|
}
|
|
21
21
|
export function inviteGrantTermsRefusal(terms, mintedAt) {
|
|
22
22
|
const { expiresAt, maxUses } = terms;
|
|
23
|
-
if (!expiresAt)
|
|
23
|
+
if (!expiresAt) {
|
|
24
24
|
return INVITE_GRANT_NO_EXPIRY;
|
|
25
|
-
|
|
25
|
+
}
|
|
26
|
+
if (expiresAt > mintedAt + GRANT_MAX_TTL_MS) {
|
|
26
27
|
return INVITE_GRANT_TOO_LONG;
|
|
28
|
+
}
|
|
27
29
|
if (!maxUses || !Number.isInteger(maxUses) || maxUses < 1 || maxUses > GRANT_MAX_USES) {
|
|
28
30
|
return INVITE_GRANT_USES_OUT_OF_RANGE;
|
|
29
31
|
}
|
|
@@ -19,8 +19,9 @@ export function encodeMeshInvite(invite) {
|
|
|
19
19
|
}
|
|
20
20
|
export function decodeMeshInvite(raw) {
|
|
21
21
|
const value = raw.trim().toLowerCase();
|
|
22
|
-
if (!value.startsWith(INVITE_PREFIX))
|
|
22
|
+
if (!value.startsWith(INVITE_PREFIX)) {
|
|
23
23
|
return null;
|
|
24
|
+
}
|
|
24
25
|
let payload;
|
|
25
26
|
try {
|
|
26
27
|
payload = decodeStruct(INVITE_STRUCT, z32.decode(value.slice(INVITE_PREFIX.length)));
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
|
|
3
|
-
const FILES_BY_BLOB = '@local/files-by-blob';
|
|
4
|
-
const RECLAIMABLE_FILES = '@local/reclaimable-files-by-last-accessed';
|
|
5
|
-
const LIVE_FILES = '@local/live-files';
|
|
6
|
-
const CONFIG = '@local/config';
|
|
2
|
+
import { LOCAL_CONFIG, LOCAL_FILES, LOCAL_FILES_BY_BLOB, LOCAL_LIVE_FILES, LOCAL_RECLAIMABLE_FILES_BY_LAST_ACCESSED } from '../collections.js';
|
|
7
3
|
const TOUCH_GRAIN_MS = 60 * 60 * 1000;
|
|
8
4
|
export class LocalFiles {
|
|
9
5
|
_db;
|
|
@@ -59,12 +55,12 @@ export class LocalFiles {
|
|
|
59
55
|
const tx = this._db.transaction();
|
|
60
56
|
let changed = false;
|
|
61
57
|
for (const file of files) {
|
|
62
|
-
const known = await tx.get(
|
|
58
|
+
const known = await tx.get(LOCAL_FILES, keyOf(file));
|
|
63
59
|
const row = next(file, known);
|
|
64
60
|
if (!row) {
|
|
65
61
|
continue;
|
|
66
62
|
}
|
|
67
|
-
await tx.insert(
|
|
63
|
+
await tx.insert(LOCAL_FILES, row);
|
|
68
64
|
changed = true;
|
|
69
65
|
}
|
|
70
66
|
if (changed) {
|
|
@@ -78,45 +74,50 @@ export class LocalFiles {
|
|
|
78
74
|
markCleared(file) {
|
|
79
75
|
return this._locked(async () => {
|
|
80
76
|
const tx = this._db.transaction();
|
|
81
|
-
const known = await tx.get(
|
|
77
|
+
const known = await tx.get(LOCAL_FILES, keyOf(file));
|
|
82
78
|
if (!known) {
|
|
83
79
|
await tx.close();
|
|
84
80
|
return;
|
|
85
81
|
}
|
|
86
|
-
await tx.insert(
|
|
82
|
+
await tx.insert(LOCAL_FILES, { ...known, cleared: true });
|
|
87
83
|
await tx.flush();
|
|
88
84
|
});
|
|
89
85
|
}
|
|
90
86
|
async meshOf(coreKey, blockOffset) {
|
|
91
87
|
const key = { coreKey, blockOffset };
|
|
92
|
-
const row = await this._db.findOne(
|
|
88
|
+
const row = await this._db.findOne(LOCAL_FILES_BY_BLOB, { gte: key, lte: key });
|
|
93
89
|
return row?.meshKey ?? null;
|
|
94
90
|
}
|
|
95
91
|
async backfilled(meshKey) {
|
|
96
|
-
return (await this._db.get(
|
|
92
|
+
return ((await this._db.get(LOCAL_CONFIG, { key: backfillKey(meshKey) })) !== null);
|
|
97
93
|
}
|
|
98
94
|
markBackfilled(meshKey) {
|
|
99
95
|
return this._locked(async () => {
|
|
100
96
|
const tx = this._db.transaction();
|
|
101
|
-
await tx.insert(
|
|
97
|
+
await tx.insert(LOCAL_CONFIG, { key: backfillKey(meshKey), value: true });
|
|
102
98
|
await tx.flush();
|
|
103
99
|
});
|
|
104
100
|
}
|
|
105
101
|
list(meshKey) {
|
|
106
|
-
return this._db.find(
|
|
102
|
+
return this._db.find(LOCAL_FILES, meshRange(meshKey)).toArray();
|
|
107
103
|
}
|
|
108
104
|
live(meshKey) {
|
|
109
|
-
return this._db.find(
|
|
105
|
+
return this._db.find(LOCAL_LIVE_FILES, meshRange(meshKey)).toArray();
|
|
110
106
|
}
|
|
111
107
|
stale(cutoff) {
|
|
112
|
-
return this._db
|
|
108
|
+
return this._db
|
|
109
|
+
.find(LOCAL_RECLAIMABLE_FILES_BY_LAST_ACCESSED, { lt: { lastAccessed: cutoff } })
|
|
110
|
+
.toArray();
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
113
|
export async function dropMeshFiles(tx, meshKey) {
|
|
116
|
-
const rows = await tx
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
const rows = await tx
|
|
115
|
+
.find(LOCAL_FILES, { gte: { meshKey }, lte: { meshKey } })
|
|
116
|
+
.toArray();
|
|
117
|
+
for (const row of rows) {
|
|
118
|
+
await tx.delete(LOCAL_FILES, keyOf(row));
|
|
119
|
+
}
|
|
120
|
+
await tx.delete(LOCAL_CONFIG, { key: backfillKey(meshKey) });
|
|
120
121
|
}
|
|
121
122
|
function meshRange(meshKey) {
|
|
122
123
|
return meshKey ? { gte: { meshKey }, lte: { meshKey } } : {};
|