@qvac/core 0.3.0 → 0.3.2
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/dist-lib/lib/api/chat.d.ts +3 -1
- package/dist-lib/lib/api/chat.js +6 -2
- package/dist-lib/lib/api/index.d.ts +2 -0
- package/dist-lib/lib/api/index.js +3 -1
- package/dist-lib/lib/api/inference-calls.d.ts +18 -0
- package/dist-lib/lib/api/inference-calls.js +15 -0
- package/dist-lib/lib/api/rag.js +10 -2
- package/dist-lib/lib/assistant/harness.d.ts +1 -0
- package/dist-lib/lib/assistant/history.d.ts +10 -1
- package/dist-lib/lib/assistant/history.js +36 -1
- package/dist-lib/lib/assistant/message.d.ts +2 -0
- package/dist-lib/lib/assistant/message.js +11 -0
- package/dist-lib/lib/assistant/skill-encode.js +27 -1
- package/dist-lib/lib/assistant-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +11 -2
- package/dist-lib/lib/assistant.d.ts +19 -3
- package/dist-lib/lib/assistant.js +148 -23
- package/dist-lib/lib/core/chunk.js +5 -0
- package/dist-lib/lib/core/files/rag/build.d.ts +1 -2
- package/dist-lib/lib/core/files/rag/build.js +1 -2
- package/dist-lib/lib/core/files/rag/extract/office-collabora.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/index.d.ts +4 -24
- package/dist-lib/lib/core/files/rag/index.js +3 -17
- package/dist-lib/lib/core/files/rag/load.d.ts +1 -2
- package/dist-lib/lib/core/files/rag/load.js +1 -2
- package/dist-lib/lib/core/files/rag/produce.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/produce.js +1 -3
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +1 -4
- package/dist-lib/lib/core/files/rag/similarity.d.ts +5 -0
- package/dist-lib/lib/core/files/rag/similarity.js +6 -0
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/inference-calls-handoff.d.ts +20 -0
- package/dist-lib/lib/core/inference-calls-handoff.js +37 -0
- package/dist-lib/lib/core/inference-calls-receiver.d.ts +14 -0
- package/dist-lib/lib/core/inference-calls-receiver.js +39 -0
- package/dist-lib/lib/core/notification.js +5 -4
- package/dist-lib/lib/core/skill-secrets.js +3 -6
- package/dist-lib/lib/core.d.ts +9 -1
- package/dist-lib/lib/core.js +129 -13
- package/dist-lib/lib/credential-pusher.d.ts +2 -3
- package/dist-lib/lib/credential-pusher.js +67 -39
- package/dist-lib/lib/inference-calls.d.ts +40 -0
- package/dist-lib/lib/inference-calls.js +266 -0
- package/dist-lib/lib/integrations/index.d.ts +1 -2
- package/dist-lib/lib/integrations/index.js +0 -1
- package/dist-lib/lib/integrations/setup-routes.js +0 -15
- package/dist-lib/lib/oauth/flow-core.js +1 -1
- package/dist-lib/lib/oauth/flow.d.ts +4 -2
- package/dist-lib/lib/oauth/flow.js +3 -4
- package/dist-lib/lib/oauth/host.d.ts +3 -1
- package/dist-lib/lib/oauth/host.js +3 -1
- package/dist-lib/lib/oauth/keys.d.ts +21 -20
- package/dist-lib/lib/oauth/keys.js +59 -85
- package/dist-lib/lib/oauth/loopback.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.js +32 -19
- package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.stub.js +2 -2
- package/dist-lib/lib/oauth/providers.d.ts +3 -5
- package/dist-lib/lib/oauth/providers.js +20 -67
- package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
- package/dist-lib/lib/oauth/registry.d.ts +10 -0
- package/dist-lib/lib/oauth/registry.js +25 -0
- package/dist-lib/lib/oauth/resolve.js +1 -1
- package/dist-lib/lib/oauth/token-exchange-core.js +2 -1
- package/dist-lib/lib/oauth/types.d.ts +1 -1
- package/dist-lib/lib/oauth.client.d.ts +3 -1
- package/dist-lib/lib/oauth.client.js +3 -1
- package/dist-lib/lib/oauth.d.ts +4 -7
- package/dist-lib/lib/oauth.js +4 -7
- package/dist-lib/lib/skill-types.d.ts +12 -0
- package/dist-lib/schema/content.js +5 -1
- package/dist-lib/schema/engine.js +63 -2
- package/dist-lib/schema/qvac.js +4 -2
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/capabilities.d.ts +2 -0
- package/dist-lib/spec/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +284 -52
- package/dist-lib/spec/hyperschema/index.js +284 -52
- package/dist-lib/spec/hyperschema/schema.json +210 -1
- package/dist-lib/spec/hyperschema/types.d.ts +51 -1
- package/dist-lib/spec/local/hyperdb/messages.js +64 -128
- package/dist-lib/spec/local/hyperschema/index.js +32 -64
- package/dist-lib/spec/local/hyperschema/schema.json +16 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +176 -311
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +132 -236
- package/dist-lib/spec/mesh/hyperschema/index.js +132 -236
- package/dist-lib/spec/mesh/hyperschema/schema.json +70 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +3 -1
- package/package.json +15 -18
- package/tui/app.mjs +98 -155
- package/tui/lib/knowledge-import.mjs +1 -1
- package/tui/lib/save-file.mjs +1 -1
- package/.claude/skills/asana/SKILL.md +0 -86
- package/.claude/skills/compaction/SKILL.md +0 -136
- package/.claude/skills/device-mesh-debug/SKILL.md +0 -328
- package/.claude/skills/gh-stack/SKILL.md +0 -181
- package/.claude/skills/gh-stack/references/commands.md +0 -177
- package/.claude/skills/gh-stack/references/stack-design.md +0 -97
- package/.claude/skills/gh-stack/references/troubleshooting.md +0 -159
- package/.claude/skills/js-house-style/SKILL.md +0 -671
- package/.claude/skills/pr-create/SKILL.md +0 -243
- package/.claude/skills/pr-review/SKILL.md +0 -428
- package/.claude/skills/release/SKILL.md +0 -122
- package/CLAUDE.md +0 -48
- package/dist-lib/lib/core/files/rag/artifact/codec.d.ts +0 -3
- package/dist-lib/lib/core/files/rag/artifact/codec.js +0 -172
- package/dist-lib/lib/core/files/rag/artifact/id.d.ts +0 -10
- package/dist-lib/lib/core/files/rag/artifact/id.js +0 -39
- package/dist-lib/lib/core/files/rag/artifact/types.d.ts +0 -24
- package/dist-lib/lib/core/files/rag/artifact/types.js +0 -41
- package/dist-lib/lib/core/files/rag/chunk/chunking.d.ts +0 -12
- package/dist-lib/lib/core/files/rag/chunk/chunking.js +0 -117
- package/dist-lib/lib/core/files/rag/chunk/metadata.d.ts +0 -30
- package/dist-lib/lib/core/files/rag/chunk/metadata.js +0 -89
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.d.ts +0 -7
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.js +0 -18
- package/dist-lib/lib/core/files/rag/extract/csv-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/csv-text.js +0 -117
- package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +0 -22
- package/dist-lib/lib/core/files/rag/extract/document-types.js +0 -152
- package/dist-lib/lib/core/files/rag/extract/extract.d.ts +0 -17
- package/dist-lib/lib/core/files/rag/extract/extract.js +0 -81
- package/dist-lib/lib/core/files/rag/extract/html-table-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/html-table-text.js +0 -125
- package/dist-lib/lib/core/files/rag/extract/html-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/html-text.js +0 -132
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.d.ts +0 -17
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +0 -141
- package/dist-lib/lib/core/files/rag/extract/pdf-text.d.ts +0 -12
- package/dist-lib/lib/core/files/rag/extract/pdf-text.js +0 -43
- package/dist-lib/lib/core/files/rag/extract/rtf-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/rtf-text.js +0 -15
- package/dist-lib/lib/core/files/rag/extract/text-decoding.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/text-decoding.js +0 -91
- package/dist-lib/lib/core/files/rag/extract/types.d.ts +0 -36
- package/dist-lib/lib/core/files/rag/extract/types.js +0 -12
- package/dist-lib/lib/core/files/rag/extract/utf.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/extract/utf.js +0 -18
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.js +0 -16
- package/dist-lib/lib/core/files/rag/retrieval/coverage.d.ts +0 -4
- package/dist-lib/lib/core/files/rag/retrieval/coverage.js +0 -48
- package/dist-lib/lib/core/files/rag/retrieval/diversity.d.ts +0 -10
- package/dist-lib/lib/core/files/rag/retrieval/diversity.js +0 -37
- package/dist-lib/lib/core/files/rag/retrieval/floor.d.ts +0 -5
- package/dist-lib/lib/core/files/rag/retrieval/floor.js +0 -21
- package/dist-lib/lib/core/files/rag/retrieval/format.d.ts +0 -6
- package/dist-lib/lib/core/files/rag/retrieval/format.js +0 -21
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +0 -54
- package/dist-lib/lib/core/files/rag/retrieval/notices.d.ts +0 -16
- package/dist-lib/lib/core/files/rag/retrieval/notices.js +0 -27
- package/dist-lib/lib/core/files/rag/retrieval/scoring.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/scoring.js +0 -82
- package/dist-lib/lib/core/files/rag/retrieval/search.d.ts +0 -3
- package/dist-lib/lib/core/files/rag/retrieval/search.js +0 -49
- package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +0 -11
- package/dist-lib/lib/core/files/rag/retrieval/selection.js +0 -93
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.d.ts +0 -6
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.js +0 -79
- package/dist-lib/lib/core/files/rag/retrieval/sources.d.ts +0 -13
- package/dist-lib/lib/core/files/rag/retrieval/sources.js +0 -20
- package/dist-lib/lib/core/files/rag/retrieval/target.d.ts +0 -13
- package/dist-lib/lib/core/files/rag/retrieval/target.js +0 -89
- package/dist-lib/lib/core/files/rag/retrieval/terms.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/terms.js +0 -70
- package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +0 -29
- package/dist-lib/lib/core/files/rag/retrieval/types.js +0 -1
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +0 -41
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.js +0 -96
- package/dist-lib/lib/core/files/rag/vector/memory.d.ts +0 -15
- package/dist-lib/lib/core/files/rag/vector/memory.js +0 -135
- package/dist-lib/lib/core/files/rag/vector/types.d.ts +0 -28
- package/dist-lib/lib/core/files/rag/vector/types.js +0 -1
- package/dist-lib/lib/integrations/oauth-providers.d.ts +0 -14
- package/dist-lib/lib/integrations/oauth-providers.js +0 -116
- package/dist-lib/lib/oauth/asana.d.ts +0 -35
- package/dist-lib/lib/oauth/asana.js +0 -71
- package/dist-lib/lib/oauth/google.d.ts +0 -37
- package/dist-lib/lib/oauth/google.js +0 -77
- package/dist-lib/lib/oauth/notion.d.ts +0 -34
- package/dist-lib/lib/oauth/notion.js +0 -82
- package/dist-lib/lib/oauth/spotify.d.ts +0 -32
- package/dist-lib/lib/oauth/spotify.js +0 -74
- package/dist-lib/lib/oauth/verify.d.ts +0 -8
- package/dist-lib/lib/oauth/verify.js +0 -58
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY } from './obsidian-key.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { scopedKey } from './oauth.js';
|
|
3
|
+
import { oauthSpecs } from './oauth/registry.js';
|
|
4
|
+
import { resolveOAuthCredential } from './oauth/resolve.js';
|
|
5
|
+
import { buildProviderConfig } from './oauth/providers.js';
|
|
6
|
+
import { refreshOAuthTokens } from './oauth/token-exchange.js';
|
|
4
7
|
import ScopeLock from 'scope-lock';
|
|
5
8
|
import { credentialSlots } from '@qvac/harness/lib/tools/skills/credential-slots.ts';
|
|
6
9
|
import { REFRESH_SKEW_MS } from './oauth/common.js';
|
|
7
|
-
const RESOLVE_BY_PROVIDER = {
|
|
8
|
-
google: resolveGoogleCredential,
|
|
9
|
-
spotify: resolveSpotifyCredential,
|
|
10
|
-
notion: resolveNotionCredential,
|
|
11
|
-
asana: resolveAsanaCredential
|
|
12
|
-
};
|
|
13
|
-
export function oauthStateKeyFor(credentialKey) {
|
|
14
|
-
return specStateKeyFor(credentialKey);
|
|
15
|
-
}
|
|
16
10
|
const PLAIN_KEYS = ['github_access_token', OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY];
|
|
17
11
|
const REFRESH_INTERVAL = 10 * 60 * 1000;
|
|
18
12
|
const MIN_REFRESH_DELAY = 30_000;
|
|
@@ -31,9 +25,16 @@ export function nextRefreshDelay(entries, now = Date.now()) {
|
|
|
31
25
|
return REFRESH_INTERVAL;
|
|
32
26
|
return Math.min(REFRESH_INTERVAL, Math.max(MIN_REFRESH_DELAY, nearest - now - REFRESH_SKEW_MS));
|
|
33
27
|
}
|
|
34
|
-
async function oauthEntry(engine,
|
|
35
|
-
const
|
|
36
|
-
const token = await
|
|
28
|
+
async function oauthEntry(engine, spec, agentId) {
|
|
29
|
+
const { credentialKey, stateKey } = spec;
|
|
30
|
+
const token = await resolveOAuthCredential({
|
|
31
|
+
engine,
|
|
32
|
+
agentId,
|
|
33
|
+
credentialKey,
|
|
34
|
+
stateKey,
|
|
35
|
+
requireClientSecret: spec.tokenAuth !== 'pkce-only',
|
|
36
|
+
refresh: (args) => refreshOAuthTokens(buildProviderConfig(spec, { clientId: args.clientId, clientSecret: args.clientSecret }), args.refreshToken)
|
|
37
|
+
});
|
|
37
38
|
if (!token)
|
|
38
39
|
return null;
|
|
39
40
|
const { value } = await engine.configGet({
|
|
@@ -92,16 +93,13 @@ export function settingFields(catalog) {
|
|
|
92
93
|
export function settingConfigKey(agentId, skill, key) {
|
|
93
94
|
return scopedKey(agentId, `settings.${skill}.${key}`);
|
|
94
95
|
}
|
|
95
|
-
export function oauthStateKey(credentialKey) {
|
|
96
|
-
return specStateKeyFor(credentialKey) ?? undefined;
|
|
97
|
-
}
|
|
98
96
|
function fanOut(entry, owners) {
|
|
99
97
|
const skills = owners.get(entry.key) ?? [];
|
|
100
98
|
return skills.length > 0 ? skills.map((skill) => ({ ...entry, skill })) : [entry];
|
|
101
99
|
}
|
|
102
|
-
async function resolveScope(engine, agentId, last, owners, logger) {
|
|
100
|
+
async function resolveScope(engine, agentId, last, owners, specs, logger) {
|
|
103
101
|
const entries = [];
|
|
104
|
-
for (const spec of
|
|
102
|
+
for (const spec of specs) {
|
|
105
103
|
const mk = storeKey(spec.credentialKey, agentId);
|
|
106
104
|
try {
|
|
107
105
|
const entry = await oauthEntry(engine, spec, agentId);
|
|
@@ -120,7 +118,10 @@ async function resolveScope(engine, agentId, last, owners, logger) {
|
|
|
120
118
|
entries.push(...fanOut(kept, owners));
|
|
121
119
|
}
|
|
122
120
|
}
|
|
121
|
+
const specKeys = new Set(specs.map((spec) => spec.credentialKey));
|
|
123
122
|
for (const key of PLAIN_KEYS) {
|
|
123
|
+
if (specKeys.has(key))
|
|
124
|
+
continue;
|
|
124
125
|
const mk = storeKey(key, agentId);
|
|
125
126
|
try {
|
|
126
127
|
const entry = await plainEntry(engine, key, agentId);
|
|
@@ -166,10 +167,48 @@ async function resolveSettings(engine, scopes, catalog, logger) {
|
|
|
166
167
|
}
|
|
167
168
|
export function startCredentialPusher(harness, engine, logger) {
|
|
168
169
|
const last = new Map();
|
|
169
|
-
const watches =
|
|
170
|
+
const watches = new Map();
|
|
170
171
|
let disposed = false;
|
|
171
172
|
let timer = null;
|
|
172
173
|
const pushLock = new ScopeLock({ debounce: true });
|
|
174
|
+
const watch = (key) => {
|
|
175
|
+
const stream = engine.configWatch({ key: scopedKey(undefined, key) });
|
|
176
|
+
watches.set(key, stream);
|
|
177
|
+
(async () => {
|
|
178
|
+
for await (const _ of stream)
|
|
179
|
+
schedule();
|
|
180
|
+
if (disposed || watches.get(key) !== stream)
|
|
181
|
+
return;
|
|
182
|
+
logger?.warn('credential-pusher', `credential watch ended for ${key}, change propagation degrades to the interval until restart`);
|
|
183
|
+
})().catch((err) => {
|
|
184
|
+
if (disposed || watches.get(key) !== stream)
|
|
185
|
+
return;
|
|
186
|
+
logger?.warn('credential-pusher', `credential watch ended for ${key}`, errorMessage(err));
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
const syncWatches = (oauthKeys) => {
|
|
190
|
+
if (disposed)
|
|
191
|
+
return;
|
|
192
|
+
const wanted = new Set([...oauthKeys, ...PLAIN_KEYS]);
|
|
193
|
+
for (const [key, stream] of watches) {
|
|
194
|
+
if (wanted.has(key))
|
|
195
|
+
continue;
|
|
196
|
+
try {
|
|
197
|
+
stream.destroy();
|
|
198
|
+
}
|
|
199
|
+
catch { }
|
|
200
|
+
watches.delete(key);
|
|
201
|
+
}
|
|
202
|
+
for (const key of wanted) {
|
|
203
|
+
if (!watches.has(key))
|
|
204
|
+
watch(key);
|
|
205
|
+
}
|
|
206
|
+
for (const mk of last.keys()) {
|
|
207
|
+
const key = mk.includes('\0') ? mk.slice(mk.indexOf('\0') + 1) : mk;
|
|
208
|
+
if (!wanted.has(key))
|
|
209
|
+
last.delete(mk);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
173
212
|
const armTimer = (delay) => {
|
|
174
213
|
if (disposed)
|
|
175
214
|
return;
|
|
@@ -188,18 +227,22 @@ export function startCredentialPusher(harness, engine, logger) {
|
|
|
188
227
|
}
|
|
189
228
|
catch (err) {
|
|
190
229
|
logger?.warn('credential-pusher', 'skill catalog read failed', errorMessage(err));
|
|
191
|
-
return
|
|
230
|
+
return null;
|
|
192
231
|
}
|
|
193
232
|
};
|
|
194
233
|
const pushAll = async () => {
|
|
195
234
|
const entries = [];
|
|
196
235
|
try {
|
|
197
236
|
const skills = await catalog();
|
|
237
|
+
if (skills === null)
|
|
238
|
+
return;
|
|
198
239
|
const owners = credentialOwners(skills);
|
|
240
|
+
const specs = oauthSpecs(skills);
|
|
241
|
+
syncWatches(specs.map((spec) => spec.credentialKey));
|
|
199
242
|
const ids = (await engine.listAgents({})).agents.map((agent) => agent.id);
|
|
200
243
|
const scopes = [undefined, ...ids];
|
|
201
244
|
for (const agentId of scopes) {
|
|
202
|
-
entries.push(...(await resolveScope(engine, agentId, last, owners, logger)));
|
|
245
|
+
entries.push(...(await resolveScope(engine, agentId, last, owners, specs, logger)));
|
|
203
246
|
}
|
|
204
247
|
if (disposed)
|
|
205
248
|
return;
|
|
@@ -250,22 +293,6 @@ export function startCredentialPusher(harness, engine, logger) {
|
|
|
250
293
|
pushLock.unlock();
|
|
251
294
|
}
|
|
252
295
|
};
|
|
253
|
-
const watchKeys = [...OAUTH_KEY_SPECS.map((s) => s.credentialKey), ...PLAIN_KEYS];
|
|
254
|
-
for (const key of watchKeys) {
|
|
255
|
-
const stream = engine.configWatch({ key: scopedKey(undefined, key) });
|
|
256
|
-
watches.push(stream);
|
|
257
|
-
(async () => {
|
|
258
|
-
for await (const _ of stream)
|
|
259
|
-
schedule();
|
|
260
|
-
if (disposed)
|
|
261
|
-
return;
|
|
262
|
-
logger?.warn('credential-pusher', `credential watch ended for ${key}, change propagation degrades to the interval until restart`);
|
|
263
|
-
})().catch((err) => {
|
|
264
|
-
if (disposed)
|
|
265
|
-
return;
|
|
266
|
-
logger?.warn('credential-pusher', `credential watch ended for ${key}`, errorMessage(err));
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
296
|
schedule();
|
|
270
297
|
const stop = async () => {
|
|
271
298
|
if (disposed)
|
|
@@ -274,12 +301,13 @@ export function startCredentialPusher(harness, engine, logger) {
|
|
|
274
301
|
if (timer)
|
|
275
302
|
clearTimeout(timer);
|
|
276
303
|
timer = null;
|
|
277
|
-
for (const stream of watches) {
|
|
304
|
+
for (const stream of watches.values()) {
|
|
278
305
|
try {
|
|
279
306
|
stream.destroy();
|
|
280
307
|
}
|
|
281
308
|
catch { }
|
|
282
309
|
}
|
|
310
|
+
watches.clear();
|
|
283
311
|
pushLock.destroy();
|
|
284
312
|
await pushLock.flush();
|
|
285
313
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface InferenceCallEntry {
|
|
2
|
+
runId: string;
|
|
3
|
+
at: number;
|
|
4
|
+
call: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare function defaultInferenceCallsDir(): string;
|
|
7
|
+
export declare const MAX_TOTAL_BYTES: number;
|
|
8
|
+
export declare const MAX_AGE_MS: number;
|
|
9
|
+
export declare class InferenceCallStore {
|
|
10
|
+
private readonly _dir;
|
|
11
|
+
private readonly _writes;
|
|
12
|
+
constructor(dir?: string);
|
|
13
|
+
record(chatId: string, entry: InferenceCallEntry): Promise<void>;
|
|
14
|
+
recordSent(chatId: string, sent: {
|
|
15
|
+
runId: string;
|
|
16
|
+
round: number;
|
|
17
|
+
messages: unknown;
|
|
18
|
+
tokens: unknown;
|
|
19
|
+
outcome: unknown;
|
|
20
|
+
reason: unknown;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
recordOutcome(chatId: string, verdict: {
|
|
23
|
+
runId: string;
|
|
24
|
+
outcome: string;
|
|
25
|
+
reason: string | null;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
list(chatId: string): {
|
|
28
|
+
calls: ReadonlyArray<InferenceCallEntry>;
|
|
29
|
+
truncated: boolean;
|
|
30
|
+
};
|
|
31
|
+
forget(chatId: string): Promise<void>;
|
|
32
|
+
sweep(limits?: {
|
|
33
|
+
maxTotalBytes?: number;
|
|
34
|
+
maxAgeMs?: number;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
removed: number;
|
|
37
|
+
}>;
|
|
38
|
+
private _drop;
|
|
39
|
+
private _chatSizes;
|
|
40
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { persistent } from 'bare-storage';
|
|
4
|
+
import { WriteQueue } from './write-queue.js';
|
|
5
|
+
export function defaultInferenceCallsDir() {
|
|
6
|
+
return join(persistent(), 'qvac', 'inspector');
|
|
7
|
+
}
|
|
8
|
+
const CALLS_FILE = 'calls.jsonl';
|
|
9
|
+
const BLOCKS_DIR = 'blocks';
|
|
10
|
+
const MAX_CALLS_BYTES = 8 * 1024 * 1024;
|
|
11
|
+
export const MAX_TOTAL_BYTES = 64 * 1024 * 1024;
|
|
12
|
+
export const MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;
|
|
13
|
+
const MAX_LINES_READ = 600;
|
|
14
|
+
export class InferenceCallStore {
|
|
15
|
+
_dir;
|
|
16
|
+
_writes;
|
|
17
|
+
constructor(dir = defaultInferenceCallsDir()) {
|
|
18
|
+
this._dir = dir;
|
|
19
|
+
this._writes = new WriteQueue();
|
|
20
|
+
}
|
|
21
|
+
record(chatId, entry) {
|
|
22
|
+
return this._writes.run(chatId, 'inference-call', async () => {
|
|
23
|
+
const { system, tools, promptPrefix, rest } = split(entry.call);
|
|
24
|
+
const chatDir = join(this._dir, safeName(chatId));
|
|
25
|
+
await fs.promises.mkdir(join(chatDir, BLOCKS_DIR), { recursive: true });
|
|
26
|
+
const callsPath = join(chatDir, CALLS_FILE);
|
|
27
|
+
if (((await sizeOf(callsPath)) ?? 0) > MAX_CALLS_BYTES)
|
|
28
|
+
return;
|
|
29
|
+
if (promptPrefix) {
|
|
30
|
+
const blockPath = join(chatDir, BLOCKS_DIR, `${safeName(promptPrefix)}.json`);
|
|
31
|
+
await fs.promises
|
|
32
|
+
.writeFile(blockPath, JSON.stringify({ system, tools }), { flag: 'wx' })
|
|
33
|
+
.catch(() => undefined);
|
|
34
|
+
}
|
|
35
|
+
const line = JSON.stringify({ runId: entry.runId, at: entry.at, ...rest });
|
|
36
|
+
await fs.promises.appendFile(callsPath, `${line}\n`);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
recordSent(chatId, sent) {
|
|
40
|
+
return this._writes.run(chatId, 'inference-sent', async () => {
|
|
41
|
+
const chatDir = join(this._dir, safeName(chatId));
|
|
42
|
+
const callsPath = join(chatDir, CALLS_FILE);
|
|
43
|
+
const size = await sizeOf(callsPath);
|
|
44
|
+
if (size === null || size > MAX_CALLS_BYTES)
|
|
45
|
+
return;
|
|
46
|
+
const line = JSON.stringify({
|
|
47
|
+
sentFor: sent.round,
|
|
48
|
+
sentRun: sent.runId,
|
|
49
|
+
sent: sent.messages,
|
|
50
|
+
tokens: sent.tokens,
|
|
51
|
+
outcome: sent.outcome,
|
|
52
|
+
reason: sent.reason
|
|
53
|
+
});
|
|
54
|
+
await fs.promises.appendFile(callsPath, `${line}\n`);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
recordOutcome(chatId, verdict) {
|
|
58
|
+
return this._writes.run(chatId, 'inference-outcome', async () => {
|
|
59
|
+
const callsPath = join(this._dir, safeName(chatId), CALLS_FILE);
|
|
60
|
+
const size = await sizeOf(callsPath);
|
|
61
|
+
if (size === null || size > MAX_CALLS_BYTES)
|
|
62
|
+
return;
|
|
63
|
+
const line = JSON.stringify({
|
|
64
|
+
outcomeFor: verdict.runId,
|
|
65
|
+
outcome: verdict.outcome,
|
|
66
|
+
reason: verdict.reason
|
|
67
|
+
});
|
|
68
|
+
await fs.promises.appendFile(callsPath, `${line}\n`);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
list(chatId) {
|
|
72
|
+
const chatDir = join(this._dir, safeName(chatId));
|
|
73
|
+
const all = readLines(join(chatDir, CALLS_FILE));
|
|
74
|
+
const lines = all.slice(-MAX_LINES_READ);
|
|
75
|
+
const blocks = new Map();
|
|
76
|
+
const entries = [];
|
|
77
|
+
for (const line of lines) {
|
|
78
|
+
const parsed = parseLine(line);
|
|
79
|
+
if (!parsed)
|
|
80
|
+
continue;
|
|
81
|
+
if ('sentFor' in parsed) {
|
|
82
|
+
foldSent(entries, parsed);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if ('outcomeFor' in parsed) {
|
|
86
|
+
foldOutcome(entries, parsed);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const { runId, at, ...rest } = parsed;
|
|
90
|
+
const prefix = typeof rest.promptPrefix === 'string' ? rest.promptPrefix : '';
|
|
91
|
+
const block = prefix ? readBlock(blocks, chatDir, prefix) : null;
|
|
92
|
+
const messages = Array.isArray(rest.messages) ? rest.messages : [];
|
|
93
|
+
entries.push({
|
|
94
|
+
runId: String(runId ?? ''),
|
|
95
|
+
at: Number(at ?? 0),
|
|
96
|
+
call: {
|
|
97
|
+
...rest,
|
|
98
|
+
tools: block ? block.tools : (rest.tools ?? null),
|
|
99
|
+
messages: block?.system
|
|
100
|
+
? [{ role: 'system', content: block.system }, ...messages]
|
|
101
|
+
: messages
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return { calls: entries, truncated: all.length > lines.length };
|
|
106
|
+
}
|
|
107
|
+
forget(chatId) {
|
|
108
|
+
return this._writes.run(chatId, 'inference-forget', () => fs.promises.rm(join(this._dir, safeName(chatId)), { recursive: true, force: true }));
|
|
109
|
+
}
|
|
110
|
+
async sweep(limits = {}) {
|
|
111
|
+
const maxTotalBytes = limits.maxTotalBytes ?? MAX_TOTAL_BYTES;
|
|
112
|
+
const maxAgeMs = limits.maxAgeMs ?? MAX_AGE_MS;
|
|
113
|
+
const chats = await this._chatSizes();
|
|
114
|
+
const cutoff = Date.now() - maxAgeMs;
|
|
115
|
+
const aged = chats.filter((chat) => chat.mtimeMs < cutoff);
|
|
116
|
+
let removed = 0;
|
|
117
|
+
for (const chat of aged) {
|
|
118
|
+
await this._drop(chat.name);
|
|
119
|
+
removed++;
|
|
120
|
+
}
|
|
121
|
+
const kept = chats
|
|
122
|
+
.filter((chat) => chat.mtimeMs >= cutoff)
|
|
123
|
+
.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
124
|
+
let total = kept.reduce((sum, chat) => sum + chat.bytes, 0);
|
|
125
|
+
for (const chat of kept) {
|
|
126
|
+
if (total <= maxTotalBytes)
|
|
127
|
+
break;
|
|
128
|
+
await this._drop(chat.name);
|
|
129
|
+
total -= chat.bytes;
|
|
130
|
+
removed++;
|
|
131
|
+
}
|
|
132
|
+
return { removed };
|
|
133
|
+
}
|
|
134
|
+
async _drop(name) {
|
|
135
|
+
await fs.promises.rm(join(this._dir, name), { recursive: true, force: true });
|
|
136
|
+
}
|
|
137
|
+
async _chatSizes() {
|
|
138
|
+
let names;
|
|
139
|
+
try {
|
|
140
|
+
names = await fs.promises.readdir(this._dir);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
const chats = [];
|
|
146
|
+
for (const name of names) {
|
|
147
|
+
const measured = await measureDir(join(this._dir, name));
|
|
148
|
+
if (measured)
|
|
149
|
+
chats.push({ name, ...measured });
|
|
150
|
+
}
|
|
151
|
+
return chats;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function measureDir(dir) {
|
|
155
|
+
let bytes = 0;
|
|
156
|
+
let mtimeMs = 0;
|
|
157
|
+
const visit = async (path) => {
|
|
158
|
+
const stat = await fs.promises.stat(path);
|
|
159
|
+
if (stat.isDirectory()) {
|
|
160
|
+
for (const child of await fs.promises.readdir(path))
|
|
161
|
+
await visit(join(path, child));
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
bytes += stat.size;
|
|
165
|
+
mtimeMs = Math.max(mtimeMs, stat.mtimeMs);
|
|
166
|
+
};
|
|
167
|
+
try {
|
|
168
|
+
await visit(dir);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return { bytes, mtimeMs };
|
|
174
|
+
}
|
|
175
|
+
function foldSent(entries, parsed) {
|
|
176
|
+
const round = Number(parsed.sentFor ?? -1);
|
|
177
|
+
const runId = parsed.sentRun === undefined ? null : String(parsed.sentRun);
|
|
178
|
+
for (let index = entries.length - 1; index >= 0; index--) {
|
|
179
|
+
const entry = entries[index];
|
|
180
|
+
if (runId !== null && entry?.runId !== runId)
|
|
181
|
+
continue;
|
|
182
|
+
if (entry && Number(entry.call.round ?? -1) === round) {
|
|
183
|
+
entry.call.sent = parsed.sent ?? null;
|
|
184
|
+
entry.call.tokens = parsed.tokens ?? null;
|
|
185
|
+
entry.call.outcome = parsed.outcome ?? null;
|
|
186
|
+
entry.call.reason = parsed.reason ?? null;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function foldOutcome(entries, parsed) {
|
|
192
|
+
const runId = String(parsed.outcomeFor ?? '');
|
|
193
|
+
for (const entry of entries) {
|
|
194
|
+
if (entry.runId !== runId || entry.call.outcome)
|
|
195
|
+
continue;
|
|
196
|
+
entry.call.outcome = parsed.outcome ?? null;
|
|
197
|
+
entry.call.reason = parsed.reason ?? null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function split(call) {
|
|
201
|
+
const { messages, tools, ...rest } = call;
|
|
202
|
+
const turns = Array.isArray(messages) ? messages : [];
|
|
203
|
+
const promptPrefix = typeof rest.promptPrefix === 'string' ? rest.promptPrefix : '';
|
|
204
|
+
if (!promptPrefix) {
|
|
205
|
+
return { system: null, tools: null, promptPrefix, rest: { ...rest, messages: turns, tools } };
|
|
206
|
+
}
|
|
207
|
+
const system = turns.find((turn) => isSystemTurn(turn));
|
|
208
|
+
return {
|
|
209
|
+
system: system ? String(system.content) : null,
|
|
210
|
+
tools: tools ?? null,
|
|
211
|
+
promptPrefix,
|
|
212
|
+
rest: { ...rest, messages: turns.filter((turn) => !isSystemTurn(turn)) }
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function isSystemTurn(turn) {
|
|
216
|
+
return typeof turn === 'object' && turn !== null && 'role' in turn && turn.role === 'system';
|
|
217
|
+
}
|
|
218
|
+
function readBlock(cache, chatDir, prefix) {
|
|
219
|
+
const hit = cache.get(prefix);
|
|
220
|
+
if (hit)
|
|
221
|
+
return hit;
|
|
222
|
+
const raw = readFile(join(chatDir, BLOCKS_DIR, `${safeName(prefix)}.json`));
|
|
223
|
+
if (!raw)
|
|
224
|
+
return null;
|
|
225
|
+
const parsed = parseBlock(raw);
|
|
226
|
+
if (parsed)
|
|
227
|
+
cache.set(prefix, parsed);
|
|
228
|
+
return parsed;
|
|
229
|
+
}
|
|
230
|
+
function parseLine(line) {
|
|
231
|
+
try {
|
|
232
|
+
const value = JSON.parse(line);
|
|
233
|
+
return typeof value === 'object' && value !== null ? value : null;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function parseBlock(raw) {
|
|
240
|
+
const parsed = parseLine(raw);
|
|
241
|
+
return parsed ? { system: parsed.system ?? null, tools: parsed.tools ?? null } : null;
|
|
242
|
+
}
|
|
243
|
+
function readLines(path) {
|
|
244
|
+
const raw = readFile(path);
|
|
245
|
+
return raw ? raw.split('\n').filter((line) => line.length > 0) : [];
|
|
246
|
+
}
|
|
247
|
+
function readFile(path) {
|
|
248
|
+
try {
|
|
249
|
+
return fs.readFileSync(path, 'utf8');
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async function sizeOf(path) {
|
|
256
|
+
try {
|
|
257
|
+
return (await fs.promises.stat(path)).size;
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function safeName(value) {
|
|
264
|
+
const fenced = value.replace(/[^A-Za-z0-9._-]/g, '_');
|
|
265
|
+
return /^\.*$/.test(fenced) ? `_${fenced}` : fenced;
|
|
266
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type { SkillSetup, SkillSetupField, SkillSetupRoute } from '../skill-types.ts';
|
|
1
|
+
export type { SkillOAuthConfig, SkillSetup, SkillSetupField, SkillSetupRoute } from '../skill-types.ts';
|
|
2
2
|
export { isMcpTokenProvider, MCP_TOKEN_PROVIDERS, type McpProviderConfig, type McpTokenProvider, resolveMcpProvider } from './mcp-providers.ts';
|
|
3
|
-
export { OAUTH_PROVIDERS, type OAuthIntegrationConfig, resolveOAuthProviderByCredentialKey } from './oauth-providers.ts';
|
|
4
3
|
export { deriveSetupRoutes, SETUP_ROUTE_KIND } from './setup-routes.ts';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY } from '../obsidian-key.js';
|
|
2
2
|
import { MCP_TOKEN_PROVIDERS } from './mcp-providers.js';
|
|
3
|
-
import { resolveOAuthProviderByCredentialKey } from './oauth-providers.js';
|
|
4
3
|
const UNSUPPORTED_STATE = 'unsupported';
|
|
5
4
|
export const SETUP_ROUTE_KIND = {
|
|
6
5
|
oauth: 'oauth',
|
|
@@ -67,20 +66,6 @@ function credentialKeysFor(entry) {
|
|
|
67
66
|
return entry.metadata.requires?.credentials ?? [];
|
|
68
67
|
}
|
|
69
68
|
function credentialRoute(credentialKey) {
|
|
70
|
-
const oauth = resolveOAuthProviderByCredentialKey(credentialKey);
|
|
71
|
-
if (oauth) {
|
|
72
|
-
return {
|
|
73
|
-
kind: SETUP_ROUTE_KIND.oauth,
|
|
74
|
-
label: `Connect ${oauth.label}`,
|
|
75
|
-
provider: oauth.provider,
|
|
76
|
-
credentialKey,
|
|
77
|
-
description: oauth.description,
|
|
78
|
-
helpUrl: oauth.helpUrl,
|
|
79
|
-
fields: oauth.fields,
|
|
80
|
-
steps: oauth.guide,
|
|
81
|
-
configSteps: oauth.configGuide
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
69
|
const token = MCP_TOKEN_PROVIDERS.find((config) => config.credentialKey === credentialKey);
|
|
85
70
|
if (token) {
|
|
86
71
|
return {
|
|
@@ -18,7 +18,7 @@ function buildAuthParams(config, clientId, redirectUri, state, pkce) {
|
|
|
18
18
|
export async function runOAuthFlowWithRuntime(config, deps, runtime) {
|
|
19
19
|
const openUrl = deps.openUrl ??
|
|
20
20
|
(() => Promise.reject(new Error('OAuth browser launcher is unavailable; inject openUrl or createRedirect')));
|
|
21
|
-
const redirect = await deps.createRedirect({ port: config.port }, { openUrl });
|
|
21
|
+
const redirect = await deps.createRedirect({ port: config.port, credentialKey: config.credentialKey }, { openUrl });
|
|
22
22
|
try {
|
|
23
23
|
const clientId = config.dynamicRegistration && !config.clientId
|
|
24
24
|
? await resolveDynamicClientId(config, redirect.redirectUri, deps, runtime.fetch)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type { OAuthFlowDeps,
|
|
2
|
-
export declare function cancelOAuthFlow(
|
|
1
|
+
import type { OAuthFlowDeps, OAuthProviderConfig, OAuthTokens } from './types.ts';
|
|
2
|
+
export declare function cancelOAuthFlow(target: {
|
|
3
|
+
credentialKey: string;
|
|
4
|
+
}): Promise<boolean>;
|
|
3
5
|
export declare function runOAuthFlow(config: OAuthProviderConfig, deps?: OAuthFlowDeps): Promise<OAuthTokens>;
|
|
@@ -2,12 +2,11 @@ import { abortOAuthLoopback, startOAuthLoopback } from '#oauth-loopback';
|
|
|
2
2
|
import { randomBase64Url, sha256Base64Url } from '@qvac/core/oauth/runtime/crypto';
|
|
3
3
|
import defaultFetch from '@qvac/core/oauth/runtime/fetch';
|
|
4
4
|
import { runOAuthFlowWithRuntime } from './flow-core.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return abortOAuthLoopback(OAUTH_PROVIDER_PORTS[provider]);
|
|
5
|
+
export function cancelOAuthFlow(target) {
|
|
6
|
+
return abortOAuthLoopback(target.credentialKey);
|
|
8
7
|
}
|
|
9
8
|
const loopbackRedirect = async (target, deps) => {
|
|
10
|
-
const loopback = await startOAuthLoopback(target.port);
|
|
9
|
+
const loopback = await startOAuthLoopback(target.port, target.credentialKey);
|
|
11
10
|
return {
|
|
12
11
|
redirectUri: loopback.redirectUri,
|
|
13
12
|
async authorize(authUrl, timeoutMs, expectedState) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export { buildProviderConfig
|
|
1
|
+
export { buildProviderConfig } from './providers.ts';
|
|
2
|
+
export { specFromRoute, type OAuthKeySpec, type OAuthRouteLike } from './keys.ts';
|
|
3
|
+
export { oauthSpecFor, oauthSpecs } from './registry.ts';
|
|
2
4
|
export { isTokenExpired, refreshOAuthTokens } from './token-exchange.ts';
|
|
3
5
|
export { cancelOAuthFlow, runOAuthFlow } from './flow.ts';
|
|
4
6
|
export type { OAuthCredentials, OAuthFlowDeps, OAuthFlowResult, OAuthProvider, OAuthProviderConfig, OAuthTokens } from './types.ts';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export { buildProviderConfig
|
|
1
|
+
export { buildProviderConfig } from './providers.js';
|
|
2
|
+
export { specFromRoute } from './keys.js';
|
|
3
|
+
export { oauthSpecFor, oauthSpecs } from './registry.js';
|
|
2
4
|
export { isTokenExpired, refreshOAuthTokens } from './token-exchange.js';
|
|
3
5
|
export { cancelOAuthFlow, runOAuthFlow } from './flow.js';
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SkillOAuthConfig } from '@qvac/harness';
|
|
2
2
|
export declare function scopedKey(agentId: string | undefined, key: string): string;
|
|
3
|
-
export
|
|
4
|
-
export declare const GOOGLE_CALENDAR_CREDENTIAL_KEY = "google_calendar_access_token";
|
|
5
|
-
export declare const GOOGLE_DOCS_CREDENTIAL_KEY = "google_docs_access_token";
|
|
6
|
-
export declare const GOOGLE_DRIVE_CREDENTIAL_KEY = "google_drive_access_token";
|
|
7
|
-
export declare const GOOGLE_SHEETS_CREDENTIAL_KEY = "google_sheets_access_token";
|
|
8
|
-
export declare const SPOTIFY_CREDENTIAL_KEY = "spotify_access_token";
|
|
9
|
-
export declare const ASANA_MCP_CREDENTIAL_KEY = "asana_mcp_access_token";
|
|
10
|
-
export declare const NOTION_MCP_CREDENTIAL_KEY = "notion_mcp_access_token";
|
|
11
|
-
export declare const LEGACY_GOOGLE_CREDENTIAL_KEY = "google_workspace_access_token";
|
|
12
|
-
export type OAuthKeySpec = {
|
|
3
|
+
export type OAuthKeySpec = SkillOAuthConfig & {
|
|
13
4
|
readonly credentialKey: string;
|
|
14
|
-
readonly
|
|
15
|
-
readonly provider: OAuthProvider;
|
|
16
|
-
readonly scopes: ReadonlyArray<string>;
|
|
5
|
+
readonly provider: string;
|
|
17
6
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
type OAuthConfigLike = {
|
|
8
|
+
readonly stateKey?: string | null | undefined;
|
|
9
|
+
readonly authUrl?: string | null | undefined;
|
|
10
|
+
readonly tokenUrl?: string | null | undefined;
|
|
11
|
+
readonly scopes?: ReadonlyArray<string> | null | undefined;
|
|
12
|
+
readonly tokenAuth?: string | null | undefined;
|
|
13
|
+
readonly extraAuthParams?: unknown;
|
|
14
|
+
readonly registrationEndpoint?: string | null | undefined;
|
|
15
|
+
readonly port?: number | null | undefined;
|
|
16
|
+
readonly sharedIosSession?: boolean | null | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type OAuthRouteLike = {
|
|
19
|
+
readonly credentialKey?: string | null | undefined;
|
|
20
|
+
readonly provider?: string | null | undefined;
|
|
21
|
+
readonly oauth?: OAuthConfigLike | null | undefined;
|
|
22
|
+
};
|
|
23
|
+
export declare function specFromRoute(route: OAuthRouteLike): OAuthKeySpec | null;
|
|
24
24
|
export declare const OAUTH_CALLBACK_PATH = "/callback";
|
|
25
25
|
export declare const OAUTH_WAIT_FOR_CODE_TIMEOUT_MS = 120000;
|
|
26
26
|
export declare function oauthRedirectUri(port: number): string;
|
|
27
|
+
export {};
|