@qvac/core 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/compaction/SKILL.md +15 -6
- package/.claude/skills/js-house-style/SKILL.md +1 -0
- package/.claude/skills/pr-create/SKILL.md +66 -3
- package/.claude/skills/pr-review/SKILL.md +252 -40
- package/.claude/skills/release/SKILL.md +122 -0
- package/CLAUDE.md +8 -5
- package/README.md +3 -1
- package/dist-lib/client.js +1 -1
- package/dist-lib/index.js +8 -8
- package/dist-lib/lib/api/agents.d.ts +1 -1
- package/dist-lib/lib/api/agents.js +10 -10
- package/dist-lib/lib/api/app-config.js +1 -1
- package/dist-lib/lib/api/approval-rules.js +9 -5
- package/dist-lib/lib/api/attachments.js +25 -3
- package/dist-lib/lib/api/chat-groups.d.ts +1 -1
- package/dist-lib/lib/api/chat-groups.js +5 -4
- package/dist-lib/lib/api/chat.js +10 -10
- package/dist-lib/lib/api/chunks.d.ts +1 -1
- package/dist-lib/lib/api/chunks.js +11 -21
- package/dist-lib/lib/api/config.js +1 -1
- package/dist-lib/lib/api/current-mesh.d.ts +16 -1
- package/dist-lib/lib/api/current-mesh.js +18 -0
- package/dist-lib/lib/api/custom-models.js +2 -2
- package/dist-lib/lib/api/devices.d.ts +1 -1
- package/dist-lib/lib/api/devices.js +12 -9
- package/dist-lib/lib/api/diagnostics.js +1 -1
- package/dist-lib/lib/api/effective-ctx-size.js +1 -1
- package/dist-lib/lib/api/execution.js +4 -4
- package/dist-lib/lib/api/files.js +2 -2
- package/dist-lib/lib/api/index.d.ts +1 -0
- package/dist-lib/lib/api/index.js +34 -34
- package/dist-lib/lib/api/instrument.js +1 -1
- package/dist-lib/lib/api/knowledge.js +13 -9
- package/dist-lib/lib/api/logs.js +1 -1
- package/dist-lib/lib/api/members.d.ts +4 -1
- package/dist-lib/lib/api/members.js +87 -18
- package/dist-lib/lib/api/mesh.d.ts +13 -3
- package/dist-lib/lib/api/mesh.js +25 -2
- package/dist-lib/lib/api/model-download.js +1 -1
- package/dist-lib/lib/api/network.js +1 -1
- package/dist-lib/lib/api/notifications.js +3 -3
- package/dist-lib/lib/api/rag.js +7 -7
- package/dist-lib/lib/api/sync.d.ts +1 -1
- package/dist-lib/lib/api/sync.js +3 -2
- package/dist-lib/lib/api/tool-activity.js +5 -5
- package/dist-lib/lib/api/tool-configs.js +5 -5
- package/dist-lib/lib/api/watchable.d.ts +6 -1
- package/dist-lib/lib/api/watchable.js +14 -3
- package/dist-lib/lib/assistant/fetch-body.d.ts +5 -0
- package/dist-lib/lib/assistant/fetch-body.js +36 -0
- package/dist-lib/lib/assistant/harness.d.ts +225 -0
- package/dist-lib/lib/assistant/harness.js +154 -0
- package/dist-lib/lib/assistant/history.d.ts +31 -0
- package/dist-lib/lib/assistant/history.js +226 -0
- package/dist-lib/lib/assistant/message.d.ts +45 -0
- package/dist-lib/lib/assistant/message.js +47 -0
- package/dist-lib/lib/assistant/skill-encode.d.ts +21 -0
- package/dist-lib/lib/assistant/skill-encode.js +71 -0
- package/dist-lib/lib/assistant-client.js +2 -2
- package/dist-lib/lib/assistant-tree.js +10 -4
- package/dist-lib/lib/assistant.d.ts +28 -292
- package/dist-lib/lib/assistant.js +284 -716
- package/dist-lib/lib/audio-format.js +2 -2
- package/dist-lib/lib/client.js +2 -2
- package/dist-lib/lib/collabora/convert.js +1 -1
- package/dist-lib/lib/collabora/entry.js +1 -1
- package/dist-lib/lib/collabora/worker.js +1 -1
- package/dist-lib/lib/compaction.d.ts +1 -2
- package/dist-lib/lib/compaction.js +8 -6
- package/dist-lib/lib/constants.js +1 -1
- package/dist-lib/lib/core/account-recovery.d.ts +19 -0
- package/dist-lib/lib/core/account-recovery.js +50 -0
- package/dist-lib/lib/core/agent.js +8 -4
- package/dist-lib/lib/core/app-build.d.ts +1 -1
- package/dist-lib/lib/core/approval-rules.d.ts +1 -0
- package/dist-lib/lib/core/approval-rules.js +3 -1
- package/dist-lib/lib/core/archived-mesh.d.ts +25 -0
- package/dist-lib/lib/core/archived-mesh.js +162 -0
- package/dist-lib/lib/core/chat-activity.js +1 -1
- package/dist-lib/lib/core/chat-group.d.ts +1 -0
- package/dist-lib/lib/core/chat-group.js +24 -4
- package/dist-lib/lib/core/chat-search.js +2 -2
- package/dist-lib/lib/core/chat.js +5 -5
- package/dist-lib/lib/core/chunk.d.ts +2 -1
- package/dist-lib/lib/core/chunk.js +31 -4
- package/dist-lib/lib/core/contract/agents.js +1 -1
- package/dist-lib/lib/core/contract/approval-rules.js +6 -4
- package/dist-lib/lib/core/contract/attestations.js +1 -1
- package/dist-lib/lib/core/contract/chat-group.js +1 -1
- package/dist-lib/lib/core/contract/chat.js +1 -1
- package/dist-lib/lib/core/contract/chunks.js +2 -2
- package/dist-lib/lib/core/contract/compute.d.ts +11 -0
- package/dist-lib/lib/core/contract/compute.js +45 -0
- package/dist-lib/lib/core/contract/devices.js +19 -5
- package/dist-lib/lib/core/contract/index.d.ts +3 -1
- package/dist-lib/lib/core/contract/index.js +19 -16
- package/dist-lib/lib/core/contract/indexing.js +2 -2
- package/dist-lib/lib/core/contract/joined-meshes.js +1 -1
- package/dist-lib/lib/core/contract/knowledge.js +2 -2
- package/dist-lib/lib/core/contract/members.js +2 -2
- package/dist-lib/lib/core/contract/seal.d.ts +2 -0
- package/dist-lib/lib/core/contract/seal.js +8 -0
- package/dist-lib/lib/core/contract/seed-defaults.js +1 -1
- package/dist-lib/lib/core/contract/tool-activity.js +1 -1
- package/dist-lib/lib/core/contract/tool-configs.js +3 -3
- package/dist-lib/lib/core/contract/writers.js +66 -42
- package/dist-lib/lib/core/departures.js +1 -1
- package/dist-lib/lib/core/device-invites.js +1 -1
- package/dist-lib/lib/core/document-attachment.js +2 -2
- package/dist-lib/lib/core/files/attachments.js +3 -3
- package/dist-lib/lib/core/files/index.d.ts +2 -2
- package/dist-lib/lib/core/files/index.js +19 -19
- package/dist-lib/lib/core/files/knowledge.js +3 -3
- package/dist-lib/lib/core/files/preview/image.js +1 -1
- package/dist-lib/lib/core/files/preview/index.js +6 -6
- package/dist-lib/lib/core/files/processing/claims.js +1 -1
- package/dist-lib/lib/core/files/processing/document.js +5 -5
- package/dist-lib/lib/core/files/processing/index.js +8 -8
- package/dist-lib/lib/core/files/processing/ownership.js +1 -1
- package/dist-lib/lib/core/files/processing/protocol.js +3 -3
- package/dist-lib/lib/core/files/processing/source.js +1 -1
- package/dist-lib/lib/core/files/rag/artifact/codec.js +1 -1
- package/dist-lib/lib/core/files/rag/artifact/id.js +1 -1
- package/dist-lib/lib/core/files/rag/artifact/types.d.ts +4 -4
- package/dist-lib/lib/core/files/rag/build.js +2 -2
- package/dist-lib/lib/core/files/rag/chunk/chunking.js +2 -2
- package/dist-lib/lib/core/files/rag/document-types.d.ts +3 -3
- package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +9 -9
- package/dist-lib/lib/core/files/rag/extract/extract.js +7 -7
- package/dist-lib/lib/core/files/rag/extract/html-text.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/office-collabora.js +2 -2
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/pdf-text.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/text-decoding.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/types.d.ts +2 -2
- package/dist-lib/lib/core/files/rag/index.js +22 -22
- package/dist-lib/lib/core/files/rag/load.js +5 -5
- package/dist-lib/lib/core/files/rag/policy.js +2 -2
- package/dist-lib/lib/core/files/rag/produce.js +5 -5
- package/dist-lib/lib/core/files/rag/retrieval/coverage.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/diversity.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/floor.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/format.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +18 -11
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +5 -5
- package/dist-lib/lib/core/files/rag/retrieval/scoring.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/search.js +4 -4
- package/dist-lib/lib/core/files/rag/retrieval/selection.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/sources.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/terms.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +1 -1
- package/dist-lib/lib/core/files/records/chunks.js +1 -1
- package/dist-lib/lib/core/files/records/index.js +8 -8
- package/dist-lib/lib/core/files/records/knowledge.js +2 -2
- package/dist-lib/lib/core/files/records/output.js +1 -1
- package/dist-lib/lib/core/files/records/reclaim.js +5 -5
- package/dist-lib/lib/core/files/records/routing.js +7 -7
- package/dist-lib/lib/core/files/store/blob.js +2 -2
- package/dist-lib/lib/core/files/store/index.js +7 -7
- package/dist-lib/lib/core/files/store/reference.js +2 -2
- package/dist-lib/lib/core/files/store/server.js +1 -1
- package/dist-lib/lib/core/files/store/sweep.js +1 -1
- package/dist-lib/lib/core/files/upload-input.js +2 -2
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/files/upload.js +6 -6
- package/dist-lib/lib/core/harness-loan.d.ts +29 -0
- package/dist-lib/lib/core/harness-loan.js +187 -0
- package/dist-lib/lib/core/helpers/index.d.ts +2 -1
- package/dist-lib/lib/core/helpers/index.js +4 -4
- package/dist-lib/lib/core/hosted-agents.js +2 -2
- package/dist-lib/lib/core/identity.d.ts +2 -0
- package/dist-lib/lib/core/identity.js +4 -2
- package/dist-lib/lib/core/invite.d.ts +1 -0
- package/dist-lib/lib/core/invite.js +4 -2
- package/dist-lib/lib/core/local/index.d.ts +12 -3
- package/dist-lib/lib/core/local/index.js +81 -16
- package/dist-lib/lib/core/membership.d.ts +3 -0
- package/dist-lib/lib/core/membership.js +15 -1
- package/dist-lib/lib/core/mesh-seed-handoff.js +1 -1
- package/dist-lib/lib/core/mesh.d.ts +9 -3
- package/dist-lib/lib/core/mesh.js +41 -26
- package/dist-lib/lib/core/migrations/agent-catalog.js +1 -1
- package/dist-lib/lib/core/migrations/index.js +5 -3
- package/dist-lib/lib/core/migrations/membership.js +2 -2
- package/dist-lib/lib/core/migrations/seal.d.ts +3 -0
- package/dist-lib/lib/core/migrations/seal.js +30 -0
- package/dist-lib/lib/core/next-frame.js +1 -1
- package/dist-lib/lib/core/notification.js +1 -1
- package/dist-lib/lib/core/ota-config.js +1 -1
- package/dist-lib/lib/core/secret-handoff.js +1 -1
- package/dist-lib/lib/core/send.js +3 -3
- package/dist-lib/lib/core/skill-overlay-handoff.js +1 -1
- package/dist-lib/lib/core/skill-overlay-receiver.js +2 -2
- package/dist-lib/lib/core/skill-secrets.js +3 -3
- package/dist-lib/lib/core/sync/devices.js +1 -1
- package/dist-lib/lib/core/sync/index.js +8 -5
- package/dist-lib/lib/core/sync-status.js +1 -1
- package/dist-lib/lib/core/system-info.js +1 -1
- package/dist-lib/lib/core/tool-activity.js +2 -2
- package/dist-lib/lib/core/tool-configs.js +2 -2
- package/dist-lib/lib/core.d.ts +42 -3
- package/dist-lib/lib/core.js +543 -100
- package/dist-lib/lib/credential-pusher.js +4 -4
- package/dist-lib/lib/deadline.js +1 -1
- package/dist-lib/lib/fs-drive-bridge.js +5 -3
- package/dist-lib/lib/integrations/index.js +3 -3
- package/dist-lib/lib/integrations/oauth-providers.js +1 -1
- package/dist-lib/lib/integrations/setup-routes.d.ts +5 -5
- package/dist-lib/lib/integrations/setup-routes.js +3 -3
- package/dist-lib/lib/knowledge-search.js +1 -1
- package/dist-lib/lib/log.js +3 -3
- package/dist-lib/lib/mesh-scoped-engine.d.ts +3 -0
- package/dist-lib/lib/mesh-scoped-engine.js +101 -0
- package/dist-lib/lib/model-context.d.ts +2 -2
- package/dist-lib/lib/model-context.js +1 -1
- package/dist-lib/lib/model-download.d.ts +2 -0
- package/dist-lib/lib/model-download.js +26 -11
- package/dist-lib/lib/oauth/asana.js +3 -3
- package/dist-lib/lib/oauth/browser-connect.js +1 -1
- package/dist-lib/lib/oauth/client.js +2 -2
- package/dist-lib/lib/oauth/common.d.ts +1 -1
- package/dist-lib/lib/oauth/common.js +1 -1
- package/dist-lib/lib/oauth/flow-core.js +3 -3
- package/dist-lib/lib/oauth/flow.js +2 -2
- package/dist-lib/lib/oauth/google.js +4 -4
- package/dist-lib/lib/oauth/host.js +3 -3
- package/dist-lib/lib/oauth/keys.js +1 -0
- package/dist-lib/lib/oauth/loopback.js +1 -1
- package/dist-lib/lib/oauth/notion.js +3 -3
- package/dist-lib/lib/oauth/providers.js +1 -1
- package/dist-lib/lib/oauth/resolve.js +1 -1
- package/dist-lib/lib/oauth/spotify.js +4 -3
- package/dist-lib/lib/oauth/token-exchange.js +1 -1
- package/dist-lib/lib/oauth/verify.d.ts +8 -0
- package/dist-lib/lib/oauth/verify.js +58 -0
- package/dist-lib/lib/oauth.client.js +2 -2
- package/dist-lib/lib/oauth.d.ts +1 -0
- package/dist-lib/lib/oauth.js +13 -12
- package/dist-lib/lib/run-notices.d.ts +7 -7
- package/dist-lib/lib/run-transcript.js +1 -1
- package/dist-lib/schema/build.js +12 -6
- package/dist-lib/schema/content.d.ts +11 -11
- package/dist-lib/schema/engine.js +193 -30
- package/dist-lib/schema/field-order.js +2 -2
- package/dist-lib/schema/local.js +18 -4
- package/dist-lib/schema/qvac.d.ts +3 -0
- package/dist-lib/schema/qvac.js +22 -6
- package/dist-lib/spec/bind.js +41 -0
- package/dist-lib/spec/calls.js +12 -0
- package/dist-lib/spec/capabilities.d.ts +36 -12
- package/dist-lib/spec/hrpc/hrpc.json +161 -5
- package/dist-lib/spec/hrpc/index.js +154 -9
- package/dist-lib/spec/hrpc/messages.js +549 -129
- package/dist-lib/spec/hyperschema/index.js +549 -129
- package/dist-lib/spec/hyperschema/schema.json +370 -40
- package/dist-lib/spec/hyperschema/types.d.ts +85 -1
- package/dist-lib/spec/local/hyperdb/db.json +15 -0
- package/dist-lib/spec/local/hyperdb/index.js +70 -1
- package/dist-lib/spec/local/hyperdb/messages.js +300 -117
- package/dist-lib/spec/local/hyperschema/index.js +97 -4
- package/dist-lib/spec/local/hyperschema/schema.json +58 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +14 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +393 -288
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +6 -0
- package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +176 -85
- package/dist-lib/spec/mesh/hyperschema/index.js +176 -85
- package/dist-lib/spec/mesh/hyperschema/schema.json +71 -21
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +14 -1
- package/package.json +14 -8
- package/tui/README.md +7 -0
- package/tui/app.mjs +633 -55
- package/tui/lib/busy-words.mjs +57 -5
- package/tui/lib/export.mjs +1 -0
- package/tui/lib/render.mjs +25 -2
- package/tui/lib/selection.mjs +16 -0
- package/tui/lib/usage.mjs +54 -0
- package/tui/main.mjs +5 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY } from
|
|
2
|
-
import { resolveAsanaCredential, resolveGoogleCredential, resolveNotionCredential, resolveSpotifyCredential, scopedKey } from
|
|
3
|
-
import { OAUTH_KEY_SPECS, oauthStateKeyFor as specStateKeyFor } from
|
|
1
|
+
import { OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY } from './obsidian-key.js';
|
|
2
|
+
import { resolveAsanaCredential, resolveGoogleCredential, resolveNotionCredential, resolveSpotifyCredential, scopedKey } from './oauth.js';
|
|
3
|
+
import { OAUTH_KEY_SPECS, oauthStateKeyFor as specStateKeyFor } from './oauth/keys.js';
|
|
4
4
|
import ScopeLock from 'scope-lock';
|
|
5
5
|
import { credentialSlots } from '@qvac/harness/lib/tools/skills/credential-slots.ts';
|
|
6
|
-
import { REFRESH_SKEW_MS } from
|
|
6
|
+
import { REFRESH_SKEW_MS } from './oauth/common.js';
|
|
7
7
|
const RESOLVE_BY_PROVIDER = {
|
|
8
8
|
google: resolveGoogleCredential,
|
|
9
9
|
spotify: resolveSpotifyCredential,
|
package/dist-lib/lib/deadline.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { pipelinePromise, Readable } from 'streamx';
|
|
4
|
+
import { AbortController } from 'bare-abort-controller';
|
|
4
5
|
import { STAGING_DIR as HARNESS_STAGING_DIR } from '@qvac/harness/lib/staging.ts';
|
|
5
6
|
import { userTmpPath } from '@qvac/harness/lib/tmp-path.ts';
|
|
6
7
|
import { MAX_DRIVE_BYTES } from '@qvac/harness/lib/tools/fs/remote.ts';
|
|
@@ -12,7 +13,7 @@ export async function sweepDriveStaging(now = Date.now()) {
|
|
|
12
13
|
const names = await fs.promises.readdir(STAGING_DIR).catch(() => []);
|
|
13
14
|
await Promise.all(names.map(async (name) => {
|
|
14
15
|
const file = path.join(STAGING_DIR, name);
|
|
15
|
-
const stat = await fs.promises.stat(file).catch(
|
|
16
|
+
const stat = await fs.promises.stat(file).catch(noop);
|
|
16
17
|
if (stat && now - stat.mtimeMs > STAGING_MAX_AGE_MS) {
|
|
17
18
|
await fs.promises.unlink(file).catch(noop);
|
|
18
19
|
}
|
|
@@ -22,8 +23,9 @@ function withDeadline(op, ms, task) {
|
|
|
22
23
|
const controller = new AbortController();
|
|
23
24
|
const { promise, resolve, reject } = Promise.withResolvers();
|
|
24
25
|
const timer = setTimeout(() => {
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const err = new Error(`drive ${op} timed out on the host`);
|
|
27
|
+
controller.abort(err);
|
|
28
|
+
reject(err);
|
|
27
29
|
}, ms);
|
|
28
30
|
task(controller.signal).then((value) => {
|
|
29
31
|
clearTimeout(timer);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { isMcpTokenProvider, MCP_TOKEN_PROVIDERS, resolveMcpProvider } from
|
|
2
|
-
export { OAUTH_PROVIDERS, resolveOAuthProviderByCredentialKey } from
|
|
3
|
-
export { deriveSetupRoutes, SETUP_ROUTE_KIND } from
|
|
1
|
+
export { isMcpTokenProvider, MCP_TOKEN_PROVIDERS, resolveMcpProvider } from './mcp-providers.js';
|
|
2
|
+
export { OAUTH_PROVIDERS, resolveOAuthProviderByCredentialKey } from './oauth-providers.js';
|
|
3
|
+
export { deriveSetupRoutes, SETUP_ROUTE_KIND } from './setup-routes.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ASANA_MCP_CREDENTIAL_KEY, GMAIL_CREDENTIAL_KEY, GOOGLE_CALENDAR_CREDENTIAL_KEY, GOOGLE_DOCS_CREDENTIAL_KEY, GOOGLE_DRIVE_CREDENTIAL_KEY, GOOGLE_SHEETS_CREDENTIAL_KEY, NOTION_MCP_CREDENTIAL_KEY, SPOTIFY_CREDENTIAL_KEY } from
|
|
1
|
+
import { ASANA_MCP_CREDENTIAL_KEY, GMAIL_CREDENTIAL_KEY, GOOGLE_CALENDAR_CREDENTIAL_KEY, GOOGLE_DOCS_CREDENTIAL_KEY, GOOGLE_DRIVE_CREDENTIAL_KEY, GOOGLE_SHEETS_CREDENTIAL_KEY, NOTION_MCP_CREDENTIAL_KEY, SPOTIFY_CREDENTIAL_KEY } from '../oauth/keys.js';
|
|
2
2
|
const OAUTH_CLIENT_FIELDS = [
|
|
3
3
|
{
|
|
4
4
|
key: 'clientId',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { SkillEntry, SkillSetup } from '../skill-types.ts';
|
|
2
2
|
export declare const SETUP_ROUTE_KIND: {
|
|
3
|
-
readonly oauth:
|
|
4
|
-
readonly token:
|
|
5
|
-
readonly install:
|
|
6
|
-
readonly picker:
|
|
7
|
-
readonly instructions:
|
|
3
|
+
readonly oauth: 'oauth';
|
|
4
|
+
readonly token: 'token';
|
|
5
|
+
readonly install: 'install';
|
|
6
|
+
readonly picker: 'picker';
|
|
7
|
+
readonly instructions: 'instructions';
|
|
8
8
|
};
|
|
9
9
|
export type DeriveSetupOptions = {
|
|
10
10
|
readonly sandboxed?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY } from
|
|
2
|
-
import { MCP_TOKEN_PROVIDERS } from
|
|
3
|
-
import { resolveOAuthProviderByCredentialKey } from
|
|
1
|
+
import { OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY } from '../obsidian-key.js';
|
|
2
|
+
import { MCP_TOKEN_PROVIDERS } from './mcp-providers.js';
|
|
3
|
+
import { resolveOAuthProviderByCredentialKey } from './oauth-providers.js';
|
|
4
4
|
const UNSUPPORTED_STATE = 'unsupported';
|
|
5
5
|
export const SETUP_ROUTE_KIND = {
|
|
6
6
|
oauth: 'oauth',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isWholeDocumentQuery, referencedDocuments } from
|
|
1
|
+
import { isWholeDocumentQuery, referencedDocuments } from './core/files/index.js';
|
|
2
2
|
import { raceAbort } from '@qvac/harness/race-abort';
|
|
3
3
|
export async function searchKnowledge(engine, request, options) {
|
|
4
4
|
const { signal, preparing } = options;
|
package/dist-lib/lib/log.js
CHANGED
|
@@ -2,9 +2,9 @@ import fs from 'fs';
|
|
|
2
2
|
import { dirname } from 'path';
|
|
3
3
|
import FileLog from 'bare-file-logger';
|
|
4
4
|
import SystemLog from 'bare-system-logger';
|
|
5
|
-
import { LogBuffer } from
|
|
6
|
-
import { LEVELS } from
|
|
7
|
-
export { LEVELS } from
|
|
5
|
+
import { LogBuffer } from './log-buffer.js';
|
|
6
|
+
import { LEVELS } from './log-levels.js';
|
|
7
|
+
export { LEVELS } from './log-levels.js';
|
|
8
8
|
const SCOPE = 'qvac-app-core';
|
|
9
9
|
const LOG_BUFFER_CAP = 1000;
|
|
10
10
|
export function isLogLevel(value) {
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export const MESH_SCOPED = new Set([
|
|
2
|
+
'getAgent',
|
|
3
|
+
'agentsWatch',
|
|
4
|
+
'getChat',
|
|
5
|
+
'appendChunk',
|
|
6
|
+
'updateChunk',
|
|
7
|
+
'listChunks',
|
|
8
|
+
'chunksWatch',
|
|
9
|
+
'resolveApproval',
|
|
10
|
+
'listApprovalRules',
|
|
11
|
+
'recordToolActivity',
|
|
12
|
+
'renameChat',
|
|
13
|
+
'listToolConfigs',
|
|
14
|
+
'ragSearch',
|
|
15
|
+
'fileStatusWatch',
|
|
16
|
+
'listKnowledge',
|
|
17
|
+
'knowledgeWatch',
|
|
18
|
+
'listIndexing',
|
|
19
|
+
'indexingWatch',
|
|
20
|
+
'indexingProgressWatch',
|
|
21
|
+
'fileRead',
|
|
22
|
+
'listDevices',
|
|
23
|
+
'devicesWatch',
|
|
24
|
+
'listMembers',
|
|
25
|
+
'membersWatch',
|
|
26
|
+
'listChats',
|
|
27
|
+
'chatsWatch',
|
|
28
|
+
'listAgents',
|
|
29
|
+
'deleteChat',
|
|
30
|
+
'deleteAgent'
|
|
31
|
+
]);
|
|
32
|
+
const DEVICE_LOCAL = new Set([
|
|
33
|
+
'configGet',
|
|
34
|
+
'configSet',
|
|
35
|
+
'configWatch',
|
|
36
|
+
'getConfig',
|
|
37
|
+
'setConfig',
|
|
38
|
+
'setModelPaused',
|
|
39
|
+
'configWatchTyped',
|
|
40
|
+
'modelDownloadsWatch',
|
|
41
|
+
'setModelDownloadStatus',
|
|
42
|
+
'clearModelDownload',
|
|
43
|
+
'retryModelDownload',
|
|
44
|
+
'beginModelTransfer',
|
|
45
|
+
'completeModelTransfer',
|
|
46
|
+
'customModelsWatch',
|
|
47
|
+
'addCustomModel',
|
|
48
|
+
'removeCustomModel',
|
|
49
|
+
'deviceInfo',
|
|
50
|
+
'storeIdentityPhrase',
|
|
51
|
+
'suspend',
|
|
52
|
+
'resume',
|
|
53
|
+
'listModels',
|
|
54
|
+
'deleteModel',
|
|
55
|
+
'modelCatalogWatch',
|
|
56
|
+
'clearKvCache',
|
|
57
|
+
'deleteChatKvCache',
|
|
58
|
+
'transcribe',
|
|
59
|
+
'speak',
|
|
60
|
+
'speakStream',
|
|
61
|
+
'transcodeImage',
|
|
62
|
+
'tools',
|
|
63
|
+
'logsWatch',
|
|
64
|
+
'writeLog',
|
|
65
|
+
'diagnostics',
|
|
66
|
+
'diagnosticsWatch',
|
|
67
|
+
'networkWatch',
|
|
68
|
+
'meshStatusWatch',
|
|
69
|
+
'listMeshes',
|
|
70
|
+
'meshesWatch',
|
|
71
|
+
'openMesh',
|
|
72
|
+
'selectMesh',
|
|
73
|
+
'closeMesh',
|
|
74
|
+
'leaveMesh',
|
|
75
|
+
'acknowledgeKicked',
|
|
76
|
+
'joinMesh',
|
|
77
|
+
'cancelMeshJoin',
|
|
78
|
+
'meshInvite',
|
|
79
|
+
'setMeshLabel',
|
|
80
|
+
'createRoom'
|
|
81
|
+
]);
|
|
82
|
+
export function meshScoped(engine, meshId) {
|
|
83
|
+
if (!meshId)
|
|
84
|
+
return engine;
|
|
85
|
+
return new Proxy(engine, {
|
|
86
|
+
get(target, prop) {
|
|
87
|
+
const value = Reflect.get(target, prop, target);
|
|
88
|
+
if (typeof value !== 'function')
|
|
89
|
+
return value;
|
|
90
|
+
const name = prop;
|
|
91
|
+
if (MESH_SCOPED.has(name)) {
|
|
92
|
+
return (input = {}) => value.call(target, { ...input, meshId });
|
|
93
|
+
}
|
|
94
|
+
if (DEVICE_LOCAL.has(name))
|
|
95
|
+
return value.bind(target);
|
|
96
|
+
return () => {
|
|
97
|
+
throw new Error(`${String(prop)} is not mesh-scoped: it cannot answer for mesh ${meshId}`);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const MOBILE_CONTEXT_SIZE = 12288;
|
|
2
2
|
export declare const MODEL_CONTEXT_TARGET: {
|
|
3
|
-
readonly desktop:
|
|
4
|
-
readonly mobile:
|
|
3
|
+
readonly desktop: 'desktop';
|
|
4
|
+
readonly mobile: 'mobile';
|
|
5
5
|
};
|
|
6
6
|
export type ModelContextTarget = (typeof MODEL_CONTEXT_TARGET)[keyof typeof MODEL_CONTEXT_TARGET];
|
|
7
7
|
export declare function modelContextTargetForPlatform(platform: string | null | undefined): ModelContextTarget | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_27B, QWEN_36_35B_A3B, QWEN_38_27B, MEDPSY_1_7B, MEDPSY_4B } from
|
|
1
|
+
import { QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_27B, QWEN_36_35B_A3B, QWEN_38_27B, MEDPSY_1_7B, MEDPSY_4B } from './llm-model-names.js';
|
|
2
2
|
const QWEN_35_MAX_CONTEXT = 262_144;
|
|
3
3
|
const QWEN_36_MAX_CONTEXT = 262_144;
|
|
4
4
|
const QWEN_38_MAX_CONTEXT = 262_144;
|
|
@@ -152,6 +152,7 @@ export declare class ModelDownloadReconciler {
|
|
|
152
152
|
private _reset;
|
|
153
153
|
suspend(): Promise<void>;
|
|
154
154
|
resume(): void;
|
|
155
|
+
meshSelected(): void;
|
|
155
156
|
yieldToRuns(models: ReadonlyArray<string>): void;
|
|
156
157
|
observeImageProgress(observation: ImageDownloadObservation): void;
|
|
157
158
|
private _transfer;
|
|
@@ -161,6 +162,7 @@ export declare class ModelDownloadReconciler {
|
|
|
161
162
|
close(): Promise<void>;
|
|
162
163
|
private _watchConfig;
|
|
163
164
|
private _syncToolConfigsWatch;
|
|
165
|
+
private _swapToolConfigsWatch;
|
|
164
166
|
private _watchToolConfigs;
|
|
165
167
|
private _watchAgents;
|
|
166
168
|
private _restartWatch;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AbortController } from 'bare-abort-controller';
|
|
2
2
|
import { skillModelsForAgent } from '@qvac/harness/lib/models/model-catalog.ts';
|
|
3
3
|
import { GENERATE_MUSIC_TOOL, MUSIC_MODEL_CHOICES } from '@qvac/harness/music-catalog';
|
|
4
|
-
import { DeadlineScheduler } from
|
|
4
|
+
import { DeadlineScheduler } from './deadline.js';
|
|
5
5
|
import { DownloadSpeedSampler, progressBytes, transferProgress } from '@qvac/harness/model-progress';
|
|
6
|
-
import { isMeshTransition } from
|
|
7
|
-
import { runnableModelName } from
|
|
8
|
-
import { ModelDownloadStatus } from
|
|
9
|
-
import { RetryBudget } from
|
|
10
|
-
import { unref } from
|
|
6
|
+
import { isMeshTransition } from './api/current-mesh.js';
|
|
7
|
+
import { runnableModelName } from './model-clamp.js';
|
|
8
|
+
import { ModelDownloadStatus } from './model-download-status.js';
|
|
9
|
+
import { RetryBudget } from './retry-budget.js';
|
|
10
|
+
import { unref } from './unref.js';
|
|
11
11
|
const WATCH_RETRY_MS = 30_000;
|
|
12
12
|
const LOCAL_PROGRESS_INTERVAL_MS = 750;
|
|
13
13
|
const LOCAL_PROGRESS_PERCENTAGE_STEP = 1;
|
|
@@ -103,6 +103,17 @@ export class ModelDownloadReconciler {
|
|
|
103
103
|
this._paused = false;
|
|
104
104
|
this._kick();
|
|
105
105
|
}
|
|
106
|
+
meshSelected() {
|
|
107
|
+
if (this._closed)
|
|
108
|
+
return;
|
|
109
|
+
const agents = this._agentsStream;
|
|
110
|
+
this._agentsStream = null;
|
|
111
|
+
if (agents?.return)
|
|
112
|
+
void agents.return().catch(() => { });
|
|
113
|
+
this._watchAgents();
|
|
114
|
+
this._swapToolConfigsWatch(this._toolConfigsAgentId);
|
|
115
|
+
this._kick();
|
|
116
|
+
}
|
|
106
117
|
yieldToRuns(models) {
|
|
107
118
|
if (this._closed)
|
|
108
119
|
return;
|
|
@@ -162,11 +173,11 @@ export class ModelDownloadReconciler {
|
|
|
162
173
|
signal.aborted) {
|
|
163
174
|
return;
|
|
164
175
|
}
|
|
165
|
-
const rows = await this._harness.list({}).catch(
|
|
176
|
+
const rows = await this._harness.list({}).catch(noop);
|
|
166
177
|
if (this._closed || this._handled.has(model) || signal.aborted)
|
|
167
178
|
return;
|
|
168
179
|
let addon = 'llm';
|
|
169
|
-
if (rows
|
|
180
|
+
if (rows) {
|
|
170
181
|
const row = rows.find((entry) => entry.name === model);
|
|
171
182
|
if (!row || row.isCached)
|
|
172
183
|
return;
|
|
@@ -241,6 +252,9 @@ export class ModelDownloadReconciler {
|
|
|
241
252
|
const agentId = this._config?.activeAgentId ?? null;
|
|
242
253
|
if (agentId === this._toolConfigsAgentId)
|
|
243
254
|
return;
|
|
255
|
+
this._swapToolConfigsWatch(agentId);
|
|
256
|
+
}
|
|
257
|
+
_swapToolConfigsWatch(agentId) {
|
|
244
258
|
const previous = this._toolConfigsStream;
|
|
245
259
|
this._toolConfigsStream = null;
|
|
246
260
|
this._toolConfigsAgentId = null;
|
|
@@ -567,7 +581,7 @@ export class ModelDownloadReconciler {
|
|
|
567
581
|
const activeAgentId = this._config?.activeAgentId;
|
|
568
582
|
if (!activeAgentId)
|
|
569
583
|
return;
|
|
570
|
-
const agent = await this._engine.getAgent({ id: activeAgentId }).catch(
|
|
584
|
+
const agent = await this._engine.getAgent({ id: activeAgentId }).catch(noop);
|
|
571
585
|
if (!agent?.modelName)
|
|
572
586
|
return;
|
|
573
587
|
if (!agent.providerDeviceId?.equals(this._deviceId))
|
|
@@ -593,8 +607,8 @@ export class ModelDownloadReconciler {
|
|
|
593
607
|
const configs = await this._engine
|
|
594
608
|
.listToolConfigs({ agentId })
|
|
595
609
|
.then((result) => result.configs ?? [])
|
|
596
|
-
.catch(
|
|
597
|
-
if (configs
|
|
610
|
+
.catch(noop);
|
|
611
|
+
if (!configs)
|
|
598
612
|
return { ok: false };
|
|
599
613
|
const row = configs.find((entry) => entry?.toolName === GENERATE_MUSIC_TOOL);
|
|
600
614
|
const settings = row?.settings;
|
|
@@ -785,3 +799,4 @@ function shouldFlush(previous, percentage, at, intervalMs, percentageStep) {
|
|
|
785
799
|
at - previous.at >= intervalMs ||
|
|
786
800
|
percentage - previous.percentage >= percentageStep);
|
|
787
801
|
}
|
|
802
|
+
function noop() { }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { URLSearchParams } from 'url';
|
|
2
2
|
import defaultFetch from '#fetch';
|
|
3
|
-
import { runBrowserConnect } from
|
|
4
|
-
import { oauthRedirectUri, tokenRequest } from
|
|
5
|
-
import { resolveOAuthCredential } from
|
|
3
|
+
import { runBrowserConnect } from './browser-connect.js';
|
|
4
|
+
import { oauthRedirectUri, tokenRequest } from './common.js';
|
|
5
|
+
import { resolveOAuthCredential } from './resolve.js';
|
|
6
6
|
export const ASANA_MCP_CREDENTIAL_KEY = 'asana_mcp_access_token';
|
|
7
7
|
export const ASANA_OAUTH_STATE_KEY = 'asana_oauth';
|
|
8
8
|
export const ASANA_OAUTH_PORT = 18981;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomBytes as defaultRandomBytes } from 'crypto';
|
|
2
2
|
import { createServer } from 'http';
|
|
3
3
|
import { URL } from 'url';
|
|
4
|
-
import { base64url, CALLBACK_PATH, createPkce, DEFAULT_TIMEOUT_MS } from
|
|
4
|
+
import { base64url, CALLBACK_PATH, createPkce, DEFAULT_TIMEOUT_MS } from './common.js';
|
|
5
5
|
export function waitForOAuthCallback(opts) {
|
|
6
6
|
const { port, state, timeoutMs = DEFAULT_TIMEOUT_MS, onListening } = opts;
|
|
7
7
|
return new Promise((resolve, reject) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { runOAuthFlowWithRuntime } from
|
|
2
|
-
import { isTokenExpired, refreshOAuthTokensWithFetch } from
|
|
1
|
+
import { runOAuthFlowWithRuntime } from './flow-core.js';
|
|
2
|
+
import { isTokenExpired, refreshOAuthTokensWithFetch } from './token-exchange-core.js';
|
|
3
3
|
export function createOAuthClient(runtime) {
|
|
4
4
|
return {
|
|
5
5
|
runOAuthFlow: (config, deps) => runOAuthFlowWithRuntime(config, deps, runtime),
|
|
@@ -32,7 +32,7 @@ export declare function base64url(bytes: Buffer | Uint8Array): string;
|
|
|
32
32
|
export declare function createPkce(randomBytes?: RandomBytes): {
|
|
33
33
|
verifier: string;
|
|
34
34
|
challenge: string;
|
|
35
|
-
method:
|
|
35
|
+
method: 'S256';
|
|
36
36
|
};
|
|
37
37
|
export declare function oauthRedirectUri(port: number): string;
|
|
38
38
|
export declare function tokenRequest(fetchImpl: Fetch, tokenUrl: string, body: URLSearchParams, label: string): Promise<OAuthTokens>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
2
|
import { createHash, randomBytes as defaultRandomBytes } from 'crypto';
|
|
3
|
-
export { scopedKey } from
|
|
3
|
+
export { scopedKey } from './keys.js';
|
|
4
4
|
export const CALLBACK_PATH = '/callback';
|
|
5
5
|
export const DEFAULT_TIMEOUT_MS = 120_000;
|
|
6
6
|
export const REFRESH_SKEW_MS = 60_000;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { generateRuntimePkceChallenge } from
|
|
2
|
-
import { resolveDynamicClientId } from
|
|
3
|
-
import { exchangeCodeWithFetch } from
|
|
1
|
+
import { generateRuntimePkceChallenge } from './pkce-runtime.js';
|
|
2
|
+
import { resolveDynamicClientId } from './register.js';
|
|
3
|
+
import { exchangeCodeWithFetch } from './token-exchange-core.js';
|
|
4
4
|
function buildAuthParams(config, clientId, redirectUri, state, pkce) {
|
|
5
5
|
const params = new URLSearchParams({
|
|
6
6
|
...(config.extraAuthParams ?? {}),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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
|
-
import { runOAuthFlowWithRuntime } from
|
|
5
|
-
import { OAUTH_PROVIDER_PORTS } from
|
|
4
|
+
import { runOAuthFlowWithRuntime } from './flow-core.js';
|
|
5
|
+
import { OAUTH_PROVIDER_PORTS } from './keys.js';
|
|
6
6
|
export function cancelOAuthFlow(provider) {
|
|
7
7
|
return abortOAuthLoopback(OAUTH_PROVIDER_PORTS[provider]);
|
|
8
8
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { URLSearchParams } from 'url';
|
|
2
2
|
import defaultFetch from '#fetch';
|
|
3
|
-
import { runBrowserConnect } from
|
|
4
|
-
import { oauthRedirectUri, tokenRequest } from
|
|
5
|
-
import { OAUTH_PROVIDER_PORTS, oauthKeySpec } from
|
|
6
|
-
import { resolveOAuthCredential } from
|
|
3
|
+
import { runBrowserConnect } from './browser-connect.js';
|
|
4
|
+
import { oauthRedirectUri, tokenRequest } from './common.js';
|
|
5
|
+
import { OAUTH_PROVIDER_PORTS, oauthKeySpec } from './keys.js';
|
|
6
|
+
import { resolveOAuthCredential } from './resolve.js';
|
|
7
7
|
export const GOOGLE_OAUTH_PORT = OAUTH_PROVIDER_PORTS.google;
|
|
8
8
|
const REDIRECT_URI = oauthRedirectUri(GOOGLE_OAUTH_PORT);
|
|
9
9
|
const AUTH_URL = 'https://accounts.google.com/o/oauth2/v2/auth';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, providerSupportsSharedIosSession } from
|
|
2
|
-
export { isTokenExpired, refreshOAuthTokens } from
|
|
3
|
-
export { cancelOAuthFlow, runOAuthFlow } from
|
|
1
|
+
export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, providerSupportsSharedIosSession } from './providers.js';
|
|
2
|
+
export { isTokenExpired, refreshOAuthTokens } from './token-exchange.js';
|
|
3
|
+
export { cancelOAuthFlow, runOAuthFlow } from './flow.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createServer } from 'http';
|
|
2
|
-
import { OAUTH_CALLBACK_PATH, OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, oauthRedirectUri } from
|
|
2
|
+
import { OAUTH_CALLBACK_PATH, OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, oauthRedirectUri } from './keys.js';
|
|
3
3
|
const activeLoopbacks = new Map();
|
|
4
4
|
function closeServer(server) {
|
|
5
5
|
return new Promise((resolve) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { URLSearchParams } from 'url';
|
|
2
2
|
import defaultFetch from '#fetch';
|
|
3
|
-
import { runBrowserConnect } from
|
|
4
|
-
import { oauthRedirectUri, tokenRequest } from
|
|
5
|
-
import { resolveOAuthCredential } from
|
|
3
|
+
import { runBrowserConnect } from './browser-connect.js';
|
|
4
|
+
import { oauthRedirectUri, tokenRequest } from './common.js';
|
|
5
|
+
import { resolveOAuthCredential } from './resolve.js';
|
|
6
6
|
export const NOTION_MCP_CREDENTIAL_KEY = 'notion_mcp_access_token';
|
|
7
7
|
export const NOTION_OAUTH_STATE_KEY = 'notion_oauth';
|
|
8
8
|
export const NOTION_OAUTH_PORT = 18982;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OAUTH_PROVIDER_PORTS, oauthKeySpec } from
|
|
1
|
+
import { OAUTH_PROVIDER_PORTS, oauthKeySpec } from './keys.js';
|
|
2
2
|
const ASANA_MCP_RESOURCE = 'https://mcp.asana.com/v2';
|
|
3
3
|
export function providerRequiresSecret(provider) {
|
|
4
4
|
return provider === 'google' || provider === 'asana';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { REFRESH_SKEW_MS, scopedKey } from
|
|
1
|
+
import { REFRESH_SKEW_MS, scopedKey } from './common.js';
|
|
2
2
|
const inFlightRefresh = new Map();
|
|
3
3
|
export async function resolveOAuthCredential(opts) {
|
|
4
4
|
const { engine, agentId, credentialKey, stateKey, refresh, requireClientSecret = false } = opts;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { URLSearchParams } from 'url';
|
|
2
2
|
import defaultFetch from '#fetch';
|
|
3
|
-
import { runBrowserConnect } from
|
|
4
|
-
import { oauthRedirectUri, tokenRequest } from
|
|
5
|
-
import { resolveOAuthCredential } from
|
|
3
|
+
import { runBrowserConnect } from './browser-connect.js';
|
|
4
|
+
import { oauthRedirectUri, tokenRequest } from './common.js';
|
|
5
|
+
import { resolveOAuthCredential } from './resolve.js';
|
|
6
6
|
export const SPOTIFY_CREDENTIAL_KEY = 'spotify_access_token';
|
|
7
7
|
export const SPOTIFY_OAUTH_STATE_KEY = 'spotify_oauth';
|
|
8
8
|
export const SPOTIFY_OAUTH_PORT = 18974;
|
|
@@ -10,6 +10,7 @@ const REDIRECT_URI = oauthRedirectUri(SPOTIFY_OAUTH_PORT);
|
|
|
10
10
|
const AUTH_URL = 'https://accounts.spotify.com/authorize';
|
|
11
11
|
const TOKEN_URL = 'https://accounts.spotify.com/api/token';
|
|
12
12
|
const SCOPES = [
|
|
13
|
+
'user-read-private',
|
|
13
14
|
'user-read-playback-state',
|
|
14
15
|
'user-modify-playback-state',
|
|
15
16
|
'user-read-currently-playing',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import defaultFetch from '@qvac/core/oauth/runtime/fetch';
|
|
2
|
-
import { exchangeCodeWithFetch, isTokenExpired, refreshOAuthTokensWithFetch } from
|
|
2
|
+
import { exchangeCodeWithFetch, isTokenExpired, refreshOAuthTokensWithFetch } from './token-exchange-core.js';
|
|
3
3
|
export function exchangeCode(config, clientId, redirectUri, code, verifier, deps) {
|
|
4
4
|
return exchangeCodeWithFetch(config, clientId, redirectUri, code, verifier, deps, defaultFetch);
|
|
5
5
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { oauthKeySpec } from './keys.js';
|
|
2
|
+
export async function verifyOAuthTokens(credentialKey, accessToken, fetch) {
|
|
3
|
+
const provider = oauthKeySpec(credentialKey)?.provider;
|
|
4
|
+
if (provider !== 'asana' && provider !== 'spotify')
|
|
5
|
+
return { ok: true };
|
|
6
|
+
const controller = typeof globalThis.AbortController === 'function' ? new globalThis.AbortController() : null;
|
|
7
|
+
const timer = setTimeout(() => controller?.abort(), 5_000);
|
|
8
|
+
try {
|
|
9
|
+
if (provider === 'asana') {
|
|
10
|
+
const response = await fetch('https://mcp.asana.com/v2/mcp', {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers: {
|
|
13
|
+
Authorization: `Bearer ${accessToken}`,
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
Accept: 'application/json, text/event-stream'
|
|
16
|
+
},
|
|
17
|
+
body: JSON.stringify({
|
|
18
|
+
jsonrpc: '2.0',
|
|
19
|
+
id: 1,
|
|
20
|
+
method: 'initialize',
|
|
21
|
+
params: {
|
|
22
|
+
protocolVersion: '2025-03-26',
|
|
23
|
+
capabilities: {},
|
|
24
|
+
clientInfo: { name: 'qvac', version: '1.0.0' }
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
signal: controller?.signal
|
|
28
|
+
});
|
|
29
|
+
if (response.status === 401 || response.status === 403) {
|
|
30
|
+
return { ok: false, error: 'OAuth error: asana_not_mcp_app' };
|
|
31
|
+
}
|
|
32
|
+
return { ok: true };
|
|
33
|
+
}
|
|
34
|
+
const response = await fetch('https://api.spotify.com/v1/me', {
|
|
35
|
+
method: 'GET',
|
|
36
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
37
|
+
signal: controller?.signal
|
|
38
|
+
});
|
|
39
|
+
if (response.status === 401 || response.status === 403)
|
|
40
|
+
return { ok: true };
|
|
41
|
+
if (response.status < 200 || response.status >= 300)
|
|
42
|
+
return { ok: true };
|
|
43
|
+
try {
|
|
44
|
+
const body = (await response.json());
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(body, 'product') && body.product !== 'premium') {
|
|
46
|
+
return { ok: false, error: 'OAuth error: spotify_premium_required' };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch { }
|
|
50
|
+
return { ok: true };
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return { ok: true };
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createOAuthClient, isTokenExpired } from
|
|
2
|
-
export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, providerSupportsSharedIosSession } from
|
|
1
|
+
export { createOAuthClient, isTokenExpired } from './oauth/client.js';
|
|
2
|
+
export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, providerSupportsSharedIosSession } from './oauth/providers.js';
|
package/dist-lib/lib/oauth.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, provi
|
|
|
11
11
|
export type { OAuthCallbackResult, OAuthRedirect, OAuthRedirectFactory } from './oauth/redirect-types.ts';
|
|
12
12
|
export { registerOAuthClient, resolveDynamicClientId } from './oauth/register.ts';
|
|
13
13
|
export { isTokenExpired, refreshOAuthTokens } from './oauth/token-exchange.ts';
|
|
14
|
+
export { verifyOAuthTokens, type VerifyResult } from './oauth/verify.ts';
|
|
14
15
|
export type { OAuthCredentials, OAuthFlowDeps, OAuthFlowResult, OAuthProvider, OAuthProviderConfig } from './oauth/types.ts';
|
package/dist-lib/lib/oauth.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export { createPkce, scopedKey } from
|
|
2
|
-
export { waitForOAuthCallback } from
|
|
3
|
-
export { buildGoogleAuthUrl, connectGoogle, exchangeGoogleCode, GOOGLE_OAUTH_PORT, refreshGoogleToken, resolveGoogleCredential } from
|
|
4
|
-
export { buildNotionAuthUrl, connectNotion, exchangeNotionCode, NOTION_MCP_CREDENTIAL_KEY, NOTION_OAUTH_PORT, NOTION_OAUTH_STATE_KEY, refreshNotionToken, registerNotionClient, resolveNotionCredential } from
|
|
5
|
-
export { buildAsanaAuthUrl, connectAsana, exchangeAsanaCode, ASANA_MCP_CREDENTIAL_KEY, ASANA_OAUTH_PORT, ASANA_OAUTH_STATE_KEY, refreshAsanaToken, resolveAsanaCredential } from
|
|
6
|
-
export { buildSpotifyAuthUrl, connectSpotify, exchangeSpotifyCode, refreshSpotifyToken, resolveSpotifyCredential, SPOTIFY_CREDENTIAL_KEY, SPOTIFY_OAUTH_PORT, SPOTIFY_OAUTH_STATE_KEY } from
|
|
7
|
-
export { cancelOAuthFlow, runOAuthFlow } from
|
|
8
|
-
export { defaultCredentialKeyFor, GMAIL_CREDENTIAL_KEY, GOOGLE_CALENDAR_CREDENTIAL_KEY, GOOGLE_CREDENTIAL_KEYS, GOOGLE_DOCS_CREDENTIAL_KEY, GOOGLE_DRIVE_CREDENTIAL_KEY, GOOGLE_SHEETS_CREDENTIAL_KEY, LEGACY_GOOGLE_CREDENTIAL_KEY, OAUTH_KEY_SPECS, oauthKeySpec, oauthStateKeyFor } from
|
|
9
|
-
export { generatePkceChallenge } from
|
|
10
|
-
export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, providerSupportsSharedIosSession } from
|
|
11
|
-
export { registerOAuthClient, resolveDynamicClientId } from
|
|
12
|
-
export { isTokenExpired, refreshOAuthTokens } from
|
|
1
|
+
export { createPkce, scopedKey } from './oauth/common.js';
|
|
2
|
+
export { waitForOAuthCallback } from './oauth/browser-connect.js';
|
|
3
|
+
export { buildGoogleAuthUrl, connectGoogle, exchangeGoogleCode, GOOGLE_OAUTH_PORT, refreshGoogleToken, resolveGoogleCredential } from './oauth/google.js';
|
|
4
|
+
export { buildNotionAuthUrl, connectNotion, exchangeNotionCode, NOTION_MCP_CREDENTIAL_KEY, NOTION_OAUTH_PORT, NOTION_OAUTH_STATE_KEY, refreshNotionToken, registerNotionClient, resolveNotionCredential } from './oauth/notion.js';
|
|
5
|
+
export { buildAsanaAuthUrl, connectAsana, exchangeAsanaCode, ASANA_MCP_CREDENTIAL_KEY, ASANA_OAUTH_PORT, ASANA_OAUTH_STATE_KEY, refreshAsanaToken, resolveAsanaCredential } from './oauth/asana.js';
|
|
6
|
+
export { buildSpotifyAuthUrl, connectSpotify, exchangeSpotifyCode, refreshSpotifyToken, resolveSpotifyCredential, SPOTIFY_CREDENTIAL_KEY, SPOTIFY_OAUTH_PORT, SPOTIFY_OAUTH_STATE_KEY } from './oauth/spotify.js';
|
|
7
|
+
export { cancelOAuthFlow, runOAuthFlow } from './oauth/flow.js';
|
|
8
|
+
export { defaultCredentialKeyFor, GMAIL_CREDENTIAL_KEY, GOOGLE_CALENDAR_CREDENTIAL_KEY, GOOGLE_CREDENTIAL_KEYS, GOOGLE_DOCS_CREDENTIAL_KEY, GOOGLE_DRIVE_CREDENTIAL_KEY, GOOGLE_SHEETS_CREDENTIAL_KEY, LEGACY_GOOGLE_CREDENTIAL_KEY, OAUTH_KEY_SPECS, oauthKeySpec, oauthStateKeyFor } from './oauth/keys.js';
|
|
9
|
+
export { generatePkceChallenge } from './oauth/pkce.js';
|
|
10
|
+
export { buildProviderConfig, providerRequiresSecret, providerSupportsDcr, providerSupportsSharedIosSession } from './oauth/providers.js';
|
|
11
|
+
export { registerOAuthClient, resolveDynamicClientId } from './oauth/register.js';
|
|
12
|
+
export { isTokenExpired, refreshOAuthTokens } from './oauth/token-exchange.js';
|
|
13
|
+
export { verifyOAuthTokens } from './oauth/verify.js';
|