@qvac/core 1.0.0-rc.1 → 1.0.0-rc.2
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 +852 -1
- package/README.md +40 -81
- package/dist-lib/index.d.ts +0 -1
- package/dist-lib/index.js +0 -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 +7 -0
- package/dist-lib/lib/api/chunk-delta.js +33 -0
- package/dist-lib/lib/api/chunks.d.ts +17 -2
- package/dist-lib/lib/api/chunks.js +64 -13
- package/dist-lib/lib/api/config.d.ts +2 -1
- package/dist-lib/lib/api/config.js +3 -2
- 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 +10 -8
- 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 +20 -10
- 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/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 +12 -44
- 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 +64 -17
- package/dist-lib/lib/api/mesh.d.ts +12 -2
- package/dist-lib/lib/api/mesh.js +10 -6
- 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 +6 -5
- package/dist-lib/lib/api/projects.d.ts +20 -0
- package/dist-lib/lib/api/projects.js +165 -0
- package/dist-lib/lib/api/rag.d.ts +0 -1
- package/dist-lib/lib/api/rag.js +47 -23
- package/dist-lib/lib/api/served.d.ts +17 -0
- package/dist-lib/lib/api/served.js +47 -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 +48 -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 +29 -29
- package/dist-lib/lib/assistant/harness.js +34 -6
- package/dist-lib/lib/assistant/history.d.ts +30 -17
- package/dist-lib/lib/assistant/history.js +168 -82
- 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 +21 -0
- package/dist-lib/lib/assistant/message.js +43 -0
- package/dist-lib/lib/assistant/model-round.d.ts +95 -0
- package/dist-lib/lib/assistant/model-round.js +591 -0
- package/dist-lib/lib/assistant/pdf-budget.d.ts +3 -0
- package/dist-lib/lib/assistant/pdf-budget.js +13 -0
- package/dist-lib/lib/assistant/round-host.d.ts +42 -0
- package/dist-lib/lib/assistant/round-host.js +239 -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 +2 -0
- package/dist-lib/lib/assistant-client.js +4 -3
- package/dist-lib/lib/assistant-tree.d.ts +8 -3
- package/dist-lib/lib/assistant-tree.js +58 -18
- package/dist-lib/lib/assistant.d.ts +76 -20
- package/dist-lib/lib/assistant.js +1659 -1070
- 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/constants.d.ts +7 -0
- package/dist-lib/lib/constants.js +7 -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 +36 -22
- 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 +245 -0
- package/dist-lib/lib/core/chat-group.js +8 -7
- package/dist-lib/lib/core/chat-move.d.ts +71 -0
- package/dist-lib/lib/core/chat-move.js +567 -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 +34 -4
- package/dist-lib/lib/core/chat.js +122 -39
- package/dist-lib/lib/core/chunk.d.ts +21 -4
- package/dist-lib/lib/core/chunk.js +138 -23
- package/dist-lib/lib/core/collections.d.ts +28 -0
- package/dist-lib/lib/core/collections.js +28 -0
- package/dist-lib/lib/core/contract/agent-join.d.ts +10 -0
- package/dist-lib/lib/core/contract/agent-join.js +108 -0
- package/dist-lib/lib/core/contract/agents.d.ts +5 -0
- package/dist-lib/lib/core/contract/agents.js +141 -3
- package/dist-lib/lib/core/contract/chat.d.ts +1 -0
- package/dist-lib/lib/core/contract/chat.js +42 -3
- package/dist-lib/lib/core/contract/chunks.d.ts +7 -0
- package/dist-lib/lib/core/contract/chunks.js +112 -35
- package/dist-lib/lib/core/contract/index.d.ts +2 -3
- package/dist-lib/lib/core/contract/index.js +35 -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 +18 -9
- package/dist-lib/lib/core/contract/joined-meshes.js +2 -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 +31 -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 +279 -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 +29 -0
- package/dist-lib/lib/core/contract/project-host-keys.d.ts +7 -0
- package/dist-lib/lib/core/contract/project-host-keys.js +40 -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 +328 -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 +120 -0
- package/dist-lib/lib/core/contract/run-requests.d.ts +10 -0
- package/dist-lib/lib/core/contract/run-requests.js +75 -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/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 +317 -0
- package/dist-lib/lib/core/contract/writers.js +82 -12
- 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.js +1 -1
- package/dist-lib/lib/core/document-attachment.d.ts +7 -0
- package/dist-lib/lib/core/document-attachment.js +9 -0
- package/dist-lib/lib/core/files/attachments.js +5 -4
- package/dist-lib/lib/core/files/index.d.ts +21 -11
- package/dist-lib/lib/core/files/index.js +114 -28
- 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 +7 -2
- package/dist-lib/lib/core/files/processing/index.js +91 -71
- 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 +3 -0
- package/dist-lib/lib/core/files/processing/source.js +9 -4
- package/dist-lib/lib/core/files/processing/state.d.ts +4 -1
- package/dist-lib/lib/core/files/processing/state.js +2 -1
- package/dist-lib/lib/core/files/rag/build.d.ts +4 -1
- package/dist-lib/lib/core/files/rag/build.js +18 -7
- 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 +12 -1
- package/dist-lib/lib/core/files/rag/index.js +29 -7
- 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 +30 -18
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +1 -1
- 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/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 +4 -0
- package/dist-lib/lib/core/invite.js +19 -6
- 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 +76 -6
- package/dist-lib/lib/core/local/index.js +209 -19
- 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 +94 -28
- package/dist-lib/lib/core/mesh.js +527 -144
- 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/file-index.js +2 -4
- package/dist-lib/lib/core/migrations/index.js +6 -2
- 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 +4 -2
- package/dist-lib/lib/core/pdf/rasterize.d.ts +2 -2
- package/dist-lib/lib/core/pdf/rasterize.js +5 -6
- package/dist-lib/lib/core/peer-duplex.d.ts +34 -0
- package/dist-lib/lib/core/{harness-loan.js → peer-duplex.js} +47 -40
- 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 +88 -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 +59 -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 +18 -0
- package/dist-lib/lib/core/senders.js +52 -0
- package/dist-lib/lib/core/shared-agents.d.ts +39 -0
- package/dist-lib/lib/core/shared-agents.js +255 -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 +47 -0
- package/dist-lib/lib/core/sync/background.js +162 -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 +1 -1
- 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 +154 -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/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 +249 -79
- package/dist-lib/lib/core.js +3369 -1460
- package/dist-lib/lib/credential-pusher.d.ts +6 -0
- package/dist-lib/lib/credential-pusher.js +77 -60
- 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/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 +790 -0
- package/dist-lib/lib/errors.js +724 -0
- package/dist-lib/lib/fs-drive-bridge.d.ts +1 -1
- package/dist-lib/lib/fs-drive-bridge.js +4 -1
- 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/knowledge-search.js +13 -18
- 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/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 +11 -12
- package/dist-lib/lib/model-download.js +63 -22
- 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/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/run-input.d.ts +14 -0
- package/dist-lib/lib/run-input.js +33 -0
- package/dist-lib/lib/run-notices.d.ts +3 -0
- package/dist-lib/lib/run-notices.js +8 -2
- package/dist-lib/lib/run-replay.d.ts +32 -0
- package/dist-lib/lib/run-replay.js +121 -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 +3 -1
- 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 +58 -11
- package/dist-lib/schema/engine.d.ts +1 -0
- package/dist-lib/schema/engine.js +709 -116
- package/dist-lib/schema/field-order.js +2 -1
- package/dist-lib/schema/indexes.d.ts +3 -0
- package/dist-lib/schema/indexes.js +30 -3
- package/dist-lib/schema/local.js +72 -4
- package/dist-lib/schema/qvac.d.ts +4 -1
- package/dist-lib/schema/qvac.js +364 -12
- package/dist-lib/spec/bind.js +209 -48
- package/dist-lib/spec/calls.js +45 -5
- package/dist-lib/spec/capabilities.d.ts +98 -18
- package/dist-lib/spec/config/hyperconf/index.js +1 -1
- package/dist-lib/spec/hrpc/hrpc.json +726 -206
- package/dist-lib/spec/hrpc/index.js +832 -345
- package/dist-lib/spec/hrpc/messages.js +6906 -4832
- package/dist-lib/spec/hyperschema/index.js +6906 -4832
- package/dist-lib/spec/hyperschema/schema.json +4744 -3139
- package/dist-lib/spec/hyperschema/types.d.ts +461 -61
- 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 +1506 -484
- package/dist-lib/spec/local/hyperschema/index.js +542 -13
- package/dist-lib/spec/local/hyperschema/schema.json +319 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +78 -2
- package/dist-lib/spec/mesh/hyperdb/db.json +371 -5
- package/dist-lib/spec/mesh/hyperdb/index.js +1564 -5
- package/dist-lib/spec/mesh/hyperdb/messages.js +6023 -1246
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +187 -1
- package/dist-lib/spec/mesh/hyperdispatch/index.js +528 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +3449 -217
- package/dist-lib/spec/mesh/hyperschema/index.js +3449 -217
- package/dist-lib/spec/mesh/hyperschema/schema.json +1865 -19
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +470 -6
- package/package.json +50 -35
- package/worker/assistant-sidecar.mjs +15 -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/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/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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { allTools } from '../agent.js';
|
|
2
|
+
import { AGENTS } from '../collections.js';
|
|
3
|
+
export async function migrateAgentToolsScope(mesh) {
|
|
4
|
+
const scoped = await selectedScopeAgents(mesh);
|
|
5
|
+
for (const agent of scoped) {
|
|
6
|
+
await mesh.dispatch('put-agent', { agent: { ...agent, ...allTools() } });
|
|
7
|
+
}
|
|
8
|
+
return scoped.length > 0;
|
|
9
|
+
}
|
|
10
|
+
async function selectedScopeAgents(mesh) {
|
|
11
|
+
const snap = mesh.view.snapshot();
|
|
12
|
+
try {
|
|
13
|
+
const scoped = [];
|
|
14
|
+
for await (const agent of snap.find(AGENTS)) {
|
|
15
|
+
if (!agent.deletedAt && agent.toolsScope === 'selected') {
|
|
16
|
+
scoped.push(agent);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return scoped;
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
await snap.close();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { attachmentChunks } from '../files/records/sweep.js';
|
|
2
2
|
const BATCH = 256;
|
|
3
3
|
export async function backfillFileIndex(mesh) {
|
|
4
4
|
const index = mesh.fileIndex;
|
|
@@ -8,11 +8,9 @@ export async function backfillFileIndex(mesh) {
|
|
|
8
8
|
const snapshot = mesh.view.snapshot();
|
|
9
9
|
try {
|
|
10
10
|
let batch = [];
|
|
11
|
-
for await (const chunk of snapshot
|
|
11
|
+
for await (const chunk of attachmentChunks(snapshot)) {
|
|
12
12
|
if (mesh.closing)
|
|
13
13
|
return;
|
|
14
|
-
if (chunk.type !== 'attachment')
|
|
15
|
-
continue;
|
|
16
14
|
batch.push(chunk);
|
|
17
15
|
if (batch.length < BATCH) {
|
|
18
16
|
continue;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { inRole } from '../contract/roles.js';
|
|
1
2
|
import { migrateAgentCatalog } from './agent-catalog.js';
|
|
3
|
+
import { migrateAgentToolsScope } from './agent-tools-scope.js';
|
|
2
4
|
import { migrateMembership } from './membership.js';
|
|
3
5
|
import { sealDeviceRows } from './seal.js';
|
|
4
6
|
import { reindexAgents } from './agent-indexes.js';
|
|
@@ -6,8 +8,10 @@ import { reindexDevices } from './device-indexes.js';
|
|
|
6
8
|
export async function runMigrations(mesh, context, { catalog = true } = {}) {
|
|
7
9
|
const devices = await reindexDevices(mesh);
|
|
8
10
|
const membership = await migrateMembership(mesh, context);
|
|
9
|
-
const
|
|
11
|
+
const holdsAgents = mesh.role !== 'public' && inRole(mesh.role, '@qvac/put-agent');
|
|
12
|
+
const agents = holdsAgents && catalog && (await migrateAgentCatalog(mesh, context));
|
|
10
13
|
const seal = await sealDeviceRows(mesh, context);
|
|
11
14
|
const indexed = await reindexAgents(mesh);
|
|
12
|
-
|
|
15
|
+
const tools = holdsAgents && (await migrateAgentToolsScope(mesh));
|
|
16
|
+
return devices || membership || agents || seal || indexed || tools;
|
|
13
17
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { QvacChunk } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
import type { Mesh } from './mesh.ts';
|
|
3
|
+
export interface SettleModelRequestInput {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly state: 'done' | 'failed';
|
|
6
|
+
readonly result?: unknown;
|
|
7
|
+
readonly reason?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function takeModelRequest(store: Mesh, id: string): Promise<QvacChunk>;
|
|
10
|
+
export declare function settleModelRequest(store: Mesh, { id, state, result, reason }: SettleModelRequestInput): Promise<void>;
|
|
11
|
+
export declare function cancelModelRequest(store: Mesh, id: string): Promise<void>;
|
|
12
|
+
export declare function reopenModelRequest(store: Mesh, id: string): Promise<void>;
|
|
13
|
+
export declare function listModelRequests(store: Mesh): Promise<QvacChunk[]>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CoreError } from '../errors.js';
|
|
2
|
+
import { getChunk, mustGetChunk } from './chunk.js';
|
|
3
|
+
import { asModelRequest, ownerSigner, takenBySigner, takerFor } from './contract/model-requests.js';
|
|
4
|
+
import { LIVE_MODEL_REQUESTS } from './collections.js';
|
|
5
|
+
async function liveRequest(store, id) {
|
|
6
|
+
const request = asModelRequest(await getChunk(store, id));
|
|
7
|
+
if (!request) {
|
|
8
|
+
throw new CoreError('CHUNK_NOT_FOUND', [id]);
|
|
9
|
+
}
|
|
10
|
+
const { state } = request.modelRequest;
|
|
11
|
+
if (state !== 'open' && state !== 'taken') {
|
|
12
|
+
throw new CoreError('MODEL_REQUEST_CLOSED', [id]);
|
|
13
|
+
}
|
|
14
|
+
return request;
|
|
15
|
+
}
|
|
16
|
+
async function ownersRequest(store, id) {
|
|
17
|
+
const request = await liveRequest(store, id);
|
|
18
|
+
if (!(await ownerSigner(store.view, request, store.localWriterKey))) {
|
|
19
|
+
throw new CoreError('MODEL_REQUEST_NOT_OURS', [id]);
|
|
20
|
+
}
|
|
21
|
+
return request;
|
|
22
|
+
}
|
|
23
|
+
export async function takeModelRequest(store, id) {
|
|
24
|
+
const request = await liveRequest(store, id);
|
|
25
|
+
if (!(await takerFor(store.view, request, store.localWriterKey))) {
|
|
26
|
+
throw new CoreError('MODEL_REQUEST_NOT_OURS', [id]);
|
|
27
|
+
}
|
|
28
|
+
await store.dispatch('take-model-request', { id, at: Date.now() });
|
|
29
|
+
return mustGetChunk(store, id);
|
|
30
|
+
}
|
|
31
|
+
export async function settleModelRequest(store, { id, state, result, reason }) {
|
|
32
|
+
const request = await liveRequest(store, id);
|
|
33
|
+
if (!(await takenBySigner(store.view, request, store.localWriterKey))) {
|
|
34
|
+
throw new CoreError('MODEL_REQUEST_NOT_OURS', [id]);
|
|
35
|
+
}
|
|
36
|
+
await store.dispatch('settle-model-request', { id, state, result, reason, at: Date.now() });
|
|
37
|
+
}
|
|
38
|
+
export async function cancelModelRequest(store, id) {
|
|
39
|
+
await ownersRequest(store, id);
|
|
40
|
+
await store.dispatch('cancel-model-request', { id, at: Date.now() });
|
|
41
|
+
}
|
|
42
|
+
export async function reopenModelRequest(store, id) {
|
|
43
|
+
const request = await ownersRequest(store, id);
|
|
44
|
+
if (request.modelRequest.state === 'open') {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
await store.dispatch('reopen-model-request', { id, at: Date.now() });
|
|
48
|
+
}
|
|
49
|
+
export async function listModelRequests(store) {
|
|
50
|
+
const snap = store.view.snapshot();
|
|
51
|
+
try {
|
|
52
|
+
const live = await snap.find(LIVE_MODEL_REQUESTS).toArray();
|
|
53
|
+
const ours = [];
|
|
54
|
+
for (const chunk of live) {
|
|
55
|
+
const request = asModelRequest(chunk);
|
|
56
|
+
if (request && (await takerFor(snap, request, store.localWriterKey))) {
|
|
57
|
+
ours.push(chunk);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return ours;
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
await snap.close();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
2
|
+
import { CoreError } from '../errors.js';
|
|
2
3
|
import { unref } from '../unref.js';
|
|
3
4
|
export const UPLOAD_INACTIVITY_MS = 30_000;
|
|
4
5
|
export function nextFrame(iterator, { signal, inactivityMs = UPLOAD_INACTIVITY_MS } = {}) {
|
|
@@ -6,7 +7,7 @@ export function nextFrame(iterator, { signal, inactivityMs = UPLOAD_INACTIVITY_M
|
|
|
6
7
|
return Promise.reject(new AbortedError());
|
|
7
8
|
}
|
|
8
9
|
return new Promise((resolve, reject) => {
|
|
9
|
-
const timer = setTimeout(() => finish(new
|
|
10
|
+
const timer = setTimeout(() => finish(new CoreError('UPLOAD_TIMEOUT')), inactivityMs);
|
|
10
11
|
unref(timer);
|
|
11
12
|
const abort = () => finish(new AbortedError());
|
|
12
13
|
const finish = (error, result) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { diagramRepairLinks, isDiagramRepairPrompt } from '@qvac/harness/lib/diagram-repair.ts';
|
|
2
2
|
import { findChunksOfType } from './chunk.js';
|
|
3
|
+
import { runDefinition } from './shared-agents.js';
|
|
3
4
|
import b4a from 'b4a';
|
|
4
5
|
import { ACTIVE_CHATS, AGENTS, CHUNK_COUNTERS, DEVICES, MEMBERS } from './collections.js';
|
|
5
6
|
const DEFAULT_LIMIT = 200;
|
|
@@ -50,7 +51,8 @@ export async function deriveNotifications(mesh, local, { limit: requestedLimit,
|
|
|
50
51
|
}
|
|
51
52
|
const agentNameById = new Map();
|
|
52
53
|
for (const agentId of new Set(selected.map((candidate) => candidate.agentId))) {
|
|
53
|
-
|
|
54
|
+
const row = await snap.get(AGENTS, { id: agentId });
|
|
55
|
+
agentNameById.set(agentId, (await runDefinition(mesh, row))?.name);
|
|
54
56
|
}
|
|
55
57
|
const notifications = selected.map((candidate) => {
|
|
56
58
|
const content = candidate.kind === 'approval-required' ? undefined : contentByChat.get(candidate.chatId);
|
|
@@ -128,7 +130,7 @@ async function messageCandidate(snap, chunk, { chat, deviceId, own }) {
|
|
|
128
130
|
return null;
|
|
129
131
|
}
|
|
130
132
|
const sender = await snap.get(DEVICES, { id: chunk.originDeviceId });
|
|
131
|
-
const senderMemberId = chunk.senderMemberId ?? sender?.memberId;
|
|
133
|
+
const senderMemberId = chunk.requesterMemberId ?? chunk.senderMemberId ?? sender?.memberId;
|
|
132
134
|
if (own?.memberId && senderMemberId && b4a.equals(senderMemberId, own.memberId)) {
|
|
133
135
|
return null;
|
|
134
136
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { LoggerInterface } from '@qvac/logging';
|
|
1
2
|
export declare const PDF_RENDER_SCALE = 2;
|
|
2
|
-
export declare const MAX_PDF_PAGE_IMAGES = 10;
|
|
3
3
|
interface PageFlags {
|
|
4
4
|
hasImage: boolean;
|
|
5
5
|
hasText: boolean;
|
|
@@ -14,5 +14,5 @@ export interface PdfDoc {
|
|
|
14
14
|
export interface PdfRasterizer {
|
|
15
15
|
open(bytes: Uint8Array): Promise<PdfDoc | null>;
|
|
16
16
|
}
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const createPdfRasterizer: (log: LoggerInterface | null) => PdfRasterizer;
|
|
18
18
|
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { MAX_IMAGE_WIDTH, rasterToModelJpeg } from '../image/normalize.js';
|
|
2
2
|
export const PDF_RENDER_SCALE = 2;
|
|
3
|
-
export const MAX_PDF_PAGE_IMAGES = 10;
|
|
4
3
|
export function renderScale(pageWidth) {
|
|
5
4
|
return Math.min(PDF_RENDER_SCALE, MAX_IMAGE_WIDTH / pageWidth);
|
|
6
5
|
}
|
|
7
6
|
let pdfium;
|
|
8
|
-
async function loadPdfium() {
|
|
7
|
+
async function loadPdfium(log) {
|
|
9
8
|
if (pdfium !== undefined)
|
|
10
9
|
return pdfium;
|
|
11
10
|
try {
|
|
@@ -13,14 +12,14 @@ async function loadPdfium() {
|
|
|
13
12
|
pdfium = mod.default ?? mod;
|
|
14
13
|
}
|
|
15
14
|
catch (err) {
|
|
16
|
-
|
|
15
|
+
log?.warn('pdf', 'bare-pdfium did not load; PDF pages will not render', err);
|
|
17
16
|
pdfium = null;
|
|
18
17
|
}
|
|
19
18
|
return pdfium;
|
|
20
19
|
}
|
|
21
|
-
export const
|
|
20
|
+
export const createPdfRasterizer = (log) => ({
|
|
22
21
|
async open(bytes) {
|
|
23
|
-
const mod = await loadPdfium();
|
|
22
|
+
const mod = await loadPdfium(log);
|
|
24
23
|
if (!mod) {
|
|
25
24
|
return null;
|
|
26
25
|
}
|
|
@@ -54,4 +53,4 @@ export const pdfRasterizer = {
|
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
|
-
};
|
|
56
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Duplex } from 'streamx';
|
|
2
|
+
export interface PeerStream {
|
|
3
|
+
readonly remotePublicKey: Uint8Array;
|
|
4
|
+
readonly noiseStream: {
|
|
5
|
+
userData: unknown;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface PeerDuplexOptions {
|
|
9
|
+
readonly protocol: string;
|
|
10
|
+
readonly onaccept: (fromDeviceId: Uint8Array) => Promise<Duplex | null>;
|
|
11
|
+
readonly unreachable: () => Error;
|
|
12
|
+
readonly revoked: () => Error;
|
|
13
|
+
readonly onchange?: (deviceId: string) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare class PeerDuplexChannel {
|
|
16
|
+
private readonly _opts;
|
|
17
|
+
private readonly _peers;
|
|
18
|
+
private _nextId;
|
|
19
|
+
private readonly _pairing;
|
|
20
|
+
constructor(opts: PeerDuplexOptions);
|
|
21
|
+
addStream(stream: PeerStream): void;
|
|
22
|
+
openIds(): string[];
|
|
23
|
+
isOpen(deviceId: string): boolean;
|
|
24
|
+
closeDialled(deviceId: string, reason: () => Error): void;
|
|
25
|
+
dial(deviceId: string): Duplex;
|
|
26
|
+
revalidate(allowed: (deviceId: Uint8Array) => Promise<boolean>): Promise<void>;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
private _opened;
|
|
29
|
+
private _attach;
|
|
30
|
+
private _serve;
|
|
31
|
+
private _deliver;
|
|
32
|
+
private _end;
|
|
33
|
+
private _drop;
|
|
34
|
+
}
|
|
@@ -1,31 +1,8 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { raw, uint } from 'compact-encoding';
|
|
3
|
-
import Protomux, {} from 'protomux';
|
|
4
3
|
import { Duplex } from 'streamx';
|
|
5
|
-
|
|
4
|
+
import { createProtocolPairing } from './protocol-pairing.js';
|
|
6
5
|
function noop() { }
|
|
7
|
-
export const LOAN_UNREACHABLE = 'the device lending its model is not connected';
|
|
8
|
-
export const LOAN_REFUSED = 'the device would not lend its model';
|
|
9
|
-
export const LOAN_REVOKED = 'the device stopped lending its model';
|
|
10
|
-
export function loanFailureNotice(error) {
|
|
11
|
-
const message = messageOf(error);
|
|
12
|
-
if (message.includes(LOAN_UNREACHABLE)) {
|
|
13
|
-
return LOAN_UNREACHABLE;
|
|
14
|
-
}
|
|
15
|
-
if (message.includes('does not support a host-owned run log') ||
|
|
16
|
-
message.includes('rpc stream destroyed')) {
|
|
17
|
-
return LOAN_REFUSED;
|
|
18
|
-
}
|
|
19
|
-
if (message.includes('CHANNEL_CLOSED')) {
|
|
20
|
-
return LOAN_REFUSED;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
function messageOf(error) {
|
|
25
|
-
if (error instanceof Error)
|
|
26
|
-
return error.message;
|
|
27
|
-
return typeof error === 'string' ? error : '';
|
|
28
|
-
}
|
|
29
6
|
const bytes = raw;
|
|
30
7
|
const frame = {
|
|
31
8
|
preencode(state, f) {
|
|
@@ -57,22 +34,27 @@ const ends = {
|
|
|
57
34
|
return { id: uint.decode(state), mine: uint.decode(state) === 1 };
|
|
58
35
|
}
|
|
59
36
|
};
|
|
60
|
-
export class
|
|
37
|
+
export class PeerDuplexChannel {
|
|
61
38
|
_opts;
|
|
62
39
|
_peers;
|
|
63
40
|
_nextId;
|
|
41
|
+
_pairing;
|
|
64
42
|
constructor(opts) {
|
|
65
43
|
this._opts = opts;
|
|
66
44
|
this._peers = new Map();
|
|
67
45
|
this._nextId = 1;
|
|
46
|
+
this._pairing = createProtocolPairing(opts.protocol);
|
|
68
47
|
}
|
|
69
48
|
addStream(stream) {
|
|
70
49
|
const deviceId = b4a.toHex(stream.remotePublicKey);
|
|
71
50
|
if (this._peers.has(deviceId)) {
|
|
72
51
|
return;
|
|
73
52
|
}
|
|
74
|
-
const channel =
|
|
75
|
-
|
|
53
|
+
const channel = this._pairing
|
|
54
|
+
.mux(stream, () => this.addStream(stream))
|
|
55
|
+
.createChannel({
|
|
56
|
+
protocol: this._opts.protocol,
|
|
57
|
+
onopen: () => this._opened(deviceId),
|
|
76
58
|
onclose: () => this._drop(deviceId)
|
|
77
59
|
});
|
|
78
60
|
if (!channel) {
|
|
@@ -96,15 +78,27 @@ export class HarnessLoan {
|
|
|
96
78
|
open,
|
|
97
79
|
data,
|
|
98
80
|
close,
|
|
99
|
-
|
|
100
|
-
served: new Map()
|
|
81
|
+
dialled: new Map(),
|
|
82
|
+
served: new Map(),
|
|
83
|
+
opened: false
|
|
101
84
|
});
|
|
102
85
|
channel.open();
|
|
103
86
|
}
|
|
104
|
-
|
|
87
|
+
openIds() {
|
|
88
|
+
return [...this._peers].filter(([, peer]) => peer.opened).map(([deviceId]) => deviceId);
|
|
89
|
+
}
|
|
90
|
+
isOpen(deviceId) {
|
|
91
|
+
return this._peers.get(deviceId)?.opened === true;
|
|
92
|
+
}
|
|
93
|
+
closeDialled(deviceId, reason) {
|
|
94
|
+
for (const stream of [...(this._peers.get(deviceId)?.dialled.values() ?? [])]) {
|
|
95
|
+
stream.destroy(reason());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
dial(deviceId) {
|
|
105
99
|
const peer = this._peers.get(deviceId);
|
|
106
100
|
if (!peer) {
|
|
107
|
-
throw
|
|
101
|
+
throw this._opts.unreachable();
|
|
108
102
|
}
|
|
109
103
|
const id = this._nextId;
|
|
110
104
|
this._nextId += 1;
|
|
@@ -121,11 +115,12 @@ export class HarnessLoan {
|
|
|
121
115
|
for (const [id, stream] of [...peer.served]) {
|
|
122
116
|
peer.served.delete(id);
|
|
123
117
|
peer.close.send({ id, mine: false });
|
|
124
|
-
stream.destroy(
|
|
118
|
+
stream.destroy(this._opts.revoked());
|
|
125
119
|
}
|
|
126
120
|
}
|
|
127
121
|
}
|
|
128
122
|
destroy() {
|
|
123
|
+
this._pairing.destroy();
|
|
129
124
|
for (const [deviceId, peer] of [...this._peers]) {
|
|
130
125
|
try {
|
|
131
126
|
peer.channel.close();
|
|
@@ -134,9 +129,17 @@ export class HarnessLoan {
|
|
|
134
129
|
this._drop(deviceId);
|
|
135
130
|
}
|
|
136
131
|
}
|
|
132
|
+
_opened(deviceId) {
|
|
133
|
+
const peer = this._peers.get(deviceId);
|
|
134
|
+
if (!peer) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
peer.opened = true;
|
|
138
|
+
this._opts.onchange?.(deviceId);
|
|
139
|
+
}
|
|
137
140
|
_attach(peer, id, opts) {
|
|
138
141
|
const { mine } = opts;
|
|
139
|
-
const held = mine ? peer.
|
|
142
|
+
const held = mine ? peer.dialled : peer.served;
|
|
140
143
|
const stream = new Duplex({
|
|
141
144
|
write: (chunk, cb) => {
|
|
142
145
|
peer.data.send({ id, mine, data: chunk });
|
|
@@ -162,12 +165,13 @@ export class HarnessLoan {
|
|
|
162
165
|
return;
|
|
163
166
|
}
|
|
164
167
|
const stream = this._attach(peer, id, { mine: false });
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
stream.on('error', noop);
|
|
169
|
+
const served = await this._opts.onaccept(peer.remoteKey).catch(noop);
|
|
170
|
+
if (!served || peer.served.get(id) !== stream) {
|
|
171
|
+
served?.destroy();
|
|
167
172
|
stream.destroy();
|
|
168
173
|
return;
|
|
169
174
|
}
|
|
170
|
-
stream.on('error', noop);
|
|
171
175
|
served.on('error', noop);
|
|
172
176
|
stream.pipe(served).pipe(stream);
|
|
173
177
|
}
|
|
@@ -176,7 +180,7 @@ export class HarnessLoan {
|
|
|
176
180
|
if (!peer) {
|
|
177
181
|
return;
|
|
178
182
|
}
|
|
179
|
-
const held = f.mine ? peer.served : peer.
|
|
183
|
+
const held = f.mine ? peer.served : peer.dialled;
|
|
180
184
|
held.get(f.id)?.push(f.data);
|
|
181
185
|
}
|
|
182
186
|
_end(deviceId, e) {
|
|
@@ -184,7 +188,7 @@ export class HarnessLoan {
|
|
|
184
188
|
if (!peer) {
|
|
185
189
|
return;
|
|
186
190
|
}
|
|
187
|
-
const held = e.mine ? peer.served : peer.
|
|
191
|
+
const held = e.mine ? peer.served : peer.dialled;
|
|
188
192
|
const stream = held.get(e.id);
|
|
189
193
|
if (!stream) {
|
|
190
194
|
return;
|
|
@@ -199,11 +203,14 @@ export class HarnessLoan {
|
|
|
199
203
|
return;
|
|
200
204
|
}
|
|
201
205
|
this._peers.delete(deviceId);
|
|
202
|
-
for (const held of [peer.
|
|
206
|
+
for (const held of [peer.dialled, peer.served]) {
|
|
203
207
|
for (const stream of held.values()) {
|
|
204
|
-
stream.destroy(
|
|
208
|
+
stream.destroy(this._opts.unreachable());
|
|
205
209
|
}
|
|
206
210
|
held.clear();
|
|
207
211
|
}
|
|
212
|
+
if (peer.opened) {
|
|
213
|
+
this._opts.onchange?.(deviceId);
|
|
214
|
+
}
|
|
208
215
|
}
|
|
209
216
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type HyperDB from 'hyperdb';
|
|
2
|
+
import type { QvacAgent, QvacProject, QvacProjectDeviceKey, QvacProjectHostKey, QvacProjectKey } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
3
|
+
export interface ProjectSeed {
|
|
4
|
+
readonly projectId: Buffer;
|
|
5
|
+
readonly seed: Buffer;
|
|
6
|
+
}
|
|
7
|
+
export interface ProjectHostSeed extends ProjectSeed {
|
|
8
|
+
readonly project: HyperDB;
|
|
9
|
+
readonly picking?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function dueProjectKey(view: HyperDB, memberId: Buffer, { projectId, seed }: ProjectSeed): Promise<QvacProjectKey | null>;
|
|
12
|
+
export declare function dueProjectHostKey(view: HyperDB, agent: QvacAgent, seal: ProjectHostSeed): Promise<QvacProjectHostKey | null>;
|
|
13
|
+
export declare function dueProjectDeviceKeys(view: HyperDB, row: QvacProject, seed: Buffer): Promise<QvacProjectDeviceKey[]>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { AGENT_USERS, AGENTS, DEVICES } from './collections.js';
|
|
3
|
+
import { readProjectHostKey } from './contract/project-host-keys.js';
|
|
4
|
+
import { readProjectDeviceKey } from './contract/project-device-keys.js';
|
|
5
|
+
import { listsMember, readProject, readProjectKey } from './contract/projects.js';
|
|
6
|
+
import { readMemberKey, upgradeMembers } from './contract/workspace.js';
|
|
7
|
+
import { sealToDevice } from './device-seal.js';
|
|
8
|
+
import { sealToMember } from './member-key.js';
|
|
9
|
+
export async function dueProjectKey(view, memberId, { projectId, seed }) {
|
|
10
|
+
const key = await readMemberKey(view, memberId);
|
|
11
|
+
const held = key && (await readProjectKey(view, projectId, memberId));
|
|
12
|
+
if (!key || (held && b4a.equals(held.boxKey, key.boxKey))) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return { projectId, memberId, boxKey: key.boxKey, sealedSeed: sealToMember(seed, key.boxKey) };
|
|
16
|
+
}
|
|
17
|
+
async function usedBy(view, agent, seal) {
|
|
18
|
+
const live = await view.get(AGENTS, { id: agent.id });
|
|
19
|
+
if (!live || live.deletedAt || !b4a.equals(live.providerDeviceId, agent.providerDeviceId)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return (!!seal.picking || !!(await view.get(AGENT_USERS, { agentId: agent.id, userId: seal.projectId })));
|
|
23
|
+
}
|
|
24
|
+
export async function dueProjectHostKey(view, agent, seal) {
|
|
25
|
+
const { projectId, seed, project } = seal;
|
|
26
|
+
const deviceId = agent.providerDeviceId;
|
|
27
|
+
const row = await readProject(view, projectId);
|
|
28
|
+
const host = await view.get(DEVICES, { id: deviceId });
|
|
29
|
+
const member = host && !host.revoked ? host.memberId : null;
|
|
30
|
+
const inProject = await project.get(DEVICES, { id: deviceId });
|
|
31
|
+
if (!row || !member || inProject || listsMember(row, member)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (!(await usedBy(view, agent, seal))) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (await readProjectHostKey(view, projectId, deviceId)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return { projectId, deviceId, agentId: agent.id, sealedSeed: sealToDevice(seed, deviceId) };
|
|
41
|
+
}
|
|
42
|
+
export async function dueProjectDeviceKeys(view, row, seed) {
|
|
43
|
+
if (!row.groupId) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
const counted = (await upgradeMembers(view)).filter((id) => listsMember(row, id));
|
|
47
|
+
const due = [];
|
|
48
|
+
for await (const { id, memberId, revoked } of view.find(DEVICES)) {
|
|
49
|
+
const listed = memberId && counted.some((member) => b4a.equals(member, memberId));
|
|
50
|
+
if (!memberId || !listed || revoked || (await readProjectDeviceKey(view, row.id, id))) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
due.push({ projectId: row.id, deviceId: id, memberId, sealedSeed: sealToDevice(seed, id) });
|
|
54
|
+
}
|
|
55
|
+
return due;
|
|
56
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { diagramRepairAccepted, diagramRepairLinks, isDiagramRepairPrompt } from '@qvac/harness/lib/diagram-repair.ts';
|
|
2
|
-
import {
|
|
2
|
+
import { hiddenTranscriptText } from './transcript-visibility.js';
|
|
3
3
|
export function historyBranches(all, currentRunId) {
|
|
4
4
|
const seqById = new Map(all.map((chunk) => [chunk.id, chunk.seq]));
|
|
5
5
|
const repairs = diagramRepairLinks(all.filter((chunk) => chunk.type === 'user-message' || chunk.type === 'run-request'), (chunk) => chunk.userMessage?.text ?? null);
|
|
6
6
|
const repairByRunId = new Map(repairs.map((repair) => [repair.runId, repair]));
|
|
7
|
-
const visibleText = visibleTranscriptTextChunks(all);
|
|
8
7
|
const hiddenChunkIds = new Set(all
|
|
9
8
|
.filter((chunk) => isDiagramRepairPrompt(chunk.userMessage?.text ?? ''))
|
|
10
9
|
.map((chunk) => chunk.id));
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
const hiddenText = hiddenTranscriptText(all);
|
|
11
|
+
const replyText = (target) => all
|
|
12
|
+
.filter((chunk) => chunk.runId === target && chunk.content && !hiddenText.has(chunk.id))
|
|
13
13
|
.map((chunk) => chunk.content?.text ?? '')
|
|
14
14
|
.join('');
|
|
15
15
|
const completed = (target) => all.some((chunk) => chunk.type === 'run-status' &&
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Protomux from 'protomux';
|
|
2
|
+
export interface PairedStream {
|
|
3
|
+
readonly noiseStream: {
|
|
4
|
+
userData: unknown;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export interface ProtocolPairing {
|
|
8
|
+
mux(stream: PairedStream, onopen: () => void): Protomux;
|
|
9
|
+
destroy(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function createProtocolPairing(protocol: string): ProtocolPairing;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Protomux from 'protomux';
|
|
2
|
+
export function createProtocolPairing(protocol) {
|
|
3
|
+
const muxes = new Map();
|
|
4
|
+
function mux(stream, onopen) {
|
|
5
|
+
const paired = Protomux.from(stream.noiseStream);
|
|
6
|
+
if (!muxes.has(paired)) {
|
|
7
|
+
const onclose = () => muxes.delete(paired);
|
|
8
|
+
muxes.set(paired, onclose);
|
|
9
|
+
paired.pair({ protocol }, onopen);
|
|
10
|
+
paired.stream.once('close', onclose);
|
|
11
|
+
}
|
|
12
|
+
return paired;
|
|
13
|
+
}
|
|
14
|
+
function destroy() {
|
|
15
|
+
for (const [paired, onclose] of muxes) {
|
|
16
|
+
paired.unpair({ protocol });
|
|
17
|
+
paired.stream.off('close', onclose);
|
|
18
|
+
}
|
|
19
|
+
muxes.clear();
|
|
20
|
+
}
|
|
21
|
+
return { mux, destroy };
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { QvacChat, QvacJoinedMesh } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
import type { Mesh } from './mesh.ts';
|
|
3
|
+
export declare function publicSeed(accountSeed: Buffer, workspaceKey: Buffer): Buffer;
|
|
4
|
+
export declare function ownWorkspaceSeed(accountSeed: Buffer): Buffer;
|
|
5
|
+
export declare function isOwnWorkspace(account: Mesh, workspace: Mesh): boolean;
|
|
6
|
+
export declare function onOwnSeed(account: Mesh, meshKey: Buffer): Promise<boolean>;
|
|
7
|
+
export interface OwnWorkspaces {
|
|
8
|
+
readonly own: Buffer | null;
|
|
9
|
+
readonly lost: QvacJoinedMesh[];
|
|
10
|
+
}
|
|
11
|
+
export declare function ownWorkspaces(account: Mesh): Promise<OwnWorkspaces>;
|
|
12
|
+
export declare function lostMint(account: Mesh, meshKey: Buffer): Promise<boolean>;
|
|
13
|
+
export declare function publicMeshKey(account: Mesh, workspaceKey: Buffer): Promise<Buffer | null>;
|
|
14
|
+
export declare function servesAgents(mesh: Mesh, deviceId: Buffer): Promise<boolean>;
|
|
15
|
+
export declare function servesChat(mesh: Mesh, deviceId: Buffer, chatId: string): Promise<boolean>;
|
|
16
|
+
export declare function servesChunk(mesh: Mesh, deviceId: Buffer, chunkId: string): Promise<boolean>;
|
|
17
|
+
export declare function servedChats(mesh: Mesh, deviceId: Buffer): Promise<QvacChat[]>;
|
|
18
|
+
export interface PublicRecord {
|
|
19
|
+
readonly key: string | null;
|
|
20
|
+
readonly writerSeed: string;
|
|
21
|
+
readonly migrated: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function publicRecordKey(accountKey: Buffer, workspaceKey: Buffer): string;
|
|
24
|
+
export declare function leftPublicRecordKey(accountKey: Buffer, workspaceKey: Buffer): string;
|
|
25
|
+
export declare function isPublicRecord(value: unknown): value is PublicRecord;
|
|
26
|
+
export declare function freshPublicRecord(migrated?: boolean): PublicRecord;
|