@qvac/core 0.4.1 → 0.6.0
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 +262 -1
- package/README.md +1 -1
- package/dist-lib/lib/api/agents.js +3 -2
- package/dist-lib/lib/api/app-config.d.ts +1 -1
- package/dist-lib/lib/api/app-config.js +54 -15
- package/dist-lib/lib/api/attachments.d.ts +6 -5
- package/dist-lib/lib/api/attachments.js +4 -2
- package/dist-lib/lib/api/chat.d.ts +7 -3
- package/dist-lib/lib/api/chat.js +4 -4
- package/dist-lib/lib/api/chunks.js +3 -3
- package/dist-lib/lib/api/config.js +2 -2
- package/dist-lib/lib/api/current-mesh.d.ts +3 -4
- package/dist-lib/lib/api/current-mesh.js +9 -4
- package/dist-lib/lib/api/custom-models.d.ts +8 -1
- package/dist-lib/lib/api/custom-models.js +53 -16
- package/dist-lib/lib/api/devices.d.ts +14 -5
- package/dist-lib/lib/api/devices.js +14 -9
- package/dist-lib/lib/api/diagnostics.d.ts +1 -0
- package/dist-lib/lib/api/diagnostics.js +1 -1
- package/dist-lib/lib/api/effective-ctx-size.d.ts +6 -1
- package/dist-lib/lib/api/effective-ctx-size.js +5 -3
- package/dist-lib/lib/api/execution.js +9 -2
- package/dist-lib/lib/api/files.js +2 -1
- package/dist-lib/lib/api/index.d.ts +7 -1
- package/dist-lib/lib/api/index.js +101 -101
- package/dist-lib/lib/api/instrument.js +29 -20
- package/dist-lib/lib/api/knowledge.d.ts +6 -5
- package/dist-lib/lib/api/knowledge.js +8 -6
- package/dist-lib/lib/api/local-files.js +1 -1
- package/dist-lib/lib/api/logs.js +6 -3
- package/dist-lib/lib/api/members.js +22 -13
- package/dist-lib/lib/api/mesh.d.ts +7 -2
- package/dist-lib/lib/api/mesh.js +10 -5
- package/dist-lib/lib/api/model-download.js +1 -1
- package/dist-lib/lib/api/network.d.ts +1 -0
- package/dist-lib/lib/api/network.js +1 -1
- package/dist-lib/lib/api/notifications.js +23 -13
- package/dist-lib/lib/api/rag.d.ts +6 -1
- package/dist-lib/lib/api/rag.js +20 -11
- package/dist-lib/lib/api/range.d.ts +2 -2
- package/dist-lib/lib/api/sync.js +1 -1
- package/dist-lib/lib/api/tool-activity.js +7 -3
- package/dist-lib/lib/api/tool-configs.js +2 -4
- package/dist-lib/lib/api/upload-frames.d.ts +7 -8
- package/dist-lib/lib/api/upload-frames.js +2 -1
- package/dist-lib/lib/api/watchable.d.ts +6 -1
- package/dist-lib/lib/api/watchable.js +23 -14
- package/dist-lib/lib/assistant/fetch-body.js +4 -2
- package/dist-lib/lib/assistant/harness.d.ts +72 -24
- package/dist-lib/lib/assistant/harness.js +53 -15
- package/dist-lib/lib/assistant/history.d.ts +9 -7
- package/dist-lib/lib/assistant/history.js +77 -42
- package/dist-lib/lib/assistant/message.d.ts +5 -3
- package/dist-lib/lib/assistant/message.js +4 -2
- package/dist-lib/lib/assistant/skill-encode.d.ts +3 -1
- package/dist-lib/lib/assistant/skill-encode.js +52 -62
- package/dist-lib/lib/assistant-client.js +7 -4
- package/dist-lib/lib/assistant-tree.js +36 -11
- package/dist-lib/lib/assistant.d.ts +37 -12
- package/dist-lib/lib/assistant.js +977 -373
- package/dist-lib/lib/audio-format.d.ts +1 -1
- package/dist-lib/lib/audio-format.js +1 -1
- package/dist-lib/lib/chat-title.js +9 -4
- package/dist-lib/lib/client.js +3 -2
- package/dist-lib/lib/collabora/convert.d.ts +2 -2
- package/dist-lib/lib/collabora/convert.js +6 -3
- package/dist-lib/lib/collabora/entry.js +9 -5
- package/dist-lib/lib/collabora/protocol.d.ts +2 -2
- package/dist-lib/lib/collabora/protocol.js +14 -7
- package/dist-lib/lib/collabora/worker.js +14 -7
- package/dist-lib/lib/compaction.d.ts +5 -6
- package/dist-lib/lib/compaction.js +14 -7
- package/dist-lib/lib/constants.d.ts +2 -0
- package/dist-lib/lib/constants.js +4 -0
- package/dist-lib/lib/core/account-recovery.d.ts +4 -3
- package/dist-lib/lib/core/account-recovery.js +7 -4
- package/dist-lib/lib/core/agent.d.ts +0 -1
- package/dist-lib/lib/core/agent.js +18 -16
- package/dist-lib/lib/core/approval-rules.d.ts +7 -6
- package/dist-lib/lib/core/approval-rules.js +12 -6
- package/dist-lib/lib/core/archived-mesh.d.ts +7 -5
- package/dist-lib/lib/core/archived-mesh.js +25 -22
- package/dist-lib/lib/core/async-iterable.js +10 -5
- package/dist-lib/lib/core/attachment-link.d.ts +2 -2
- package/dist-lib/lib/core/audio-attachment.js +1 -1
- package/dist-lib/lib/core/blind-peers.d.ts +2 -2
- package/dist-lib/lib/core/chat-activity.d.ts +2 -2
- package/dist-lib/lib/core/chat-activity.js +42 -21
- package/dist-lib/lib/core/chat-group.d.ts +8 -6
- package/dist-lib/lib/core/chat-group.js +17 -10
- package/dist-lib/lib/core/chat-order.d.ts +11 -9
- package/dist-lib/lib/core/chat-order.js +1 -3
- package/dist-lib/lib/core/chat-search.d.ts +4 -4
- package/dist-lib/lib/core/chat-search.js +38 -24
- package/dist-lib/lib/core/chat.d.ts +20 -14
- package/dist-lib/lib/core/chat.js +42 -28
- package/dist-lib/lib/core/chunk.d.ts +20 -24
- package/dist-lib/lib/core/chunk.js +34 -22
- package/dist-lib/lib/core/collections.d.ts +69 -0
- package/dist-lib/lib/core/collections.js +69 -0
- package/dist-lib/lib/core/contract/activity.d.ts +8 -2
- package/dist-lib/lib/core/contract/activity.js +39 -11
- package/dist-lib/lib/core/contract/agents.js +3 -2
- package/dist-lib/lib/core/contract/approval-rules.js +1 -1
- package/dist-lib/lib/core/contract/attestations.js +1 -1
- package/dist-lib/lib/core/contract/chat-group.js +1 -1
- package/dist-lib/lib/core/contract/chat.js +1 -1
- package/dist-lib/lib/core/contract/chunks.js +16 -9
- package/dist-lib/lib/core/contract/compute.js +2 -1
- package/dist-lib/lib/core/contract/devices.js +10 -6
- package/dist-lib/lib/core/contract/grant-order.d.ts +5 -0
- package/dist-lib/lib/core/contract/grant-order.js +20 -0
- package/dist-lib/lib/core/contract/index.d.ts +1 -1
- package/dist-lib/lib/core/contract/index.js +27 -2
- package/dist-lib/lib/core/contract/indexing.js +3 -3
- package/dist-lib/lib/core/contract/invites.d.ts +16 -0
- package/dist-lib/lib/core/contract/invites.js +256 -0
- package/dist-lib/lib/core/contract/joined-meshes.js +22 -22
- package/dist-lib/lib/core/contract/knowledge.js +5 -5
- package/dist-lib/lib/core/contract/members.d.ts +15 -0
- package/dist-lib/lib/core/contract/members.js +116 -31
- package/dist-lib/lib/core/contract/mesh-kind.d.ts +6 -0
- package/dist-lib/lib/core/contract/mesh-kind.js +49 -0
- package/dist-lib/lib/core/contract/seal.js +1 -1
- package/dist-lib/lib/core/contract/seed-defaults.js +1 -3
- package/dist-lib/lib/core/contract/tool-activity.js +5 -5
- package/dist-lib/lib/core/contract/tool-configs.js +1 -2
- package/dist-lib/lib/core/contract/writers.d.ts +13 -0
- package/dist-lib/lib/core/contract/writers.js +181 -24
- package/dist-lib/lib/core/departures.js +16 -8
- package/dist-lib/lib/core/device-attestation.d.ts +5 -0
- package/dist-lib/lib/core/device-attestation.js +24 -0
- package/dist-lib/lib/core/device-invites.d.ts +2 -0
- package/dist-lib/lib/core/device-invites.js +29 -7
- package/dist-lib/lib/core/devices.d.ts +2 -1
- package/dist-lib/lib/core/devices.js +52 -2
- package/dist-lib/lib/core/document-attachment.d.ts +20 -11
- package/dist-lib/lib/core/document-attachment.js +10 -5
- package/dist-lib/lib/core/files/attachments.d.ts +2 -5
- package/dist-lib/lib/core/files/attachments.js +6 -3
- package/dist-lib/lib/core/files/index.d.ts +44 -52
- package/dist-lib/lib/core/files/index.js +142 -93
- package/dist-lib/lib/core/files/knowledge.d.ts +2 -5
- package/dist-lib/lib/core/files/local-index.js +9 -5
- package/dist-lib/lib/core/files/preview/image.d.ts +0 -1
- package/dist-lib/lib/core/files/preview/image.js +9 -6
- package/dist-lib/lib/core/files/preview/index.d.ts +8 -11
- package/dist-lib/lib/core/files/preview/index.js +20 -15
- package/dist-lib/lib/core/files/processing/claims.d.ts +6 -5
- package/dist-lib/lib/core/files/processing/claims.js +16 -8
- package/dist-lib/lib/core/files/processing/document.d.ts +21 -50
- package/dist-lib/lib/core/files/processing/index.d.ts +18 -13
- package/dist-lib/lib/core/files/processing/index.js +65 -37
- package/dist-lib/lib/core/files/processing/ownership.d.ts +8 -1
- package/dist-lib/lib/core/files/processing/ownership.js +1 -1
- package/dist-lib/lib/core/files/processing/protocol.d.ts +19 -19
- package/dist-lib/lib/core/files/processing/protocol.js +5 -5
- package/dist-lib/lib/core/files/processing/settle.d.ts +10 -7
- package/dist-lib/lib/core/files/processing/settle.js +22 -11
- package/dist-lib/lib/core/files/processing/source.js +14 -8
- package/dist-lib/lib/core/files/processing/state.d.ts +13 -11
- package/dist-lib/lib/core/files/processing/state.js +19 -12
- package/dist-lib/lib/core/files/rag/build.d.ts +2 -2
- package/dist-lib/lib/core/files/rag/build.js +2 -1
- package/dist-lib/lib/core/files/rag/document-types.d.ts +4 -6
- package/dist-lib/lib/core/files/rag/index.d.ts +10 -13
- package/dist-lib/lib/core/files/rag/index.js +3 -2
- package/dist-lib/lib/core/files/rag/load.d.ts +10 -9
- package/dist-lib/lib/core/files/rag/load.js +26 -13
- package/dist-lib/lib/core/files/rag/policy.js +2 -1
- package/dist-lib/lib/core/files/rag/produce.js +33 -19
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +5 -3
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +30 -10
- package/dist-lib/lib/core/files/records/chunks.js +4 -2
- package/dist-lib/lib/core/files/records/knowledge.d.ts +10 -11
- package/dist-lib/lib/core/files/records/knowledge.js +9 -8
- package/dist-lib/lib/core/files/records/linkage.js +6 -3
- package/dist-lib/lib/core/files/records/output.d.ts +5 -4
- package/dist-lib/lib/core/files/records/output.js +8 -4
- package/dist-lib/lib/core/files/records/reclaim.js +41 -25
- package/dist-lib/lib/core/files/records/routing.d.ts +4 -6
- package/dist-lib/lib/core/files/records/routing.js +15 -8
- package/dist-lib/lib/core/files/records/source.d.ts +5 -4
- package/dist-lib/lib/core/files/records/source.js +20 -14
- package/dist-lib/lib/core/files/records/sweep.js +1 -3
- package/dist-lib/lib/core/files/store/blob.d.ts +10 -10
- package/dist-lib/lib/core/files/store/blob.js +25 -19
- package/dist-lib/lib/core/files/store/index.d.ts +1 -6
- package/dist-lib/lib/core/files/store/index.js +4 -4
- package/dist-lib/lib/core/files/store/inline.d.ts +2 -2
- package/dist-lib/lib/core/files/store/inline.js +6 -3
- package/dist-lib/lib/core/files/store/reference.d.ts +6 -9
- package/dist-lib/lib/core/files/store/reference.js +25 -17
- package/dist-lib/lib/core/files/store/server.d.ts +7 -6
- package/dist-lib/lib/core/files/store/server.js +22 -11
- package/dist-lib/lib/core/files/store/sweep.js +13 -7
- package/dist-lib/lib/core/files/upload-input.d.ts +4 -12
- package/dist-lib/lib/core/files/upload-input.js +10 -5
- package/dist-lib/lib/core/files/upload.d.ts +27 -24
- package/dist-lib/lib/core/files/upload.js +74 -51
- package/dist-lib/lib/core/fs-drives.js +4 -2
- package/dist-lib/lib/core/grant-expiry.d.ts +11 -0
- package/dist-lib/lib/core/grant-expiry.js +66 -0
- package/dist-lib/lib/core/handoff-channel.d.ts +2 -1
- package/dist-lib/lib/core/handoff-channel.js +36 -15
- package/dist-lib/lib/core/harness-loan.js +35 -17
- package/dist-lib/lib/core/helpers/index.d.ts +2 -1
- package/dist-lib/lib/core/helpers/index.js +11 -6
- package/dist-lib/lib/core/hosted-agents.js +19 -12
- package/dist-lib/lib/core/id.js +1 -1
- package/dist-lib/lib/core/identity.d.ts +1 -0
- package/dist-lib/lib/core/identity.js +11 -3
- package/dist-lib/lib/core/image/cache-sweep.d.ts +12 -10
- package/dist-lib/lib/core/image/cache-sweep.js +11 -6
- package/dist-lib/lib/core/image/normalize.d.ts +6 -0
- package/dist-lib/lib/core/image/normalize.js +12 -2
- package/dist-lib/lib/core/image/sniff.js +42 -21
- package/dist-lib/lib/core/inference-calls-receiver.js +7 -4
- package/dist-lib/lib/core/invite-grants.d.ts +20 -0
- package/dist-lib/lib/core/invite-grants.js +46 -0
- package/dist-lib/lib/core/invite.d.ts +3 -0
- package/dist-lib/lib/core/invite.js +6 -3
- package/dist-lib/lib/core/local/files.js +20 -19
- package/dist-lib/lib/core/local/index.d.ts +70 -45
- package/dist-lib/lib/core/local/index.js +157 -126
- package/dist-lib/lib/core/membership.d.ts +15 -2
- package/dist-lib/lib/core/membership.js +95 -20
- package/dist-lib/lib/core/mesh-seed-handoff.d.ts +12 -4
- package/dist-lib/lib/core/mesh-seed-handoff.js +23 -5
- package/dist-lib/lib/core/mesh.d.ts +57 -30
- package/dist-lib/lib/core/mesh.js +232 -78
- package/dist-lib/lib/core/migrations/agent-catalog.js +3 -2
- package/dist-lib/lib/core/migrations/agent-indexes.js +3 -3
- package/dist-lib/lib/core/migrations/device-indexes.d.ts +2 -0
- package/dist-lib/lib/core/migrations/device-indexes.js +7 -0
- package/dist-lib/lib/core/migrations/file-index.js +7 -4
- package/dist-lib/lib/core/migrations/index.d.ts +4 -3
- package/dist-lib/lib/core/migrations/index.js +3 -1
- package/dist-lib/lib/core/migrations/membership.js +9 -4
- package/dist-lib/lib/core/migrations/seal.js +3 -2
- package/dist-lib/lib/core/min-version.js +4 -2
- package/dist-lib/lib/core/next-frame.d.ts +5 -4
- package/dist-lib/lib/core/next-frame.js +6 -3
- package/dist-lib/lib/core/notification.d.ts +5 -1
- package/dist-lib/lib/core/notification.js +89 -77
- package/dist-lib/lib/core/ota-config.js +2 -1
- package/dist-lib/lib/core/pdf/rasterize.d.ts +18 -0
- package/dist-lib/lib/core/pdf/rasterize.js +57 -0
- package/dist-lib/lib/core/prompt-history.js +4 -2
- package/dist-lib/lib/core/range.d.ts +4 -4
- package/dist-lib/lib/core/range.js +12 -6
- package/dist-lib/lib/core/rank.d.ts +5 -4
- package/dist-lib/lib/core/rank.js +2 -1
- package/dist-lib/lib/core/send.d.ts +8 -5
- package/dist-lib/lib/core/send.js +9 -3
- package/dist-lib/lib/core/skill-overlay-receiver.js +7 -4
- package/dist-lib/lib/core/skill-secrets.js +16 -9
- package/dist-lib/lib/core/sync/chunks.js +2 -1
- package/dist-lib/lib/core/sync/devices.js +3 -1
- package/dist-lib/lib/core/sync/files.d.ts +2 -4
- package/dist-lib/lib/core/sync/files.js +28 -20
- package/dist-lib/lib/core/sync/index.d.ts +2 -5
- package/dist-lib/lib/core/sync/index.js +33 -17
- package/dist-lib/lib/core/sync-status.js +10 -7
- package/dist-lib/lib/core/system-info.js +4 -2
- package/dist-lib/lib/core/tool-activity.d.ts +4 -3
- package/dist-lib/lib/core/tool-activity.js +1 -1
- package/dist-lib/lib/core/tool-configs.js +12 -7
- package/dist-lib/lib/core.d.ts +107 -45
- package/dist-lib/lib/core.js +1765 -595
- package/dist-lib/lib/credential-pusher.d.ts +12 -17
- package/dist-lib/lib/credential-pusher.js +61 -42
- package/dist-lib/lib/custom-model-pusher.d.ts +7 -3
- package/dist-lib/lib/custom-model-pusher.js +15 -7
- package/dist-lib/lib/custom-model-task.d.ts +1 -0
- package/dist-lib/lib/custom-model-task.js +12 -0
- package/dist-lib/lib/deadline.js +4 -2
- package/dist-lib/lib/diagnostics.d.ts +1 -5
- package/dist-lib/lib/frame-readable.d.ts +3 -0
- package/dist-lib/lib/frame-readable.js +3 -0
- package/dist-lib/lib/fs-drive-bridge.js +24 -14
- package/dist-lib/lib/fs-grants.js +13 -8
- package/dist-lib/lib/guards.d.ts +3 -0
- package/dist-lib/lib/guards.js +9 -0
- package/dist-lib/lib/inference-calls.d.ts +28 -23
- package/dist-lib/lib/inference-calls.js +25 -13
- package/dist-lib/lib/integrations/mcp-providers.d.ts +2 -2
- package/dist-lib/lib/integrations/setup-routes.d.ts +2 -2
- package/dist-lib/lib/knowledge-search.d.ts +6 -5
- package/dist-lib/lib/knowledge-search.js +26 -18
- package/dist-lib/lib/kv-cache-reclaim.js +4 -2
- package/dist-lib/lib/kv-cache.js +8 -4
- package/dist-lib/lib/legacy-core-domain.d.ts +42 -42
- package/dist-lib/lib/log-buffer.js +2 -1
- package/dist-lib/lib/log.js +25 -15
- package/dist-lib/lib/mesh-scoped-engine.js +14 -4
- package/dist-lib/lib/model-catalog-revision.js +6 -3
- package/dist-lib/lib/model-clamp.js +6 -3
- package/dist-lib/lib/model-context.d.ts +8 -3
- package/dist-lib/lib/model-context.js +13 -5
- package/dist-lib/lib/model-download-status.js +4 -2
- package/dist-lib/lib/model-download.d.ts +12 -4
- package/dist-lib/lib/model-download.js +200 -103
- package/dist-lib/lib/model-idle-pusher.d.ts +10 -0
- package/dist-lib/lib/model-idle-pusher.js +41 -0
- package/dist-lib/lib/oauth/browser-connect.d.ts +10 -8
- package/dist-lib/lib/oauth/browser-connect.js +33 -20
- package/dist-lib/lib/oauth/client.d.ts +2 -2
- package/dist-lib/lib/oauth/flow-core.js +23 -9
- package/dist-lib/lib/oauth/flow.d.ts +1 -3
- package/dist-lib/lib/oauth/flow.js +9 -5
- package/dist-lib/lib/oauth/keys.d.ts +4 -4
- package/dist-lib/lib/oauth/keys.js +18 -12
- package/dist-lib/lib/oauth/loopback.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.js +147 -107
- package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.stub.js +1 -1
- package/dist-lib/lib/oauth/pkce.d.ts +4 -2
- package/dist-lib/lib/oauth/pkce.js +10 -0
- package/dist-lib/lib/oauth/providers.js +5 -5
- package/dist-lib/lib/oauth/redirect-types.d.ts +12 -7
- package/dist-lib/lib/oauth/register.js +3 -2
- package/dist-lib/lib/oauth/registry.d.ts +2 -2
- package/dist-lib/lib/oauth/registry.js +2 -1
- package/dist-lib/lib/oauth/resolve.d.ts +30 -10
- package/dist-lib/lib/oauth/resolve.js +12 -6
- package/dist-lib/lib/oauth/token-exchange-core.d.ts +12 -4
- package/dist-lib/lib/oauth/token-exchange-core.js +1 -1
- package/dist-lib/lib/oauth/types.d.ts +12 -12
- package/dist-lib/lib/oauth.d.ts +4 -5
- package/dist-lib/lib/oauth.js +2 -3
- package/dist-lib/lib/reconnecting-watch.d.ts +1 -1
- package/dist-lib/lib/reconnecting-watch.js +6 -6
- package/dist-lib/lib/retry-budget.js +6 -3
- package/dist-lib/lib/run-notices.d.ts +2 -0
- package/dist-lib/lib/run-notices.js +7 -3
- package/dist-lib/lib/run-transcript.d.ts +2 -4
- package/dist-lib/lib/run-transcript.js +4 -2
- package/dist-lib/lib/skill-readiness.d.ts +1 -0
- package/dist-lib/lib/skill-readiness.js +17 -2
- package/dist-lib/lib/skill-types.d.ts +16 -16
- package/dist-lib/lib/suspend-lifecycle.d.ts +4 -4
- package/dist-lib/lib/suspend-lifecycle.js +10 -5
- package/dist-lib/lib/task.d.ts +5 -1
- package/dist-lib/lib/task.js +29 -12
- package/dist-lib/lib/unref.d.ts +3 -2
- package/dist-lib/lib/unref.js +2 -1
- package/dist-lib/lib/wav-duration.js +10 -5
- package/dist-lib/lib/write-queue.d.ts +5 -4
- package/dist-lib/lib/write-queue.js +2 -1
- package/dist-lib/schema/build.js +16 -8
- package/dist-lib/schema/config.d.ts +3 -4
- package/dist-lib/schema/config.js +1 -1
- package/dist-lib/schema/content.d.ts +18 -2
- package/dist-lib/schema/content.js +4 -1
- package/dist-lib/schema/engine.d.ts +3 -2
- package/dist-lib/schema/engine.js +192 -12
- package/dist-lib/schema/field-order.js +22 -11
- package/dist-lib/schema/indexes.d.ts +22 -0
- package/dist-lib/schema/{helpers.js → indexes.js} +19 -57
- package/dist-lib/schema/local.d.ts +3 -2
- package/dist-lib/schema/local.js +9 -3
- package/dist-lib/schema/media-kind.d.ts +8 -0
- package/dist-lib/schema/media-kind.js +52 -0
- package/dist-lib/schema/qvac.d.ts +12 -9
- package/dist-lib/schema/qvac.js +132 -7
- package/dist-lib/spec/bind.js +21 -0
- package/dist-lib/spec/calls.js +7 -0
- package/dist-lib/spec/capabilities.d.ts +18 -4
- package/dist-lib/spec/config/hyperconf/index.js +1 -1
- package/dist-lib/spec/hrpc/hrpc.json +93 -2
- package/dist-lib/spec/hrpc/index.js +89 -5
- package/dist-lib/spec/hrpc/messages.js +1568 -941
- package/dist-lib/spec/hyperschema/index.js +1568 -941
- package/dist-lib/spec/hyperschema/schema.json +531 -1
- package/dist-lib/spec/hyperschema/types.d.ts +145 -1
- package/dist-lib/spec/local/hyperdb/index.js +1 -1
- package/dist-lib/spec/local/hyperdb/messages.js +92 -20
- package/dist-lib/spec/local/hyperschema/index.js +47 -11
- package/dist-lib/spec/local/hyperschema/schema.json +32 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +7 -1
- package/dist-lib/spec/mesh/hyperdb/db.json +131 -3
- package/dist-lib/spec/mesh/hyperdb/index.js +548 -5
- package/dist-lib/spec/mesh/hyperdb/messages.js +2444 -893
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +37 -1
- package/dist-lib/spec/mesh/hyperdispatch/index.js +104 -2
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +1035 -11
- package/dist-lib/spec/mesh/hyperschema/index.js +1035 -11
- package/dist-lib/spec/mesh/hyperschema/schema.json +553 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +143 -1
- package/package.json +11 -5
- package/tui/app.mjs +2624 -986
- package/tui/boot.mjs +17 -46
- package/tui/index.mjs +10 -5
- package/tui/lib/boot-timing.mjs +8 -8
- package/tui/lib/busy-words.mjs +21 -22
- package/tui/lib/export.mjs +100 -32
- package/tui/lib/knowledge-command.mjs +64 -19
- package/tui/lib/knowledge-import.mjs +52 -18
- package/tui/lib/render.mjs +65 -33
- package/tui/lib/save-file.mjs +30 -13
- package/tui/lib/select.mjs +23 -5
- package/tui/lib/selection.mjs +6 -4
- package/tui/lib/setup.mjs +11 -19
- package/tui/lib/sidebar.mjs +23 -13
- package/tui/lib/splash.mjs +6 -7
- package/tui/lib/upload-frames.mjs +1 -2
- package/tui/lib/usage.mjs +13 -9
- package/tui/lib/wrap.mjs +35 -6
- package/tui/main.mjs +54 -78
- package/worker/assistant-sidecar.mjs +5 -10
- package/worker/stow-entry.mjs +7 -4
- package/dist-lib/lib/custom-model-source.d.ts +0 -15
- package/dist-lib/lib/custom-model-source.js +0 -46
- package/dist-lib/lib/oauth/common.d.ts +0 -38
- package/dist-lib/lib/oauth/common.js +0 -34
- package/dist-lib/schema/helpers.d.ts +0 -32
|
@@ -7,13 +7,13 @@ const USAGE =
|
|
|
7
7
|
|
|
8
8
|
export async function knowledgeCommand(engine, { chatId, meshId, saveDir }, input) {
|
|
9
9
|
try {
|
|
10
|
-
return { type: 'notice', text: await execute(engine, { chatId, meshId
|
|
10
|
+
return { type: 'notice', text: await execute(engine, { chatId, meshId, saveDir }, input) }
|
|
11
11
|
} catch (error) {
|
|
12
12
|
return { type: 'run.error', error }
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async function execute(engine,
|
|
16
|
+
async function execute(engine, { saveDir, ...scope }, input) {
|
|
17
17
|
const { chatId, meshId } = scope
|
|
18
18
|
const { action, argument } = parseInput(input)
|
|
19
19
|
if ((!action || action === 'list') && !argument) {
|
|
@@ -23,21 +23,31 @@ async function execute(engine, scope, saveDir, input) {
|
|
|
23
23
|
])
|
|
24
24
|
return formatKnowledge(sortKnowledge(knowledge ?? []), statuses ?? [])
|
|
25
25
|
}
|
|
26
|
+
|
|
26
27
|
if (action === 'add' || action === 'add-dir') {
|
|
27
|
-
if (!argument)
|
|
28
|
+
if (!argument) {
|
|
29
|
+
return USAGE
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
if (action === 'add') {
|
|
29
33
|
const added = await importKnowledgeFile(engine, scope, argument)
|
|
30
34
|
return `uploaded ${singleLine(added.fileName)} (${added.byteLength}B) · run /knowledge to track indexing`
|
|
31
35
|
}
|
|
36
|
+
|
|
32
37
|
return formatDirectoryImport(await importKnowledgeDirectory(engine, scope, argument))
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
const [selector, ...extra] = argument.split(/\s+/)
|
|
36
|
-
if ((action !== 'download' && action !== 'remove') || !selector || extra.length)
|
|
41
|
+
if ((action !== 'download' && action !== 'remove') || !selector || extra.length) {
|
|
42
|
+
return USAGE
|
|
43
|
+
}
|
|
37
44
|
|
|
38
45
|
const { knowledge } = await engine.listKnowledge({ chatId, meshId })
|
|
39
46
|
const selected = resolveKnowledge(sortKnowledge(knowledge ?? []), selector)
|
|
40
|
-
if (selected.error)
|
|
47
|
+
if (selected.error) {
|
|
48
|
+
return selected.error
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
const row = selected.knowledge
|
|
42
52
|
if (action === 'remove') {
|
|
43
53
|
await engine.removeKnowledge({ knowledgeId: row.id, at: Date.now(), meshId })
|
|
@@ -45,18 +55,23 @@ async function execute(engine, scope, saveDir, input) {
|
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
const saved = await saveUniqueStream(
|
|
48
|
-
|
|
49
|
-
row.fileName
|
|
50
|
-
frameData(engine.downloadKnowledge({ blobId: row.blobId, meshId }))
|
|
58
|
+
frameData(engine.downloadKnowledge({ blobId: row.blobId, meshId })),
|
|
59
|
+
{ dir: saveDir, fileName: row.fileName }
|
|
51
60
|
)
|
|
52
|
-
if (saved)
|
|
61
|
+
if (saved) {
|
|
62
|
+
return `saved ${singleLine(row.fileName)} (${saved.bytesWritten}B) to ${saved.file}`
|
|
63
|
+
}
|
|
64
|
+
|
|
53
65
|
return `not saved: 100 files named ${singleLine(row.fileName)} already exist in ${saveDir}`
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
function parseInput(input) {
|
|
57
69
|
const value = input.trim()
|
|
58
70
|
const separator = value.search(/\s/)
|
|
59
|
-
if (separator === -1)
|
|
71
|
+
if (separator === -1) {
|
|
72
|
+
return { action: value, argument: '' }
|
|
73
|
+
}
|
|
74
|
+
|
|
60
75
|
return {
|
|
61
76
|
action: value.slice(0, separator),
|
|
62
77
|
argument: value.slice(separator).trimStart()
|
|
@@ -67,21 +82,28 @@ function formatDirectoryImport(result) {
|
|
|
67
82
|
if (!result.added.length && !result.failed.length) {
|
|
68
83
|
return `no supported knowledge files in ${result.directory}`
|
|
69
84
|
}
|
|
85
|
+
|
|
70
86
|
const lines = [
|
|
71
87
|
`uploaded ${result.added.length} knowledge file${result.added.length === 1 ? '' : 's'}`
|
|
72
88
|
]
|
|
73
89
|
for (const row of result.added) {
|
|
74
90
|
lines.push(` + ${singleLine(row.fileName)} (${row.byteLength}B)`)
|
|
75
91
|
}
|
|
92
|
+
|
|
76
93
|
for (const row of result.failed) {
|
|
77
94
|
lines.push(` ! ${singleLine(row.fileName)} · ${singleLine(row.error)}`)
|
|
78
95
|
}
|
|
96
|
+
|
|
79
97
|
if (result.skipped.length) {
|
|
80
98
|
lines.push(
|
|
81
99
|
` - skipped ${result.skipped.length} unsupported ${result.skipped.length === 1 ? 'entry' : 'entries'}`
|
|
82
100
|
)
|
|
83
101
|
}
|
|
84
|
-
|
|
102
|
+
|
|
103
|
+
if (result.added.length) {
|
|
104
|
+
lines.push('run /knowledge to track indexing')
|
|
105
|
+
}
|
|
106
|
+
|
|
85
107
|
return lines.join('\n')
|
|
86
108
|
}
|
|
87
109
|
|
|
@@ -93,6 +115,7 @@ function formatKnowledge(knowledge, statuses) {
|
|
|
93
115
|
rows.push(row)
|
|
94
116
|
byKnowledge.set(row.knowledgeId, rows)
|
|
95
117
|
}
|
|
118
|
+
|
|
96
119
|
return knowledge
|
|
97
120
|
.map((row, index) => formatKnowledgeRow(row, index, byKnowledge.get(row.id) ?? []))
|
|
98
121
|
.join('\n')
|
|
@@ -102,8 +125,14 @@ function formatKnowledgeRow(knowledge, index, statuses) {
|
|
|
102
125
|
const name = singleLine(knowledge.fileName) || '(unnamed)'
|
|
103
126
|
const lines = [`${index + 1}. ${name} (${knowledge.byteLength}B) · ${knowledge.id.slice(0, 8)}`]
|
|
104
127
|
const sorted = [...statuses].sort((a, b) => a.id.localeCompare(b.id))
|
|
105
|
-
if (!sorted.length)
|
|
106
|
-
|
|
128
|
+
if (!sorted.length) {
|
|
129
|
+
lines.push(' - not indexed')
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
for (const row of sorted) {
|
|
133
|
+
lines.push(` - ${formatStatus(row)}`)
|
|
134
|
+
}
|
|
135
|
+
|
|
107
136
|
return lines.join('\n')
|
|
108
137
|
}
|
|
109
138
|
|
|
@@ -111,9 +140,13 @@ function formatStatus(row) {
|
|
|
111
140
|
const status = row.status === 'indexing' && !row.claimLive ? 'expired' : row.status
|
|
112
141
|
let detail = `${status} · artifact ${row.id.slice(0, 8)}`
|
|
113
142
|
if (row.status === 'indexing' && row.claimLive) {
|
|
114
|
-
detail += ` · claimed by ${b4a.
|
|
143
|
+
detail += ` · claimed by ${b4a.toHex(row.claimedBy).slice(0, 8)}`
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (row.status === 'failed' && row.error) {
|
|
147
|
+
detail += ` · ${singleLine(row.error)}`
|
|
115
148
|
}
|
|
116
|
-
|
|
149
|
+
|
|
117
150
|
return detail
|
|
118
151
|
}
|
|
119
152
|
|
|
@@ -123,14 +156,24 @@ function sortKnowledge(rows) {
|
|
|
123
156
|
|
|
124
157
|
function resolveKnowledge(rows, selector) {
|
|
125
158
|
const exact = rows.find((row) => row.id === selector)
|
|
126
|
-
if (exact)
|
|
159
|
+
if (exact) {
|
|
160
|
+
return { knowledge: exact }
|
|
161
|
+
}
|
|
162
|
+
|
|
127
163
|
if (/^\d+$/.test(selector)) {
|
|
128
164
|
const index = Number(selector) - 1
|
|
129
165
|
return rows[index] ? { knowledge: rows[index] } : { error: `no knowledge #${selector}` }
|
|
130
166
|
}
|
|
167
|
+
|
|
131
168
|
const matches = rows.filter((row) => row.id.startsWith(selector))
|
|
132
|
-
if (matches.length === 1)
|
|
133
|
-
|
|
169
|
+
if (matches.length === 1) {
|
|
170
|
+
return { knowledge: matches[0] }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (matches.length > 1) {
|
|
174
|
+
return { error: `ambiguous knowledge id: ${selector}` }
|
|
175
|
+
}
|
|
176
|
+
|
|
134
177
|
return { error: `no knowledge matching: ${selector}` }
|
|
135
178
|
}
|
|
136
179
|
|
|
@@ -140,6 +183,8 @@ function singleLine(value) {
|
|
|
140
183
|
|
|
141
184
|
async function* frameData(frames) {
|
|
142
185
|
for await (const frame of frames) {
|
|
143
|
-
if (frame.data)
|
|
186
|
+
if (frame.data) {
|
|
187
|
+
yield frame.data
|
|
188
|
+
}
|
|
144
189
|
}
|
|
145
190
|
}
|
|
@@ -4,6 +4,7 @@ import path from 'path'
|
|
|
4
4
|
import { fileURLToPath } from 'url'
|
|
5
5
|
import { RAG_ACCEPT_EXTENSIONS } from 'rag-extract'
|
|
6
6
|
import { UPLOAD_FRAME_BYTES, writeFrame } from './upload-frames.mjs'
|
|
7
|
+
import { errorMessage } from '../../dist-lib/lib/guards.js'
|
|
7
8
|
const ACCEPTED = new Set(RAG_ACCEPT_EXTENSIONS)
|
|
8
9
|
const MIME_TYPES = new Map([
|
|
9
10
|
['.pdf', 'application/pdf'],
|
|
@@ -31,15 +32,23 @@ const MIME_TYPES = new Map([
|
|
|
31
32
|
export async function importKnowledgeFile(engine, scope, inputPath) {
|
|
32
33
|
const file = resolvePath(inputPath)
|
|
33
34
|
const stat = await fs.promises.stat(file)
|
|
34
|
-
if (!stat.isFile())
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
if (!stat.isFile()) {
|
|
36
|
+
throw new Error(`not a file: ${file}`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!supported(file)) {
|
|
40
|
+
throw new Error(`unsupported knowledge file: ${path.basename(file)}`)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return upload(engine, file, { ...scope, byteLength: stat.size })
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
export async function importKnowledgeDirectory(engine, scope, inputPath) {
|
|
40
47
|
const directory = resolvePath(inputPath)
|
|
41
48
|
const stat = await fs.promises.stat(directory)
|
|
42
|
-
if (!stat.isDirectory())
|
|
49
|
+
if (!stat.isDirectory()) {
|
|
50
|
+
throw new Error(`not a directory: ${directory}`)
|
|
51
|
+
}
|
|
43
52
|
|
|
44
53
|
const added = []
|
|
45
54
|
const failed = []
|
|
@@ -54,24 +63,36 @@ export async function importKnowledgeDirectory(engine, scope, inputPath) {
|
|
|
54
63
|
failed.push({ fileName: name, error: errorMessage(error) })
|
|
55
64
|
continue
|
|
56
65
|
}
|
|
66
|
+
|
|
57
67
|
if (!fileStat.isFile() || !supported(file)) {
|
|
58
68
|
skipped.push(name)
|
|
59
69
|
continue
|
|
60
70
|
}
|
|
71
|
+
|
|
61
72
|
try {
|
|
62
|
-
added.push(await upload(engine,
|
|
73
|
+
added.push(await upload(engine, file, { ...scope, byteLength: fileStat.size }))
|
|
63
74
|
} catch (error) {
|
|
64
75
|
failed.push({ fileName: name, error: errorMessage(error) })
|
|
65
76
|
}
|
|
66
77
|
}
|
|
78
|
+
|
|
67
79
|
return { directory, added, failed, skipped }
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
function resolvePath(input) {
|
|
71
83
|
const value = input.trim()
|
|
72
|
-
if (value.startsWith('file://'))
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
if (value.startsWith('file://')) {
|
|
85
|
+
return fileURLToPath(value)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (value === '~') {
|
|
89
|
+
return os.homedir()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (value.startsWith('~/')) {
|
|
93
|
+
return path.join(os.homedir(), value.slice(2))
|
|
94
|
+
}
|
|
95
|
+
|
|
75
96
|
return path.resolve(value)
|
|
76
97
|
}
|
|
77
98
|
|
|
@@ -79,7 +100,7 @@ function supported(file) {
|
|
|
79
100
|
return ACCEPTED.has(path.extname(file).toLowerCase())
|
|
80
101
|
}
|
|
81
102
|
|
|
82
|
-
async function upload(engine, { chatId, meshId
|
|
103
|
+
async function upload(engine, file, { chatId, meshId, byteLength }) {
|
|
83
104
|
const fileName = path.basename(file)
|
|
84
105
|
const extension = path.extname(file).toLowerCase()
|
|
85
106
|
const stream = engine.uploadKnowledge()
|
|
@@ -87,6 +108,7 @@ async function upload(engine, { chatId, meshId }, file, byteLength) {
|
|
|
87
108
|
const response = readFinal(stream).catch((error) => {
|
|
88
109
|
responseError = error
|
|
89
110
|
safeDestroy(stream)
|
|
111
|
+
|
|
90
112
|
return null
|
|
91
113
|
})
|
|
92
114
|
const source = fs.createReadStream(file, { highWaterMark: UPLOAD_FRAME_BYTES })
|
|
@@ -100,27 +122,43 @@ async function upload(engine, { chatId, meshId }, file, byteLength) {
|
|
|
100
122
|
mimeType: MIME_TYPES.get(extension) ?? 'application/octet-stream',
|
|
101
123
|
totalBytes: byteLength
|
|
102
124
|
})
|
|
103
|
-
if (!metadataWritten)
|
|
125
|
+
if (!metadataWritten) {
|
|
126
|
+
throw responseError ?? new Error('knowledge upload closed while writing')
|
|
127
|
+
}
|
|
128
|
+
|
|
104
129
|
for await (const data of source) {
|
|
105
130
|
if (responseError) throw responseError
|
|
106
131
|
const dataWritten = await writeFrame(stream, { data })
|
|
107
|
-
if (!dataWritten)
|
|
132
|
+
if (!dataWritten) {
|
|
133
|
+
throw responseError ?? new Error('knowledge upload closed while writing')
|
|
134
|
+
}
|
|
108
135
|
}
|
|
136
|
+
|
|
109
137
|
stream.end()
|
|
110
138
|
const final = await response
|
|
111
|
-
if (responseError)
|
|
112
|
-
|
|
139
|
+
if (responseError) {
|
|
140
|
+
throw responseError
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!final?.knowledge) {
|
|
144
|
+
throw new Error('knowledge upload ended without a knowledge row')
|
|
145
|
+
}
|
|
146
|
+
|
|
113
147
|
return { fileName, byteLength, knowledge: final.knowledge }
|
|
114
148
|
} catch (error) {
|
|
115
149
|
source.destroy()
|
|
116
150
|
safeDestroy(stream)
|
|
151
|
+
|
|
117
152
|
throw error
|
|
118
153
|
}
|
|
119
154
|
}
|
|
120
155
|
|
|
121
156
|
async function readFinal(stream) {
|
|
122
157
|
let final = null
|
|
123
|
-
for await (const frame of stream)
|
|
158
|
+
for await (const frame of stream) {
|
|
159
|
+
final = frame
|
|
160
|
+
}
|
|
161
|
+
|
|
124
162
|
return final
|
|
125
163
|
}
|
|
126
164
|
|
|
@@ -131,7 +169,3 @@ function safeDestroy(stream) {
|
|
|
131
169
|
// Cleanup must not replace the file or transport error.
|
|
132
170
|
}
|
|
133
171
|
}
|
|
134
|
-
|
|
135
|
-
function errorMessage(error) {
|
|
136
|
-
return error instanceof Error ? error.message : String(error)
|
|
137
|
-
}
|
package/tui/lib/render.mjs
CHANGED
|
@@ -9,15 +9,22 @@ const PAYLOAD_FIELDS = {
|
|
|
9
9
|
attachment: 'attachment'
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
// its answer, so the marker goes above that message: that is where the folded history ends.
|
|
14
|
-
// An upload is appended before the message it belongs to, so the marker goes above it too.
|
|
12
|
+
// a fold lands after its triggering message (and that message's upload), so the marker goes above
|
|
15
13
|
function foldMarkerIndex(turns) {
|
|
16
14
|
let at = turns.length
|
|
17
|
-
while (at > 0 && turns[at - 1].from === 'agent' && turns[at - 1].segments.length === 0)
|
|
18
|
-
|
|
15
|
+
while (at > 0 && turns[at - 1].from === 'agent' && turns[at - 1].segments.length === 0) {
|
|
16
|
+
at--
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (at === turns.length || at === 0 || turns[at - 1].from !== 'user') {
|
|
20
|
+
return turns.length
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
at--
|
|
20
|
-
while (at > 0 && turns[at - 1].from === 'user' && isUpload(turns[at - 1]))
|
|
24
|
+
while (at > 0 && turns[at - 1].from === 'user' && isUpload(turns[at - 1])) {
|
|
25
|
+
at--
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
return at
|
|
22
29
|
}
|
|
23
30
|
|
|
@@ -29,8 +36,7 @@ export function turnsFromChunks(chunks) {
|
|
|
29
36
|
const turns = []
|
|
30
37
|
const byRun = new Map()
|
|
31
38
|
for (const chunk of chunks) {
|
|
32
|
-
//
|
|
33
|
-
// human side per device — purely presentational, nothing schema-enforced.
|
|
39
|
+
// purely presentational: lets a renderer label the human side per device
|
|
34
40
|
if (chunk.type === 'user-message') {
|
|
35
41
|
turns.push({
|
|
36
42
|
from: 'user',
|
|
@@ -39,9 +45,8 @@ export function turnsFromChunks(chunks) {
|
|
|
39
45
|
})
|
|
40
46
|
continue
|
|
41
47
|
}
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
// into that run's turn below like any other segment.
|
|
48
|
+
|
|
49
|
+
// an attachment a tool produced mid-run has a runId and groups into that run's turn below
|
|
45
50
|
if (chunk.type === 'attachment' && !chunk.runId) {
|
|
46
51
|
turns.push({
|
|
47
52
|
from: 'user',
|
|
@@ -50,49 +55,56 @@ export function turnsFromChunks(chunks) {
|
|
|
50
55
|
})
|
|
51
56
|
continue
|
|
52
57
|
}
|
|
53
|
-
|
|
54
|
-
//
|
|
58
|
+
|
|
59
|
+
// grouped by its absent runId a fold would be an agent turn that never ends, holding the busy gate
|
|
55
60
|
if (chunk.type === 'compaction') {
|
|
56
61
|
turns.splice(foldMarkerIndex(turns), 0, { from: 'compaction', segments: [] })
|
|
57
62
|
continue
|
|
58
63
|
}
|
|
64
|
+
|
|
59
65
|
let turn = byRun.get(chunk.runId)
|
|
60
66
|
if (!turn) {
|
|
61
67
|
turn = { from: 'agent', runId: chunk.runId, status: null, segments: [] }
|
|
62
68
|
byRun.set(chunk.runId, turn)
|
|
63
69
|
turns.push(turn)
|
|
64
70
|
}
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
|
|
72
|
+
// the ask materializes the turn so every peer sees a run in flight before the host even starts
|
|
73
|
+
if (chunk.type === 'run-request') {
|
|
74
|
+
continue
|
|
75
|
+
}
|
|
76
|
+
|
|
69
77
|
if (chunk.type === 'run-status') {
|
|
70
78
|
turn.status = chunk.runStatus.state
|
|
71
79
|
turn.statusReason = chunk.runStatus.reason
|
|
72
80
|
turn.statusDetail = chunk.runStatus
|
|
73
|
-
//
|
|
74
|
-
// provider), so progress can be labelled with WHERE it's happening.
|
|
81
|
+
// stamped by the provider, so progress can be labelled with where it is happening
|
|
75
82
|
turn.statusDeviceId = chunk.originDeviceId && b4a.toHex(chunk.originDeviceId)
|
|
76
83
|
continue
|
|
77
84
|
}
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
// id so the UI can resolveApproval() it directly.
|
|
85
|
+
|
|
86
|
+
// the chunk is the approval state, so it is never coalesced and carries its own id to resolve
|
|
81
87
|
if (chunk.type === 'approval-request') {
|
|
82
88
|
turn.segments.push({ type: 'approval-request', id: chunk.id, detail: chunk.approvalRequest })
|
|
83
89
|
continue
|
|
84
90
|
}
|
|
91
|
+
|
|
85
92
|
// recovery appends a fresh sources chunk on the same run - the newest wins (v1 rule)
|
|
86
93
|
if (chunk.type === 'sources') {
|
|
87
94
|
const stale = turn.segments.findIndex((segment) => segment.type === 'sources')
|
|
88
|
-
if (stale >= 0)
|
|
95
|
+
if (stale >= 0) {
|
|
96
|
+
turn.segments.splice(stale, 1)
|
|
97
|
+
}
|
|
98
|
+
|
|
89
99
|
turn.segments.push({ type: 'sources', detail: chunk.sources })
|
|
90
100
|
continue
|
|
91
101
|
}
|
|
102
|
+
|
|
92
103
|
const detail = chunk[PAYLOAD_FIELDS[chunk.type]] ?? {}
|
|
93
104
|
const last = turn.segments[turn.segments.length - 1]
|
|
94
|
-
if (last && last.type === chunk.type)
|
|
95
|
-
|
|
105
|
+
if (last && last.type === chunk.type) {
|
|
106
|
+
last.text += detail.text ?? ''
|
|
107
|
+
} else {
|
|
96
108
|
turn.segments.push({
|
|
97
109
|
type: chunk.type,
|
|
98
110
|
text: detail.text ?? '',
|
|
@@ -100,26 +112,31 @@ export function turnsFromChunks(chunks) {
|
|
|
100
112
|
})
|
|
101
113
|
}
|
|
102
114
|
}
|
|
115
|
+
|
|
103
116
|
return turns
|
|
104
117
|
}
|
|
105
118
|
|
|
106
|
-
//
|
|
107
|
-
// there's at most one live tool call awaiting approval at a time (the
|
|
108
|
-
// harness's own loop blocks on it before doing anything else).
|
|
119
|
+
// the harness's loop blocks on an approval, so at most one is live at a time
|
|
109
120
|
export function findPendingApproval(turns) {
|
|
110
121
|
for (let i = turns.length - 1; i >= 0; i--) {
|
|
111
122
|
for (const segment of turns[i].segments) {
|
|
112
|
-
if (segment.type === 'approval-request' && segment.detail.status === 'pending')
|
|
123
|
+
if (segment.type === 'approval-request' && segment.detail.status === 'pending') {
|
|
124
|
+
return segment
|
|
125
|
+
}
|
|
113
126
|
}
|
|
114
127
|
}
|
|
128
|
+
|
|
115
129
|
return null
|
|
116
130
|
}
|
|
117
131
|
|
|
118
132
|
export function runningAgentTurn(turns) {
|
|
119
133
|
for (let i = turns.length - 1; i >= 0; i--) {
|
|
120
134
|
const turn = turns[i]
|
|
121
|
-
if (turn.from === 'agent' && turn.status === 'executing')
|
|
135
|
+
if (turn.from === 'agent' && turn.status === 'executing') {
|
|
136
|
+
return turn
|
|
137
|
+
}
|
|
122
138
|
}
|
|
139
|
+
|
|
123
140
|
return null
|
|
124
141
|
}
|
|
125
142
|
|
|
@@ -134,31 +151,46 @@ export function runInFlight(turns) {
|
|
|
134
151
|
if (turns[i].from !== 'agent') continue
|
|
135
152
|
return !TERMINAL_RUN_STATES.has(turns[i].status)
|
|
136
153
|
}
|
|
154
|
+
|
|
137
155
|
return false
|
|
138
156
|
}
|
|
139
157
|
|
|
140
158
|
export function busyStatus(modelState, runTurn, elapsed) {
|
|
141
|
-
if (modelState?.status === 'loading')
|
|
159
|
+
if (modelState?.status === 'loading') {
|
|
160
|
+
return { text: `loading ${modelState.model}…`, on: 'local' }
|
|
161
|
+
}
|
|
162
|
+
|
|
142
163
|
if (modelState?.status === 'downloading') {
|
|
143
164
|
return {
|
|
144
165
|
text: `downloading ${modelState.model}: ${Math.round(modelState.percentage ?? 0)}%`,
|
|
145
166
|
on: 'local'
|
|
146
167
|
}
|
|
147
168
|
}
|
|
169
|
+
|
|
148
170
|
if (modelState?.status === 'unloading') {
|
|
149
171
|
return { text: `unloading ${modelState.model}…`, on: 'local' }
|
|
150
172
|
}
|
|
173
|
+
|
|
151
174
|
const progress = runTurn?.statusDetail?.progress
|
|
152
|
-
if (progress?.phase === 'loading')
|
|
175
|
+
if (progress?.phase === 'loading') {
|
|
176
|
+
return { text: `loading ${progress.model}…`, on: 'host' }
|
|
177
|
+
}
|
|
178
|
+
|
|
153
179
|
if (progress?.phase === 'downloading') {
|
|
154
180
|
return { text: `downloading ${progress.model}: ${progress.percentage ?? 0}%`, on: 'host' }
|
|
155
181
|
}
|
|
182
|
+
|
|
156
183
|
if (progress?.phase === 'generating') {
|
|
157
184
|
return { text: `generating image: ${progress.percentage ?? 0}%`, on: 'host' }
|
|
158
185
|
}
|
|
186
|
+
|
|
159
187
|
if (progress?.phase === 'queued') {
|
|
160
188
|
return { text: `queued - agent busy in ${progress.busyChatId}`, on: 'host' }
|
|
161
189
|
}
|
|
162
|
-
|
|
190
|
+
|
|
191
|
+
if (progress?.phase === 'compacting') {
|
|
192
|
+
return { text: 'compacting conversation…', on: 'host' }
|
|
193
|
+
}
|
|
194
|
+
|
|
163
195
|
return { text: busyWord(runTurn?.runId, elapsed), on: null }
|
|
164
196
|
}
|
package/tui/lib/save-file.mjs
CHANGED
|
@@ -1,45 +1,58 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import path from 'path'
|
|
3
3
|
|
|
4
|
-
export async function saveUniqueFile(
|
|
5
|
-
const saved = await saveUnique(
|
|
4
|
+
export async function saveUniqueFile(bytes, target) {
|
|
5
|
+
const saved = await saveUnique(target, (handle) => write(handle, bytes))
|
|
6
6
|
return saved?.file ?? null
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function saveUniqueStream(
|
|
10
|
-
return saveUnique(
|
|
9
|
+
export function saveUniqueStream(source, target) {
|
|
10
|
+
return saveUnique(target, async (handle) => {
|
|
11
11
|
let bytesWritten = 0
|
|
12
|
-
for await (const data of source)
|
|
12
|
+
for await (const data of source) {
|
|
13
|
+
bytesWritten += await write(handle, data)
|
|
14
|
+
}
|
|
15
|
+
|
|
13
16
|
return bytesWritten
|
|
14
17
|
})
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
async function saveUnique(
|
|
18
|
-
const tempDir = await fs.promises.mkdtemp(path.join(dir, '.qvac-download-'))
|
|
20
|
+
async function saveUnique(target, writeFile) {
|
|
21
|
+
const tempDir = await fs.promises.mkdtemp(path.join(target.dir, '.qvac-download-'))
|
|
19
22
|
const tempFile = path.join(tempDir, 'download')
|
|
20
23
|
let handle = await fs.promises.open(tempFile, 'w')
|
|
21
24
|
let file = null
|
|
22
25
|
|
|
23
26
|
try {
|
|
24
|
-
file = await claimUniqueFile(
|
|
25
|
-
if (!file)
|
|
27
|
+
file = await claimUniqueFile(target, tempFile)
|
|
28
|
+
if (!file) {
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
const bytesWritten = await writeFile(handle)
|
|
27
33
|
await handle.close()
|
|
28
34
|
handle = null
|
|
35
|
+
|
|
29
36
|
return { file, bytesWritten }
|
|
30
37
|
} catch (err) {
|
|
31
38
|
await handle.close().catch(noop)
|
|
32
39
|
handle = null
|
|
33
|
-
if (file)
|
|
40
|
+
if (file) {
|
|
41
|
+
await fs.promises.unlink(file).catch(noop)
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
throw err
|
|
35
45
|
} finally {
|
|
36
46
|
// Cleanup must not replace the download error or remove the reserved destination.
|
|
37
|
-
if (handle)
|
|
47
|
+
if (handle) {
|
|
48
|
+
await handle.close().catch(noop)
|
|
49
|
+
}
|
|
50
|
+
|
|
38
51
|
await fs.promises.rm(tempDir, { recursive: true, force: true }).catch(noop)
|
|
39
52
|
}
|
|
40
53
|
}
|
|
41
54
|
|
|
42
|
-
async function claimUniqueFile(dir, fileName, extension, source) {
|
|
55
|
+
async function claimUniqueFile({ dir, fileName, extension }, source) {
|
|
43
56
|
const sanitized = path.basename(fileName).replace(/[^a-zA-Z0-9_.-]/g, '_')
|
|
44
57
|
const safe = !sanitized || sanitized === '.' || sanitized === '..' ? 'download' : sanitized
|
|
45
58
|
const dot = safe.lastIndexOf('.')
|
|
@@ -53,9 +66,12 @@ async function claimUniqueFile(dir, fileName, extension, source) {
|
|
|
53
66
|
await fs.promises.link(source, file)
|
|
54
67
|
return file
|
|
55
68
|
} catch (err) {
|
|
56
|
-
if (err.code !== 'EEXIST')
|
|
69
|
+
if (err.code !== 'EEXIST') {
|
|
70
|
+
throw err
|
|
71
|
+
}
|
|
57
72
|
}
|
|
58
73
|
}
|
|
74
|
+
|
|
59
75
|
return null
|
|
60
76
|
}
|
|
61
77
|
|
|
@@ -65,6 +81,7 @@ async function write(handle, data) {
|
|
|
65
81
|
const result = await handle.write(offset ? data.subarray(offset) : data)
|
|
66
82
|
offset += result.bytesWritten
|
|
67
83
|
}
|
|
84
|
+
|
|
68
85
|
return data.length
|
|
69
86
|
}
|
|
70
87
|
|
package/tui/lib/select.mjs
CHANGED
|
@@ -29,18 +29,35 @@ function walk(line, start, end) {
|
|
|
29
29
|
for (const cell of cells(line)) {
|
|
30
30
|
if (cell.esc) {
|
|
31
31
|
painted += cell.esc
|
|
32
|
-
if (on && RESETS.has(cell.esc))
|
|
32
|
+
if (on && RESETS.has(cell.esc)) {
|
|
33
|
+
painted += REVERSE
|
|
34
|
+
}
|
|
35
|
+
|
|
33
36
|
continue
|
|
34
37
|
}
|
|
38
|
+
|
|
35
39
|
const inside = col >= start && col < end
|
|
36
|
-
if (inside && !on)
|
|
37
|
-
|
|
40
|
+
if (inside && !on) {
|
|
41
|
+
painted += REVERSE
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!inside && on) {
|
|
45
|
+
painted += REVERSE_OFF
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
on = inside
|
|
39
|
-
if (inside)
|
|
49
|
+
if (inside) {
|
|
50
|
+
text += cell.ch
|
|
51
|
+
}
|
|
52
|
+
|
|
40
53
|
painted += cell.ch
|
|
41
54
|
col += cell.w
|
|
42
55
|
}
|
|
43
|
-
|
|
56
|
+
|
|
57
|
+
if (on) {
|
|
58
|
+
painted += REVERSE_OFF
|
|
59
|
+
}
|
|
60
|
+
|
|
44
61
|
return { text: text.replace(/ +$/, ''), painted }
|
|
45
62
|
}
|
|
46
63
|
|
|
@@ -51,6 +68,7 @@ export function selectionText(lines, anchor, focus) {
|
|
|
51
68
|
const at = span(row, from, to)
|
|
52
69
|
rows.push(walk(lines[row], at.start, at.end).text)
|
|
53
70
|
}
|
|
71
|
+
|
|
54
72
|
return rows.join('\n').replace(/^\n+|\n+$/g, '')
|
|
55
73
|
}
|
|
56
74
|
|