@qvac/core 1.0.0-rc.0 → 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
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
2
|
import EventEmitter from 'bare-events';
|
|
3
|
-
import type { AssistantFileStatusList, AssistantFileReadRequest, AssistantFileReadFrame, AssistantFilePreviewResponse, AssistantIndexingStatusList } from '../../../spec/hyperschema/types.d.ts';
|
|
3
|
+
import type { AssistantFileStatusList, AssistantFileReadRequest, AssistantFileReadFrame, AssistantFilePreviewResponse, AssistantIndexingStatusList, AssistantKnowledgeBaseList } from '../../../spec/hyperschema/types.d.ts';
|
|
4
4
|
import type { QvacChunk, QvacKnowledge, QvacKnowledgeArtifact } from '../../../spec/mesh/hyperschema/types.d.ts';
|
|
5
5
|
import { attachmentFiles } from './attachments.ts';
|
|
6
6
|
import { addKnowledgeArtifact, type FileRecord } from './records/index.ts';
|
|
7
7
|
import { knowledgeFiles } from './knowledge.ts';
|
|
8
|
-
import { FileState, type LocalWork, type
|
|
8
|
+
import { FileState, type LocalWork, type FileProcessor } from './processing/index.ts';
|
|
9
|
+
import type ScopeLock from 'scope-lock';
|
|
9
10
|
import { BlobStore } from './store/index.ts';
|
|
10
|
-
import { type IndexingProgress, type IndexingEmbedder, type RagExtractors, type VectorIndex } from './rag/index.ts';
|
|
11
|
+
import { type IndexingDevice, type IndexingProgress, type IndexingEmbedder, type RagExtractors, type VectorIndex } from './rag/index.ts';
|
|
11
12
|
import type { Mesh } from '../mesh.ts';
|
|
12
13
|
import type { ChatFileKey } from './records/source.ts';
|
|
13
14
|
import type { SettleOptions } from './processing/settle.ts';
|
|
14
|
-
export { fullTextBudgetChars, fullTextHits, retrieveRagKnowledge, searchRagChunks, referencesPendingFile, type VectorHit, type RagDocumentRef } from './rag/index.ts';
|
|
15
|
+
export { fullTextBudgetChars, fullTextHits, joinedIndex, retrieveRagKnowledge, searchRagChunks, referencesPendingFile, type VectorHit, type RagDocumentRef } from './rag/index.ts';
|
|
15
16
|
export { isKnowledgeRoutedAttachment } from './records/index.ts';
|
|
16
17
|
export { assertRemovableAt } from './records/index.ts';
|
|
17
18
|
export { assertArtifactOutput } from './records/index.ts';
|
|
18
19
|
export { claimSource } from './records/index.ts';
|
|
19
|
-
export interface RetryFileRequest
|
|
20
|
+
export interface RetryFileRequest {
|
|
21
|
+
readonly chatId?: string | null;
|
|
22
|
+
readonly fileId: string;
|
|
20
23
|
readonly processorId: string;
|
|
21
24
|
}
|
|
22
25
|
export interface FileReadOptions {
|
|
@@ -24,11 +27,13 @@ export interface FileReadOptions {
|
|
|
24
27
|
}
|
|
25
28
|
export interface StartProcessorOptions {
|
|
26
29
|
readonly deviceId: Buffer | null;
|
|
30
|
+
readonly device?: IndexingDevice;
|
|
27
31
|
}
|
|
28
32
|
export interface StartProcessingOptions extends StartProcessorOptions {
|
|
29
33
|
readonly embedder: IndexingEmbedder;
|
|
30
34
|
readonly index: VectorIndex;
|
|
31
35
|
readonly extractors?: RagExtractors;
|
|
36
|
+
readonly batches?: ScopeLock;
|
|
32
37
|
}
|
|
33
38
|
export interface FileLoadOptions {
|
|
34
39
|
readonly artifactId?: string;
|
|
@@ -69,20 +74,24 @@ export declare class Files extends EventEmitter {
|
|
|
69
74
|
inline(bytes: Buffer, mimeType: string): string;
|
|
70
75
|
reference(id: Parameters<BlobStore['reference']>[0]): string;
|
|
71
76
|
clear(reference: string, id: string): Promise<boolean>;
|
|
77
|
+
clearFetched(reference: string, id: string): Promise<void>;
|
|
72
78
|
compact(coreKeys: ReadonlyArray<Buffer>): Promise<void>;
|
|
73
79
|
attachments(options?: Parameters<typeof attachmentFiles>[1]): import("./attachments.ts").BoundAttachments;
|
|
74
|
-
knowledge(options?: Parameters<typeof knowledgeFiles>[1]):
|
|
80
|
+
knowledge(options?: Parameters<typeof knowledgeFiles>[1]): import("./knowledge.ts").KnowledgeFiles;
|
|
75
81
|
listKnowledge(chatId: string): Promise<QvacKnowledge[]>;
|
|
82
|
+
knowledgeBase(): Promise<AssistantKnowledgeBaseList>;
|
|
76
83
|
record(id: string): Promise<QvacKnowledge | null>;
|
|
77
84
|
resolve(request: ChatFileKey): Promise<FileRecord | null>;
|
|
78
85
|
fileRead(request: Omit<AssistantFileReadRequest, 'meshId'>, options?: FileReadOptions): AsyncGenerator<AssistantFileReadFrame>;
|
|
79
86
|
preview(request: ChatFileKey): Promise<AssistantFilePreviewResponse>;
|
|
80
|
-
retry(
|
|
87
|
+
retry({ chatId, fileId, processorId }: RetryFileRequest): Promise<void>;
|
|
88
|
+
private _retryKnowledgeBase;
|
|
81
89
|
artifact(id: string): Promise<QvacKnowledgeArtifact | null>;
|
|
82
90
|
artifacts(id: string): Promise<QvacKnowledgeArtifact[]>;
|
|
83
91
|
publish(input: Parameters<typeof addKnowledgeArtifact>[1]): Promise<QvacKnowledgeArtifact>;
|
|
84
92
|
hasLiveSource(chatId: string, reference: string): Promise<boolean>;
|
|
85
|
-
|
|
93
|
+
syncAttachments(chunks: ReadonlyArray<QvacChunk>): Promise<void>;
|
|
94
|
+
reclaimAttachments(chunks: ReadonlyArray<QvacChunk>): Promise<void>;
|
|
86
95
|
syncKnowledge(row: QvacKnowledge): Promise<void>;
|
|
87
96
|
syncArtifact(row: QvacKnowledgeArtifact): Promise<void>;
|
|
88
97
|
reclaimPurged(): Promise<number>;
|
|
@@ -94,6 +103,7 @@ export declare class Files extends EventEmitter {
|
|
|
94
103
|
stopProcessor(id: string): Promise<boolean>;
|
|
95
104
|
private get _processing();
|
|
96
105
|
startProcessing(options: StartProcessingOptions): void;
|
|
106
|
+
rescan(): void;
|
|
97
107
|
stopProcessing(): Promise<boolean>;
|
|
98
108
|
suspend(): Promise<void>;
|
|
99
109
|
resume(): void;
|
|
@@ -108,7 +118,7 @@ export declare class Files extends EventEmitter {
|
|
|
108
118
|
settle(ids: string[], options?: SettleOptions): Promise<void>;
|
|
109
119
|
reconnect(): void;
|
|
110
120
|
report: (update: Parameters<IndexingProgress>[0], processorId?: string) => void;
|
|
111
|
-
progress(chatId: string):
|
|
121
|
+
progress(chatId: string): import("./processing/state.ts").ChatProgressEntry[];
|
|
112
122
|
beginUpload(input: BeginUploadInput): Promise<BegunUpload>;
|
|
113
123
|
uploadProgress(id: string, bytes: number): void;
|
|
114
124
|
uploadComplete(id: string): void;
|
|
@@ -122,7 +132,7 @@ export declare class Files extends EventEmitter {
|
|
|
122
132
|
close(): Promise<void>;
|
|
123
133
|
}
|
|
124
134
|
export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from './rag/index.ts';
|
|
125
|
-
export type { IndexingEmbedder, RagExtractors, RagSource, VectorIndex } from './rag/index.ts';
|
|
135
|
+
export type { IndexingDevice, IndexingEmbedder, RagExtractors, RagSource, VectorIndex } from './rag/index.ts';
|
|
126
136
|
export { attachTurnDocumentIds, groupAttachmentsByMessage } from './records/index.ts';
|
|
127
|
-
export { CoreBlobServer, parseBlobReferenceCoreKey } from './store/index.ts';
|
|
137
|
+
export { CoreBlobServer, PENDING_BLOB_REFERENCE, isPendingBlobReference, parseBlobReferenceCoreKey } from './store/index.ts';
|
|
128
138
|
export type { MeshBlobKeys } from './store/index.ts';
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import EventEmitter from 'bare-events';
|
|
3
3
|
import { attachmentFiles } from './attachments.js';
|
|
4
|
-
import { isKnowledgeRoutedAttachment, getKnowledge, listKnowledge, getKnowledgeArtifact, listKnowledgeArtifactsByKnowledge, addKnowledgeArtifact, hasLiveSource, syncAttachmentChunk, syncKnowledgeTombstone, syncArtifactArrival, sweepTombstonedBlobs, reclaimPurgedFiles, referencedBlobs, scopedFile, attachmentRecord, isProcessorOutput, isProcessorArtifactId } from './records/index.js';
|
|
4
|
+
import { isKnowledgeRoutedAttachment, getKnowledge, listKnowledge, getKnowledgeArtifact, listKnowledgeArtifactsByKnowledge, addKnowledgeArtifact, hasLiveSource, syncAttachmentChunk, syncKnowledgeTombstone, syncArtifactArrival, sweepTombstonedBlobs, reclaimPurgedFiles, referencedBlobs, scopedFile, attachmentRecord, isProcessorOutput, isProcessorArtifactId, knowledgeCapBytes, usedKnowledgeBytes } from './records/index.js';
|
|
5
5
|
import { knowledgeFiles } from './knowledge.js';
|
|
6
6
|
import { randomId } from '../id.js';
|
|
7
|
-
import { getChunk, listChunks } from '../chunk.js';
|
|
8
|
-
import { settleFiles, isClaimLive, listIndexingByChat, FileState, FileProcessing } from './processing/index.js';
|
|
7
|
+
import { findChunksOfType, getChunk, listChunks } from '../chunk.js';
|
|
8
|
+
import { settleFiles, isClaimLive, listIndexingByChat, listIndexingByKnowledge, FileState, FileProcessing } from './processing/index.js';
|
|
9
9
|
import { DeadlineScheduler } from '../../deadline.js';
|
|
10
10
|
import { liveDeviceForWriter } from '../contract/activity.js';
|
|
11
|
+
import { runDefinition } from '../shared-agents.js';
|
|
11
12
|
import { BlobStore, parseBlobReference } from './store/index.js';
|
|
12
13
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
13
14
|
import { RagProcessor } from './rag/index.js';
|
|
14
15
|
import { PreviewProcessor, PREVIEW_VERSION, previewId } from './preview/index.js';
|
|
16
|
+
import { parseFailure } from './rag/failure.js';
|
|
17
|
+
import { CoreError } from '../../errors.js';
|
|
15
18
|
import { errorMessage } from '../../guards.js';
|
|
16
|
-
import { ACTIVE_KNOWLEDGE_BY_CHAT, AGENTS, CHATS,
|
|
17
|
-
export { fullTextBudgetChars, fullTextHits, retrieveRagKnowledge, searchRagChunks, referencesPendingFile } from './rag/index.js';
|
|
19
|
+
import { ACTIVE_KNOWLEDGE_BASE, ACTIVE_KNOWLEDGE_BY_CHAT, AGENTS, CHATS, INDEXING_STATUS_BY_CHAT, INDEXING_STATUS_BY_KNOWLEDGE, KNOWLEDGE, KNOWLEDGE_ARTIFACTS_BY_KNOWLEDGE } from '../collections.js';
|
|
20
|
+
export { fullTextBudgetChars, fullTextHits, joinedIndex, retrieveRagKnowledge, searchRagChunks, referencesPendingFile } from './rag/index.js';
|
|
18
21
|
export { isKnowledgeRoutedAttachment } from './records/index.js';
|
|
19
22
|
export { assertRemovableAt } from './records/index.js';
|
|
20
23
|
export { assertArtifactOutput } from './records/index.js';
|
|
@@ -75,6 +78,15 @@ export class Files extends EventEmitter {
|
|
|
75
78
|
clear(reference, id) {
|
|
76
79
|
return this._store.clear(reference, id);
|
|
77
80
|
}
|
|
81
|
+
async clearFetched(reference, id) {
|
|
82
|
+
const { coreKey, inline } = parseBlobReference(reference);
|
|
83
|
+
if (inline || !coreKey || coreKey === b4a.toHex(this._mesh.blobs.core.key)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (await this.clear(reference, id)) {
|
|
87
|
+
await this._mesh.fileIndex?.markCleared(reference);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
78
90
|
compact(coreKeys) {
|
|
79
91
|
return this._store.compact(coreKeys);
|
|
80
92
|
}
|
|
@@ -87,6 +99,43 @@ export class Files extends EventEmitter {
|
|
|
87
99
|
listKnowledge(chatId) {
|
|
88
100
|
return listKnowledge(this._mesh, { chatId });
|
|
89
101
|
}
|
|
102
|
+
async knowledgeBase() {
|
|
103
|
+
const snap = this._mesh.view.snapshot();
|
|
104
|
+
try {
|
|
105
|
+
const entries = [];
|
|
106
|
+
const rows = await snap.find(ACTIVE_KNOWLEDGE_BASE).toArray();
|
|
107
|
+
for (const knowledge of rows) {
|
|
108
|
+
const attempts = await snap
|
|
109
|
+
.find(INDEXING_STATUS_BY_KNOWLEDGE, {
|
|
110
|
+
gte: { knowledgeId: knowledge.id },
|
|
111
|
+
lte: { knowledgeId: knowledge.id }
|
|
112
|
+
})
|
|
113
|
+
.toArray();
|
|
114
|
+
const rag = attempts.filter((row) => !isProcessorArtifactId(row.id));
|
|
115
|
+
const latest = rag.reduce((current, row) => (!current || row.at > current.at ? row : current), null);
|
|
116
|
+
const status = rag.find((row) => row.status === 'ready') ?? latest;
|
|
117
|
+
const failed = status?.status === 'failed' ? status : null;
|
|
118
|
+
const failure = failed && parseFailure(failed.error);
|
|
119
|
+
const device = failed && (await liveDeviceForWriter(snap, failed.claimedBy));
|
|
120
|
+
entries.push({
|
|
121
|
+
knowledge,
|
|
122
|
+
status: status?.status ?? 'indexing',
|
|
123
|
+
error: failure?.detail,
|
|
124
|
+
loaded: !!this.state.get(knowledge.id)?.loaded,
|
|
125
|
+
reason: failure?.reason,
|
|
126
|
+
failedOn: device?.name
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
entries,
|
|
131
|
+
usedBytes: usedKnowledgeBytes(rows),
|
|
132
|
+
capBytes: await knowledgeCapBytes(snap)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
await snap.close();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
90
139
|
record(id) {
|
|
91
140
|
return getKnowledge(this._mesh, id);
|
|
92
141
|
}
|
|
@@ -131,16 +180,35 @@ export class Files extends EventEmitter {
|
|
|
131
180
|
data: await this.readBytes(output.artifactBlobId)
|
|
132
181
|
};
|
|
133
182
|
}
|
|
134
|
-
async retry(
|
|
135
|
-
const file =
|
|
136
|
-
|
|
183
|
+
async retry({ chatId, fileId, processorId }) {
|
|
184
|
+
const file = chatId
|
|
185
|
+
? await this.resolve({ chatId, fileId })
|
|
186
|
+
: await this._retryKnowledgeBase(fileId);
|
|
187
|
+
const entry = this._processors.get(processorId);
|
|
137
188
|
if (!file || !entry) {
|
|
138
189
|
return;
|
|
139
190
|
}
|
|
140
|
-
this.processorState(
|
|
191
|
+
this.processorState(processorId).retry(file.id);
|
|
141
192
|
await entry.work.enqueue([file.id]);
|
|
142
193
|
this._updated();
|
|
143
194
|
}
|
|
195
|
+
async _retryKnowledgeBase(fileId) {
|
|
196
|
+
if (this._mesh.role !== 'project') {
|
|
197
|
+
throw new CoreError('KNOWLEDGE_BASE_NOT_A_PROJECT');
|
|
198
|
+
}
|
|
199
|
+
const knowledge = await this.record(fileId);
|
|
200
|
+
if (!knowledge || knowledge.chatId || knowledge.deletedAt) {
|
|
201
|
+
throw new CoreError('KNOWLEDGE_NOT_FOUND', [fileId]);
|
|
202
|
+
}
|
|
203
|
+
const failedAt = (await listIndexingByKnowledge(this._mesh, { knowledgeId: fileId }))
|
|
204
|
+
.filter((row) => row.status === 'failed')
|
|
205
|
+
.reduce((newest, row) => Math.max(newest, row.at + 1), 0);
|
|
206
|
+
await this._mesh.dispatch('retry-indexing', {
|
|
207
|
+
knowledgeId: fileId,
|
|
208
|
+
at: Math.max(Date.now(), failedAt)
|
|
209
|
+
});
|
|
210
|
+
return knowledge;
|
|
211
|
+
}
|
|
144
212
|
artifact(id) {
|
|
145
213
|
return getKnowledgeArtifact(this._mesh, id);
|
|
146
214
|
}
|
|
@@ -153,9 +221,16 @@ export class Files extends EventEmitter {
|
|
|
153
221
|
hasLiveSource(chatId, reference) {
|
|
154
222
|
return hasLiveSource(this._mesh, chatId, reference);
|
|
155
223
|
}
|
|
156
|
-
async
|
|
157
|
-
await this._mesh.fileIndex?.refresh(
|
|
158
|
-
await
|
|
224
|
+
async syncAttachments(chunks) {
|
|
225
|
+
await this._mesh.fileIndex?.refresh(chunks);
|
|
226
|
+
await this.reclaimAttachments(chunks);
|
|
227
|
+
}
|
|
228
|
+
async reclaimAttachments(chunks) {
|
|
229
|
+
for (const chunk of chunks) {
|
|
230
|
+
if (this._mesh.closing)
|
|
231
|
+
return;
|
|
232
|
+
await syncAttachmentChunk(this._mesh, chunk);
|
|
233
|
+
}
|
|
159
234
|
}
|
|
160
235
|
syncKnowledge(row) {
|
|
161
236
|
return syncKnowledgeTombstone(this._mesh, row);
|
|
@@ -218,8 +293,14 @@ export class Files extends EventEmitter {
|
|
|
218
293
|
this.setModel(options.embedder.model);
|
|
219
294
|
this.startProcessor(new RagProcessor({
|
|
220
295
|
...options,
|
|
221
|
-
model: options.embedder.model
|
|
222
|
-
|
|
296
|
+
model: options.embedder.model,
|
|
297
|
+
log: this._mesh.log
|
|
298
|
+
}), { deviceId: options.deviceId, device: options.device });
|
|
299
|
+
}
|
|
300
|
+
rescan() {
|
|
301
|
+
for (const { work } of this._processors.values()) {
|
|
302
|
+
work.rescan();
|
|
303
|
+
}
|
|
223
304
|
}
|
|
224
305
|
async stopProcessing() {
|
|
225
306
|
const cleared = await this.stopProcessor('rag');
|
|
@@ -240,7 +321,7 @@ export class Files extends EventEmitter {
|
|
|
240
321
|
const rows = await listIndexingByChat(this._mesh, { chatId });
|
|
241
322
|
let statuses = rows
|
|
242
323
|
.filter((row) => !isProcessorArtifactId(row.id))
|
|
243
|
-
.map((row) => ({ ...row, claimLive: isClaimLive(row, Date.now()) }));
|
|
324
|
+
.map((row) => ({ ...row, chatId, claimLive: isClaimLive(row, Date.now()) }));
|
|
244
325
|
for (const file of (await this.status(chatId)).files) {
|
|
245
326
|
const processor = file.processors.find((entry) => entry.processorId === 'rag');
|
|
246
327
|
if (!processor || file.readyForChat || processor.state === 'not-applicable') {
|
|
@@ -323,7 +404,7 @@ export class Files extends EventEmitter {
|
|
|
323
404
|
processing: this._processing,
|
|
324
405
|
chatIds: async () => {
|
|
325
406
|
const rows = await Promise.all(ids.map((id) => getKnowledge(this._mesh, id)));
|
|
326
|
-
return [...new Set(rows.flatMap((row) => (row ? [row.chatId] : [])))];
|
|
407
|
+
return [...new Set(rows.flatMap((row) => (row?.chatId ? [row.chatId] : [])))];
|
|
327
408
|
}
|
|
328
409
|
});
|
|
329
410
|
}
|
|
@@ -346,15 +427,15 @@ export class Files extends EventEmitter {
|
|
|
346
427
|
return this.state.progress(chatId);
|
|
347
428
|
}
|
|
348
429
|
async beginUpload(input) {
|
|
349
|
-
const { chatId, fileName, mimeType } = input;
|
|
350
|
-
if (!
|
|
351
|
-
throw new
|
|
430
|
+
const { chatId = null, fileName, mimeType } = input;
|
|
431
|
+
if (!fileName || !mimeType) {
|
|
432
|
+
throw new CoreError('UPLOAD_METADATA_INCOMPLETE');
|
|
352
433
|
}
|
|
353
434
|
const id = input.fileId || randomId();
|
|
354
435
|
this._pruneUploads();
|
|
355
436
|
const previous = this._uploads.get(id);
|
|
356
437
|
if (previous && !previous.expiresAt) {
|
|
357
|
-
throw new
|
|
438
|
+
throw new CoreError('FILE_ID_EXISTS');
|
|
358
439
|
}
|
|
359
440
|
this._uploads.set(id, {
|
|
360
441
|
status: {
|
|
@@ -376,8 +457,9 @@ export class Files extends EventEmitter {
|
|
|
376
457
|
if (input.fileId &&
|
|
377
458
|
((await getKnowledge(this._mesh, id)) ||
|
|
378
459
|
(await getChunk(this._mesh, id)) ||
|
|
379
|
-
(
|
|
380
|
-
|
|
460
|
+
(chatId &&
|
|
461
|
+
(await listChunks(this._mesh, { chatId, type: 'attachment' })).some((chunk) => chunk.attachment?.id === id)))) {
|
|
462
|
+
throw new CoreError('FILE_ID_EXISTS');
|
|
381
463
|
}
|
|
382
464
|
}
|
|
383
465
|
catch (error) {
|
|
@@ -446,15 +528,15 @@ export class Files extends EventEmitter {
|
|
|
446
528
|
if (!chat || chat.deletedAt) {
|
|
447
529
|
return { files: [] };
|
|
448
530
|
}
|
|
449
|
-
const agent = await snap.get(AGENTS, { id: chat.agentId });
|
|
531
|
+
const agent = await runDefinition(this._mesh, await snap.get(AGENTS, { id: chat.agentId }));
|
|
450
532
|
const knowledge = await snap.find(ACTIVE_KNOWLEDGE_BY_CHAT, range).toArray();
|
|
451
|
-
const chunks = await snap
|
|
533
|
+
const chunks = await findChunksOfType(snap, { chatId, type: 'attachment' });
|
|
452
534
|
const statuses = await snap.find(INDEXING_STATUS_BY_CHAT, range).toArray();
|
|
453
535
|
const sources = new Map(knowledge.map((row) => [row.id, row]));
|
|
454
536
|
const ragIds = new Set(sources.keys());
|
|
455
537
|
for (const chunk of chunks) {
|
|
456
538
|
const file = chunk.attachment;
|
|
457
|
-
if (!file || file.deletedAt || sources.has(file.id)) {
|
|
539
|
+
if (!file || file.deletedAt || chunk.sourceId || sources.has(file.id)) {
|
|
458
540
|
continue;
|
|
459
541
|
}
|
|
460
542
|
sources.set(file.id, { ...file, chatId, updatedAt: file.createdAt });
|
|
@@ -471,6 +553,7 @@ export class Files extends EventEmitter {
|
|
|
471
553
|
if (upload.chatId === chatId && upload.state !== 'pending') {
|
|
472
554
|
result.set(upload.fileId, {
|
|
473
555
|
...upload,
|
|
556
|
+
chatId,
|
|
474
557
|
uploadProgress: upload.uploadProgress ? { ...upload.uploadProgress } : undefined
|
|
475
558
|
});
|
|
476
559
|
}
|
|
@@ -512,7 +595,7 @@ export class Files extends EventEmitter {
|
|
|
512
595
|
else if (local?.work &&
|
|
513
596
|
!published &&
|
|
514
597
|
local.work.state !== 'running' &&
|
|
515
|
-
(!terminalFailure || local.work
|
|
598
|
+
(!terminalFailure || !yieldsToVerdict(local.work))) {
|
|
516
599
|
Object.assign(processor, local.work);
|
|
517
600
|
}
|
|
518
601
|
else if (local?.load && published) {
|
|
@@ -520,7 +603,7 @@ export class Files extends EventEmitter {
|
|
|
520
603
|
}
|
|
521
604
|
else if (failed && !published && failed.error !== 'interrupted: suspend') {
|
|
522
605
|
processor.state = failed.error === 'source unavailable' ? 'pending' : 'failed';
|
|
523
|
-
processor.reason = failed.error || 'processing failed';
|
|
606
|
+
processor.reason = parseFailure(failed.error).detail || 'processing failed';
|
|
524
607
|
}
|
|
525
608
|
else if (!this._model) {
|
|
526
609
|
processor.reason = 'model unavailable on this device';
|
|
@@ -636,6 +719,9 @@ export class Files extends EventEmitter {
|
|
|
636
719
|
await this._store.close();
|
|
637
720
|
}
|
|
638
721
|
}
|
|
722
|
+
function yieldsToVerdict(work) {
|
|
723
|
+
return work.state === 'pending' || (work.state === 'failed' && work.retryAt === undefined);
|
|
724
|
+
}
|
|
639
725
|
function fileState(processor, opts) {
|
|
640
726
|
if (opts.readyForChat) {
|
|
641
727
|
return { state: 'ready', reason: undefined };
|
|
@@ -647,4 +733,4 @@ function fileState(processor, opts) {
|
|
|
647
733
|
}
|
|
648
734
|
export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from './rag/index.js';
|
|
649
735
|
export { attachTurnDocumentIds, groupAttachmentsByMessage } from './records/index.js';
|
|
650
|
-
export { CoreBlobServer, parseBlobReferenceCoreKey } from './store/index.js';
|
|
736
|
+
export { CoreBlobServer, PENDING_BLOB_REFERENCE, isPendingBlobReference, parseBlobReferenceCoreKey } from './store/index.js';
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import type { AssistantFileKnowledgeRequest, AssistantKnowledge } from '../../../spec/hyperschema/types.d.ts';
|
|
1
2
|
import { MAX_KNOWLEDGE_BYTES } from './rag/index.ts';
|
|
2
3
|
import type { Mesh } from '../mesh.ts';
|
|
3
4
|
import { type FileHandlersOptions } from './upload.ts';
|
|
4
5
|
import type { CapabilityHandlers } from '../../../spec/capabilities.d.ts';
|
|
5
6
|
export { MAX_KNOWLEDGE_BYTES };
|
|
6
|
-
export
|
|
7
|
+
export type FileKnowledgeRequest = Omit<AssistantFileKnowledgeRequest, 'meshId'>;
|
|
8
|
+
export interface KnowledgeFiles extends Pick<CapabilityHandlers, 'uploadKnowledge' | 'downloadKnowledge' | 'listKnowledge' | 'removeKnowledge' | 'listIndexing'> {
|
|
9
|
+
fileKnowledge(request: FileKnowledgeRequest): Promise<AssistantKnowledge>;
|
|
10
|
+
}
|
|
11
|
+
export interface KnowledgeFilesOptions extends FileHandlersOptions {
|
|
12
|
+
readonly mobile?: () => boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function knowledgeFiles(mesh: Mesh, { maxBytes, inactivityMs, deviceId, mobile }?: KnowledgeFilesOptions): KnowledgeFiles;
|
|
15
|
+
export declare function setKnowledgeCap(mesh: Mesh, bytes: number): Promise<void>;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { listKnowledge, removeKnowledge } from './records/index.js';
|
|
2
|
-
import { MAX_KNOWLEDGE_BYTES } from './rag/index.js';
|
|
1
|
+
import { addKnowledge, assertKnowledgeRoom, hasLiveSource, listKnowledge, removeKnowledge } from './records/index.js';
|
|
2
|
+
import { MAX_KNOWLEDGE_BYTES, isSupportedRagDocument } from './rag/index.js';
|
|
3
|
+
import { requireChatIn } from '../chunk.js';
|
|
4
|
+
import { randomId } from '../id.js';
|
|
5
|
+
import { CoreError } from '../../errors.js';
|
|
3
6
|
import { uploadFile } from './upload.js';
|
|
7
|
+
import { KNOWLEDGE_CAP_ROW } from '../contract/knowledge.js';
|
|
8
|
+
import { KNOWLEDGE_CAPS } from '../collections.js';
|
|
4
9
|
export { MAX_KNOWLEDGE_BYTES };
|
|
5
|
-
export function knowledgeFiles(mesh, { maxBytes = MAX_KNOWLEDGE_BYTES, inactivityMs, deviceId } = {}) {
|
|
10
|
+
export function knowledgeFiles(mesh, { maxBytes = MAX_KNOWLEDGE_BYTES, inactivityMs, deviceId, mobile } = {}) {
|
|
6
11
|
const list = async ({ chatId }) => ({
|
|
7
12
|
knowledge: await listKnowledge(mesh, { chatId })
|
|
8
13
|
});
|
|
@@ -22,10 +27,77 @@ export function knowledgeFiles(mesh, { maxBytes = MAX_KNOWLEDGE_BYTES, inactivit
|
|
|
22
27
|
}
|
|
23
28
|
},
|
|
24
29
|
downloadKnowledge: async function* ({ blobId }) {
|
|
25
|
-
|
|
30
|
+
let fetched = false;
|
|
31
|
+
try {
|
|
32
|
+
for await (const frame of mesh.files.read(blobId)) {
|
|
33
|
+
fetched = true;
|
|
34
|
+
yield frame;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
if (fetched && mobile?.() && (await hasLiveSource(mesh, null, blobId))) {
|
|
39
|
+
await mesh.files.clearFetched(blobId, blobId);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
26
42
|
},
|
|
27
43
|
listKnowledge: list,
|
|
28
44
|
listIndexing: indexingList,
|
|
29
|
-
removeKnowledge: async ({ knowledgeId, at }) => removeKnowledge(mesh, { knowledgeId, at })
|
|
45
|
+
removeKnowledge: async ({ knowledgeId, at }) => removeKnowledge(mesh, { knowledgeId, at }),
|
|
46
|
+
fileKnowledge: (request) => fileKnowledge(mesh, request)
|
|
30
47
|
};
|
|
31
48
|
}
|
|
49
|
+
async function fileKnowledge(mesh, { chatId, fileId }) {
|
|
50
|
+
if (mesh.role !== 'project') {
|
|
51
|
+
throw new CoreError('KNOWLEDGE_BASE_NOT_A_PROJECT');
|
|
52
|
+
}
|
|
53
|
+
await requireChatIn(mesh, chatId);
|
|
54
|
+
const file = await mesh.files.resolve({ chatId, fileId });
|
|
55
|
+
if (!file) {
|
|
56
|
+
throw new CoreError('KNOWLEDGE_NOT_FOUND', [fileId]);
|
|
57
|
+
}
|
|
58
|
+
if (!isSupportedRagDocument(file)) {
|
|
59
|
+
throw new CoreError('KNOWLEDGE_TYPE_UNSUPPORTED', [file.fileName]);
|
|
60
|
+
}
|
|
61
|
+
await assertKnowledgeRoom(mesh, file.byteLength);
|
|
62
|
+
const blobId = await copyBlob(mesh, file.blobId);
|
|
63
|
+
const id = randomId();
|
|
64
|
+
const { fileName, mimeType, byteLength } = file;
|
|
65
|
+
try {
|
|
66
|
+
return await addKnowledge(mesh, { id, fileName, mimeType, byteLength, blobId });
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
await mesh.files.clear(blobId, id).catch(noop);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function copyBlob(mesh, source) {
|
|
74
|
+
let blobId = null;
|
|
75
|
+
for await (const frame of mesh.files.write(bytesOf(mesh.files.read(source, { wait: false })))) {
|
|
76
|
+
if ('blobId' in frame) {
|
|
77
|
+
blobId = mesh.files.reference(frame.blobId);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (blobId === null) {
|
|
81
|
+
throw new Error('blob write ended without its blobId frame');
|
|
82
|
+
}
|
|
83
|
+
return blobId;
|
|
84
|
+
}
|
|
85
|
+
function noop() { }
|
|
86
|
+
async function* bytesOf(frames) {
|
|
87
|
+
for await (const { data } of frames) {
|
|
88
|
+
yield data;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export async function setKnowledgeCap(mesh, bytes) {
|
|
92
|
+
if (mesh.role !== 'project') {
|
|
93
|
+
throw new CoreError('KNOWLEDGE_BASE_NOT_A_PROJECT');
|
|
94
|
+
}
|
|
95
|
+
if (bytes < 1) {
|
|
96
|
+
throw new CoreError('KNOWLEDGE_CAP_INVALID');
|
|
97
|
+
}
|
|
98
|
+
const current = await mesh.view.get(KNOWLEDGE_CAPS, { id: KNOWLEDGE_CAP_ROW });
|
|
99
|
+
await mesh.dispatch('set-knowledge-cap', {
|
|
100
|
+
bytes,
|
|
101
|
+
setAt: Math.max(Date.now(), (current?.setAt ?? 0) + 1)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import crypto from 'hypercore-crypto';
|
|
3
3
|
import { processorArtifactId } from '../records/index.js';
|
|
4
|
-
import { parseBlobReference } from '../store/index.js';
|
|
4
|
+
import { isPendingBlobReference, parseBlobReference } from '../store/index.js';
|
|
5
5
|
import { IMAGE_MIMES } from '../../image/normalize.js';
|
|
6
6
|
import { previewEncoder } from './image.js';
|
|
7
7
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
@@ -30,7 +30,8 @@ export class PreviewProcessor {
|
|
|
30
30
|
IMAGE_MIMES.has(file.mimeType.toLowerCase()));
|
|
31
31
|
}
|
|
32
32
|
async canProduce(file, host) {
|
|
33
|
-
|
|
33
|
+
const chat = file.chatId ? await getChat(host.mesh, file.chatId) : null;
|
|
34
|
+
return !file.deletedAt && !chat?.deletedAt;
|
|
34
35
|
}
|
|
35
36
|
accepts(output, file) {
|
|
36
37
|
if (output.embedderVersion !== this.version)
|
|
@@ -151,6 +152,9 @@ export function previewId(file) {
|
|
|
151
152
|
});
|
|
152
153
|
}
|
|
153
154
|
function previewSource(file) {
|
|
155
|
+
if (isPendingBlobReference(file.blobId)) {
|
|
156
|
+
return hash([file.blobId]);
|
|
157
|
+
}
|
|
154
158
|
const { blobId, coreKey } = parseBlobReference(file.blobId);
|
|
155
159
|
return hash([
|
|
156
160
|
coreKey ?? '',
|
|
@@ -11,6 +11,12 @@ export interface IndexingClaimsOptions {
|
|
|
11
11
|
export interface IndexingClaim {
|
|
12
12
|
readonly claimId: string;
|
|
13
13
|
}
|
|
14
|
+
export interface IndexingLease {
|
|
15
|
+
keep(force?: boolean): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare class ClaimLostError extends Error {
|
|
18
|
+
constructor(artifactId: string);
|
|
19
|
+
}
|
|
14
20
|
export declare class IndexingClaims {
|
|
15
21
|
private readonly _mesh;
|
|
16
22
|
private readonly _schedule;
|
|
@@ -22,6 +28,7 @@ export declare class IndexingClaims {
|
|
|
22
28
|
markFailed(artifactId: string): void;
|
|
23
29
|
isFailed(artifactId: string): boolean;
|
|
24
30
|
claim(artifactId: string, knowledgeId: string): Promise<IndexingClaim | null>;
|
|
31
|
+
lease(artifactId: string, claimId: string): IndexingLease;
|
|
25
32
|
blockedByStatus(artifactId: string): Promise<boolean>;
|
|
26
33
|
settle(artifactId: string, knowledgeId: string): Promise<void>;
|
|
27
34
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { claimIndexing, getIndexingStatus, isClaimLive, resolveIndexing } from './protocol.js';
|
|
1
|
+
import { INDEXING_STALE_MS, claimIndexing, getIndexingStatus, isClaimLive, progressIndexing, resolveIndexing } from './protocol.js';
|
|
2
|
+
import { isContentFailure } from '../rag/failure.js';
|
|
3
|
+
export class ClaimLostError extends Error {
|
|
4
|
+
constructor(artifactId) {
|
|
5
|
+
super(`indexing claim taken over: ${artifactId}`);
|
|
6
|
+
this.name = 'ClaimLostError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
2
9
|
export class IndexingClaims {
|
|
3
10
|
_mesh;
|
|
4
11
|
_schedule;
|
|
@@ -42,18 +49,37 @@ export class IndexingClaims {
|
|
|
42
49
|
!(await getIndexingStatus(this._mesh, artifactId))) {
|
|
43
50
|
return { claimId: '' };
|
|
44
51
|
}
|
|
45
|
-
|
|
52
|
+
this._mesh.log?.debug('rag', 'claim not placed', { id: artifactId, err });
|
|
46
53
|
return null;
|
|
47
54
|
}
|
|
48
55
|
}
|
|
56
|
+
lease(artifactId, claimId) {
|
|
57
|
+
let last = Date.now();
|
|
58
|
+
return {
|
|
59
|
+
keep: async (force = false) => {
|
|
60
|
+
const at = Date.now();
|
|
61
|
+
if (!claimId || (!force && at - last < INDEXING_STALE_MS / 3)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
last = at;
|
|
65
|
+
if (!(await progressIndexing(this._mesh, { artifactId, claimId, at }))) {
|
|
66
|
+
throw new ClaimLostError(artifactId);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
49
71
|
async blockedByStatus(artifactId) {
|
|
50
|
-
if (this.isFailed(artifactId))
|
|
51
|
-
return true;
|
|
52
72
|
const row = await getIndexingStatus(this._mesh, artifactId);
|
|
73
|
+
if (this.isFailed(artifactId)) {
|
|
74
|
+
if (row) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
this._state.artifact(artifactId).terminal = false;
|
|
78
|
+
}
|
|
53
79
|
if (!row) {
|
|
54
80
|
return false;
|
|
55
81
|
}
|
|
56
|
-
if (row.status === 'ready') {
|
|
82
|
+
if (row.status === 'ready' || isContentFailure(row)) {
|
|
57
83
|
return true;
|
|
58
84
|
}
|
|
59
85
|
if (isClaimLive(row, Date.now())) {
|
|
@@ -87,11 +113,11 @@ export class IndexingClaims {
|
|
|
87
113
|
status: 'ready'
|
|
88
114
|
});
|
|
89
115
|
if (applied) {
|
|
90
|
-
|
|
116
|
+
this._mesh.log?.info('rag', 'repaired to ready', { id: artifactId });
|
|
91
117
|
}
|
|
92
118
|
}
|
|
93
119
|
catch (err) {
|
|
94
|
-
|
|
120
|
+
this._mesh.log?.debug('rag', 'repair resolve dropped', { id: artifactId, err });
|
|
95
121
|
}
|
|
96
122
|
}
|
|
97
123
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LoggerInterface } from '@qvac/logging';
|
|
1
2
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
3
|
import { type IndexingProgress } from '../rag/index.ts';
|
|
3
4
|
import { IndexingClaims } from './claims.ts';
|
|
@@ -17,6 +18,7 @@ export interface FileDocumentOptions {
|
|
|
17
18
|
readonly closed: () => boolean;
|
|
18
19
|
readonly paused: () => boolean;
|
|
19
20
|
readonly progress?: IndexingProgress;
|
|
21
|
+
readonly admit?: () => void;
|
|
20
22
|
}
|
|
21
23
|
interface SourceReference {
|
|
22
24
|
readonly id: string;
|
|
@@ -32,16 +34,20 @@ export declare class FileDocument {
|
|
|
32
34
|
isFailed: IndexingClaims['isFailed'];
|
|
33
35
|
blockedByStatus: IndexingClaims['blockedByStatus'];
|
|
34
36
|
claim: (id: string) => ReturnType<IndexingClaims['claim']>;
|
|
37
|
+
lease: IndexingClaims['lease'];
|
|
35
38
|
settle: (id: string) => Promise<void>;
|
|
36
39
|
};
|
|
37
40
|
readonly ownership: ArtifactOwnership;
|
|
38
41
|
readonly schedule: (deadline: number) => void;
|
|
39
42
|
readonly closed: () => boolean;
|
|
40
43
|
readonly paused: () => boolean;
|
|
44
|
+
readonly admit: () => void;
|
|
41
45
|
private readonly _output;
|
|
46
|
+
private _fetched;
|
|
42
47
|
private readonly _progress?;
|
|
43
48
|
private readonly _processor;
|
|
44
49
|
constructor(mesh: Mesh, options: FileDocumentOptions);
|
|
50
|
+
get log(): LoggerInterface | null;
|
|
45
51
|
get localCoreKey(): string;
|
|
46
52
|
artifact(id: string): import("./state.ts").ArtifactState;
|
|
47
53
|
readArtifact(id: string): Readonly<import("./state.ts").ArtifactState> | undefined;
|
|
@@ -51,6 +57,8 @@ export declare class FileDocument {
|
|
|
51
57
|
miss: () => number;
|
|
52
58
|
clear: () => void;
|
|
53
59
|
};
|
|
60
|
+
clearFetched(): Promise<void>;
|
|
61
|
+
private _fetching;
|
|
54
62
|
artifacts(): Promise<import("../../../../spec/index").QvacKnowledgeArtifact[]>;
|
|
55
63
|
statuses(): Promise<import("../../../../spec/index").QvacIndexingStatus[]>;
|
|
56
64
|
current(): Promise<FileRecord | null>;
|