@qvac/core 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/lib/api/chat.d.ts +3 -1
- package/dist-lib/lib/api/chat.js +6 -2
- package/dist-lib/lib/api/index.d.ts +2 -0
- package/dist-lib/lib/api/index.js +3 -1
- package/dist-lib/lib/api/inference-calls.d.ts +18 -0
- package/dist-lib/lib/api/inference-calls.js +15 -0
- package/dist-lib/lib/api/rag.js +10 -2
- package/dist-lib/lib/assistant/harness.d.ts +1 -0
- package/dist-lib/lib/assistant/history.d.ts +10 -1
- package/dist-lib/lib/assistant/history.js +36 -1
- package/dist-lib/lib/assistant/message.d.ts +2 -0
- package/dist-lib/lib/assistant/message.js +11 -0
- package/dist-lib/lib/assistant/skill-encode.js +27 -1
- package/dist-lib/lib/assistant-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +11 -2
- package/dist-lib/lib/assistant.d.ts +19 -3
- package/dist-lib/lib/assistant.js +148 -23
- package/dist-lib/lib/core/chunk.js +5 -0
- package/dist-lib/lib/core/files/rag/build.d.ts +1 -2
- package/dist-lib/lib/core/files/rag/build.js +1 -2
- package/dist-lib/lib/core/files/rag/extract/office-collabora.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/index.d.ts +4 -24
- package/dist-lib/lib/core/files/rag/index.js +3 -17
- package/dist-lib/lib/core/files/rag/load.d.ts +1 -2
- package/dist-lib/lib/core/files/rag/load.js +1 -2
- package/dist-lib/lib/core/files/rag/produce.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/produce.js +1 -3
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +1 -4
- package/dist-lib/lib/core/files/rag/similarity.d.ts +5 -0
- package/dist-lib/lib/core/files/rag/similarity.js +6 -0
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/inference-calls-handoff.d.ts +20 -0
- package/dist-lib/lib/core/inference-calls-handoff.js +37 -0
- package/dist-lib/lib/core/inference-calls-receiver.d.ts +14 -0
- package/dist-lib/lib/core/inference-calls-receiver.js +39 -0
- package/dist-lib/lib/core/notification.js +5 -4
- package/dist-lib/lib/core/skill-secrets.js +3 -6
- package/dist-lib/lib/core.d.ts +9 -1
- package/dist-lib/lib/core.js +129 -13
- package/dist-lib/lib/credential-pusher.d.ts +2 -3
- package/dist-lib/lib/credential-pusher.js +67 -39
- package/dist-lib/lib/inference-calls.d.ts +40 -0
- package/dist-lib/lib/inference-calls.js +266 -0
- package/dist-lib/lib/integrations/index.d.ts +1 -2
- package/dist-lib/lib/integrations/index.js +0 -1
- package/dist-lib/lib/integrations/setup-routes.js +0 -15
- package/dist-lib/lib/oauth/flow-core.js +1 -1
- package/dist-lib/lib/oauth/flow.d.ts +4 -2
- package/dist-lib/lib/oauth/flow.js +3 -4
- package/dist-lib/lib/oauth/host.d.ts +3 -1
- package/dist-lib/lib/oauth/host.js +3 -1
- package/dist-lib/lib/oauth/keys.d.ts +21 -20
- package/dist-lib/lib/oauth/keys.js +59 -85
- package/dist-lib/lib/oauth/loopback.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.js +32 -19
- package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.stub.js +2 -2
- package/dist-lib/lib/oauth/providers.d.ts +3 -5
- package/dist-lib/lib/oauth/providers.js +20 -67
- package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
- package/dist-lib/lib/oauth/registry.d.ts +10 -0
- package/dist-lib/lib/oauth/registry.js +25 -0
- package/dist-lib/lib/oauth/resolve.js +1 -1
- package/dist-lib/lib/oauth/token-exchange-core.js +2 -1
- package/dist-lib/lib/oauth/types.d.ts +1 -1
- package/dist-lib/lib/oauth.client.d.ts +3 -1
- package/dist-lib/lib/oauth.client.js +3 -1
- package/dist-lib/lib/oauth.d.ts +4 -7
- package/dist-lib/lib/oauth.js +4 -7
- package/dist-lib/lib/skill-types.d.ts +12 -0
- package/dist-lib/schema/content.js +5 -1
- package/dist-lib/schema/engine.js +63 -2
- package/dist-lib/schema/qvac.js +4 -2
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/capabilities.d.ts +2 -0
- package/dist-lib/spec/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +284 -52
- package/dist-lib/spec/hyperschema/index.js +284 -52
- package/dist-lib/spec/hyperschema/schema.json +210 -1
- package/dist-lib/spec/hyperschema/types.d.ts +51 -1
- package/dist-lib/spec/local/hyperdb/messages.js +64 -128
- package/dist-lib/spec/local/hyperschema/index.js +32 -64
- package/dist-lib/spec/local/hyperschema/schema.json +16 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +176 -311
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +132 -236
- package/dist-lib/spec/mesh/hyperschema/index.js +132 -236
- package/dist-lib/spec/mesh/hyperschema/schema.json +70 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +3 -1
- package/package.json +15 -18
- package/tui/app.mjs +98 -155
- package/tui/lib/knowledge-import.mjs +1 -1
- package/tui/lib/save-file.mjs +1 -1
- package/.claude/skills/asana/SKILL.md +0 -86
- package/.claude/skills/compaction/SKILL.md +0 -136
- package/.claude/skills/device-mesh-debug/SKILL.md +0 -328
- package/.claude/skills/gh-stack/SKILL.md +0 -181
- package/.claude/skills/gh-stack/references/commands.md +0 -177
- package/.claude/skills/gh-stack/references/stack-design.md +0 -97
- package/.claude/skills/gh-stack/references/troubleshooting.md +0 -159
- package/.claude/skills/js-house-style/SKILL.md +0 -671
- package/.claude/skills/pr-create/SKILL.md +0 -243
- package/.claude/skills/pr-review/SKILL.md +0 -428
- package/.claude/skills/release/SKILL.md +0 -122
- package/CLAUDE.md +0 -48
- package/dist-lib/lib/core/files/rag/artifact/codec.d.ts +0 -3
- package/dist-lib/lib/core/files/rag/artifact/codec.js +0 -172
- package/dist-lib/lib/core/files/rag/artifact/id.d.ts +0 -10
- package/dist-lib/lib/core/files/rag/artifact/id.js +0 -39
- package/dist-lib/lib/core/files/rag/artifact/types.d.ts +0 -24
- package/dist-lib/lib/core/files/rag/artifact/types.js +0 -41
- package/dist-lib/lib/core/files/rag/chunk/chunking.d.ts +0 -12
- package/dist-lib/lib/core/files/rag/chunk/chunking.js +0 -117
- package/dist-lib/lib/core/files/rag/chunk/metadata.d.ts +0 -30
- package/dist-lib/lib/core/files/rag/chunk/metadata.js +0 -89
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.d.ts +0 -7
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.js +0 -18
- package/dist-lib/lib/core/files/rag/extract/csv-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/csv-text.js +0 -117
- package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +0 -22
- package/dist-lib/lib/core/files/rag/extract/document-types.js +0 -152
- package/dist-lib/lib/core/files/rag/extract/extract.d.ts +0 -17
- package/dist-lib/lib/core/files/rag/extract/extract.js +0 -81
- package/dist-lib/lib/core/files/rag/extract/html-table-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/html-table-text.js +0 -125
- package/dist-lib/lib/core/files/rag/extract/html-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/html-text.js +0 -132
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.d.ts +0 -17
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +0 -141
- package/dist-lib/lib/core/files/rag/extract/pdf-text.d.ts +0 -12
- package/dist-lib/lib/core/files/rag/extract/pdf-text.js +0 -43
- package/dist-lib/lib/core/files/rag/extract/rtf-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/rtf-text.js +0 -15
- package/dist-lib/lib/core/files/rag/extract/text-decoding.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/text-decoding.js +0 -91
- package/dist-lib/lib/core/files/rag/extract/types.d.ts +0 -36
- package/dist-lib/lib/core/files/rag/extract/types.js +0 -12
- package/dist-lib/lib/core/files/rag/extract/utf.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/extract/utf.js +0 -18
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.js +0 -16
- package/dist-lib/lib/core/files/rag/retrieval/coverage.d.ts +0 -4
- package/dist-lib/lib/core/files/rag/retrieval/coverage.js +0 -48
- package/dist-lib/lib/core/files/rag/retrieval/diversity.d.ts +0 -10
- package/dist-lib/lib/core/files/rag/retrieval/diversity.js +0 -37
- package/dist-lib/lib/core/files/rag/retrieval/floor.d.ts +0 -5
- package/dist-lib/lib/core/files/rag/retrieval/floor.js +0 -21
- package/dist-lib/lib/core/files/rag/retrieval/format.d.ts +0 -6
- package/dist-lib/lib/core/files/rag/retrieval/format.js +0 -21
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +0 -54
- package/dist-lib/lib/core/files/rag/retrieval/notices.d.ts +0 -16
- package/dist-lib/lib/core/files/rag/retrieval/notices.js +0 -27
- package/dist-lib/lib/core/files/rag/retrieval/scoring.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/scoring.js +0 -82
- package/dist-lib/lib/core/files/rag/retrieval/search.d.ts +0 -3
- package/dist-lib/lib/core/files/rag/retrieval/search.js +0 -49
- package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +0 -11
- package/dist-lib/lib/core/files/rag/retrieval/selection.js +0 -93
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.d.ts +0 -6
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.js +0 -79
- package/dist-lib/lib/core/files/rag/retrieval/sources.d.ts +0 -13
- package/dist-lib/lib/core/files/rag/retrieval/sources.js +0 -20
- package/dist-lib/lib/core/files/rag/retrieval/target.d.ts +0 -13
- package/dist-lib/lib/core/files/rag/retrieval/target.js +0 -89
- package/dist-lib/lib/core/files/rag/retrieval/terms.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/terms.js +0 -70
- package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +0 -29
- package/dist-lib/lib/core/files/rag/retrieval/types.js +0 -1
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +0 -41
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.js +0 -96
- package/dist-lib/lib/core/files/rag/vector/memory.d.ts +0 -15
- package/dist-lib/lib/core/files/rag/vector/memory.js +0 -135
- package/dist-lib/lib/core/files/rag/vector/types.d.ts +0 -28
- package/dist-lib/lib/core/files/rag/vector/types.js +0 -1
- package/dist-lib/lib/integrations/oauth-providers.d.ts +0 -14
- package/dist-lib/lib/integrations/oauth-providers.js +0 -116
- package/dist-lib/lib/oauth/asana.d.ts +0 -35
- package/dist-lib/lib/oauth/asana.js +0 -71
- package/dist-lib/lib/oauth/google.d.ts +0 -37
- package/dist-lib/lib/oauth/google.js +0 -77
- package/dist-lib/lib/oauth/notion.d.ts +0 -34
- package/dist-lib/lib/oauth/notion.js +0 -82
- package/dist-lib/lib/oauth/spotify.d.ts +0 -32
- package/dist-lib/lib/oauth/spotify.js +0 -74
- package/dist-lib/lib/oauth/verify.d.ts +0 -8
- package/dist-lib/lib/oauth/verify.js +0 -58
|
@@ -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';
|
|
@@ -40,13 +42,14 @@ import { searchKnowledge } from './knowledge-search.js';
|
|
|
40
42
|
import { isLifecycleTeardown, knownAbortOutcome, RUN_ABORT_REASONS, RUN_FAILURE_REASONS, runFailureNotice } from './run-notices.js';
|
|
41
43
|
import { encodeAgentSkillReadiness } from './skill-readiness.js';
|
|
42
44
|
import { harnessClearKvCache, harnessDeathReason, harnessDeleteModel, harnessDied, harnessListModels, harnessSkillCatalog, harnessSkillManagement, harnessSpeak, harnessSpeakStream, harnessTools, harnessTranscribe, imageDownloadProgress, modelCatalogChanged, toolReportEntry } from './assistant/harness.js';
|
|
43
|
-
import { annotateUnreadableImages, audioTranscriptBlock, backfillDocumentOnlyTurn, backfillImageOnlyTurns, silentAudioNotice, unheardAudioNotice } from './assistant/message.js';
|
|
45
|
+
import { annotateUnreadableImages, audioTranscriptBlock, backfillDocumentOnlyTurn, backfillImageOnlyTurns, silentAudioNotice, unheardAudioNotice, nameSenders } from './assistant/message.js';
|
|
44
46
|
import { drainBody, raceInactivity } from './assistant/fetch-body.js';
|
|
45
|
-
import { GENERIC_ACKNOWLEDGEMENTS, HISTORY_TYPES, SKILL_TOOL, TERMINAL_STATES, historyFromChunks, inputAvailableToRun, listHistoryChunks, staleToolRunIds } from './assistant/history.js';
|
|
47
|
+
import { GENERIC_ACKNOWLEDGEMENTS, HISTORY_TYPES, SKILL_TOOL, TERMINAL_STATES, couldNameSenders, historyFromChunks, inputAvailableToRun, listHistoryChunks, senderAttribution, senderNamesFrom, staleToolRunIds } from './assistant/history.js';
|
|
46
48
|
export { harnessClearKvCache, harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessSkillManagement, harnessSpeak, harnessSpeakStream, harnessTools, harnessTranscribe } from './assistant/harness.js';
|
|
47
49
|
export {} from './assistant/skill-encode.js';
|
|
48
|
-
export { annotateUnreadableImages, unheardAudioNotice, unreadableImagesNotice, DOCUMENT_ONLY_USER_PROMPT, IMAGE_AND_DOCUMENT_USER_PROMPT, IMAGE_ONLY_USER_PROMPT } from './assistant/message.js';
|
|
49
|
-
export { historyFromChunks, listHistoryChunks, staleToolRunIds } from './assistant/history.js';
|
|
50
|
+
export { annotateUnreadableImages, unheardAudioNotice, unreadableImagesNotice, DOCUMENT_ONLY_USER_PROMPT, IMAGE_AND_DOCUMENT_USER_PROMPT, IMAGE_ONLY_USER_PROMPT, nameSenders } from './assistant/message.js';
|
|
51
|
+
export { couldNameSenders, historyFromChunks, listHistoryChunks, senderAttribution, senderNamesFrom, staleToolRunIds } from './assistant/history.js';
|
|
52
|
+
const NO_SENDERS = new Map();
|
|
50
53
|
const QvacState = local.getEnum('@local/qvac-state');
|
|
51
54
|
const FINAL_FLUSH_MS = 10_000;
|
|
52
55
|
const UPLOAD_FRAME_BYTES = 64 * 1024;
|
|
@@ -63,6 +66,10 @@ function isDeniedResult(result) {
|
|
|
63
66
|
return false;
|
|
64
67
|
return result.denied === true;
|
|
65
68
|
}
|
|
69
|
+
const TITLE_RUN_ID = 'chat-title';
|
|
70
|
+
export const CAPTURE_INFERENCE_CALLS_KEY = 'inspector.captureInferenceCalls';
|
|
71
|
+
export const CAPTURE_ON = 'on';
|
|
72
|
+
export const CAPTURE_OFF = 'off';
|
|
66
73
|
const BLOB_READ_TIMEOUT_MS = 15_000;
|
|
67
74
|
const SUSPENDED = RUN_ABORT_REASONS.suspended;
|
|
68
75
|
const OWNERSHIP_LOST = RUN_ABORT_REASONS.ownershipLost;
|
|
@@ -80,6 +87,11 @@ function withConfigDefaults(agent, config) {
|
|
|
80
87
|
return agent;
|
|
81
88
|
return { ...agent, ctxSize: config.ctxSize };
|
|
82
89
|
}
|
|
90
|
+
const RAG_SOURCE_BOUNDS = {
|
|
91
|
+
maxSources: MAX_RAG_SOURCES_PER_CHUNK,
|
|
92
|
+
excerptChars: RAG_SOURCE_EXCERPT_CHARS
|
|
93
|
+
};
|
|
94
|
+
const WEB_RAG_SOURCE_BOUNDS = { ...RAG_SOURCE_BOUNDS, maxUrlChars: MAX_RAG_SOURCE_URL_CHARS };
|
|
83
95
|
export class QvacAssistant extends ReadyResource {
|
|
84
96
|
_engine;
|
|
85
97
|
_harness;
|
|
@@ -123,15 +135,17 @@ export class QvacAssistant extends ReadyResource {
|
|
|
123
135
|
_runConsumers;
|
|
124
136
|
_runs;
|
|
125
137
|
_seen;
|
|
138
|
+
_inferenceCalls;
|
|
126
139
|
_lifecycle;
|
|
127
140
|
_audioTranscripts;
|
|
128
141
|
_chats;
|
|
129
142
|
_runImageCacheNames;
|
|
130
143
|
_reconciledCompactions;
|
|
144
|
+
_chatAttribution;
|
|
131
145
|
_modelCatalog = new ModelCatalogRevisionHub();
|
|
132
146
|
_onHarnessStatus;
|
|
133
147
|
_onModelCatalogEvent;
|
|
134
|
-
constructor(engine, harness, { logger = null, imageCacheDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform = os.platform(), preloadCurrentAgentModel = true, drives, borrowHarness, blobReadTimeoutMs = BLOB_READ_TIMEOUT_MS } = {}) {
|
|
148
|
+
constructor(engine, harness, { logger = null, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform = os.platform(), preloadCurrentAgentModel = true, drives, borrowHarness, blobReadTimeoutMs = BLOB_READ_TIMEOUT_MS } = {}) {
|
|
135
149
|
super();
|
|
136
150
|
this._engine = engine;
|
|
137
151
|
this._harness = harness;
|
|
@@ -167,11 +181,13 @@ export class QvacAssistant extends ReadyResource {
|
|
|
167
181
|
this._runConsumers = new Map();
|
|
168
182
|
this._runs = new Map();
|
|
169
183
|
this._seen = new Map();
|
|
184
|
+
this._inferenceCalls = new InferenceCallStore(inferenceCallsDir);
|
|
170
185
|
this._lifecycle = new AbortController();
|
|
171
186
|
this._audioTranscripts = new Map();
|
|
172
187
|
this._chats = new Map();
|
|
173
188
|
this._runImageCacheNames = new Map();
|
|
174
189
|
this._reconciledCompactions = new Map();
|
|
190
|
+
this._chatAttribution = new Map();
|
|
175
191
|
this._onHarnessStatus = (status) => {
|
|
176
192
|
this._log?.warn('assistant', 'harness status', status);
|
|
177
193
|
if (harnessDied(status)) {
|
|
@@ -275,6 +291,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
275
291
|
try {
|
|
276
292
|
await Promise.allSettled([
|
|
277
293
|
this._sweepImageCache(),
|
|
294
|
+
this._sweepInferenceCalls(),
|
|
278
295
|
this._reportCapabilities(),
|
|
279
296
|
this._reconcileDeviceProfile()
|
|
280
297
|
]);
|
|
@@ -335,6 +352,16 @@ export class QvacAssistant extends ReadyResource {
|
|
|
335
352
|
this._log?.warn('assistant', 'image cache sweep failed', err);
|
|
336
353
|
}
|
|
337
354
|
}
|
|
355
|
+
async _sweepInferenceCalls() {
|
|
356
|
+
try {
|
|
357
|
+
const { removed } = await this._inferenceCalls.sweep();
|
|
358
|
+
if (removed > 0)
|
|
359
|
+
this._log?.info('assistant', 'inspector records swept', { removed });
|
|
360
|
+
}
|
|
361
|
+
catch (err) {
|
|
362
|
+
this._log?.warn('assistant', 'inspector record sweep failed', err);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
338
365
|
_imageCacheInUse(name) {
|
|
339
366
|
for (const names of this._runImageCacheNames.values())
|
|
340
367
|
if (names.has(name))
|
|
@@ -369,6 +396,22 @@ export class QvacAssistant extends ReadyResource {
|
|
|
369
396
|
supportsImages: this._harness.supportsImages ?? false
|
|
370
397
|
});
|
|
371
398
|
}
|
|
399
|
+
async _capturingInferenceCalls() {
|
|
400
|
+
try {
|
|
401
|
+
const { value } = await this._engine.configGet({ key: CAPTURE_INFERENCE_CALLS_KEY });
|
|
402
|
+
return value === CAPTURE_ON;
|
|
403
|
+
}
|
|
404
|
+
catch (err) {
|
|
405
|
+
this._log?.warn('assistant', 'inspector capture flag unreadable', { err });
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
inferenceCalls(chatId) {
|
|
410
|
+
return this._inferenceCalls.list(chatId);
|
|
411
|
+
}
|
|
412
|
+
forgetInferenceCalls(chatId) {
|
|
413
|
+
return this._inferenceCalls.forget(chatId);
|
|
414
|
+
}
|
|
372
415
|
diagnosticsSlice() {
|
|
373
416
|
const harness = this._harness.diagnostics?.() ?? this._harnessDiagnostics;
|
|
374
417
|
void this._refreshHarnessDiagnostics();
|
|
@@ -683,11 +726,16 @@ export class QvacAssistant extends ReadyResource {
|
|
|
683
726
|
if (known !== null) {
|
|
684
727
|
for (const chatId of disappearedChatIds(known, ids)) {
|
|
685
728
|
this._reconciledCompactions.delete(chatId);
|
|
729
|
+
this._chatAttribution.delete(chatId);
|
|
686
730
|
void this._deleteChatKvCache(chatId, 'chat deleted');
|
|
731
|
+
void this._inferenceCalls
|
|
732
|
+
.forget(chatId)
|
|
733
|
+
.catch((err) => this._log?.warn('assistant', 'inspector records not dropped', { err }));
|
|
687
734
|
}
|
|
688
735
|
}
|
|
689
736
|
known = new Set(ids);
|
|
690
737
|
await this._sweepImageCache();
|
|
738
|
+
await this._sweepInferenceCalls();
|
|
691
739
|
}
|
|
692
740
|
}
|
|
693
741
|
async _watchAgents() {
|
|
@@ -740,6 +788,29 @@ export class QvacAssistant extends ReadyResource {
|
|
|
740
788
|
if (gone)
|
|
741
789
|
this._reconciledCompactions.set(chatId, newest.id);
|
|
742
790
|
}
|
|
791
|
+
async _senderNames(engine, chunks) {
|
|
792
|
+
if (!couldNameSenders(chunks))
|
|
793
|
+
return new Map();
|
|
794
|
+
const stamped = chunks.every((chunk) => chunk.type !== 'user-message' || chunk.senderMemberId);
|
|
795
|
+
const [{ members }, { devices }] = await Promise.all([
|
|
796
|
+
engine.listMembers({}).catch(() => ({ members: [] })),
|
|
797
|
+
stamped ? { devices: [] } : engine.listDevices({}).catch(() => ({ devices: [] }))
|
|
798
|
+
]);
|
|
799
|
+
return senderNamesFrom(chunks, members ?? [], devices ?? []);
|
|
800
|
+
}
|
|
801
|
+
async _reconcileAttribution(chatId, senders) {
|
|
802
|
+
const attribution = senderAttribution(senders);
|
|
803
|
+
const seen = this._chatAttribution.get(chatId);
|
|
804
|
+
if (seen === attribution)
|
|
805
|
+
return;
|
|
806
|
+
if (seen === undefined && !attribution) {
|
|
807
|
+
this._chatAttribution.set(chatId, attribution);
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
const gone = await this._deleteChatKvCache(chatId, 'sender attribution changed');
|
|
811
|
+
if (gone)
|
|
812
|
+
this._chatAttribution.set(chatId, attribution);
|
|
813
|
+
}
|
|
743
814
|
async deleteChatKvCache(chatId) {
|
|
744
815
|
return ((await this._harness.deleteKvCache?.(chatKvCacheKey(chatId))) ?? {
|
|
745
816
|
status: 'unsupported',
|
|
@@ -914,7 +985,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
914
985
|
settle.catch((err) => this._log?.error('assistant', `run ${runId} failed`, err));
|
|
915
986
|
}
|
|
916
987
|
async _citeWebSources(transcript, runId, result) {
|
|
917
|
-
const records = webSourcesFromToolResult(result);
|
|
988
|
+
const records = webSourcesFromToolResult(result, WEB_RAG_SOURCE_BOUNDS);
|
|
918
989
|
if (records.length === 0)
|
|
919
990
|
return;
|
|
920
991
|
try {
|
|
@@ -1038,7 +1109,12 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1038
1109
|
let ran = (priorResults ?? []).some((chunk) => chunk.runId === runId &&
|
|
1039
1110
|
chunk.toolResult?.name !== SKILL_TOOL &&
|
|
1040
1111
|
!isDeniedResult(chunk.toolResult?.result));
|
|
1041
|
-
const
|
|
1112
|
+
const named = couldNameSenders(history);
|
|
1113
|
+
const senders = named ? await this._senderNames(engine, history) : NO_SENDERS;
|
|
1114
|
+
if (named || this._chatAttribution.get(chatId)) {
|
|
1115
|
+
await this._reconcileAttribution(chatId, senders);
|
|
1116
|
+
}
|
|
1117
|
+
const messages = historyFromChunks(history, staleToolRunIds(history, priorAsks ?? [], runId), senders);
|
|
1042
1118
|
if (currentRepair)
|
|
1043
1119
|
messages.push({ role: 'user', content: currentRepair.promptText });
|
|
1044
1120
|
const diagramRepair = currentRepair !== undefined;
|
|
@@ -1133,6 +1209,8 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1133
1209
|
await transcript.flush();
|
|
1134
1210
|
};
|
|
1135
1211
|
let titleOutcome = null;
|
|
1212
|
+
let runFailure = null;
|
|
1213
|
+
let runVerdict = 'completed';
|
|
1136
1214
|
try {
|
|
1137
1215
|
const attachTurnIds = attachTurnDocumentIds(history);
|
|
1138
1216
|
if (attachTurnIds.length > 0)
|
|
@@ -1144,11 +1222,15 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1144
1222
|
if (controller.signal.aborted) {
|
|
1145
1223
|
const outcome = this._abortOutcome(runId, controller.signal.reason);
|
|
1146
1224
|
if (outcome.kind === 'replay') {
|
|
1225
|
+
runVerdict = 'replay';
|
|
1147
1226
|
this._seen.delete(runId);
|
|
1148
1227
|
return;
|
|
1149
1228
|
}
|
|
1150
|
-
if (outcome.kind === 'handoff')
|
|
1229
|
+
if (outcome.kind === 'handoff') {
|
|
1230
|
+
runVerdict = 'handoff';
|
|
1151
1231
|
return;
|
|
1232
|
+
}
|
|
1233
|
+
runFailure = outcome.reason;
|
|
1152
1234
|
await transcript.status({ state: 'failed', reason: outcome.reason, metrics });
|
|
1153
1235
|
return;
|
|
1154
1236
|
}
|
|
@@ -1174,7 +1256,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1174
1256
|
}
|
|
1175
1257
|
}
|
|
1176
1258
|
else {
|
|
1177
|
-
const records = sourcesFromHits(knowledge.hits);
|
|
1259
|
+
const records = sourcesFromHits(knowledge.hits, RAG_SOURCE_BOUNDS);
|
|
1178
1260
|
const notice = chooseRagNotice({
|
|
1179
1261
|
errorMessage: knowledge.search.errorMessage,
|
|
1180
1262
|
hitCount: records.length,
|
|
@@ -1264,7 +1346,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1264
1346
|
const events = this._harnessFor(runAgent).completion({
|
|
1265
1347
|
model,
|
|
1266
1348
|
agent: runAgent,
|
|
1267
|
-
messages,
|
|
1349
|
+
messages: nameSenders(messages),
|
|
1268
1350
|
cacheKey,
|
|
1269
1351
|
thinkingDefault: config ? (config.thinkingEnabled ? 'enabled' : 'disabled') : undefined,
|
|
1270
1352
|
toolConfigs,
|
|
@@ -1283,7 +1365,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1283
1365
|
limit: input.limit
|
|
1284
1366
|
}), controller.signal);
|
|
1285
1367
|
const hits = found.hits ?? [];
|
|
1286
|
-
const records = sourcesFromHits(hits);
|
|
1368
|
+
const records = sourcesFromHits(hits, RAG_SOURCE_BOUNDS);
|
|
1287
1369
|
if (records.length > 0) {
|
|
1288
1370
|
try {
|
|
1289
1371
|
sourceTagFilter.add(records.map((record) => record.title));
|
|
@@ -1311,6 +1393,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1311
1393
|
},
|
|
1312
1394
|
progress: (update) => modelWatch.image(update),
|
|
1313
1395
|
generationParams: diagramRepair ? { reasoning_budget: 0 } : undefined,
|
|
1396
|
+
captureInferenceCalls: await this._capturingInferenceCalls(),
|
|
1314
1397
|
signal: controller.signal
|
|
1315
1398
|
});
|
|
1316
1399
|
let harnessEvents = 0;
|
|
@@ -1334,6 +1417,25 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1334
1417
|
this._log?.info('runs', 'run metrics', { runId, ...runMetricsSummary(rest) });
|
|
1335
1418
|
continue;
|
|
1336
1419
|
}
|
|
1420
|
+
if (event.type === 'inference-sent') {
|
|
1421
|
+
void this._inferenceCalls
|
|
1422
|
+
.recordSent(chatId, {
|
|
1423
|
+
runId,
|
|
1424
|
+
round: Number(event.round ?? 0),
|
|
1425
|
+
messages: event.messages,
|
|
1426
|
+
tokens: event.tokens,
|
|
1427
|
+
outcome: event.outcome,
|
|
1428
|
+
reason: event.reason
|
|
1429
|
+
})
|
|
1430
|
+
.catch((err) => this._log?.warn('assistant', 'sent slice not recorded', { err }));
|
|
1431
|
+
continue;
|
|
1432
|
+
}
|
|
1433
|
+
if (event.type === 'inference-call') {
|
|
1434
|
+
void this._inferenceCalls
|
|
1435
|
+
.record(chatId, { runId, at: Date.now(), call: asRecord(event.call) })
|
|
1436
|
+
.catch((err) => this._log?.warn('assistant', 'inference call not recorded', { err }));
|
|
1437
|
+
continue;
|
|
1438
|
+
}
|
|
1337
1439
|
await flushTranscript();
|
|
1338
1440
|
if (event.type === 'error') {
|
|
1339
1441
|
const folded = isContextOverflowFailure(event.message) &&
|
|
@@ -1344,11 +1446,8 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1344
1446
|
signal: controller.signal,
|
|
1345
1447
|
meshId
|
|
1346
1448
|
}));
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
reason: runFailureNotice(event.message),
|
|
1350
|
-
metrics
|
|
1351
|
-
});
|
|
1449
|
+
runFailure = runFailureNotice(event.message);
|
|
1450
|
+
await transcript.status({ state: 'failed', reason: runFailure, metrics });
|
|
1352
1451
|
if (folded) {
|
|
1353
1452
|
await this._engine
|
|
1354
1453
|
.runAgent({ chatId, agentId: agent.id, parentRunId: runId })
|
|
@@ -1360,11 +1459,15 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1360
1459
|
if (event.type === 'aborted') {
|
|
1361
1460
|
const outcome = this._abortOutcome(runId, controller.signal.reason);
|
|
1362
1461
|
if (outcome.kind === 'replay') {
|
|
1462
|
+
runVerdict = 'replay';
|
|
1363
1463
|
this._seen.delete(runId);
|
|
1364
1464
|
return;
|
|
1365
1465
|
}
|
|
1366
|
-
if (outcome.kind === 'handoff')
|
|
1466
|
+
if (outcome.kind === 'handoff') {
|
|
1467
|
+
runVerdict = 'handoff';
|
|
1367
1468
|
return;
|
|
1469
|
+
}
|
|
1470
|
+
runFailure = outcome.reason;
|
|
1368
1471
|
await transcript.status({ state: 'failed', reason: outcome.reason, metrics });
|
|
1369
1472
|
titleOutcome = 'ended';
|
|
1370
1473
|
return;
|
|
@@ -1438,17 +1541,28 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1438
1541
|
? this._abortOutcome(runId, controller.signal.reason)
|
|
1439
1542
|
: null;
|
|
1440
1543
|
if (outcome?.kind === 'replay') {
|
|
1544
|
+
runVerdict = 'replay';
|
|
1441
1545
|
this._seen.delete(runId);
|
|
1442
1546
|
return;
|
|
1443
1547
|
}
|
|
1444
|
-
if (outcome?.kind === 'handoff')
|
|
1548
|
+
if (outcome?.kind === 'handoff') {
|
|
1549
|
+
runVerdict = 'handoff';
|
|
1445
1550
|
return;
|
|
1551
|
+
}
|
|
1446
1552
|
await flushTranscript();
|
|
1447
|
-
|
|
1448
|
-
|
|
1553
|
+
runFailure =
|
|
1554
|
+
(this._lenderFor(runAgent) ? loanFailureNotice(err) : null) ?? runFailureNotice(err);
|
|
1555
|
+
await transcript.status({ state: 'failed', reason: runFailure, metrics });
|
|
1449
1556
|
titleOutcome = 'ended';
|
|
1450
1557
|
}
|
|
1451
1558
|
finally {
|
|
1559
|
+
void this._inferenceCalls
|
|
1560
|
+
.recordOutcome(chatId, {
|
|
1561
|
+
runId,
|
|
1562
|
+
outcome: runFailure ? 'failed' : runVerdict,
|
|
1563
|
+
reason: runFailure
|
|
1564
|
+
})
|
|
1565
|
+
.catch((err) => this._log?.warn('assistant', 'run outcome not recorded', { err }));
|
|
1452
1566
|
transcript.close();
|
|
1453
1567
|
modelWatch.stop();
|
|
1454
1568
|
ownershipWatch.stop();
|
|
@@ -1772,6 +1886,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1772
1886
|
const userTurns = chunks.filter((chunk) => chunk.userMessage).length;
|
|
1773
1887
|
let announced = false;
|
|
1774
1888
|
let keepTurns = COMPACTION_KEEP_TURNS;
|
|
1889
|
+
const senders = await this._senderNames(engine, chunks);
|
|
1775
1890
|
for (;;) {
|
|
1776
1891
|
const boundary = compactionBoundary(chunks, keepTurns);
|
|
1777
1892
|
if (!boundary)
|
|
@@ -1782,7 +1897,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1782
1897
|
if (through.seq <= lastThroughSeq)
|
|
1783
1898
|
return { compacted: false, reason: 'already-compacted' };
|
|
1784
1899
|
const inRange = chunks.filter((chunk) => chunk.seq <= through.seq);
|
|
1785
|
-
const folded = historyFromChunks(inRange, staleToolRunIds(inRange, priorAsks ?? [], ''));
|
|
1900
|
+
const folded = historyFromChunks(inRange, staleToolRunIds(inRange, priorAsks ?? [], ''), senders);
|
|
1786
1901
|
if (!announced) {
|
|
1787
1902
|
await options.onFold?.();
|
|
1788
1903
|
announced = true;
|
|
@@ -1830,7 +1945,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1830
1945
|
messages: [
|
|
1831
1946
|
{
|
|
1832
1947
|
role: 'user',
|
|
1833
|
-
content: buildCompactionPrompt(turns.map((turn) => ({ role: turn.role, content: turn.content })), hasPriorSummary)
|
|
1948
|
+
content: buildCompactionPrompt(nameSenders(turns).map((turn) => ({ role: turn.role, content: turn.content })), hasPriorSummary)
|
|
1834
1949
|
}
|
|
1835
1950
|
],
|
|
1836
1951
|
generationParams: { reasoning_budget: 0 },
|
|
@@ -1881,6 +1996,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1881
1996
|
if (probe && !this.closing) {
|
|
1882
1997
|
try {
|
|
1883
1998
|
generated = await this._titleFromCompletion({
|
|
1999
|
+
chatId,
|
|
1884
2000
|
input: prompt,
|
|
1885
2001
|
model,
|
|
1886
2002
|
agent,
|
|
@@ -1903,7 +2019,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1903
2019
|
return title;
|
|
1904
2020
|
}
|
|
1905
2021
|
async _titleFromCompletion(params) {
|
|
1906
|
-
const { input, model, agent, signal } = params;
|
|
2022
|
+
const { chatId, input, model, agent, signal } = params;
|
|
1907
2023
|
const events = this._harnessFor(agent).completion({
|
|
1908
2024
|
model,
|
|
1909
2025
|
agent: {
|
|
@@ -1915,6 +2031,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1915
2031
|
},
|
|
1916
2032
|
messages: [{ role: 'user', content: buildTitlePrompt(input) }],
|
|
1917
2033
|
generationParams: { reasoning_budget: 0 },
|
|
2034
|
+
captureInferenceCalls: await this._capturingInferenceCalls(),
|
|
1918
2035
|
responseFormat: {
|
|
1919
2036
|
type: 'json_schema',
|
|
1920
2037
|
json_schema: {
|
|
@@ -1933,6 +2050,11 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1933
2050
|
for await (const event of events) {
|
|
1934
2051
|
if (event.type === 'content' && typeof event.text === 'string')
|
|
1935
2052
|
text += event.text;
|
|
2053
|
+
else if (event.type === 'inference-call') {
|
|
2054
|
+
void this._inferenceCalls
|
|
2055
|
+
.record(chatId, { runId: TITLE_RUN_ID, at: Date.now(), call: asRecord(event.call) })
|
|
2056
|
+
.catch((err) => this._log?.warn('assistant', 'title call not recorded', { err }));
|
|
2057
|
+
}
|
|
1936
2058
|
else if (event.type === 'error' || event.type === 'aborted' || event.type === 'done')
|
|
1937
2059
|
break;
|
|
1938
2060
|
}
|
|
@@ -2270,6 +2392,9 @@ function runMetricsSummary(metrics) {
|
|
|
2270
2392
|
stopReason
|
|
2271
2393
|
};
|
|
2272
2394
|
}
|
|
2395
|
+
function asRecord(value) {
|
|
2396
|
+
return typeof value === 'object' && value !== null ? { ...value } : {};
|
|
2397
|
+
}
|
|
2273
2398
|
function isStreamDestroyed(err) {
|
|
2274
2399
|
return typeof err === 'object' && err !== null && 'code' in err && err.code === 'STREAM_DESTROYED';
|
|
2275
2400
|
}
|
|
@@ -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;
|
|
@@ -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
|
|
4
|
-
import type { VectorIndex } from './vector/types.ts';
|
|
3
|
+
import { type RagExtractors, type VectorIndex } from 'rag-extract';
|
|
5
4
|
import { type IndexingEmbedder } from './produce.ts';
|
|
6
5
|
import type { Mesh } from '../../mesh.ts';
|
|
7
6
|
import type { FileDocument, FileProcessor } from '../processing/index.ts';
|
|
@@ -27,28 +26,9 @@ export declare class RagProcessor implements FileProcessor {
|
|
|
27
26
|
produce(document: FileDocument, signal: AbortSignal): Promise<void>;
|
|
28
27
|
close(): Promise<boolean>;
|
|
29
28
|
}
|
|
30
|
-
export { encodeRagArtifact } from './artifact/codec.ts';
|
|
31
|
-
export type { RagArtifactPayload } from './artifact/types.ts';
|
|
32
|
-
export { isSupportedRagDocument } from './extract/document-types.ts';
|
|
33
|
-
export type { RagExtractors } from './extract/extract.ts';
|
|
34
29
|
export { MAX_KNOWLEDGE_BYTES } from './limits.ts';
|
|
35
30
|
export { canIndexChat } from './policy.ts';
|
|
36
31
|
export type { IndexingEmbedder, IndexingProgress } from './produce.ts';
|
|
37
|
-
export {
|
|
38
|
-
export { formatRagContext } from '
|
|
39
|
-
export {
|
|
40
|
-
export { RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, chooseRagNotice } from './retrieval/notices.ts';
|
|
41
|
-
export { createRagSourceTagFilter } from './retrieval/source-tag-filter.ts';
|
|
42
|
-
export { sourcesFromHits } from './retrieval/sources.ts';
|
|
43
|
-
export type { RagSource } from './retrieval/sources.ts';
|
|
44
|
-
export { WEB_TOOLS, webSourcesFromToolResult, withoutDataChannel } from './retrieval/web-sources.ts';
|
|
45
|
-
export { MemoryVectorIndex } from './vector/memory.ts';
|
|
46
|
-
export type { VectorIndex } from './vector/types.ts';
|
|
47
|
-
export { fullTextBudgetChars, fullTextHits } from './retrieval/full-text.ts';
|
|
48
|
-
export { retrieveRagKnowledge } from './retrieval/knowledge.ts';
|
|
49
|
-
export { searchRagChunks } from './retrieval/search.ts';
|
|
50
|
-
export { referencesPendingFile } from './retrieval/target.ts';
|
|
51
|
-
export type { RagDocumentRef } from './retrieval/target.ts';
|
|
52
|
-
export type { VectorHit } from './vector/types.ts';
|
|
53
|
-
export { isWholeDocumentQuery } from './retrieval/whole-document-query.ts';
|
|
54
|
-
export { referencedDocuments } from './retrieval/target.ts';
|
|
32
|
+
export { formatFullDocumentContext, fullTextBudgetChars, fullTextHits, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.ts';
|
|
33
|
+
export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, encodeRagArtifact, formatRagContext, isSupportedRagDocument, isWholeDocumentQuery, referencedDocuments, referencesPendingFile, retrieveRagKnowledge, searchRagChunks, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from 'rag-extract';
|
|
34
|
+
export type { RagArtifactPayload, RagDocumentRef, RagExtractors, RagSource, VectorHit, VectorIndex } from 'rag-extract';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ScopeLock from 'scope-lock';
|
|
2
|
-
import { pipelineVersionFor } from '
|
|
2
|
+
import { pipelineVersionFor } from 'rag-extract';
|
|
3
3
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
4
4
|
import { IndexingPass } from './produce.js';
|
|
5
5
|
import { HydratePass } from './load.js';
|
|
@@ -59,21 +59,7 @@ export class RagProcessor {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
export { encodeRagArtifact } from './artifact/codec.js';
|
|
63
|
-
export { isSupportedRagDocument } from './extract/document-types.js';
|
|
64
62
|
export { MAX_KNOWLEDGE_BYTES } from './limits.js';
|
|
65
63
|
export { canIndexChat } from './policy.js';
|
|
66
|
-
export {
|
|
67
|
-
export { formatRagContext } from '
|
|
68
|
-
export { formatFullDocumentContext, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.js';
|
|
69
|
-
export { RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, chooseRagNotice } from './retrieval/notices.js';
|
|
70
|
-
export { createRagSourceTagFilter } from './retrieval/source-tag-filter.js';
|
|
71
|
-
export { sourcesFromHits } from './retrieval/sources.js';
|
|
72
|
-
export { WEB_TOOLS, webSourcesFromToolResult, withoutDataChannel } from './retrieval/web-sources.js';
|
|
73
|
-
export { MemoryVectorIndex } from './vector/memory.js';
|
|
74
|
-
export { fullTextBudgetChars, fullTextHits } from './retrieval/full-text.js';
|
|
75
|
-
export { retrieveRagKnowledge } from './retrieval/knowledge.js';
|
|
76
|
-
export { searchRagChunks } from './retrieval/search.js';
|
|
77
|
-
export { referencesPendingFile } from './retrieval/target.js';
|
|
78
|
-
export { isWholeDocumentQuery } from './retrieval/whole-document-query.js';
|
|
79
|
-
export { referencedDocuments } from './retrieval/target.js';
|
|
64
|
+
export { formatFullDocumentContext, fullTextBudgetChars, fullTextHits, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.js';
|
|
65
|
+
export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, encodeRagArtifact, formatRagContext, isSupportedRagDocument, isWholeDocumentQuery, referencedDocuments, referencesPendingFile, retrieveRagKnowledge, searchRagChunks, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from 'rag-extract';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { QvacKnowledgeArtifact } from '../../../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
-
import type
|
|
2
|
+
import { type RagExtractors, type VectorIndex } from 'rag-extract';
|
|
3
3
|
import type { FileDocument } from '../processing/index.ts';
|
|
4
4
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
5
5
|
import { type BuildEmbedder } from './build.ts';
|
|
6
|
-
import type { RagExtractors } from './extract/extract.ts';
|
|
7
6
|
export type HydratePassOptions = {
|
|
8
7
|
model: string;
|
|
9
8
|
index: VectorIndex;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { decodeRagArtifact } from '
|
|
2
|
-
import { pipelineVersionFor, contentHash } from './artifact/id.js';
|
|
1
|
+
import { contentHash, decodeRagArtifact, pipelineVersionFor } from 'rag-extract';
|
|
3
2
|
import { compareBlobReferences } from '../store/index.js';
|
|
4
3
|
import { buildArtifactPayload, EmbedderFailure } from './build.js';
|
|
5
4
|
import { EMBED_RETRY_LIMIT } from './produce.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
|
-
import type
|
|
2
|
+
import { type RagExtractors } from 'rag-extract';
|
|
3
3
|
import { type BuildEmbedder } from './build.ts';
|
|
4
4
|
import { type FileDocument } from '../processing/index.ts';
|
|
5
5
|
export interface IndexingEmbedder extends BuildEmbedder {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { encodeRagArtifact } from '
|
|
2
|
-
import { contentHash, documentIndexArtifactId, pipelineVersionFor } from './artifact/id.js';
|
|
3
|
-
import { classifyRagDocument, RAG_DOCUMENT_KIND } from './extract/document-types.js';
|
|
1
|
+
import { classifyRagDocument, contentHash, documentIndexArtifactId, encodeRagArtifact, pipelineVersionFor, RAG_DOCUMENT_KIND } from 'rag-extract';
|
|
4
2
|
import { buildArtifactPayload, EmbedderFailure } from './build.js';
|
|
5
3
|
import { isClaimLive } from '../processing/index.js';
|
|
6
4
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QvacKnowledge } from '../../../../../spec/mesh/hyperschema/types.d.ts';
|
|
2
2
|
import type { Mesh } from '../../../mesh.ts';
|
|
3
|
-
import type
|
|
3
|
+
import { type VectorHit } from 'rag-extract';
|
|
4
4
|
export declare function fullTextBudgetChars(ctxSize: number): number;
|
|
5
5
|
export declare function isFullTextHit(hit: {
|
|
6
6
|
readonly id: string;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { parseRagMetadata } from '
|
|
2
|
-
import { classifyRagDocument, RAG_DOCUMENT_KIND } from '../extract/document-types.js';
|
|
3
|
-
import { extractRagDocumentFromBytes } from '../extract/extract.js';
|
|
4
|
-
import { extractPdfHead } from '../extract/pdf-text.js';
|
|
1
|
+
import { classifyRagDocument, extractPdfHead, extractRagDocumentFromBytes, parseRagMetadata, RAG_DOCUMENT_KIND } from 'rag-extract';
|
|
5
2
|
const DEFAULT_FULL_TEXT_BUDGET_TOKENS = 4096;
|
|
6
3
|
const CHARS_PER_TOKEN = 4;
|
|
7
4
|
const FULL_TEXT_KINDS = new Set([
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import '../../../logger.ts';
|
|
2
|
+
import { applySimilarityFloor, RAG_MIN_SIMILARITY } from 'rag-extract/retrieval';
|
|
3
|
+
import type { VectorHit } from 'rag-extract/vector';
|
|
4
|
+
export { applySimilarityFloor, RAG_MIN_SIMILARITY };
|
|
5
|
+
export declare function logSimilarityScores(candidates: ReadonlyArray<VectorHit>, kept: ReadonlyArray<VectorHit>): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '../../../logger.js';
|
|
2
|
+
import { applySimilarityFloor, logSimilarityScores as traceSimilarityScores, RAG_MIN_SIMILARITY } from 'rag-extract/retrieval';
|
|
3
|
+
export { applySimilarityFloor, RAG_MIN_SIMILARITY };
|
|
4
|
+
export function logSimilarityScores(candidates, kept) {
|
|
5
|
+
traceSimilarityScores(candidates, kept, (message) => logger.debug('rag', message));
|
|
6
|
+
}
|
|
@@ -7,8 +7,8 @@ export declare function uploadFile(mesh: Mesh, frames: AsyncIterable<AssistantUp
|
|
|
7
7
|
deviceId?: Buffer | null;
|
|
8
8
|
inactivityMs?: number;
|
|
9
9
|
}): AsyncGenerator<{
|
|
10
|
-
attachment?: undefined;
|
|
11
10
|
bytesWritten: number;
|
|
11
|
+
attachment?: undefined;
|
|
12
12
|
knowledge?: undefined;
|
|
13
13
|
} | {
|
|
14
14
|
bytesWritten: number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE, type HandoffStream } from './handoff-channel.ts';
|
|
2
|
+
import type { AssistantInferenceCallEntry, AssistantInferenceCallsRequest } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
+
export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE, type HandoffStream };
|
|
4
|
+
export type InferenceCallsRequest = AssistantInferenceCallsRequest;
|
|
5
|
+
export interface InferenceCallsAnswer {
|
|
6
|
+
readonly calls: ReadonlyArray<AssistantInferenceCallEntry>;
|
|
7
|
+
readonly truncated: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type InferenceCallsHandler = (request: InferenceCallsRequest, fromDeviceId: Uint8Array) => Promise<InferenceCallsAnswer>;
|
|
10
|
+
export interface InferenceCallsHandoffOptions {
|
|
11
|
+
readonly onrequest: InferenceCallsHandler;
|
|
12
|
+
readonly ackTimeoutMs?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class InferenceCallsHandoff {
|
|
15
|
+
private readonly _channel;
|
|
16
|
+
constructor(opts: InferenceCallsHandoffOptions);
|
|
17
|
+
addStream(stream: HandoffStream): void;
|
|
18
|
+
send(hostDeviceId: Uint8Array, request: InferenceCallsRequest): Promise<InferenceCallsAnswer>;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|