@qvac/core 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +11 -2
- package/dist-lib/lib/assistant.d.ts +14 -1
- package/dist-lib/lib/assistant.js +107 -15
- 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.d.ts +8 -1
- package/dist-lib/lib/core.js +78 -4
- package/dist-lib/lib/inference-calls.d.ts +40 -0
- package/dist-lib/lib/inference-calls.js +266 -0
- package/dist-lib/schema/content.js +5 -1
- package/dist-lib/schema/engine.js +42 -1
- 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 +172 -49
- package/dist-lib/spec/hyperschema/index.js +172 -49
- package/dist-lib/spec/hyperschema/schema.json +127 -1
- package/dist-lib/spec/hyperschema/types.d.ts +34 -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 +14 -17
- package/tui/lib/knowledge-import.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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
2
|
import { type CurrentMesh } from './current-mesh.ts';
|
|
3
3
|
type ChatCapabilities = Pick<CapabilityHandlers, 'createChat' | 'listChats' | 'getChat' | 'renameChat' | 'setChatRagEnabled' | 'setChatWebSearchEnabled' | 'deleteChat' | 'chatsWatch' | 'listChatActivity' | 'chatActivityWatch' | 'searchChats'>;
|
|
4
|
-
export declare function createChatApi(current: CurrentMesh, deviceId: Buffer | null
|
|
4
|
+
export declare function createChatApi(current: CurrentMesh, deviceId: Buffer | null, inferenceCalls?: {
|
|
5
|
+
forget(chatId: string): Promise<void>;
|
|
6
|
+
} | null): ChatCapabilities;
|
|
5
7
|
export {};
|
package/dist-lib/lib/api/chat.js
CHANGED
|
@@ -5,7 +5,7 @@ import { searchChats } from '../core/chat-search.js';
|
|
|
5
5
|
import { meshWatchable, requireMesh, selectionPin } from './current-mesh.js';
|
|
6
6
|
import { watchable } from './watchable.js';
|
|
7
7
|
const SEARCH_SUPERSEDED_ABORT = 'superseded by a newer chat search';
|
|
8
|
-
export function createChatApi(current, deviceId) {
|
|
8
|
+
export function createChatApi(current, deviceId, inferenceCalls = null) {
|
|
9
9
|
let searchAbort = null;
|
|
10
10
|
const chatList = (mesh) => listSidebar(mesh);
|
|
11
11
|
const chatActivity = (mesh, chatIds) => listChatActivity(mesh, chatIds ?? undefined).then((activities) => ({ activities }));
|
|
@@ -16,7 +16,11 @@ export function createChatApi(current, deviceId) {
|
|
|
16
16
|
renameChat: async ({ id, title, meshId }) => renameChat(await requireMesh(current, meshId), id, title),
|
|
17
17
|
setChatRagEnabled: async ({ id, enabled }) => setChatRagEnabled(await requireMesh(current), id, enabled ?? false),
|
|
18
18
|
setChatWebSearchEnabled: async ({ id, enabled }) => setChatWebSearchEnabled(await requireMesh(current), id, enabled ?? false),
|
|
19
|
-
deleteChat: async ({ id, meshId }) =>
|
|
19
|
+
deleteChat: async ({ id, meshId }) => {
|
|
20
|
+
const deleted = await deleteChat(await requireMesh(current, meshId), deviceId, id);
|
|
21
|
+
await inferenceCalls?.forget(id);
|
|
22
|
+
return deleted;
|
|
23
|
+
},
|
|
20
24
|
chatsWatch: meshWatchable('chatsWatch', current, (_request, store) => chatList(store)),
|
|
21
25
|
listChatActivity: async (input) => chatActivity(await requireMesh(current), input?.chatIds),
|
|
22
26
|
chatActivityWatch: watchable('chatActivityWatch', () => requireMesh(current), (request, store) => chatActivity(store, request?.chatIds), () => selectionPin(current)),
|
|
@@ -3,6 +3,7 @@ import type { AssistantCapabilityProfile, AssistantClearModelDownloadRequest, As
|
|
|
3
3
|
import type { openLocalStore } from '../core/local/index.ts';
|
|
4
4
|
import type { CurrentMesh } from './current-mesh.ts';
|
|
5
5
|
import { type DiagnosticsSource } from './diagnostics.ts';
|
|
6
|
+
import { type InferenceCallReader } from './inference-calls.ts';
|
|
6
7
|
import { type LogSource } from './logs.ts';
|
|
7
8
|
import { type MeshStatusSource } from './mesh.ts';
|
|
8
9
|
import { type NetworkSource } from './network.ts';
|
|
@@ -15,6 +16,7 @@ interface ApiDeps {
|
|
|
15
16
|
meshStatus?: MeshStatusSource | null;
|
|
16
17
|
network?: NetworkSource | null;
|
|
17
18
|
diagnostics?: DiagnosticsSource | null;
|
|
19
|
+
inferenceCalls?: InferenceCallReader | null;
|
|
18
20
|
logs?: LogSource | null;
|
|
19
21
|
deviceId?: Buffer | null;
|
|
20
22
|
lifecycle?: {
|
|
@@ -11,6 +11,7 @@ import { createAppConfigApi } from './app-config.js';
|
|
|
11
11
|
import { createConfigApi } from './config.js';
|
|
12
12
|
import { createDevicesApi } from './devices.js';
|
|
13
13
|
import { createDiagnosticsApi } from './diagnostics.js';
|
|
14
|
+
import { createInferenceCallsApi } from './inference-calls.js';
|
|
14
15
|
import { createExecutionApi } from './execution.js';
|
|
15
16
|
import { createKnowledgeApi } from './knowledge.js';
|
|
16
17
|
import { createFilesApi } from './files.js';
|
|
@@ -38,7 +39,7 @@ export function createApi(deps = {}) {
|
|
|
38
39
|
...(state ? createModelDownloadApi(state) : null),
|
|
39
40
|
...(state ? createCustomModelApi(state) : null),
|
|
40
41
|
...(mesh ? createAgentsApi(mesh, deps.deviceId ?? null, deps.computeLender ?? null) : null),
|
|
41
|
-
...(mesh ? createChatApi(mesh, deps.deviceId ?? null) : null),
|
|
42
|
+
...(mesh ? createChatApi(mesh, deps.deviceId ?? null, deps.inferenceCalls ?? null) : null),
|
|
42
43
|
...(mesh ? createChatGroupsApi(mesh) : null),
|
|
43
44
|
...(mesh ? createApprovalRulesApi(mesh) : null),
|
|
44
45
|
...(mesh ? createChunksApi(mesh, deps.deviceId ?? null) : null),
|
|
@@ -68,6 +69,7 @@ export function createApi(deps = {}) {
|
|
|
68
69
|
...(mesh ? createMembersApi(mesh, state) : null),
|
|
69
70
|
...(deps.network ? createNetworkApi(deps.network) : null),
|
|
70
71
|
...(deps.diagnostics ? createDiagnosticsApi(deps.diagnostics) : null),
|
|
72
|
+
...(deps.inferenceCalls ? createInferenceCallsApi(deps.inferenceCalls) : null),
|
|
71
73
|
...(deps.logs ? createLogsApi(deps.logs) : null),
|
|
72
74
|
...(deps.lifecycle
|
|
73
75
|
? {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
|
+
import type { InferenceCallEntry } from '../inference-calls.ts';
|
|
3
|
+
export interface InferenceCallSource {
|
|
4
|
+
list(chatId: string): {
|
|
5
|
+
calls: ReadonlyArray<InferenceCallEntry>;
|
|
6
|
+
truncated: boolean;
|
|
7
|
+
};
|
|
8
|
+
forget(chatId: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface InferenceCallAnswer {
|
|
11
|
+
calls: ReadonlyArray<InferenceCallEntry>;
|
|
12
|
+
truncated: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface InferenceCallReader {
|
|
15
|
+
list(chatId: string): Promise<InferenceCallAnswer>;
|
|
16
|
+
forget(chatId: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createInferenceCallsApi(reader: InferenceCallReader): Pick<CapabilityHandlers, 'inferenceCalls'>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function createInferenceCallsApi(reader) {
|
|
2
|
+
return {
|
|
3
|
+
inferenceCalls: async ({ chatId }) => {
|
|
4
|
+
const answer = await reader.list(chatId);
|
|
5
|
+
return {
|
|
6
|
+
calls: answer.calls.map((entry) => ({
|
|
7
|
+
runId: entry.runId,
|
|
8
|
+
at: entry.at,
|
|
9
|
+
call: entry.call
|
|
10
|
+
})),
|
|
11
|
+
truncated: answer.truncated
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
package/dist-lib/lib/api/rag.js
CHANGED
|
@@ -138,7 +138,11 @@ export function createRagApi(current, index, embedder, effectiveCtxSize = null)
|
|
|
138
138
|
chatId,
|
|
139
139
|
limit: clampLimit(limit),
|
|
140
140
|
liveSourceIds: rows.map((row) => row.id)
|
|
141
|
-
}, {
|
|
141
|
+
}, {
|
|
142
|
+
index: vectorIndex,
|
|
143
|
+
embed: (texts) => embed.embed({ texts }),
|
|
144
|
+
debug: (message) => logger.debug('rag', message)
|
|
145
|
+
});
|
|
142
146
|
return respond({
|
|
143
147
|
searchedCount: hits.length,
|
|
144
148
|
indexEmpty,
|
|
@@ -163,7 +167,11 @@ export function createRagApi(current, index, embedder, effectiveCtxSize = null)
|
|
|
163
167
|
documents: hydratedDocuments,
|
|
164
168
|
liveSourceIds: rows.map((row) => row.id),
|
|
165
169
|
scopeDocumentIds: scopeDocumentIds.length > 0 ? scopeDocumentIds : undefined
|
|
166
|
-
}, {
|
|
170
|
+
}, {
|
|
171
|
+
index: vectorIndex,
|
|
172
|
+
embed: (texts) => embed.embed({ texts }),
|
|
173
|
+
debug: (message) => logger.debug('rag', message)
|
|
174
|
+
});
|
|
167
175
|
return respond({
|
|
168
176
|
searchedCount: result.searchedCount,
|
|
169
177
|
indexEmpty,
|
|
@@ -21,6 +21,7 @@ export interface AssistantTreeOptions {
|
|
|
21
21
|
harness: HarnessFactory | ChildSpec<Harness>;
|
|
22
22
|
logger?: Logger | null;
|
|
23
23
|
imageCacheDir?: string;
|
|
24
|
+
inferenceCallsDir?: string;
|
|
24
25
|
imageCacheMaxBytes?: number;
|
|
25
26
|
imageCacheMaxAgeMs?: number;
|
|
26
27
|
embedder?: EmbedderFactory;
|
|
@@ -35,6 +36,7 @@ export interface AssistantChildOptions {
|
|
|
35
36
|
core?: string;
|
|
36
37
|
logger?: Logger | null;
|
|
37
38
|
imageCacheDir?: string;
|
|
39
|
+
inferenceCallsDir?: string;
|
|
38
40
|
imageCacheMaxBytes?: number;
|
|
39
41
|
imageCacheMaxAgeMs?: number;
|
|
40
42
|
embedder?: EmbedderFactory;
|
|
@@ -5,7 +5,7 @@ import { startCustomModelPusher } from './custom-model-pusher.js';
|
|
|
5
5
|
import { serveHarness } from '@qvac/harness';
|
|
6
6
|
import { duplexPair } from '@qvac/harness/transport';
|
|
7
7
|
export function assistantTree(opts) {
|
|
8
|
-
const { core, harness, logger = null, imageCacheDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, platform, preloadCurrentAgentModel } = opts;
|
|
8
|
+
const { core, harness, logger = null, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, platform, preloadCurrentAgentModel } = opts;
|
|
9
9
|
const sup = new Supervisor();
|
|
10
10
|
const logged = ['child-died', 'child-restarting', 'child-ready', 'gave-up', 'stall'];
|
|
11
11
|
for (const event of logged) {
|
|
@@ -13,6 +13,7 @@ export function assistantTree(opts) {
|
|
|
13
13
|
}
|
|
14
14
|
sup.on('power', (payload) => logger?.info('assistant-tree', 'power', payload));
|
|
15
15
|
let offDiagnostics = null;
|
|
16
|
+
let offInferenceCalls = null;
|
|
16
17
|
let offListModels = null;
|
|
17
18
|
let offDeleteModel = null;
|
|
18
19
|
let offClearKvCache = null;
|
|
@@ -59,6 +60,7 @@ export function assistantTree(opts) {
|
|
|
59
60
|
const assistant = new QvacAssistant(engine, harness, {
|
|
60
61
|
logger,
|
|
61
62
|
imageCacheDir,
|
|
63
|
+
...(inferenceCallsDir ? { inferenceCallsDir } : {}),
|
|
62
64
|
imageCacheMaxBytes,
|
|
63
65
|
imageCacheMaxAgeMs,
|
|
64
66
|
...(platform ? { platform } : {}),
|
|
@@ -67,6 +69,10 @@ export function assistantTree(opts) {
|
|
|
67
69
|
borrowHarness: (deviceId) => core.borrowHarness(deviceId)
|
|
68
70
|
});
|
|
69
71
|
offDiagnostics = core.registerDiagnostics(() => assistant.diagnosticsSlice());
|
|
72
|
+
offInferenceCalls = core.registerInferenceCalls({
|
|
73
|
+
list: (chatId) => assistant.inferenceCalls(chatId),
|
|
74
|
+
forget: (chatId) => assistant.forgetInferenceCalls(chatId)
|
|
75
|
+
});
|
|
70
76
|
offListModels = core.registerListModels(harnessListModels(harness));
|
|
71
77
|
offDeleteModel = core.registerDeleteModel(harnessDeleteModel(harness));
|
|
72
78
|
offClearKvCache = core.registerClearKvCache(harnessClearKvCache(harness));
|
|
@@ -116,6 +122,8 @@ export function assistantTree(opts) {
|
|
|
116
122
|
stop: async (assistant) => {
|
|
117
123
|
offDiagnostics?.();
|
|
118
124
|
offDiagnostics = null;
|
|
125
|
+
offInferenceCalls?.();
|
|
126
|
+
offInferenceCalls = null;
|
|
119
127
|
offListModels?.();
|
|
120
128
|
offListModels = null;
|
|
121
129
|
offDeleteModel?.();
|
|
@@ -162,7 +170,7 @@ export function assistantTree(opts) {
|
|
|
162
170
|
return sup;
|
|
163
171
|
}
|
|
164
172
|
export function assistantChild(opts) {
|
|
165
|
-
const { harness, core = 'core', logger = null, imageCacheDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, preloadCurrentAgentModel, ...spec } = opts;
|
|
173
|
+
const { harness, core = 'core', logger = null, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, preloadCurrentAgentModel, ...spec } = opts;
|
|
166
174
|
return {
|
|
167
175
|
...spec,
|
|
168
176
|
deps: [core],
|
|
@@ -172,6 +180,7 @@ export function assistantChild(opts) {
|
|
|
172
180
|
harness,
|
|
173
181
|
logger,
|
|
174
182
|
imageCacheDir,
|
|
183
|
+
...(inferenceCallsDir ? { inferenceCallsDir } : {}),
|
|
175
184
|
imageCacheMaxBytes,
|
|
176
185
|
imageCacheMaxAgeMs,
|
|
177
186
|
embedder,
|
|
@@ -5,6 +5,7 @@ import type { AssistantKvCacheDeletionResponse, AssistantModelCatalogRevision }
|
|
|
5
5
|
import type { Capabilities } from './api/index.ts';
|
|
6
6
|
import type { DriveHost } from './core/fs-drives.ts';
|
|
7
7
|
import { type DiagnosticsSlice } from './diagnostics.ts';
|
|
8
|
+
import { type InferenceCallEntry } from './inference-calls.ts';
|
|
8
9
|
import type { Logger } from './log.ts';
|
|
9
10
|
import { type DeleteModelSummary, type Harness, type ListModelsOptions, type ModelInfo, type ToolCatalogEntry } from './assistant/harness.ts';
|
|
10
11
|
import type { Skill } from './assistant/skill-encode.ts';
|
|
@@ -13,9 +14,13 @@ export { harnessClearKvCache, harnessDeleteModel, harnessListModels, harnessSkil
|
|
|
13
14
|
export { type Skill } from './assistant/skill-encode.ts';
|
|
14
15
|
export { annotateUnreadableImages, unheardAudioNotice, unreadableImagesNotice, DOCUMENT_ONLY_USER_PROMPT, IMAGE_AND_DOCUMENT_USER_PROMPT, IMAGE_ONLY_USER_PROMPT } from './assistant/message.ts';
|
|
15
16
|
export { historyFromChunks, listHistoryChunks, staleToolRunIds, type CompactOptions, type CompactResult, type CompactionTrigger, type StaleToolRuns } from './assistant/history.ts';
|
|
17
|
+
export declare const CAPTURE_INFERENCE_CALLS_KEY = "inspector.captureInferenceCalls";
|
|
18
|
+
export declare const CAPTURE_ON = "on";
|
|
19
|
+
export declare const CAPTURE_OFF = "off";
|
|
16
20
|
export interface AssistantOptions {
|
|
17
21
|
logger?: Logger | null;
|
|
18
22
|
imageCacheDir?: string;
|
|
23
|
+
inferenceCallsDir?: string;
|
|
19
24
|
imageCacheMaxBytes?: number;
|
|
20
25
|
imageCacheMaxAgeMs?: number;
|
|
21
26
|
downloadRetryMs?: number;
|
|
@@ -68,6 +73,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
68
73
|
private readonly _runConsumers;
|
|
69
74
|
private readonly _runs;
|
|
70
75
|
private readonly _seen;
|
|
76
|
+
private readonly _inferenceCalls;
|
|
71
77
|
private readonly _lifecycle;
|
|
72
78
|
private readonly _audioTranscripts;
|
|
73
79
|
private readonly _chats;
|
|
@@ -76,7 +82,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
76
82
|
private readonly _modelCatalog;
|
|
77
83
|
private readonly _onHarnessStatus;
|
|
78
84
|
private readonly _onModelCatalogEvent;
|
|
79
|
-
constructor(engine: Capabilities, harness: Harness, { logger, imageCacheDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform, preloadCurrentAgentModel, drives, borrowHarness, blobReadTimeoutMs }?: AssistantOptions);
|
|
85
|
+
constructor(engine: Capabilities, harness: Harness, { logger, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform, preloadCurrentAgentModel, drives, borrowHarness, blobReadTimeoutMs }?: AssistantOptions);
|
|
80
86
|
_open(): Promise<void>;
|
|
81
87
|
private _triggerModelWarm;
|
|
82
88
|
private _warmCurrentAgentModel;
|
|
@@ -87,9 +93,16 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
87
93
|
ensureMediaModelUnpaused(category: ModelCategory, model?: string | null): Promise<boolean>;
|
|
88
94
|
private _persistedProfile;
|
|
89
95
|
private _sweepImageCache;
|
|
96
|
+
private _sweepInferenceCalls;
|
|
90
97
|
private _imageCacheInUse;
|
|
91
98
|
private _referencedImageNames;
|
|
92
99
|
private _describeHarness;
|
|
100
|
+
private _capturingInferenceCalls;
|
|
101
|
+
inferenceCalls(chatId: string): {
|
|
102
|
+
calls: ReadonlyArray<InferenceCallEntry>;
|
|
103
|
+
truncated: boolean;
|
|
104
|
+
};
|
|
105
|
+
forgetInferenceCalls(chatId: string): Promise<void>;
|
|
93
106
|
diagnosticsSlice(): DiagnosticsSlice;
|
|
94
107
|
private _refreshHarnessDiagnostics;
|
|
95
108
|
private _reportCapabilities;
|
|
@@ -11,6 +11,7 @@ import { loanFailureNotice } from './core/harness-loan.js';
|
|
|
11
11
|
import { SKILL_STATE } from '@qvac/harness/lib/tools/skills/skill-state.ts';
|
|
12
12
|
import { toolsetEnabled } from '@qvac/harness/lib/tools/toolsets.ts';
|
|
13
13
|
import { RAG_CITATION_LINE } from '@qvac/harness/lib/prompt.ts';
|
|
14
|
+
import { MAX_RAG_SOURCE_URL_CHARS, MAX_RAG_SOURCES_PER_CHUNK, RAG_SOURCE_EXCERPT_CHARS } from '../schema/qvac.js';
|
|
14
15
|
import { acceptedRepairCount, historyBranches, isPromptChunk } from './core/prompt-history.js';
|
|
15
16
|
import ReadyGuard from 'ready-guard';
|
|
16
17
|
import ReadyResource from 'ready-resource';
|
|
@@ -26,6 +27,7 @@ import { imageCacheName, sweepImageCache } from './core/image/cache-sweep.js';
|
|
|
26
27
|
import { IMAGE_MIMES, normalizeImageForModel } from './core/image/normalize.js';
|
|
27
28
|
import { summarizeRuns } from './diagnostics.js';
|
|
28
29
|
import { resolveFsGrants } from './fs-drive-bridge.js';
|
|
30
|
+
import { InferenceCallStore } from './inference-calls.js';
|
|
29
31
|
import { fsGrantKey, fsWriteGrantKey } from './fs-grant-keys.js';
|
|
30
32
|
import { fsGrantsFrom, grantedDirsFrom } from './fs-grants.js';
|
|
31
33
|
import { defaultImageCacheDir } from './image-cache-dir.js';
|
|
@@ -63,6 +65,10 @@ function isDeniedResult(result) {
|
|
|
63
65
|
return false;
|
|
64
66
|
return result.denied === true;
|
|
65
67
|
}
|
|
68
|
+
const TITLE_RUN_ID = 'chat-title';
|
|
69
|
+
export const CAPTURE_INFERENCE_CALLS_KEY = 'inspector.captureInferenceCalls';
|
|
70
|
+
export const CAPTURE_ON = 'on';
|
|
71
|
+
export const CAPTURE_OFF = 'off';
|
|
66
72
|
const BLOB_READ_TIMEOUT_MS = 15_000;
|
|
67
73
|
const SUSPENDED = RUN_ABORT_REASONS.suspended;
|
|
68
74
|
const OWNERSHIP_LOST = RUN_ABORT_REASONS.ownershipLost;
|
|
@@ -80,6 +86,11 @@ function withConfigDefaults(agent, config) {
|
|
|
80
86
|
return agent;
|
|
81
87
|
return { ...agent, ctxSize: config.ctxSize };
|
|
82
88
|
}
|
|
89
|
+
const RAG_SOURCE_BOUNDS = {
|
|
90
|
+
maxSources: MAX_RAG_SOURCES_PER_CHUNK,
|
|
91
|
+
excerptChars: RAG_SOURCE_EXCERPT_CHARS
|
|
92
|
+
};
|
|
93
|
+
const WEB_RAG_SOURCE_BOUNDS = { ...RAG_SOURCE_BOUNDS, maxUrlChars: MAX_RAG_SOURCE_URL_CHARS };
|
|
83
94
|
export class QvacAssistant extends ReadyResource {
|
|
84
95
|
_engine;
|
|
85
96
|
_harness;
|
|
@@ -123,6 +134,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
123
134
|
_runConsumers;
|
|
124
135
|
_runs;
|
|
125
136
|
_seen;
|
|
137
|
+
_inferenceCalls;
|
|
126
138
|
_lifecycle;
|
|
127
139
|
_audioTranscripts;
|
|
128
140
|
_chats;
|
|
@@ -131,7 +143,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
131
143
|
_modelCatalog = new ModelCatalogRevisionHub();
|
|
132
144
|
_onHarnessStatus;
|
|
133
145
|
_onModelCatalogEvent;
|
|
134
|
-
constructor(engine, harness, { logger = null, imageCacheDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform = os.platform(), preloadCurrentAgentModel = true, drives, borrowHarness, blobReadTimeoutMs = BLOB_READ_TIMEOUT_MS } = {}) {
|
|
146
|
+
constructor(engine, harness, { logger = null, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform = os.platform(), preloadCurrentAgentModel = true, drives, borrowHarness, blobReadTimeoutMs = BLOB_READ_TIMEOUT_MS } = {}) {
|
|
135
147
|
super();
|
|
136
148
|
this._engine = engine;
|
|
137
149
|
this._harness = harness;
|
|
@@ -167,6 +179,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
167
179
|
this._runConsumers = new Map();
|
|
168
180
|
this._runs = new Map();
|
|
169
181
|
this._seen = new Map();
|
|
182
|
+
this._inferenceCalls = new InferenceCallStore(inferenceCallsDir);
|
|
170
183
|
this._lifecycle = new AbortController();
|
|
171
184
|
this._audioTranscripts = new Map();
|
|
172
185
|
this._chats = new Map();
|
|
@@ -275,6 +288,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
275
288
|
try {
|
|
276
289
|
await Promise.allSettled([
|
|
277
290
|
this._sweepImageCache(),
|
|
291
|
+
this._sweepInferenceCalls(),
|
|
278
292
|
this._reportCapabilities(),
|
|
279
293
|
this._reconcileDeviceProfile()
|
|
280
294
|
]);
|
|
@@ -335,6 +349,16 @@ export class QvacAssistant extends ReadyResource {
|
|
|
335
349
|
this._log?.warn('assistant', 'image cache sweep failed', err);
|
|
336
350
|
}
|
|
337
351
|
}
|
|
352
|
+
async _sweepInferenceCalls() {
|
|
353
|
+
try {
|
|
354
|
+
const { removed } = await this._inferenceCalls.sweep();
|
|
355
|
+
if (removed > 0)
|
|
356
|
+
this._log?.info('assistant', 'inspector records swept', { removed });
|
|
357
|
+
}
|
|
358
|
+
catch (err) {
|
|
359
|
+
this._log?.warn('assistant', 'inspector record sweep failed', err);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
338
362
|
_imageCacheInUse(name) {
|
|
339
363
|
for (const names of this._runImageCacheNames.values())
|
|
340
364
|
if (names.has(name))
|
|
@@ -369,6 +393,22 @@ export class QvacAssistant extends ReadyResource {
|
|
|
369
393
|
supportsImages: this._harness.supportsImages ?? false
|
|
370
394
|
});
|
|
371
395
|
}
|
|
396
|
+
async _capturingInferenceCalls() {
|
|
397
|
+
try {
|
|
398
|
+
const { value } = await this._engine.configGet({ key: CAPTURE_INFERENCE_CALLS_KEY });
|
|
399
|
+
return value === CAPTURE_ON;
|
|
400
|
+
}
|
|
401
|
+
catch (err) {
|
|
402
|
+
this._log?.warn('assistant', 'inspector capture flag unreadable', { err });
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
inferenceCalls(chatId) {
|
|
407
|
+
return this._inferenceCalls.list(chatId);
|
|
408
|
+
}
|
|
409
|
+
forgetInferenceCalls(chatId) {
|
|
410
|
+
return this._inferenceCalls.forget(chatId);
|
|
411
|
+
}
|
|
372
412
|
diagnosticsSlice() {
|
|
373
413
|
const harness = this._harness.diagnostics?.() ?? this._harnessDiagnostics;
|
|
374
414
|
void this._refreshHarnessDiagnostics();
|
|
@@ -684,10 +724,14 @@ export class QvacAssistant extends ReadyResource {
|
|
|
684
724
|
for (const chatId of disappearedChatIds(known, ids)) {
|
|
685
725
|
this._reconciledCompactions.delete(chatId);
|
|
686
726
|
void this._deleteChatKvCache(chatId, 'chat deleted');
|
|
727
|
+
void this._inferenceCalls
|
|
728
|
+
.forget(chatId)
|
|
729
|
+
.catch((err) => this._log?.warn('assistant', 'inspector records not dropped', { err }));
|
|
687
730
|
}
|
|
688
731
|
}
|
|
689
732
|
known = new Set(ids);
|
|
690
733
|
await this._sweepImageCache();
|
|
734
|
+
await this._sweepInferenceCalls();
|
|
691
735
|
}
|
|
692
736
|
}
|
|
693
737
|
async _watchAgents() {
|
|
@@ -914,7 +958,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
914
958
|
settle.catch((err) => this._log?.error('assistant', `run ${runId} failed`, err));
|
|
915
959
|
}
|
|
916
960
|
async _citeWebSources(transcript, runId, result) {
|
|
917
|
-
const records = webSourcesFromToolResult(result);
|
|
961
|
+
const records = webSourcesFromToolResult(result, WEB_RAG_SOURCE_BOUNDS);
|
|
918
962
|
if (records.length === 0)
|
|
919
963
|
return;
|
|
920
964
|
try {
|
|
@@ -1133,6 +1177,8 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1133
1177
|
await transcript.flush();
|
|
1134
1178
|
};
|
|
1135
1179
|
let titleOutcome = null;
|
|
1180
|
+
let runFailure = null;
|
|
1181
|
+
let runVerdict = 'completed';
|
|
1136
1182
|
try {
|
|
1137
1183
|
const attachTurnIds = attachTurnDocumentIds(history);
|
|
1138
1184
|
if (attachTurnIds.length > 0)
|
|
@@ -1144,11 +1190,15 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1144
1190
|
if (controller.signal.aborted) {
|
|
1145
1191
|
const outcome = this._abortOutcome(runId, controller.signal.reason);
|
|
1146
1192
|
if (outcome.kind === 'replay') {
|
|
1193
|
+
runVerdict = 'replay';
|
|
1147
1194
|
this._seen.delete(runId);
|
|
1148
1195
|
return;
|
|
1149
1196
|
}
|
|
1150
|
-
if (outcome.kind === 'handoff')
|
|
1197
|
+
if (outcome.kind === 'handoff') {
|
|
1198
|
+
runVerdict = 'handoff';
|
|
1151
1199
|
return;
|
|
1200
|
+
}
|
|
1201
|
+
runFailure = outcome.reason;
|
|
1152
1202
|
await transcript.status({ state: 'failed', reason: outcome.reason, metrics });
|
|
1153
1203
|
return;
|
|
1154
1204
|
}
|
|
@@ -1174,7 +1224,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1174
1224
|
}
|
|
1175
1225
|
}
|
|
1176
1226
|
else {
|
|
1177
|
-
const records = sourcesFromHits(knowledge.hits);
|
|
1227
|
+
const records = sourcesFromHits(knowledge.hits, RAG_SOURCE_BOUNDS);
|
|
1178
1228
|
const notice = chooseRagNotice({
|
|
1179
1229
|
errorMessage: knowledge.search.errorMessage,
|
|
1180
1230
|
hitCount: records.length,
|
|
@@ -1283,7 +1333,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1283
1333
|
limit: input.limit
|
|
1284
1334
|
}), controller.signal);
|
|
1285
1335
|
const hits = found.hits ?? [];
|
|
1286
|
-
const records = sourcesFromHits(hits);
|
|
1336
|
+
const records = sourcesFromHits(hits, RAG_SOURCE_BOUNDS);
|
|
1287
1337
|
if (records.length > 0) {
|
|
1288
1338
|
try {
|
|
1289
1339
|
sourceTagFilter.add(records.map((record) => record.title));
|
|
@@ -1311,6 +1361,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1311
1361
|
},
|
|
1312
1362
|
progress: (update) => modelWatch.image(update),
|
|
1313
1363
|
generationParams: diagramRepair ? { reasoning_budget: 0 } : undefined,
|
|
1364
|
+
captureInferenceCalls: await this._capturingInferenceCalls(),
|
|
1314
1365
|
signal: controller.signal
|
|
1315
1366
|
});
|
|
1316
1367
|
let harnessEvents = 0;
|
|
@@ -1334,6 +1385,25 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1334
1385
|
this._log?.info('runs', 'run metrics', { runId, ...runMetricsSummary(rest) });
|
|
1335
1386
|
continue;
|
|
1336
1387
|
}
|
|
1388
|
+
if (event.type === 'inference-sent') {
|
|
1389
|
+
void this._inferenceCalls
|
|
1390
|
+
.recordSent(chatId, {
|
|
1391
|
+
runId,
|
|
1392
|
+
round: Number(event.round ?? 0),
|
|
1393
|
+
messages: event.messages,
|
|
1394
|
+
tokens: event.tokens,
|
|
1395
|
+
outcome: event.outcome,
|
|
1396
|
+
reason: event.reason
|
|
1397
|
+
})
|
|
1398
|
+
.catch((err) => this._log?.warn('assistant', 'sent slice not recorded', { err }));
|
|
1399
|
+
continue;
|
|
1400
|
+
}
|
|
1401
|
+
if (event.type === 'inference-call') {
|
|
1402
|
+
void this._inferenceCalls
|
|
1403
|
+
.record(chatId, { runId, at: Date.now(), call: asRecord(event.call) })
|
|
1404
|
+
.catch((err) => this._log?.warn('assistant', 'inference call not recorded', { err }));
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1337
1407
|
await flushTranscript();
|
|
1338
1408
|
if (event.type === 'error') {
|
|
1339
1409
|
const folded = isContextOverflowFailure(event.message) &&
|
|
@@ -1344,11 +1414,8 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1344
1414
|
signal: controller.signal,
|
|
1345
1415
|
meshId
|
|
1346
1416
|
}));
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
reason: runFailureNotice(event.message),
|
|
1350
|
-
metrics
|
|
1351
|
-
});
|
|
1417
|
+
runFailure = runFailureNotice(event.message);
|
|
1418
|
+
await transcript.status({ state: 'failed', reason: runFailure, metrics });
|
|
1352
1419
|
if (folded) {
|
|
1353
1420
|
await this._engine
|
|
1354
1421
|
.runAgent({ chatId, agentId: agent.id, parentRunId: runId })
|
|
@@ -1360,11 +1427,15 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1360
1427
|
if (event.type === 'aborted') {
|
|
1361
1428
|
const outcome = this._abortOutcome(runId, controller.signal.reason);
|
|
1362
1429
|
if (outcome.kind === 'replay') {
|
|
1430
|
+
runVerdict = 'replay';
|
|
1363
1431
|
this._seen.delete(runId);
|
|
1364
1432
|
return;
|
|
1365
1433
|
}
|
|
1366
|
-
if (outcome.kind === 'handoff')
|
|
1434
|
+
if (outcome.kind === 'handoff') {
|
|
1435
|
+
runVerdict = 'handoff';
|
|
1367
1436
|
return;
|
|
1437
|
+
}
|
|
1438
|
+
runFailure = outcome.reason;
|
|
1368
1439
|
await transcript.status({ state: 'failed', reason: outcome.reason, metrics });
|
|
1369
1440
|
titleOutcome = 'ended';
|
|
1370
1441
|
return;
|
|
@@ -1438,17 +1509,28 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1438
1509
|
? this._abortOutcome(runId, controller.signal.reason)
|
|
1439
1510
|
: null;
|
|
1440
1511
|
if (outcome?.kind === 'replay') {
|
|
1512
|
+
runVerdict = 'replay';
|
|
1441
1513
|
this._seen.delete(runId);
|
|
1442
1514
|
return;
|
|
1443
1515
|
}
|
|
1444
|
-
if (outcome?.kind === 'handoff')
|
|
1516
|
+
if (outcome?.kind === 'handoff') {
|
|
1517
|
+
runVerdict = 'handoff';
|
|
1445
1518
|
return;
|
|
1519
|
+
}
|
|
1446
1520
|
await flushTranscript();
|
|
1447
|
-
|
|
1448
|
-
|
|
1521
|
+
runFailure =
|
|
1522
|
+
(this._lenderFor(runAgent) ? loanFailureNotice(err) : null) ?? runFailureNotice(err);
|
|
1523
|
+
await transcript.status({ state: 'failed', reason: runFailure, metrics });
|
|
1449
1524
|
titleOutcome = 'ended';
|
|
1450
1525
|
}
|
|
1451
1526
|
finally {
|
|
1527
|
+
void this._inferenceCalls
|
|
1528
|
+
.recordOutcome(chatId, {
|
|
1529
|
+
runId,
|
|
1530
|
+
outcome: runFailure ? 'failed' : runVerdict,
|
|
1531
|
+
reason: runFailure
|
|
1532
|
+
})
|
|
1533
|
+
.catch((err) => this._log?.warn('assistant', 'run outcome not recorded', { err }));
|
|
1452
1534
|
transcript.close();
|
|
1453
1535
|
modelWatch.stop();
|
|
1454
1536
|
ownershipWatch.stop();
|
|
@@ -1881,6 +1963,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1881
1963
|
if (probe && !this.closing) {
|
|
1882
1964
|
try {
|
|
1883
1965
|
generated = await this._titleFromCompletion({
|
|
1966
|
+
chatId,
|
|
1884
1967
|
input: prompt,
|
|
1885
1968
|
model,
|
|
1886
1969
|
agent,
|
|
@@ -1903,7 +1986,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1903
1986
|
return title;
|
|
1904
1987
|
}
|
|
1905
1988
|
async _titleFromCompletion(params) {
|
|
1906
|
-
const { input, model, agent, signal } = params;
|
|
1989
|
+
const { chatId, input, model, agent, signal } = params;
|
|
1907
1990
|
const events = this._harnessFor(agent).completion({
|
|
1908
1991
|
model,
|
|
1909
1992
|
agent: {
|
|
@@ -1915,6 +1998,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1915
1998
|
},
|
|
1916
1999
|
messages: [{ role: 'user', content: buildTitlePrompt(input) }],
|
|
1917
2000
|
generationParams: { reasoning_budget: 0 },
|
|
2001
|
+
captureInferenceCalls: await this._capturingInferenceCalls(),
|
|
1918
2002
|
responseFormat: {
|
|
1919
2003
|
type: 'json_schema',
|
|
1920
2004
|
json_schema: {
|
|
@@ -1933,6 +2017,11 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1933
2017
|
for await (const event of events) {
|
|
1934
2018
|
if (event.type === 'content' && typeof event.text === 'string')
|
|
1935
2019
|
text += event.text;
|
|
2020
|
+
else if (event.type === 'inference-call') {
|
|
2021
|
+
void this._inferenceCalls
|
|
2022
|
+
.record(chatId, { runId: TITLE_RUN_ID, at: Date.now(), call: asRecord(event.call) })
|
|
2023
|
+
.catch((err) => this._log?.warn('assistant', 'title call not recorded', { err }));
|
|
2024
|
+
}
|
|
1936
2025
|
else if (event.type === 'error' || event.type === 'aborted' || event.type === 'done')
|
|
1937
2026
|
break;
|
|
1938
2027
|
}
|
|
@@ -2270,6 +2359,9 @@ function runMetricsSummary(metrics) {
|
|
|
2270
2359
|
stopReason
|
|
2271
2360
|
};
|
|
2272
2361
|
}
|
|
2362
|
+
function asRecord(value) {
|
|
2363
|
+
return typeof value === 'object' && value !== null ? { ...value } : {};
|
|
2364
|
+
}
|
|
2273
2365
|
function isStreamDestroyed(err) {
|
|
2274
2366
|
return typeof err === 'object' && err !== null && 'code' in err && err.code === 'STREAM_DESTROYED';
|
|
2275
2367
|
}
|
|
@@ -144,6 +144,8 @@ export async function appendChunk(store, { id = randomId(), chatId, runId, type,
|
|
|
144
144
|
if (type === 'sources' && !ragSourcesWithinBounds(payload.sources)) {
|
|
145
145
|
throw new Error('chunk payload invalid: a sources chunk exceeds its wire bounds');
|
|
146
146
|
}
|
|
147
|
+
if (type === 'user-message' && !store.ourMemberId)
|
|
148
|
+
await store.refreshOurMember();
|
|
147
149
|
if (parentId) {
|
|
148
150
|
const parent = await getChunk(store, parentId);
|
|
149
151
|
if (!parent || parent.chatId !== chatId) {
|
|
@@ -162,6 +164,9 @@ export async function appendChunk(store, { id = randomId(), chatId, runId, type,
|
|
|
162
164
|
display,
|
|
163
165
|
rawCall,
|
|
164
166
|
createdAt: Date.now(),
|
|
167
|
+
...(type === 'user-message' && store.ourMemberId && store.ourDeviceId?.equals(originDeviceId)
|
|
168
|
+
? { senderMemberId: store.ourMemberId }
|
|
169
|
+
: undefined),
|
|
165
170
|
...payload
|
|
166
171
|
};
|
|
167
172
|
await into.dispatch('append-chunk', op);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
2
|
import type { QvacKnowledge } from '../../../../spec/mesh/hyperschema/types.d.ts';
|
|
3
|
-
import { type RagExtractors } from '
|
|
4
|
-
import type { RagArtifactPayload } from './artifact/types.ts';
|
|
3
|
+
import { type RagArtifactPayload, type RagExtractors } from 'rag-extract';
|
|
5
4
|
export type BuildEmbedder = {
|
|
6
5
|
model: string;
|
|
7
6
|
embed(input: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { chunkRagDocuments } from '
|
|
2
|
-
import { extractRagDocumentFromBytes } from './extract/extract.js';
|
|
1
|
+
import { chunkRagDocuments, extractRagDocumentFromBytes } from 'rag-extract';
|
|
3
2
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
4
3
|
const EMBED_BATCH = 8;
|
|
5
4
|
export class EmbedderFailure extends Error {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RagFileExtractor } from '
|
|
1
|
+
import type { RagFileExtractor } from 'rag-extract';
|
|
2
2
|
export declare const extractOfficeText: RagFileExtractor;
|