@qvac/core 0.5.0 → 0.6.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/CHANGELOG.md +92 -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 +31 -11
- package/dist-lib/lib/assistant.js +846 -390
- 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 +50 -31
- 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 +70 -0
- package/dist-lib/lib/core/collections.js +70 -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.d.ts +2 -0
- package/dist-lib/lib/core/contract/chat.js +67 -1
- package/dist-lib/lib/core/contract/chunks.js +15 -9
- package/dist-lib/lib/core/contract/compute.d.ts +1 -1
- package/dist-lib/lib/core/contract/compute.js +4 -2
- 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 +10 -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 +46 -52
- package/dist-lib/lib/core/files/index.js +149 -94
- package/dist-lib/lib/core/files/knowledge.d.ts +2 -5
- package/dist-lib/lib/core/files/local-index.d.ts +4 -1
- 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 +21 -13
- package/dist-lib/lib/core/files/processing/index.js +74 -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 +14 -11
- package/dist-lib/lib/core/files/processing/state.js +24 -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 +12 -13
- package/dist-lib/lib/core/files/rag/index.js +9 -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/index.d.ts +1 -0
- package/dist-lib/lib/core/files/records/index.js +1 -0
- 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/purge.d.ts +4 -0
- package/dist-lib/lib/core/files/records/purge.js +108 -0
- package/dist-lib/lib/core/files/records/reclaim.js +43 -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 +11 -10
- package/dist-lib/lib/core/files/store/blob.js +54 -19
- package/dist-lib/lib/core/files/store/index.d.ts +2 -6
- package/dist-lib/lib/core/files/store/index.js +10 -5
- 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.d.ts +2 -0
- package/dist-lib/lib/core/local/files.js +51 -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 +33 -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 +1009 -541
- package/dist-lib/lib/credential-pusher.d.ts +20 -20
- package/dist-lib/lib/credential-pusher.js +65 -43
- 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 +18 -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/db.json +16 -1
- package/dist-lib/spec/mesh/hyperdb/index.js +72 -3
- package/dist-lib/spec/mesh/hyperdb/messages.js +400 -221
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +7 -1
- package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +117 -2
- package/dist-lib/spec/mesh/hyperschema/index.js +117 -2
- package/dist-lib/spec/mesh/hyperschema/schema.json +65 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +19 -1
- package/package.json +8 -4
- package/tui/app.mjs +2424 -941
- package/tui/boot.mjs +18 -49
- 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
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import crypto from 'hypercore-crypto';
|
|
2
2
|
import { parseBlobReferenceCoreKey } from './files/index.js';
|
|
3
3
|
import { Mesh } from './mesh.js';
|
|
4
|
-
|
|
5
|
-
const ACTIVE_AGENTS = '@qvac/active-agents';
|
|
6
|
-
const ACTIVE_CHATS = '@qvac/active-chats';
|
|
7
|
-
const ACTIVE_CHAT_GROUPS = '@qvac/active-chat-groups';
|
|
8
|
-
const ACTIVE_TOOL_CONFIGS_BY_AGENT = '@qvac/active-tool-configs-by-agent';
|
|
9
|
-
const CHUNKS = '@qvac/chunks';
|
|
10
|
-
const CHUNKS_BY_CHAT = '@qvac/chunks-by-chat';
|
|
11
|
-
const KNOWLEDGE = '@qvac/knowledge';
|
|
4
|
+
import { ACTIVE_AGENTS, ACTIVE_CHATS, ACTIVE_CHAT_GROUPS, ACTIVE_TOOL_CONFIGS_BY_AGENT, AGENTS, CHUNKS, CHUNKS_BY_CHAT, KNOWLEDGE } from './collections.js';
|
|
12
5
|
const MIGRATED_SUFFIX = ' (migrated)';
|
|
13
6
|
export const NO_ARCHIVE_HELD = 'No archive is held for this mesh';
|
|
14
|
-
export async function withArchivedMesh(
|
|
15
|
-
if (!(await opts.storage.hasCore(crypto.discoveryKey(row.key))))
|
|
7
|
+
export async function withArchivedMesh(row, opts, fn) {
|
|
8
|
+
if (!(await opts.storage.hasCore(crypto.discoveryKey(row.key)))) {
|
|
16
9
|
throw new Error(NO_ARCHIVE_HELD);
|
|
17
|
-
|
|
10
|
+
}
|
|
11
|
+
const mesh = new Mesh(opts.store, {
|
|
18
12
|
seed: row.seed,
|
|
19
13
|
key: row.key,
|
|
20
14
|
deviceId: opts.deviceId,
|
|
@@ -23,8 +17,9 @@ export async function withArchivedMesh(store, row, opts, fn) {
|
|
|
23
17
|
});
|
|
24
18
|
await mesh.ready();
|
|
25
19
|
try {
|
|
26
|
-
if (mesh.localLength === 0)
|
|
20
|
+
if (mesh.localLength === 0) {
|
|
27
21
|
throw new Error(NO_ARCHIVE_HELD);
|
|
22
|
+
}
|
|
28
23
|
await mesh.autobee.update();
|
|
29
24
|
return await fn(mesh);
|
|
30
25
|
}
|
|
@@ -46,12 +41,14 @@ export async function countContents(mesh, into) {
|
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
async function countAgents(snap, into) {
|
|
49
|
-
if (!into)
|
|
44
|
+
if (!into) {
|
|
50
45
|
return count(snap.find(ACTIVE_AGENTS));
|
|
46
|
+
}
|
|
51
47
|
let appendable = 0;
|
|
52
48
|
for (const row of await snap.find(ACTIVE_AGENTS).toArray()) {
|
|
53
|
-
if (!(await alreadyHeld(into, row)))
|
|
49
|
+
if (!(await alreadyHeld(into, row))) {
|
|
54
50
|
appendable++;
|
|
51
|
+
}
|
|
55
52
|
}
|
|
56
53
|
return appendable;
|
|
57
54
|
}
|
|
@@ -63,13 +60,16 @@ export async function migrateContents(from, into) {
|
|
|
63
60
|
const knowledge = await liveKnowledge(snap);
|
|
64
61
|
const batch = into.batch();
|
|
65
62
|
const agents = await migrateAgents(snap, into, batch);
|
|
66
|
-
for (const group of groups)
|
|
63
|
+
for (const group of groups) {
|
|
67
64
|
batch.dispatch('put-chat-group', { group: stripped(group) });
|
|
68
|
-
|
|
65
|
+
}
|
|
66
|
+
for (const chat of chats) {
|
|
69
67
|
batch.dispatch('put-chat', { chat: stripped(chat) });
|
|
68
|
+
}
|
|
70
69
|
await batch.flush();
|
|
71
|
-
for (const chat of chats)
|
|
72
|
-
await migrateChunks(snap, from, into
|
|
70
|
+
for (const chat of chats) {
|
|
71
|
+
await migrateChunks(snap, chat.id, { from, into });
|
|
72
|
+
}
|
|
73
73
|
let carried = 0;
|
|
74
74
|
for (const row of knowledge) {
|
|
75
75
|
if (await into.view.get(KNOWLEDGE, { id: row.id })) {
|
|
@@ -77,8 +77,9 @@ export async function migrateContents(from, into) {
|
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
79
79
|
const blobId = await copyBlob(from, into, row.blobId);
|
|
80
|
-
if (!blobId)
|
|
80
|
+
if (!blobId) {
|
|
81
81
|
continue;
|
|
82
|
+
}
|
|
82
83
|
batch.dispatch('add-knowledge', { knowledge: { ...stripped(row), blobId } });
|
|
83
84
|
await batch.flush();
|
|
84
85
|
carried++;
|
|
@@ -113,7 +114,7 @@ async function migrateAgents(snap, into, batch) {
|
|
|
113
114
|
async function alreadyHeld(into, row) {
|
|
114
115
|
return !!(await into.view.get(AGENTS, { id: row.id }));
|
|
115
116
|
}
|
|
116
|
-
async function migrateChunks(snap, from, into
|
|
117
|
+
async function migrateChunks(snap, chatId, { from, into }) {
|
|
117
118
|
const chunks = await snap
|
|
118
119
|
.find(CHUNKS_BY_CHAT, { gte: { chatId }, lte: { chatId } })
|
|
119
120
|
.toArray();
|
|
@@ -127,8 +128,9 @@ async function migrateChunks(snap, from, into, chatId) {
|
|
|
127
128
|
continue;
|
|
128
129
|
}
|
|
129
130
|
const blobId = await copyBlob(from, into, attachment.blobId);
|
|
130
|
-
if (!blobId)
|
|
131
|
+
if (!blobId) {
|
|
131
132
|
continue;
|
|
133
|
+
}
|
|
132
134
|
batch.dispatch('append-chunk', { ...op, attachment: { ...attachment, blobId } });
|
|
133
135
|
await batch.flush();
|
|
134
136
|
await into.fileIndex?.record([{ ...chunk, attachment: { ...attachment, blobId } }]);
|
|
@@ -157,7 +159,8 @@ async function liveKnowledge(snap) {
|
|
|
157
159
|
}
|
|
158
160
|
async function count(stream) {
|
|
159
161
|
let total = 0;
|
|
160
|
-
for await (const _row of stream)
|
|
162
|
+
for await (const _row of stream) {
|
|
161
163
|
total++;
|
|
164
|
+
}
|
|
162
165
|
return total;
|
|
163
166
|
}
|
|
@@ -48,14 +48,19 @@ export function toAsyncIterable(streamOrIterable) {
|
|
|
48
48
|
return { done: true, value: undefined };
|
|
49
49
|
},
|
|
50
50
|
next() {
|
|
51
|
-
if (!queue.length && !ended && !error)
|
|
51
|
+
if (!queue.length && !ended && !error) {
|
|
52
52
|
stream.resume?.();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
}
|
|
54
|
+
if (queue.length) {
|
|
55
|
+
const [value] = queue.splice(0, 1);
|
|
56
|
+
return Promise.resolve({ value, done: false });
|
|
57
|
+
}
|
|
58
|
+
if (ended) {
|
|
56
59
|
return Promise.resolve({ value: undefined, done: true });
|
|
57
|
-
|
|
60
|
+
}
|
|
61
|
+
if (error) {
|
|
58
62
|
return Promise.reject(error);
|
|
63
|
+
}
|
|
59
64
|
return new Promise((resolve, reject) => {
|
|
60
65
|
waiting = { resolve, reject };
|
|
61
66
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface LinkableAttachment {
|
|
2
2
|
readonly blobId: string;
|
|
3
3
|
readonly mimeType: string;
|
|
4
4
|
readonly deletedAt?: number;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
6
|
export type AttachmentUrl = (attachment: LinkableAttachment) => string | null;
|
|
7
7
|
export declare function linkAttachment<T extends LinkableAttachment>(mint: AttachmentUrl | null, attachment: T): T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface BlindPeeringOpts {
|
|
2
2
|
readonly batchIdleWait?: number;
|
|
3
3
|
readonly batchMaxWait?: number;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
5
|
export declare const BLIND_RELAY_KEYS: ReadonlyArray<Buffer>;
|
|
6
6
|
export declare const BLIND_PEER_KEYS: ReadonlyArray<Buffer>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Mesh } from './mesh.ts';
|
|
2
2
|
export type ChatActivityState = 'queued' | 'running' | 'generating-image' | 'generating-audio' | 'transcribing-audio' | 'awaiting-approval';
|
|
3
|
-
export
|
|
3
|
+
export interface ChatActivityRow {
|
|
4
4
|
readonly id: string;
|
|
5
5
|
readonly activityState: ChatActivityState;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
export declare function listChatActivity(store: Mesh, chatIds?: ReadonlyArray<string>): Promise<ChatActivityRow[]>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import ScopeLock from 'scope-lock';
|
|
2
2
|
import { findChunksOfType } from './chunk.js';
|
|
3
|
-
|
|
4
|
-
const CHUNKS = '@qvac/chunks';
|
|
3
|
+
import { ACTIVE_CHATS, CHUNKS } from './collections.js';
|
|
5
4
|
const TERMINAL_RUN_STATES = new Set(['completed', 'failed', 'canceled']);
|
|
6
5
|
const ACTIVITY_CHUNK_TYPES = [
|
|
7
6
|
'run-request',
|
|
@@ -44,7 +43,7 @@ class ChatActivityCatalog {
|
|
|
44
43
|
return [...this._states()]
|
|
45
44
|
.filter(([id]) => !window || window.has(id))
|
|
46
45
|
.map(([id, activityState]) => ({ id, activityState }))
|
|
47
|
-
.sort((left, right) => (left.id
|
|
46
|
+
.sort((left, right) => compareIds(left.id, right.id));
|
|
48
47
|
}
|
|
49
48
|
finally {
|
|
50
49
|
await snap.close();
|
|
@@ -69,26 +68,30 @@ class ChatActivityCatalog {
|
|
|
69
68
|
}
|
|
70
69
|
async _rebuild(snap, activeChatIds) {
|
|
71
70
|
this._chats.clear();
|
|
72
|
-
for (const chatId of activeChatIds)
|
|
71
|
+
for (const chatId of activeChatIds) {
|
|
73
72
|
await this._loadChat(snap, chatId);
|
|
73
|
+
}
|
|
74
74
|
}
|
|
75
75
|
_prune(activeChatIds) {
|
|
76
76
|
for (const chatId of this._chats.keys()) {
|
|
77
|
-
if (!activeChatIds.has(chatId))
|
|
77
|
+
if (!activeChatIds.has(chatId)) {
|
|
78
78
|
this._chats.delete(chatId);
|
|
79
|
+
}
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
async _loadMissing(snap, activeChatIds) {
|
|
82
83
|
for (const chatId of activeChatIds) {
|
|
83
|
-
if (!this._chats.has(chatId))
|
|
84
|
+
if (!this._chats.has(chatId)) {
|
|
84
85
|
await this._loadChat(snap, chatId);
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
async _loadChat(snap, chatId) {
|
|
88
90
|
const activity = { runs: new Map() };
|
|
89
91
|
this._chats.set(chatId, activity);
|
|
90
|
-
for (const chunk of await activityChunks(snap, chatId))
|
|
92
|
+
for (const chunk of await activityChunks(snap, chatId)) {
|
|
91
93
|
applyChunk(activity, chunk);
|
|
94
|
+
}
|
|
92
95
|
}
|
|
93
96
|
async _applyChanges(snap, from, activeChatIds) {
|
|
94
97
|
const chunksByChat = new Map();
|
|
@@ -97,19 +100,22 @@ class ChatActivityCatalog {
|
|
|
97
100
|
continue;
|
|
98
101
|
if (change.type === 'delete')
|
|
99
102
|
return false;
|
|
100
|
-
if (!activeChatIds.has(change.value.chatId))
|
|
103
|
+
if (!activeChatIds.has(change.value.chatId)) {
|
|
101
104
|
continue;
|
|
105
|
+
}
|
|
102
106
|
const chunks = chunksByChat.get(change.value.chatId) ?? [];
|
|
103
107
|
chunks.push(change.value);
|
|
104
108
|
chunksByChat.set(change.value.chatId, chunks);
|
|
105
109
|
}
|
|
106
110
|
for (const [chatId, chunks] of chunksByChat) {
|
|
107
111
|
const activity = this._chats.get(chatId);
|
|
108
|
-
if (!activity)
|
|
112
|
+
if (!activity) {
|
|
109
113
|
continue;
|
|
114
|
+
}
|
|
110
115
|
chunks.sort((left, right) => left.seq - right.seq);
|
|
111
|
-
for (const chunk of chunks)
|
|
116
|
+
for (const chunk of chunks) {
|
|
112
117
|
applyChunk(activity, chunk);
|
|
118
|
+
}
|
|
113
119
|
}
|
|
114
120
|
return true;
|
|
115
121
|
}
|
|
@@ -117,19 +123,22 @@ class ChatActivityCatalog {
|
|
|
117
123
|
const states = new Map();
|
|
118
124
|
for (const [chatId, { runs }] of this._chats) {
|
|
119
125
|
const active = [...runs.values()];
|
|
120
|
-
if (active.length === 0)
|
|
126
|
+
if (active.length === 0) {
|
|
121
127
|
continue;
|
|
128
|
+
}
|
|
122
129
|
states.set(chatId, activityState(active));
|
|
123
130
|
}
|
|
124
131
|
return states;
|
|
125
132
|
}
|
|
126
133
|
}
|
|
127
134
|
function activityState(runs) {
|
|
128
|
-
if (runs.some((run) => run.pendingApprovals.size > 0))
|
|
135
|
+
if (runs.some((run) => run.pendingApprovals.size > 0)) {
|
|
129
136
|
return 'awaiting-approval';
|
|
137
|
+
}
|
|
130
138
|
const started = runs.filter((run) => run.started);
|
|
131
|
-
if (started.length === 0)
|
|
139
|
+
if (started.length === 0) {
|
|
132
140
|
return 'queued';
|
|
141
|
+
}
|
|
133
142
|
return mediaState(latestRun(started)) ?? 'running';
|
|
134
143
|
}
|
|
135
144
|
function mediaState(run) {
|
|
@@ -137,14 +146,16 @@ function mediaState(run) {
|
|
|
137
146
|
const tool = latestTool(run.tools);
|
|
138
147
|
return tool && AUDIO_TOOLS.has(tool.name) ? 'generating-audio' : 'generating-image';
|
|
139
148
|
}
|
|
140
|
-
if (run.progress === 'transcribing')
|
|
149
|
+
if (run.progress === 'transcribing') {
|
|
141
150
|
return 'transcribing-audio';
|
|
151
|
+
}
|
|
142
152
|
return null;
|
|
143
153
|
}
|
|
144
154
|
function applyChunk(activity, chunk) {
|
|
145
155
|
const runId = chunk.runId;
|
|
146
|
-
if (!runId)
|
|
156
|
+
if (!runId) {
|
|
147
157
|
return;
|
|
158
|
+
}
|
|
148
159
|
if (chunk.type === 'run-request') {
|
|
149
160
|
const existing = activity.runs.get(runId);
|
|
150
161
|
if (existing) {
|
|
@@ -155,8 +166,9 @@ function applyChunk(activity, chunk) {
|
|
|
155
166
|
return;
|
|
156
167
|
}
|
|
157
168
|
const run = activity.runs.get(runId);
|
|
158
|
-
if (!run)
|
|
169
|
+
if (!run) {
|
|
159
170
|
return;
|
|
171
|
+
}
|
|
160
172
|
run.started = true;
|
|
161
173
|
if (run.seen.has(chunk.id)) {
|
|
162
174
|
applyMutableChunk(run, chunk);
|
|
@@ -180,12 +192,14 @@ function applyChunk(activity, chunk) {
|
|
|
180
192
|
applyApproval(run, chunk);
|
|
181
193
|
return;
|
|
182
194
|
}
|
|
183
|
-
if (chunk.seq <= run.attemptSeq)
|
|
195
|
+
if (chunk.seq <= run.attemptSeq) {
|
|
184
196
|
return;
|
|
197
|
+
}
|
|
185
198
|
if (chunk.type === 'tool-call') {
|
|
186
199
|
const name = chunk.toolCall?.name;
|
|
187
|
-
if (name && MEDIA_TOOLS.has(name))
|
|
200
|
+
if (name && MEDIA_TOOLS.has(name)) {
|
|
188
201
|
run.tools.push({ name, seq: chunk.seq });
|
|
202
|
+
}
|
|
189
203
|
}
|
|
190
204
|
else if (chunk.type === 'tool-result') {
|
|
191
205
|
settleTool(run.tools, chunk.toolResult?.name ?? '');
|
|
@@ -213,13 +227,15 @@ function applyMutableChunk(run, chunk) {
|
|
|
213
227
|
}
|
|
214
228
|
}
|
|
215
229
|
function applyApproval(run, chunk) {
|
|
216
|
-
if (chunk.approvalRequest?.status === 'pending')
|
|
230
|
+
if (chunk.approvalRequest?.status === 'pending') {
|
|
217
231
|
run.pendingApprovals.add(chunk.id);
|
|
218
|
-
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
219
234
|
run.pendingApprovals.delete(chunk.id);
|
|
235
|
+
}
|
|
220
236
|
}
|
|
221
237
|
async function activityChunks(snap, chatId) {
|
|
222
|
-
const groups = await Promise.all(ACTIVITY_CHUNK_TYPES.map((type) => findChunksOfType(snap, chatId, type)));
|
|
238
|
+
const groups = await Promise.all(ACTIVITY_CHUNK_TYPES.map((type) => findChunksOfType(snap, { chatId, type })));
|
|
223
239
|
return groups.flat().sort((left, right) => left.seq - right.seq);
|
|
224
240
|
}
|
|
225
241
|
function settleTool(tools, name) {
|
|
@@ -236,3 +252,8 @@ function latestTool(tools) {
|
|
|
236
252
|
function latestRun(runs) {
|
|
237
253
|
return runs.reduce((latest, run) => (run.requestSeq > latest.requestSeq ? run : latest));
|
|
238
254
|
}
|
|
255
|
+
function compareIds(left, right) {
|
|
256
|
+
if (left < right)
|
|
257
|
+
return -1;
|
|
258
|
+
return left > right ? 1 : 0;
|
|
259
|
+
}
|
|
@@ -8,12 +8,14 @@ export declare function listChatGroups(store: Mesh): Promise<QvacChatGroup[]>;
|
|
|
8
8
|
export declare function getChatGroup(store: Mesh, id: string): Promise<QvacChatGroup | null>;
|
|
9
9
|
export declare function mustGetChatGroup(store: Mesh, id: string): Promise<QvacChatGroup>;
|
|
10
10
|
export declare function mustGetActiveChatGroup(store: Mesh, id: string): Promise<QvacChatGroup>;
|
|
11
|
-
export
|
|
12
|
-
name: string;
|
|
13
|
-
}
|
|
11
|
+
export interface CreateChatGroupInput {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createChatGroup(store: Mesh, input: CreateChatGroupInput): Promise<QvacChatGroup>;
|
|
14
15
|
export declare function renameChatGroup(store: Mesh, id: string, name: string): Promise<QvacChatGroup>;
|
|
15
|
-
export
|
|
16
|
-
afterId?: string | null;
|
|
17
|
-
}
|
|
16
|
+
export interface MoveChatGroupOptions {
|
|
17
|
+
readonly afterId?: string | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function moveChatGroup(store: Mesh, id: string, { afterId }: MoveChatGroupOptions): Promise<QvacChatGroup>;
|
|
18
20
|
export declare function sortChatGroupsByName(store: Mesh): Promise<QvacChatGroup[]>;
|
|
19
21
|
export declare function deleteChatGroup(store: Mesh, id: string): Promise<QvacChatGroup>;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { randomId } from './id.js';
|
|
2
2
|
import { place } from './rank.js';
|
|
3
|
-
|
|
4
|
-
const ACTIVE_CHAT_GROUPS = '@qvac/active-chat-groups';
|
|
3
|
+
import { ACTIVE_CHAT_GROUPS, CHAT_GROUPS } from './collections.js';
|
|
5
4
|
const NAME_MAX_LENGTH = 100;
|
|
6
5
|
export function groupSortKey(group) {
|
|
7
6
|
return group.rank || 0;
|
|
8
7
|
}
|
|
9
8
|
export function byGroupOrder(a, b) {
|
|
10
9
|
const ranked = groupSortKey(b) - groupSortKey(a);
|
|
11
|
-
if (ranked)
|
|
10
|
+
if (ranked) {
|
|
12
11
|
return ranked;
|
|
12
|
+
}
|
|
13
13
|
const an = a.name.toLowerCase();
|
|
14
14
|
const bn = b.name.toLowerCase();
|
|
15
|
-
if (an !== bn)
|
|
15
|
+
if (an !== bn) {
|
|
16
16
|
return an < bn ? -1 : 1;
|
|
17
|
+
}
|
|
17
18
|
return a.id < b.id ? -1 : 1;
|
|
18
19
|
}
|
|
19
20
|
export async function listChatGroupsIn(snap) {
|
|
@@ -41,20 +42,23 @@ export async function getChatGroup(store, id) {
|
|
|
41
42
|
}
|
|
42
43
|
export async function mustGetChatGroup(store, id) {
|
|
43
44
|
const group = await getChatGroup(store, id);
|
|
44
|
-
if (!group)
|
|
45
|
+
if (!group) {
|
|
45
46
|
throw new Error(`chat group not found: ${id}`);
|
|
47
|
+
}
|
|
46
48
|
return group;
|
|
47
49
|
}
|
|
48
50
|
export async function mustGetActiveChatGroup(store, id) {
|
|
49
51
|
const group = await mustGetChatGroup(store, id);
|
|
50
|
-
if (group.deletedAt)
|
|
52
|
+
if (group.deletedAt) {
|
|
51
53
|
throw new Error(`chat group not found: ${id}`);
|
|
54
|
+
}
|
|
52
55
|
return group;
|
|
53
56
|
}
|
|
54
57
|
function assertGroupName(name) {
|
|
55
58
|
const trimmed = name.trim();
|
|
56
|
-
if (!trimmed)
|
|
59
|
+
if (!trimmed) {
|
|
57
60
|
throw new Error('chat group name is required');
|
|
61
|
+
}
|
|
58
62
|
if (trimmed.length > NAME_MAX_LENGTH) {
|
|
59
63
|
throw new Error(`chat group name exceeds ${NAME_MAX_LENGTH} characters`);
|
|
60
64
|
}
|
|
@@ -83,23 +87,26 @@ export async function renameChatGroup(store, id, name) {
|
|
|
83
87
|
}
|
|
84
88
|
export async function moveChatGroup(store, id, { afterId }) {
|
|
85
89
|
const anchor = afterId || undefined;
|
|
86
|
-
if (anchor === id)
|
|
90
|
+
if (anchor === id) {
|
|
87
91
|
throw new Error(`a chat group cannot be placed after itself: ${id}`);
|
|
92
|
+
}
|
|
88
93
|
const now = Date.now();
|
|
89
94
|
const snap = store.view.snapshot();
|
|
90
95
|
let current;
|
|
91
96
|
let placement;
|
|
92
97
|
try {
|
|
93
98
|
const group = await snap.get(CHAT_GROUPS, { id });
|
|
94
|
-
if (!group || group.deletedAt)
|
|
99
|
+
if (!group || group.deletedAt) {
|
|
95
100
|
throw new Error(`chat group not found: ${id}`);
|
|
101
|
+
}
|
|
96
102
|
current = group;
|
|
97
103
|
const siblings = (await listChatGroupsIn(snap)).filter((sibling) => sibling.id !== id);
|
|
98
104
|
let at = -1;
|
|
99
105
|
if (anchor) {
|
|
100
106
|
at = siblings.findIndex((sibling) => sibling.id === anchor);
|
|
101
|
-
if (at === -1)
|
|
107
|
+
if (at === -1) {
|
|
102
108
|
throw new Error(`chat group not found: ${anchor}`);
|
|
109
|
+
}
|
|
103
110
|
}
|
|
104
111
|
placement = place(siblings, groupSortKey, { at, now });
|
|
105
112
|
}
|
|
@@ -2,19 +2,21 @@ import { type Sidebar } from './chat.ts';
|
|
|
2
2
|
import type { openLocalStore } from './local/index.ts';
|
|
3
3
|
import type { Mesh } from './mesh.ts';
|
|
4
4
|
type LocalStore = ReturnType<typeof openLocalStore>;
|
|
5
|
-
export
|
|
6
|
-
rank?: number;
|
|
7
|
-
rankedAt?: number;
|
|
8
|
-
lastActivityAt: number;
|
|
9
|
-
}
|
|
5
|
+
export interface RankedChat {
|
|
6
|
+
readonly rank?: number;
|
|
7
|
+
readonly rankedAt?: number;
|
|
8
|
+
readonly lastActivityAt: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function chatSortKey(chat: RankedChat): number;
|
|
10
11
|
export declare function sortKeyBytes(value: number): Buffer;
|
|
11
12
|
export declare function refreshChatOrder(mesh: Mesh, local: LocalStore, chatIds: Iterable<string>): Promise<void>;
|
|
12
13
|
export declare function rebuildChatOrder(mesh: Mesh, local: LocalStore): Promise<void>;
|
|
13
14
|
export interface ChatPage extends Sidebar {
|
|
14
15
|
readonly nextCursor?: string;
|
|
15
16
|
}
|
|
16
|
-
export
|
|
17
|
-
limit?: number;
|
|
18
|
-
cursor?: string;
|
|
19
|
-
}
|
|
17
|
+
export interface ListChatPageOptions {
|
|
18
|
+
readonly limit?: number;
|
|
19
|
+
readonly cursor?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function listChatPage(mesh: Mesh, local: LocalStore, { limit, cursor }?: ListChatPageOptions): Promise<ChatPage>;
|
|
20
22
|
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { enrichAll } from './chat.js';
|
|
3
3
|
import { listChatGroupsIn } from './chat-group.js';
|
|
4
|
-
|
|
5
|
-
const ACTIVE_CHATS = '@qvac/active-chats';
|
|
6
|
-
const CHUNK_COUNTERS = '@qvac/chunk-counters';
|
|
4
|
+
import { ACTIVE_CHATS, CHATS, CHUNK_COUNTERS } from './collections.js';
|
|
7
5
|
export function chatSortKey(chat) {
|
|
8
6
|
return chat.rank && (chat.rankedAt ?? 0) >= chat.lastActivityAt ? chat.rank : chat.lastActivityAt;
|
|
9
7
|
}
|
|
@@ -2,16 +2,16 @@ import type { AbortSignal } from 'bare-abort-controller';
|
|
|
2
2
|
import { type ChatListing } from './chat.ts';
|
|
3
3
|
import type { Mesh } from './mesh.ts';
|
|
4
4
|
export type ChatSearchMatch = 'title' | 'content';
|
|
5
|
-
export
|
|
5
|
+
export interface ChatSearchHit {
|
|
6
6
|
readonly chat: ChatListing;
|
|
7
7
|
readonly match: ChatSearchMatch;
|
|
8
8
|
readonly snippet: string;
|
|
9
9
|
readonly chunkId: string;
|
|
10
10
|
readonly runId: string;
|
|
11
|
-
}
|
|
12
|
-
export
|
|
11
|
+
}
|
|
12
|
+
export interface ChatSearchInput {
|
|
13
13
|
readonly query: string;
|
|
14
14
|
readonly limit?: number;
|
|
15
15
|
readonly signal?: AbortSignal;
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
export declare function searchChats(store: Mesh, input: ChatSearchInput): Promise<ReadonlyArray<ChatSearchHit>>;
|