@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,88 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import crypto from 'hypercore-crypto';
|
|
3
|
+
import { isRecord } from '../guards.js';
|
|
4
|
+
import { ACTIVE_CHATS_BY_AGENT, AGENTS, CHATS, CHUNKS, JOINED_MESHES, MESH_SEEDS, PUBLIC_MESHES } from './collections.js';
|
|
5
|
+
const PUBLIC = b4a.from('public');
|
|
6
|
+
const WORKSPACE = b4a.from('workspace');
|
|
7
|
+
export function publicSeed(accountSeed, workspaceKey) {
|
|
8
|
+
return crypto.hash([PUBLIC, accountSeed, workspaceKey]);
|
|
9
|
+
}
|
|
10
|
+
export function ownWorkspaceSeed(accountSeed) {
|
|
11
|
+
return crypto.hash([WORKSPACE, accountSeed]);
|
|
12
|
+
}
|
|
13
|
+
export function isOwnWorkspace(account, workspace) {
|
|
14
|
+
return (workspace.role === 'workspace' && b4a.equals(workspace.seed, ownWorkspaceSeed(account.seed)));
|
|
15
|
+
}
|
|
16
|
+
export async function onOwnSeed(account, meshKey) {
|
|
17
|
+
const held = await account.view.get(MESH_SEEDS, { meshKey });
|
|
18
|
+
return !!held && b4a.equals(held.seed, ownWorkspaceSeed(account.seed));
|
|
19
|
+
}
|
|
20
|
+
export async function ownWorkspaces(account) {
|
|
21
|
+
const ours = account.ourMemberId;
|
|
22
|
+
const mints = [];
|
|
23
|
+
for await (const joined of account.view.find(JOINED_MESHES)) {
|
|
24
|
+
const mine = !!ours && !!joined.workspace && b4a.equals(joined.memberId, ours);
|
|
25
|
+
if (mine && (await onOwnSeed(account, joined.meshKey))) {
|
|
26
|
+
mints.push(joined);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const live = mints
|
|
30
|
+
.filter((joined) => !joined.leftAt)
|
|
31
|
+
.sort((a, b) => b4a.compare(a.meshKey, b.meshKey));
|
|
32
|
+
return { own: live[0]?.meshKey ?? null, lost: mints.filter((joined) => joined !== live[0]) };
|
|
33
|
+
}
|
|
34
|
+
export async function lostMint(account, meshKey) {
|
|
35
|
+
if (!(await onOwnSeed(account, meshKey))) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const { own } = await ownWorkspaces(account);
|
|
39
|
+
return !own || !b4a.equals(own, meshKey);
|
|
40
|
+
}
|
|
41
|
+
export async function publicMeshKey(account, workspaceKey) {
|
|
42
|
+
const id = b4a.toHex(workspaceKey);
|
|
43
|
+
const row = await account.view.get(PUBLIC_MESHES, { id });
|
|
44
|
+
return row?.meshKey ?? null;
|
|
45
|
+
}
|
|
46
|
+
function serving(agent, deviceId) {
|
|
47
|
+
return !!agent && !agent.deletedAt && b4a.equals(agent.providerDeviceId, deviceId);
|
|
48
|
+
}
|
|
49
|
+
export async function servesAgents(mesh, deviceId) {
|
|
50
|
+
for await (const agent of mesh.view.find(AGENTS)) {
|
|
51
|
+
if (serving(agent, deviceId))
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
export async function servesChat(mesh, deviceId, chatId) {
|
|
57
|
+
const chat = await mesh.view.get(CHATS, { id: chatId });
|
|
58
|
+
return !!chat && serving(await mesh.view.get(AGENTS, { id: chat.agentId }), deviceId);
|
|
59
|
+
}
|
|
60
|
+
export async function servesChunk(mesh, deviceId, chunkId) {
|
|
61
|
+
const chunk = await mesh.view.get(CHUNKS, { id: chunkId });
|
|
62
|
+
return !!chunk && servesChat(mesh, deviceId, chunk.chatId);
|
|
63
|
+
}
|
|
64
|
+
export async function servedChats(mesh, deviceId) {
|
|
65
|
+
const chats = [];
|
|
66
|
+
for await (const agent of mesh.view.find(AGENTS)) {
|
|
67
|
+
if (!serving(agent, deviceId))
|
|
68
|
+
continue;
|
|
69
|
+
const range = { gte: { agentId: agent.id }, lte: { agentId: agent.id } };
|
|
70
|
+
chats.push(...(await mesh.view.find(ACTIVE_CHATS_BY_AGENT, range).toArray()));
|
|
71
|
+
}
|
|
72
|
+
return chats;
|
|
73
|
+
}
|
|
74
|
+
export function publicRecordKey(accountKey, workspaceKey) {
|
|
75
|
+
return `public-mesh/${b4a.toHex(accountKey)}/${b4a.toHex(workspaceKey)}`;
|
|
76
|
+
}
|
|
77
|
+
export function leftPublicRecordKey(accountKey, workspaceKey) {
|
|
78
|
+
return `public-mesh-left/${b4a.toHex(accountKey)}/${b4a.toHex(workspaceKey)}`;
|
|
79
|
+
}
|
|
80
|
+
export function isPublicRecord(value) {
|
|
81
|
+
return (isRecord(value) &&
|
|
82
|
+
typeof value.writerSeed === 'string' &&
|
|
83
|
+
typeof value.migrated === 'boolean' &&
|
|
84
|
+
(value.key === null || typeof value.key === 'string'));
|
|
85
|
+
}
|
|
86
|
+
export function freshPublicRecord(migrated = false) {
|
|
87
|
+
return { key: null, writerSeed: `public-${b4a.toHex(crypto.randomBytes(8))}`, migrated };
|
|
88
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface RunRequestFields {
|
|
2
|
+
readonly capability?: string | null;
|
|
3
|
+
readonly originDeviceId: Buffer;
|
|
4
|
+
readonly runnerDeviceId?: Buffer | null;
|
|
5
|
+
readonly runTakenBy?: Buffer | null;
|
|
6
|
+
}
|
|
7
|
+
export interface RunDriverInput {
|
|
8
|
+
readonly request: RunRequestFields;
|
|
9
|
+
readonly agent: {
|
|
10
|
+
readonly providerDeviceId: Buffer;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function runDriver({ request, agent }: RunDriverInput): Buffer | null;
|
|
14
|
+
export declare function drivenBy(input: RunDriverInput, deviceId: Buffer): boolean;
|
|
15
|
+
export declare function offeredTo(request: RunRequestFields, deviceId: Buffer): boolean;
|
|
16
|
+
export declare function handedOff(request: RunRequestFields, deviceId: Buffer): boolean;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
export function runDriver({ request, agent }) {
|
|
3
|
+
if (request.capability) {
|
|
4
|
+
return agent.providerDeviceId;
|
|
5
|
+
}
|
|
6
|
+
return request.runnerDeviceId ? (request.runTakenBy ?? null) : request.originDeviceId;
|
|
7
|
+
}
|
|
8
|
+
export function drivenBy(input, deviceId) {
|
|
9
|
+
const driver = runDriver(input);
|
|
10
|
+
return !!driver && b4a.equals(driver, deviceId);
|
|
11
|
+
}
|
|
12
|
+
function untaken(request) {
|
|
13
|
+
return !request.capability && !!request.runnerDeviceId && !request.runTakenBy;
|
|
14
|
+
}
|
|
15
|
+
export function offeredTo(request, deviceId) {
|
|
16
|
+
return untaken(request) && b4a.equals(request.runnerDeviceId, deviceId);
|
|
17
|
+
}
|
|
18
|
+
export function handedOff(request, deviceId) {
|
|
19
|
+
return untaken(request) && b4a.equals(request.originDeviceId, deviceId);
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { QvacAgent, QvacChunk } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
import type { Mesh, MeshDispatcher } from './mesh.ts';
|
|
3
|
+
export interface RunnerChoice {
|
|
4
|
+
readonly deviceId: Buffer;
|
|
5
|
+
readonly peers: ReadonlyArray<string>;
|
|
6
|
+
readonly agent: Pick<QvacAgent, 'providerDeviceId'>;
|
|
7
|
+
}
|
|
8
|
+
export declare function pickRunner(mesh: Mesh, { deviceId, peers, agent }: RunnerChoice): Promise<Buffer | undefined>;
|
|
9
|
+
export declare function takeRunRequest(store: Mesh, id: string): Promise<QvacChunk>;
|
|
10
|
+
export declare function handedOffRequests(store: Mesh, deviceId: Buffer, chatId: string): Promise<QvacChunk[]>;
|
|
11
|
+
export declare function takeBack(requests: ReadonlyArray<QvacChunk>, into: MeshDispatcher): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { isMobilePlatform } from '@qvac/harness/lib/models/model-catalog.ts';
|
|
3
|
+
import { CAPABILITY_PROFILES } from '../../schema/qvac.js';
|
|
4
|
+
import { CoreError } from '../errors.js';
|
|
5
|
+
import { getChunk, mustGetChunk } from './chunk.js';
|
|
6
|
+
import { openToTake, runHasTerminalStatus, runTaker } from './contract/run-requests.js';
|
|
7
|
+
import { DEVICES, RUN_REQUESTS } from './collections.js';
|
|
8
|
+
const rank = (device) => CAPABILITY_PROFILES.indexOf(device.capabilityProfile);
|
|
9
|
+
export async function pickRunner(mesh, { deviceId, peers, agent }) {
|
|
10
|
+
const self = await mesh.view.get(DEVICES, { id: deviceId });
|
|
11
|
+
const member = self?.memberId;
|
|
12
|
+
if (!member) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const connected = new Set(peers);
|
|
16
|
+
const devices = await mesh.view.find(DEVICES).toArray();
|
|
17
|
+
const ours = devices.filter((device) => !device.revoked &&
|
|
18
|
+
!!device.memberId &&
|
|
19
|
+
b4a.equals(device.memberId, member) &&
|
|
20
|
+
!b4a.equals(device.id, deviceId) &&
|
|
21
|
+
connected.has(b4a.toHex(device.id)));
|
|
22
|
+
const provider = ours.find((device) => b4a.equals(device.id, agent.providerDeviceId));
|
|
23
|
+
if (provider) {
|
|
24
|
+
return provider.id;
|
|
25
|
+
}
|
|
26
|
+
const desktops = ours.filter((device) => !isMobilePlatform(device.platform ?? ''));
|
|
27
|
+
return desktops.sort((a, b) => rank(b) - rank(a))[0]?.id;
|
|
28
|
+
}
|
|
29
|
+
export async function takeRunRequest(store, id) {
|
|
30
|
+
const request = await getChunk(store, id);
|
|
31
|
+
if (request?.type !== 'run-request') {
|
|
32
|
+
throw new CoreError('CHUNK_NOT_FOUND', [id]);
|
|
33
|
+
}
|
|
34
|
+
if (request.runnerDeviceId && !(await runTaker(store.view, request, store.localWriterKey))) {
|
|
35
|
+
throw new CoreError('RUN_REQUEST_NOT_OURS', [id]);
|
|
36
|
+
}
|
|
37
|
+
const { chatId, runId } = request;
|
|
38
|
+
if (!openToTake(request) || !runId || (await runHasTerminalStatus(store.view, chatId, runId))) {
|
|
39
|
+
throw new CoreError('RUN_REQUEST_TAKEN', [id]);
|
|
40
|
+
}
|
|
41
|
+
await store.dispatch('take-run-request', { id, at: Date.now() });
|
|
42
|
+
return mustGetChunk(store, id);
|
|
43
|
+
}
|
|
44
|
+
export async function handedOffRequests(store, deviceId, chatId) {
|
|
45
|
+
const range = { gte: { chatId }, lte: { chatId } };
|
|
46
|
+
const handed = [];
|
|
47
|
+
for await (const request of store.view.find(RUN_REQUESTS, range)) {
|
|
48
|
+
const ours = openToTake(request) && b4a.equals(request.originDeviceId, deviceId);
|
|
49
|
+
if (ours && request.runId && !(await runHasTerminalStatus(store.view, chatId, request.runId))) {
|
|
50
|
+
handed.push(request);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return handed;
|
|
54
|
+
}
|
|
55
|
+
export function takeBack(requests, into) {
|
|
56
|
+
for (const request of requests) {
|
|
57
|
+
into.dispatch('take-run-request', { id: request.id, at: Date.now() });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,27 +1,39 @@
|
|
|
1
|
+
import { CoreError } from '../errors.js';
|
|
2
|
+
import { mustGetActiveAgent } from './agent.js';
|
|
1
3
|
import { buildChat, enrichChat, mustGetActiveChat } from './chat.js';
|
|
2
4
|
import { appendChunk, listChunks } from './chunk.js';
|
|
3
5
|
import { randomId } from './id.js';
|
|
6
|
+
import { handedOffRequests, pickRunner, takeBack } from './run-requests.js';
|
|
7
|
+
import { runDefinition } from './shared-agents.js';
|
|
4
8
|
export async function sendMessage(mesh, input) {
|
|
5
9
|
const existing = input.chatId ? await mustGetActiveChat(mesh, input.chatId) : null;
|
|
6
10
|
const agentId = input.agentId ?? existing?.agentId;
|
|
7
11
|
if (!agentId) {
|
|
8
|
-
throw new
|
|
12
|
+
throw new CoreError('SEND_AGENT_REQUIRED');
|
|
9
13
|
}
|
|
14
|
+
const agent = await runDefinition(mesh, await mustGetActiveAgent(mesh, agentId));
|
|
10
15
|
const chat = existing ?? buildChat({ agentId, title: input.title ?? '' });
|
|
11
16
|
const chatId = chat.id;
|
|
12
17
|
const parentId = input.parentRunId
|
|
13
18
|
? await parentRequestId(mesh, chatId, input.parentRunId)
|
|
14
19
|
: undefined;
|
|
15
20
|
const runId = randomId();
|
|
21
|
+
const { originDeviceId } = input;
|
|
22
|
+
const handed = existing ? await handedOffRequests(mesh, originDeviceId, chatId) : [];
|
|
23
|
+
const runner = agent && input.peers && !input.capability && !handed.length
|
|
24
|
+
? await pickRunner(mesh, { deviceId: originDeviceId, peers: input.peers, agent })
|
|
25
|
+
: undefined;
|
|
16
26
|
const batch = mesh.batch();
|
|
17
27
|
if (!existing) {
|
|
18
28
|
batch.dispatch('put-chat', { chat });
|
|
19
29
|
}
|
|
30
|
+
takeBack(handed, batch);
|
|
20
31
|
const { id: chunkId } = await appendChunk(mesh, {
|
|
21
32
|
chatId,
|
|
22
33
|
type: 'user-message',
|
|
23
34
|
userMessage: { text: input.text },
|
|
24
|
-
originDeviceId
|
|
35
|
+
originDeviceId,
|
|
36
|
+
senderNameAtSend: input.senderNameAtSend
|
|
25
37
|
}, batch);
|
|
26
38
|
await appendChunk(mesh, {
|
|
27
39
|
chatId,
|
|
@@ -32,7 +44,8 @@ export async function sendMessage(mesh, input) {
|
|
|
32
44
|
capabilityArgs: input.capabilityArgs,
|
|
33
45
|
enhance: input.enhance,
|
|
34
46
|
parentId,
|
|
35
|
-
originDeviceId
|
|
47
|
+
originDeviceId,
|
|
48
|
+
runnerDeviceId: runner
|
|
36
49
|
}, batch);
|
|
37
50
|
await batch.flush();
|
|
38
51
|
return {
|
|
@@ -46,7 +59,7 @@ export async function parentRequestId(mesh, chatId, parentRunId) {
|
|
|
46
59
|
const requests = await listChunks(mesh, { chatId, type: 'run-request' });
|
|
47
60
|
const parent = requests.find((chunk) => chunk.runId === parentRunId);
|
|
48
61
|
if (!parent) {
|
|
49
|
-
throw new
|
|
62
|
+
throw new CoreError('RUN_NOT_FOUND', [parentRunId]);
|
|
50
63
|
}
|
|
51
64
|
return parent.id;
|
|
52
65
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type HyperDB from 'hyperdb';
|
|
2
|
+
import type { ReadChunk } from './chunk.ts';
|
|
3
|
+
import type { Mesh } from './mesh.ts';
|
|
4
|
+
export interface Senders {
|
|
5
|
+
readonly names: ReadonlyMap<string, string>;
|
|
6
|
+
readonly live: ReadonlySet<string>;
|
|
7
|
+
readonly inProject: ReadonlySet<string>;
|
|
8
|
+
}
|
|
9
|
+
export type SenderLookup = (meshId: string) => Promise<Senders | null>;
|
|
10
|
+
export type SentChunk = ReadChunk & {
|
|
11
|
+
readonly senderName?: string | undefined;
|
|
12
|
+
readonly senderNotInProject?: boolean;
|
|
13
|
+
readonly senderFormerMember?: boolean;
|
|
14
|
+
readonly senderCopiedBy?: Buffer | undefined;
|
|
15
|
+
};
|
|
16
|
+
export declare function projectSenders(workspace: HyperDB, project: HyperDB): Promise<Senders>;
|
|
17
|
+
export declare function ourSenderName(mesh: Mesh, meshId: string, lookup: SenderLookup | null | undefined): Promise<string | undefined>;
|
|
18
|
+
export declare function withSenders(chunks: ReadonlyArray<ReadChunk>, senders: Senders | null): SentChunk[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { MEMBERS, PROJECT_MEMBERS } from './collections.js';
|
|
3
|
+
import { liveMemberIds } from './contract/workspace.js';
|
|
4
|
+
export async function projectSenders(workspace, project) {
|
|
5
|
+
const [names, live, inProject] = await Promise.all([
|
|
6
|
+
memberNames(workspace),
|
|
7
|
+
liveMemberIds(workspace),
|
|
8
|
+
projectMemberIds(project)
|
|
9
|
+
]);
|
|
10
|
+
return { names, live, inProject };
|
|
11
|
+
}
|
|
12
|
+
export async function ourSenderName(mesh, meshId, lookup) {
|
|
13
|
+
const ours = mesh.ourMemberId ?? (await mesh.refreshOurMember())?.memberId;
|
|
14
|
+
const senders = ours && lookup ? await lookup(meshId) : null;
|
|
15
|
+
return ours ? senders?.names.get(b4a.toHex(ours)) : undefined;
|
|
16
|
+
}
|
|
17
|
+
export function withSenders(chunks, senders) {
|
|
18
|
+
if (!senders) {
|
|
19
|
+
return [...chunks];
|
|
20
|
+
}
|
|
21
|
+
return chunks.map((chunk) => {
|
|
22
|
+
if (chunk.type !== 'user-message' || !chunk.requesterMemberId) {
|
|
23
|
+
return chunk;
|
|
24
|
+
}
|
|
25
|
+
const writer = chunk.requesterMemberId;
|
|
26
|
+
const sender = chunk.senderMemberId ?? writer;
|
|
27
|
+
const id = b4a.toHex(sender);
|
|
28
|
+
const name = senders.names.get(id);
|
|
29
|
+
const live = senders.live.has(id);
|
|
30
|
+
return {
|
|
31
|
+
...chunk,
|
|
32
|
+
senderName: name,
|
|
33
|
+
senderNotInProject: live && !senders.inProject.has(id),
|
|
34
|
+
senderFormerMember: name !== undefined && !live,
|
|
35
|
+
senderCopiedBy: b4a.equals(sender, writer) ? undefined : writer
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function memberNames(view) {
|
|
40
|
+
const names = new Map();
|
|
41
|
+
for await (const member of view.find(MEMBERS)) {
|
|
42
|
+
names.set(b4a.toHex(member.id), member.name);
|
|
43
|
+
}
|
|
44
|
+
return names;
|
|
45
|
+
}
|
|
46
|
+
async function projectMemberIds(view) {
|
|
47
|
+
const ids = new Set();
|
|
48
|
+
for await (const row of view.find(PROJECT_MEMBERS)) {
|
|
49
|
+
ids.add(b4a.toHex(row.memberId));
|
|
50
|
+
}
|
|
51
|
+
return ids;
|
|
52
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { QvacAgent } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
import type { Mesh, MeshBatch } from './mesh.ts';
|
|
3
|
+
export declare function ownerOf(workspace: Mesh, agent: QvacAgent): Promise<Buffer | null>;
|
|
4
|
+
export declare function liveSharedAgent(workspace: Mesh, agentId: string): Promise<QvacAgent | null>;
|
|
5
|
+
export declare function shareAgent(account: Mesh, workspace: Mesh, agentId: string): Promise<QvacAgent>;
|
|
6
|
+
export declare function unshareAgent(workspace: Mesh, agentId: string): Promise<void>;
|
|
7
|
+
export declare function followSharedAgents(account: Mesh, workspace: Mesh): Promise<void>;
|
|
8
|
+
export interface ListedAgent extends QvacAgent {
|
|
9
|
+
readonly ownerMemberId?: Buffer;
|
|
10
|
+
readonly shared: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function workspaceAgents(workspace: Mesh, own: ReadonlyArray<QvacAgent>): Promise<ListedAgent[]>;
|
|
13
|
+
export type PickRefusal = 'AGENT_NOT_SHARED' | 'CHAT_AGENT_UNAVAILABLE';
|
|
14
|
+
export interface AgentPicks {
|
|
15
|
+
pick(into: Mesh, agentId: string | null | undefined, refusal?: PickRefusal): Promise<void>;
|
|
16
|
+
unpick(into: Mesh, agentId: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare function accountPicks(account: () => Mesh | null): AgentPicks;
|
|
19
|
+
export interface PickScope {
|
|
20
|
+
readonly account: Mesh | null;
|
|
21
|
+
readonly workspace: Mesh | null;
|
|
22
|
+
readonly sharePublicSeed: (workspace: Mesh, hostDeviceId: Buffer) => Promise<void>;
|
|
23
|
+
readonly shareProjectSeed: (batch: MeshBatch, seal: HostSeal) => Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export interface HostSeal {
|
|
26
|
+
readonly workspace: Mesh;
|
|
27
|
+
readonly project: Mesh;
|
|
28
|
+
readonly agent: QvacAgent;
|
|
29
|
+
readonly picking?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface AgentPick {
|
|
32
|
+
readonly into: Mesh;
|
|
33
|
+
readonly agentId: string | null | undefined;
|
|
34
|
+
readonly refusal?: PickRefusal;
|
|
35
|
+
}
|
|
36
|
+
export declare function pickAgent(scope: PickScope, { into, agentId, refusal }: AgentPick): Promise<void>;
|
|
37
|
+
export declare function unpickAgent(workspace: Mesh, into: Mesh, agentId: string): Promise<void>;
|
|
38
|
+
export declare function followPickedAgents(workspace: Mesh, into: Mesh): Promise<void>;
|
|
39
|
+
export declare function runDefinition(mesh: Mesh, row: QvacAgent | null): Promise<QvacAgent | null>;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { encode } from '../../spec/mesh/hyperschema/index.js';
|
|
3
|
+
import { CoreError } from '../errors.js';
|
|
4
|
+
import { mustGetActiveAgent } from './agent.js';
|
|
5
|
+
import { copyAgent } from './agent-copies.js';
|
|
6
|
+
import { stripped } from './chat-copy.js';
|
|
7
|
+
import { listsMember, readProject } from './contract/projects.js';
|
|
8
|
+
import { ACTIVE_CHATS_BY_AGENT, AGENT_USERS, AGENTS, DEVICES } from './collections.js';
|
|
9
|
+
export async function ownerOf(workspace, agent) {
|
|
10
|
+
const device = await workspace.view.get(DEVICES, { id: agent.providerDeviceId });
|
|
11
|
+
return device?.memberId ?? null;
|
|
12
|
+
}
|
|
13
|
+
async function ours(workspace, agent) {
|
|
14
|
+
const owner = await ownerOf(workspace, agent);
|
|
15
|
+
return !!owner && !!workspace.ourMemberId && b4a.equals(owner, workspace.ourMemberId);
|
|
16
|
+
}
|
|
17
|
+
async function theirs(workspace, agent) {
|
|
18
|
+
const owner = await ownerOf(workspace, agent);
|
|
19
|
+
return !!owner && !!workspace.ourMemberId && !b4a.equals(owner, workspace.ourMemberId);
|
|
20
|
+
}
|
|
21
|
+
export async function liveSharedAgent(workspace, agentId) {
|
|
22
|
+
const agent = await workspace.view.get(AGENTS, { id: agentId });
|
|
23
|
+
return agent && !agent.deletedAt ? agent : null;
|
|
24
|
+
}
|
|
25
|
+
function sharedRow(agent, updatedAt) {
|
|
26
|
+
return { ...stripped(agent), isDefault: false, updatedAt };
|
|
27
|
+
}
|
|
28
|
+
export async function shareAgent(account, workspace, agentId) {
|
|
29
|
+
const agent = await mustGetActiveAgent(account, agentId);
|
|
30
|
+
if (!(await ours(workspace, agent))) {
|
|
31
|
+
throw new CoreError('AGENT_HOST_NOT_IN_WORKSPACE');
|
|
32
|
+
}
|
|
33
|
+
const held = await workspace.view.get(AGENTS, { id: agentId });
|
|
34
|
+
if (held && !held.deletedAt && !(await ours(workspace, held))) {
|
|
35
|
+
throw new CoreError('AGENT_NOT_OURS');
|
|
36
|
+
}
|
|
37
|
+
if (held && !held.deletedAt && held.updatedAt >= agent.updatedAt) {
|
|
38
|
+
return held;
|
|
39
|
+
}
|
|
40
|
+
const row = sharedRow(agent, Math.max(agent.updatedAt, (held?.updatedAt ?? 0) + 1));
|
|
41
|
+
await workspace.dispatch('put-agent', { agent: row });
|
|
42
|
+
return row;
|
|
43
|
+
}
|
|
44
|
+
export async function unshareAgent(workspace, agentId) {
|
|
45
|
+
const shared = await liveSharedAgent(workspace, agentId);
|
|
46
|
+
if (!shared) {
|
|
47
|
+
throw new CoreError('AGENT_NOT_SHARED', [agentId]);
|
|
48
|
+
}
|
|
49
|
+
if (!(await ours(workspace, shared))) {
|
|
50
|
+
throw new CoreError('AGENT_NOT_OURS');
|
|
51
|
+
}
|
|
52
|
+
const at = Math.max(Date.now(), shared.updatedAt + 1);
|
|
53
|
+
await workspace.dispatch('put-agent', { agent: { ...shared, deletedAt: at, updatedAt: at } });
|
|
54
|
+
}
|
|
55
|
+
export async function followSharedAgents(account, workspace) {
|
|
56
|
+
for (const copy of await workspace.view.find(AGENTS).toArray()) {
|
|
57
|
+
if (workspace.closing || account.closing)
|
|
58
|
+
return;
|
|
59
|
+
if (copy.deletedAt || !(await ours(workspace, copy)))
|
|
60
|
+
continue;
|
|
61
|
+
const agent = await account.view.get(AGENTS, { id: copy.id });
|
|
62
|
+
if (agent && agent.updatedAt > copy.updatedAt) {
|
|
63
|
+
await workspace.dispatch('put-agent', { agent: sharedRow(agent, agent.updatedAt) });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export async function workspaceAgents(workspace, own) {
|
|
68
|
+
const member = workspace.ourMemberId;
|
|
69
|
+
const ownIds = new Set(own.map((agent) => agent.id));
|
|
70
|
+
const listed = [];
|
|
71
|
+
for (const agent of own) {
|
|
72
|
+
const copy = await liveSharedAgent(workspace, agent.id);
|
|
73
|
+
const shared = !!copy && (await ours(workspace, copy));
|
|
74
|
+
listed.push({ ...agent, ownerMemberId: member ?? undefined, shared });
|
|
75
|
+
}
|
|
76
|
+
for (const copy of await workspace.view.find(AGENTS).toArray()) {
|
|
77
|
+
const owner = copy.deletedAt || ownIds.has(copy.id) ? null : await ownerOf(workspace, copy);
|
|
78
|
+
if (owner && !(member && b4a.equals(owner, member))) {
|
|
79
|
+
listed.push({ ...copy, ownerMemberId: owner, shared: true });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return listed;
|
|
83
|
+
}
|
|
84
|
+
export function accountPicks(account) {
|
|
85
|
+
return {
|
|
86
|
+
pick: (into, agentId) => copyAgent(account(), into, agentId),
|
|
87
|
+
unpick: async () => { }
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function pickedRow(shared, workspace, updatedAt) {
|
|
91
|
+
return { ...sharedRow(shared, updatedAt), sharedIn: workspace.key };
|
|
92
|
+
}
|
|
93
|
+
function sameContent(a, b) {
|
|
94
|
+
return b4a.equals(encode('@qvac/agent', { ...a, updatedAt: 0 }), encode('@qvac/agent', { ...b, updatedAt: 0 }));
|
|
95
|
+
}
|
|
96
|
+
function restored(workspace, shared, held) {
|
|
97
|
+
if (held && sameContent(held, pickedRow(shared, workspace, 0))) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
return pickedRow(shared, workspace, Math.max(shared.updatedAt, (held?.updatedAt ?? 0) + 1));
|
|
101
|
+
}
|
|
102
|
+
function picked(copy, workspace) {
|
|
103
|
+
return !!copy && !copy.deletedAt && !!copy.sharedIn && b4a.equals(copy.sharedIn, workspace.key);
|
|
104
|
+
}
|
|
105
|
+
function follows(workspace, into, copy) {
|
|
106
|
+
return into.role === 'project' || (!!copy.sharedIn && b4a.equals(copy.sharedIn, workspace.key));
|
|
107
|
+
}
|
|
108
|
+
function inUse(into, agentId) {
|
|
109
|
+
return into.view.findOne(ACTIVE_CHATS_BY_AGENT, { gte: { agentId }, lte: { agentId } });
|
|
110
|
+
}
|
|
111
|
+
function userOf(workspace, into) {
|
|
112
|
+
if (into.role === 'project') {
|
|
113
|
+
return { projectId: into.key };
|
|
114
|
+
}
|
|
115
|
+
return workspace.ourMemberId ? { memberId: workspace.ourMemberId } : null;
|
|
116
|
+
}
|
|
117
|
+
function refuse(refusal, agentId) {
|
|
118
|
+
return refusal === 'AGENT_NOT_SHARED'
|
|
119
|
+
? new CoreError('AGENT_NOT_SHARED', [agentId])
|
|
120
|
+
: new CoreError('CHAT_AGENT_UNAVAILABLE');
|
|
121
|
+
}
|
|
122
|
+
export async function pickAgent(scope, { into, agentId, refusal = 'AGENT_NOT_SHARED' }) {
|
|
123
|
+
const { account, workspace } = scope;
|
|
124
|
+
if (!agentId || !workspace) {
|
|
125
|
+
return copyAgent(account, into, agentId);
|
|
126
|
+
}
|
|
127
|
+
const own = into.role === 'public' ? await account?.view.get(AGENTS, { id: agentId }) : null;
|
|
128
|
+
if (own && !own.deletedAt) {
|
|
129
|
+
return copyAgent(account, into, agentId);
|
|
130
|
+
}
|
|
131
|
+
const shared = await liveSharedAgent(workspace, agentId);
|
|
132
|
+
if (!shared) {
|
|
133
|
+
throw refuse(refusal, agentId);
|
|
134
|
+
}
|
|
135
|
+
const held = await into.view.get(AGENTS, { id: agentId });
|
|
136
|
+
if (await heldByAnother(workspace, held, shared)) {
|
|
137
|
+
throw new CoreError('CHAT_AGENT_UNAVAILABLE');
|
|
138
|
+
}
|
|
139
|
+
if (refusal === 'CHAT_AGENT_UNAVAILABLE' &&
|
|
140
|
+
(await leftProject(into, { workspace, held, shared }))) {
|
|
141
|
+
throw new CoreError('CHAT_AGENT_UNAVAILABLE');
|
|
142
|
+
}
|
|
143
|
+
const row = restored(workspace, shared, held);
|
|
144
|
+
if (row) {
|
|
145
|
+
await into.dispatch('put-agent', { agent: row });
|
|
146
|
+
}
|
|
147
|
+
const user = userOf(workspace, into);
|
|
148
|
+
const userId = user?.memberId ?? user?.projectId;
|
|
149
|
+
if (!user || !userId) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (user.memberId && (await theirs(workspace, shared))) {
|
|
153
|
+
await scope.sharePublicSeed(workspace, shared.providerDeviceId);
|
|
154
|
+
}
|
|
155
|
+
const batch = workspace.batch();
|
|
156
|
+
const picking = !(await workspace.view.get(AGENT_USERS, { agentId, userId }));
|
|
157
|
+
if (picking) {
|
|
158
|
+
batch.dispatch('put-agent-user', { agentId, ...user });
|
|
159
|
+
}
|
|
160
|
+
if (user.projectId) {
|
|
161
|
+
await scope.shareProjectSeed(batch, { workspace, project: into, agent: shared, picking });
|
|
162
|
+
}
|
|
163
|
+
await batch.flush();
|
|
164
|
+
}
|
|
165
|
+
export async function unpickAgent(workspace, into, agentId) {
|
|
166
|
+
const copy = await into.view.get(AGENTS, { id: agentId });
|
|
167
|
+
if (!picked(copy, workspace) || (await inUse(into, agentId))) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const at = Math.max(Date.now(), copy.updatedAt + 1);
|
|
171
|
+
await into.dispatch('put-agent', { agent: { ...stripped(copy), deletedAt: at, updatedAt: at } });
|
|
172
|
+
const user = userOf(workspace, into);
|
|
173
|
+
const userId = user?.memberId ?? user?.projectId;
|
|
174
|
+
if (user && userId && (await workspace.view.get(AGENT_USERS, { agentId, userId }))) {
|
|
175
|
+
await workspace.dispatch('put-agent-user', { agentId, ...user, removed: true });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export async function followPickedAgents(workspace, into) {
|
|
179
|
+
for (const copy of await into.view.find(AGENTS).toArray()) {
|
|
180
|
+
if (into.closing || workspace.closing)
|
|
181
|
+
return;
|
|
182
|
+
const shared = await workspace.view.get(AGENTS, { id: copy.id });
|
|
183
|
+
if (!follows(workspace, into, copy)) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (await ownerRemoved(workspace, copy, shared)) {
|
|
187
|
+
if (!copy.deletedAt) {
|
|
188
|
+
const at = copy.updatedAt + 1;
|
|
189
|
+
await into.dispatch('put-agent', {
|
|
190
|
+
agent: { ...stripped(copy), deletedAt: at, updatedAt: at }
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (!shared || (await unpicked(into, copy, shared))) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (copy.deletedAt && (await leftProject(into, { workspace, held: copy, shared }))) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const row = restored(workspace, shared, copy);
|
|
202
|
+
if (row) {
|
|
203
|
+
await into.dispatch('put-agent', { agent: row });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async function ownerRemoved(workspace, copy, shared) {
|
|
208
|
+
const host = await workspace.view.get(DEVICES, { id: copy.providerDeviceId });
|
|
209
|
+
if (!host?.revoked || !host.memberId) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
const owner = shared && (await ownerOf(workspace, shared));
|
|
213
|
+
return !owner || !b4a.equals(owner, host.memberId);
|
|
214
|
+
}
|
|
215
|
+
async function heldByAnother(workspace, held, shared) {
|
|
216
|
+
if (!held || b4a.equals(held.providerDeviceId, shared.providerDeviceId)) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if (await ownerRemoved(workspace, held, shared)) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
const [was, now] = [await ownerOf(workspace, held), await ownerOf(workspace, shared)];
|
|
223
|
+
return !was || !now || !b4a.equals(was, now);
|
|
224
|
+
}
|
|
225
|
+
async function leftProject(into, { workspace, held, shared }) {
|
|
226
|
+
if (into.role !== 'project') {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
const host = held && (await into.view.get(DEVICES, { id: held.providerDeviceId }));
|
|
230
|
+
if (held?.deletedAt && host?.revoked) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
if (await workspace.view.get(AGENT_USERS, { agentId: shared.id, userId: into.key })) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
const [owner, project] = [
|
|
237
|
+
await ownerOf(workspace, shared),
|
|
238
|
+
await readProject(workspace.view, into.key)
|
|
239
|
+
];
|
|
240
|
+
return !owner || !project || !listsMember(project, owner);
|
|
241
|
+
}
|
|
242
|
+
async function unpicked(into, copy, shared) {
|
|
243
|
+
return !!copy.deletedAt && (!!shared.deletedAt || !(await inUse(into, copy.id)));
|
|
244
|
+
}
|
|
245
|
+
export async function runDefinition(mesh, row) {
|
|
246
|
+
const workspace = row && (await mesh.pickedFrom?.());
|
|
247
|
+
if (!row || !workspace || !follows(workspace, mesh, row)) {
|
|
248
|
+
return row;
|
|
249
|
+
}
|
|
250
|
+
const shared = await workspace.view.get(AGENTS, { id: row.id });
|
|
251
|
+
if (!shared || shared.deletedAt || (await ownerRemoved(workspace, row, shared))) {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
return pickedRow(shared, workspace, row.updatedAt);
|
|
255
|
+
}
|