@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
package/tui/lib/selection.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
//
|
|
2
|
-
// keeps them too, so duck resumes where either app left off. setConfig replaces the whole
|
|
3
|
-
// writable record, so the untouched fields ride along from the current read.
|
|
1
|
+
// setConfig replaces the whole writable record, so the untouched fields ride along from the read
|
|
4
2
|
export async function rememberSelection(engine, { agentId, chatId }) {
|
|
5
3
|
const current = await engine.getConfig({})
|
|
6
|
-
if (current.activeAgentId === agentId && current.activeChatId === chatId)
|
|
4
|
+
if (current.activeAgentId === agentId && current.activeChatId === chatId) {
|
|
5
|
+
return current
|
|
6
|
+
}
|
|
7
|
+
|
|
7
8
|
const { thinkingEnabled, ctxSize, onboardingCompleted, delegation } = current
|
|
9
|
+
|
|
8
10
|
return engine.setConfig({
|
|
9
11
|
activeAgentId: agentId,
|
|
10
12
|
activeChatId: chatId,
|
package/tui/lib/setup.mjs
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// run for you: an OAuth route becomes /connect, a pasted-token route a /cred
|
|
3
|
-
// stub, anything else its own steps. The routes themselves come from the shared
|
|
4
|
-
// integrations registry, so the TUI and the desktop Settings UI agree on what
|
|
5
|
-
// setting a skill up means.
|
|
1
|
+
// routes come from the shared integrations registry so the TUI and desktop agree on setup
|
|
6
2
|
import { deriveSetupRoutes } from '../../dist-lib/lib/integrations/index.js'
|
|
7
3
|
|
|
8
4
|
const STATUS_LABELS = {
|
|
@@ -31,23 +27,20 @@ export function connectSlug(credentialKey) {
|
|
|
31
27
|
.replaceAll('_', '-')
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
//
|
|
35
|
-
// one way in — Obsidian is either the CLI or a vault folder — and the ones that
|
|
36
|
-
// carry a credential key are also how it is RECONFIGURED later.
|
|
30
|
+
// the routes that carry a credential key are also how a skill is reconfigured later
|
|
37
31
|
export function setupActions(skill) {
|
|
38
32
|
return (deriveSetupRoutes(skillEntry(skill)).routes ?? []).map((route) =>
|
|
39
33
|
routeAction(route, skill)
|
|
40
34
|
)
|
|
41
35
|
}
|
|
42
36
|
|
|
43
|
-
//
|
|
44
|
-
// route, preferring one the TUI can run over one that only prints instructions;
|
|
45
|
-
// `others` are the remaining ways in, rendered as a one-line "or …" each.
|
|
37
|
+
// prefers a route the TUI can run over one that only prints instructions
|
|
46
38
|
export function setupPlan(skill) {
|
|
47
39
|
const actions = setupActions(skill)
|
|
48
40
|
const open = actions.filter((action) => !action.satisfied)
|
|
49
41
|
const primary = open.find((action) => action.command || action.prefill) ?? open[0] ?? null
|
|
50
42
|
const others = actions.filter((action) => action !== primary)
|
|
43
|
+
|
|
51
44
|
return { primary, others }
|
|
52
45
|
}
|
|
53
46
|
|
|
@@ -55,10 +48,7 @@ export function setupAction(skill) {
|
|
|
55
48
|
return setupPlan(skill).primary
|
|
56
49
|
}
|
|
57
50
|
|
|
58
|
-
//
|
|
59
|
-
// these: they are how it is pointed somewhere else (another Obsidian vault,
|
|
60
|
-
// another GitHub token) — a route with a credential key is configuration, not
|
|
61
|
-
// a one-time connect.
|
|
51
|
+
// a connected skill keeps these: a route with a credential key is configuration, not a one-off
|
|
62
52
|
export function configureActions(skill) {
|
|
63
53
|
const { primary, others } = setupPlan(skill)
|
|
64
54
|
return [primary, ...others].filter((action) => action?.command || action?.prefill)
|
|
@@ -75,10 +65,14 @@ function routeAction(route, skill) {
|
|
|
75
65
|
command: undefined,
|
|
76
66
|
prefill: undefined
|
|
77
67
|
}
|
|
78
|
-
if (!route.credentialKey)
|
|
68
|
+
if (!route.credentialKey) {
|
|
69
|
+
return action
|
|
70
|
+
}
|
|
71
|
+
|
|
79
72
|
if (route.kind === 'oauth') {
|
|
80
73
|
return { ...action, kind: 'connect', command: `/connect ${connectSlug(route.credentialKey)}` }
|
|
81
74
|
}
|
|
75
|
+
|
|
82
76
|
return { ...action, kind: 'cred', prefill: `/cred ${route.credentialKey} ` }
|
|
83
77
|
}
|
|
84
78
|
|
|
@@ -86,9 +80,7 @@ function installSteps(skill) {
|
|
|
86
80
|
return (skill.install ?? []).map((s) => (s.command ? `${s.label} → ${s.command}` : s.label))
|
|
87
81
|
}
|
|
88
82
|
|
|
89
|
-
//
|
|
90
|
-
// registry reads a catalog entry. `a|b` credential slots list interchangeable
|
|
91
|
-
// keys — each is its own candidate route.
|
|
83
|
+
// `a|b` credential slots list interchangeable keys, each its own candidate route
|
|
92
84
|
function skillEntry(skill) {
|
|
93
85
|
const credentials = (skill.requires?.credentials ?? skill.credentials ?? []).flatMap((slot) =>
|
|
94
86
|
slot.split('|')
|
package/tui/lib/sidebar.mjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// presents them (groups first, each chat where it was dragged or else
|
|
3
|
-
// newest-activity first). Rows are what the pane draws and what its cursor
|
|
4
|
-
// walks; only `chat` rows are selectable.
|
|
1
|
+
// the chat sidebar's row model; only `chat` rows are selectable
|
|
5
2
|
|
|
6
3
|
export const SIDEBAR_COLS = 26
|
|
7
4
|
|
|
@@ -11,32 +8,45 @@ export function sidebarRows(chats, groups, activeId) {
|
|
|
11
8
|
for (const group of groups ?? []) {
|
|
12
9
|
const held = live.filter((chat) => chat.groupId === group.id)
|
|
13
10
|
rows.push({ kind: 'group', label: group.name })
|
|
14
|
-
if (!held.length)
|
|
15
|
-
|
|
11
|
+
if (!held.length) {
|
|
12
|
+
rows.push({ kind: 'empty', label: '(empty)' })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
for (const chat of held) {
|
|
16
|
+
rows.push(chatRow(chat, activeId))
|
|
17
|
+
}
|
|
16
18
|
}
|
|
19
|
+
|
|
17
20
|
const loose = live.filter((chat) => !chat.groupId)
|
|
18
|
-
if (loose.length && rows.length)
|
|
19
|
-
|
|
21
|
+
if (loose.length && rows.length) {
|
|
22
|
+
rows.push({ kind: 'group', label: '(ungrouped)' })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const chat of loose) {
|
|
26
|
+
rows.push(chatRow(chat, activeId))
|
|
27
|
+
}
|
|
28
|
+
|
|
20
29
|
return rows
|
|
21
30
|
}
|
|
22
31
|
|
|
23
|
-
// The move picker's rows — every group, plus ungrouping, minus the one the chat
|
|
24
|
-
// already sits in.
|
|
25
32
|
export function moveRows(groups, groupId) {
|
|
26
33
|
const rows = (groups ?? [])
|
|
27
34
|
.filter((group) => group.id !== groupId)
|
|
28
35
|
.map((group) => ({ kind: 'target', label: group.name, groupId: group.id }))
|
|
29
|
-
if (groupId)
|
|
36
|
+
if (groupId) {
|
|
37
|
+
rows.unshift({ kind: 'target', label: '(no group)', groupId: null })
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
rows.push({ kind: 'new-group', label: 'New group…' })
|
|
41
|
+
|
|
31
42
|
return rows
|
|
32
43
|
}
|
|
33
44
|
|
|
34
|
-
// The next row the cursor may land on, walking `delta` at a time; the headers
|
|
35
|
-
// and the (empty) placeholders are skipped. Stays put at either end.
|
|
36
45
|
export function nextSelectable(rows, from, delta) {
|
|
37
46
|
for (let i = from + delta; i >= 0 && i < rows.length; i += delta) {
|
|
38
47
|
if (selectable(rows[i])) return i
|
|
39
48
|
}
|
|
49
|
+
|
|
40
50
|
return selectable(rows[from]) ? from : firstSelectable(rows)
|
|
41
51
|
}
|
|
42
52
|
|
package/tui/lib/splash.mjs
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { SIZES } from './splash-art.mjs'
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
// null when even the smallest doesn't. Rows carry their own SGR and reset, so
|
|
5
|
-
// the caller can hand the result straight to wrapBlock: every row's visible
|
|
6
|
-
// width is its cut's width, which fits by construction.
|
|
3
|
+
// rows carry their own SGR and reset, so the result goes straight to wrapBlock
|
|
7
4
|
export function splash(width, height) {
|
|
8
5
|
const art = SIZES.find((size) => size.width <= width && size.rows.length <= height)
|
|
9
|
-
if (!art)
|
|
6
|
+
if (!art) {
|
|
7
|
+
return null
|
|
8
|
+
}
|
|
9
|
+
|
|
10
10
|
const indent = ' '.repeat((width - art.width) >> 1)
|
|
11
11
|
const above = '\n'.repeat((height - art.rows.length) >> 1)
|
|
12
|
+
|
|
12
13
|
return above + art.rows.map((row) => indent + row).join('\n')
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
// Centered against the same box, so a caption sits under the art rather than
|
|
16
|
-
// against the left edge.
|
|
17
16
|
export function center(line, width, plainWidth = line.length) {
|
|
18
17
|
return ' '.repeat(Math.max(0, (width - plainWidth) >> 1)) + line
|
|
19
18
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Writable } from 'streamx'
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
// the upload ends with no response. Every blob upload goes up in these.
|
|
3
|
+
// the wire drops a multi-megabyte frame whole and the upload ends with no response
|
|
5
4
|
export const UPLOAD_FRAME_BYTES = 64 * 1024
|
|
6
5
|
|
|
7
6
|
export function writeFrame(stream, frame) {
|
package/tui/lib/usage.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import b4a from 'b4a'
|
|
2
|
-
//
|
|
3
|
-
// that ran the turn had loaded, `cacheTokens` the SDK's occupancy reading, `usage` the
|
|
4
|
-
// harness's attribution of the prompt it sent (docs/decisions in @qvac/harness).
|
|
2
|
+
// only what the run itself reported, nothing counted here
|
|
5
3
|
const PROMPT_ROWS = [
|
|
6
4
|
['systemPrompt', 'System prompt'],
|
|
7
5
|
['agentInstructions', 'Agent instructions'],
|
|
@@ -10,15 +8,22 @@ const PROMPT_ROWS = [
|
|
|
10
8
|
]
|
|
11
9
|
|
|
12
10
|
export function usageReport(statuses, folds = []) {
|
|
13
|
-
// one row per run, its latest status
|
|
11
|
+
// one row per run, its latest status as turnsFromChunks reads them, so a run never counts twice
|
|
14
12
|
const latest = new Map()
|
|
15
|
-
for (const chunk of statuses)
|
|
13
|
+
for (const chunk of statuses) {
|
|
14
|
+
latest.set(chunk.runId, chunk)
|
|
15
|
+
}
|
|
16
|
+
|
|
16
17
|
const completed = [...latest.values()].filter(
|
|
17
18
|
(chunk) => chunk.runStatus?.state === 'completed' && chunk.runStatus.metrics
|
|
18
19
|
)
|
|
19
|
-
if (!completed.length)
|
|
20
|
+
if (!completed.length) {
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
const last = completed[completed.length - 1]
|
|
21
25
|
const metrics = last.runStatus.metrics
|
|
26
|
+
|
|
22
27
|
return {
|
|
23
28
|
runs: completed.length,
|
|
24
29
|
generated: completed.reduce(
|
|
@@ -39,9 +44,7 @@ export function usageReport(statuses, folds = []) {
|
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
//
|
|
43
|
-
// so a cost no row authors — the template's turn wrappers, the reply just generated — lands on
|
|
44
|
-
// the turns rather than skewing a prompt row; the rows shrink to fit when they exceed it.
|
|
47
|
+
// conversation is the remainder, so a cost no row authors lands on the turns, not a prompt row
|
|
45
48
|
function promptRows(usage, occupied) {
|
|
46
49
|
if (!usage || !occupied) return null
|
|
47
50
|
const reported = PROMPT_ROWS.reduce((sum, [key]) => sum + usage[key], 0)
|
|
@@ -51,5 +54,6 @@ function promptRows(usage, occupied) {
|
|
|
51
54
|
tokens: Math.floor(usage[key] * scale)
|
|
52
55
|
}))
|
|
53
56
|
const known = rows.reduce((sum, row) => sum + row.tokens, 0)
|
|
57
|
+
|
|
54
58
|
return [{ label: 'Conversation', tokens: occupied - known }, ...rows]
|
|
55
59
|
}
|
package/tui/lib/wrap.mjs
CHANGED
|
@@ -22,10 +22,12 @@ export function cells(line) {
|
|
|
22
22
|
continue
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
|
|
25
26
|
const ch = String.fromCodePoint(line.codePointAt(i))
|
|
26
27
|
out.push({ ch, w: charWidth(ch) })
|
|
27
28
|
i += ch.length
|
|
28
29
|
}
|
|
30
|
+
|
|
29
31
|
return out
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -34,20 +36,26 @@ function tokens(line) {
|
|
|
34
36
|
let token = null
|
|
35
37
|
for (const cell of cells(line)) {
|
|
36
38
|
if (cell.esc) {
|
|
37
|
-
if (!token)
|
|
39
|
+
if (!token) {
|
|
40
|
+
out.push((token = { raw: '', w: 0, space: false, cells: [] }))
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
token.raw += cell.esc
|
|
39
44
|
token.cells.push(cell)
|
|
40
45
|
continue
|
|
41
46
|
}
|
|
47
|
+
|
|
42
48
|
const space = cell.ch === ' '
|
|
43
49
|
if (!token || (token.w > 0 && token.space !== space)) {
|
|
44
50
|
out.push((token = { raw: '', w: 0, space, cells: [] }))
|
|
45
51
|
}
|
|
52
|
+
|
|
46
53
|
token.space = space
|
|
47
54
|
token.raw += cell.ch
|
|
48
55
|
token.w += cell.w
|
|
49
56
|
token.cells.push(cell)
|
|
50
57
|
}
|
|
58
|
+
|
|
51
59
|
return out
|
|
52
60
|
}
|
|
53
61
|
|
|
@@ -56,6 +64,7 @@ function activeSgr(raw) {
|
|
|
56
64
|
for (const match of raw.matchAll(SGR_ALL)) {
|
|
57
65
|
open = match[0] === RESET || match[0] === '\x1b[m' ? '' : open + match[0]
|
|
58
66
|
}
|
|
67
|
+
|
|
59
68
|
return open
|
|
60
69
|
}
|
|
61
70
|
|
|
@@ -65,7 +74,10 @@ function leadingSpaces(line) {
|
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
export function wrapLine(line, max) {
|
|
68
|
-
if (max <= 0 || style.width(line) <= max)
|
|
77
|
+
if (max <= 0 || style.width(line) <= max) {
|
|
78
|
+
return [line]
|
|
79
|
+
}
|
|
80
|
+
|
|
69
81
|
const indent = ' '.repeat(Math.min(leadingSpaces(line), Math.max(0, max - 1)))
|
|
70
82
|
const rows = []
|
|
71
83
|
let row = ''
|
|
@@ -82,27 +94,44 @@ export function wrapLine(line, max) {
|
|
|
82
94
|
row += token.raw
|
|
83
95
|
continue
|
|
84
96
|
}
|
|
97
|
+
|
|
85
98
|
if (col + token.w <= max) {
|
|
86
99
|
row += token.raw
|
|
87
100
|
col += token.w
|
|
88
101
|
continue
|
|
89
102
|
}
|
|
103
|
+
|
|
90
104
|
if (token.space) {
|
|
91
|
-
if (col > indent.length)
|
|
105
|
+
if (col > indent.length) {
|
|
106
|
+
breakRow()
|
|
107
|
+
}
|
|
108
|
+
|
|
92
109
|
continue
|
|
93
110
|
}
|
|
94
|
-
|
|
111
|
+
|
|
112
|
+
if (col > indent.length && indent.length + token.w <= max) {
|
|
113
|
+
breakRow()
|
|
114
|
+
}
|
|
115
|
+
|
|
95
116
|
for (const cell of token.cells) {
|
|
96
117
|
if (cell.esc) {
|
|
97
118
|
row += cell.esc
|
|
98
119
|
continue
|
|
99
120
|
}
|
|
100
|
-
|
|
121
|
+
|
|
122
|
+
if (col + cell.w > max) {
|
|
123
|
+
breakRow()
|
|
124
|
+
}
|
|
125
|
+
|
|
101
126
|
row += cell.ch
|
|
102
127
|
col += cell.w
|
|
103
128
|
}
|
|
104
129
|
}
|
|
105
|
-
|
|
130
|
+
|
|
131
|
+
if (rows.length === 0 || style.width(row) > indent.length) {
|
|
132
|
+
rows.push(row)
|
|
133
|
+
}
|
|
134
|
+
|
|
106
135
|
return rows
|
|
107
136
|
}
|
|
108
137
|
|
package/tui/main.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// something to run; this draws the first frame and then imports boot.mjs, the
|
|
3
|
-
// engine side, behind it.
|
|
1
|
+
// the TUI itself: draws the first frame, then imports boot.mjs, the engine side, behind it
|
|
4
2
|
import fs from 'bare-fs'
|
|
5
3
|
import os from 'bare-os'
|
|
6
4
|
import process from 'bare-process'
|
|
@@ -13,16 +11,10 @@ import b4a from 'b4a'
|
|
|
13
11
|
|
|
14
12
|
const { Program } = tui
|
|
15
13
|
|
|
16
|
-
//
|
|
17
|
-
// writes a real one in a single read, so this only has to beat human perception
|
|
14
|
+
// the terminal writes a real sequence in one read, so this only has to beat human perception
|
|
18
15
|
const ESCAPE_TIMEOUT_MS = 50
|
|
19
16
|
|
|
20
|
-
//
|
|
21
|
-
// console — bare-tui's Program owns the terminal via cursor-tracked ANSI
|
|
22
|
-
// output, so any other writer to the same fd corrupts the redraw. Silence
|
|
23
|
-
// console output for the TUI's lifetime; errors after it exits still print.
|
|
24
|
-
// (llama.cpp's own native stdout logs are a separate path, not covered by
|
|
25
|
-
// this — see assistant-harness/lib/sdk-loader.ts.)
|
|
17
|
+
// any other writer to the tty corrupts bare-tui's redraw; errors after exit still print
|
|
26
18
|
function withConsoleSuppressed(fn) {
|
|
27
19
|
const original = {
|
|
28
20
|
log: console.log,
|
|
@@ -39,22 +31,18 @@ function withConsoleSuppressed(fn) {
|
|
|
39
31
|
error: noop,
|
|
40
32
|
debug: noop
|
|
41
33
|
})
|
|
34
|
+
|
|
42
35
|
return fn().finally(() => Object.assign(console, original))
|
|
43
36
|
}
|
|
44
37
|
|
|
45
|
-
// llama.cpp writes
|
|
46
|
-
// stdout/stderr fd (see assistant-harness/lib/sdk-loader.ts) — that bypasses
|
|
47
|
-
// both withConsoleSuppressed below AND bare-tui's Renderer, which only
|
|
48
|
-
// repaints rows whose logical content changed and has no idea those rows got
|
|
49
|
-
// clobbered by an external writer. Sending a synthetic resize forces the
|
|
50
|
-
// same full repaint Program already does on a real terminal resize, wiping
|
|
51
|
-
// any leaked lines. `getProgram` is a thunk because this is wired up before
|
|
52
|
-
// Program exists.
|
|
38
|
+
// llama.cpp writes straight to the tty fd; a synthetic resize forces a full repaint over its lines
|
|
53
39
|
function requestRepaint(getProgram) {
|
|
54
40
|
const program = getProgram()
|
|
55
|
-
if (!program)
|
|
56
|
-
|
|
57
|
-
|
|
41
|
+
if (!program) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// || not ??: a size-less pty reports 0 columns, and 0-width style math hits repeat(-2)
|
|
58
46
|
program.send({
|
|
59
47
|
type: 'resize',
|
|
60
48
|
width: program.output.columns || 80,
|
|
@@ -62,26 +50,25 @@ function requestRepaint(getProgram) {
|
|
|
62
50
|
})
|
|
63
51
|
}
|
|
64
52
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
53
|
+
const CLIPBOARD_COMMANDS = {
|
|
54
|
+
darwin: [['pbcopy', []]],
|
|
55
|
+
win32: [['clip', []]],
|
|
56
|
+
linux: [
|
|
57
|
+
['wl-copy', []],
|
|
58
|
+
['xclip', ['-selection', 'clipboard']]
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// piped to the platform clipboard command so nothing reaches the tty; first to exit 0 wins
|
|
69
63
|
function copyToClipboard(text) {
|
|
70
|
-
const commands =
|
|
71
|
-
process.platform === 'darwin'
|
|
72
|
-
? [['pbcopy', []]]
|
|
73
|
-
: process.platform === 'win32'
|
|
74
|
-
? [['clip', []]]
|
|
75
|
-
: [
|
|
76
|
-
['wl-copy', []],
|
|
77
|
-
['xclip', ['-selection', 'clipboard']]
|
|
78
|
-
]
|
|
64
|
+
const commands = CLIPBOARD_COMMANDS[process.platform] ?? CLIPBOARD_COMMANDS.linux
|
|
79
65
|
return new Promise((resolve, reject) => {
|
|
80
66
|
const attempt = (i) => {
|
|
81
67
|
if (i >= commands.length) {
|
|
82
68
|
reject(new Error('no clipboard command available'))
|
|
83
69
|
return
|
|
84
70
|
}
|
|
71
|
+
|
|
85
72
|
const [cmd, args] = commands[i]
|
|
86
73
|
let child
|
|
87
74
|
try {
|
|
@@ -90,9 +77,10 @@ function copyToClipboard(text) {
|
|
|
90
77
|
attempt(i + 1)
|
|
91
78
|
return
|
|
92
79
|
}
|
|
80
|
+
|
|
93
81
|
child.on('error', () => attempt(i + 1))
|
|
94
82
|
child.on('exit', (code) => (code === 0 ? resolve() : attempt(i + 1)))
|
|
95
|
-
child.stdin.write(
|
|
83
|
+
child.stdin.write(b4a.from(text))
|
|
96
84
|
child.stdin.end()
|
|
97
85
|
}
|
|
98
86
|
attempt(0)
|
|
@@ -113,6 +101,7 @@ function readClipboard() {
|
|
|
113
101
|
reject(new Error('no clipboard command available'))
|
|
114
102
|
return
|
|
115
103
|
}
|
|
104
|
+
|
|
116
105
|
const [cmd, args] = commands[i]
|
|
117
106
|
let child
|
|
118
107
|
try {
|
|
@@ -121,11 +110,12 @@ function readClipboard() {
|
|
|
121
110
|
attempt(i + 1)
|
|
122
111
|
return
|
|
123
112
|
}
|
|
113
|
+
|
|
124
114
|
const out = []
|
|
125
115
|
child.stdout.on('data', (data) => out.push(data))
|
|
126
116
|
child.on('error', () => attempt(i + 1))
|
|
127
117
|
child.on('exit', (code) =>
|
|
128
|
-
code === 0 ? resolve(
|
|
118
|
+
code === 0 ? resolve(b4a.concat(out).toString()) : attempt(i + 1)
|
|
129
119
|
)
|
|
130
120
|
}
|
|
131
121
|
attempt(0)
|
|
@@ -148,14 +138,13 @@ const MIME_TYPES = new Map([
|
|
|
148
138
|
// the engine's own cap (lib/core/files/attachments.ts); a lower one here refused files it takes
|
|
149
139
|
const MAX_ATTACHMENT_BYTES = 100 * 1024 * 1024
|
|
150
140
|
|
|
151
|
-
//
|
|
152
|
-
// "copy" in a file manager and drag-to-terminal produce) becomes an
|
|
153
|
-
// attachment; anything else is null and the shortcut just says so. Raw
|
|
154
|
-
// image DATA on the clipboard has no portable tty-side accessor — copy the
|
|
155
|
-
// file, not the pixels.
|
|
141
|
+
// raw image data on the clipboard has no portable tty-side accessor, so only file paths attach
|
|
156
142
|
async function resolvePastedFile() {
|
|
157
143
|
const text = (await readClipboard()).trim()
|
|
158
|
-
if (!text || text.includes('\n'))
|
|
144
|
+
if (!text || text.includes('\n')) {
|
|
145
|
+
return null
|
|
146
|
+
}
|
|
147
|
+
|
|
159
148
|
const file = expandFilePath(text)
|
|
160
149
|
let stat
|
|
161
150
|
try {
|
|
@@ -163,7 +152,11 @@ async function resolvePastedFile() {
|
|
|
163
152
|
} catch {
|
|
164
153
|
return null
|
|
165
154
|
}
|
|
166
|
-
|
|
155
|
+
|
|
156
|
+
if (!stat.isFile()) {
|
|
157
|
+
return null
|
|
158
|
+
}
|
|
159
|
+
|
|
167
160
|
return fileToAttachment(file, stat)
|
|
168
161
|
}
|
|
169
162
|
|
|
@@ -182,6 +175,7 @@ function fileToAttachment(file, stat = fs.statSync(file)) {
|
|
|
182
175
|
if (stat.size > MAX_ATTACHMENT_BYTES) {
|
|
183
176
|
throw new Error(`file too large (${MAX_ATTACHMENT_BYTES / (1024 * 1024)}MB cap)`)
|
|
184
177
|
}
|
|
178
|
+
|
|
185
179
|
return {
|
|
186
180
|
fileName: path.basename(file),
|
|
187
181
|
mimeType: MIME_TYPES.get(path.extname(file).toLowerCase()) ?? 'application/octet-stream',
|
|
@@ -189,13 +183,7 @@ function fileToAttachment(file, stat = fs.statSync(file)) {
|
|
|
189
183
|
}
|
|
190
184
|
}
|
|
191
185
|
|
|
192
|
-
//
|
|
193
|
-
// throwaway > the persistent global default. Joining a mesh is /join inside the
|
|
194
|
-
// app — the engine takes an invite live, so it never needed to be a flag.
|
|
195
|
-
// Boot-timing report (QVAC_BOOT_TIMING=1): per-stage stamps from the sidecar
|
|
196
|
-
// bring-up (see lib/boot-timing.mjs), plus the host's own connect wall time.
|
|
197
|
-
// The TUI calls this only once it has released the tty, so it never fights
|
|
198
|
-
// bare-tui's live render.
|
|
186
|
+
// called only once the TUI released the tty, so it never fights bare-tui's live render
|
|
199
187
|
function printBootTiming(booted) {
|
|
200
188
|
if (process.env.QVAC_BOOT_TIMING !== '1' || !booted) return
|
|
201
189
|
const lines = [
|
|
@@ -205,7 +193,7 @@ function printBootTiming(booted) {
|
|
|
205
193
|
console.log(`\nboot timing:\n${lines.join('\n')}`)
|
|
206
194
|
}
|
|
207
195
|
|
|
208
|
-
export
|
|
196
|
+
export function main(args) {
|
|
209
197
|
run(args).catch((err) => {
|
|
210
198
|
console.error(err)
|
|
211
199
|
Bare.exit(1)
|
|
@@ -216,27 +204,18 @@ async function run(args) {
|
|
|
216
204
|
let program
|
|
217
205
|
// the engine side, once it is up: its teardown, and what the boot report prints
|
|
218
206
|
let booted = null
|
|
219
|
-
//
|
|
220
|
-
// init()), so the terminal shows the app's own "starting up…" frame instead
|
|
221
|
-
// of a pre-render status line — console is suppressed for run()'s lifetime
|
|
222
|
-
// below, so the SDK's boot logs can't corrupt the render. boot.mjs and the
|
|
223
|
-
// ~1200 modules behind it are imported here, after that frame, not before.
|
|
224
|
-
// The app never mints an agent: a fresh mesh seeds its default at birth
|
|
225
|
-
// (contract/seed-defaults.ts) and a joiner waits for it to replicate; the
|
|
226
|
-
// provider applies the QVAC_MODEL override only when one is set.
|
|
207
|
+
// bring-up runs inside the TUI so its "starting up…" frame shows while ~1200 modules load
|
|
227
208
|
const connect = async () => {
|
|
228
|
-
const {
|
|
209
|
+
const { boot } = await import('./boot.mjs')
|
|
229
210
|
booted = await boot(args)
|
|
230
211
|
const { engine, skills, deviceId, meshInvite, modelName } = booted
|
|
212
|
+
|
|
231
213
|
return { engine, skills, deviceId, meshInvite, modelName }
|
|
232
214
|
}
|
|
233
215
|
|
|
234
|
-
//
|
|
235
|
-
// invite another instance joins with, then park — the engine's own handles
|
|
236
|
-
// hold the loop open and its logs stream to stdout until a signal arrives.
|
|
216
|
+
// the engine's own handles hold the loop open until a signal arrives
|
|
237
217
|
if (args.headless) {
|
|
238
|
-
// armed before connect
|
|
239
|
-
// model download still unwinds cleanly (nothing to tear down until then)
|
|
218
|
+
// armed before connect so a ctrl+C during a first-run model download still unwinds cleanly
|
|
240
219
|
const shutdown = async () => {
|
|
241
220
|
await booted?.close()
|
|
242
221
|
Bare.exit(0)
|
|
@@ -249,6 +228,7 @@ async function run(args) {
|
|
|
249
228
|
console.log(`device ${booted.deviceName} ${b4a.toHex(deviceId)}`)
|
|
250
229
|
console.log(`invite ${meshInvite ?? '(none — mesh not writable)'}`)
|
|
251
230
|
printBootTiming(booted)
|
|
231
|
+
|
|
252
232
|
return
|
|
253
233
|
}
|
|
254
234
|
|
|
@@ -259,20 +239,18 @@ async function run(args) {
|
|
|
259
239
|
resolvePastedFile,
|
|
260
240
|
resolveFileAttachment
|
|
261
241
|
})
|
|
262
|
-
//
|
|
263
|
-
// into ↑/↓ keys: the transcript scrolls, and it selects its own text (the
|
|
264
|
-
// terminal can't while tracking is on) — see ChatApp._select
|
|
242
|
+
// the transcript selects its own text, since the terminal can't while mouse tracking is on
|
|
265
243
|
program = new Program(app, { mouse: 'drag' })
|
|
266
|
-
// bracketed paste
|
|
267
|
-
// instead of per-line key events submitting each pasted line
|
|
244
|
+
// bracketed paste, or each pasted line arrives as keys and submits itself
|
|
268
245
|
program.output.write('\x1b[?2004h')
|
|
269
246
|
try {
|
|
270
247
|
await withConsoleSuppressed(() => {
|
|
271
248
|
const running = program.run()
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
249
|
+
// bare-tui cannot configure the decoder, whose 500ms esc timeout delays every overlay close
|
|
250
|
+
if (program._decoder) {
|
|
251
|
+
program._decoder._escapeDelay = ESCAPE_TIMEOUT_MS
|
|
252
|
+
}
|
|
253
|
+
|
|
276
254
|
return running
|
|
277
255
|
})
|
|
278
256
|
} finally {
|
|
@@ -281,8 +259,6 @@ async function run(args) {
|
|
|
281
259
|
|
|
282
260
|
await booted?.close()
|
|
283
261
|
printBootTiming(booted)
|
|
284
|
-
//
|
|
285
|
-
// unwind a blocking native call (e.g. a model still loading) before its loop
|
|
286
|
-
// drains; close() has already torn the sidecar down.
|
|
262
|
+
// don't wait for the child to unwind a blocking native call; close() already tore the sidecar down
|
|
287
263
|
Bare.exit(0)
|
|
288
264
|
}
|