@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
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { attachmentTurn, skillLoadedTurn } from '@qvac/harness/lib/capabilities/tool-turns.ts';
|
|
2
2
|
import { HISTORY_CHUNK_TYPES } from '../core/chunk.js';
|
|
3
3
|
import { isAudioAttachment } from '../core/audio-attachment.js';
|
|
4
|
-
import { isDocumentAttachment } from '../core/document-attachment.js';
|
|
4
|
+
import { isDocumentAttachment, isPdfAttachment } from '../core/document-attachment.js';
|
|
5
5
|
import { groupAttachmentsByMessage } from '../core/files/index.js';
|
|
6
6
|
import { IMAGE_MIMES } from '../core/image/normalize.js';
|
|
7
7
|
import { compactionTurn, foldCompactedChunks } from '../compaction.js';
|
|
8
|
+
import b4a from 'b4a';
|
|
9
|
+
import { isRecord } from '../guards.js';
|
|
8
10
|
export const TERMINAL_STATES = new Set(['completed', 'failed', 'canceled']);
|
|
9
11
|
export const HISTORY_TYPES = HISTORY_CHUNK_TYPES;
|
|
10
12
|
export const SKILL_TOOL = 'skill';
|
|
@@ -27,8 +29,9 @@ export function latestAttemptStarts(chunks) {
|
|
|
27
29
|
continue;
|
|
28
30
|
if (TERMINAL_STATES.has(chunk.runStatus?.state ?? ''))
|
|
29
31
|
continue;
|
|
30
|
-
if (chunk.runStatus?.progress?.phase === 'compacting')
|
|
32
|
+
if (chunk.runStatus?.progress?.phase === 'compacting') {
|
|
31
33
|
continue;
|
|
34
|
+
}
|
|
32
35
|
starts.set(chunk.runId, chunk.seq);
|
|
33
36
|
}
|
|
34
37
|
return starts;
|
|
@@ -44,25 +47,28 @@ export function couldNameSenders(chunks) {
|
|
|
44
47
|
for (const chunk of chunks) {
|
|
45
48
|
if (chunk.type !== 'user-message')
|
|
46
49
|
continue;
|
|
47
|
-
seen.add((chunk.senderMemberId ?? chunk.originDeviceId)
|
|
48
|
-
if (seen.size > 1)
|
|
50
|
+
seen.add(b4a.toHex(chunk.senderMemberId ?? chunk.originDeviceId));
|
|
51
|
+
if (seen.size > 1) {
|
|
49
52
|
return true;
|
|
53
|
+
}
|
|
50
54
|
}
|
|
51
55
|
return false;
|
|
52
56
|
}
|
|
53
57
|
export function senderNamesFrom(chunks, members, devices) {
|
|
54
|
-
if (members.length < 2)
|
|
58
|
+
if (members.length < 2) {
|
|
55
59
|
return new Map();
|
|
56
|
-
|
|
57
|
-
const
|
|
60
|
+
}
|
|
61
|
+
const byMember = new Map(members.map((member) => [b4a.toHex(member.id), member.name]));
|
|
62
|
+
const deviceMember = new Map(devices.map((device) => [b4a.toHex(device.id), device.memberId]));
|
|
58
63
|
const names = new Map();
|
|
59
64
|
for (const chunk of chunks) {
|
|
60
65
|
if (chunk.type !== 'user-message')
|
|
61
66
|
continue;
|
|
62
|
-
const memberId = chunk.senderMemberId ?? deviceMember.get(chunk.originDeviceId
|
|
63
|
-
const name = memberId ? byMember.get(
|
|
64
|
-
if (name)
|
|
67
|
+
const memberId = chunk.senderMemberId ?? deviceMember.get(b4a.toHex(chunk.originDeviceId));
|
|
68
|
+
const name = memberId ? byMember.get(b4a.toHex(memberId)) : undefined;
|
|
69
|
+
if (name) {
|
|
65
70
|
names.set(chunk.id, name);
|
|
71
|
+
}
|
|
66
72
|
}
|
|
67
73
|
return names;
|
|
68
74
|
}
|
|
@@ -80,16 +86,19 @@ export function historyFromChunks(chunks, stale = {}, senderNames = new Map()) {
|
|
|
80
86
|
const attachments = [];
|
|
81
87
|
const userMessages = [];
|
|
82
88
|
for (const chunk of source) {
|
|
83
|
-
if (chunk.type === 'attachment')
|
|
89
|
+
if (chunk.type === 'attachment') {
|
|
84
90
|
attachments.push(chunk);
|
|
85
|
-
|
|
91
|
+
}
|
|
92
|
+
else if (chunk.userMessage) {
|
|
86
93
|
userMessages.push(chunk);
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
96
|
const byMessage = groupAttachmentsByMessage(attachments, userMessages);
|
|
89
97
|
const history = [];
|
|
90
98
|
const replayedSkills = new Set();
|
|
91
|
-
if (folded.summary)
|
|
99
|
+
if (folded.summary) {
|
|
92
100
|
history.push({ role: 'user', content: compactionTurn(folded.summary) });
|
|
101
|
+
}
|
|
93
102
|
const byRun = new Map();
|
|
94
103
|
const anchor = (runId) => {
|
|
95
104
|
let turn = byRun.get(runId);
|
|
@@ -102,39 +111,52 @@ export function historyFromChunks(chunks, stale = {}, senderNames = new Map()) {
|
|
|
102
111
|
};
|
|
103
112
|
for (const chunk of source) {
|
|
104
113
|
if (chunk.userMessage) {
|
|
105
|
-
if (staleQuestionChunkIds.has(chunk.id))
|
|
114
|
+
if (staleQuestionChunkIds.has(chunk.id)) {
|
|
106
115
|
continue;
|
|
116
|
+
}
|
|
107
117
|
const sender = shared ? senderNames.get(chunk.id) : undefined;
|
|
108
118
|
const turn = { role: 'user', content: chunk.userMessage.text };
|
|
109
|
-
if (sender)
|
|
119
|
+
if (sender) {
|
|
110
120
|
turn.sender = sender;
|
|
121
|
+
}
|
|
111
122
|
const refs = (byMessage.get(chunk.id) ?? [])
|
|
112
|
-
.
|
|
123
|
+
.flatMap((attachmentChunk) => attachmentChunk.attachment ?? [])
|
|
113
124
|
.filter((ref) => !ref.deletedAt);
|
|
114
125
|
const images = refs.filter((ref) => IMAGE_MIMES.has(ref.mimeType.toLowerCase()));
|
|
115
126
|
const audio = refs.filter((ref) => isAudioAttachment(ref.fileName, ref.mimeType));
|
|
116
127
|
const documents = refs.filter((ref) => isDocumentAttachment(ref));
|
|
117
|
-
|
|
128
|
+
const pdfs = documents.filter(isPdfAttachment);
|
|
129
|
+
if (images.length) {
|
|
118
130
|
turn.images = images;
|
|
119
|
-
|
|
131
|
+
}
|
|
132
|
+
if (audio.length) {
|
|
120
133
|
turn.audioAttachments = audio;
|
|
121
|
-
|
|
134
|
+
}
|
|
135
|
+
if (documents.length) {
|
|
122
136
|
turn.documents = documents;
|
|
137
|
+
}
|
|
138
|
+
if (pdfs.length) {
|
|
139
|
+
turn.pdfs = pdfs;
|
|
140
|
+
}
|
|
123
141
|
history.push(turn);
|
|
124
142
|
continue;
|
|
125
143
|
}
|
|
126
|
-
if (chunk.attachment)
|
|
144
|
+
if (chunk.attachment) {
|
|
127
145
|
continue;
|
|
146
|
+
}
|
|
128
147
|
if (chunk.type === 'run-request' && chunk.runId) {
|
|
129
148
|
anchor(chunk.runId);
|
|
130
149
|
continue;
|
|
131
150
|
}
|
|
132
151
|
if (chunk.toolResult?.name === SKILL_TOOL) {
|
|
133
|
-
if (chunk.runId && staleRunIds.has(chunk.runId))
|
|
152
|
+
if (chunk.runId && staleRunIds.has(chunk.runId)) {
|
|
134
153
|
continue;
|
|
135
|
-
|
|
154
|
+
}
|
|
155
|
+
if (beforeLatestAttempt(chunk, attemptStarts)) {
|
|
136
156
|
continue;
|
|
137
|
-
|
|
157
|
+
}
|
|
158
|
+
const { result } = chunk.toolResult;
|
|
159
|
+
const loaded = isRecord(result) ? result.name : undefined;
|
|
138
160
|
if (typeof loaded === 'string' && !replayedSkills.has(loaded)) {
|
|
139
161
|
replayedSkills.add(loaded);
|
|
140
162
|
const at = history.indexOf(anchor(chunk.runId)) + 1;
|
|
@@ -143,21 +165,27 @@ export function historyFromChunks(chunks, stale = {}, senderNames = new Map()) {
|
|
|
143
165
|
continue;
|
|
144
166
|
}
|
|
145
167
|
if (chunk.toolResult) {
|
|
146
|
-
if (chunk.runId && staleRunIds.has(chunk.runId))
|
|
168
|
+
if (chunk.runId && staleRunIds.has(chunk.runId)) {
|
|
147
169
|
continue;
|
|
148
|
-
|
|
170
|
+
}
|
|
171
|
+
if (beforeLatestAttempt(chunk, attemptStarts)) {
|
|
149
172
|
continue;
|
|
173
|
+
}
|
|
150
174
|
const produced = attachmentTurn(chunk.toolResult.name, chunk.toolResult.result);
|
|
151
|
-
if (produced)
|
|
175
|
+
if (produced) {
|
|
152
176
|
history.push({ role: 'tool', content: produced });
|
|
177
|
+
}
|
|
153
178
|
continue;
|
|
154
179
|
}
|
|
155
|
-
if (!chunk.content)
|
|
180
|
+
if (!chunk.content) {
|
|
156
181
|
continue;
|
|
157
|
-
|
|
182
|
+
}
|
|
183
|
+
if (chunk.runId && staleRunIds.has(chunk.runId)) {
|
|
158
184
|
continue;
|
|
159
|
-
|
|
185
|
+
}
|
|
186
|
+
if (beforeLatestAttempt(chunk, attemptStarts)) {
|
|
160
187
|
continue;
|
|
188
|
+
}
|
|
161
189
|
anchor(chunk.runId).content += chunk.content.text;
|
|
162
190
|
}
|
|
163
191
|
return history.filter((turn) => turn.role === 'user' || turn.content.length > 0);
|
|
@@ -205,12 +233,13 @@ export function staleToolRunIds(historyChunks, approvalChunks, currentRunId) {
|
|
|
205
233
|
const empty = { runIds: new Set(), questionChunkIds: new Set() };
|
|
206
234
|
const toolRuns = new Set();
|
|
207
235
|
for (const chunk of approvalChunks) {
|
|
208
|
-
if (chunk.runId)
|
|
236
|
+
if (chunk.runId) {
|
|
209
237
|
toolRuns.add(chunk.runId);
|
|
238
|
+
}
|
|
210
239
|
}
|
|
211
|
-
if (!toolRuns.size)
|
|
240
|
+
if (!toolRuns.size) {
|
|
212
241
|
return empty;
|
|
213
|
-
|
|
242
|
+
}
|
|
214
243
|
const turnText = new Map();
|
|
215
244
|
const turnRuns = new Map();
|
|
216
245
|
const runChunk = new Map();
|
|
@@ -223,7 +252,6 @@ export function staleToolRunIds(historyChunks, approvalChunks, currentRunId) {
|
|
|
223
252
|
if (chunk.type === 'run-request' && chunk.runId && lastUser !== null) {
|
|
224
253
|
const chunkId = lastUser.chunkId;
|
|
225
254
|
if (!turnText.has(chunkId)) {
|
|
226
|
-
turnOrder.push(chunkId);
|
|
227
255
|
turnText.set(chunkId, lastUser.text);
|
|
228
256
|
}
|
|
229
257
|
turnRuns.set(chunkId, [...(turnRuns.get(chunkId) ?? []), chunk.runId]);
|
|
@@ -231,31 +259,38 @@ export function staleToolRunIds(historyChunks, approvalChunks, currentRunId) {
|
|
|
231
259
|
}
|
|
232
260
|
}
|
|
233
261
|
const currentChunkId = runChunk.get(currentRunId) ?? lastUser?.chunkId;
|
|
234
|
-
if (currentChunkId === undefined)
|
|
262
|
+
if (currentChunkId === undefined) {
|
|
235
263
|
return empty;
|
|
264
|
+
}
|
|
236
265
|
const currentText = turnText.get(currentChunkId) ?? lastUser?.text;
|
|
237
|
-
if (currentText === undefined)
|
|
266
|
+
if (currentText === undefined) {
|
|
238
267
|
return empty;
|
|
268
|
+
}
|
|
239
269
|
const target = normalizeQuestion(currentText);
|
|
240
|
-
if (isGenericAcknowledgement(target))
|
|
270
|
+
if (isGenericAcknowledgement(target)) {
|
|
241
271
|
return empty;
|
|
242
|
-
|
|
243
|
-
const
|
|
272
|
+
}
|
|
273
|
+
const turns = [...turnText];
|
|
274
|
+
const currentIndex = turns.findIndex(([chunkId]) => chunkId === currentChunkId);
|
|
275
|
+
const start = currentIndex === -1 ? turns.length - 1 : currentIndex - 1;
|
|
244
276
|
const runIds = new Set();
|
|
245
277
|
const questionChunkIds = new Set();
|
|
246
278
|
let blockHadApproval = false;
|
|
247
279
|
for (let i = start; i >= 0; i--) {
|
|
248
|
-
const chunkId =
|
|
249
|
-
if (normalizeQuestion(
|
|
280
|
+
const [chunkId, text] = turns[i];
|
|
281
|
+
if (normalizeQuestion(text) !== target) {
|
|
250
282
|
break;
|
|
283
|
+
}
|
|
251
284
|
questionChunkIds.add(chunkId);
|
|
252
285
|
for (const rid of turnRuns.get(chunkId) ?? []) {
|
|
253
286
|
runIds.add(rid);
|
|
254
|
-
if (toolRuns.has(rid))
|
|
287
|
+
if (toolRuns.has(rid)) {
|
|
255
288
|
blockHadApproval = true;
|
|
289
|
+
}
|
|
256
290
|
}
|
|
257
291
|
}
|
|
258
|
-
if (!blockHadApproval)
|
|
292
|
+
if (!blockHadApproval) {
|
|
259
293
|
return empty;
|
|
294
|
+
}
|
|
260
295
|
return { runIds, questionChunkIds };
|
|
261
296
|
}
|
|
@@ -9,6 +9,7 @@ export interface ChatMessage {
|
|
|
9
9
|
images?: AttachmentRef[];
|
|
10
10
|
audioAttachments?: AttachmentRef[];
|
|
11
11
|
documents?: DocumentAttachment[];
|
|
12
|
+
pdfs?: AttachmentRef[];
|
|
12
13
|
}
|
|
13
14
|
export declare const IMAGE_ONLY_USER_PROMPT = "The user sent one or more images without any accompanying text. Describe what the images show and respond to anything notable in them.";
|
|
14
15
|
export declare const DOCUMENT_ONLY_USER_PROMPT = "The user sent one or more documents without any accompanying text. Summarize the attached documents.";
|
|
@@ -17,9 +18,10 @@ export declare function backfillDocumentOnlyTurn(messages: ChatMessage[]): void;
|
|
|
17
18
|
export declare function backfillImageOnlyTurns(messages: ChatMessage[]): void;
|
|
18
19
|
export declare function unreadableImagesNotice(fileNames: readonly string[]): string;
|
|
19
20
|
export declare function annotateUnreadableImages(unreadable: ReadonlyMap<ChatMessage, string[]>): void;
|
|
20
|
-
export
|
|
21
|
-
retryable?: boolean;
|
|
22
|
-
}
|
|
21
|
+
export interface UnheardAudioNoticeOptions {
|
|
22
|
+
readonly retryable?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function unheardAudioNotice(label: string, reason: string, opts?: UnheardAudioNoticeOptions): string;
|
|
23
25
|
export declare function silentAudioNotice(fileName: string): string;
|
|
24
26
|
export declare function audioTranscriptBlock(fileName: string, transcript: string): string;
|
|
25
27
|
export interface AttachmentRef {
|
|
@@ -3,8 +3,9 @@ export const DOCUMENT_ONLY_USER_PROMPT = 'The user sent one or more documents wi
|
|
|
3
3
|
export const IMAGE_AND_DOCUMENT_USER_PROMPT = 'The user sent one or more images together with one or more documents, and no accompanying text. Describe what the images show and summarize the attached documents.';
|
|
4
4
|
export function backfillDocumentOnlyTurn(messages) {
|
|
5
5
|
const last = messages.findLast((turn) => turn.role === 'user');
|
|
6
|
-
if (!last || last.content.trim())
|
|
6
|
+
if (!last || last.content.trim()) {
|
|
7
7
|
return;
|
|
8
|
+
}
|
|
8
9
|
last.content = last.attachments?.length
|
|
9
10
|
? IMAGE_AND_DOCUMENT_USER_PROMPT
|
|
10
11
|
: DOCUMENT_ONLY_USER_PROMPT;
|
|
@@ -13,8 +14,9 @@ export function backfillImageOnlyTurns(messages) {
|
|
|
13
14
|
for (const turn of messages) {
|
|
14
15
|
if (turn.role !== 'user' || turn.content.trim())
|
|
15
16
|
continue;
|
|
16
|
-
if (turn.attachments?.length)
|
|
17
|
+
if (turn.attachments?.length) {
|
|
17
18
|
turn.content = IMAGE_ONLY_USER_PROMPT;
|
|
19
|
+
}
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
export function unreadableImagesNotice(fileNames) {
|
|
@@ -18,4 +18,6 @@ export interface Skill {
|
|
|
18
18
|
export declare function toEngineSkill(skill: Skill): AssistantSkill;
|
|
19
19
|
export declare function toEngineSkillRequirements(requires: SkillRequires): NonNullable<AssistantSkill['requirements']>;
|
|
20
20
|
export declare function toEngineInstallStep(step: InstallStep): NonNullable<AssistantSkill['install']>[number];
|
|
21
|
-
|
|
21
|
+
type EngineSetup = NonNullable<AssistantSkill['setup']>;
|
|
22
|
+
export declare function toEngineSkillSetup(setup: SkillSetup): EngineSetup;
|
|
23
|
+
export {};
|
|
@@ -10,12 +10,12 @@ export function toEngineSkill(skill) {
|
|
|
10
10
|
allowList: [...skill.allowList],
|
|
11
11
|
platforms: [...skill.platform],
|
|
12
12
|
status: skill.status,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
requirements: skill.requires ? toEngineSkillRequirements(skill.requires) : undefined,
|
|
14
|
+
install: skill.install?.map(toEngineInstallStep),
|
|
15
|
+
setup: setup ? toEngineSkillSetup(setup) : undefined,
|
|
16
|
+
stub: skill.stub,
|
|
17
|
+
minCapabilityProfile: skill.minCapabilityProfile,
|
|
18
|
+
emoji: skill.emoji
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
export function toEngineSkillRequirements(requires) {
|
|
@@ -33,65 +33,55 @@ export function toEngineInstallStep(step) {
|
|
|
33
33
|
id: step.id,
|
|
34
34
|
kind: step.kind,
|
|
35
35
|
label: step.label,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
formula: step.formula,
|
|
37
|
+
command: step.command,
|
|
38
|
+
manual: step.manual,
|
|
39
|
+
bins: step.bins && [...step.bins]
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
export function toEngineSkillSetup(setup) {
|
|
43
43
|
return {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
...(route.oauth.port !== undefined ? { port: route.oauth.port } : {}),
|
|
87
|
-
...(route.oauth.sharedIosSession !== undefined
|
|
88
|
-
? { sharedIosSession: route.oauth.sharedIosSession }
|
|
89
|
-
: {})
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
: {})
|
|
93
|
-
}))
|
|
94
|
-
}
|
|
95
|
-
: {})
|
|
44
|
+
summary: setup.summary,
|
|
45
|
+
routes: setup.routes?.map(toEngineRoute)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function toEngineRoute(route) {
|
|
49
|
+
return {
|
|
50
|
+
kind: route.kind,
|
|
51
|
+
label: route.label,
|
|
52
|
+
provider: route.provider,
|
|
53
|
+
credentialKey: route.credentialKey,
|
|
54
|
+
description: route.description,
|
|
55
|
+
helpUrl: route.helpUrl,
|
|
56
|
+
steps: route.steps && [...route.steps],
|
|
57
|
+
configSteps: route.configSteps && [...route.configSteps],
|
|
58
|
+
fields: route.fields?.map((field) => ({
|
|
59
|
+
key: field.key,
|
|
60
|
+
label: field.label,
|
|
61
|
+
placeholder: field.placeholder,
|
|
62
|
+
secret: field.secret,
|
|
63
|
+
required: field.required
|
|
64
|
+
})),
|
|
65
|
+
satisfied: route.satisfied,
|
|
66
|
+
oauth: toEngineOauth(route.oauth)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function toEngineOauth(oauth) {
|
|
70
|
+
if (!oauth?.stateKey || !oauth.authUrl || !oauth.tokenUrl)
|
|
71
|
+
return undefined;
|
|
72
|
+
const tokenAuth = TOKEN_AUTH.find((mode) => mode === oauth.tokenAuth);
|
|
73
|
+
if (!tokenAuth) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
stateKey: oauth.stateKey,
|
|
78
|
+
authUrl: oauth.authUrl,
|
|
79
|
+
tokenUrl: oauth.tokenUrl,
|
|
80
|
+
tokenAuth,
|
|
81
|
+
scopes: [...(oauth.scopes ?? [])],
|
|
82
|
+
extraAuthParams: oauth.extraAuthParams,
|
|
83
|
+
registrationEndpoint: oauth.registrationEndpoint,
|
|
84
|
+
port: oauth.port,
|
|
85
|
+
sharedIosSession: oauth.sharedIosSession
|
|
96
86
|
};
|
|
97
87
|
}
|
|
@@ -5,8 +5,10 @@ export class AssistantClient extends Client {
|
|
|
5
5
|
_inline;
|
|
6
6
|
constructor({ sidecar: spawnSidecar = true, storagePath, device, meshSeed, meshKey, bootstrapNodes, entry, ...engineOptions }) {
|
|
7
7
|
const inline = { core: null };
|
|
8
|
-
if (spawnSidecar && !entry)
|
|
8
|
+
if (spawnSidecar && !entry) {
|
|
9
9
|
throw new Error('sidecar mode needs a stowed bundle entry');
|
|
10
|
+
}
|
|
11
|
+
const sidecarEntry = spawnSidecar ? entry : undefined;
|
|
10
12
|
const args = [
|
|
11
13
|
storagePath,
|
|
12
14
|
device?.name ?? '',
|
|
@@ -16,14 +18,15 @@ export class AssistantClient extends Client {
|
|
|
16
18
|
meshKey ? b4a.toHex(meshKey) : '',
|
|
17
19
|
(bootstrapNodes ?? []).map((node) => `${node.host}:${node.port}`).join(',')
|
|
18
20
|
];
|
|
19
|
-
const transport =
|
|
21
|
+
const transport = sidecarEntry
|
|
20
22
|
? async () => {
|
|
21
23
|
const { default: sidecarRunner } = await import('bare-supervisor/runner/sidecar');
|
|
22
|
-
const { ipc, exit } = sidecarRunner(
|
|
24
|
+
const { ipc, exit } = sidecarRunner(sidecarEntry, args, engineOptions.logger ?? null);
|
|
23
25
|
const died = exit.then((code) => `sidecar exited (${code}) before ready`);
|
|
24
26
|
const failure = await Promise.race([ipc.ready.then(() => null), died]);
|
|
25
|
-
if (failure)
|
|
27
|
+
if (failure) {
|
|
26
28
|
throw new Error(failure);
|
|
29
|
+
}
|
|
27
30
|
return ipc;
|
|
28
31
|
}
|
|
29
32
|
: async () => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Supervisor, {} from 'bare-supervisor';
|
|
2
|
-
import { harnessClearKvCache,
|
|
2
|
+
import { harnessClearKvCache, harnessListModels, harnessPreviewModelSource, harnessSkillCatalog, harnessSkillManagement, harnessDetectLanguage, harnessSpeak, harnessSpeakStream, harnessTools, harnessTranscribe, QvacAssistant } from './assistant.js';
|
|
3
3
|
import { Client } from './client.js';
|
|
4
4
|
import { startCustomModelPusher } from './custom-model-pusher.js';
|
|
5
|
+
import { startModelIdlePusher } from './model-idle-pusher.js';
|
|
5
6
|
import { serveHarness } from '@qvac/harness';
|
|
6
7
|
import { duplexPair } from '@qvac/harness/transport';
|
|
7
8
|
export function assistantTree(opts) {
|
|
@@ -20,6 +21,7 @@ export function assistantTree(opts) {
|
|
|
20
21
|
let offDeleteChatKvCache = null;
|
|
21
22
|
let offCompactChat = null;
|
|
22
23
|
let offRetryModelDownload = null;
|
|
24
|
+
let offModelResidency = null;
|
|
23
25
|
let offSkills = null;
|
|
24
26
|
let offSkillCatalog = null;
|
|
25
27
|
let offSkillManagement = null;
|
|
@@ -27,10 +29,13 @@ export function assistantTree(opts) {
|
|
|
27
29
|
let offEmbedder = null;
|
|
28
30
|
let offHarness = null;
|
|
29
31
|
let offTranscribe = null;
|
|
32
|
+
let offDetectLanguage = null;
|
|
33
|
+
let offPreviewModelSource = null;
|
|
30
34
|
let offSpeak = null;
|
|
31
35
|
let offSpeakStream = null;
|
|
32
36
|
let offModelCatalogWatch = null;
|
|
33
37
|
let offCustomModels = null;
|
|
38
|
+
let offModelIdle = null;
|
|
34
39
|
let offLoanableHarness = null;
|
|
35
40
|
sup.add('engine', {
|
|
36
41
|
start: async () => {
|
|
@@ -60,12 +65,12 @@ export function assistantTree(opts) {
|
|
|
60
65
|
const assistant = new QvacAssistant(engine, harness, {
|
|
61
66
|
logger,
|
|
62
67
|
imageCacheDir,
|
|
63
|
-
|
|
68
|
+
inferenceCallsDir,
|
|
64
69
|
imageCacheMaxBytes,
|
|
65
70
|
imageCacheMaxAgeMs,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
platform,
|
|
72
|
+
preloadCurrentAgentModel,
|
|
73
|
+
drives: core.fsDrives ?? undefined,
|
|
69
74
|
borrowHarness: (deviceId) => core.borrowHarness(deviceId)
|
|
70
75
|
});
|
|
71
76
|
offDiagnostics = core.registerDiagnostics(() => assistant.diagnosticsSlice());
|
|
@@ -74,20 +79,30 @@ export function assistantTree(opts) {
|
|
|
74
79
|
forget: (chatId) => assistant.forgetInferenceCalls(chatId)
|
|
75
80
|
});
|
|
76
81
|
offListModels = core.registerListModels(harnessListModels(harness));
|
|
77
|
-
offDeleteModel = core.registerDeleteModel(
|
|
82
|
+
offDeleteModel = core.registerDeleteModel(({ name }) => assistant.deleteModel(name));
|
|
78
83
|
offClearKvCache = core.registerClearKvCache(harnessClearKvCache(harness));
|
|
79
84
|
offDeleteChatKvCache = core.registerDeleteChatKvCache((chatId) => assistant.deleteChatKvCache(chatId));
|
|
80
85
|
offCompactChat = core.registerCompactChat((chatId, meshId) => assistant.compactChat(chatId, { meshId }));
|
|
81
86
|
offModelCatalogWatch = core.registerModelCatalogWatch(() => assistant.modelCatalogWatch());
|
|
82
|
-
offCustomModels = startCustomModelPusher(harness, core.local,
|
|
87
|
+
offCustomModels = startCustomModelPusher(harness, core.local, {
|
|
88
|
+
logger,
|
|
89
|
+
onPushed: () => assistant.notifyModelCatalog()
|
|
90
|
+
});
|
|
91
|
+
offModelIdle = startModelIdlePusher(harness, core.local, logger);
|
|
83
92
|
offLoanableHarness = core.registerLoanableHarness((stream) => serveHarness(stream, harness));
|
|
84
93
|
offRetryModelDownload = core.registerRetryModelDownload((name) => assistant.retryModelDownload(name));
|
|
94
|
+
offModelResidency = core.registerModelResidency({
|
|
95
|
+
load: (name) => assistant.loadModel(name),
|
|
96
|
+
unload: (name) => assistant.unloadModel(name)
|
|
97
|
+
});
|
|
85
98
|
offSkills = core.registerSkills((agentId, modelName, options) => assistant.skills(agentId, modelName, options));
|
|
86
99
|
const transcribe = harnessTranscribe(harness);
|
|
87
100
|
offTranscribe = core.registerTranscribe(async (request) => {
|
|
88
101
|
await assistant.ensureMediaModelUnpaused('transcription', request.model);
|
|
89
102
|
return transcribe(request);
|
|
90
103
|
});
|
|
104
|
+
offDetectLanguage = core.registerDetectLanguage(harnessDetectLanguage(harness));
|
|
105
|
+
offPreviewModelSource = core.registerPreviewModelSource(harnessPreviewModelSource(harness));
|
|
91
106
|
const speak = harnessSpeak(harness);
|
|
92
107
|
offSpeak = core.registerSpeak(async (request) => {
|
|
93
108
|
await assistant.ensureMediaModelUnpaused('tts', request.model);
|
|
@@ -107,16 +122,18 @@ export function assistantTree(opts) {
|
|
|
107
122
|
const wrapped = {
|
|
108
123
|
model: emb.model,
|
|
109
124
|
embed: async (input) => {
|
|
110
|
-
if (!ensured)
|
|
125
|
+
if (!ensured) {
|
|
111
126
|
ensured = await assistant.ensureMediaModelUnpaused('embedding');
|
|
127
|
+
}
|
|
112
128
|
return emb.embed(input);
|
|
113
129
|
}
|
|
114
130
|
};
|
|
115
131
|
offEmbedder = core.registerEmbedder(wrapped, extractors);
|
|
116
132
|
}
|
|
117
133
|
const off = onHarness?.(harness, { engine });
|
|
118
|
-
if (typeof off === 'function')
|
|
134
|
+
if (typeof off === 'function') {
|
|
119
135
|
offHarness = off;
|
|
136
|
+
}
|
|
120
137
|
return assistant;
|
|
121
138
|
},
|
|
122
139
|
stop: async (assistant) => {
|
|
@@ -138,10 +155,14 @@ export function assistantTree(opts) {
|
|
|
138
155
|
offModelCatalogWatch = null;
|
|
139
156
|
await offCustomModels?.();
|
|
140
157
|
offCustomModels = null;
|
|
158
|
+
await offModelIdle?.();
|
|
159
|
+
offModelIdle = null;
|
|
141
160
|
offLoanableHarness?.();
|
|
142
161
|
offLoanableHarness = null;
|
|
143
162
|
offRetryModelDownload?.();
|
|
144
163
|
offRetryModelDownload = null;
|
|
164
|
+
offModelResidency?.();
|
|
165
|
+
offModelResidency = null;
|
|
145
166
|
offSkills?.();
|
|
146
167
|
offSkills = null;
|
|
147
168
|
offSkillCatalog?.();
|
|
@@ -156,6 +177,10 @@ export function assistantTree(opts) {
|
|
|
156
177
|
offHarness = null;
|
|
157
178
|
offTranscribe?.();
|
|
158
179
|
offTranscribe = null;
|
|
180
|
+
offDetectLanguage?.();
|
|
181
|
+
offDetectLanguage = null;
|
|
182
|
+
offPreviewModelSource?.();
|
|
183
|
+
offPreviewModelSource = null;
|
|
159
184
|
offSpeak?.();
|
|
160
185
|
offSpeak = null;
|
|
161
186
|
offSpeakStream?.();
|
|
@@ -180,13 +205,13 @@ export function assistantChild(opts) {
|
|
|
180
205
|
harness,
|
|
181
206
|
logger,
|
|
182
207
|
imageCacheDir,
|
|
183
|
-
|
|
208
|
+
inferenceCallsDir,
|
|
184
209
|
imageCacheMaxBytes,
|
|
185
210
|
imageCacheMaxAgeMs,
|
|
186
211
|
embedder,
|
|
187
212
|
extractors,
|
|
188
213
|
onHarness,
|
|
189
|
-
|
|
214
|
+
preloadCurrentAgentModel
|
|
190
215
|
});
|
|
191
216
|
tree.on('gave-up', ({ error }) => ctx.onDeath(error));
|
|
192
217
|
return tree;
|