@qvac/core 0.0.0 → 0.1.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/LICENSE.md +198 -0
- package/NOTICE.md +13 -0
- package/README.md +694 -0
- package/SECURITY.md +6 -0
- package/dist/assistant.bundle +47256 -0
- package/dist/assistant.cjs +18 -0
- package/dist/assistant.d.ts +8 -0
- package/dist/prebuilds-manifest.json +380 -0
- package/dist-lib/client.d.ts +2 -0
- package/dist-lib/client.js +1 -0
- package/dist-lib/index.d.ts +13 -0
- package/dist-lib/index.js +10 -0
- package/dist-lib/lib/agent-icons.d.ts +3 -0
- package/dist-lib/lib/agent-icons.js +1 -0
- package/dist-lib/lib/api/agents.d.ts +5 -0
- package/dist-lib/lib/api/agents.js +38 -0
- package/dist-lib/lib/api/app-config.d.ts +5 -0
- package/dist-lib/lib/api/app-config.js +108 -0
- package/dist-lib/lib/api/approval-rules.d.ts +3 -0
- package/dist-lib/lib/api/approval-rules.js +9 -0
- package/dist-lib/lib/api/attachments.d.ts +8 -0
- package/dist-lib/lib/api/attachments.js +15 -0
- package/dist-lib/lib/api/chat-groups.d.ts +5 -0
- package/dist-lib/lib/api/chat-groups.js +12 -0
- package/dist-lib/lib/api/chat.d.ts +5 -0
- package/dist-lib/lib/api/chat.js +38 -0
- package/dist-lib/lib/api/chunks.d.ts +5 -0
- package/dist-lib/lib/api/chunks.js +61 -0
- package/dist-lib/lib/api/config.d.ts +5 -0
- package/dist-lib/lib/api/config.js +15 -0
- package/dist-lib/lib/api/current-mesh.d.ts +5 -0
- package/dist-lib/lib/api/current-mesh.js +12 -0
- package/dist-lib/lib/api/custom-models.d.ts +5 -0
- package/dist-lib/lib/api/custom-models.js +45 -0
- package/dist-lib/lib/api/devices.d.ts +8 -0
- package/dist-lib/lib/api/devices.js +125 -0
- package/dist-lib/lib/api/diagnostics.d.ts +7 -0
- package/dist-lib/lib/api/diagnostics.js +7 -0
- package/dist-lib/lib/api/effective-ctx-size.d.ts +2 -0
- package/dist-lib/lib/api/effective-ctx-size.js +10 -0
- package/dist-lib/lib/api/execution.d.ts +3 -0
- package/dist-lib/lib/api/execution.js +45 -0
- package/dist-lib/lib/api/files.d.ts +3 -0
- package/dist-lib/lib/api/files.js +48 -0
- package/dist-lib/lib/api/index.d.ts +62 -0
- package/dist-lib/lib/api/index.js +172 -0
- package/dist-lib/lib/api/instrument.d.ts +2 -0
- package/dist-lib/lib/api/instrument.js +86 -0
- package/dist-lib/lib/api/knowledge.d.ts +8 -0
- package/dist-lib/lib/api/knowledge.js +26 -0
- package/dist-lib/lib/api/logs.d.ts +14 -0
- package/dist-lib/lib/api/logs.js +116 -0
- package/dist-lib/lib/api/mesh.d.ts +13 -0
- package/dist-lib/lib/api/mesh.js +25 -0
- package/dist-lib/lib/api/model-download.d.ts +5 -0
- package/dist-lib/lib/api/model-download.js +47 -0
- package/dist-lib/lib/api/network.d.ts +8 -0
- package/dist-lib/lib/api/network.js +6 -0
- package/dist-lib/lib/api/notifications.d.ts +21 -0
- package/dist-lib/lib/api/notifications.js +108 -0
- package/dist-lib/lib/api/rag.d.ts +7 -0
- package/dist-lib/lib/api/rag.js +216 -0
- package/dist-lib/lib/api/sync.d.ts +3 -0
- package/dist-lib/lib/api/sync.js +6 -0
- package/dist-lib/lib/api/tool-activity.d.ts +5 -0
- package/dist-lib/lib/api/tool-activity.js +53 -0
- package/dist-lib/lib/api/tool-configs.d.ts +6 -0
- package/dist-lib/lib/api/tool-configs.js +27 -0
- package/dist-lib/lib/api/watchable.d.ts +12 -0
- package/dist-lib/lib/api/watchable.js +121 -0
- package/dist-lib/lib/assistant-client.d.ts +21 -0
- package/dist-lib/lib/assistant-client.js +52 -0
- package/dist-lib/lib/assistant-tree.d.ts +50 -0
- package/dist-lib/lib/assistant-tree.js +184 -0
- package/dist-lib/lib/assistant.d.ts +425 -0
- package/dist-lib/lib/assistant.js +2706 -0
- package/dist-lib/lib/audio-format.d.ts +4 -0
- package/dist-lib/lib/audio-format.js +4 -0
- package/dist-lib/lib/chat-title.d.ts +5 -0
- package/dist-lib/lib/chat-title.js +58 -0
- package/dist-lib/lib/client.d.ts +25 -0
- package/dist-lib/lib/client.js +53 -0
- package/dist-lib/lib/collabora/convert.d.ts +9 -0
- package/dist-lib/lib/collabora/convert.js +62 -0
- package/dist-lib/lib/collabora/entry.d.ts +1 -0
- package/dist-lib/lib/collabora/entry.js +44 -0
- package/dist-lib/lib/collabora/protocol.d.ts +15 -0
- package/dist-lib/lib/collabora/protocol.js +24 -0
- package/dist-lib/lib/collabora/worker.d.ts +5 -0
- package/dist-lib/lib/collabora/worker.js +111 -0
- package/dist-lib/lib/compaction.d.ts +30 -0
- package/dist-lib/lib/compaction.js +95 -0
- package/dist-lib/lib/constants.d.ts +4 -0
- package/dist-lib/lib/constants.js +4 -0
- package/dist-lib/lib/core/agent.d.ts +15 -0
- package/dist-lib/lib/core/agent.js +149 -0
- package/dist-lib/lib/core/app-build.d.ts +7 -0
- package/dist-lib/lib/core/app-build.js +1 -0
- package/dist-lib/lib/core/approval-rules.d.ts +15 -0
- package/dist-lib/lib/core/approval-rules.js +41 -0
- package/dist-lib/lib/core/async-iterable.d.ts +13 -0
- package/dist-lib/lib/core/async-iterable.js +65 -0
- package/dist-lib/lib/core/attachment-link.d.ts +7 -0
- package/dist-lib/lib/core/attachment-link.js +6 -0
- package/dist-lib/lib/core/audio-attachment.d.ts +1 -0
- package/dist-lib/lib/core/audio-attachment.js +4 -0
- package/dist-lib/lib/core/blind-peers.d.ts +6 -0
- package/dist-lib/lib/core/blind-peers.js +13 -0
- package/dist-lib/lib/core/chat-activity.d.ts +7 -0
- package/dist-lib/lib/core/chat-activity.js +244 -0
- package/dist-lib/lib/core/chat-group.d.ts +14 -0
- package/dist-lib/lib/core/chat-group.js +79 -0
- package/dist-lib/lib/core/chat-search.d.ts +17 -0
- package/dist-lib/lib/core/chat-search.js +199 -0
- package/dist-lib/lib/core/chat.d.ts +37 -0
- package/dist-lib/lib/core/chat.js +196 -0
- package/dist-lib/lib/core/chunk.d.ts +61 -0
- package/dist-lib/lib/core/chunk.js +212 -0
- package/dist-lib/lib/core/contract/activity.d.ts +11 -0
- package/dist-lib/lib/core/contract/activity.js +45 -0
- package/dist-lib/lib/core/contract/agents.d.ts +2 -0
- package/dist-lib/lib/core/contract/agents.js +29 -0
- package/dist-lib/lib/core/contract/approval-rules.d.ts +2 -0
- package/dist-lib/lib/core/contract/approval-rules.js +14 -0
- package/dist-lib/lib/core/contract/attestations.d.ts +2 -0
- package/dist-lib/lib/core/contract/attestations.js +14 -0
- package/dist-lib/lib/core/contract/chat-group.d.ts +2 -0
- package/dist-lib/lib/core/contract/chat-group.js +20 -0
- package/dist-lib/lib/core/contract/chat.d.ts +2 -0
- package/dist-lib/lib/core/contract/chat.js +18 -0
- package/dist-lib/lib/core/contract/chunks.d.ts +2 -0
- package/dist-lib/lib/core/contract/chunks.js +156 -0
- package/dist-lib/lib/core/contract/devices.d.ts +2 -0
- package/dist-lib/lib/core/contract/devices.js +110 -0
- package/dist-lib/lib/core/contract/index.d.ts +2 -0
- package/dist-lib/lib/core/contract/index.js +30 -0
- package/dist-lib/lib/core/contract/indexing.d.ts +4 -0
- package/dist-lib/lib/core/contract/indexing.js +82 -0
- package/dist-lib/lib/core/contract/knowledge.d.ts +2 -0
- package/dist-lib/lib/core/contract/knowledge.js +55 -0
- package/dist-lib/lib/core/contract/members.d.ts +2 -0
- package/dist-lib/lib/core/contract/members.js +96 -0
- package/dist-lib/lib/core/contract/seed-defaults.d.ts +2 -0
- package/dist-lib/lib/core/contract/seed-defaults.js +29 -0
- package/dist-lib/lib/core/contract/tool-activity.d.ts +2 -0
- package/dist-lib/lib/core/contract/tool-activity.js +25 -0
- package/dist-lib/lib/core/contract/tool-configs.d.ts +2 -0
- package/dist-lib/lib/core/contract/tool-configs.js +50 -0
- package/dist-lib/lib/core/contract/types.d.ts +11 -0
- package/dist-lib/lib/core/contract/types.js +1 -0
- package/dist-lib/lib/core/contract/writers.d.ts +2 -0
- package/dist-lib/lib/core/contract/writers.js +112 -0
- package/dist-lib/lib/core/cpu-info-node.d.ts +3 -0
- package/dist-lib/lib/core/cpu-info-node.js +2 -0
- package/dist-lib/lib/core/departures.d.ts +41 -0
- package/dist-lib/lib/core/departures.js +145 -0
- package/dist-lib/lib/core/device-attestation.d.ts +6 -0
- package/dist-lib/lib/core/device-attestation.js +12 -0
- package/dist-lib/lib/core/devices.d.ts +14 -0
- package/dist-lib/lib/core/devices.js +11 -0
- package/dist-lib/lib/core/document-attachment.d.ts +22 -0
- package/dist-lib/lib/core/document-attachment.js +35 -0
- package/dist-lib/lib/core/files/attachments.d.ts +8 -0
- package/dist-lib/lib/core/files/attachments.js +50 -0
- package/dist-lib/lib/core/files/index.d.ts +133 -0
- package/dist-lib/lib/core/files/index.js +585 -0
- package/dist-lib/lib/core/files/knowledge.d.ts +9 -0
- package/dist-lib/lib/core/files/knowledge.js +31 -0
- package/dist-lib/lib/core/files/preview/image.d.ts +4 -0
- package/dist-lib/lib/core/files/preview/image.js +42 -0
- package/dist-lib/lib/core/files/preview/index.d.ts +33 -0
- package/dist-lib/lib/core/files/preview/index.js +161 -0
- package/dist-lib/lib/core/files/processing/claims.d.ts +26 -0
- package/dist-lib/lib/core/files/processing/claims.js +89 -0
- package/dist-lib/lib/core/files/processing/document.d.ts +100 -0
- package/dist-lib/lib/core/files/processing/document.js +101 -0
- package/dist-lib/lib/core/files/processing/index.d.ts +75 -0
- package/dist-lib/lib/core/files/processing/index.js +295 -0
- package/dist-lib/lib/core/files/processing/ownership.d.ts +11 -0
- package/dist-lib/lib/core/files/processing/ownership.js +41 -0
- package/dist-lib/lib/core/files/processing/protocol.d.ts +29 -0
- package/dist-lib/lib/core/files/processing/protocol.js +70 -0
- package/dist-lib/lib/core/files/processing/settle.d.ts +10 -0
- package/dist-lib/lib/core/files/processing/settle.js +75 -0
- package/dist-lib/lib/core/files/processing/source.d.ts +36 -0
- package/dist-lib/lib/core/files/processing/source.js +96 -0
- package/dist-lib/lib/core/files/processing/state.d.ts +64 -0
- package/dist-lib/lib/core/files/processing/state.js +118 -0
- package/dist-lib/lib/core/files/rag/artifact/codec.d.ts +3 -0
- package/dist-lib/lib/core/files/rag/artifact/codec.js +172 -0
- package/dist-lib/lib/core/files/rag/artifact/id.d.ts +10 -0
- package/dist-lib/lib/core/files/rag/artifact/id.js +39 -0
- package/dist-lib/lib/core/files/rag/artifact/types.d.ts +24 -0
- package/dist-lib/lib/core/files/rag/artifact/types.js +41 -0
- package/dist-lib/lib/core/files/rag/build.d.ts +25 -0
- package/dist-lib/lib/core/files/rag/build.js +60 -0
- package/dist-lib/lib/core/files/rag/chunk/chunking.d.ts +12 -0
- package/dist-lib/lib/core/files/rag/chunk/chunking.js +117 -0
- package/dist-lib/lib/core/files/rag/chunk/metadata.d.ts +30 -0
- package/dist-lib/lib/core/files/rag/chunk/metadata.js +89 -0
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.d.ts +7 -0
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.js +18 -0
- package/dist-lib/lib/core/files/rag/document-types.d.ts +11 -0
- package/dist-lib/lib/core/files/rag/document-types.js +94 -0
- package/dist-lib/lib/core/files/rag/extract/csv-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/csv-text.js +117 -0
- package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +22 -0
- package/dist-lib/lib/core/files/rag/extract/document-types.js +152 -0
- package/dist-lib/lib/core/files/rag/extract/extract.d.ts +17 -0
- package/dist-lib/lib/core/files/rag/extract/extract.js +81 -0
- package/dist-lib/lib/core/files/rag/extract/html-table-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/html-table-text.js +125 -0
- package/dist-lib/lib/core/files/rag/extract/html-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/html-text.js +132 -0
- package/dist-lib/lib/core/files/rag/extract/office-collabora.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/extract/office-collabora.js +8 -0
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.d.ts +17 -0
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +141 -0
- package/dist-lib/lib/core/files/rag/extract/pdf-text.d.ts +12 -0
- package/dist-lib/lib/core/files/rag/extract/pdf-text.js +43 -0
- package/dist-lib/lib/core/files/rag/extract/rtf-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/rtf-text.js +15 -0
- package/dist-lib/lib/core/files/rag/extract/text-decoding.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/extract/text-decoding.js +91 -0
- package/dist-lib/lib/core/files/rag/extract/types.d.ts +36 -0
- package/dist-lib/lib/core/files/rag/extract/types.js +12 -0
- package/dist-lib/lib/core/files/rag/extract/utf.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/extract/utf.js +18 -0
- package/dist-lib/lib/core/files/rag/index.d.ts +54 -0
- package/dist-lib/lib/core/files/rag/index.js +79 -0
- package/dist-lib/lib/core/files/rag/limits.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/limits.js +2 -0
- package/dist-lib/lib/core/files/rag/load.d.ts +28 -0
- package/dist-lib/lib/core/files/rag/load.js +250 -0
- package/dist-lib/lib/core/files/rag/models.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/models.js +1 -0
- package/dist-lib/lib/core/files/rag/policy.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/policy.js +23 -0
- package/dist-lib/lib/core/files/rag/produce.d.ts +21 -0
- package/dist-lib/lib/core/files/rag/produce.js +214 -0
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.js +16 -0
- package/dist-lib/lib/core/files/rag/retrieval/coverage.d.ts +4 -0
- package/dist-lib/lib/core/files/rag/retrieval/coverage.js +48 -0
- package/dist-lib/lib/core/files/rag/retrieval/diversity.d.ts +10 -0
- package/dist-lib/lib/core/files/rag/retrieval/diversity.js +37 -0
- package/dist-lib/lib/core/files/rag/retrieval/floor.d.ts +5 -0
- package/dist-lib/lib/core/files/rag/retrieval/floor.js +21 -0
- package/dist-lib/lib/core/files/rag/retrieval/format.d.ts +6 -0
- package/dist-lib/lib/core/files/rag/retrieval/format.js +21 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +22 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +137 -0
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +53 -0
- package/dist-lib/lib/core/files/rag/retrieval/notices.d.ts +16 -0
- package/dist-lib/lib/core/files/rag/retrieval/notices.js +27 -0
- package/dist-lib/lib/core/files/rag/retrieval/scoring.d.ts +8 -0
- package/dist-lib/lib/core/files/rag/retrieval/scoring.js +82 -0
- package/dist-lib/lib/core/files/rag/retrieval/search.d.ts +3 -0
- package/dist-lib/lib/core/files/rag/retrieval/search.js +46 -0
- package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +10 -0
- package/dist-lib/lib/core/files/rag/retrieval/selection.js +63 -0
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.d.ts +6 -0
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.js +79 -0
- package/dist-lib/lib/core/files/rag/retrieval/sources.d.ts +13 -0
- package/dist-lib/lib/core/files/rag/retrieval/sources.js +20 -0
- package/dist-lib/lib/core/files/rag/retrieval/target.d.ts +13 -0
- package/dist-lib/lib/core/files/rag/retrieval/target.js +89 -0
- package/dist-lib/lib/core/files/rag/retrieval/terms.d.ts +8 -0
- package/dist-lib/lib/core/files/rag/retrieval/terms.js +70 -0
- package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +28 -0
- package/dist-lib/lib/core/files/rag/retrieval/types.js +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.d.ts +8 -0
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +41 -0
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.js +96 -0
- package/dist-lib/lib/core/files/rag/vector/memory.d.ts +15 -0
- package/dist-lib/lib/core/files/rag/vector/memory.js +135 -0
- package/dist-lib/lib/core/files/rag/vector/types.d.ts +28 -0
- package/dist-lib/lib/core/files/rag/vector/types.js +1 -0
- package/dist-lib/lib/core/files/records/chunks.d.ts +3 -0
- package/dist-lib/lib/core/files/records/chunks.js +12 -0
- package/dist-lib/lib/core/files/records/index.d.ts +10 -0
- package/dist-lib/lib/core/files/records/index.js +8 -0
- package/dist-lib/lib/core/files/records/knowledge.d.ts +22 -0
- package/dist-lib/lib/core/files/records/knowledge.js +105 -0
- package/dist-lib/lib/core/files/records/linkage.d.ts +11 -0
- package/dist-lib/lib/core/files/records/linkage.js +27 -0
- package/dist-lib/lib/core/files/records/output.d.ts +8 -0
- package/dist-lib/lib/core/files/records/output.js +38 -0
- package/dist-lib/lib/core/files/records/reclaim.d.ts +5 -0
- package/dist-lib/lib/core/files/records/reclaim.js +73 -0
- package/dist-lib/lib/core/files/records/routing.d.ts +23 -0
- package/dist-lib/lib/core/files/records/routing.js +62 -0
- package/dist-lib/lib/core/files/records/source.d.ts +16 -0
- package/dist-lib/lib/core/files/records/source.js +70 -0
- package/dist-lib/lib/core/files/records/sweep.d.ts +2 -0
- package/dist-lib/lib/core/files/records/sweep.js +30 -0
- package/dist-lib/lib/core/files/store/blob.d.ts +29 -0
- package/dist-lib/lib/core/files/store/blob.js +98 -0
- package/dist-lib/lib/core/files/store/index.d.ts +36 -0
- package/dist-lib/lib/core/files/store/index.js +89 -0
- package/dist-lib/lib/core/files/store/inline.d.ts +8 -0
- package/dist-lib/lib/core/files/store/inline.js +38 -0
- package/dist-lib/lib/core/files/store/reference.d.ts +27 -0
- package/dist-lib/lib/core/files/store/reference.js +168 -0
- package/dist-lib/lib/core/files/store/server.d.ts +27 -0
- package/dist-lib/lib/core/files/store/server.js +114 -0
- package/dist-lib/lib/core/files/store/sweep.d.ts +2 -0
- package/dist-lib/lib/core/files/store/sweep.js +45 -0
- package/dist-lib/lib/core/files/upload-input.d.ts +27 -0
- package/dist-lib/lib/core/files/upload-input.js +52 -0
- package/dist-lib/lib/core/files/upload.d.ts +32 -0
- package/dist-lib/lib/core/files/upload.js +201 -0
- package/dist-lib/lib/core/fs-drives.d.ts +18 -0
- package/dist-lib/lib/core/fs-drives.js +58 -0
- package/dist-lib/lib/core/gpu-info-node.d.ts +3 -0
- package/dist-lib/lib/core/gpu-info-node.js +2 -0
- package/dist-lib/lib/core/handoff-channel.d.ts +46 -0
- package/dist-lib/lib/core/handoff-channel.js +102 -0
- package/dist-lib/lib/core/health-assistant.d.ts +7 -0
- package/dist-lib/lib/core/health-assistant.js +24 -0
- package/dist-lib/lib/core/helpers/index.d.ts +5 -0
- package/dist-lib/lib/core/helpers/index.js +74 -0
- package/dist-lib/lib/core/hosted-agents.d.ts +36 -0
- package/dist-lib/lib/core/hosted-agents.js +127 -0
- package/dist-lib/lib/core/id.d.ts +1 -0
- package/dist-lib/lib/core/id.js +5 -0
- package/dist-lib/lib/core/identity.d.ts +14 -0
- package/dist-lib/lib/core/identity.js +45 -0
- package/dist-lib/lib/core/image/cache-sweep.d.ts +12 -0
- package/dist-lib/lib/core/image/cache-sweep.js +67 -0
- package/dist-lib/lib/core/image/normalize.d.ts +3 -0
- package/dist-lib/lib/core/image/normalize.js +49 -0
- package/dist-lib/lib/core/image/sniff.d.ts +3 -0
- package/dist-lib/lib/core/image/sniff.js +149 -0
- package/dist-lib/lib/core/invite.d.ts +14 -0
- package/dist-lib/lib/core/invite.js +36 -0
- package/dist-lib/lib/core/local/index.d.ts +71 -0
- package/dist-lib/lib/core/local/index.js +391 -0
- package/dist-lib/lib/core/membership.d.ts +15 -0
- package/dist-lib/lib/core/membership.js +40 -0
- package/dist-lib/lib/core/mesh.d.ts +153 -0
- package/dist-lib/lib/core/mesh.js +509 -0
- package/dist-lib/lib/core/migrations/agent-catalog.d.ts +6 -0
- package/dist-lib/lib/core/migrations/agent-catalog.js +17 -0
- package/dist-lib/lib/core/migrations/index.d.ts +5 -0
- package/dist-lib/lib/core/migrations/index.js +7 -0
- package/dist-lib/lib/core/migrations/membership.d.ts +11 -0
- package/dist-lib/lib/core/migrations/membership.js +26 -0
- package/dist-lib/lib/core/min-version.d.ts +6 -0
- package/dist-lib/lib/core/min-version.js +31 -0
- package/dist-lib/lib/core/next-frame.d.ts +6 -0
- package/dist-lib/lib/core/next-frame.js +27 -0
- package/dist-lib/lib/core/notification.d.ts +6 -0
- package/dist-lib/lib/core/notification.js +162 -0
- package/dist-lib/lib/core/ota-config.d.ts +19 -0
- package/dist-lib/lib/core/ota-config.js +44 -0
- package/dist-lib/lib/core/prompt-history.d.ts +12 -0
- package/dist-lib/lib/core/prompt-history.js +40 -0
- package/dist-lib/lib/core/search-fold.d.ts +1 -0
- package/dist-lib/lib/core/search-fold.js +4 -0
- package/dist-lib/lib/core/secret-handoff.d.ts +17 -0
- package/dist-lib/lib/core/secret-handoff.js +29 -0
- package/dist-lib/lib/core/send.d.ts +18 -0
- package/dist-lib/lib/core/send.js +46 -0
- package/dist-lib/lib/core/skill-overlay-handoff.d.ts +25 -0
- package/dist-lib/lib/core/skill-overlay-handoff.js +50 -0
- package/dist-lib/lib/core/skill-overlay-receiver.d.ts +8 -0
- package/dist-lib/lib/core/skill-overlay-receiver.js +20 -0
- package/dist-lib/lib/core/skill-secrets.d.ts +25 -0
- package/dist-lib/lib/core/skill-secrets.js +79 -0
- package/dist-lib/lib/core/sync/chats.d.ts +3 -0
- package/dist-lib/lib/core/sync/chats.js +5 -0
- package/dist-lib/lib/core/sync/chunks.d.ts +9 -0
- package/dist-lib/lib/core/sync/chunks.js +16 -0
- package/dist-lib/lib/core/sync/devices.d.ts +4 -0
- package/dist-lib/lib/core/sync/devices.js +12 -0
- package/dist-lib/lib/core/sync/files.d.ts +16 -0
- package/dist-lib/lib/core/sync/files.js +109 -0
- package/dist-lib/lib/core/sync/index.d.ts +5 -0
- package/dist-lib/lib/core/sync/index.js +63 -0
- package/dist-lib/lib/core/sync-status.d.ts +17 -0
- package/dist-lib/lib/core/sync-status.js +129 -0
- package/dist-lib/lib/core/system-info.d.ts +24 -0
- package/dist-lib/lib/core/system-info.js +66 -0
- package/dist-lib/lib/core/tool-activity.d.ts +22 -0
- package/dist-lib/lib/core/tool-activity.js +39 -0
- package/dist-lib/lib/core/tool-configs.d.ts +13 -0
- package/dist-lib/lib/core/tool-configs.js +141 -0
- package/dist-lib/lib/core.d.ts +291 -0
- package/dist-lib/lib/core.js +2126 -0
- package/dist-lib/lib/credential-pusher.d.ts +67 -0
- package/dist-lib/lib/credential-pusher.js +290 -0
- package/dist-lib/lib/custom-model-pusher.d.ts +9 -0
- package/dist-lib/lib/custom-model-pusher.js +42 -0
- package/dist-lib/lib/custom-model-source.d.ts +15 -0
- package/dist-lib/lib/custom-model-source.js +46 -0
- package/dist-lib/lib/deadline.d.ts +9 -0
- package/dist-lib/lib/deadline.js +31 -0
- package/dist-lib/lib/diagnostics.d.ts +35 -0
- package/dist-lib/lib/diagnostics.js +14 -0
- package/dist-lib/lib/fetch-node.d.ts +1 -0
- package/dist-lib/lib/fetch-node.js +1 -0
- package/dist-lib/lib/fs-drive-bridge.d.ts +12 -0
- package/dist-lib/lib/fs-drive-bridge.js +186 -0
- package/dist-lib/lib/fs-grant-keys.d.ts +2 -0
- package/dist-lib/lib/fs-grant-keys.js +6 -0
- package/dist-lib/lib/fs-grants.d.ts +10 -0
- package/dist-lib/lib/fs-grants.js +44 -0
- package/dist-lib/lib/image-cache-dir.d.ts +1 -0
- package/dist-lib/lib/image-cache-dir.js +5 -0
- package/dist-lib/lib/integrations/index.d.ts +4 -0
- package/dist-lib/lib/integrations/index.js +3 -0
- package/dist-lib/lib/integrations/mcp-providers.d.ts +12 -0
- package/dist-lib/lib/integrations/mcp-providers.js +22 -0
- package/dist-lib/lib/integrations/oauth-providers.d.ts +14 -0
- package/dist-lib/lib/integrations/oauth-providers.js +116 -0
- package/dist-lib/lib/integrations/setup-routes.d.ts +12 -0
- package/dist-lib/lib/integrations/setup-routes.js +114 -0
- package/dist-lib/lib/knowledge-search.d.ts +7 -0
- package/dist-lib/lib/knowledge-search.js +53 -0
- package/dist-lib/lib/kv-cache-reclaim.d.ts +5 -0
- package/dist-lib/lib/kv-cache-reclaim.js +29 -0
- package/dist-lib/lib/kv-cache.d.ts +18 -0
- package/dist-lib/lib/kv-cache.js +33 -0
- package/dist-lib/lib/legacy-core-domain.d.ts +258 -0
- package/dist-lib/lib/legacy-core-domain.js +1 -0
- package/dist-lib/lib/llm-model-names.d.ts +1 -0
- package/dist-lib/lib/llm-model-names.js +1 -0
- package/dist-lib/lib/log-buffer.d.ts +7 -0
- package/dist-lib/lib/log-buffer.js +16 -0
- package/dist-lib/lib/log-levels.d.ts +7 -0
- package/dist-lib/lib/log-levels.js +1 -0
- package/dist-lib/lib/log.d.ts +60 -0
- package/dist-lib/lib/log.js +149 -0
- package/dist-lib/lib/logger-type.d.ts +13 -0
- package/dist-lib/lib/logger-type.js +1 -0
- package/dist-lib/lib/logger.d.ts +5 -0
- package/dist-lib/lib/logger.js +18 -0
- package/dist-lib/lib/model-catalog-revision.d.ts +9 -0
- package/dist-lib/lib/model-catalog-revision.js +65 -0
- package/dist-lib/lib/model-clamp.d.ts +6 -0
- package/dist-lib/lib/model-clamp.js +20 -0
- package/dist-lib/lib/model-context.d.ts +13 -0
- package/dist-lib/lib/model-context.js +71 -0
- package/dist-lib/lib/model-download-status.d.ts +29 -0
- package/dist-lib/lib/model-download-status.js +56 -0
- package/dist-lib/lib/model-download.d.ts +191 -0
- package/dist-lib/lib/model-download.js +787 -0
- package/dist-lib/lib/oauth/asana.d.ts +35 -0
- package/dist-lib/lib/oauth/asana.js +71 -0
- package/dist-lib/lib/oauth/browser-connect.d.ts +22 -0
- package/dist-lib/lib/oauth/browser-connect.js +83 -0
- package/dist-lib/lib/oauth/client.d.ts +9 -0
- package/dist-lib/lib/oauth/client.js +9 -0
- package/dist-lib/lib/oauth/common.d.ts +38 -0
- package/dist-lib/lib/oauth/common.js +36 -0
- package/dist-lib/lib/oauth/crypto.d.ts +3 -0
- package/dist-lib/lib/oauth/crypto.js +25 -0
- package/dist-lib/lib/oauth/fetch-platform.d.ts +1 -0
- package/dist-lib/lib/oauth/fetch-platform.js +1 -0
- package/dist-lib/lib/oauth/flow-core.d.ts +6 -0
- package/dist-lib/lib/oauth/flow-core.js +37 -0
- package/dist-lib/lib/oauth/flow.d.ts +3 -0
- package/dist-lib/lib/oauth/flow.js +24 -0
- package/dist-lib/lib/oauth/google.d.ts +37 -0
- package/dist-lib/lib/oauth/google.js +77 -0
- package/dist-lib/lib/oauth/host.d.ts +5 -0
- package/dist-lib/lib/oauth/host.js +3 -0
- package/dist-lib/lib/oauth/keys.d.ts +25 -0
- package/dist-lib/lib/oauth/keys.js +93 -0
- package/dist-lib/lib/oauth/loopback.d.ts +3 -0
- package/dist-lib/lib/oauth/loopback.js +119 -0
- package/dist-lib/lib/oauth/loopback.stub.d.ts +3 -0
- package/dist-lib/lib/oauth/loopback.stub.js +6 -0
- package/dist-lib/lib/oauth/notion.d.ts +34 -0
- package/dist-lib/lib/oauth/notion.js +82 -0
- package/dist-lib/lib/oauth/pkce-runtime.d.ts +3 -0
- package/dist-lib/lib/oauth/pkce-runtime.js +5 -0
- package/dist-lib/lib/oauth/pkce.d.ts +8 -0
- package/dist-lib/lib/oauth/pkce.js +6 -0
- package/dist-lib/lib/oauth/providers.d.ts +5 -0
- package/dist-lib/lib/oauth/providers.js +73 -0
- package/dist-lib/lib/oauth/redirect-types.d.ts +19 -0
- package/dist-lib/lib/oauth/redirect-types.js +1 -0
- package/dist-lib/lib/oauth/register.d.ts +3 -0
- package/dist-lib/lib/oauth/register.js +34 -0
- package/dist-lib/lib/oauth/resolve.d.ts +17 -0
- package/dist-lib/lib/oauth/resolve.js +57 -0
- package/dist-lib/lib/oauth/spotify.d.ts +32 -0
- package/dist-lib/lib/oauth/spotify.js +73 -0
- package/dist-lib/lib/oauth/token-exchange-core.d.ts +6 -0
- package/dist-lib/lib/oauth/token-exchange-core.js +97 -0
- package/dist-lib/lib/oauth/token-exchange.d.ts +5 -0
- package/dist-lib/lib/oauth/token-exchange.js +9 -0
- package/dist-lib/lib/oauth/types.d.ts +54 -0
- package/dist-lib/lib/oauth/types.js +1 -0
- package/dist-lib/lib/oauth.client.d.ts +5 -0
- package/dist-lib/lib/oauth.client.js +2 -0
- package/dist-lib/lib/oauth.d.ts +14 -0
- package/dist-lib/lib/oauth.js +12 -0
- package/dist-lib/lib/obsidian-key.d.ts +1 -0
- package/dist-lib/lib/obsidian-key.js +1 -0
- package/dist-lib/lib/race-resource.d.ts +5 -0
- package/dist-lib/lib/race-resource.js +25 -0
- package/dist-lib/lib/reconnecting-watch.d.ts +2 -0
- package/dist-lib/lib/reconnecting-watch.js +78 -0
- package/dist-lib/lib/retry-budget.d.ts +14 -0
- package/dist-lib/lib/retry-budget.js +39 -0
- package/dist-lib/lib/run-notices.d.ts +23 -0
- package/dist-lib/lib/run-notices.js +33 -0
- package/dist-lib/lib/run-transcript.d.ts +35 -0
- package/dist-lib/lib/run-transcript.js +106 -0
- package/dist-lib/lib/skill-readiness.d.ts +2 -0
- package/dist-lib/lib/skill-readiness.js +21 -0
- package/dist-lib/lib/skill-types.d.ts +70 -0
- package/dist-lib/lib/skill-types.js +1 -0
- package/dist-lib/lib/spec-loader.d.ts +14 -0
- package/dist-lib/lib/spec-loader.js +9 -0
- package/dist-lib/lib/suspend-lifecycle.d.ts +17 -0
- package/dist-lib/lib/suspend-lifecycle.js +33 -0
- package/dist-lib/lib/task.d.ts +26 -0
- package/dist-lib/lib/task.js +69 -0
- package/dist-lib/lib/unref.d.ts +3 -0
- package/dist-lib/lib/unref.js +4 -0
- package/dist-lib/lib/wav-duration.d.ts +1 -0
- package/dist-lib/lib/wav-duration.js +53 -0
- package/dist-lib/lib/write-queue.d.ts +22 -0
- package/dist-lib/lib/write-queue.js +39 -0
- package/dist-lib/schema/build.d.ts +1 -0
- package/dist-lib/schema/build.js +120 -0
- package/dist-lib/schema/config.d.ts +4 -0
- package/dist-lib/schema/config.js +7 -0
- package/dist-lib/schema/content.d.ts +20 -0
- package/dist-lib/schema/content.js +122 -0
- package/dist-lib/schema/engine.d.ts +2 -0
- package/dist-lib/schema/engine.js +2013 -0
- package/dist-lib/schema/field-order.d.ts +1 -0
- package/dist-lib/schema/field-order.js +95 -0
- package/dist-lib/schema/local.d.ts +2 -0
- package/dist-lib/schema/local.js +133 -0
- package/dist-lib/schema/qvac.d.ts +22 -0
- package/dist-lib/schema/qvac.js +722 -0
- package/dist-lib/spec/bind.d.ts +2 -0
- package/dist-lib/spec/bind.js +520 -0
- package/dist-lib/spec/calls.d.ts +3 -0
- package/dist-lib/spec/calls.js +129 -0
- package/dist-lib/spec/capabilities.d.ts +263 -0
- package/dist-lib/spec/config/hyperconf/index.d.ts +15 -0
- package/dist-lib/spec/config/hyperconf/index.js +24 -0
- package/dist-lib/spec/config/hyperconf/package.json +3 -0
- package/dist-lib/spec/config/hyperschema/index.js +81 -0
- package/dist-lib/spec/config/hyperschema/schema.json +19 -0
- package/dist-lib/spec/hrpc/hrpc.json +1500 -0
- package/dist-lib/spec/hrpc/index.d.ts +3 -0
- package/dist-lib/spec/hrpc/index.js +1545 -0
- package/dist-lib/spec/hrpc/messages.d.ts +4 -0
- package/dist-lib/spec/hrpc/messages.js +8373 -0
- package/dist-lib/spec/hyperschema/index.d.ts +20 -0
- package/dist-lib/spec/hyperschema/index.js +8373 -0
- package/dist-lib/spec/hyperschema/schema.json +6202 -0
- package/dist-lib/spec/hyperschema/types.d.ts +1545 -0
- package/dist-lib/spec/index.d.ts +36 -0
- package/dist-lib/spec/index.js +6 -0
- package/dist-lib/spec/local/hyperdb/db.json +186 -0
- package/dist-lib/spec/local/hyperdb/index.d.ts +9 -0
- package/dist-lib/spec/local/hyperdb/index.js +855 -0
- package/dist-lib/spec/local/hyperdb/messages.js +2189 -0
- package/dist-lib/spec/local/hyperschema/index.js +1208 -0
- package/dist-lib/spec/local/hyperschema/schema.json +639 -0
- package/dist-lib/spec/local/hyperschema/types.d.ts +159 -0
- package/dist-lib/spec/mesh/hyperdb/db.json +702 -0
- package/dist-lib/spec/mesh/hyperdb/index.d.ts +9 -0
- package/dist-lib/spec/mesh/hyperdb/index.js +2260 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +7453 -0
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +174 -0
- package/dist-lib/spec/mesh/hyperdispatch/index.d.ts +13 -0
- package/dist-lib/spec/mesh/hyperdispatch/index.js +566 -0
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +5713 -0
- package/dist-lib/spec/mesh/hyperschema/index.d.ts +14 -0
- package/dist-lib/spec/mesh/hyperschema/index.js +5713 -0
- package/dist-lib/spec/mesh/hyperschema/schema.json +3142 -0
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +754 -0
- package/ducks.png +0 -0
- package/package.json +332 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { toAsyncIterable } from "../core/async-iterable.js";
|
|
2
|
+
import { normalizeImageForModel } from "../core/image/normalize.js";
|
|
3
|
+
import { detectImageMime } from "../core/image/sniff.js";
|
|
4
|
+
import { createAgentsApi } from "./agents.js";
|
|
5
|
+
import { createApprovalRulesApi } from "./approval-rules.js";
|
|
6
|
+
import { createAttachmentsApi } from "./attachments.js";
|
|
7
|
+
import { createChatApi } from "./chat.js";
|
|
8
|
+
import { createChatGroupsApi } from "./chat-groups.js";
|
|
9
|
+
import { createChunksApi } from "./chunks.js";
|
|
10
|
+
import { createAppConfigApi } from "./app-config.js";
|
|
11
|
+
import { createConfigApi } from "./config.js";
|
|
12
|
+
import { createDevicesApi } from "./devices.js";
|
|
13
|
+
import { createDiagnosticsApi } from "./diagnostics.js";
|
|
14
|
+
import { createExecutionApi } from "./execution.js";
|
|
15
|
+
import { createKnowledgeApi } from "./knowledge.js";
|
|
16
|
+
import { createFilesApi } from "./files.js";
|
|
17
|
+
import { createLogsApi } from "./logs.js";
|
|
18
|
+
import { instrument } from "./instrument.js";
|
|
19
|
+
import { watchable } from "./watchable.js";
|
|
20
|
+
import { createMeshApi } from "./mesh.js";
|
|
21
|
+
import { createNetworkApi } from "./network.js";
|
|
22
|
+
import { createNotificationsApi } from "./notifications.js";
|
|
23
|
+
import { createModelDownloadApi } from "./model-download.js";
|
|
24
|
+
import { createCustomModelApi } from "./custom-models.js";
|
|
25
|
+
import { createRagApi } from "./rag.js";
|
|
26
|
+
import { createSyncApi } from "./sync.js";
|
|
27
|
+
import { createToolActivityApi } from "./tool-activity.js";
|
|
28
|
+
import { createToolConfigsApi } from "./tool-configs.js";
|
|
29
|
+
import { effectiveCtxSize } from "./effective-ctx-size.js";
|
|
30
|
+
export function createApi(deps = {}) {
|
|
31
|
+
const mesh = deps.mesh ?? null;
|
|
32
|
+
const retryModelDownload = deps.retryModelDownload;
|
|
33
|
+
const state = deps.state ?? null;
|
|
34
|
+
return instrument({
|
|
35
|
+
...(state ? createConfigApi(state) : null),
|
|
36
|
+
...(state ? createAppConfigApi(state) : null),
|
|
37
|
+
...(state ? createModelDownloadApi(state) : null),
|
|
38
|
+
...(state ? createCustomModelApi(state) : null),
|
|
39
|
+
...(mesh ? createAgentsApi(mesh, deps.deviceId ?? null) : null),
|
|
40
|
+
...(mesh ? createChatApi(mesh, deps.deviceId ?? null) : null),
|
|
41
|
+
...(mesh ? createChatGroupsApi(mesh) : null),
|
|
42
|
+
...(mesh ? createApprovalRulesApi(mesh) : null),
|
|
43
|
+
...(mesh ? createChunksApi(mesh) : null),
|
|
44
|
+
...(mesh && deps.deviceId && deps.deviceHost
|
|
45
|
+
? createDevicesApi(mesh, deps.deviceId, deps.deviceHost.removeWriter, deps.deviceHost.renameLocal, deps.deviceHost.saveProfileLocal, deps.deviceHost.readLocalProfile)
|
|
46
|
+
: null),
|
|
47
|
+
...(mesh ? createAttachmentsApi(mesh, { deviceId: deps.deviceId }) : null),
|
|
48
|
+
...(mesh ? createKnowledgeApi(mesh, { deviceId: deps.deviceId }) : null),
|
|
49
|
+
...(mesh ? createFilesApi(mesh) : null),
|
|
50
|
+
...(mesh
|
|
51
|
+
? createRagApi(mesh, deps.ragIndex ?? (() => null), deps.ragEmbed ?? (() => null), state
|
|
52
|
+
? async (agent) => effectiveCtxSize(agent, (await state.getAppConfigRow())?.ctxSize ?? 0, deps.platform?.() ?? null)
|
|
53
|
+
: null)
|
|
54
|
+
: null),
|
|
55
|
+
...(mesh && deps.deviceId ? createExecutionApi(mesh, deps.deviceId) : null),
|
|
56
|
+
...(mesh ? createSyncApi(mesh) : null),
|
|
57
|
+
...(mesh ? createToolConfigsApi(mesh) : null),
|
|
58
|
+
...(mesh ? createToolActivityApi(mesh, deps.deviceId ?? null) : null),
|
|
59
|
+
...(mesh && state
|
|
60
|
+
? createNotificationsApi(mesh, state, {
|
|
61
|
+
deviceId: deps.deviceId,
|
|
62
|
+
lifetime: deps.notificationLifetime,
|
|
63
|
+
changes: deps.meshStatus ?? undefined
|
|
64
|
+
})
|
|
65
|
+
: null),
|
|
66
|
+
...(deps.meshStatus ? createMeshApi(deps.meshStatus) : null),
|
|
67
|
+
...(deps.network ? createNetworkApi(deps.network) : null),
|
|
68
|
+
...(deps.diagnostics ? createDiagnosticsApi(deps.diagnostics) : null),
|
|
69
|
+
...(deps.logs ? createLogsApi(deps.logs) : null),
|
|
70
|
+
...(deps.lifecycle
|
|
71
|
+
? {
|
|
72
|
+
suspend: async () => {
|
|
73
|
+
await deps.lifecycle?.suspend();
|
|
74
|
+
return { ok: true };
|
|
75
|
+
},
|
|
76
|
+
resume: async () => {
|
|
77
|
+
await deps.lifecycle?.resume();
|
|
78
|
+
return { ok: true };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
: null),
|
|
82
|
+
transcodeImage,
|
|
83
|
+
...(deps.listModels ? { listModels: deps.listModels } : null),
|
|
84
|
+
...(deps.deleteModel ? { deleteModel: deps.deleteModel } : null),
|
|
85
|
+
...(deps.clearKvCache ? { clearKvCache: deps.clearKvCache } : null),
|
|
86
|
+
...(deps.deleteChatKvCache
|
|
87
|
+
? { deleteChatKvCache: ({ id }) => deps.deleteChatKvCache(id) }
|
|
88
|
+
: null),
|
|
89
|
+
...(deps.compactChat
|
|
90
|
+
? { compactChat: ({ id }) => deps.compactChat(id) }
|
|
91
|
+
: null),
|
|
92
|
+
...(deps.modelCatalogWatch ? { modelCatalogWatch: deps.modelCatalogWatch } : null),
|
|
93
|
+
...(retryModelDownload
|
|
94
|
+
? {
|
|
95
|
+
retryModelDownload: async (request) => {
|
|
96
|
+
await retryModelDownload(request);
|
|
97
|
+
return { ok: true };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
: null),
|
|
101
|
+
...(deps.pushSkillSecret
|
|
102
|
+
? {
|
|
103
|
+
pushSkillSecret: async (request) => {
|
|
104
|
+
await deps.pushSkillSecret?.(request);
|
|
105
|
+
return { ok: true };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
: null),
|
|
109
|
+
...(deps.transcribe ? { transcribe: deps.transcribe } : null),
|
|
110
|
+
...(deps.speak ? { speak: deps.speak } : null),
|
|
111
|
+
...(deps.speakStream
|
|
112
|
+
? {
|
|
113
|
+
speakStream: async function* (stream) {
|
|
114
|
+
const text = (async function* () {
|
|
115
|
+
for await (const frame of toAsyncIterable(stream))
|
|
116
|
+
if (frame.text)
|
|
117
|
+
yield frame.text;
|
|
118
|
+
})();
|
|
119
|
+
yield* deps.speakStream(text);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
: null),
|
|
123
|
+
...(deps.skills
|
|
124
|
+
? {
|
|
125
|
+
skills: async (req) => ({
|
|
126
|
+
skills: await deps.skills?.(req?.agentId, req?.modelName, {
|
|
127
|
+
refresh: req?.refresh === true
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
: null),
|
|
132
|
+
...(deps.skillCatalog
|
|
133
|
+
? {
|
|
134
|
+
skillCatalog: async (req) => deps.skillCatalog?.(req?.agentId, req?.modelName, {
|
|
135
|
+
refresh: req?.refresh === true
|
|
136
|
+
}) ?? Promise.resolve({ skills: [] })
|
|
137
|
+
}
|
|
138
|
+
: null),
|
|
139
|
+
...(deps.listManagedSkills
|
|
140
|
+
? {
|
|
141
|
+
listManagedSkills: async (req) => deps.listManagedSkills(req?.agentId)
|
|
142
|
+
}
|
|
143
|
+
: null),
|
|
144
|
+
...(deps.readSkillFile
|
|
145
|
+
? {
|
|
146
|
+
readSkillFile: async (req) => deps.readSkillFile(req?.name, req?.agentId)
|
|
147
|
+
}
|
|
148
|
+
: null),
|
|
149
|
+
...(deps.writeSkillFile
|
|
150
|
+
? {
|
|
151
|
+
writeSkillFile: async (req) => deps.writeSkillFile(req?.name, req?.content, req?.agentId)
|
|
152
|
+
}
|
|
153
|
+
: null),
|
|
154
|
+
...(deps.copySkillForEdit
|
|
155
|
+
? {
|
|
156
|
+
copySkillForEdit: async (req) => deps.copySkillForEdit(req?.name, req?.agentId)
|
|
157
|
+
}
|
|
158
|
+
: null),
|
|
159
|
+
...(deps.deleteOverlaySkill
|
|
160
|
+
? {
|
|
161
|
+
deleteOverlaySkill: async (req) => deps.deleteOverlaySkill(req?.name, req?.agentId)
|
|
162
|
+
}
|
|
163
|
+
: null),
|
|
164
|
+
...(deps.tools ? { tools: deps.tools } : null)
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
async function transcodeImage(request) {
|
|
168
|
+
const normalized = await normalizeImageForModel(request.bytes);
|
|
169
|
+
if (normalized === request.bytes || detectImageMime(normalized) !== 'image/jpeg')
|
|
170
|
+
return {};
|
|
171
|
+
return { bytes: normalized };
|
|
172
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import "../logger.js";
|
|
3
|
+
const SCOPE = ['api'];
|
|
4
|
+
const MAX_STRING = 40;
|
|
5
|
+
export function instrument(handlers) {
|
|
6
|
+
const out = {};
|
|
7
|
+
for (const [name, handler] of Object.entries(handlers)) {
|
|
8
|
+
out[name] = typeof handler === 'function' ? wrap(name, handler) : handler;
|
|
9
|
+
}
|
|
10
|
+
return out;
|
|
11
|
+
}
|
|
12
|
+
function wrap(name, handler) {
|
|
13
|
+
return function (...args) {
|
|
14
|
+
const started = Date.now();
|
|
15
|
+
const request = summarize(args[0]);
|
|
16
|
+
let result;
|
|
17
|
+
try {
|
|
18
|
+
result = handler.apply(this, args);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
logger.debug(SCOPE, `${name} failed`, { request, ms: Date.now() - started, err: reason(err) });
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
if (isStream(result)) {
|
|
25
|
+
logger.debug(SCOPE, `${name} opened`, { request });
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
if (isPromise(result)) {
|
|
29
|
+
return result.then((value) => {
|
|
30
|
+
logger.debug(SCOPE, name, { request, ms: Date.now() - started, ...count(value) });
|
|
31
|
+
return value;
|
|
32
|
+
}, (err) => {
|
|
33
|
+
logger.debug(SCOPE, `${name} failed`, {
|
|
34
|
+
request,
|
|
35
|
+
ms: Date.now() - started,
|
|
36
|
+
err: reason(err)
|
|
37
|
+
});
|
|
38
|
+
throw err;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
logger.debug(SCOPE, name, { request, ms: Date.now() - started, ...count(result) });
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function isPromise(value) {
|
|
46
|
+
return isRecord(value) && typeof value.then === 'function';
|
|
47
|
+
}
|
|
48
|
+
function isStream(value) {
|
|
49
|
+
return isRecord(value) && typeof value[Symbol.asyncIterator] === 'function';
|
|
50
|
+
}
|
|
51
|
+
function isRecord(value) {
|
|
52
|
+
return typeof value === 'object' && value !== null;
|
|
53
|
+
}
|
|
54
|
+
function count(value) {
|
|
55
|
+
if (!isRecord(value))
|
|
56
|
+
return null;
|
|
57
|
+
for (const field of Object.values(value)) {
|
|
58
|
+
if (Array.isArray(field))
|
|
59
|
+
return { n: field.length };
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
function summarize(request) {
|
|
64
|
+
if (!isRecord(request))
|
|
65
|
+
return '';
|
|
66
|
+
return Object.entries(request)
|
|
67
|
+
.map(([key, value]) => `${key}=${scalar(value)}`)
|
|
68
|
+
.join(' ');
|
|
69
|
+
}
|
|
70
|
+
function scalar(value) {
|
|
71
|
+
if (value === null || value === undefined)
|
|
72
|
+
return String(value);
|
|
73
|
+
if (b4a.isBuffer(value))
|
|
74
|
+
return `<${value.byteLength}b>`;
|
|
75
|
+
if (Array.isArray(value))
|
|
76
|
+
return `[${value.length}]`;
|
|
77
|
+
if (typeof value === 'string') {
|
|
78
|
+
return value.length > MAX_STRING ? `<str:${value.length}>` : value;
|
|
79
|
+
}
|
|
80
|
+
if (typeof value === 'object')
|
|
81
|
+
return '{}';
|
|
82
|
+
return String(value);
|
|
83
|
+
}
|
|
84
|
+
function reason(err) {
|
|
85
|
+
return err instanceof Error ? err.message : String(err);
|
|
86
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
|
+
import { type CurrentMesh } from './current-mesh.ts';
|
|
3
|
+
export { MAX_KNOWLEDGE_BYTES } from '../core/files/knowledge.ts';
|
|
4
|
+
export declare function createKnowledgeApi(current: CurrentMesh, options?: {
|
|
5
|
+
maxBytes?: number;
|
|
6
|
+
inactivityMs?: number;
|
|
7
|
+
deviceId?: Buffer | null;
|
|
8
|
+
}): Pick<CapabilityHandlers, 'uploadKnowledge' | 'downloadKnowledge' | 'removeKnowledge' | 'listKnowledge' | 'knowledgeWatch' | 'listIndexing' | 'indexingWatch' | 'fileStatusWatch' | 'indexingProgressWatch'>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { requireMesh } from "./current-mesh.js";
|
|
2
|
+
import { watchable } from "./watchable.js";
|
|
3
|
+
export { MAX_KNOWLEDGE_BYTES } from "../core/files/knowledge.js";
|
|
4
|
+
export function createKnowledgeApi(current, options = {}) {
|
|
5
|
+
return {
|
|
6
|
+
async *uploadKnowledge(frames) {
|
|
7
|
+
yield* (await requireMesh(current)).files.knowledge(options).uploadKnowledge(frames);
|
|
8
|
+
},
|
|
9
|
+
async *downloadKnowledge(request) {
|
|
10
|
+
yield* (await requireMesh(current)).files.knowledge(options).downloadKnowledge(request);
|
|
11
|
+
},
|
|
12
|
+
async removeKnowledge(request) {
|
|
13
|
+
return (await requireMesh(current)).files.knowledge(options).removeKnowledge(request);
|
|
14
|
+
},
|
|
15
|
+
async listKnowledge(request) {
|
|
16
|
+
return (await requireMesh(current)).files.knowledge(options).listKnowledge(request);
|
|
17
|
+
},
|
|
18
|
+
async listIndexing(request) {
|
|
19
|
+
return (await requireMesh(current)).files.knowledge(options).listIndexing(request);
|
|
20
|
+
},
|
|
21
|
+
knowledgeWatch: watchable('knowledgeWatch', () => requireMesh(current), async (request, mesh) => mesh.files.knowledge(options).listKnowledge(request)),
|
|
22
|
+
indexingWatch: watchable('indexingWatch', async () => (await requireMesh(current)).files, ({ chatId }, files) => files.listIndexing(chatId)),
|
|
23
|
+
fileStatusWatch: watchable('fileStatusWatch', async () => (await requireMesh(current)).files, ({ chatId }, files) => files.status(chatId)),
|
|
24
|
+
indexingProgressWatch: watchable('indexingProgressWatch', async () => (await requireMesh(current)).files, ({ chatId }, files) => Promise.resolve({ entries: files.progress(chatId) }))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
|
+
import type { LogLevel, LogRecord } from '../log.ts';
|
|
3
|
+
export interface LogSource {
|
|
4
|
+
backfill(): ReadonlyArray<LogRecord>;
|
|
5
|
+
subscribe(listener: (record: LogRecord) => void): void;
|
|
6
|
+
unsubscribe(listener: (record: LogRecord) => void): void;
|
|
7
|
+
write(input: {
|
|
8
|
+
level: LogLevel;
|
|
9
|
+
scope: ReadonlyArray<string>;
|
|
10
|
+
message: string;
|
|
11
|
+
at: number;
|
|
12
|
+
}): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createLogsApi(source: LogSource): Pick<CapabilityHandlers, 'logsWatch' | 'writeLog'>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Readable } from 'streamx';
|
|
2
|
+
import { LEVELS } from "../log-levels.js";
|
|
3
|
+
const MAX_LIVE_QUEUE = 1000;
|
|
4
|
+
export function createLogsApi(source) {
|
|
5
|
+
return {
|
|
6
|
+
logsWatch: (request) => logStream(source, request),
|
|
7
|
+
writeLog: (request) => {
|
|
8
|
+
source.write({
|
|
9
|
+
level: request.level,
|
|
10
|
+
scope: request.scope ?? [],
|
|
11
|
+
message: request.message,
|
|
12
|
+
at: request.at
|
|
13
|
+
});
|
|
14
|
+
return { ok: true };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function logStream(source, request) {
|
|
19
|
+
const matches = makeFilter(request);
|
|
20
|
+
const queue = [];
|
|
21
|
+
let dropped = 0;
|
|
22
|
+
let droppedSeq = 0;
|
|
23
|
+
let backfill = null;
|
|
24
|
+
let wake = null;
|
|
25
|
+
const onRecord = (record) => {
|
|
26
|
+
if (!matches(record))
|
|
27
|
+
return;
|
|
28
|
+
if (queue.length >= MAX_LIVE_QUEUE) {
|
|
29
|
+
droppedSeq = queue.shift().seq;
|
|
30
|
+
dropped++;
|
|
31
|
+
}
|
|
32
|
+
queue.push(toLine(record));
|
|
33
|
+
wake?.resolve();
|
|
34
|
+
wake = null;
|
|
35
|
+
};
|
|
36
|
+
const stream = new Readable({
|
|
37
|
+
open(cb) {
|
|
38
|
+
source.subscribe(onRecord);
|
|
39
|
+
const history = source.backfill().filter(matches);
|
|
40
|
+
backfill = request.backfill ? history.slice(-request.backfill).map(toLine) : [];
|
|
41
|
+
cb(null);
|
|
42
|
+
},
|
|
43
|
+
async read(cb) {
|
|
44
|
+
try {
|
|
45
|
+
if (backfill) {
|
|
46
|
+
const initial = backfill;
|
|
47
|
+
backfill = null;
|
|
48
|
+
if (initial.length) {
|
|
49
|
+
stream.push({ lines: initial });
|
|
50
|
+
return cb(null);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
while (!stream.destroying) {
|
|
54
|
+
if (queue.length === 0) {
|
|
55
|
+
wake = Promise.withResolvers();
|
|
56
|
+
await wake.promise;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const lines = queue.splice(0);
|
|
60
|
+
if (dropped > 0) {
|
|
61
|
+
lines.unshift(droppedMarker(dropped, droppedSeq));
|
|
62
|
+
dropped = 0;
|
|
63
|
+
}
|
|
64
|
+
stream.push({ lines });
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
cb(null);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
cb(err);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
predestroy() {
|
|
74
|
+
wake?.resolve();
|
|
75
|
+
wake = null;
|
|
76
|
+
},
|
|
77
|
+
destroy(cb) {
|
|
78
|
+
source.unsubscribe(onRecord);
|
|
79
|
+
cb(null);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return stream;
|
|
83
|
+
}
|
|
84
|
+
function makeFilter(request) {
|
|
85
|
+
const minLevel = request.level ? LEVELS[request.level] : 0;
|
|
86
|
+
const scope = request.scope ?? [];
|
|
87
|
+
const origin = request.origin ?? null;
|
|
88
|
+
return (record) => {
|
|
89
|
+
if (LEVELS[record.level] < minLevel)
|
|
90
|
+
return false;
|
|
91
|
+
if (origin && record.origin !== origin)
|
|
92
|
+
return false;
|
|
93
|
+
return scope.every((s) => record.scope.includes(s));
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function toLine(record) {
|
|
97
|
+
return {
|
|
98
|
+
seq: record.seq,
|
|
99
|
+
at: record.at,
|
|
100
|
+
level: record.level,
|
|
101
|
+
scope: [...record.scope],
|
|
102
|
+
message: record.message,
|
|
103
|
+
origin: record.origin,
|
|
104
|
+
originDeviceId: record.originDeviceId
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function droppedMarker(count, seq) {
|
|
108
|
+
return {
|
|
109
|
+
seq,
|
|
110
|
+
at: Date.now(),
|
|
111
|
+
level: 'warn',
|
|
112
|
+
scope: ['logs'],
|
|
113
|
+
message: `dropped ${count} log lines (slow reader)`,
|
|
114
|
+
origin: 'core'
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AssistantMeshStatus } from '../../spec/hyperschema/types.d.ts';
|
|
2
|
+
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
|
+
export interface MeshStatusSource {
|
|
4
|
+
watch(listener: () => void): void;
|
|
5
|
+
unwatch(listener: () => void): void;
|
|
6
|
+
snapshot(): AssistantMeshStatus;
|
|
7
|
+
leave(): Promise<void>;
|
|
8
|
+
acknowledgeKicked(): void;
|
|
9
|
+
join(invite: string): Promise<void>;
|
|
10
|
+
cancelJoin(): void;
|
|
11
|
+
invite(): Promise<string | null>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createMeshApi(status: MeshStatusSource): Pick<CapabilityHandlers, 'meshStatusWatch' | 'leaveMesh' | 'acknowledgeKicked' | 'joinMesh' | 'cancelMeshJoin' | 'meshInvite'>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { watchable } from "./watchable.js";
|
|
2
|
+
export function createMeshApi(status) {
|
|
3
|
+
return {
|
|
4
|
+
meshStatusWatch: watchable('meshStatusWatch', () => status, async () => status.snapshot()),
|
|
5
|
+
leaveMesh: async () => {
|
|
6
|
+
await status.leave();
|
|
7
|
+
return { ok: true };
|
|
8
|
+
},
|
|
9
|
+
acknowledgeKicked: async () => {
|
|
10
|
+
status.acknowledgeKicked();
|
|
11
|
+
return { ok: true };
|
|
12
|
+
},
|
|
13
|
+
joinMesh: async ({ invite }) => {
|
|
14
|
+
await status.join(invite);
|
|
15
|
+
return { ok: true };
|
|
16
|
+
},
|
|
17
|
+
cancelMeshJoin: async () => {
|
|
18
|
+
status.cancelJoin();
|
|
19
|
+
return { ok: true };
|
|
20
|
+
},
|
|
21
|
+
meshInvite: async () => ({
|
|
22
|
+
invite: (await status.invite()) ?? undefined
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { openLocalStore } from '../core/local/index.ts';
|
|
2
|
+
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
|
+
type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
|
|
4
|
+
export declare function createModelDownloadApi(state: LocalStore): Pick<CapabilityHandlers, 'modelDownloadsWatch' | 'setModelDownloadStatus' | 'clearModelDownload' | 'beginModelTransfer' | 'completeModelTransfer'>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { watchable } from "./watchable.js";
|
|
2
|
+
async function readDownloads(state) {
|
|
3
|
+
const rows = await state.getModelDownloadRows();
|
|
4
|
+
return {
|
|
5
|
+
downloads: rows.map((row) => ({
|
|
6
|
+
name: row.name,
|
|
7
|
+
phase: row.phase,
|
|
8
|
+
percentage: row.percentage ?? 0,
|
|
9
|
+
error: row.error ?? null,
|
|
10
|
+
updatedAt: row.updatedAt,
|
|
11
|
+
downloaded: row.downloaded ?? 0,
|
|
12
|
+
total: row.total ?? 0,
|
|
13
|
+
bytesPerSecond: row.bytesPerSecond ?? 0
|
|
14
|
+
}))
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function createModelDownloadApi(state) {
|
|
18
|
+
return {
|
|
19
|
+
beginModelTransfer: async ({ name, transferred }) => {
|
|
20
|
+
const { transferId } = await state.beginModelTransfer(name, { transferred });
|
|
21
|
+
return { name, transferId };
|
|
22
|
+
},
|
|
23
|
+
completeModelTransfer: async (request) => {
|
|
24
|
+
await state.completeModelTransfer(request);
|
|
25
|
+
return { ok: true };
|
|
26
|
+
},
|
|
27
|
+
modelDownloadsWatch: watchable('modelDownloadsWatch', () => state, () => readDownloads(state)),
|
|
28
|
+
setModelDownloadStatus: async (input) => {
|
|
29
|
+
const row = {
|
|
30
|
+
name: input.name,
|
|
31
|
+
phase: input.phase,
|
|
32
|
+
percentage: input.percentage ?? 0,
|
|
33
|
+
error: input.error ?? null,
|
|
34
|
+
updatedAt: Date.now(),
|
|
35
|
+
downloaded: input.downloaded ?? 0,
|
|
36
|
+
total: input.total ?? 0,
|
|
37
|
+
bytesPerSecond: input.bytesPerSecond ?? 0
|
|
38
|
+
};
|
|
39
|
+
await state.putModelDownloadRow(row);
|
|
40
|
+
return { ok: true };
|
|
41
|
+
},
|
|
42
|
+
clearModelDownload: async ({ name }) => {
|
|
43
|
+
await state.deleteModelDownloadRow(name);
|
|
44
|
+
return { ok: true };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AssistantNetworkStatus } from '../../spec/hyperschema/types.d.ts';
|
|
2
|
+
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
|
+
export interface NetworkSource {
|
|
4
|
+
watch(listener: () => void): void;
|
|
5
|
+
unwatch(listener: () => void): void;
|
|
6
|
+
snapshot(): AssistantNetworkStatus;
|
|
7
|
+
}
|
|
8
|
+
export declare function createNetworkApi(source: NetworkSource): Pick<CapabilityHandlers, 'networkWatch'>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
|
+
import type { openLocalStore } from '../core/local/index.ts';
|
|
3
|
+
import { type CurrentMesh } from './current-mesh.ts';
|
|
4
|
+
type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
|
|
5
|
+
type NotificationCapabilities = Pick<CapabilityHandlers, 'notificationsWatch' | 'ackNotification'>;
|
|
6
|
+
export interface NotificationLifetime {
|
|
7
|
+
once(event: 'close', listener: () => void): unknown;
|
|
8
|
+
off(event: 'close', listener: () => void): unknown;
|
|
9
|
+
readonly closing: unknown;
|
|
10
|
+
readonly closed: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface NotificationOptions {
|
|
13
|
+
readonly deviceId?: Buffer | null;
|
|
14
|
+
readonly lifetime?: NotificationLifetime;
|
|
15
|
+
readonly changes?: {
|
|
16
|
+
watch(listener: () => void): void;
|
|
17
|
+
unwatch(listener: () => void): void;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare function createNotificationsApi(current: CurrentMesh, local: LocalStore, options?: NotificationOptions): NotificationCapabilities;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { deriveNotifications } from "../core/notification.js";
|
|
2
|
+
import { requireMesh } from "./current-mesh.js";
|
|
3
|
+
import { watchable } from "./watchable.js";
|
|
4
|
+
export function createNotificationsApi(current, local, options = {}) {
|
|
5
|
+
return {
|
|
6
|
+
notificationsWatch: watchable('notificationsWatch', () => notificationSource(current, local, options), (request) => notificationSnapshot(current, local, request?.limit, options.deviceId)),
|
|
7
|
+
ackNotification: async ({ chatId, seq, notificationId }) => {
|
|
8
|
+
if (notificationId) {
|
|
9
|
+
if ((chatId !== undefined && chatId !== null) || (seq ?? 0) !== 0) {
|
|
10
|
+
throw new Error('notification acknowledgement must select one source');
|
|
11
|
+
}
|
|
12
|
+
await local.ackModelNotification(notificationId);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
if (!chatId || seq === undefined || seq === null) {
|
|
16
|
+
throw new Error('chat acknowledgement requires chatId and seq');
|
|
17
|
+
}
|
|
18
|
+
await requireMesh(current);
|
|
19
|
+
await local.ackChatNotify(chatId, seq);
|
|
20
|
+
}
|
|
21
|
+
return { ok: true };
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function notificationSource(current, local, options) {
|
|
26
|
+
let mesh = null;
|
|
27
|
+
let generation = 0;
|
|
28
|
+
let watching = false;
|
|
29
|
+
let listener = null;
|
|
30
|
+
const notify = () => listener?.();
|
|
31
|
+
const detach = () => {
|
|
32
|
+
mesh?.unwatch(notify);
|
|
33
|
+
mesh?.off('close', changed);
|
|
34
|
+
mesh = null;
|
|
35
|
+
};
|
|
36
|
+
const changed = () => {
|
|
37
|
+
const version = ++generation;
|
|
38
|
+
detach();
|
|
39
|
+
notify();
|
|
40
|
+
void Promise.resolve(current())
|
|
41
|
+
.then((next) => {
|
|
42
|
+
if (!watching || version !== generation || next?.closing || next?.closed)
|
|
43
|
+
return;
|
|
44
|
+
mesh = next;
|
|
45
|
+
mesh?.watch(notify);
|
|
46
|
+
mesh?.once('close', changed);
|
|
47
|
+
notify();
|
|
48
|
+
})
|
|
49
|
+
.catch(notify);
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
watch(onChange) {
|
|
53
|
+
listener = onChange;
|
|
54
|
+
watching = true;
|
|
55
|
+
local.watch(notify);
|
|
56
|
+
options.changes?.watch(changed);
|
|
57
|
+
changed();
|
|
58
|
+
},
|
|
59
|
+
unwatch() {
|
|
60
|
+
watching = false;
|
|
61
|
+
generation++;
|
|
62
|
+
detach();
|
|
63
|
+
local.unwatch(notify);
|
|
64
|
+
options.changes?.unwatch(changed);
|
|
65
|
+
listener = null;
|
|
66
|
+
},
|
|
67
|
+
once: (event, onClose) => options.lifetime?.once(event, onClose),
|
|
68
|
+
off: (event, onClose) => options.lifetime?.off(event, onClose),
|
|
69
|
+
get closing() {
|
|
70
|
+
return options.lifetime?.closing;
|
|
71
|
+
},
|
|
72
|
+
get closed() {
|
|
73
|
+
return options.lifetime?.closed ?? false;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async function notificationSnapshot(current, local, requestedLimit, deviceId) {
|
|
78
|
+
const mesh = await current();
|
|
79
|
+
let chats = { notifications: [] };
|
|
80
|
+
if (mesh && !mesh.closing && !mesh.closed) {
|
|
81
|
+
try {
|
|
82
|
+
chats = await deriveNotifications(mesh, local, Number.MAX_SAFE_INTEGER, deviceId);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (mesh === (await current()) && !mesh.closing && !mesh.closed)
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const models = await local.getModelNotifications();
|
|
90
|
+
if (mesh !== (await current()) || mesh?.closing || mesh?.closed)
|
|
91
|
+
chats = { notifications: [] };
|
|
92
|
+
const notifications = [
|
|
93
|
+
...(chats.notifications ?? []),
|
|
94
|
+
...models
|
|
95
|
+
.filter((row) => row.notificationId && !row.acknowledged)
|
|
96
|
+
.map((row) => ({
|
|
97
|
+
kind: 'model-downloaded',
|
|
98
|
+
notificationId: row.notificationId,
|
|
99
|
+
modelName: row.name,
|
|
100
|
+
createdAt: row.completedAt
|
|
101
|
+
}))
|
|
102
|
+
].sort((left, right) => right.createdAt - left.createdAt || (right.seq ?? 0) - (left.seq ?? 0));
|
|
103
|
+
const limit = requestedLimit || 200;
|
|
104
|
+
return {
|
|
105
|
+
notifications: notifications.slice(0, limit),
|
|
106
|
+
truncated: notifications.length > limit || undefined
|
|
107
|
+
};
|
|
108
|
+
}
|