@qvac/core 1.0.0-rc.1 → 1.0.0-rc.3
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 +1008 -1
- package/README.md +40 -81
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/index.js +1 -1
- package/dist-lib/lib/api/agent-folders.d.ts +22 -0
- package/dist-lib/lib/api/agent-folders.js +115 -0
- package/dist-lib/lib/api/agents.d.ts +19 -2
- package/dist-lib/lib/api/agents.js +121 -24
- package/dist-lib/lib/api/app-config.d.ts +4 -1
- package/dist-lib/lib/api/app-config.js +17 -6
- package/dist-lib/lib/api/attachments.js +3 -2
- package/dist-lib/lib/api/chat-move.d.ts +4 -0
- package/dist-lib/lib/api/chat-move.js +7 -0
- package/dist-lib/lib/api/chat.d.ts +13 -2
- package/dist-lib/lib/api/chat.js +114 -9
- package/dist-lib/lib/api/chunk-delta.d.ts +12 -0
- package/dist-lib/lib/api/chunk-delta.js +115 -0
- package/dist-lib/lib/api/chunks.d.ts +17 -2
- package/dist-lib/lib/api/chunks.js +70 -13
- package/dist-lib/lib/api/config.d.ts +6 -2
- package/dist-lib/lib/api/config.js +47 -5
- package/dist-lib/lib/api/current-mesh.d.ts +13 -5
- package/dist-lib/lib/api/current-mesh.js +15 -11
- package/dist-lib/lib/api/custom-models.d.ts +7 -1
- package/dist-lib/lib/api/custom-models.js +12 -12
- package/dist-lib/lib/api/device-routes.d.ts +9 -0
- package/dist-lib/lib/api/device-routes.js +123 -0
- package/dist-lib/lib/api/devices.d.ts +3 -2
- package/dist-lib/lib/api/devices.js +23 -11
- package/dist-lib/lib/api/diagnostics.d.ts +2 -1
- package/dist-lib/lib/api/diagnostics.js +2 -2
- package/dist-lib/lib/api/execution.d.ts +12 -1
- package/dist-lib/lib/api/execution.js +44 -14
- package/dist-lib/lib/api/files.d.ts +1 -1
- package/dist-lib/lib/api/files.js +65 -8
- package/dist-lib/lib/api/host-run-log.d.ts +2 -41
- package/dist-lib/lib/api/host-run-log.js +35 -83
- package/dist-lib/lib/api/index.d.ts +28 -6
- package/dist-lib/lib/api/index.js +101 -33
- package/dist-lib/lib/api/instrument.d.ts +2 -2
- package/dist-lib/lib/api/instrument.js +24 -48
- package/dist-lib/lib/api/knowledge.d.ts +4 -1
- package/dist-lib/lib/api/knowledge.js +25 -7
- package/dist-lib/lib/api/local-files.d.ts +5 -1
- package/dist-lib/lib/api/local-files.js +9 -5
- package/dist-lib/lib/api/logs.js +3 -3
- package/dist-lib/lib/api/members.d.ts +10 -1
- package/dist-lib/lib/api/members.js +67 -26
- package/dist-lib/lib/api/mesh.d.ts +12 -4
- package/dist-lib/lib/api/mesh.js +12 -8
- package/dist-lib/lib/api/model-download.d.ts +2 -1
- package/dist-lib/lib/api/model-download.js +2 -2
- package/dist-lib/lib/api/network.d.ts +10 -2
- package/dist-lib/lib/api/network.js +8 -2
- package/dist-lib/lib/api/notifications.d.ts +3 -1
- package/dist-lib/lib/api/notifications.js +14 -9
- package/dist-lib/lib/api/projects.d.ts +20 -0
- package/dist-lib/lib/api/projects.js +169 -0
- package/dist-lib/lib/api/rag.d.ts +0 -1
- package/dist-lib/lib/api/rag.js +71 -34
- package/dist-lib/lib/api/served.d.ts +17 -0
- package/dist-lib/lib/api/served.js +48 -0
- package/dist-lib/lib/api/sync.d.ts +2 -1
- package/dist-lib/lib/api/sync.js +2 -2
- package/dist-lib/lib/api/tool-activity.d.ts +2 -1
- package/dist-lib/lib/api/tool-activity.js +4 -3
- package/dist-lib/lib/api/tool-configs.d.ts +2 -1
- package/dist-lib/lib/api/tool-configs.js +6 -9
- package/dist-lib/lib/api/upload-frames.d.ts +0 -1
- package/dist-lib/lib/api/upload-frames.js +0 -1
- package/dist-lib/lib/api/watchable.d.ts +3 -2
- package/dist-lib/lib/api/watchable.js +2 -3
- package/dist-lib/lib/api/workspace.d.ts +5 -0
- package/dist-lib/lib/api/workspace.js +47 -0
- package/dist-lib/lib/assistant/fake-models.d.ts +20 -0
- package/dist-lib/lib/assistant/fake-models.js +112 -0
- package/dist-lib/lib/assistant/harness.d.ts +37 -31
- package/dist-lib/lib/assistant/harness.js +51 -10
- package/dist-lib/lib/assistant/history.d.ts +30 -17
- package/dist-lib/lib/assistant/history.js +179 -87
- package/dist-lib/lib/assistant/host-run-log.d.ts +6 -1
- package/dist-lib/lib/assistant/host-run-log.js +24 -36
- package/dist-lib/lib/assistant/message.d.ts +27 -1
- package/dist-lib/lib/assistant/message.js +65 -2
- package/dist-lib/lib/assistant/model-round.d.ts +100 -0
- package/dist-lib/lib/assistant/model-round.js +619 -0
- package/dist-lib/lib/assistant/pdf-budget.d.ts +11 -0
- package/dist-lib/lib/assistant/pdf-budget.js +12 -0
- package/dist-lib/lib/assistant/pdf-pages.d.ts +25 -0
- package/dist-lib/lib/assistant/pdf-pages.js +75 -0
- package/dist-lib/lib/assistant/round-host.d.ts +42 -0
- package/dist-lib/lib/assistant/round-host.js +241 -0
- package/dist-lib/lib/assistant/skill-encode.d.ts +2 -1
- package/dist-lib/lib/assistant/skill-encode.js +2 -1
- package/dist-lib/lib/assistant/video-budget.d.ts +13 -0
- package/dist-lib/lib/assistant/video-budget.js +29 -0
- package/dist-lib/lib/assistant-client.d.ts +4 -1
- package/dist-lib/lib/assistant-client.js +27 -8
- package/dist-lib/lib/assistant-tree.d.ts +10 -3
- package/dist-lib/lib/assistant-tree.js +63 -20
- package/dist-lib/lib/assistant.d.ts +93 -24
- package/dist-lib/lib/assistant.js +2048 -1231
- package/dist-lib/lib/audio-format.js +1 -1
- package/dist-lib/lib/chat-suggestion.d.ts +3 -0
- package/dist-lib/lib/chat-suggestion.js +47 -0
- package/dist-lib/lib/client.d.ts +2 -2
- package/dist-lib/lib/client.js +10 -1
- package/dist-lib/lib/compaction.d.ts +3 -1
- package/dist-lib/lib/compaction.js +18 -4
- package/dist-lib/lib/constants.d.ts +10 -0
- package/dist-lib/lib/constants.js +10 -0
- package/dist-lib/lib/core/agent-copies.d.ts +9 -0
- package/dist-lib/lib/core/agent-copies.js +40 -0
- package/dist-lib/lib/core/agent-hosting.d.ts +25 -0
- package/dist-lib/lib/core/agent-hosting.js +71 -0
- package/dist-lib/lib/core/agent.d.ts +9 -1
- package/dist-lib/lib/core/agent.js +45 -19
- package/dist-lib/lib/core/archived-mesh.d.ts +11 -6
- package/dist-lib/lib/core/archived-mesh.js +77 -58
- package/dist-lib/lib/core/async-iterable.js +1 -1
- package/dist-lib/lib/core/blind-peers.d.ts +1 -0
- package/dist-lib/lib/core/blind-peers.js +1 -0
- package/dist-lib/lib/core/chat-activity.d.ts +1 -1
- package/dist-lib/lib/core/chat-activity.js +45 -34
- package/dist-lib/lib/core/chat-copy.d.ts +42 -0
- package/dist-lib/lib/core/chat-copy.js +395 -0
- package/dist-lib/lib/core/chat-fork.d.ts +16 -0
- package/dist-lib/lib/core/chat-fork.js +246 -0
- package/dist-lib/lib/core/chat-group.js +8 -7
- package/dist-lib/lib/core/chat-move.d.ts +75 -0
- package/dist-lib/lib/core/chat-move.js +598 -0
- package/dist-lib/lib/core/chat-order.d.ts +2 -1
- package/dist-lib/lib/core/chat-order.js +19 -4
- package/dist-lib/lib/core/chat-project.d.ts +2 -0
- package/dist-lib/lib/core/chat-project.js +15 -0
- package/dist-lib/lib/core/chat-read.d.ts +4 -0
- package/dist-lib/lib/core/chat-read.js +49 -0
- package/dist-lib/lib/core/chat-search.js +14 -12
- package/dist-lib/lib/core/chat.d.ts +33 -4
- package/dist-lib/lib/core/chat.js +122 -39
- package/dist-lib/lib/core/chunk.d.ts +35 -7
- package/dist-lib/lib/core/chunk.js +250 -45
- package/dist-lib/lib/core/collections.d.ts +40 -1
- package/dist-lib/lib/core/collections.js +40 -1
- package/dist-lib/lib/core/config-value.d.ts +6 -0
- package/dist-lib/lib/core/config-value.js +14 -0
- package/dist-lib/lib/core/contract/activity.d.ts +3 -2
- package/dist-lib/lib/core/contract/activity.js +39 -21
- package/dist-lib/lib/core/contract/agent-join.d.ts +10 -0
- package/dist-lib/lib/core/contract/agent-join.js +104 -0
- package/dist-lib/lib/core/contract/agents.d.ts +5 -0
- package/dist-lib/lib/core/contract/agents.js +142 -3
- package/dist-lib/lib/core/contract/chat.d.ts +4 -0
- package/dist-lib/lib/core/contract/chat.js +53 -3
- package/dist-lib/lib/core/contract/chunks.d.ts +7 -0
- package/dist-lib/lib/core/contract/chunks.js +125 -38
- package/dist-lib/lib/core/contract/devices.js +6 -4
- package/dist-lib/lib/core/contract/index.d.ts +2 -3
- package/dist-lib/lib/core/contract/index.js +36 -11
- package/dist-lib/lib/core/contract/indexing.d.ts +1 -0
- package/dist-lib/lib/core/contract/indexing.js +51 -7
- package/dist-lib/lib/core/contract/invites.d.ts +3 -14
- package/dist-lib/lib/core/contract/invites.js +26 -36
- package/dist-lib/lib/core/contract/joined-meshes.js +3 -1
- package/dist-lib/lib/core/contract/knowledge.d.ts +1 -0
- package/dist-lib/lib/core/contract/knowledge.js +57 -6
- package/dist-lib/lib/core/contract/members.d.ts +3 -1
- package/dist-lib/lib/core/contract/members.js +34 -4
- package/dist-lib/lib/core/contract/mesh-kind.d.ts +3 -3
- package/dist-lib/lib/core/contract/mesh-kind.js +20 -16
- package/dist-lib/lib/core/contract/mesh-name.d.ts +3 -0
- package/dist-lib/lib/core/contract/mesh-name.js +31 -0
- package/dist-lib/lib/core/contract/mesh-rules.d.ts +8 -0
- package/dist-lib/lib/core/contract/mesh-rules.js +35 -0
- package/dist-lib/lib/core/contract/mesh-seeds.d.ts +2 -0
- package/dist-lib/lib/core/contract/mesh-seeds.js +26 -0
- package/dist-lib/lib/core/contract/model-requests.d.ts +26 -0
- package/dist-lib/lib/core/contract/model-requests.js +280 -0
- package/dist-lib/lib/core/contract/oldest-version.d.ts +9 -0
- package/dist-lib/lib/core/contract/oldest-version.js +20 -0
- package/dist-lib/lib/core/contract/open-join.d.ts +2 -0
- package/dist-lib/lib/core/contract/open-join.js +77 -0
- package/dist-lib/lib/core/contract/project-device-keys.d.ts +7 -0
- package/dist-lib/lib/core/contract/project-device-keys.js +38 -0
- package/dist-lib/lib/core/contract/project-host-keys.d.ts +7 -0
- package/dist-lib/lib/core/contract/project-host-keys.js +41 -0
- package/dist-lib/lib/core/contract/project-order.d.ts +2 -0
- package/dist-lib/lib/core/contract/project-order.js +25 -0
- package/dist-lib/lib/core/contract/projects.d.ts +21 -0
- package/dist-lib/lib/core/contract/projects.js +327 -0
- package/dist-lib/lib/core/contract/public-mesh.d.ts +3 -0
- package/dist-lib/lib/core/contract/public-mesh.js +31 -0
- package/dist-lib/lib/core/contract/public-seeds.d.ts +9 -0
- package/dist-lib/lib/core/contract/public-seeds.js +43 -0
- package/dist-lib/lib/core/contract/roles.d.ts +10 -0
- package/dist-lib/lib/core/contract/roles.js +121 -0
- package/dist-lib/lib/core/contract/run-requests.d.ts +10 -0
- package/dist-lib/lib/core/contract/run-requests.js +81 -0
- package/dist-lib/lib/core/contract/seed-defaults.d.ts +3 -1
- package/dist-lib/lib/core/contract/seed-defaults.js +17 -4
- package/dist-lib/lib/core/contract/shipped-rows.d.ts +2 -0
- package/dist-lib/lib/core/contract/shipped-rows.js +22 -0
- package/dist-lib/lib/core/contract/skill-secrets.d.ts +3 -0
- package/dist-lib/lib/core/contract/skill-secrets.js +32 -0
- package/dist-lib/lib/core/contract/tool-activity.js +12 -1
- package/dist-lib/lib/core/contract/tool-configs.js +2 -1
- package/dist-lib/lib/core/contract/types.d.ts +2 -2
- package/dist-lib/lib/core/contract/workspace.d.ts +31 -0
- package/dist-lib/lib/core/contract/workspace.js +311 -0
- package/dist-lib/lib/core/contract/writers.js +100 -16
- package/dist-lib/lib/core/departures.d.ts +16 -5
- package/dist-lib/lib/core/departures.js +79 -6
- package/dist-lib/lib/core/device-control.d.ts +21 -0
- package/dist-lib/lib/core/device-control.js +91 -0
- package/dist-lib/lib/core/device-seal.d.ts +4 -0
- package/dist-lib/lib/core/device-seal.js +22 -0
- package/dist-lib/lib/core/devices.d.ts +2 -1
- package/dist-lib/lib/core/devices.js +5 -3
- package/dist-lib/lib/core/document-attachment.d.ts +10 -0
- package/dist-lib/lib/core/document-attachment.js +14 -0
- package/dist-lib/lib/core/files/attachments.js +8 -7
- package/dist-lib/lib/core/files/index.d.ts +27 -14
- package/dist-lib/lib/core/files/index.js +220 -43
- package/dist-lib/lib/core/files/knowledge.d.ts +10 -1
- package/dist-lib/lib/core/files/knowledge.js +77 -5
- package/dist-lib/lib/core/files/preview/index.js +6 -2
- package/dist-lib/lib/core/files/processing/claims.d.ts +7 -0
- package/dist-lib/lib/core/files/processing/claims.js +33 -7
- package/dist-lib/lib/core/files/processing/document.d.ts +8 -0
- package/dist-lib/lib/core/files/processing/document.js +26 -2
- package/dist-lib/lib/core/files/processing/index.d.ts +8 -3
- package/dist-lib/lib/core/files/processing/index.js +99 -73
- package/dist-lib/lib/core/files/processing/protocol.d.ts +7 -1
- package/dist-lib/lib/core/files/processing/protocol.js +14 -3
- package/dist-lib/lib/core/files/processing/source.d.ts +4 -0
- package/dist-lib/lib/core/files/processing/source.js +12 -4
- package/dist-lib/lib/core/files/processing/state.d.ts +5 -1
- package/dist-lib/lib/core/files/processing/state.js +9 -1
- package/dist-lib/lib/core/files/rag/build.d.ts +5 -1
- package/dist-lib/lib/core/files/rag/build.js +32 -8
- package/dist-lib/lib/core/files/rag/failure.d.ts +20 -0
- package/dist-lib/lib/core/files/rag/failure.js +57 -0
- package/dist-lib/lib/core/files/rag/index.d.ts +13 -2
- package/dist-lib/lib/core/files/rag/index.js +30 -8
- package/dist-lib/lib/core/files/rag/joined-index.d.ts +6 -0
- package/dist-lib/lib/core/files/rag/joined-index.js +35 -0
- package/dist-lib/lib/core/files/rag/limits.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/limits.js +1 -0
- package/dist-lib/lib/core/files/rag/load.js +6 -3
- package/dist-lib/lib/core/files/rag/policy.d.ts +10 -1
- package/dist-lib/lib/core/files/rag/policy.js +23 -2
- package/dist-lib/lib/core/files/rag/produce.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/produce.js +31 -18
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +8 -2
- package/dist-lib/lib/core/files/rag/similarity.d.ts +2 -2
- package/dist-lib/lib/core/files/rag/similarity.js +2 -3
- package/dist-lib/lib/core/files/records/chunks.js +22 -1
- package/dist-lib/lib/core/files/records/index.d.ts +1 -1
- package/dist-lib/lib/core/files/records/index.js +1 -1
- package/dist-lib/lib/core/files/records/knowledge.d.ts +11 -1
- package/dist-lib/lib/core/files/records/knowledge.js +40 -3
- package/dist-lib/lib/core/files/records/purge.js +13 -8
- package/dist-lib/lib/core/files/records/reclaim.js +20 -48
- package/dist-lib/lib/core/files/records/routing.d.ts +1 -1
- package/dist-lib/lib/core/files/records/routing.js +6 -2
- package/dist-lib/lib/core/files/records/source.js +3 -5
- package/dist-lib/lib/core/files/records/sweep.d.ts +3 -0
- package/dist-lib/lib/core/files/records/sweep.js +9 -3
- package/dist-lib/lib/core/files/store/blob.d.ts +2 -0
- package/dist-lib/lib/core/files/store/blob.js +2 -2
- package/dist-lib/lib/core/files/store/index.d.ts +3 -1
- package/dist-lib/lib/core/files/store/index.js +4 -1
- package/dist-lib/lib/core/files/store/reference.d.ts +3 -0
- package/dist-lib/lib/core/files/store/reference.js +12 -2
- package/dist-lib/lib/core/files/store/sweep.js +3 -1
- package/dist-lib/lib/core/files/upload.d.ts +5 -1
- package/dist-lib/lib/core/files/upload.js +53 -14
- package/dist-lib/lib/core/first-event.d.ts +6 -0
- package/dist-lib/lib/core/first-event.js +13 -0
- package/dist-lib/lib/core/fs-drives.d.ts +6 -3
- package/dist-lib/lib/core/fs-drives.js +30 -18
- package/dist-lib/lib/core/id.d.ts +1 -0
- package/dist-lib/lib/core/id.js +3 -0
- package/dist-lib/lib/core/identity.d.ts +3 -1
- package/dist-lib/lib/core/identity.js +25 -4
- package/dist-lib/lib/core/invite.d.ts +6 -2
- package/dist-lib/lib/core/invite.js +22 -8
- package/dist-lib/lib/core/local/files.d.ts +2 -1
- package/dist-lib/lib/core/local/files.js +5 -7
- package/dist-lib/lib/core/local/index.d.ts +86 -7
- package/dist-lib/lib/core/local/index.js +312 -27
- package/dist-lib/lib/core/local/run-logs.d.ts +38 -0
- package/dist-lib/lib/core/local/run-logs.js +132 -0
- package/dist-lib/lib/core/member-key.d.ts +7 -0
- package/dist-lib/lib/core/member-key.js +24 -0
- package/dist-lib/lib/core/membership.d.ts +3 -14
- package/dist-lib/lib/core/membership.js +3 -96
- package/dist-lib/lib/core/mesh.d.ts +107 -30
- package/dist-lib/lib/core/mesh.js +625 -171
- package/dist-lib/lib/core/migrations/agent-tools-scope.d.ts +2 -0
- package/dist-lib/lib/core/migrations/agent-tools-scope.js +24 -0
- package/dist-lib/lib/core/migrations/chat-chunks.d.ts +4 -0
- package/dist-lib/lib/core/migrations/chat-chunks.js +47 -0
- package/dist-lib/lib/core/migrations/file-index.d.ts +1 -1
- package/dist-lib/lib/core/migrations/file-index.js +8 -6
- package/dist-lib/lib/core/migrations/index.d.ts +2 -1
- package/dist-lib/lib/core/migrations/index.js +69 -8
- package/dist-lib/lib/core/model-requests.d.ts +13 -0
- package/dist-lib/lib/core/model-requests.js +65 -0
- package/dist-lib/lib/core/next-frame.js +2 -1
- package/dist-lib/lib/core/notification.js +100 -25
- package/dist-lib/lib/core/pdf/figure.d.ts +22 -0
- package/dist-lib/lib/core/pdf/figure.js +64 -0
- package/dist-lib/lib/core/pdf/rasterize.d.ts +12 -3
- package/dist-lib/lib/core/pdf/rasterize.js +77 -28
- package/dist-lib/lib/core/peer-duplex.d.ts +34 -0
- package/dist-lib/lib/core/{harness-loan.js → peer-duplex.js} +104 -45
- package/dist-lib/lib/core/project-keys.d.ts +13 -0
- package/dist-lib/lib/core/project-keys.js +56 -0
- package/dist-lib/lib/core/prompt-history.js +4 -4
- package/dist-lib/lib/core/protocol-pairing.d.ts +11 -0
- package/dist-lib/lib/core/protocol-pairing.js +22 -0
- package/dist-lib/lib/core/public-mesh.d.ts +26 -0
- package/dist-lib/lib/core/public-mesh.js +94 -0
- package/dist-lib/lib/core/purge.d.ts +3 -0
- package/dist-lib/lib/core/purge.js +7 -0
- package/dist-lib/lib/core/run-driver.d.ts +17 -0
- package/dist-lib/lib/core/run-driver.js +20 -0
- package/dist-lib/lib/core/run-requests.d.ts +11 -0
- package/dist-lib/lib/core/run-requests.js +58 -0
- package/dist-lib/lib/core/send.d.ts +2 -0
- package/dist-lib/lib/core/send.js +17 -4
- package/dist-lib/lib/core/senders.d.ts +19 -0
- package/dist-lib/lib/core/senders.js +45 -0
- package/dist-lib/lib/core/shared-agents.d.ts +40 -0
- package/dist-lib/lib/core/shared-agents.js +283 -0
- package/dist-lib/lib/core/skill-secrets.d.ts +10 -16
- package/dist-lib/lib/core/skill-secrets.js +90 -72
- package/dist-lib/lib/core/sync/background.d.ts +35 -0
- package/dist-lib/lib/core/sync/background.js +85 -0
- package/dist-lib/lib/core/sync/changed.d.ts +20 -0
- package/dist-lib/lib/core/sync/changed.js +7 -0
- package/dist-lib/lib/core/sync/devices.js +6 -3
- package/dist-lib/lib/core/sync/files.d.ts +1 -0
- package/dist-lib/lib/core/sync/files.js +50 -72
- package/dist-lib/lib/core/sync/index.d.ts +1 -1
- package/dist-lib/lib/core/sync/index.js +164 -81
- package/dist-lib/lib/core/sync/view-updates.d.ts +33 -0
- package/dist-lib/lib/core/sync/view-updates.js +133 -0
- package/dist-lib/lib/core/sync-status.js +3 -3
- package/dist-lib/lib/core/system-info.d.ts +2 -2
- package/dist-lib/lib/core/system-info.js +10 -11
- package/dist-lib/lib/core/tool-configs.d.ts +5 -3
- package/dist-lib/lib/core/tool-configs.js +11 -11
- package/dist-lib/lib/core/transcript-visibility.d.ts +5 -5
- package/dist-lib/lib/core/transcript-visibility.js +27 -31
- package/dist-lib/lib/core/upgrade-agents.d.ts +11 -0
- package/dist-lib/lib/core/upgrade-agents.js +78 -0
- package/dist-lib/lib/core/video/attachment.d.ts +1 -0
- package/dist-lib/lib/core/video/attachment.js +7 -0
- package/dist-lib/lib/core/video/digest.d.ts +16 -0
- package/dist-lib/lib/core/video/digest.js +57 -0
- package/dist-lib/lib/core/video/frames.d.ts +32 -0
- package/dist-lib/lib/core/video/frames.js +224 -0
- package/dist-lib/lib/core/workspace-upgrade.d.ts +22 -0
- package/dist-lib/lib/core/workspace-upgrade.js +50 -0
- package/dist-lib/lib/core.d.ts +303 -84
- package/dist-lib/lib/core.js +3952 -1511
- package/dist-lib/lib/credential-pusher.d.ts +17 -7
- package/dist-lib/lib/credential-pusher.js +111 -62
- package/dist-lib/lib/custom-model-pusher.d.ts +2 -4
- package/dist-lib/lib/custom-model-task.d.ts +2 -1
- package/dist-lib/lib/custom-model-task.js +2 -2
- package/dist-lib/lib/device-tree.d.ts +18 -0
- package/dist-lib/lib/device-tree.js +32 -0
- package/dist-lib/lib/diagnostics.d.ts +7 -0
- package/dist-lib/lib/diagnostics.js +22 -0
- package/dist-lib/lib/doctor/checks.d.ts +15 -0
- package/dist-lib/lib/doctor/checks.js +272 -0
- package/dist-lib/lib/doctor/redact.d.ts +4 -0
- package/dist-lib/lib/doctor/redact.js +31 -0
- package/dist-lib/lib/doctor/render.d.ts +8 -0
- package/dist-lib/lib/doctor/render.js +83 -0
- package/dist-lib/lib/doctor/tree.d.ts +5 -0
- package/dist-lib/lib/doctor/tree.js +167 -0
- package/dist-lib/lib/downloads-allowed-pusher.d.ts +8 -0
- package/dist-lib/lib/downloads-allowed-pusher.js +37 -0
- package/dist-lib/lib/errors.d.ts +794 -0
- package/dist-lib/lib/errors.js +728 -0
- package/dist-lib/lib/fs-drive-bridge.d.ts +8 -1
- package/dist-lib/lib/fs-drive-bridge.js +312 -31
- package/dist-lib/lib/guards.d.ts +1 -0
- package/dist-lib/lib/guards.js +4 -0
- package/dist-lib/lib/inference-calls.d.ts +1 -2
- package/dist-lib/lib/inference-calls.js +2 -10
- package/dist-lib/lib/integrations/setup-routes.js +7 -5
- package/dist-lib/lib/knowledge-search.d.ts +1 -1
- package/dist-lib/lib/knowledge-search.js +5 -51
- package/dist-lib/lib/kv-cache-reclaim.d.ts +2 -1
- package/dist-lib/lib/kv-cache-reclaim.js +30 -0
- package/dist-lib/lib/kv-cache-retention.d.ts +35 -0
- package/dist-lib/lib/kv-cache-retention.js +98 -0
- package/dist-lib/lib/latest-frame.d.ts +10 -0
- package/dist-lib/lib/latest-frame.js +48 -0
- package/dist-lib/lib/log.d.ts +7 -6
- package/dist-lib/lib/log.js +14 -7
- package/dist-lib/lib/logger-type.d.ts +2 -5
- package/dist-lib/lib/mesh-scoped-engine.js +42 -2
- package/dist-lib/lib/model-download-status.d.ts +3 -3
- package/dist-lib/lib/model-download.d.ts +16 -12
- package/dist-lib/lib/model-download.js +90 -34
- package/dist-lib/lib/model-idle-pusher.d.ts +2 -4
- package/dist-lib/lib/model-memory-cap.d.ts +27 -0
- package/dist-lib/lib/model-memory-cap.js +69 -0
- package/dist-lib/lib/models-watch.d.ts +1 -1
- package/dist-lib/lib/models-watch.js +4 -4
- package/dist-lib/lib/oauth/browser-connect.js +3 -2
- package/dist-lib/lib/oauth/flow-core.js +5 -3
- package/dist-lib/lib/oauth/flow.js +1 -1
- package/dist-lib/lib/oauth/loopback.d.ts +1 -0
- package/dist-lib/lib/oauth/loopback.js +57 -12
- package/dist-lib/lib/oauth/providers.js +4 -2
- package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
- package/dist-lib/lib/oauth/register.js +35 -19
- package/dist-lib/lib/oauth/request.d.ts +10 -0
- package/dist-lib/lib/oauth/request.js +22 -0
- package/dist-lib/lib/oauth/resolve.js +13 -5
- package/dist-lib/lib/oauth/token-exchange-core.js +31 -33
- package/dist-lib/lib/oauth/types.d.ts +3 -0
- package/dist-lib/lib/oauth.d.ts +2 -1
- package/dist-lib/lib/oauth.js +1 -0
- package/dist-lib/lib/persistent-dir.d.ts +1 -0
- package/dist-lib/lib/persistent-dir.js +9 -0
- package/dist-lib/lib/probe-rounds.d.ts +3 -0
- package/dist-lib/lib/probe-rounds.js +5 -0
- package/dist-lib/lib/reconnecting-watch.js +19 -11
- package/dist-lib/lib/run-input.d.ts +14 -0
- package/dist-lib/lib/run-input.js +33 -0
- package/dist-lib/lib/run-notices.d.ts +5 -0
- package/dist-lib/lib/run-notices.js +13 -2
- package/dist-lib/lib/run-replay.d.ts +44 -0
- package/dist-lib/lib/run-replay.js +158 -0
- package/dist-lib/lib/run-transcript.d.ts +11 -12
- package/dist-lib/lib/run-transcript.js +16 -18
- package/dist-lib/lib/suspend-lifecycle.js +15 -5
- package/dist-lib/lib/task.js +6 -4
- package/dist-lib/lib/test-env.d.ts +1 -0
- package/dist-lib/lib/test-env.js +4 -0
- package/dist-lib/schema/build.js +66 -55
- package/dist-lib/schema/config.d.ts +1 -1
- package/dist-lib/schema/config.js +1 -1
- package/dist-lib/schema/content.d.ts +5 -1
- package/dist-lib/schema/content.js +60 -12
- package/dist-lib/schema/engine.d.ts +1 -0
- package/dist-lib/schema/engine.js +780 -155
- package/dist-lib/schema/field-order.js +8 -1
- package/dist-lib/schema/indexes.d.ts +7 -0
- package/dist-lib/schema/indexes.js +48 -3
- package/dist-lib/schema/local.js +80 -5
- package/dist-lib/schema/qvac.d.ts +4 -1
- package/dist-lib/schema/qvac.js +474 -14
- package/dist-lib/spec/bind.js +212 -48
- package/dist-lib/spec/calls.js +46 -5
- package/dist-lib/spec/capabilities.d.ts +100 -18
- package/dist-lib/spec/config/hyperconf/index.js +1 -1
- package/dist-lib/spec/hrpc/hrpc.json +739 -206
- package/dist-lib/spec/hrpc/index.js +844 -345
- package/dist-lib/spec/hrpc/messages.js +3906 -1749
- package/dist-lib/spec/hyperschema/index.js +3906 -1749
- package/dist-lib/spec/hyperschema/schema.json +4809 -3119
- package/dist-lib/spec/hyperschema/types.d.ts +482 -62
- package/dist-lib/spec/local/hyperdb/db.json +95 -1
- package/dist-lib/spec/local/hyperdb/index.js +459 -2
- package/dist-lib/spec/local/hyperdb/messages.js +1565 -487
- package/dist-lib/spec/local/hyperschema/index.js +573 -16
- package/dist-lib/spec/local/hyperschema/schema.json +354 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +85 -2
- package/dist-lib/spec/mesh/hyperdb/db.json +577 -7
- package/dist-lib/spec/mesh/hyperdb/index.js +2224 -6
- package/dist-lib/spec/mesh/hyperdb/messages.js +6476 -1266
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +193 -1
- package/dist-lib/spec/mesh/hyperdispatch/index.js +545 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +3655 -265
- package/dist-lib/spec/mesh/hyperschema/index.js +3655 -265
- package/dist-lib/spec/mesh/hyperschema/schema.json +1974 -19
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +498 -6
- package/package.json +64 -43
- package/worker/assistant-sidecar.mjs +18 -2
- package/worker/stow-entry.mjs +2 -0
- package/dist-lib/lib/core/contract/compute.d.ts +0 -11
- package/dist-lib/lib/core/contract/compute.js +0 -48
- package/dist-lib/lib/core/device-invites.d.ts +0 -11
- package/dist-lib/lib/core/device-invites.js +0 -63
- package/dist-lib/lib/core/files/processing/settle.d.ts +0 -13
- package/dist-lib/lib/core/files/processing/settle.js +0 -86
- package/dist-lib/lib/core/grant-expiry.d.ts +0 -11
- package/dist-lib/lib/core/grant-expiry.js +0 -66
- package/dist-lib/lib/core/handoff-channel.d.ts +0 -47
- package/dist-lib/lib/core/handoff-channel.js +0 -123
- package/dist-lib/lib/core/harness-loan.d.ts +0 -29
- package/dist-lib/lib/core/host-run-log-store.d.ts +0 -114
- package/dist-lib/lib/core/host-run-log-store.js +0 -976
- package/dist-lib/lib/core/hosted-agents.d.ts +0 -38
- package/dist-lib/lib/core/hosted-agents.js +0 -140
- package/dist-lib/lib/core/inference-calls-handoff.d.ts +0 -20
- package/dist-lib/lib/core/inference-calls-handoff.js +0 -37
- package/dist-lib/lib/core/inference-calls-receiver.d.ts +0 -14
- package/dist-lib/lib/core/inference-calls-receiver.js +0 -42
- package/dist-lib/lib/core/mesh-seed-handoff.d.ts +0 -25
- package/dist-lib/lib/core/mesh-seed-handoff.js +0 -52
- package/dist-lib/lib/core/migrations/device-indexes.d.ts +0 -2
- package/dist-lib/lib/core/migrations/device-indexes.js +0 -7
- package/dist-lib/lib/core/secret-handoff.d.ts +0 -17
- package/dist-lib/lib/core/secret-handoff.js +0 -29
- package/dist-lib/lib/core/skill-overlay-handoff.d.ts +0 -25
- package/dist-lib/lib/core/skill-overlay-handoff.js +0 -50
- package/dist-lib/lib/core/skill-overlay-receiver.d.ts +0 -8
- package/dist-lib/lib/core/skill-overlay-receiver.js +0 -23
- package/dist-lib/lib/image-cache-dir.d.ts +0 -1
- package/dist-lib/lib/image-cache-dir.js +0 -5
- package/dist-lib/lib/log-levels.d.ts +0 -7
- package/dist-lib/lib/log-levels.js +0 -1
- package/dist-lib/lib/logger.d.ts +0 -5
- package/dist-lib/lib/logger.js +0 -18
- package/dist-lib/lib/oauth/loopback.stub.d.ts +0 -3
- package/dist-lib/lib/oauth/loopback.stub.js +0 -6
- package/tui/README.md +0 -142
- package/tui/app.mjs +0 -6939
- package/tui/boot.mjs +0 -111
- package/tui/index.mjs +0 -53
- package/tui/lib/boot-timing.mjs +0 -41
- package/tui/lib/busy-words.mjs +0 -116
- package/tui/lib/export.mjs +0 -194
- package/tui/lib/knowledge-command.mjs +0 -190
- package/tui/lib/knowledge-import.mjs +0 -171
- package/tui/lib/render.mjs +0 -196
- package/tui/lib/save-file.mjs +0 -88
- package/tui/lib/select.mjs +0 -81
- package/tui/lib/selection.mjs +0 -18
- package/tui/lib/setup.mjs +0 -101
- package/tui/lib/sidebar.mjs +0 -63
- package/tui/lib/splash-art.mjs +0 -107
- package/tui/lib/splash.mjs +0 -18
- package/tui/lib/upload-frames.mjs +0 -9
- package/tui/lib/usage.mjs +0 -59
- package/tui/lib/wrap.mjs +0 -143
- package/tui/main.mjs +0 -264
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { CHUNK_PAYLOAD_FIELDS, ragSourcesWithinBounds } from '../../schema/qvac.js';
|
|
2
2
|
import { chunkTypeOrdinal } from '../../schema/indexes.js';
|
|
3
3
|
import { mediaKindOrdinal } from '../../schema/media-kind.js';
|
|
4
|
+
import { CoreError } from '../errors.js';
|
|
4
5
|
import { putApprovalRule } from './approval-rules.js';
|
|
5
6
|
import { linkAttachment } from './attachment-link.js';
|
|
7
|
+
import { foreignChat } from './contract/chat.js';
|
|
8
|
+
import { runRequestOf } from './contract/chunks.js';
|
|
9
|
+
import { asModelRequest, takenBySigner } from './contract/model-requests.js';
|
|
10
|
+
import { inProject, projectRules } from './contract/projects.js';
|
|
6
11
|
import { randomId } from './id.js';
|
|
7
12
|
import { keyRange } from './range.js';
|
|
13
|
+
import { runDefinition } from './shared-agents.js';
|
|
14
|
+
import { drivenBy, handedOff, offeredTo } from './run-driver.js';
|
|
8
15
|
import b4a from 'b4a';
|
|
9
|
-
import { AGENTS, ATTACHMENTS_BY_MEDIA_KIND, ATTACHMENTS_BY_MEDIA_KIND_ORIGIN, CHUNKS, CHUNKS_BY_CHAT, CHUNKS_BY_TYPE, HISTORY_CHUNKS, RUN_REQUESTS } from './collections.js';
|
|
16
|
+
import { AGENTS, ATTACHMENTS_BY_MEDIA_KIND, ATTACHMENTS_BY_MEDIA_KIND_ORIGIN, CHAT_CHUNKS, CHUNKS, CHUNKS_BY_CHAT, CHUNKS_BY_TYPE, CHUNK_COUNTERS, HISTORY_CHUNKS, RUN_REQUESTS } from './collections.js';
|
|
17
|
+
const TERMINAL_RUN_STATES = new Set(['completed', 'failed', 'canceled']);
|
|
10
18
|
export const HISTORY_CHUNK_TYPES = [
|
|
11
19
|
'user-message',
|
|
12
20
|
'run-request',
|
|
@@ -15,12 +23,31 @@ export const HISTORY_CHUNK_TYPES = [
|
|
|
15
23
|
'compaction',
|
|
16
24
|
'round-reset'
|
|
17
25
|
];
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
const FALSY_RESULTS = new Map([
|
|
27
|
+
['false', false],
|
|
28
|
+
['0', 0],
|
|
29
|
+
['""', '']
|
|
30
|
+
]);
|
|
31
|
+
export function readChunk({ toolResult, ...chunk }) {
|
|
32
|
+
if (!toolResult) {
|
|
33
|
+
return { ...chunk, toolResult: null };
|
|
22
34
|
}
|
|
23
|
-
|
|
35
|
+
const stored = chunk.falsyResult ?? '';
|
|
36
|
+
const result = FALSY_RESULTS.has(stored) ? FALSY_RESULTS.get(stored) : (toolResult.result ?? null);
|
|
37
|
+
return { ...chunk, toolResult: { ...toolResult, result } };
|
|
38
|
+
}
|
|
39
|
+
export function linkChunks(store, chunks) {
|
|
40
|
+
const mint = store.attachmentUrl;
|
|
41
|
+
return chunks.map((row) => {
|
|
42
|
+
const chunk = readChunk(row);
|
|
43
|
+
return mint && chunk.attachment
|
|
44
|
+
? { ...chunk, attachment: linkAttachment(mint, chunk.attachment) }
|
|
45
|
+
: chunk;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function falsyResultOf(payload) {
|
|
49
|
+
const result = payload.toolResult?.result;
|
|
50
|
+
return result === false || result === 0 || result === '' ? JSON.stringify(result) : undefined;
|
|
24
51
|
}
|
|
25
52
|
export async function recordLinks(store, chunks) {
|
|
26
53
|
await store.fileIndex?.record(chunks.filter((chunk) => chunk.attachment?.url));
|
|
@@ -32,31 +59,91 @@ export function findChunksOfType(snap, { chatId, type, ...bounds }) {
|
|
|
32
59
|
.find(CHUNKS_BY_TYPE, keyRange(prefix, 'seq', bounds))
|
|
33
60
|
.toArray();
|
|
34
61
|
}
|
|
35
|
-
export async function
|
|
62
|
+
export async function findChunksOfTypes(db, { chatId, types, ...bounds }) {
|
|
63
|
+
const ordered = await readChatOrdered(db, chatId, { types, ...bounds });
|
|
64
|
+
if (ordered) {
|
|
65
|
+
return ordered;
|
|
66
|
+
}
|
|
67
|
+
const byType = await Promise.all(types.map((type) => findChunksOfType(db, { chatId, type, ...bounds })));
|
|
68
|
+
return byType.flat().sort((left, right) => left.seq - right.seq);
|
|
69
|
+
}
|
|
70
|
+
export async function listChunks(store, input) {
|
|
71
|
+
const snap = store.view.snapshot();
|
|
72
|
+
try {
|
|
73
|
+
return linkChunks(store, await readChunks(snap, input));
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
await snap.close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export async function readChunks(db, { chatId, type, types, ...bounds }) {
|
|
36
80
|
const selected = selectedChunkTypes(type, types);
|
|
37
81
|
if (selected?.length === 0) {
|
|
38
82
|
return [];
|
|
39
83
|
}
|
|
40
84
|
if (selected && selected.length > 1 && !isHistorySelection(selected)) {
|
|
41
|
-
throw new
|
|
85
|
+
throw new CoreError('CHUNK_TYPES_UNMAPPED');
|
|
42
86
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (selected?.length === 1) {
|
|
46
|
-
const prefix = { chatId, type: chunkTypeOrdinal(selected[0]) };
|
|
47
|
-
const chunks = await snap
|
|
48
|
-
.find(CHUNKS_BY_TYPE, keyRange(prefix, 'seq', bounds))
|
|
49
|
-
.toArray();
|
|
50
|
-
return linkChunks(store, chunks);
|
|
51
|
-
}
|
|
52
|
-
const chunks = await snap
|
|
53
|
-
.find(selected ? HISTORY_CHUNKS : CHUNKS_BY_CHAT, keyRange({ chatId }, 'seq', bounds))
|
|
54
|
-
.toArray();
|
|
55
|
-
return linkChunks(store, chunks);
|
|
87
|
+
if (selected?.length === 1) {
|
|
88
|
+
return findChunksOfType(db, { chatId, type: selected[0], ...bounds });
|
|
56
89
|
}
|
|
57
|
-
|
|
58
|
-
|
|
90
|
+
const history = selected !== null;
|
|
91
|
+
const ordered = history && bounds.limit
|
|
92
|
+
? null
|
|
93
|
+
: await readChatOrdered(db, chatId, {
|
|
94
|
+
types: history ? HISTORY_CHUNK_TYPES : null,
|
|
95
|
+
...bounds
|
|
96
|
+
});
|
|
97
|
+
if (ordered) {
|
|
98
|
+
return ordered;
|
|
99
|
+
}
|
|
100
|
+
return db
|
|
101
|
+
.find(history ? HISTORY_CHUNKS : CHUNKS_BY_CHAT, keyRange({ chatId }, 'seq', bounds))
|
|
102
|
+
.toArray();
|
|
103
|
+
}
|
|
104
|
+
async function readChatOrdered(db, chatId, { types, ...bounds }) {
|
|
105
|
+
const counter = await db.get(CHUNK_COUNTERS, { chatId });
|
|
106
|
+
if (!counter) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const chunks = await db
|
|
110
|
+
.find(CHAT_CHUNKS, keyRange({ chatId }, 'seq', bounds))
|
|
111
|
+
.toArray();
|
|
112
|
+
const { first, last } = seqSpan(counter.count, bounds);
|
|
113
|
+
if (last < first) {
|
|
114
|
+
return chunks.length === 0 ? chunks : null;
|
|
115
|
+
}
|
|
116
|
+
const [low, high] = bounds.reverse ? [chunks.at(-1), chunks[0]] : [chunks[0], chunks.at(-1)];
|
|
117
|
+
const whole = chunks.length === last - first + 1 && low?.seq === first && high?.seq === last;
|
|
118
|
+
if (!whole) {
|
|
119
|
+
return null;
|
|
59
120
|
}
|
|
121
|
+
const settled = new Set(chunks
|
|
122
|
+
.filter((chunk) => TERMINAL_RUN_STATES.has(chunk.runStatus?.state ?? ''))
|
|
123
|
+
.map((c) => c.runId));
|
|
124
|
+
const selected = types ? chunks.filter((chunk) => types.includes(chunk.type)) : chunks;
|
|
125
|
+
return Promise.all(selected.map((chunk) => (changeable(chunk, settled) ? current(db, chunk) : chunk)));
|
|
126
|
+
}
|
|
127
|
+
function changeable(chunk, settled) {
|
|
128
|
+
return ((chunk.type === 'run-status' && !settled.has(chunk.runId)) ||
|
|
129
|
+
(chunk.type === 'approval-request' && chunk.approvalRequest?.status === 'pending') ||
|
|
130
|
+
(chunk.type === 'attachment' && !chunk.attachment?.deletedAt));
|
|
131
|
+
}
|
|
132
|
+
async function current(db, chunk) {
|
|
133
|
+
return (await db.get(CHUNKS, { id: chunk.id })) ?? chunk;
|
|
134
|
+
}
|
|
135
|
+
function seqSpan(count, { gt, gte, lt, lte, reverse, limit }) {
|
|
136
|
+
let first = Math.max(0, gte ?? 0, gt === undefined ? 0 : gt + 1);
|
|
137
|
+
let last = Math.min(count - 1, lte ?? Infinity, lt === undefined ? Infinity : lt - 1);
|
|
138
|
+
if (limit) {
|
|
139
|
+
if (reverse) {
|
|
140
|
+
first = Math.max(first, last - limit + 1);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
last = Math.min(last, first + limit - 1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return { first, last };
|
|
60
147
|
}
|
|
61
148
|
export async function listAttachmentsByKind(store, { kind, origin, ...bounds }) {
|
|
62
149
|
const mediaKind = mediaKindOrdinal(kind);
|
|
@@ -87,6 +174,15 @@ function selectedChunkTypes(type, types) {
|
|
|
87
174
|
}
|
|
88
175
|
return [...selected];
|
|
89
176
|
}
|
|
177
|
+
export function selectsChunk({ chatId, type, types, gt, gte, lt, lte }, chunk) {
|
|
178
|
+
const selected = selectedChunkTypes(type, types);
|
|
179
|
+
return (chunk.chatId === chatId &&
|
|
180
|
+
(selected === null || selected.includes(chunk.type)) &&
|
|
181
|
+
(gt === undefined || chunk.seq > gt) &&
|
|
182
|
+
(gte === undefined || chunk.seq >= gte) &&
|
|
183
|
+
(lt === undefined || chunk.seq < lt) &&
|
|
184
|
+
(lte === undefined || chunk.seq <= lte));
|
|
185
|
+
}
|
|
90
186
|
function isHistorySelection(types) {
|
|
91
187
|
return (types.length === HISTORY_CHUNK_TYPES.length &&
|
|
92
188
|
types.every((type) => HISTORY_CHUNK_TYPES.includes(type)));
|
|
@@ -101,10 +197,10 @@ export async function getChunk(store, id) {
|
|
|
101
197
|
await snap.close();
|
|
102
198
|
}
|
|
103
199
|
}
|
|
104
|
-
async function mustGetChunk(store, id) {
|
|
200
|
+
export async function mustGetChunk(store, id) {
|
|
105
201
|
const chunk = await getChunk(store, id);
|
|
106
202
|
if (!chunk) {
|
|
107
|
-
throw new
|
|
203
|
+
throw new CoreError('CHUNK_NOT_FOUND', [id]);
|
|
108
204
|
}
|
|
109
205
|
return chunk;
|
|
110
206
|
}
|
|
@@ -115,29 +211,125 @@ function assertPayloadMatchesType(type, payload) {
|
|
|
115
211
|
(candidate === field)) {
|
|
116
212
|
continue;
|
|
117
213
|
}
|
|
118
|
-
throw new
|
|
214
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', [`${type} carries ${field} and nothing else`]);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
export async function requireChatIn(store, chatId) {
|
|
218
|
+
if (store.role === 'project' && (await foreignChat(store.view, chatId))) {
|
|
219
|
+
throw new CoreError('CHAT_NOT_FOUND', [chatId]);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function projectRun(store) {
|
|
223
|
+
return store.role === 'project' ? projectRules(store.view) : Promise.resolve(false);
|
|
224
|
+
}
|
|
225
|
+
async function ourMember(store) {
|
|
226
|
+
return store.ourMemberId ?? (await store.refreshOurMember())?.memberId;
|
|
227
|
+
}
|
|
228
|
+
export async function ownedByUs(store, chunk) {
|
|
229
|
+
const ours = await ourMember(store);
|
|
230
|
+
return !!ours && !!chunk.requesterMemberId && b4a.equals(ours, chunk.requesterMemberId);
|
|
231
|
+
}
|
|
232
|
+
export async function requireProjectMember(store, meshId) {
|
|
233
|
+
if (!(await projectRun(store))) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const ours = await ourMember(store);
|
|
237
|
+
if (!ours || !(await inProject(store.view, ours))) {
|
|
238
|
+
throw new CoreError('PROJECT_NOT_FOUND', [meshId]);
|
|
119
239
|
}
|
|
120
240
|
}
|
|
121
|
-
|
|
241
|
+
async function projectRunRequest(store, chatId, runId) {
|
|
242
|
+
if (!(await projectRun(store))) {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
const request = await runRequestOf(store.view, chatId, runId);
|
|
246
|
+
if (!request) {
|
|
247
|
+
throw new CoreError('RUN_NOT_FOUND', [runId]);
|
|
248
|
+
}
|
|
249
|
+
return request;
|
|
250
|
+
}
|
|
251
|
+
export async function answersRound(store, parentId) {
|
|
252
|
+
return !!parentId && !!asModelRequest(await getChunk(store, parentId));
|
|
253
|
+
}
|
|
254
|
+
export async function requireOwnRun(store, chatId, runId) {
|
|
255
|
+
const request = await projectRunRequest(store, chatId, runId);
|
|
256
|
+
if (request && !(await ownedByUs(store, request))) {
|
|
257
|
+
throw new CoreError('RUN_NOT_OURS', [runId]);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
export async function requireStoppableRun(store, { meshId, chatId, runId }) {
|
|
261
|
+
if (await projectRunRequest(store, chatId, runId)) {
|
|
262
|
+
await requireProjectMember(store, meshId);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
async function requireRoundOutput(store, { type, runId }, parent) {
|
|
266
|
+
const round = asModelRequest(parent);
|
|
267
|
+
if (!round) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if ((type !== 'content' && type !== 'thinking') || runId !== round.runId) {
|
|
271
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', [
|
|
272
|
+
"only its run's content and thinking answer a model-request"
|
|
273
|
+
]);
|
|
274
|
+
}
|
|
275
|
+
if (!(await takenBySigner(store.view, round, store.localWriterKey))) {
|
|
276
|
+
throw new CoreError('MODEL_REQUEST_NOT_OURS', [round.id]);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async function namedHost(store, agentId) {
|
|
280
|
+
const row = agentId ? await store.view.get(AGENTS, { id: agentId }) : null;
|
|
281
|
+
if (row && !row.sharedIn && store.role !== 'project') {
|
|
282
|
+
return row.providerDeviceId;
|
|
283
|
+
}
|
|
284
|
+
if (!row?.sharedIn || !(await store.pickedFrom?.())) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
return (await runDefinition(store, row))?.providerDeviceId;
|
|
288
|
+
}
|
|
289
|
+
export async function appendChunk(store, { id = randomId(), chatId, runId, type, originDeviceId, parentId, effect, intent, display, rawCall, capability, capabilityArgs, enhance, senderNameAtSend, sourceId, round, callId, resumed, runnerDeviceId, ...payload }, into = store) {
|
|
122
290
|
assertPayloadMatchesType(type, payload);
|
|
123
291
|
if (type === 'sources' && !runId) {
|
|
124
|
-
throw new
|
|
292
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', ['a sources chunk requires runId']);
|
|
125
293
|
}
|
|
126
294
|
if (type === 'sources' && !ragSourcesWithinBounds(payload.sources)) {
|
|
127
|
-
throw new
|
|
295
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', ['a sources chunk exceeds its wire bounds']);
|
|
128
296
|
}
|
|
129
297
|
if (capability && type !== 'run-request') {
|
|
130
|
-
throw new
|
|
298
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', ['only a run-request carries a capability']);
|
|
299
|
+
}
|
|
300
|
+
if (runnerDeviceId && (type !== 'run-request' || capability)) {
|
|
301
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', ['only a run-request for an agent names a runner']);
|
|
302
|
+
}
|
|
303
|
+
if (sourceId && type !== 'attachment') {
|
|
304
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', ['only an attachment is derived from another']);
|
|
131
305
|
}
|
|
132
306
|
if (type === 'user-message' && !store.ourMemberId) {
|
|
133
307
|
await store.refreshOurMember();
|
|
134
308
|
}
|
|
309
|
+
if (type === 'agent-switch' && (runId || parentId)) {
|
|
310
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', ['an agent-switch belongs to the chat, not a run']);
|
|
311
|
+
}
|
|
312
|
+
if ((type === 'context' || type === 'model-request') && !runId) {
|
|
313
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', [`a ${type} chunk requires runId`]);
|
|
314
|
+
}
|
|
315
|
+
if ((type === 'context' || type === 'model-request') &&
|
|
316
|
+
!(store.ourDeviceId && b4a.equals(store.ourDeviceId, originDeviceId))) {
|
|
317
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', [
|
|
318
|
+
`a ${type} chunk is written by its origin device`
|
|
319
|
+
]);
|
|
320
|
+
}
|
|
135
321
|
if (parentId) {
|
|
136
322
|
const parent = await getChunk(store, parentId);
|
|
137
323
|
if (!parent || parent.chatId !== chatId) {
|
|
138
|
-
throw new
|
|
324
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', [
|
|
325
|
+
`parentId is not a chunk in this chat: ${parentId}`
|
|
326
|
+
]);
|
|
139
327
|
}
|
|
328
|
+
await requireRoundOutput(store, { type, runId }, parent);
|
|
140
329
|
}
|
|
330
|
+
const senderMemberId = type === 'user-message' && store.ourDeviceId && b4a.equals(store.ourDeviceId, originDeviceId)
|
|
331
|
+
? store.ourMemberId || undefined
|
|
332
|
+
: undefined;
|
|
141
333
|
const op = {
|
|
142
334
|
id,
|
|
143
335
|
chatId,
|
|
@@ -152,15 +344,21 @@ export async function appendChunk(store, { id = randomId(), chatId, runId, type,
|
|
|
152
344
|
capability,
|
|
153
345
|
capabilityArgs,
|
|
154
346
|
enhance,
|
|
347
|
+
sourceId,
|
|
348
|
+
falsyResult: falsyResultOf(payload),
|
|
155
349
|
round,
|
|
156
350
|
callId,
|
|
157
351
|
resumed,
|
|
352
|
+
runnerDeviceId,
|
|
158
353
|
createdAt: Date.now(),
|
|
159
|
-
senderMemberId
|
|
160
|
-
|
|
161
|
-
: undefined,
|
|
354
|
+
senderMemberId,
|
|
355
|
+
senderNameAtSend: senderMemberId ? senderNameAtSend : undefined,
|
|
162
356
|
...payload
|
|
163
357
|
};
|
|
358
|
+
if (op.modelRequest && runId) {
|
|
359
|
+
const host = await namedHost(store, op.modelRequest.agents?.[0]);
|
|
360
|
+
op.modelRequest = { ...op.modelRequest, hostDeviceId: host };
|
|
361
|
+
}
|
|
164
362
|
await into.dispatch('append-chunk', op);
|
|
165
363
|
if (type === 'attachment') {
|
|
166
364
|
await store.fileIndex?.record([op]);
|
|
@@ -186,18 +384,24 @@ export function updateOp(chunk, { id, runStatus, attachment }) {
|
|
|
186
384
|
(runStatus === null || runStatus === undefined)) {
|
|
187
385
|
return { id, attachment, updatedAt: Date.now() };
|
|
188
386
|
}
|
|
189
|
-
throw new
|
|
387
|
+
throw new CoreError('CHUNK_PAYLOAD_INVALID', [
|
|
388
|
+
'a run-status edits runStatus, an attachment edits attachment'
|
|
389
|
+
]);
|
|
190
390
|
}
|
|
191
391
|
const DEFAULT_APPROVAL_RULE_TTL_MS = 60 * 60 * 1000;
|
|
192
|
-
export async function
|
|
392
|
+
export async function othersApproval(store, id) {
|
|
393
|
+
const ask = await getChunk(store, id);
|
|
394
|
+
return !!ask && (await projectRun(store)) && !(await ownedByUs(store, ask));
|
|
395
|
+
}
|
|
396
|
+
export async function resolveApproval(store, { id, approved, scope, expiresAt, agentId }, rules = store) {
|
|
193
397
|
const before = await getChunk(store, id);
|
|
194
398
|
const wasPending = before?.type === 'approval-request' && before.approvalRequest?.status === 'pending';
|
|
195
399
|
await store.dispatch('resolve-approval', { id, approved, resolvedAt: Date.now() });
|
|
196
400
|
const resolved = await mustGetChunk(store, id);
|
|
197
|
-
if (scope === 'always' && wasPending) {
|
|
401
|
+
if (rules && scope === 'always' && wasPending) {
|
|
198
402
|
const ask = resolved.approvalRequest;
|
|
199
403
|
if (ask && (ask.status === 'approved' || ask.status === 'denied')) {
|
|
200
|
-
await putApprovalRule(
|
|
404
|
+
await putApprovalRule(rules, {
|
|
201
405
|
toolName: ask.name,
|
|
202
406
|
resourceKind: ask.resource?.kind ?? undefined,
|
|
203
407
|
resourcePattern: ask.resource?.label ?? undefined,
|
|
@@ -213,24 +417,25 @@ export async function resolveApproval(store, { id, approved, scope, expiresAt, a
|
|
|
213
417
|
export async function listRunRequests(store, deviceId) {
|
|
214
418
|
if (!deviceId)
|
|
215
419
|
return [];
|
|
420
|
+
const project = await projectRun(store);
|
|
216
421
|
const snap = store.view.snapshot();
|
|
217
422
|
try {
|
|
218
423
|
const requests = await snap.find(RUN_REQUESTS).toArray();
|
|
219
|
-
const
|
|
424
|
+
const agents = new Map();
|
|
220
425
|
const mine = [];
|
|
221
426
|
for (const request of requests) {
|
|
222
427
|
if (store.closing)
|
|
223
428
|
return mine;
|
|
224
429
|
const agentId = request.runRequest?.agentId;
|
|
225
|
-
if (!agentId) {
|
|
430
|
+
if (!agentId || (project && !(await ownedByUs(store, request)))) {
|
|
226
431
|
continue;
|
|
227
432
|
}
|
|
228
|
-
if (!
|
|
229
|
-
|
|
230
|
-
providers.set(agentId, agent?.providerDeviceId);
|
|
433
|
+
if (!agents.has(agentId)) {
|
|
434
|
+
agents.set(agentId, await runDefinition(store, await snap.get(AGENTS, { id: agentId })));
|
|
231
435
|
}
|
|
232
|
-
const
|
|
233
|
-
|
|
436
|
+
const agent = agents.get(agentId);
|
|
437
|
+
const listed = offeredTo(request, deviceId) || handedOff(request, deviceId);
|
|
438
|
+
if (agent && (listed || drivenBy({ request, agent }, deviceId))) {
|
|
234
439
|
mine.push(request);
|
|
235
440
|
}
|
|
236
441
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const CHUNKS = "@qvac/chunks";
|
|
2
|
+
export declare const CHAT_CHUNKS = "@qvac/chat-chunks";
|
|
2
3
|
export declare const CHUNK_COUNTERS = "@qvac/chunk-counters";
|
|
3
4
|
export declare const AGENTS = "@qvac/agents";
|
|
4
5
|
export declare const APPROVAL_RULES = "@qvac/approval-rules";
|
|
@@ -20,6 +21,7 @@ export declare const INDEXING_STATUS_BY_KNOWLEDGE = "@qvac/indexing-status-by-kn
|
|
|
20
21
|
export declare const HISTORY_CHUNKS = "@qvac/history-chunks";
|
|
21
22
|
export declare const INDEXING_STATUS_BY_CHAT = "@qvac/indexing-status-by-chat";
|
|
22
23
|
export declare const ACTIVE_KNOWLEDGE_BY_CHAT = "@qvac/active-knowledge-by-chat";
|
|
24
|
+
export declare const ACTIVE_KNOWLEDGE_BASE = "@qvac/active-knowledge-base";
|
|
23
25
|
export declare const TOOL_CONFIGS = "@qvac/tool-configs";
|
|
24
26
|
export declare const TOOL_ACTIVITY = "@qvac/tool-activity";
|
|
25
27
|
export declare const TOOL_ACTIVITY_COUNTER = "@qvac/tool-activity-counter";
|
|
@@ -57,14 +59,51 @@ export declare const LOCAL_FILES = "@local/files";
|
|
|
57
59
|
export declare const LOCAL_FILES_BY_BLOB = "@local/files-by-blob";
|
|
58
60
|
export declare const LOCAL_RECLAIMABLE_FILES_BY_LAST_ACCESSED = "@local/reclaimable-files-by-last-accessed";
|
|
59
61
|
export declare const LOCAL_LIVE_FILES = "@local/live-files";
|
|
62
|
+
export declare const LOCAL_CHAT_MOVES = "@local/chat-moves";
|
|
63
|
+
export declare const LOCAL_MESH_UPDATES = "@local/mesh-updates";
|
|
64
|
+
export declare const LOCAL_MESH_PURGES = "@local/mesh-purges";
|
|
65
|
+
export declare const LOCAL_MESH_NAMES = "@local/mesh-names";
|
|
66
|
+
export declare const LOCAL_RUN_LOGS = "@local/run-logs";
|
|
67
|
+
export declare const LOCAL_RUN_LOG_STEPS = "@local/run-log-steps";
|
|
60
68
|
export declare const LOCAL_MESH_SESSION = "@local/mesh-session";
|
|
61
69
|
export declare const LOCAL_MESH_HISTORY = "@local/mesh-history";
|
|
62
70
|
export declare const LOCAL_MEMBERSHIP = "@local/membership";
|
|
63
|
-
export declare const INDEX_BACKFILLS = "@qvac/index-backfills";
|
|
64
71
|
export declare const LIVE_DEVICES_BY_WRITER_KEY = "@qvac/live-devices-by-writer-key";
|
|
72
|
+
export declare const LIVE_DEVICES_BY_MEMBER = "@qvac/live-devices-by-member";
|
|
73
|
+
export declare const DEVICES_BY_MEMBER = "@qvac/devices-by-member";
|
|
74
|
+
export declare const AGENT_HOSTS_BY_AGENT = "@qvac/agent-hosts-by-agent";
|
|
75
|
+
export declare const AGENT_HOSTS_BY_DEVICE = "@qvac/agent-hosts-by-device";
|
|
76
|
+
export declare const PUBLIC_SEEDS_BY_DEVICE = "@qvac/public-seeds-by-device";
|
|
77
|
+
export declare const PROJECT_HOST_KEYS_BY_DEVICE = "@qvac/project-host-keys-by-device";
|
|
78
|
+
export declare const PROJECT_DEVICE_KEYS_BY_DEVICE = "@qvac/project-device-keys-by-device";
|
|
79
|
+
export declare const PROJECT_DEVICE_KEYS_BY_MEMBER = "@qvac/project-device-keys-by-member";
|
|
80
|
+
export declare const AGENT_USERS_BY_USER = "@qvac/agent-users-by-user";
|
|
81
|
+
export declare const PROJECT_KEYS_BY_MEMBER = "@qvac/project-keys-by-member";
|
|
82
|
+
export declare const TERMINAL_RUN_STATUSES = "@qvac/terminal-run-statuses";
|
|
65
83
|
export declare const MEMBER_REMOVALS = "@qvac/member-removals";
|
|
66
84
|
export declare const INVITE_SEQUENCES = "@qvac/invite-sequences";
|
|
67
85
|
export declare const MESH_INVITE_SPENDS = "@qvac/mesh-invite-spends";
|
|
68
86
|
export declare const MESH_INVITE_GRANTS = "@qvac/mesh-invite-grants";
|
|
69
87
|
export declare const MESH_FOUNDERS = "@qvac/mesh-founders";
|
|
70
88
|
export declare const MESH_KINDS = "@qvac/mesh-kinds";
|
|
89
|
+
export declare const MESH_NAMES = "@qvac/mesh-names";
|
|
90
|
+
export declare const MESH_SEEDS = "@qvac/mesh-seeds";
|
|
91
|
+
export declare const MESH_RULES = "@qvac/mesh-rules";
|
|
92
|
+
export declare const PUBLIC_MESHES = "@qvac/public-meshes";
|
|
93
|
+
export declare const WORKSPACE = "@qvac/workspace";
|
|
94
|
+
export declare const MEMBER_ROLES = "@qvac/member-roles";
|
|
95
|
+
export declare const PUBLIC_SEEDS = "@qvac/public-seeds";
|
|
96
|
+
export declare const PROJECTS = "@qvac/projects";
|
|
97
|
+
export declare const PROJECT_MEMBERS = "@qvac/project-members";
|
|
98
|
+
export declare const PROJECT_ORDER = "@qvac/project-order";
|
|
99
|
+
export declare const CHAT_READS = "@qvac/chat-reads";
|
|
100
|
+
export declare const RUN_REQUEST_BY_RUN = "@qvac/run-request-by-run";
|
|
101
|
+
export declare const KNOWLEDGE_CAPS = "@qvac/knowledge-caps";
|
|
102
|
+
export declare const LIVE_MODEL_REQUESTS = "@qvac/live-model-requests";
|
|
103
|
+
export declare const AGENT_HOSTS = "@qvac/agent-hosts";
|
|
104
|
+
export declare const AGENT_USERS = "@qvac/agent-users";
|
|
105
|
+
export declare const MEMBER_KEYS = "@qvac/member-keys";
|
|
106
|
+
export declare const PROJECT_KEYS = "@qvac/project-keys";
|
|
107
|
+
export declare const PROJECT_HOST_KEYS = "@qvac/project-host-keys";
|
|
108
|
+
export declare const PROJECT_DEVICE_KEYS = "@qvac/project-device-keys";
|
|
109
|
+
export declare const SKILL_SECRETS = "@qvac/skill-secrets";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const CHUNKS = '@qvac/chunks';
|
|
2
|
+
export const CHAT_CHUNKS = '@qvac/chat-chunks';
|
|
2
3
|
export const CHUNK_COUNTERS = '@qvac/chunk-counters';
|
|
3
4
|
export const AGENTS = '@qvac/agents';
|
|
4
5
|
export const APPROVAL_RULES = '@qvac/approval-rules';
|
|
@@ -20,6 +21,7 @@ export const INDEXING_STATUS_BY_KNOWLEDGE = '@qvac/indexing-status-by-knowledge'
|
|
|
20
21
|
export const HISTORY_CHUNKS = '@qvac/history-chunks';
|
|
21
22
|
export const INDEXING_STATUS_BY_CHAT = '@qvac/indexing-status-by-chat';
|
|
22
23
|
export const ACTIVE_KNOWLEDGE_BY_CHAT = '@qvac/active-knowledge-by-chat';
|
|
24
|
+
export const ACTIVE_KNOWLEDGE_BASE = '@qvac/active-knowledge-base';
|
|
23
25
|
export const TOOL_CONFIGS = '@qvac/tool-configs';
|
|
24
26
|
export const TOOL_ACTIVITY = '@qvac/tool-activity';
|
|
25
27
|
export const TOOL_ACTIVITY_COUNTER = '@qvac/tool-activity-counter';
|
|
@@ -57,14 +59,51 @@ export const LOCAL_FILES = '@local/files';
|
|
|
57
59
|
export const LOCAL_FILES_BY_BLOB = '@local/files-by-blob';
|
|
58
60
|
export const LOCAL_RECLAIMABLE_FILES_BY_LAST_ACCESSED = '@local/reclaimable-files-by-last-accessed';
|
|
59
61
|
export const LOCAL_LIVE_FILES = '@local/live-files';
|
|
62
|
+
export const LOCAL_CHAT_MOVES = '@local/chat-moves';
|
|
63
|
+
export const LOCAL_MESH_UPDATES = '@local/mesh-updates';
|
|
64
|
+
export const LOCAL_MESH_PURGES = '@local/mesh-purges';
|
|
65
|
+
export const LOCAL_MESH_NAMES = '@local/mesh-names';
|
|
66
|
+
export const LOCAL_RUN_LOGS = '@local/run-logs';
|
|
67
|
+
export const LOCAL_RUN_LOG_STEPS = '@local/run-log-steps';
|
|
60
68
|
export const LOCAL_MESH_SESSION = '@local/mesh-session';
|
|
61
69
|
export const LOCAL_MESH_HISTORY = '@local/mesh-history';
|
|
62
70
|
export const LOCAL_MEMBERSHIP = '@local/membership';
|
|
63
|
-
export const INDEX_BACKFILLS = '@qvac/index-backfills';
|
|
64
71
|
export const LIVE_DEVICES_BY_WRITER_KEY = '@qvac/live-devices-by-writer-key';
|
|
72
|
+
export const LIVE_DEVICES_BY_MEMBER = '@qvac/live-devices-by-member';
|
|
73
|
+
export const DEVICES_BY_MEMBER = '@qvac/devices-by-member';
|
|
74
|
+
export const AGENT_HOSTS_BY_AGENT = '@qvac/agent-hosts-by-agent';
|
|
75
|
+
export const AGENT_HOSTS_BY_DEVICE = '@qvac/agent-hosts-by-device';
|
|
76
|
+
export const PUBLIC_SEEDS_BY_DEVICE = '@qvac/public-seeds-by-device';
|
|
77
|
+
export const PROJECT_HOST_KEYS_BY_DEVICE = '@qvac/project-host-keys-by-device';
|
|
78
|
+
export const PROJECT_DEVICE_KEYS_BY_DEVICE = '@qvac/project-device-keys-by-device';
|
|
79
|
+
export const PROJECT_DEVICE_KEYS_BY_MEMBER = '@qvac/project-device-keys-by-member';
|
|
80
|
+
export const AGENT_USERS_BY_USER = '@qvac/agent-users-by-user';
|
|
81
|
+
export const PROJECT_KEYS_BY_MEMBER = '@qvac/project-keys-by-member';
|
|
82
|
+
export const TERMINAL_RUN_STATUSES = '@qvac/terminal-run-statuses';
|
|
65
83
|
export const MEMBER_REMOVALS = '@qvac/member-removals';
|
|
66
84
|
export const INVITE_SEQUENCES = '@qvac/invite-sequences';
|
|
67
85
|
export const MESH_INVITE_SPENDS = '@qvac/mesh-invite-spends';
|
|
68
86
|
export const MESH_INVITE_GRANTS = '@qvac/mesh-invite-grants';
|
|
69
87
|
export const MESH_FOUNDERS = '@qvac/mesh-founders';
|
|
70
88
|
export const MESH_KINDS = '@qvac/mesh-kinds';
|
|
89
|
+
export const MESH_NAMES = '@qvac/mesh-names';
|
|
90
|
+
export const MESH_SEEDS = '@qvac/mesh-seeds';
|
|
91
|
+
export const MESH_RULES = '@qvac/mesh-rules';
|
|
92
|
+
export const PUBLIC_MESHES = '@qvac/public-meshes';
|
|
93
|
+
export const WORKSPACE = '@qvac/workspace';
|
|
94
|
+
export const MEMBER_ROLES = '@qvac/member-roles';
|
|
95
|
+
export const PUBLIC_SEEDS = '@qvac/public-seeds';
|
|
96
|
+
export const PROJECTS = '@qvac/projects';
|
|
97
|
+
export const PROJECT_MEMBERS = '@qvac/project-members';
|
|
98
|
+
export const PROJECT_ORDER = '@qvac/project-order';
|
|
99
|
+
export const CHAT_READS = '@qvac/chat-reads';
|
|
100
|
+
export const RUN_REQUEST_BY_RUN = '@qvac/run-request-by-run';
|
|
101
|
+
export const KNOWLEDGE_CAPS = '@qvac/knowledge-caps';
|
|
102
|
+
export const LIVE_MODEL_REQUESTS = '@qvac/live-model-requests';
|
|
103
|
+
export const AGENT_HOSTS = '@qvac/agent-hosts';
|
|
104
|
+
export const AGENT_USERS = '@qvac/agent-users';
|
|
105
|
+
export const MEMBER_KEYS = '@qvac/member-keys';
|
|
106
|
+
export const PROJECT_KEYS = '@qvac/project-keys';
|
|
107
|
+
export const PROJECT_HOST_KEYS = '@qvac/project-host-keys';
|
|
108
|
+
export const PROJECT_DEVICE_KEYS = '@qvac/project-device-keys';
|
|
109
|
+
export const SKILL_SECRETS = '@qvac/skill-secrets';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface StoredConfigValue {
|
|
2
|
+
readonly value?: unknown;
|
|
3
|
+
readonly falsyValue?: string | null;
|
|
4
|
+
}
|
|
5
|
+
export declare function configValue(value: unknown): StoredConfigValue;
|
|
6
|
+
export declare function readConfigValue({ value, falsyValue }: StoredConfigValue): unknown;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const FALSY_VALUES = new Map([
|
|
2
|
+
['false', false],
|
|
3
|
+
['0', 0],
|
|
4
|
+
['""', '']
|
|
5
|
+
]);
|
|
6
|
+
export function configValue(value) {
|
|
7
|
+
return value === false || value === 0 || value === ''
|
|
8
|
+
? { value: null, falsyValue: JSON.stringify(value) }
|
|
9
|
+
: { value };
|
|
10
|
+
}
|
|
11
|
+
export function readConfigValue({ value, falsyValue }) {
|
|
12
|
+
const falsy = falsyValue ?? '';
|
|
13
|
+
return FALSY_VALUES.has(falsy) ? FALSY_VALUES.get(falsy) : (value ?? null);
|
|
14
|
+
}
|
|
@@ -7,8 +7,9 @@ type RouteHandler<T> = (op: T, ctx: RouterContext) => Promise<unknown>;
|
|
|
7
7
|
export declare function trackActivity<T>(handler: RouteHandler<T>): RouteHandler<T>;
|
|
8
8
|
export declare function devicesByWriterKey(tx: HyperDB, writerKey: Buffer): HyperDBStream<QvacDevice>;
|
|
9
9
|
export declare function liveDeviceForWriter(db: HyperDB, writerKey: Buffer): Promise<QvacDevice | null>;
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
10
|
+
export declare function liveDevicesOf(db: HyperDB, memberId: Buffer): Promise<QvacDevice[]>;
|
|
11
|
+
export declare function devicesOfMember(db: HyperDB, memberId: Buffer): Promise<QvacDevice[]>;
|
|
12
|
+
export declare function liveDevices(db: HyperDB): AsyncGenerator<QvacDevice>;
|
|
12
13
|
export interface MarkWriterRevokedOptions {
|
|
13
14
|
readonly revoked: boolean;
|
|
14
15
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import {
|
|
2
|
+
import { WORKSPACES_RULES, rulesVersion } from './mesh-rules.js';
|
|
3
|
+
import { DEVICES, DEVICES_BY_WRITER_KEY, DEVICES_BY_MEMBER, LIVE_DEVICES_BY_MEMBER, LIVE_DEVICES_BY_WRITER_KEY, WRITER_ACTIVITY } from '../collections.js';
|
|
3
4
|
export function trackActivity(handler) {
|
|
4
5
|
return async (op, ctx) => {
|
|
5
6
|
const applied = await handler(op, ctx);
|
|
@@ -15,35 +16,52 @@ export function devicesByWriterKey(tx, writerKey) {
|
|
|
15
16
|
lte: { writerKey }
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
|
-
export
|
|
19
|
-
if (!(await liveDevicesIndexed(db))) {
|
|
20
|
-
for await (const device of devicesByWriterKey(db, writerKey)) {
|
|
21
|
-
if (!device.revoked)
|
|
22
|
-
return device;
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
19
|
+
export function liveDeviceForWriter(db, writerKey) {
|
|
26
20
|
return db.findOne(LIVE_DEVICES_BY_WRITER_KEY, {
|
|
27
21
|
gte: { writerKey },
|
|
28
22
|
lte: { writerKey }
|
|
29
23
|
});
|
|
30
24
|
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
|
|
25
|
+
async function indexed(db) {
|
|
26
|
+
return (await rulesVersion(db)) >= WORKSPACES_RULES;
|
|
27
|
+
}
|
|
28
|
+
function ownerOf(device) {
|
|
29
|
+
return device.memberId ?? device.claimedMemberId ?? null;
|
|
30
|
+
}
|
|
31
|
+
async function scanDevicesOf(db, memberId) {
|
|
32
|
+
const rows = [];
|
|
33
|
+
for await (const device of db.find(DEVICES)) {
|
|
34
|
+
const owner = ownerOf(device);
|
|
35
|
+
if (owner && b4a.equals(owner, memberId)) {
|
|
36
|
+
rows.push(device);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return rows;
|
|
40
|
+
}
|
|
41
|
+
export async function liveDevicesOf(db, memberId) {
|
|
42
|
+
if (!(await indexed(db))) {
|
|
43
|
+
return (await scanDevicesOf(db, memberId)).filter((device) => !device.revoked);
|
|
44
|
+
}
|
|
45
|
+
return db
|
|
46
|
+
.find(LIVE_DEVICES_BY_MEMBER, { gte: { memberId }, lte: { memberId } })
|
|
47
|
+
.toArray();
|
|
34
48
|
}
|
|
35
|
-
export async function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
indexed.add(b4a.toHex(device.id));
|
|
49
|
+
export async function devicesOfMember(db, memberId) {
|
|
50
|
+
if (!(await indexed(db))) {
|
|
51
|
+
return scanDevicesOf(db, memberId);
|
|
39
52
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
return db.find(DEVICES_BY_MEMBER, { gte: { memberId }, lte: { memberId } }).toArray();
|
|
54
|
+
}
|
|
55
|
+
export async function* liveDevices(db) {
|
|
56
|
+
if (!(await indexed(db))) {
|
|
57
|
+
for await (const device of db.find(DEVICES)) {
|
|
58
|
+
if (!device.revoked && ownerOf(device)) {
|
|
59
|
+
yield device;
|
|
60
|
+
}
|
|
43
61
|
}
|
|
44
|
-
|
|
62
|
+
return;
|
|
45
63
|
}
|
|
46
|
-
|
|
64
|
+
yield* db.find(LIVE_DEVICES_BY_MEMBER);
|
|
47
65
|
}
|
|
48
66
|
export async function markWriterRevoked(tx, writerKey, opts) {
|
|
49
67
|
const { revoked } = opts;
|