@qvac/core 0.10.3 → 0.11.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/CHANGELOG.md +71 -1
- package/dist-lib/lib/assistant/history.d.ts +2 -1
- package/dist-lib/lib/assistant/history.js +32 -5
- package/dist-lib/lib/assistant/message.d.ts +20 -0
- package/dist-lib/lib/assistant/message.js +36 -0
- package/dist-lib/lib/assistant/pdf-budget.d.ts +3 -0
- package/dist-lib/lib/assistant/pdf-budget.js +13 -0
- package/dist-lib/lib/assistant/video-budget.d.ts +13 -0
- package/dist-lib/lib/assistant/video-budget.js +29 -0
- package/dist-lib/lib/assistant-tree.d.ts +1 -0
- package/dist-lib/lib/assistant-tree.js +9 -2
- package/dist-lib/lib/assistant.d.ts +26 -3
- package/dist-lib/lib/assistant.js +471 -47
- package/dist-lib/lib/core/chat-fork.js +1 -0
- package/dist-lib/lib/core/chat-search.js +1 -1
- package/dist-lib/lib/core/chunk.d.ts +2 -2
- package/dist-lib/lib/core/chunk.js +5 -1
- package/dist-lib/lib/core/departures.js +6 -0
- package/dist-lib/lib/core/document-attachment.d.ts +7 -0
- package/dist-lib/lib/core/document-attachment.js +9 -0
- package/dist-lib/lib/core/files/index.js +4 -4
- package/dist-lib/lib/core/files/records/chunks.js +21 -0
- package/dist-lib/lib/core/files/records/purge.js +4 -3
- package/dist-lib/lib/core/files/records/source.js +3 -5
- package/dist-lib/lib/core/files/upload.js +3 -2
- package/dist-lib/lib/core/identity.d.ts +2 -0
- package/dist-lib/lib/core/identity.js +19 -0
- package/dist-lib/lib/core/pdf/rasterize.d.ts +0 -1
- package/dist-lib/lib/core/pdf/rasterize.js +0 -1
- package/dist-lib/lib/core/video/attachment.d.ts +1 -0
- package/dist-lib/lib/core/video/attachment.js +7 -0
- package/dist-lib/lib/core/video/digest.d.ts +16 -0
- package/dist-lib/lib/core/video/digest.js +57 -0
- package/dist-lib/lib/core/video/frames.d.ts +32 -0
- package/dist-lib/lib/core/video/frames.js +224 -0
- package/dist-lib/lib/core.d.ts +1 -0
- package/dist-lib/lib/core.js +44 -7
- package/dist-lib/lib/credential-pusher.d.ts +6 -0
- package/dist-lib/lib/credential-pusher.js +76 -59
- package/dist-lib/lib/errors.d.ts +8 -0
- package/dist-lib/lib/errors.js +8 -0
- package/dist-lib/lib/oauth/flow-core.js +2 -0
- package/dist-lib/lib/oauth/loopback.d.ts +1 -0
- package/dist-lib/lib/oauth/loopback.js +31 -1
- package/dist-lib/lib/oauth/register.js +33 -18
- package/dist-lib/lib/oauth/request.d.ts +10 -0
- package/dist-lib/lib/oauth/request.js +22 -0
- package/dist-lib/lib/oauth/token-exchange-core.js +29 -32
- package/dist-lib/lib/oauth/types.d.ts +3 -0
- package/dist-lib/lib/oauth.d.ts +2 -1
- package/dist-lib/lib/oauth.js +1 -0
- package/dist-lib/lib/run-notices.d.ts +1 -0
- package/dist-lib/lib/run-notices.js +2 -1
- package/dist-lib/lib/run-replay.d.ts +8 -2
- package/dist-lib/lib/run-replay.js +29 -11
- package/dist-lib/lib/task.js +1 -1
- package/dist-lib/schema/engine.js +4 -2
- package/dist-lib/schema/indexes.js +2 -2
- package/dist-lib/schema/qvac.js +4 -2
- package/dist-lib/spec/hrpc/messages.js +16 -6
- package/dist-lib/spec/hyperschema/index.js +16 -6
- package/dist-lib/spec/hyperschema/schema.json +10 -0
- package/dist-lib/spec/hyperschema/types.d.ts +2 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +26 -11
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +18 -8
- package/dist-lib/spec/mesh/hyperschema/index.js +18 -8
- package/dist-lib/spec/mesh/hyperschema/schema.json +11 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +3 -1
- package/package.json +7 -4
- package/tui/app.mjs +34 -1
- package/tui/lib/render.mjs +5 -0
- package/tui/main.mjs +8 -0
|
@@ -1,36 +1,51 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
import { providerRequest } from './request.js';
|
|
2
3
|
import { CoreError } from '../errors.js';
|
|
3
4
|
const RegistrationResponseSchema = z.object({
|
|
4
5
|
client_id: z.string().min(1)
|
|
5
6
|
});
|
|
6
|
-
export
|
|
7
|
+
export function registerOAuthClient(config, redirectUri, fetchImpl) {
|
|
8
|
+
return register(config, redirectUri, { fetchImpl });
|
|
9
|
+
}
|
|
10
|
+
async function register(config, redirectUri, { fetchImpl = globalThis.fetch, timeoutMs }) {
|
|
7
11
|
if (!config.registrationEndpoint) {
|
|
8
12
|
throw new CoreError('OAUTH_REGISTRATION_UNAVAILABLE');
|
|
9
13
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
return await providerRequest({
|
|
15
|
+
fetchImpl,
|
|
16
|
+
url: config.registrationEndpoint,
|
|
17
|
+
init: {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
client_name: 'QV.AC',
|
|
22
|
+
redirect_uris: [redirectUri],
|
|
23
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
24
|
+
response_types: ['code'],
|
|
25
|
+
token_endpoint_auth_method: 'none',
|
|
26
|
+
application_type: 'native'
|
|
27
|
+
})
|
|
28
|
+
},
|
|
29
|
+
timeoutMs,
|
|
30
|
+
timeout: () => new CoreError('OAUTH_REGISTRATION_TIMEOUT'),
|
|
31
|
+
read: async (response) => {
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
const text = await response.text().catch(() => '');
|
|
34
|
+
throw new CoreError('OAUTH_REGISTRATION_FAILED', [response.status, text]);
|
|
35
|
+
}
|
|
36
|
+
return RegistrationResponseSchema.parse(await response.json()).client_id;
|
|
37
|
+
}
|
|
21
38
|
});
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
const text = await response.text().catch(() => '');
|
|
24
|
-
throw new CoreError('OAUTH_REGISTRATION_FAILED', [response.status, text]);
|
|
25
|
-
}
|
|
26
|
-
return RegistrationResponseSchema.parse(await response.json()).client_id;
|
|
27
39
|
}
|
|
28
40
|
export async function resolveDynamicClientId(config, redirectUri, deps, fetchImpl) {
|
|
29
41
|
const cached = await deps.getClientId?.();
|
|
30
42
|
if (cached) {
|
|
31
43
|
return cached;
|
|
32
44
|
}
|
|
33
|
-
const clientId = await
|
|
45
|
+
const clientId = await register(config, redirectUri, {
|
|
46
|
+
fetchImpl,
|
|
47
|
+
timeoutMs: deps.requestTimeoutMs
|
|
48
|
+
});
|
|
34
49
|
await deps.saveClientId?.(clientId);
|
|
35
50
|
return clientId;
|
|
36
51
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OAuthFetch } from './types.ts';
|
|
2
|
+
export interface ProviderRequest<T> {
|
|
3
|
+
readonly fetchImpl: OAuthFetch;
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly init: RequestInit;
|
|
6
|
+
readonly timeoutMs?: number | undefined;
|
|
7
|
+
readonly timeout: () => Error;
|
|
8
|
+
readonly read: (response: Response) => Promise<T>;
|
|
9
|
+
}
|
|
10
|
+
export declare function providerRequest<T>({ fetchImpl, url, init, timeoutMs, timeout, read }: ProviderRequest<T>): Promise<T>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AbortController as BareAbortController } from 'bare-abort-controller';
|
|
2
|
+
const PROVIDER_REQUEST_TIMEOUT_MS = 30_000;
|
|
3
|
+
const AbortController = globalThis.AbortController ?? BareAbortController;
|
|
4
|
+
export async function providerRequest({ fetchImpl, url, init, timeoutMs = PROVIDER_REQUEST_TIMEOUT_MS, timeout, read }) {
|
|
5
|
+
const controller = new AbortController();
|
|
6
|
+
let timer;
|
|
7
|
+
const expired = new Promise((_resolve, reject) => {
|
|
8
|
+
timer = globalThis.setTimeout(() => {
|
|
9
|
+
controller.abort();
|
|
10
|
+
reject(timeout());
|
|
11
|
+
}, timeoutMs);
|
|
12
|
+
});
|
|
13
|
+
try {
|
|
14
|
+
return await Promise.race([
|
|
15
|
+
fetchImpl(url, { ...init, signal: controller.signal }).then(read),
|
|
16
|
+
expired
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
globalThis.clearTimeout(timer);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { AbortController as BareAbortController } from 'bare-abort-controller';
|
|
2
1
|
import * as z from 'zod';
|
|
2
|
+
import { providerRequest } from './request.js';
|
|
3
3
|
import { CoreError } from '../errors.js';
|
|
4
|
-
const TOKEN_REQUEST_TIMEOUT_MS = 30_000;
|
|
5
|
-
const AbortController = globalThis.AbortController ?? BareAbortController;
|
|
6
4
|
const TokenResponseSchema = z.object({
|
|
7
5
|
access_token: z.string(),
|
|
8
6
|
token_type: z.string(),
|
|
@@ -51,19 +49,23 @@ export async function exchangeCodeWithFetch(config, { clientId, redirectUri, cod
|
|
|
51
49
|
Accept: 'application/json'
|
|
52
50
|
};
|
|
53
51
|
applyClientSecret(config, body, headers);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
body: body.toString()
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
return await providerRequest({
|
|
53
|
+
fetchImpl,
|
|
54
|
+
url: config.tokenUrl,
|
|
55
|
+
init: { method: 'POST', headers, body: body.toString() },
|
|
56
|
+
timeoutMs: deps.requestTimeoutMs,
|
|
57
|
+
timeout: () => new CoreError('OAUTH_TOKEN_EXCHANGE_TIMEOUT'),
|
|
58
|
+
read: async (response) => {
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
const text = await response.text().catch(() => '');
|
|
61
|
+
if (config.dynamicRegistration && /invalid_client/i.test(text)) {
|
|
62
|
+
await deps.clearClientId?.();
|
|
63
|
+
}
|
|
64
|
+
throw new CoreError('OAUTH_TOKEN_EXCHANGE_FAILED', [response.status, text]);
|
|
65
|
+
}
|
|
66
|
+
return toTokens(parseTokenResponse(await response.json()));
|
|
63
67
|
}
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
return toTokens(parseTokenResponse(await response.json()));
|
|
68
|
+
});
|
|
67
69
|
}
|
|
68
70
|
export async function refreshOAuthTokensWithFetch(config, refreshToken, fetchImpl) {
|
|
69
71
|
const body = new URLSearchParams({
|
|
@@ -76,24 +78,19 @@ export async function refreshOAuthTokensWithFetch(config, refreshToken, fetchImp
|
|
|
76
78
|
Accept: 'application/json'
|
|
77
79
|
};
|
|
78
80
|
applyClientSecret(config, body, headers);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
throw new CoreError('OAUTH_TOKEN_REFRESH_FAILED', [response.status, text]);
|
|
81
|
+
return await providerRequest({
|
|
82
|
+
fetchImpl,
|
|
83
|
+
url: config.tokenUrl,
|
|
84
|
+
init: { method: 'POST', headers, body: body.toString() },
|
|
85
|
+
timeout: () => new CoreError('OAUTH_TOKEN_REFRESH_TIMEOUT'),
|
|
86
|
+
read: async (response) => {
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
const text = await response.text().catch(() => '');
|
|
89
|
+
throw new CoreError('OAUTH_TOKEN_REFRESH_FAILED', [response.status, text]);
|
|
90
|
+
}
|
|
91
|
+
return toTokens(parseTokenResponse(await response.json()), refreshToken);
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
finally {
|
|
95
|
-
globalThis.clearTimeout(timeout);
|
|
96
|
-
}
|
|
93
|
+
});
|
|
97
94
|
}
|
|
98
95
|
export function isTokenExpired(record, bufferMs = 60_000) {
|
|
99
96
|
return typeof record.expiresAt === 'number' && Date.now() + bufferMs >= record.expiresAt;
|
|
@@ -27,13 +27,16 @@ interface OAuthProviderConfigBase {
|
|
|
27
27
|
readonly dynamicRegistration?: boolean;
|
|
28
28
|
readonly registrationEndpoint?: string;
|
|
29
29
|
}
|
|
30
|
+
export type OAuthFlowStage = 'awaiting-callback' | 'exchanging-code';
|
|
30
31
|
export interface OAuthFlowDeps {
|
|
31
32
|
readonly openUrl?: (url: string) => Promise<void>;
|
|
32
33
|
readonly timeoutMs?: number;
|
|
34
|
+
readonly requestTimeoutMs?: number;
|
|
33
35
|
readonly getClientId?: () => Promise<string | undefined>;
|
|
34
36
|
readonly saveClientId?: (clientId: string) => Promise<void>;
|
|
35
37
|
readonly clearClientId?: () => Promise<void>;
|
|
36
38
|
readonly createRedirect?: OAuthRedirectFactory;
|
|
39
|
+
readonly onStage?: (stage: OAuthFlowStage) => void;
|
|
37
40
|
}
|
|
38
41
|
export type PkceOnlyProviderConfig = OAuthProviderConfigBase & {
|
|
39
42
|
readonly tokenAuth: 'pkce-only';
|
package/dist-lib/lib/oauth.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { waitForOAuthCallback } from './oauth/browser-connect.ts';
|
|
2
2
|
export { cancelOAuthFlow, runOAuthFlow } from './oauth/flow.ts';
|
|
3
|
+
export { deliverOAuthCallback } from './oauth/loopback.ts';
|
|
3
4
|
export { OAUTH_CALLBACK_PATH, OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, oauthRedirectUri, scopedKey, specFromRoute, type OAuthKeySpec, type OAuthRouteLike } from './oauth/keys.ts';
|
|
4
5
|
export { oauthSpecFor, oauthSpecs } from './oauth/registry.ts';
|
|
5
6
|
export { createPkce, generatePkceChallenge, type PkceChallenge } from './oauth/pkce.ts';
|
|
@@ -8,4 +9,4 @@ export type { OAuthCallbackResult, OAuthRedirect, OAuthRedirectFactory } from '.
|
|
|
8
9
|
export { registerOAuthClient, resolveDynamicClientId } from './oauth/register.ts';
|
|
9
10
|
export { resolveOAuthCredential, type ConfigEngine, type Fetch, type FetchResponse } from './oauth/resolve.ts';
|
|
10
11
|
export { isTokenExpired, refreshOAuthTokens } from './oauth/token-exchange.ts';
|
|
11
|
-
export type { OAuthCredentials, OAuthFlowDeps, OAuthFlowResult, OAuthProvider, OAuthProviderConfig, OAuthTokens } from './oauth/types.ts';
|
|
12
|
+
export type { OAuthCredentials, OAuthFlowDeps, OAuthFlowResult, OAuthFlowStage, OAuthProvider, OAuthProviderConfig, OAuthTokens } from './oauth/types.ts';
|
package/dist-lib/lib/oauth.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { waitForOAuthCallback } from './oauth/browser-connect.js';
|
|
2
2
|
export { cancelOAuthFlow, runOAuthFlow } from './oauth/flow.js';
|
|
3
|
+
export { deliverOAuthCallback } from './oauth/loopback.js';
|
|
3
4
|
export { OAUTH_CALLBACK_PATH, OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, oauthRedirectUri, scopedKey, specFromRoute } from './oauth/keys.js';
|
|
4
5
|
export { oauthSpecFor, oauthSpecs } from './oauth/registry.js';
|
|
5
6
|
export { createPkce, generatePkceChallenge } from './oauth/pkce.js';
|
|
@@ -13,6 +13,7 @@ export declare const RUN_FAILURE_REASONS: {
|
|
|
13
13
|
readonly runtimeEndedTurn: 'the model runtime ended this turn';
|
|
14
14
|
readonly capabilityUnavailable: 'this device cannot run a capability without a model';
|
|
15
15
|
readonly stalled: 'the agent stopped responding';
|
|
16
|
+
readonly videoNeedsVision: 'this model cannot see video: switch to a model that reads images to ask about one';
|
|
16
17
|
};
|
|
17
18
|
export type AbortOutcome = {
|
|
18
19
|
readonly kind: 'replay';
|
|
@@ -11,7 +11,8 @@ export const RUN_FAILURE_REASONS = {
|
|
|
11
11
|
harnessDied: 'the model runtime died',
|
|
12
12
|
runtimeEndedTurn: 'the model runtime ended this turn',
|
|
13
13
|
capabilityUnavailable: 'this device cannot run a capability without a model',
|
|
14
|
-
stalled: 'the agent stopped responding'
|
|
14
|
+
stalled: 'the agent stopped responding',
|
|
15
|
+
videoNeedsVision: 'this model cannot see video: switch to a model that reads images to ask about one'
|
|
15
16
|
};
|
|
16
17
|
export function knownAbortOutcome(reason) {
|
|
17
18
|
if (reason === RUN_ABORT_REASONS.suspended ||
|
|
@@ -4,13 +4,19 @@ export interface ReplayChat {
|
|
|
4
4
|
readonly holder: string;
|
|
5
5
|
readonly chatId: string;
|
|
6
6
|
}
|
|
7
|
+
export interface SentRun {
|
|
8
|
+
readonly messages: ChatMessage[];
|
|
9
|
+
readonly asked?: string | undefined;
|
|
10
|
+
}
|
|
7
11
|
export declare class RunReplayStore {
|
|
8
12
|
private readonly _dir;
|
|
9
13
|
constructor(dir: string);
|
|
10
14
|
started(): Promise<boolean>;
|
|
11
15
|
start(): Promise<void>;
|
|
12
|
-
load(
|
|
13
|
-
|
|
16
|
+
load(chat: ReplayChat): Promise<Map<string, ChatMessage[]>>;
|
|
17
|
+
loadAsked(chat: ReplayChat): Promise<Map<string, string>>;
|
|
18
|
+
save({ holder, chatId }: ReplayChat, runId: string, { messages, asked }: SentRun): Promise<void>;
|
|
19
|
+
private _records;
|
|
14
20
|
forget(chatId: string, holder?: string): Promise<void>;
|
|
15
21
|
clear(holder: string): Promise<void>;
|
|
16
22
|
private _chatDir;
|
|
@@ -19,30 +19,48 @@ export class RunReplayStore {
|
|
|
19
19
|
async start() {
|
|
20
20
|
await fs.promises.mkdir(this._dir, { recursive: true });
|
|
21
21
|
}
|
|
22
|
-
async load(
|
|
23
|
-
const chatDir = this._chatDir(holder, chatId);
|
|
22
|
+
async load(chat) {
|
|
24
23
|
const runs = new Map();
|
|
24
|
+
for (const record of await this._records(chat)) {
|
|
25
|
+
if (Array.isArray(record.messages)) {
|
|
26
|
+
runs.set(record.runId, record.messages.filter(isChatMessage));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return runs;
|
|
30
|
+
}
|
|
31
|
+
async loadAsked(chat) {
|
|
32
|
+
const asked = new Map();
|
|
33
|
+
for (const record of await this._records(chat)) {
|
|
34
|
+
if (typeof record.asked === 'string') {
|
|
35
|
+
asked.set(record.runId, record.asked);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return asked;
|
|
39
|
+
}
|
|
40
|
+
async save({ holder, chatId }, runId, { messages, asked }) {
|
|
41
|
+
const chatDir = this._chatDir(holder, chatId);
|
|
42
|
+
await fs.promises.mkdir(chatDir, { recursive: true });
|
|
43
|
+
await fs.promises.writeFile(join(chatDir, `${safeName(runId)}.json`), JSON.stringify({ runId, messages, asked }));
|
|
44
|
+
}
|
|
45
|
+
async _records({ holder, chatId }) {
|
|
46
|
+
const chatDir = this._chatDir(holder, chatId);
|
|
25
47
|
let names;
|
|
26
48
|
try {
|
|
27
49
|
names = await fs.promises.readdir(chatDir);
|
|
28
50
|
}
|
|
29
51
|
catch {
|
|
30
|
-
return
|
|
52
|
+
return [];
|
|
31
53
|
}
|
|
54
|
+
const records = [];
|
|
32
55
|
for (const name of names) {
|
|
33
56
|
if (!name.endsWith('.json'))
|
|
34
57
|
continue;
|
|
35
58
|
const parsed = JSON.parse(await fs.promises.readFile(join(chatDir, name), 'utf8'));
|
|
36
|
-
if (isRecord(parsed) && typeof parsed.runId === 'string'
|
|
37
|
-
|
|
59
|
+
if (isRecord(parsed) && typeof parsed.runId === 'string') {
|
|
60
|
+
records.push({ runId: parsed.runId, messages: parsed.messages, asked: parsed.asked });
|
|
38
61
|
}
|
|
39
62
|
}
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
async save({ holder, chatId }, runId, messages) {
|
|
43
|
-
const chatDir = this._chatDir(holder, chatId);
|
|
44
|
-
await fs.promises.mkdir(chatDir, { recursive: true });
|
|
45
|
-
await fs.promises.writeFile(join(chatDir, `${safeName(runId)}.json`), JSON.stringify({ runId, messages }));
|
|
63
|
+
return records;
|
|
46
64
|
}
|
|
47
65
|
async forget(chatId, holder) {
|
|
48
66
|
const holders = holder === undefined ? await this._holders() : [holder];
|
package/dist-lib/lib/task.js
CHANGED
|
@@ -55,7 +55,7 @@ function collect(all, { chatId, runId, state }) {
|
|
|
55
55
|
if (call) {
|
|
56
56
|
toolCalls.push({ name: call.name, arguments: call.arguments });
|
|
57
57
|
}
|
|
58
|
-
if (chunk.attachment && !chunk.attachment.deletedAt) {
|
|
58
|
+
if (chunk.attachment && !chunk.attachment.deletedAt && !chunk.sourceId) {
|
|
59
59
|
attachments.push(chunk.attachment);
|
|
60
60
|
}
|
|
61
61
|
if (chunk.sources) {
|
|
@@ -579,7 +579,8 @@ export function registerEngineTypes(ns) {
|
|
|
579
579
|
{ name: 'senderMemberId', type: 'fixed32' },
|
|
580
580
|
{ name: 'capability', type: 'string' },
|
|
581
581
|
{ name: 'capabilityArgs', type: 'json' },
|
|
582
|
-
{ name: 'enhance', type: '@assistant/enhance-mode' }
|
|
582
|
+
{ name: 'enhance', type: '@assistant/enhance-mode' },
|
|
583
|
+
{ name: 'sourceId', type: 'string' }
|
|
583
584
|
]);
|
|
584
585
|
ns.register({
|
|
585
586
|
name: 'chunk-list',
|
|
@@ -695,7 +696,8 @@ export function registerEngineTypes(ns) {
|
|
|
695
696
|
{ name: 'raw', type: 'bool' },
|
|
696
697
|
{ name: 'fileId', type: 'string' },
|
|
697
698
|
{ name: 'totalBytes', type: 'uint' },
|
|
698
|
-
{ name: 'meshId', type: 'string' }
|
|
699
|
+
{ name: 'meshId', type: 'string' },
|
|
700
|
+
{ name: 'sourceId', type: 'string' }
|
|
699
701
|
]
|
|
700
702
|
});
|
|
701
703
|
ns.register({
|
|
@@ -91,7 +91,7 @@ export function runRequestsMap(record) {
|
|
|
91
91
|
|
|
92
92
|
// not chatId-prefixed, so one range lists every audio attachment in the mesh without filtering
|
|
93
93
|
export function attachmentsByMediaKindMap(record) {
|
|
94
|
-
if (record.type !== 'attachment') return []
|
|
94
|
+
if (record.type !== 'attachment' || record.sourceId) return []
|
|
95
95
|
const attachment = record.attachment
|
|
96
96
|
if (!attachment || attachment.deletedAt) {
|
|
97
97
|
return []
|
|
@@ -112,7 +112,7 @@ function attachmentGenerated(record) {
|
|
|
112
112
|
|
|
113
113
|
// origin in the key makes "only generated audio" a range query, not a post-filter
|
|
114
114
|
export function attachmentsByMediaKindOriginMap(record) {
|
|
115
|
-
if (record.type !== 'attachment') return []
|
|
115
|
+
if (record.type !== 'attachment' || record.sourceId) return []
|
|
116
116
|
const attachment = record.attachment
|
|
117
117
|
if (!attachment || attachment.deletedAt) {
|
|
118
118
|
return []
|
package/dist-lib/schema/qvac.js
CHANGED
|
@@ -82,7 +82,8 @@ export function registerQvacTypes(ns) {
|
|
|
82
82
|
{ name: 'senderMemberId', type: 'fixed32' },
|
|
83
83
|
{ name: 'capability', type: 'string' },
|
|
84
84
|
{ name: 'capabilityArgs', type: 'json' },
|
|
85
|
-
{ name: 'enhance', type: '@qvac/enhance-mode' }
|
|
85
|
+
{ name: 'enhance', type: '@qvac/enhance-mode' },
|
|
86
|
+
{ name: 'sourceId', type: 'string' }
|
|
86
87
|
]);
|
|
87
88
|
versioned('chunk-counter', [
|
|
88
89
|
{ name: 'chatId', type: 'string', required: true },
|
|
@@ -115,7 +116,8 @@ export function registerQvacTypes(ns) {
|
|
|
115
116
|
{ name: 'senderMemberId', type: 'fixed32' },
|
|
116
117
|
{ name: 'capability', type: 'string' },
|
|
117
118
|
{ name: 'capabilityArgs', type: 'json' },
|
|
118
|
-
{ name: 'enhance', type: '@qvac/enhance-mode' }
|
|
119
|
+
{ name: 'enhance', type: '@qvac/enhance-mode' },
|
|
120
|
+
{ name: 'sourceId', type: 'string' }
|
|
119
121
|
]);
|
|
120
122
|
versioned('update-chunk-operation', [
|
|
121
123
|
{ name: 'id', type: 'string', required: true },
|
|
@@ -3681,7 +3681,8 @@ const encoding99 = {
|
|
|
3681
3681
|
(m.senderMemberId ? 262144 : 0) |
|
|
3682
3682
|
(m.capability ? 524288 : 0) |
|
|
3683
3683
|
(m.capabilityArgs ? 1048576 : 0) |
|
|
3684
|
-
(m.enhance ? 2097152 : 0)
|
|
3684
|
+
(m.enhance ? 2097152 : 0) |
|
|
3685
|
+
(m.sourceId ? 4194304 : 0)
|
|
3685
3686
|
|
|
3686
3687
|
c.string.preencode(state, m.id)
|
|
3687
3688
|
c.string.preencode(state, m.chatId)
|
|
@@ -3713,6 +3714,7 @@ const encoding99 = {
|
|
|
3713
3714
|
if (m.capability) c.string.preencode(state, m.capability)
|
|
3714
3715
|
if (m.capabilityArgs) c.json.preencode(state, m.capabilityArgs)
|
|
3715
3716
|
if (m.enhance) encoding71.preencode(state, m.enhance)
|
|
3717
|
+
if (m.sourceId) c.string.preencode(state, m.sourceId)
|
|
3716
3718
|
},
|
|
3717
3719
|
encode(state, m) {
|
|
3718
3720
|
const flags =
|
|
@@ -3737,7 +3739,8 @@ const encoding99 = {
|
|
|
3737
3739
|
(m.senderMemberId ? 262144 : 0) |
|
|
3738
3740
|
(m.capability ? 524288 : 0) |
|
|
3739
3741
|
(m.capabilityArgs ? 1048576 : 0) |
|
|
3740
|
-
(m.enhance ? 2097152 : 0)
|
|
3742
|
+
(m.enhance ? 2097152 : 0) |
|
|
3743
|
+
(m.sourceId ? 4194304 : 0)
|
|
3741
3744
|
|
|
3742
3745
|
c.string.encode(state, m.id)
|
|
3743
3746
|
c.string.encode(state, m.chatId)
|
|
@@ -3769,6 +3772,7 @@ const encoding99 = {
|
|
|
3769
3772
|
if (m.capability) c.string.encode(state, m.capability)
|
|
3770
3773
|
if (m.capabilityArgs) c.json.encode(state, m.capabilityArgs)
|
|
3771
3774
|
if (m.enhance) encoding71.encode(state, m.enhance)
|
|
3775
|
+
if (m.sourceId) c.string.encode(state, m.sourceId)
|
|
3772
3776
|
},
|
|
3773
3777
|
decode(state) {
|
|
3774
3778
|
const r0 = c.string.decode(state)
|
|
@@ -3804,7 +3808,8 @@ const encoding99 = {
|
|
|
3804
3808
|
senderMemberId: (flags & 262144) !== 0 ? c.fixed32.decode(state) : null,
|
|
3805
3809
|
capability: (flags & 524288) !== 0 ? c.string.decode(state) : null,
|
|
3806
3810
|
capabilityArgs: (flags & 1048576) !== 0 ? c.json.decode(state) : null,
|
|
3807
|
-
enhance: (flags & 2097152) !== 0 ? encoding71.decode(state) : null
|
|
3811
|
+
enhance: (flags & 2097152) !== 0 ? encoding71.decode(state) : null,
|
|
3812
|
+
sourceId: (flags & 4194304) !== 0 ? c.string.decode(state) : null
|
|
3808
3813
|
}
|
|
3809
3814
|
}
|
|
3810
3815
|
}
|
|
@@ -4449,7 +4454,8 @@ const encoding113 = {
|
|
|
4449
4454
|
(m.raw ? 64 : 0) |
|
|
4450
4455
|
(m.fileId ? 128 : 0) |
|
|
4451
4456
|
(m.totalBytes ? 256 : 0) |
|
|
4452
|
-
(m.meshId ? 512 : 0)
|
|
4457
|
+
(m.meshId ? 512 : 0) |
|
|
4458
|
+
(m.sourceId ? 1024 : 0)
|
|
4453
4459
|
|
|
4454
4460
|
c.uint.preencode(state, flags)
|
|
4455
4461
|
|
|
@@ -4462,6 +4468,7 @@ const encoding113 = {
|
|
|
4462
4468
|
if (m.fileId) c.string.preencode(state, m.fileId)
|
|
4463
4469
|
if (m.totalBytes) c.uint.preencode(state, m.totalBytes)
|
|
4464
4470
|
if (m.meshId) c.string.preencode(state, m.meshId)
|
|
4471
|
+
if (m.sourceId) c.string.preencode(state, m.sourceId)
|
|
4465
4472
|
},
|
|
4466
4473
|
encode(state, m) {
|
|
4467
4474
|
const flags =
|
|
@@ -4474,7 +4481,8 @@ const encoding113 = {
|
|
|
4474
4481
|
(m.raw ? 64 : 0) |
|
|
4475
4482
|
(m.fileId ? 128 : 0) |
|
|
4476
4483
|
(m.totalBytes ? 256 : 0) |
|
|
4477
|
-
(m.meshId ? 512 : 0)
|
|
4484
|
+
(m.meshId ? 512 : 0) |
|
|
4485
|
+
(m.sourceId ? 1024 : 0)
|
|
4478
4486
|
|
|
4479
4487
|
c.uint.encode(state, flags)
|
|
4480
4488
|
|
|
@@ -4487,6 +4495,7 @@ const encoding113 = {
|
|
|
4487
4495
|
if (m.fileId) c.string.encode(state, m.fileId)
|
|
4488
4496
|
if (m.totalBytes) c.uint.encode(state, m.totalBytes)
|
|
4489
4497
|
if (m.meshId) c.string.encode(state, m.meshId)
|
|
4498
|
+
if (m.sourceId) c.string.encode(state, m.sourceId)
|
|
4490
4499
|
},
|
|
4491
4500
|
decode(state) {
|
|
4492
4501
|
const flags = c.uint.decode(state)
|
|
@@ -4501,7 +4510,8 @@ const encoding113 = {
|
|
|
4501
4510
|
raw: (flags & 64) !== 0,
|
|
4502
4511
|
fileId: (flags & 128) !== 0 ? c.string.decode(state) : null,
|
|
4503
4512
|
totalBytes: (flags & 256) !== 0 ? c.uint.decode(state) : 0,
|
|
4504
|
-
meshId: (flags & 512) !== 0 ? c.string.decode(state) : null
|
|
4513
|
+
meshId: (flags & 512) !== 0 ? c.string.decode(state) : null,
|
|
4514
|
+
sourceId: (flags & 1024) !== 0 ? c.string.decode(state) : null
|
|
4505
4515
|
}
|
|
4506
4516
|
}
|
|
4507
4517
|
}
|
|
@@ -3681,7 +3681,8 @@ const encoding99 = {
|
|
|
3681
3681
|
(m.senderMemberId ? 262144 : 0) |
|
|
3682
3682
|
(m.capability ? 524288 : 0) |
|
|
3683
3683
|
(m.capabilityArgs ? 1048576 : 0) |
|
|
3684
|
-
(m.enhance ? 2097152 : 0)
|
|
3684
|
+
(m.enhance ? 2097152 : 0) |
|
|
3685
|
+
(m.sourceId ? 4194304 : 0)
|
|
3685
3686
|
|
|
3686
3687
|
c.string.preencode(state, m.id)
|
|
3687
3688
|
c.string.preencode(state, m.chatId)
|
|
@@ -3713,6 +3714,7 @@ const encoding99 = {
|
|
|
3713
3714
|
if (m.capability) c.string.preencode(state, m.capability)
|
|
3714
3715
|
if (m.capabilityArgs) c.json.preencode(state, m.capabilityArgs)
|
|
3715
3716
|
if (m.enhance) encoding71.preencode(state, m.enhance)
|
|
3717
|
+
if (m.sourceId) c.string.preencode(state, m.sourceId)
|
|
3716
3718
|
},
|
|
3717
3719
|
encode(state, m) {
|
|
3718
3720
|
const flags =
|
|
@@ -3737,7 +3739,8 @@ const encoding99 = {
|
|
|
3737
3739
|
(m.senderMemberId ? 262144 : 0) |
|
|
3738
3740
|
(m.capability ? 524288 : 0) |
|
|
3739
3741
|
(m.capabilityArgs ? 1048576 : 0) |
|
|
3740
|
-
(m.enhance ? 2097152 : 0)
|
|
3742
|
+
(m.enhance ? 2097152 : 0) |
|
|
3743
|
+
(m.sourceId ? 4194304 : 0)
|
|
3741
3744
|
|
|
3742
3745
|
c.string.encode(state, m.id)
|
|
3743
3746
|
c.string.encode(state, m.chatId)
|
|
@@ -3769,6 +3772,7 @@ const encoding99 = {
|
|
|
3769
3772
|
if (m.capability) c.string.encode(state, m.capability)
|
|
3770
3773
|
if (m.capabilityArgs) c.json.encode(state, m.capabilityArgs)
|
|
3771
3774
|
if (m.enhance) encoding71.encode(state, m.enhance)
|
|
3775
|
+
if (m.sourceId) c.string.encode(state, m.sourceId)
|
|
3772
3776
|
},
|
|
3773
3777
|
decode(state) {
|
|
3774
3778
|
const r0 = c.string.decode(state)
|
|
@@ -3804,7 +3808,8 @@ const encoding99 = {
|
|
|
3804
3808
|
senderMemberId: (flags & 262144) !== 0 ? c.fixed32.decode(state) : null,
|
|
3805
3809
|
capability: (flags & 524288) !== 0 ? c.string.decode(state) : null,
|
|
3806
3810
|
capabilityArgs: (flags & 1048576) !== 0 ? c.json.decode(state) : null,
|
|
3807
|
-
enhance: (flags & 2097152) !== 0 ? encoding71.decode(state) : null
|
|
3811
|
+
enhance: (flags & 2097152) !== 0 ? encoding71.decode(state) : null,
|
|
3812
|
+
sourceId: (flags & 4194304) !== 0 ? c.string.decode(state) : null
|
|
3808
3813
|
}
|
|
3809
3814
|
}
|
|
3810
3815
|
}
|
|
@@ -4449,7 +4454,8 @@ const encoding113 = {
|
|
|
4449
4454
|
(m.raw ? 64 : 0) |
|
|
4450
4455
|
(m.fileId ? 128 : 0) |
|
|
4451
4456
|
(m.totalBytes ? 256 : 0) |
|
|
4452
|
-
(m.meshId ? 512 : 0)
|
|
4457
|
+
(m.meshId ? 512 : 0) |
|
|
4458
|
+
(m.sourceId ? 1024 : 0)
|
|
4453
4459
|
|
|
4454
4460
|
c.uint.preencode(state, flags)
|
|
4455
4461
|
|
|
@@ -4462,6 +4468,7 @@ const encoding113 = {
|
|
|
4462
4468
|
if (m.fileId) c.string.preencode(state, m.fileId)
|
|
4463
4469
|
if (m.totalBytes) c.uint.preencode(state, m.totalBytes)
|
|
4464
4470
|
if (m.meshId) c.string.preencode(state, m.meshId)
|
|
4471
|
+
if (m.sourceId) c.string.preencode(state, m.sourceId)
|
|
4465
4472
|
},
|
|
4466
4473
|
encode(state, m) {
|
|
4467
4474
|
const flags =
|
|
@@ -4474,7 +4481,8 @@ const encoding113 = {
|
|
|
4474
4481
|
(m.raw ? 64 : 0) |
|
|
4475
4482
|
(m.fileId ? 128 : 0) |
|
|
4476
4483
|
(m.totalBytes ? 256 : 0) |
|
|
4477
|
-
(m.meshId ? 512 : 0)
|
|
4484
|
+
(m.meshId ? 512 : 0) |
|
|
4485
|
+
(m.sourceId ? 1024 : 0)
|
|
4478
4486
|
|
|
4479
4487
|
c.uint.encode(state, flags)
|
|
4480
4488
|
|
|
@@ -4487,6 +4495,7 @@ const encoding113 = {
|
|
|
4487
4495
|
if (m.fileId) c.string.encode(state, m.fileId)
|
|
4488
4496
|
if (m.totalBytes) c.uint.encode(state, m.totalBytes)
|
|
4489
4497
|
if (m.meshId) c.string.encode(state, m.meshId)
|
|
4498
|
+
if (m.sourceId) c.string.encode(state, m.sourceId)
|
|
4490
4499
|
},
|
|
4491
4500
|
decode(state) {
|
|
4492
4501
|
const flags = c.uint.decode(state)
|
|
@@ -4501,7 +4510,8 @@ const encoding113 = {
|
|
|
4501
4510
|
raw: (flags & 64) !== 0,
|
|
4502
4511
|
fileId: (flags & 128) !== 0 ? c.string.decode(state) : null,
|
|
4503
4512
|
totalBytes: (flags & 256) !== 0 ? c.uint.decode(state) : 0,
|
|
4504
|
-
meshId: (flags & 512) !== 0 ? c.string.decode(state) : null
|
|
4513
|
+
meshId: (flags & 512) !== 0 ? c.string.decode(state) : null,
|
|
4514
|
+
sourceId: (flags & 1024) !== 0 ? c.string.decode(state) : null
|
|
4505
4515
|
}
|
|
4506
4516
|
}
|
|
4507
4517
|
}
|
|
@@ -2877,6 +2877,11 @@
|
|
|
2877
2877
|
"name": "enhance",
|
|
2878
2878
|
"type": "@assistant/enhance-mode",
|
|
2879
2879
|
"version": 1
|
|
2880
|
+
},
|
|
2881
|
+
{
|
|
2882
|
+
"name": "sourceId",
|
|
2883
|
+
"type": "string",
|
|
2884
|
+
"version": 1
|
|
2880
2885
|
}
|
|
2881
2886
|
]
|
|
2882
2887
|
},
|
|
@@ -3433,6 +3438,11 @@
|
|
|
3433
3438
|
"name": "meshId",
|
|
3434
3439
|
"type": "string",
|
|
3435
3440
|
"version": 1
|
|
3441
|
+
},
|
|
3442
|
+
{
|
|
3443
|
+
"name": "sourceId",
|
|
3444
|
+
"type": "string",
|
|
3445
|
+
"version": 1
|
|
3436
3446
|
}
|
|
3437
3447
|
]
|
|
3438
3448
|
},
|
|
@@ -588,6 +588,7 @@ export interface AssistantChunkV1 {
|
|
|
588
588
|
capability?: string | null
|
|
589
589
|
capabilityArgs?: unknown | null
|
|
590
590
|
enhance?: AssistantEnhanceMode | null
|
|
591
|
+
sourceId?: string | null
|
|
591
592
|
}
|
|
592
593
|
|
|
593
594
|
export type AssistantChunk = (AssistantChunkV1 & { version?: number })
|
|
@@ -701,6 +702,7 @@ export interface AssistantUploadAttachmentRequest {
|
|
|
701
702
|
fileId?: string | null
|
|
702
703
|
totalBytes?: number
|
|
703
704
|
meshId?: string | null
|
|
705
|
+
sourceId?: string | null
|
|
704
706
|
}
|
|
705
707
|
|
|
706
708
|
export interface AssistantUploadAttachmentResponse {
|