@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,73 @@
|
|
|
1
|
+
import { URLSearchParams } from 'url';
|
|
2
|
+
import defaultFetch from '#fetch';
|
|
3
|
+
import { runBrowserConnect } from "./browser-connect.js";
|
|
4
|
+
import { oauthRedirectUri, tokenRequest } from "./common.js";
|
|
5
|
+
import { resolveOAuthCredential } from "./resolve.js";
|
|
6
|
+
export const SPOTIFY_CREDENTIAL_KEY = 'spotify_access_token';
|
|
7
|
+
export const SPOTIFY_OAUTH_STATE_KEY = 'spotify_oauth';
|
|
8
|
+
export const SPOTIFY_OAUTH_PORT = 18974;
|
|
9
|
+
const REDIRECT_URI = oauthRedirectUri(SPOTIFY_OAUTH_PORT);
|
|
10
|
+
const AUTH_URL = 'https://accounts.spotify.com/authorize';
|
|
11
|
+
const TOKEN_URL = 'https://accounts.spotify.com/api/token';
|
|
12
|
+
const SCOPES = [
|
|
13
|
+
'user-read-playback-state',
|
|
14
|
+
'user-modify-playback-state',
|
|
15
|
+
'user-read-currently-playing',
|
|
16
|
+
'playlist-read-private',
|
|
17
|
+
'playlist-read-collaborative',
|
|
18
|
+
'user-library-read',
|
|
19
|
+
'user-top-read',
|
|
20
|
+
'user-read-recently-played'
|
|
21
|
+
];
|
|
22
|
+
export function buildSpotifyAuthUrl(opts) {
|
|
23
|
+
const params = new URLSearchParams({
|
|
24
|
+
response_type: 'code',
|
|
25
|
+
client_id: opts.clientId,
|
|
26
|
+
redirect_uri: REDIRECT_URI,
|
|
27
|
+
scope: SCOPES.join(' '),
|
|
28
|
+
state: opts.state,
|
|
29
|
+
code_challenge: opts.challenge,
|
|
30
|
+
code_challenge_method: 'S256'
|
|
31
|
+
});
|
|
32
|
+
return `${AUTH_URL}?${params.toString()}`;
|
|
33
|
+
}
|
|
34
|
+
export async function exchangeSpotifyCode(opts) {
|
|
35
|
+
return tokenRequest(opts.fetch ?? defaultFetch, TOKEN_URL, new URLSearchParams({
|
|
36
|
+
grant_type: 'authorization_code',
|
|
37
|
+
code: opts.code,
|
|
38
|
+
redirect_uri: REDIRECT_URI,
|
|
39
|
+
client_id: opts.clientId,
|
|
40
|
+
code_verifier: opts.verifier
|
|
41
|
+
}), 'Spotify');
|
|
42
|
+
}
|
|
43
|
+
export async function refreshSpotifyToken(opts) {
|
|
44
|
+
const tokens = await tokenRequest(opts.fetch ?? defaultFetch, TOKEN_URL, new URLSearchParams({
|
|
45
|
+
grant_type: 'refresh_token',
|
|
46
|
+
refresh_token: opts.refreshToken,
|
|
47
|
+
client_id: opts.clientId
|
|
48
|
+
}), 'Spotify');
|
|
49
|
+
return { ...tokens, refreshToken: tokens.refreshToken ?? opts.refreshToken };
|
|
50
|
+
}
|
|
51
|
+
export async function connectSpotify(opts) {
|
|
52
|
+
return runBrowserConnect({
|
|
53
|
+
port: SPOTIFY_OAUTH_PORT,
|
|
54
|
+
timeoutMs: opts.timeoutMs,
|
|
55
|
+
openUrl: opts.openUrl,
|
|
56
|
+
buildAuthUrl: ({ state, challenge }) => buildSpotifyAuthUrl({ clientId: opts.clientId, state, challenge }),
|
|
57
|
+
exchange: ({ code, verifier }) => exchangeSpotifyCode({
|
|
58
|
+
clientId: opts.clientId,
|
|
59
|
+
code,
|
|
60
|
+
verifier,
|
|
61
|
+
fetch: opts.fetch
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export async function resolveSpotifyCredential(opts) {
|
|
66
|
+
return resolveOAuthCredential({
|
|
67
|
+
...opts,
|
|
68
|
+
credentialKey: SPOTIFY_CREDENTIAL_KEY,
|
|
69
|
+
stateKey: SPOTIFY_OAUTH_STATE_KEY,
|
|
70
|
+
requireClientSecret: false,
|
|
71
|
+
refresh: async ({ clientId, refreshToken, fetch }) => refreshSpotifyToken({ clientId, refreshToken, fetch })
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OAuthFetch, OAuthFlowDeps, OAuthProviderConfig, OAuthTokens } from './types.ts';
|
|
2
|
+
export declare function exchangeCodeWithFetch(config: OAuthProviderConfig, clientId: string, redirectUri: string, code: string, verifier: string, deps: OAuthFlowDeps, fetchImpl: OAuthFetch): Promise<OAuthTokens>;
|
|
3
|
+
export declare function refreshOAuthTokensWithFetch(config: OAuthProviderConfig, refreshToken: string, fetchImpl: OAuthFetch): Promise<OAuthTokens>;
|
|
4
|
+
export declare function isTokenExpired(record: {
|
|
5
|
+
readonly expiresAt?: number;
|
|
6
|
+
}, bufferMs?: number): boolean;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
const TOKEN_REQUEST_TIMEOUT_MS = 30_000;
|
|
3
|
+
const TokenResponseSchema = z.object({
|
|
4
|
+
access_token: z.string(),
|
|
5
|
+
token_type: z.string(),
|
|
6
|
+
expires_in: z.number().optional(),
|
|
7
|
+
refresh_token: z.string().optional(),
|
|
8
|
+
scope: z.string().optional()
|
|
9
|
+
});
|
|
10
|
+
const TokenErrorSchema = z.object({
|
|
11
|
+
error: z.string(),
|
|
12
|
+
error_description: z.string().optional()
|
|
13
|
+
});
|
|
14
|
+
function parseTokenResponse(raw) {
|
|
15
|
+
const failure = TokenErrorSchema.safeParse(raw);
|
|
16
|
+
if (failure.success) {
|
|
17
|
+
const detail = failure.data.error_description;
|
|
18
|
+
throw new Error(`Token endpoint returned an error: ${failure.data.error}${detail ? ` — ${detail}` : ''}`);
|
|
19
|
+
}
|
|
20
|
+
return TokenResponseSchema.parse(raw);
|
|
21
|
+
}
|
|
22
|
+
function applyClientSecret(config, body, headers) {
|
|
23
|
+
if (config.tokenAuth === 'secret-in-body') {
|
|
24
|
+
body.set('client_secret', config.clientSecret);
|
|
25
|
+
}
|
|
26
|
+
else if (config.tokenAuth === 'secret-in-basic') {
|
|
27
|
+
headers.Authorization = `Basic ${globalThis.btoa(`${config.clientId}:${config.clientSecret}`)}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function toTokens(raw, fallbackRefresh) {
|
|
31
|
+
return {
|
|
32
|
+
accessToken: raw.access_token,
|
|
33
|
+
refreshToken: raw.refresh_token ?? fallbackRefresh,
|
|
34
|
+
expiresAt: raw.expires_in ? Date.now() + raw.expires_in * 1000 : undefined,
|
|
35
|
+
scope: raw.scope
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export async function exchangeCodeWithFetch(config, clientId, redirectUri, code, verifier, deps, fetchImpl) {
|
|
39
|
+
const body = new URLSearchParams({
|
|
40
|
+
grant_type: 'authorization_code',
|
|
41
|
+
code,
|
|
42
|
+
redirect_uri: redirectUri,
|
|
43
|
+
client_id: clientId,
|
|
44
|
+
code_verifier: verifier
|
|
45
|
+
});
|
|
46
|
+
const headers = {
|
|
47
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
48
|
+
Accept: 'application/json'
|
|
49
|
+
};
|
|
50
|
+
applyClientSecret(config, body, headers);
|
|
51
|
+
const response = await fetchImpl(config.tokenUrl, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers,
|
|
54
|
+
body: body.toString()
|
|
55
|
+
});
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
const text = await response.text().catch(() => '');
|
|
58
|
+
if (config.dynamicRegistration && /invalid_client/i.test(text)) {
|
|
59
|
+
await deps.clearClientId?.();
|
|
60
|
+
}
|
|
61
|
+
throw new Error(`Token exchange failed (${response.status}): ${text}`);
|
|
62
|
+
}
|
|
63
|
+
return toTokens(parseTokenResponse(await response.json()));
|
|
64
|
+
}
|
|
65
|
+
export async function refreshOAuthTokensWithFetch(config, refreshToken, fetchImpl) {
|
|
66
|
+
const body = new URLSearchParams({
|
|
67
|
+
grant_type: 'refresh_token',
|
|
68
|
+
refresh_token: refreshToken,
|
|
69
|
+
client_id: config.clientId
|
|
70
|
+
});
|
|
71
|
+
const headers = {
|
|
72
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
73
|
+
Accept: 'application/json'
|
|
74
|
+
};
|
|
75
|
+
applyClientSecret(config, body, headers);
|
|
76
|
+
const controller = new globalThis.AbortController();
|
|
77
|
+
const timeout = globalThis.setTimeout(() => controller.abort(new Error('OAuth token refresh timed out')), TOKEN_REQUEST_TIMEOUT_MS);
|
|
78
|
+
try {
|
|
79
|
+
const response = await fetchImpl(config.tokenUrl, {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
headers,
|
|
82
|
+
body: body.toString(),
|
|
83
|
+
signal: controller.signal
|
|
84
|
+
});
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
const text = await response.text().catch(() => '');
|
|
87
|
+
throw new Error(`Token refresh failed (${response.status}): ${text}`);
|
|
88
|
+
}
|
|
89
|
+
return toTokens(parseTokenResponse(await response.json()), refreshToken);
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
globalThis.clearTimeout(timeout);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function isTokenExpired(record, bufferMs = 60_000) {
|
|
96
|
+
return typeof record.expiresAt === 'number' && Date.now() + bufferMs >= record.expiresAt;
|
|
97
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OAuthFlowDeps, OAuthProviderConfig, OAuthTokens } from './types.ts';
|
|
2
|
+
import { isTokenExpired } from './token-exchange-core.ts';
|
|
3
|
+
export declare function exchangeCode(config: OAuthProviderConfig, clientId: string, redirectUri: string, code: string, verifier: string, deps: OAuthFlowDeps): Promise<OAuthTokens>;
|
|
4
|
+
export declare function refreshOAuthTokens(config: OAuthProviderConfig, refreshToken: string): Promise<OAuthTokens>;
|
|
5
|
+
export { isTokenExpired };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import defaultFetch from '@qvac/core/oauth/runtime/fetch';
|
|
2
|
+
import { exchangeCodeWithFetch, isTokenExpired, refreshOAuthTokensWithFetch } from "./token-exchange-core.js";
|
|
3
|
+
export function exchangeCode(config, clientId, redirectUri, code, verifier, deps) {
|
|
4
|
+
return exchangeCodeWithFetch(config, clientId, redirectUri, code, verifier, deps, defaultFetch);
|
|
5
|
+
}
|
|
6
|
+
export function refreshOAuthTokens(config, refreshToken) {
|
|
7
|
+
return refreshOAuthTokensWithFetch(config, refreshToken, defaultFetch);
|
|
8
|
+
}
|
|
9
|
+
export { isTokenExpired };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { OAuthRedirectFactory } from './redirect-types.ts';
|
|
2
|
+
export type OAuthProvider = 'google' | 'spotify' | 'asana' | 'notion';
|
|
3
|
+
export type OAuthTokens = {
|
|
4
|
+
readonly accessToken: string;
|
|
5
|
+
readonly refreshToken?: string;
|
|
6
|
+
readonly expiresAt?: number;
|
|
7
|
+
readonly scope?: string;
|
|
8
|
+
};
|
|
9
|
+
export type OAuthFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
10
|
+
export type OAuthRuntime = {
|
|
11
|
+
readonly fetch: OAuthFetch;
|
|
12
|
+
readonly randomBase64Url: (size: number) => string;
|
|
13
|
+
readonly sha256Base64Url: (value: string) => string | Promise<string>;
|
|
14
|
+
};
|
|
15
|
+
export type OAuthCredentials = {
|
|
16
|
+
readonly clientId: string;
|
|
17
|
+
readonly clientSecret?: string;
|
|
18
|
+
};
|
|
19
|
+
type OAuthProviderConfigBase = {
|
|
20
|
+
readonly clientId: string;
|
|
21
|
+
readonly authUrl: string;
|
|
22
|
+
readonly tokenUrl: string;
|
|
23
|
+
readonly scopes: ReadonlyArray<string>;
|
|
24
|
+
readonly credentialKey: string;
|
|
25
|
+
readonly port: number;
|
|
26
|
+
readonly extraAuthParams?: Readonly<Record<string, string>>;
|
|
27
|
+
readonly dynamicRegistration?: boolean;
|
|
28
|
+
readonly registrationEndpoint?: string;
|
|
29
|
+
};
|
|
30
|
+
export type OAuthFlowDeps = {
|
|
31
|
+
readonly openUrl?: (url: string) => Promise<void>;
|
|
32
|
+
readonly timeoutMs?: number;
|
|
33
|
+
readonly getClientId?: () => Promise<string | undefined>;
|
|
34
|
+
readonly saveClientId?: (clientId: string) => Promise<void>;
|
|
35
|
+
readonly clearClientId?: () => Promise<void>;
|
|
36
|
+
readonly createRedirect?: OAuthRedirectFactory;
|
|
37
|
+
};
|
|
38
|
+
export type PkceOnlyProviderConfig = OAuthProviderConfigBase & {
|
|
39
|
+
readonly tokenAuth: 'pkce-only';
|
|
40
|
+
};
|
|
41
|
+
export type SecretInBodyProviderConfig = OAuthProviderConfigBase & {
|
|
42
|
+
readonly tokenAuth: 'secret-in-body';
|
|
43
|
+
readonly clientSecret: string;
|
|
44
|
+
};
|
|
45
|
+
export type SecretInBasicProviderConfig = OAuthProviderConfigBase & {
|
|
46
|
+
readonly tokenAuth: 'secret-in-basic';
|
|
47
|
+
readonly clientSecret: string;
|
|
48
|
+
};
|
|
49
|
+
export type OAuthProviderConfig = PkceOnlyProviderConfig | SecretInBodyProviderConfig | SecretInBasicProviderConfig;
|
|
50
|
+
export type OAuthFlowResult = {
|
|
51
|
+
readonly config: OAuthProviderConfig;
|
|
52
|
+
readonly tokens: OAuthTokens;
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createOAuthClient, isTokenExpired, type OAuthClient } from './oauth/client.ts';
|
|
2
|
+
export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, providerSupportsSharedIosSession } from './oauth/providers.ts';
|
|
3
|
+
export type { OAuthCallbackResult, OAuthRedirect, OAuthRedirectFactory } from './oauth/redirect-types.ts';
|
|
4
|
+
export type { OAuthRuntimeFlowDeps } from './oauth/flow-core.ts';
|
|
5
|
+
export type { OAuthCredentials, OAuthFetch, OAuthFlowDeps, OAuthFlowResult, OAuthProvider, OAuthProviderConfig, OAuthRuntime, OAuthTokens } from './oauth/types.ts';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { createPkce, scopedKey, type ConfigEngine, type Fetch, type FetchResponse, type OAuthTokens } from './oauth/common.ts';
|
|
2
|
+
export { waitForOAuthCallback } from './oauth/browser-connect.ts';
|
|
3
|
+
export { buildGoogleAuthUrl, connectGoogle, exchangeGoogleCode, GOOGLE_OAUTH_PORT, refreshGoogleToken, resolveGoogleCredential, type GoogleTokens } from './oauth/google.ts';
|
|
4
|
+
export { buildNotionAuthUrl, connectNotion, exchangeNotionCode, NOTION_MCP_CREDENTIAL_KEY, NOTION_OAUTH_PORT, NOTION_OAUTH_STATE_KEY, refreshNotionToken, registerNotionClient, resolveNotionCredential, type NotionTokens } from './oauth/notion.ts';
|
|
5
|
+
export { buildAsanaAuthUrl, connectAsana, exchangeAsanaCode, ASANA_MCP_CREDENTIAL_KEY, ASANA_OAUTH_PORT, ASANA_OAUTH_STATE_KEY, refreshAsanaToken, resolveAsanaCredential, type AsanaTokens } from './oauth/asana.ts';
|
|
6
|
+
export { buildSpotifyAuthUrl, connectSpotify, exchangeSpotifyCode, refreshSpotifyToken, resolveSpotifyCredential, SPOTIFY_CREDENTIAL_KEY, SPOTIFY_OAUTH_PORT, SPOTIFY_OAUTH_STATE_KEY, type SpotifyTokens } from './oauth/spotify.ts';
|
|
7
|
+
export { cancelOAuthFlow, runOAuthFlow } from './oauth/flow.ts';
|
|
8
|
+
export { defaultCredentialKeyFor, GMAIL_CREDENTIAL_KEY, GOOGLE_CALENDAR_CREDENTIAL_KEY, GOOGLE_CREDENTIAL_KEYS, GOOGLE_DOCS_CREDENTIAL_KEY, GOOGLE_DRIVE_CREDENTIAL_KEY, GOOGLE_SHEETS_CREDENTIAL_KEY, LEGACY_GOOGLE_CREDENTIAL_KEY, OAUTH_KEY_SPECS, oauthKeySpec, oauthStateKeyFor, type OAuthKeySpec } from './oauth/keys.ts';
|
|
9
|
+
export { generatePkceChallenge, type PkceChallenge } from './oauth/pkce.ts';
|
|
10
|
+
export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, providerSupportsSharedIosSession } from './oauth/providers.ts';
|
|
11
|
+
export type { OAuthCallbackResult, OAuthRedirect, OAuthRedirectFactory } from './oauth/redirect-types.ts';
|
|
12
|
+
export { registerOAuthClient, resolveDynamicClientId } from './oauth/register.ts';
|
|
13
|
+
export { isTokenExpired, refreshOAuthTokens } from './oauth/token-exchange.ts';
|
|
14
|
+
export type { OAuthCredentials, OAuthFlowDeps, OAuthFlowResult, OAuthProvider, OAuthProviderConfig } from './oauth/types.ts';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { createPkce, scopedKey } from "./oauth/common.js";
|
|
2
|
+
export { waitForOAuthCallback } from "./oauth/browser-connect.js";
|
|
3
|
+
export { buildGoogleAuthUrl, connectGoogle, exchangeGoogleCode, GOOGLE_OAUTH_PORT, refreshGoogleToken, resolveGoogleCredential } from "./oauth/google.js";
|
|
4
|
+
export { buildNotionAuthUrl, connectNotion, exchangeNotionCode, NOTION_MCP_CREDENTIAL_KEY, NOTION_OAUTH_PORT, NOTION_OAUTH_STATE_KEY, refreshNotionToken, registerNotionClient, resolveNotionCredential } from "./oauth/notion.js";
|
|
5
|
+
export { buildAsanaAuthUrl, connectAsana, exchangeAsanaCode, ASANA_MCP_CREDENTIAL_KEY, ASANA_OAUTH_PORT, ASANA_OAUTH_STATE_KEY, refreshAsanaToken, resolveAsanaCredential } from "./oauth/asana.js";
|
|
6
|
+
export { buildSpotifyAuthUrl, connectSpotify, exchangeSpotifyCode, refreshSpotifyToken, resolveSpotifyCredential, SPOTIFY_CREDENTIAL_KEY, SPOTIFY_OAUTH_PORT, SPOTIFY_OAUTH_STATE_KEY } from "./oauth/spotify.js";
|
|
7
|
+
export { cancelOAuthFlow, runOAuthFlow } from "./oauth/flow.js";
|
|
8
|
+
export { defaultCredentialKeyFor, GMAIL_CREDENTIAL_KEY, GOOGLE_CALENDAR_CREDENTIAL_KEY, GOOGLE_CREDENTIAL_KEYS, GOOGLE_DOCS_CREDENTIAL_KEY, GOOGLE_DRIVE_CREDENTIAL_KEY, GOOGLE_SHEETS_CREDENTIAL_KEY, LEGACY_GOOGLE_CREDENTIAL_KEY, OAUTH_KEY_SPECS, oauthKeySpec, oauthStateKeyFor } from "./oauth/keys.js";
|
|
9
|
+
export { generatePkceChallenge } from "./oauth/pkce.js";
|
|
10
|
+
export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, providerSupportsSharedIosSession } from "./oauth/providers.js";
|
|
11
|
+
export { registerOAuthClient, resolveDynamicClientId } from "./oauth/register.js";
|
|
12
|
+
export { isTokenExpired, refreshOAuthTokens } from "./oauth/token-exchange.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY = "obsidian_vault_path";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY = 'obsidian_vault_path';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface Closeable {
|
|
2
|
+
on(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
3
|
+
off(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
4
|
+
}
|
|
5
|
+
export declare function raceResource<T>(resource: Closeable, operation: Promise<T>, name: string): Promise<T>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function raceResource(resource, operation, name) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const cleanup = () => {
|
|
4
|
+
resource.off('close', onClose);
|
|
5
|
+
resource.off('error', onError);
|
|
6
|
+
};
|
|
7
|
+
const onClose = () => {
|
|
8
|
+
cleanup();
|
|
9
|
+
reject(new Error(`${name} closed during open`));
|
|
10
|
+
};
|
|
11
|
+
const onError = (...args) => {
|
|
12
|
+
cleanup();
|
|
13
|
+
reject(args[0]);
|
|
14
|
+
};
|
|
15
|
+
resource.on('close', onClose);
|
|
16
|
+
resource.on('error', onError);
|
|
17
|
+
operation.then((value) => {
|
|
18
|
+
cleanup();
|
|
19
|
+
resolve(value);
|
|
20
|
+
}, (err) => {
|
|
21
|
+
cleanup();
|
|
22
|
+
reject(err);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Readable } from 'streamx';
|
|
2
|
+
const RETRY_MIN_MS = 250;
|
|
3
|
+
const RETRY_MAX_MS = 5_000;
|
|
4
|
+
export default function reconnectingWatch(open, onDisconnect) {
|
|
5
|
+
let closeConnection = null;
|
|
6
|
+
let retry = null;
|
|
7
|
+
let retryMs = RETRY_MIN_MS;
|
|
8
|
+
let output;
|
|
9
|
+
const schedule = (error) => {
|
|
10
|
+
if (output.destroying)
|
|
11
|
+
return;
|
|
12
|
+
onDisconnect(error);
|
|
13
|
+
retry = setTimeout(() => {
|
|
14
|
+
retry = null;
|
|
15
|
+
connect();
|
|
16
|
+
}, retryMs);
|
|
17
|
+
retryMs = Math.min(retryMs * 2, RETRY_MAX_MS);
|
|
18
|
+
};
|
|
19
|
+
const connect = () => {
|
|
20
|
+
if (output.destroying)
|
|
21
|
+
return;
|
|
22
|
+
let source;
|
|
23
|
+
try {
|
|
24
|
+
source = open();
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
schedule(asError(error));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const close = () => {
|
|
31
|
+
source.off('data', onData);
|
|
32
|
+
source.off('error', onError);
|
|
33
|
+
source.off('end', onEnd);
|
|
34
|
+
source.off('close', onEnd);
|
|
35
|
+
source.destroy();
|
|
36
|
+
};
|
|
37
|
+
const disconnect = (error) => {
|
|
38
|
+
if (closeConnection !== close)
|
|
39
|
+
return;
|
|
40
|
+
closeConnection = null;
|
|
41
|
+
close();
|
|
42
|
+
schedule(error);
|
|
43
|
+
};
|
|
44
|
+
const onData = (frame) => {
|
|
45
|
+
retryMs = RETRY_MIN_MS;
|
|
46
|
+
output.push(frame);
|
|
47
|
+
};
|
|
48
|
+
const onError = (error) => disconnect(error);
|
|
49
|
+
const onEnd = () => disconnect(new Error('Watch stream ended unexpectedly'));
|
|
50
|
+
closeConnection = close;
|
|
51
|
+
source.on('data', onData);
|
|
52
|
+
source.on('error', onError);
|
|
53
|
+
source.on('end', onEnd);
|
|
54
|
+
source.on('close', onEnd);
|
|
55
|
+
};
|
|
56
|
+
output = new Readable({
|
|
57
|
+
open(cb) {
|
|
58
|
+
connect();
|
|
59
|
+
cb(null);
|
|
60
|
+
},
|
|
61
|
+
read(cb) {
|
|
62
|
+
cb(null);
|
|
63
|
+
},
|
|
64
|
+
destroy(cb) {
|
|
65
|
+
if (retry)
|
|
66
|
+
clearTimeout(retry);
|
|
67
|
+
retry = null;
|
|
68
|
+
const close = closeConnection;
|
|
69
|
+
closeConnection = null;
|
|
70
|
+
close?.();
|
|
71
|
+
cb(null);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return output;
|
|
75
|
+
}
|
|
76
|
+
function asError(error) {
|
|
77
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
78
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface RetryBudgetOptions {
|
|
2
|
+
retryMs?: number;
|
|
3
|
+
}
|
|
4
|
+
export declare class RetryBudget {
|
|
5
|
+
private readonly _retryMs;
|
|
6
|
+
private readonly _attempts;
|
|
7
|
+
private readonly _readyAt;
|
|
8
|
+
constructor({ retryMs }?: RetryBudgetOptions);
|
|
9
|
+
ready(name: string, now: number): boolean;
|
|
10
|
+
nextDeadline(names: ReadonlySet<string>, now: number): number | null;
|
|
11
|
+
reset(name: string): void;
|
|
12
|
+
retain(names: ReadonlySet<string>): void;
|
|
13
|
+
fail(name: string, now: number): number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const DEFAULT_RETRY_MS = 30_000;
|
|
2
|
+
const MAX_RETRY_MS = 15 * 60_000;
|
|
3
|
+
export class RetryBudget {
|
|
4
|
+
_retryMs;
|
|
5
|
+
_attempts = new Map();
|
|
6
|
+
_readyAt = new Map();
|
|
7
|
+
constructor({ retryMs = DEFAULT_RETRY_MS } = {}) {
|
|
8
|
+
this._retryMs = retryMs;
|
|
9
|
+
}
|
|
10
|
+
ready(name, now) {
|
|
11
|
+
return (this._readyAt.get(name) ?? 0) <= now;
|
|
12
|
+
}
|
|
13
|
+
nextDeadline(names, now) {
|
|
14
|
+
let next = null;
|
|
15
|
+
for (const [name, readyAt] of this._readyAt) {
|
|
16
|
+
if (!names.has(name) || readyAt <= now)
|
|
17
|
+
continue;
|
|
18
|
+
if (next === null || readyAt < next)
|
|
19
|
+
next = readyAt;
|
|
20
|
+
}
|
|
21
|
+
return next;
|
|
22
|
+
}
|
|
23
|
+
reset(name) {
|
|
24
|
+
this._attempts.delete(name);
|
|
25
|
+
this._readyAt.delete(name);
|
|
26
|
+
}
|
|
27
|
+
retain(names) {
|
|
28
|
+
for (const name of this._attempts.keys())
|
|
29
|
+
if (!names.has(name))
|
|
30
|
+
this.reset(name);
|
|
31
|
+
}
|
|
32
|
+
fail(name, now) {
|
|
33
|
+
const attempt = (this._attempts.get(name) ?? 0) + 1;
|
|
34
|
+
this._attempts.set(name, attempt);
|
|
35
|
+
const at = now + Math.min(this._retryMs * 2 ** (attempt - 1), MAX_RETRY_MS);
|
|
36
|
+
this._readyAt.set(name, at);
|
|
37
|
+
return at;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const RUN_ABORT_REASONS: {
|
|
2
|
+
readonly suspended: "suspended";
|
|
3
|
+
readonly ownershipLost: "ownership-lost";
|
|
4
|
+
readonly runSettled: "run-settled";
|
|
5
|
+
readonly runnerDied: "runner-died";
|
|
6
|
+
readonly runnerClosed: "runner-closed";
|
|
7
|
+
};
|
|
8
|
+
export type RunAbortReason = (typeof RUN_ABORT_REASONS)[keyof typeof RUN_ABORT_REASONS];
|
|
9
|
+
export declare const RUN_FAILURE_REASONS: {
|
|
10
|
+
readonly harnessDied: "the model runtime died";
|
|
11
|
+
readonly runtimeEndedTurn: "the model runtime ended this turn";
|
|
12
|
+
};
|
|
13
|
+
export type AbortOutcome = {
|
|
14
|
+
readonly kind: 'replay';
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'handoff';
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'failed';
|
|
19
|
+
readonly reason: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function knownAbortOutcome(reason: unknown): AbortOutcome | null;
|
|
22
|
+
export declare function isLifecycleTeardown(reason: unknown): boolean;
|
|
23
|
+
export declare function runFailureNotice(error: unknown): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const RUN_ABORT_REASONS = {
|
|
2
|
+
suspended: 'suspended',
|
|
3
|
+
ownershipLost: 'ownership-lost',
|
|
4
|
+
runSettled: 'run-settled',
|
|
5
|
+
runnerDied: 'runner-died',
|
|
6
|
+
runnerClosed: 'runner-closed'
|
|
7
|
+
};
|
|
8
|
+
export const RUN_FAILURE_REASONS = {
|
|
9
|
+
harnessDied: 'the model runtime died',
|
|
10
|
+
runtimeEndedTurn: 'the model runtime ended this turn'
|
|
11
|
+
};
|
|
12
|
+
export function knownAbortOutcome(reason) {
|
|
13
|
+
if (reason === RUN_ABORT_REASONS.suspended || reason === RUN_ABORT_REASONS.runnerClosed) {
|
|
14
|
+
return { kind: 'replay' };
|
|
15
|
+
}
|
|
16
|
+
if (reason === RUN_ABORT_REASONS.ownershipLost || reason === RUN_ABORT_REASONS.runSettled) {
|
|
17
|
+
return { kind: 'handoff' };
|
|
18
|
+
}
|
|
19
|
+
if (reason === RUN_ABORT_REASONS.runnerDied) {
|
|
20
|
+
return { kind: 'failed', reason: RUN_FAILURE_REASONS.harnessDied };
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
export function isLifecycleTeardown(reason) {
|
|
25
|
+
return knownAbortOutcome(reason)?.kind === 'replay';
|
|
26
|
+
}
|
|
27
|
+
export function runFailureNotice(error) {
|
|
28
|
+
if (error instanceof Error && error.message)
|
|
29
|
+
return error.message;
|
|
30
|
+
if (typeof error === 'string' && error.trim())
|
|
31
|
+
return error;
|
|
32
|
+
return RUN_FAILURE_REASONS.runtimeEndedTurn;
|
|
33
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AssistantAppendChunkRequest, AssistantChunkId, AssistantChunkContentRunStatus } from '../spec/hyperschema/types.d.ts';
|
|
2
|
+
import type { Capabilities } from './api/index.ts';
|
|
3
|
+
import type { Logger } from './log.ts';
|
|
4
|
+
export type TranscriptChunk = Pick<AssistantAppendChunkRequest, 'type' | 'toolCall' | 'toolResult' | 'sources' | 'effect' | 'display' | 'rawCall'>;
|
|
5
|
+
export interface RunTranscriptOptions {
|
|
6
|
+
chatId: string;
|
|
7
|
+
runId: string;
|
|
8
|
+
deviceId: Buffer;
|
|
9
|
+
model: string;
|
|
10
|
+
log?: Logger | null;
|
|
11
|
+
}
|
|
12
|
+
export declare class RunTranscript {
|
|
13
|
+
private readonly _engine;
|
|
14
|
+
private readonly _chatId;
|
|
15
|
+
private readonly _runId;
|
|
16
|
+
private readonly _deviceId;
|
|
17
|
+
private readonly _model;
|
|
18
|
+
private readonly _log;
|
|
19
|
+
private readonly _writes;
|
|
20
|
+
private readonly _ticker;
|
|
21
|
+
private readonly _announced;
|
|
22
|
+
private _buffered;
|
|
23
|
+
constructor(engine: Capabilities, { chatId, runId, deviceId, model, log }: RunTranscriptOptions);
|
|
24
|
+
text(type: 'content' | 'thinking', text: string): Promise<void>;
|
|
25
|
+
chunk(chunk: TranscriptChunk): Promise<AssistantChunkId>;
|
|
26
|
+
status(runStatus: AssistantChunkContentRunStatus): Promise<AssistantChunkId>;
|
|
27
|
+
progress(id: string, runStatus: AssistantChunkContentRunStatus): Promise<unknown>;
|
|
28
|
+
flush(): Promise<void>;
|
|
29
|
+
pending(): Array<{
|
|
30
|
+
scope: string;
|
|
31
|
+
waiting: number;
|
|
32
|
+
}>;
|
|
33
|
+
close(): void;
|
|
34
|
+
private _announce;
|
|
35
|
+
}
|