@qvac/core 0.0.0 → 0.1.1
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 +47257 -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/helpers.d.ts +28 -0
- package/dist-lib/schema/helpers.js +176 -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/schema/vendor.d.ts +5 -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 +336 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export const GMAIL_CREDENTIAL_KEY = 'gmail_access_token';
|
|
2
|
+
export const GOOGLE_CALENDAR_CREDENTIAL_KEY = 'google_calendar_access_token';
|
|
3
|
+
export const GOOGLE_DOCS_CREDENTIAL_KEY = 'google_docs_access_token';
|
|
4
|
+
export const GOOGLE_DRIVE_CREDENTIAL_KEY = 'google_drive_access_token';
|
|
5
|
+
export const GOOGLE_SHEETS_CREDENTIAL_KEY = 'google_sheets_access_token';
|
|
6
|
+
export const SPOTIFY_CREDENTIAL_KEY = 'spotify_access_token';
|
|
7
|
+
export const ASANA_MCP_CREDENTIAL_KEY = 'asana_mcp_access_token';
|
|
8
|
+
export const NOTION_MCP_CREDENTIAL_KEY = 'notion_mcp_access_token';
|
|
9
|
+
export const LEGACY_GOOGLE_CREDENTIAL_KEY = 'google_workspace_access_token';
|
|
10
|
+
const DRIVE_SCOPE = 'https://www.googleapis.com/auth/drive';
|
|
11
|
+
export const OAUTH_KEY_SPECS = [
|
|
12
|
+
{
|
|
13
|
+
credentialKey: GMAIL_CREDENTIAL_KEY,
|
|
14
|
+
stateKey: 'gmail_oauth',
|
|
15
|
+
provider: 'google',
|
|
16
|
+
scopes: ['https://www.googleapis.com/auth/gmail.modify']
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
credentialKey: GOOGLE_CALENDAR_CREDENTIAL_KEY,
|
|
20
|
+
stateKey: 'google_calendar_oauth',
|
|
21
|
+
provider: 'google',
|
|
22
|
+
scopes: ['https://www.googleapis.com/auth/calendar']
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
credentialKey: GOOGLE_DOCS_CREDENTIAL_KEY,
|
|
26
|
+
stateKey: 'google_docs_oauth',
|
|
27
|
+
provider: 'google',
|
|
28
|
+
scopes: ['https://www.googleapis.com/auth/documents', DRIVE_SCOPE]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
credentialKey: GOOGLE_DRIVE_CREDENTIAL_KEY,
|
|
32
|
+
stateKey: 'google_drive_oauth',
|
|
33
|
+
provider: 'google',
|
|
34
|
+
scopes: [DRIVE_SCOPE]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
credentialKey: GOOGLE_SHEETS_CREDENTIAL_KEY,
|
|
38
|
+
stateKey: 'google_sheets_oauth',
|
|
39
|
+
provider: 'google',
|
|
40
|
+
scopes: ['https://www.googleapis.com/auth/spreadsheets', DRIVE_SCOPE]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
credentialKey: SPOTIFY_CREDENTIAL_KEY,
|
|
44
|
+
stateKey: 'spotify_oauth',
|
|
45
|
+
provider: 'spotify',
|
|
46
|
+
scopes: [
|
|
47
|
+
'user-read-playback-state',
|
|
48
|
+
'user-modify-playback-state',
|
|
49
|
+
'user-read-currently-playing',
|
|
50
|
+
'playlist-read-private',
|
|
51
|
+
'playlist-read-collaborative',
|
|
52
|
+
'user-library-read',
|
|
53
|
+
'user-top-read',
|
|
54
|
+
'user-read-recently-played'
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
credentialKey: ASANA_MCP_CREDENTIAL_KEY,
|
|
59
|
+
stateKey: 'asana_oauth',
|
|
60
|
+
provider: 'asana',
|
|
61
|
+
scopes: []
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
credentialKey: NOTION_MCP_CREDENTIAL_KEY,
|
|
65
|
+
stateKey: 'notion_oauth',
|
|
66
|
+
provider: 'notion',
|
|
67
|
+
scopes: []
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
export function oauthKeySpec(credentialKey) {
|
|
71
|
+
return OAUTH_KEY_SPECS.find((spec) => spec.credentialKey === credentialKey) ?? null;
|
|
72
|
+
}
|
|
73
|
+
export function oauthStateKeyFor(credentialKey) {
|
|
74
|
+
return oauthKeySpec(credentialKey)?.stateKey ?? null;
|
|
75
|
+
}
|
|
76
|
+
export function defaultCredentialKeyFor(provider) {
|
|
77
|
+
const spec = OAUTH_KEY_SPECS.find((candidate) => candidate.provider === provider);
|
|
78
|
+
if (!spec)
|
|
79
|
+
throw new Error(`Unknown OAuth provider: ${String(provider)}`);
|
|
80
|
+
return spec.credentialKey;
|
|
81
|
+
}
|
|
82
|
+
export const GOOGLE_CREDENTIAL_KEYS = OAUTH_KEY_SPECS.filter((spec) => spec.provider === 'google').map((spec) => spec.credentialKey);
|
|
83
|
+
export const OAUTH_PROVIDER_PORTS = {
|
|
84
|
+
google: 18978,
|
|
85
|
+
spotify: 18974,
|
|
86
|
+
asana: 18981,
|
|
87
|
+
notion: 18982
|
|
88
|
+
};
|
|
89
|
+
export const OAUTH_CALLBACK_PATH = '/callback';
|
|
90
|
+
export const OAUTH_WAIT_FOR_CODE_TIMEOUT_MS = 120_000;
|
|
91
|
+
export function oauthRedirectUri(port) {
|
|
92
|
+
return `http://127.0.0.1:${port}${OAUTH_CALLBACK_PATH}`;
|
|
93
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createServer } from 'http';
|
|
2
|
+
import { OAUTH_CALLBACK_PATH, OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, oauthRedirectUri } from "./keys.js";
|
|
3
|
+
const activeLoopbacks = new Map();
|
|
4
|
+
function closeServer(server) {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
if (!server.listening) {
|
|
7
|
+
resolve();
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
server.closeAllConnections?.();
|
|
11
|
+
server.close(() => resolve());
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export async function abortOAuthLoopback(port) {
|
|
15
|
+
const handle = activeLoopbacks.get(port);
|
|
16
|
+
if (!handle)
|
|
17
|
+
return false;
|
|
18
|
+
await handle.abort(new Error('OAuth flow cancelled'));
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
export async function startOAuthLoopback(port) {
|
|
22
|
+
const stale = activeLoopbacks.get(port);
|
|
23
|
+
if (stale) {
|
|
24
|
+
await stale.abort(new Error('OAuth loopback superseded by a new connect attempt'));
|
|
25
|
+
}
|
|
26
|
+
let resolveCode = null;
|
|
27
|
+
let rejectCode = null;
|
|
28
|
+
let abortedReason = null;
|
|
29
|
+
let expectedState = null;
|
|
30
|
+
const rejectWaiter = (error) => {
|
|
31
|
+
const reject = rejectCode;
|
|
32
|
+
resolveCode = null;
|
|
33
|
+
rejectCode = null;
|
|
34
|
+
reject?.(error);
|
|
35
|
+
};
|
|
36
|
+
const settle = (error, code, state) => {
|
|
37
|
+
const resolve = resolveCode;
|
|
38
|
+
const reject = rejectCode;
|
|
39
|
+
resolveCode = null;
|
|
40
|
+
rejectCode = null;
|
|
41
|
+
if (error)
|
|
42
|
+
reject?.(new Error(`OAuth error: ${error}`));
|
|
43
|
+
else if (code && state)
|
|
44
|
+
resolve?.({ code, state });
|
|
45
|
+
else
|
|
46
|
+
reject?.(new Error('OAuth callback missing code or state'));
|
|
47
|
+
};
|
|
48
|
+
const server = createServer((request, response) => {
|
|
49
|
+
const url = new URL(request.url ?? '/', `http://127.0.0.1:${port}`);
|
|
50
|
+
if (url.pathname !== OAUTH_CALLBACK_PATH) {
|
|
51
|
+
response.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
52
|
+
response.end('Not found');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const code = url.searchParams.get('code');
|
|
56
|
+
const state = url.searchParams.get('state');
|
|
57
|
+
const error = url.searchParams.get('error');
|
|
58
|
+
if (expectedState !== null && state !== expectedState) {
|
|
59
|
+
response.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
60
|
+
response.end('<html><body><p>This sign-in link is from an earlier attempt. ' +
|
|
61
|
+
'You can close this tab.</p></body></html>');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
response.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
65
|
+
response.end('<html><body><p>Authorization complete. You may close this tab.</p>' +
|
|
66
|
+
'<script>window.close();</script></body></html>');
|
|
67
|
+
settle(error, code, state);
|
|
68
|
+
response.on('close', () => server.close());
|
|
69
|
+
});
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
let listenSettled = false;
|
|
72
|
+
const onError = (error) => {
|
|
73
|
+
if (listenSettled)
|
|
74
|
+
return;
|
|
75
|
+
listenSettled = true;
|
|
76
|
+
server.removeListener('listening', onListening);
|
|
77
|
+
reject(error);
|
|
78
|
+
};
|
|
79
|
+
const onListening = () => {
|
|
80
|
+
if (listenSettled)
|
|
81
|
+
return;
|
|
82
|
+
listenSettled = true;
|
|
83
|
+
server.removeListener('error', onError);
|
|
84
|
+
const handle = {
|
|
85
|
+
abort: (reason) => {
|
|
86
|
+
abortedReason = reason;
|
|
87
|
+
rejectWaiter(reason);
|
|
88
|
+
return closeServer(server);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
activeLoopbacks.set(port, handle);
|
|
92
|
+
server.once('close', () => {
|
|
93
|
+
if (activeLoopbacks.get(port) === handle)
|
|
94
|
+
activeLoopbacks.delete(port);
|
|
95
|
+
});
|
|
96
|
+
resolve({
|
|
97
|
+
redirectUri: oauthRedirectUri(port),
|
|
98
|
+
waitForCode(timeoutMs = OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, expected) {
|
|
99
|
+
if (abortedReason)
|
|
100
|
+
throw abortedReason;
|
|
101
|
+
expectedState = expected ?? null;
|
|
102
|
+
return new Promise((resolveWait, rejectWait) => {
|
|
103
|
+
resolveCode = resolveWait;
|
|
104
|
+
rejectCode = rejectWait;
|
|
105
|
+
const timeout = globalThis.setTimeout(() => {
|
|
106
|
+
server.close();
|
|
107
|
+
rejectWait(new Error('OAuth callback timed out'));
|
|
108
|
+
}, timeoutMs);
|
|
109
|
+
server.once('close', () => globalThis.clearTimeout(timeout));
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
close: () => server.close()
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
server.once('error', onError);
|
|
116
|
+
server.once('listening', onListening);
|
|
117
|
+
server.listen(port, '127.0.0.1');
|
|
118
|
+
});
|
|
119
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ConfigEngine, type Fetch, type OAuthTokens } from './common.ts';
|
|
2
|
+
export declare const NOTION_MCP_CREDENTIAL_KEY = "notion_mcp_access_token";
|
|
3
|
+
export declare const NOTION_OAUTH_STATE_KEY = "notion_oauth";
|
|
4
|
+
export declare const NOTION_OAUTH_PORT = 18982;
|
|
5
|
+
export type NotionTokens = OAuthTokens;
|
|
6
|
+
export declare function registerNotionClient(fetchImpl?: Fetch): Promise<string>;
|
|
7
|
+
export declare function buildNotionAuthUrl(opts: {
|
|
8
|
+
clientId: string;
|
|
9
|
+
state: string;
|
|
10
|
+
challenge: string;
|
|
11
|
+
}): string;
|
|
12
|
+
export declare function exchangeNotionCode(opts: {
|
|
13
|
+
clientId: string;
|
|
14
|
+
code: string;
|
|
15
|
+
verifier: string;
|
|
16
|
+
fetch?: Fetch;
|
|
17
|
+
}): Promise<NotionTokens>;
|
|
18
|
+
export declare function refreshNotionToken(opts: {
|
|
19
|
+
clientId: string;
|
|
20
|
+
refreshToken: string;
|
|
21
|
+
fetch?: Fetch;
|
|
22
|
+
}): Promise<NotionTokens>;
|
|
23
|
+
export declare function connectNotion(opts: {
|
|
24
|
+
openUrl: (url: string) => unknown;
|
|
25
|
+
fetch?: Fetch;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
}): Promise<NotionTokens & {
|
|
28
|
+
clientId: string;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function resolveNotionCredential(opts: {
|
|
31
|
+
engine: ConfigEngine;
|
|
32
|
+
agentId?: string;
|
|
33
|
+
fetch?: Fetch;
|
|
34
|
+
}): Promise<string | null>;
|
|
@@ -0,0 +1,82 @@
|
|
|
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 NOTION_MCP_CREDENTIAL_KEY = 'notion_mcp_access_token';
|
|
7
|
+
export const NOTION_OAUTH_STATE_KEY = 'notion_oauth';
|
|
8
|
+
export const NOTION_OAUTH_PORT = 18982;
|
|
9
|
+
const REDIRECT_URI = oauthRedirectUri(NOTION_OAUTH_PORT);
|
|
10
|
+
const AUTH_URL = 'https://mcp.notion.com/authorize';
|
|
11
|
+
const TOKEN_URL = 'https://mcp.notion.com/token';
|
|
12
|
+
const REGISTER_URL = 'https://mcp.notion.com/register';
|
|
13
|
+
export async function registerNotionClient(fetchImpl = defaultFetch) {
|
|
14
|
+
const response = await fetchImpl(REGISTER_URL, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
17
|
+
body: JSON.stringify({
|
|
18
|
+
client_name: 'QV.AC assistant',
|
|
19
|
+
redirect_uris: [REDIRECT_URI],
|
|
20
|
+
token_endpoint_auth_method: 'none',
|
|
21
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
22
|
+
response_types: ['code']
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
const text = await response.text().catch(() => '');
|
|
27
|
+
throw new Error(`Notion client registration failed (${response.status}): ${text.slice(0, 256)}`);
|
|
28
|
+
}
|
|
29
|
+
const raw = (await response.json());
|
|
30
|
+
if (!raw.client_id)
|
|
31
|
+
throw new Error('Notion registration returned no client_id');
|
|
32
|
+
return raw.client_id;
|
|
33
|
+
}
|
|
34
|
+
export function buildNotionAuthUrl(opts) {
|
|
35
|
+
const params = new URLSearchParams({
|
|
36
|
+
response_type: 'code',
|
|
37
|
+
client_id: opts.clientId,
|
|
38
|
+
redirect_uri: REDIRECT_URI,
|
|
39
|
+
state: opts.state,
|
|
40
|
+
code_challenge: opts.challenge,
|
|
41
|
+
code_challenge_method: 'S256'
|
|
42
|
+
});
|
|
43
|
+
return `${AUTH_URL}?${params.toString()}`;
|
|
44
|
+
}
|
|
45
|
+
export async function exchangeNotionCode(opts) {
|
|
46
|
+
return tokenRequest(opts.fetch ?? defaultFetch, TOKEN_URL, new URLSearchParams({
|
|
47
|
+
grant_type: 'authorization_code',
|
|
48
|
+
code: opts.code,
|
|
49
|
+
redirect_uri: REDIRECT_URI,
|
|
50
|
+
client_id: opts.clientId,
|
|
51
|
+
code_verifier: opts.verifier
|
|
52
|
+
}), 'Notion');
|
|
53
|
+
}
|
|
54
|
+
export async function refreshNotionToken(opts) {
|
|
55
|
+
const tokens = await tokenRequest(opts.fetch ?? defaultFetch, TOKEN_URL, new URLSearchParams({
|
|
56
|
+
grant_type: 'refresh_token',
|
|
57
|
+
refresh_token: opts.refreshToken,
|
|
58
|
+
client_id: opts.clientId
|
|
59
|
+
}), 'Notion');
|
|
60
|
+
return { ...tokens, refreshToken: tokens.refreshToken ?? opts.refreshToken };
|
|
61
|
+
}
|
|
62
|
+
export async function connectNotion(opts) {
|
|
63
|
+
const fetch = opts.fetch ?? defaultFetch;
|
|
64
|
+
const clientId = await registerNotionClient(fetch);
|
|
65
|
+
const tokens = await runBrowserConnect({
|
|
66
|
+
port: NOTION_OAUTH_PORT,
|
|
67
|
+
timeoutMs: opts.timeoutMs,
|
|
68
|
+
openUrl: opts.openUrl,
|
|
69
|
+
buildAuthUrl: ({ state, challenge }) => buildNotionAuthUrl({ clientId, state, challenge }),
|
|
70
|
+
exchange: ({ code, verifier }) => exchangeNotionCode({ clientId, code, verifier, fetch })
|
|
71
|
+
});
|
|
72
|
+
return { ...tokens, clientId };
|
|
73
|
+
}
|
|
74
|
+
export async function resolveNotionCredential(opts) {
|
|
75
|
+
return resolveOAuthCredential({
|
|
76
|
+
...opts,
|
|
77
|
+
credentialKey: NOTION_MCP_CREDENTIAL_KEY,
|
|
78
|
+
stateKey: NOTION_OAUTH_STATE_KEY,
|
|
79
|
+
requireClientSecret: false,
|
|
80
|
+
refresh: async ({ clientId, refreshToken, fetch }) => refreshNotionToken({ clientId, refreshToken, fetch })
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type RandomBytes = (size: number) => Uint8Array;
|
|
2
|
+
export type PkceChallenge = {
|
|
3
|
+
readonly verifier: string;
|
|
4
|
+
readonly challenge: string;
|
|
5
|
+
readonly method: 'S256';
|
|
6
|
+
};
|
|
7
|
+
export declare function generatePkceChallenge(randomBytes?: RandomBytes): PkceChallenge;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { bytesToBase64Url, randomBase64Url, sha256Base64Url } from '@qvac/core/oauth/runtime/crypto';
|
|
2
|
+
export function generatePkceChallenge(randomBytes) {
|
|
3
|
+
const verifier = randomBytes ? bytesToBase64Url(randomBytes(32)) : randomBase64Url(32);
|
|
4
|
+
const challenge = sha256Base64Url(verifier);
|
|
5
|
+
return { verifier, challenge, method: 'S256' };
|
|
6
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthProvider, OAuthProviderConfig } from './types.ts';
|
|
2
|
+
export declare function providerRequiresSecret(provider: OAuthProvider): boolean;
|
|
3
|
+
export declare function providerSupportsDcr(provider: OAuthProvider): boolean;
|
|
4
|
+
export declare function providerSupportsSharedIosSession(provider: OAuthProvider): boolean;
|
|
5
|
+
export declare function buildProviderConfig(credentialKey: string, credentials: OAuthCredentials): OAuthProviderConfig;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { OAUTH_PROVIDER_PORTS, oauthKeySpec } from "./keys.js";
|
|
2
|
+
const ASANA_MCP_RESOURCE = 'https://mcp.asana.com/v2';
|
|
3
|
+
export function providerRequiresSecret(provider) {
|
|
4
|
+
return provider === 'google' || provider === 'asana';
|
|
5
|
+
}
|
|
6
|
+
export function providerSupportsDcr(provider) {
|
|
7
|
+
return provider === 'notion';
|
|
8
|
+
}
|
|
9
|
+
export function providerSupportsSharedIosSession(provider) {
|
|
10
|
+
return provider === 'spotify' || provider === 'notion';
|
|
11
|
+
}
|
|
12
|
+
export function buildProviderConfig(credentialKey, credentials) {
|
|
13
|
+
const spec = oauthKeySpec(credentialKey);
|
|
14
|
+
if (!spec)
|
|
15
|
+
throw new Error(`Unknown OAuth credential key: ${credentialKey}`);
|
|
16
|
+
const { provider } = spec;
|
|
17
|
+
if (provider === 'google') {
|
|
18
|
+
return {
|
|
19
|
+
clientId: credentials.clientId,
|
|
20
|
+
clientSecret: requireSecret(credentials.clientSecret, provider),
|
|
21
|
+
tokenAuth: 'secret-in-body',
|
|
22
|
+
authUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
23
|
+
tokenUrl: 'https://oauth2.googleapis.com/token',
|
|
24
|
+
scopes: spec.scopes,
|
|
25
|
+
credentialKey: spec.credentialKey,
|
|
26
|
+
port: OAUTH_PROVIDER_PORTS[provider],
|
|
27
|
+
extraAuthParams: { access_type: 'offline', prompt: 'consent' }
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (provider === 'spotify') {
|
|
31
|
+
return {
|
|
32
|
+
clientId: credentials.clientId,
|
|
33
|
+
tokenAuth: 'pkce-only',
|
|
34
|
+
authUrl: 'https://accounts.spotify.com/authorize',
|
|
35
|
+
tokenUrl: 'https://accounts.spotify.com/api/token',
|
|
36
|
+
scopes: spec.scopes,
|
|
37
|
+
credentialKey: spec.credentialKey,
|
|
38
|
+
port: OAUTH_PROVIDER_PORTS[provider]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (provider === 'asana') {
|
|
42
|
+
return {
|
|
43
|
+
clientId: credentials.clientId,
|
|
44
|
+
clientSecret: requireSecret(credentials.clientSecret, provider),
|
|
45
|
+
tokenAuth: 'secret-in-body',
|
|
46
|
+
authUrl: 'https://app.asana.com/-/oauth_authorize',
|
|
47
|
+
tokenUrl: 'https://app.asana.com/-/oauth_token',
|
|
48
|
+
scopes: spec.scopes,
|
|
49
|
+
credentialKey: spec.credentialKey,
|
|
50
|
+
port: OAUTH_PROVIDER_PORTS[provider],
|
|
51
|
+
extraAuthParams: { resource: ASANA_MCP_RESOURCE }
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (provider === 'notion') {
|
|
55
|
+
return {
|
|
56
|
+
clientId: credentials.clientId,
|
|
57
|
+
tokenAuth: 'pkce-only',
|
|
58
|
+
authUrl: 'https://mcp.notion.com/authorize',
|
|
59
|
+
tokenUrl: 'https://mcp.notion.com/token',
|
|
60
|
+
registrationEndpoint: 'https://mcp.notion.com/register',
|
|
61
|
+
dynamicRegistration: true,
|
|
62
|
+
scopes: spec.scopes,
|
|
63
|
+
credentialKey: spec.credentialKey,
|
|
64
|
+
port: OAUTH_PROVIDER_PORTS[provider]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`Unknown OAuth provider: ${String(provider)}`);
|
|
68
|
+
}
|
|
69
|
+
function requireSecret(secret, provider) {
|
|
70
|
+
if (!secret)
|
|
71
|
+
throw new Error(`Client secret is required for ${provider}.`);
|
|
72
|
+
return secret;
|
|
73
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type OAuthCallbackResult = {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly state: string;
|
|
4
|
+
};
|
|
5
|
+
export type OAuthLoopbackServer = {
|
|
6
|
+
readonly redirectUri: string;
|
|
7
|
+
readonly waitForCode: (timeoutMs?: number, expectedState?: string) => Promise<OAuthCallbackResult>;
|
|
8
|
+
readonly close: () => void;
|
|
9
|
+
};
|
|
10
|
+
export type OAuthRedirect = {
|
|
11
|
+
readonly redirectUri: string;
|
|
12
|
+
readonly authorize: (authUrl: string, timeoutMs?: number, expectedState?: string) => Promise<OAuthCallbackResult>;
|
|
13
|
+
readonly close: () => void;
|
|
14
|
+
};
|
|
15
|
+
export type OAuthRedirectFactory = (target: {
|
|
16
|
+
readonly port: number;
|
|
17
|
+
}, deps: {
|
|
18
|
+
readonly openUrl: (url: string) => Promise<void>;
|
|
19
|
+
}) => Promise<OAuthRedirect>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { OAuthFetch, OAuthFlowDeps, OAuthProviderConfig } from './types.ts';
|
|
2
|
+
export declare function registerOAuthClient(config: OAuthProviderConfig, redirectUri: string, fetchImpl?: OAuthFetch): Promise<string>;
|
|
3
|
+
export declare function resolveDynamicClientId(config: OAuthProviderConfig, redirectUri: string, deps: OAuthFlowDeps, fetchImpl?: OAuthFetch): Promise<string>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
const RegistrationResponseSchema = z.object({
|
|
3
|
+
client_id: z.string().min(1)
|
|
4
|
+
});
|
|
5
|
+
export async function registerOAuthClient(config, redirectUri, fetchImpl = globalThis.fetch) {
|
|
6
|
+
if (!config.registrationEndpoint) {
|
|
7
|
+
throw new Error('Dynamic client registration requested without a registration endpoint');
|
|
8
|
+
}
|
|
9
|
+
const response = await fetchImpl(config.registrationEndpoint, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
12
|
+
body: JSON.stringify({
|
|
13
|
+
client_name: 'QV.AC',
|
|
14
|
+
redirect_uris: [redirectUri],
|
|
15
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
16
|
+
response_types: ['code'],
|
|
17
|
+
token_endpoint_auth_method: 'none',
|
|
18
|
+
application_type: 'native'
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
const text = await response.text().catch(() => '');
|
|
23
|
+
throw new Error(`Client registration failed (${response.status}): ${text}`);
|
|
24
|
+
}
|
|
25
|
+
return RegistrationResponseSchema.parse(await response.json()).client_id;
|
|
26
|
+
}
|
|
27
|
+
export async function resolveDynamicClientId(config, redirectUri, deps, fetchImpl = globalThis.fetch) {
|
|
28
|
+
const cached = await deps.getClientId?.();
|
|
29
|
+
if (cached)
|
|
30
|
+
return cached;
|
|
31
|
+
const clientId = await registerOAuthClient(config, redirectUri, fetchImpl);
|
|
32
|
+
await deps.saveClientId?.(clientId);
|
|
33
|
+
return clientId;
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ConfigEngine, type Fetch, type OAuthTokens } from './common.ts';
|
|
2
|
+
type RefreshFn = (opts: {
|
|
3
|
+
clientId: string;
|
|
4
|
+
clientSecret?: string;
|
|
5
|
+
refreshToken: string;
|
|
6
|
+
fetch?: Fetch;
|
|
7
|
+
}) => Promise<OAuthTokens>;
|
|
8
|
+
export declare function resolveOAuthCredential(opts: {
|
|
9
|
+
engine: ConfigEngine;
|
|
10
|
+
agentId?: string;
|
|
11
|
+
credentialKey: string;
|
|
12
|
+
stateKey: string;
|
|
13
|
+
refresh: RefreshFn;
|
|
14
|
+
requireClientSecret?: boolean;
|
|
15
|
+
fetch?: Fetch;
|
|
16
|
+
}): Promise<string | null>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { REFRESH_SKEW_MS, scopedKey } from "./common.js";
|
|
2
|
+
const inFlightRefresh = new Map();
|
|
3
|
+
export async function resolveOAuthCredential(opts) {
|
|
4
|
+
const { engine, agentId, credentialKey, stateKey, refresh, requireClientSecret = false } = opts;
|
|
5
|
+
const { value: token } = await engine.configGet({ key: scopedKey(agentId, credentialKey) });
|
|
6
|
+
if (typeof token !== 'string')
|
|
7
|
+
return null;
|
|
8
|
+
const { value: raw } = await engine.configGet({ key: scopedKey(agentId, stateKey) });
|
|
9
|
+
if (typeof raw !== 'string')
|
|
10
|
+
return token;
|
|
11
|
+
let stored;
|
|
12
|
+
try {
|
|
13
|
+
stored = JSON.parse(raw);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return token;
|
|
17
|
+
}
|
|
18
|
+
const { refreshToken, expiresAt, clientId, clientSecret } = stored ?? {};
|
|
19
|
+
if (!refreshToken || !clientId)
|
|
20
|
+
return token;
|
|
21
|
+
if (requireClientSecret && !clientSecret)
|
|
22
|
+
return token;
|
|
23
|
+
if (typeof expiresAt !== 'number' || expiresAt - REFRESH_SKEW_MS > Date.now())
|
|
24
|
+
return token;
|
|
25
|
+
const refreshKey = `${credentialKey}:${agentId ?? ''}`;
|
|
26
|
+
try {
|
|
27
|
+
let pending = inFlightRefresh.get(refreshKey);
|
|
28
|
+
if (!pending) {
|
|
29
|
+
pending = (async () => {
|
|
30
|
+
const refreshed = await refresh({
|
|
31
|
+
clientId,
|
|
32
|
+
clientSecret,
|
|
33
|
+
refreshToken,
|
|
34
|
+
fetch: opts.fetch
|
|
35
|
+
});
|
|
36
|
+
await engine.configSet({
|
|
37
|
+
key: scopedKey(agentId, credentialKey),
|
|
38
|
+
value: refreshed.accessToken
|
|
39
|
+
});
|
|
40
|
+
await engine.configSet({
|
|
41
|
+
key: scopedKey(agentId, stateKey),
|
|
42
|
+
value: JSON.stringify({
|
|
43
|
+
...stored,
|
|
44
|
+
refreshToken: refreshed.refreshToken,
|
|
45
|
+
expiresAt: refreshed.expiresAt
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
return refreshed.accessToken;
|
|
49
|
+
})().finally(() => inFlightRefresh.delete(refreshKey));
|
|
50
|
+
inFlightRefresh.set(refreshKey, pending);
|
|
51
|
+
}
|
|
52
|
+
return await pending;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return token;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ConfigEngine, type Fetch, type OAuthTokens } from './common.ts';
|
|
2
|
+
export declare const SPOTIFY_CREDENTIAL_KEY = "spotify_access_token";
|
|
3
|
+
export declare const SPOTIFY_OAUTH_STATE_KEY = "spotify_oauth";
|
|
4
|
+
export declare const SPOTIFY_OAUTH_PORT = 18974;
|
|
5
|
+
export type SpotifyTokens = OAuthTokens;
|
|
6
|
+
export declare function buildSpotifyAuthUrl(opts: {
|
|
7
|
+
clientId: string;
|
|
8
|
+
state: string;
|
|
9
|
+
challenge: string;
|
|
10
|
+
}): string;
|
|
11
|
+
export declare function exchangeSpotifyCode(opts: {
|
|
12
|
+
clientId: string;
|
|
13
|
+
code: string;
|
|
14
|
+
verifier: string;
|
|
15
|
+
fetch?: Fetch;
|
|
16
|
+
}): Promise<SpotifyTokens>;
|
|
17
|
+
export declare function refreshSpotifyToken(opts: {
|
|
18
|
+
clientId: string;
|
|
19
|
+
refreshToken: string;
|
|
20
|
+
fetch?: Fetch;
|
|
21
|
+
}): Promise<SpotifyTokens>;
|
|
22
|
+
export declare function connectSpotify(opts: {
|
|
23
|
+
clientId: string;
|
|
24
|
+
openUrl: (url: string) => unknown;
|
|
25
|
+
fetch?: Fetch;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
}): Promise<SpotifyTokens>;
|
|
28
|
+
export declare function resolveSpotifyCredential(opts: {
|
|
29
|
+
engine: ConfigEngine;
|
|
30
|
+
agentId?: string;
|
|
31
|
+
fetch?: Fetch;
|
|
32
|
+
}): Promise<string | null>;
|