@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,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
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getStruct } from '../../spec/hyperschema/index.js';
|
|
2
|
+
import { ACK_TIMEOUT_MS, HandoffChannel, HOST_SILENT, HOST_UNREACHABLE } from './handoff-channel.js';
|
|
3
|
+
const PROTOCOL = 'qvac/inference-calls-handoff';
|
|
4
|
+
export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE };
|
|
5
|
+
const handoff = getStruct('@assistant/inference-calls-handoff');
|
|
6
|
+
const handoffAck = getStruct('@assistant/inference-calls-handoff-ack');
|
|
7
|
+
export class InferenceCallsHandoff {
|
|
8
|
+
_channel;
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this._channel = new HandoffChannel({
|
|
11
|
+
protocol: PROTOCOL,
|
|
12
|
+
requestEncoding: handoff,
|
|
13
|
+
ackEncoding: handoffAck,
|
|
14
|
+
onrequest: opts.onrequest,
|
|
15
|
+
buildAck: (id, error, result) => ({
|
|
16
|
+
id,
|
|
17
|
+
error,
|
|
18
|
+
calls: result ? [...result.calls] : undefined,
|
|
19
|
+
truncated: result?.truncated
|
|
20
|
+
}),
|
|
21
|
+
readAck: (ack) => ({
|
|
22
|
+
error: ack.error ?? '',
|
|
23
|
+
result: { calls: ack.calls ?? [], truncated: ack.truncated ?? false }
|
|
24
|
+
}),
|
|
25
|
+
ackTimeoutMs: opts.ackTimeoutMs
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
addStream(stream) {
|
|
29
|
+
this._channel.addStream(stream);
|
|
30
|
+
}
|
|
31
|
+
send(hostDeviceId, request) {
|
|
32
|
+
return this._channel.send(hostDeviceId, request);
|
|
33
|
+
}
|
|
34
|
+
destroy() {
|
|
35
|
+
this._channel.destroy();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Mesh } from './mesh.ts';
|
|
2
|
+
import type { InferenceCallsHandler } from './inference-calls-handoff.ts';
|
|
3
|
+
import type { AssistantInferenceCallEntry } from '../../spec/hyperschema/types.d.ts';
|
|
4
|
+
export declare const NO_SUCH_CHAT = "no such chat on the device hosting this agent";
|
|
5
|
+
export declare const NO_RECORD_STORE = "the device hosting this agent is not recording prompts right now";
|
|
6
|
+
export interface InferenceCallsReceiverOptions {
|
|
7
|
+
readonly mesh: Mesh;
|
|
8
|
+
readonly deviceId: Uint8Array;
|
|
9
|
+
readonly listLocal: (chatId: string) => {
|
|
10
|
+
calls: ReadonlyArray<AssistantInferenceCallEntry>;
|
|
11
|
+
truncated: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function createInferenceCallsReceiver(opts: InferenceCallsReceiverOptions): InferenceCallsHandler;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { getAgent } from './agent.js';
|
|
3
|
+
import { getChat } from './chat.js';
|
|
4
|
+
import { NO_SUCH_AGENT, NOT_THE_HOST, SENDER_REVOKED } from './skill-secrets.js';
|
|
5
|
+
const DEVICES = '@qvac/devices';
|
|
6
|
+
export const NO_SUCH_CHAT = 'no such chat on the device hosting this agent';
|
|
7
|
+
export const NO_RECORD_STORE = 'the device hosting this agent is not recording prompts right now';
|
|
8
|
+
const MAX_ANSWER_BYTES = 2 * 1024 * 1024;
|
|
9
|
+
export function createInferenceCallsReceiver(opts) {
|
|
10
|
+
return async (request, fromDeviceId) => {
|
|
11
|
+
const sender = await opts.mesh.view.get(DEVICES, { id: fromDeviceId });
|
|
12
|
+
if (!sender || sender.revoked)
|
|
13
|
+
throw new Error(SENDER_REVOKED);
|
|
14
|
+
const chat = await getChat(opts.mesh, request.chatId);
|
|
15
|
+
if (!chat)
|
|
16
|
+
throw new Error(NO_SUCH_CHAT);
|
|
17
|
+
const agent = await getAgent(opts.mesh, chat.agentId);
|
|
18
|
+
if (!agent)
|
|
19
|
+
throw new Error(NO_SUCH_AGENT);
|
|
20
|
+
if (!agent.providerDeviceId || !b4a.equals(agent.providerDeviceId, opts.deviceId)) {
|
|
21
|
+
throw new Error(NOT_THE_HOST);
|
|
22
|
+
}
|
|
23
|
+
const own = opts.listLocal(request.chatId);
|
|
24
|
+
const answer = capped(own.calls);
|
|
25
|
+
return { ...answer, truncated: answer.truncated || own.truncated };
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function capped(calls) {
|
|
29
|
+
const kept = [];
|
|
30
|
+
let bytes = 0;
|
|
31
|
+
for (const entry of [...calls].reverse()) {
|
|
32
|
+
bytes += b4a.byteLength(JSON.stringify(entry.call));
|
|
33
|
+
if (bytes > MAX_ANSWER_BYTES && kept.length > 0) {
|
|
34
|
+
return { calls: kept.reverse(), truncated: true };
|
|
35
|
+
}
|
|
36
|
+
kept.push(entry);
|
|
37
|
+
}
|
|
38
|
+
return { calls: kept.reverse(), truncated: false };
|
|
39
|
+
}
|
|
@@ -35,10 +35,11 @@ export async function deriveNotifications(mesh, local, requestedLimit, deviceId)
|
|
|
35
35
|
if (isDiagramRepairPrompt(text))
|
|
36
36
|
continue;
|
|
37
37
|
const sender = await snap.get('@qvac/devices', { id: chunk.originDeviceId });
|
|
38
|
-
|
|
38
|
+
const senderMemberId = chunk.senderMemberId ?? sender?.memberId;
|
|
39
|
+
if (own?.memberId && senderMemberId?.equals(own.memberId))
|
|
39
40
|
continue;
|
|
40
|
-
const member =
|
|
41
|
-
? await snap.get('@qvac/members', { id:
|
|
41
|
+
const member = senderMemberId
|
|
42
|
+
? await snap.get('@qvac/members', { id: senderMemberId })
|
|
42
43
|
: null;
|
|
43
44
|
candidates.push({
|
|
44
45
|
chatId: chat.id,
|
|
@@ -48,7 +49,7 @@ export async function deriveNotifications(mesh, local, requestedLimit, deviceId)
|
|
|
48
49
|
seq: chunk.seq,
|
|
49
50
|
createdAt: chunk.createdAt,
|
|
50
51
|
senderDeviceId: chunk.originDeviceId,
|
|
51
|
-
senderMemberId
|
|
52
|
+
senderMemberId,
|
|
52
53
|
senderName: member?.name ?? sender?.name,
|
|
53
54
|
chatTitle: chat.title,
|
|
54
55
|
preview: Array.from(text).slice(0, PREVIEW_LIMIT).join('') || undefined
|
package/dist-lib/lib/core.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import ReadyGuard from 'ready-guard';
|
|
|
5
5
|
import ReadyResource from 'ready-resource';
|
|
6
6
|
import type { Logger } from '../index.ts';
|
|
7
7
|
import type { AssistantArchivedMeshList, AssistantCompactChatResponse, AssistantCopySkillResponse, AssistantDeleteModelRequest, AssistantDeleteModelResponse, AssistantDeleteSkillResponse, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantManagedSkillsResponse, AssistantMeshList, AssistantModelCatalogRevision, AssistantModelInfoList, AssistantOkResponse, AssistantSkillCatalogResponse, AssistantSkillFileResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantTranscribeRequest, AssistantTranscribeResponse } from '../spec/index.d.ts';
|
|
8
|
+
import type { InferenceCallSource } from './api/inference-calls.ts';
|
|
8
9
|
import { type BlindPeeringOpts } from './core/blind-peers.ts';
|
|
9
10
|
import { type IndexingEmbedder, type RagExtractors, type VectorIndex } from './core/files/index.ts';
|
|
10
11
|
import { type DriveHost } from './core/fs-drives.ts';
|
|
@@ -165,6 +166,7 @@ export declare class Core extends ReadyResource {
|
|
|
165
166
|
private readonly _following;
|
|
166
167
|
private readonly _secretHandoff;
|
|
167
168
|
private readonly _skillOverlayHandoff;
|
|
169
|
+
private readonly _inferenceCallsHandoff;
|
|
168
170
|
private _minting;
|
|
169
171
|
private _leaving;
|
|
170
172
|
private _kicked;
|
|
@@ -172,6 +174,7 @@ export declare class Core extends ReadyResource {
|
|
|
172
174
|
private readonly _peers;
|
|
173
175
|
private readonly _statusListeners;
|
|
174
176
|
private readonly _diagnosticsProviders;
|
|
177
|
+
private _inferenceCalls;
|
|
175
178
|
private _systemInfo;
|
|
176
179
|
private _statusError;
|
|
177
180
|
private _upgradeRequired;
|
|
@@ -351,7 +354,10 @@ export declare class Core extends ReadyResource {
|
|
|
351
354
|
private _isJoinedRoomKey;
|
|
352
355
|
private _isOwnMemberDevice;
|
|
353
356
|
private _skillOverlayOp;
|
|
354
|
-
private
|
|
357
|
+
private _resolveAgentHost;
|
|
358
|
+
private _listInferenceCalls;
|
|
359
|
+
private _toInferenceEntry;
|
|
360
|
+
private _serveInferenceCalls;
|
|
355
361
|
private _serveSkillOverlayOp;
|
|
356
362
|
private _runLocalSkillOverlayOp;
|
|
357
363
|
private _setupFields;
|
|
@@ -367,6 +373,7 @@ export declare class Core extends ReadyResource {
|
|
|
367
373
|
private _logSource;
|
|
368
374
|
compact(force?: boolean): Promise<void>;
|
|
369
375
|
registerDiagnostics(provider: () => object): () => void;
|
|
376
|
+
registerInferenceCalls(source: InferenceCallSource): () => void;
|
|
370
377
|
registerListModels(hook: (options: AssistantListModelsRequest) => Promise<AssistantModelInfoList>): () => void;
|
|
371
378
|
registerDeleteModel(hook: (options: AssistantDeleteModelRequest) => Promise<AssistantDeleteModelResponse>): () => void;
|
|
372
379
|
registerClearKvCache(hook: () => Promise<AssistantKvCacheDeletionResponse>): () => void;
|
package/dist-lib/lib/core.js
CHANGED
|
@@ -14,7 +14,7 @@ import { createApi } from './api/index.js';
|
|
|
14
14
|
import { NO_SUCH_MESH } from './api/current-mesh.js';
|
|
15
15
|
import { BLIND_PEER_KEYS, BLIND_RELAY_KEYS } from './core/blind-peers.js';
|
|
16
16
|
import { CoreBlobServer, parseBlobReferenceCoreKey, MemoryVectorIndex } from './core/files/index.js';
|
|
17
|
-
import { removeChatAttachments, removeChatKnowledge } from './core/chat.js';
|
|
17
|
+
import { getChat, removeChatAttachments, removeChatKnowledge } from './core/chat.js';
|
|
18
18
|
import { createFsDriveHost } from './core/fs-drives.js';
|
|
19
19
|
import { sweepDriveStaging } from './fs-drive-bridge.js';
|
|
20
20
|
import { closeCollaboraWorker } from './collabora/worker.js';
|
|
@@ -27,6 +27,8 @@ import { HarnessLoan } from './core/harness-loan.js';
|
|
|
27
27
|
import { duplexPair } from '@qvac/harness/transport';
|
|
28
28
|
import { MeshSeedHandoff } from './core/mesh-seed-handoff.js';
|
|
29
29
|
import { SecretHandoff } from './core/secret-handoff.js';
|
|
30
|
+
import { InferenceCallsHandoff } from './core/inference-calls-handoff.js';
|
|
31
|
+
import { createInferenceCallsReceiver, NO_RECORD_STORE } from './core/inference-calls-receiver.js';
|
|
30
32
|
import { SkillOverlayHandoff } from './core/skill-overlay-handoff.js';
|
|
31
33
|
import { createSkillOverlayReceiver } from './core/skill-overlay-receiver.js';
|
|
32
34
|
import { createSkillSecretReceiver, HOST_REVOKED, NO_SUCH_AGENT, NOT_THE_HOST } from './core/skill-secrets.js';
|
|
@@ -156,6 +158,7 @@ export class Core extends ReadyResource {
|
|
|
156
158
|
_following = new Set();
|
|
157
159
|
_secretHandoff;
|
|
158
160
|
_skillOverlayHandoff;
|
|
161
|
+
_inferenceCallsHandoff;
|
|
159
162
|
_minting;
|
|
160
163
|
_leaving;
|
|
161
164
|
_kicked;
|
|
@@ -163,6 +166,7 @@ export class Core extends ReadyResource {
|
|
|
163
166
|
_peers;
|
|
164
167
|
_statusListeners;
|
|
165
168
|
_diagnosticsProviders;
|
|
169
|
+
_inferenceCalls = null;
|
|
166
170
|
_systemInfo;
|
|
167
171
|
_statusError;
|
|
168
172
|
_upgradeRequired;
|
|
@@ -261,6 +265,9 @@ export class Core extends ReadyResource {
|
|
|
261
265
|
onrequest: (request, from) => this._serveMeshSeed(request, from)
|
|
262
266
|
});
|
|
263
267
|
this._harnessLoan = new HarnessLoan({ onborrow: (from) => this._lendHarness(from) });
|
|
268
|
+
this._inferenceCallsHandoff = new InferenceCallsHandoff({
|
|
269
|
+
onrequest: (request, from) => this._serveInferenceCalls(request, from)
|
|
270
|
+
});
|
|
264
271
|
this._minting = false;
|
|
265
272
|
this._leaving = false;
|
|
266
273
|
this._kicked = false;
|
|
@@ -336,6 +343,10 @@ export class Core extends ReadyResource {
|
|
|
336
343
|
meshStatus,
|
|
337
344
|
network: this._networkStatusSource(),
|
|
338
345
|
diagnostics: this._diagnosticsSource(),
|
|
346
|
+
inferenceCalls: {
|
|
347
|
+
list: (chatId) => this._listInferenceCalls(chatId),
|
|
348
|
+
forget: async (chatId) => void (await this._inferenceCalls?.forget(chatId))
|
|
349
|
+
},
|
|
339
350
|
logs: this._logSource(),
|
|
340
351
|
deviceId: this.devicePublicKey,
|
|
341
352
|
lifecycle: this._apiLifecycle,
|
|
@@ -1071,8 +1082,9 @@ export class Core extends ReadyResource {
|
|
|
1071
1082
|
const attestation = claimAttestation(mesh.publicKey, deviceId, mesh.localWriterKey);
|
|
1072
1083
|
const known = await this._knownMember(mesh);
|
|
1073
1084
|
if (known) {
|
|
1085
|
+
const displayName = (await this.local.readIdentity())?.displayName;
|
|
1074
1086
|
return {
|
|
1075
|
-
member: { id: known.id, name: known.name, joinedAt: now, updatedAt: now },
|
|
1087
|
+
member: { id: known.id, name: displayName ?? known.name, joinedAt: now, updatedAt: now },
|
|
1076
1088
|
proof: await attestMemberClaim(attestation, this._deviceKeyPair, known.proof)
|
|
1077
1089
|
};
|
|
1078
1090
|
}
|
|
@@ -1964,6 +1976,9 @@ export class Core extends ReadyResource {
|
|
|
1964
1976
|
.catch((error) => this._log?.warn(['p2p', 'mesh'], 'chat-tombstone notification reclaim failed', error));
|
|
1965
1977
|
void removeChatAttachments(mesh, deviceId, chatId, deletedAt).catch((error) => this._log?.warn(['p2p', 'mesh'], 'chat-tombstone attachment reclaim failed', error));
|
|
1966
1978
|
void removeChatKnowledge(mesh, chatId, deletedAt).catch((error) => this._log?.warn(['p2p', 'mesh'], 'chat-tombstone knowledge reclaim failed', error));
|
|
1979
|
+
void this._inferenceCalls
|
|
1980
|
+
?.forget(chatId)
|
|
1981
|
+
.catch((error) => this._log?.warn(['p2p', 'mesh'], 'chat-tombstone inspector reclaim failed', error));
|
|
1967
1982
|
});
|
|
1968
1983
|
const sweepLock = new ScopeLock({ debounce: true });
|
|
1969
1984
|
const sweep = async () => {
|
|
@@ -2569,6 +2584,7 @@ export class Core extends ReadyResource {
|
|
|
2569
2584
|
this._harnessLoan.destroy();
|
|
2570
2585
|
this._secretHandoff.destroy();
|
|
2571
2586
|
this._skillOverlayHandoff.destroy();
|
|
2587
|
+
this._inferenceCallsHandoff.destroy();
|
|
2572
2588
|
if (!this._swarm)
|
|
2573
2589
|
return;
|
|
2574
2590
|
const swarm = this._swarm;
|
|
@@ -2796,12 +2812,12 @@ export class Core extends ReadyResource {
|
|
|
2796
2812
|
return ourDevice;
|
|
2797
2813
|
}
|
|
2798
2814
|
async _skillOverlayOp(agentId, op) {
|
|
2799
|
-
const host = await this.
|
|
2815
|
+
const host = await this._resolveAgentHost(agentId);
|
|
2800
2816
|
if (!host)
|
|
2801
2817
|
return this._runLocalSkillOverlayOp(op);
|
|
2802
2818
|
return this._skillOverlayHandoff.send(host, { ...op, agentId });
|
|
2803
2819
|
}
|
|
2804
|
-
async
|
|
2820
|
+
async _resolveAgentHost(agentId) {
|
|
2805
2821
|
if (!agentId)
|
|
2806
2822
|
return null;
|
|
2807
2823
|
if (!this.opened)
|
|
@@ -2822,6 +2838,56 @@ export class Core extends ReadyResource {
|
|
|
2822
2838
|
throw new Error(HOST_REVOKED);
|
|
2823
2839
|
return agent.providerDeviceId;
|
|
2824
2840
|
}
|
|
2841
|
+
async _listInferenceCalls(chatId) {
|
|
2842
|
+
const mesh = await this._awaitMesh();
|
|
2843
|
+
const store = this._inferenceCalls;
|
|
2844
|
+
const own = store?.list(chatId) ?? { calls: [], truncated: false };
|
|
2845
|
+
const local = own.calls;
|
|
2846
|
+
const chat = mesh ? await getChat(mesh, chatId) : null;
|
|
2847
|
+
if (!chat)
|
|
2848
|
+
return own;
|
|
2849
|
+
const host = await this._resolveAgentHost(chat.agentId).catch((err) => {
|
|
2850
|
+
if (local.length === 0)
|
|
2851
|
+
throw err;
|
|
2852
|
+
this._log?.warn(['api'], 'inspector host unresolved, showing this device only', {
|
|
2853
|
+
chatId,
|
|
2854
|
+
err
|
|
2855
|
+
});
|
|
2856
|
+
return null;
|
|
2857
|
+
});
|
|
2858
|
+
if (!host) {
|
|
2859
|
+
if (!store)
|
|
2860
|
+
throw new Error(NO_RECORD_STORE);
|
|
2861
|
+
return own;
|
|
2862
|
+
}
|
|
2863
|
+
const answer = await this._inferenceCallsHandoff.send(host, { chatId });
|
|
2864
|
+
const calls = [
|
|
2865
|
+
...local,
|
|
2866
|
+
...answer.calls.flatMap((entry) => this._toInferenceEntry(entry))
|
|
2867
|
+
].sort((a, b) => a.at - b.at);
|
|
2868
|
+
return { calls, truncated: own.truncated || answer.truncated };
|
|
2869
|
+
}
|
|
2870
|
+
_toInferenceEntry(entry) {
|
|
2871
|
+
const call = entry.call;
|
|
2872
|
+
if (typeof call !== 'object' || call === null)
|
|
2873
|
+
return [];
|
|
2874
|
+
return [{ runId: entry.runId, at: entry.at, call: call }];
|
|
2875
|
+
}
|
|
2876
|
+
async _serveInferenceCalls(request, fromDeviceId) {
|
|
2877
|
+
const mesh = this._currentMesh();
|
|
2878
|
+
const deviceId = this.devicePublicKey;
|
|
2879
|
+
if (!mesh || !deviceId)
|
|
2880
|
+
throw new Error(NOT_THE_HOST);
|
|
2881
|
+
const store = this._inferenceCalls;
|
|
2882
|
+
if (!store)
|
|
2883
|
+
throw new Error(NO_RECORD_STORE);
|
|
2884
|
+
const receive = createInferenceCallsReceiver({
|
|
2885
|
+
mesh,
|
|
2886
|
+
deviceId,
|
|
2887
|
+
listLocal: (chatId) => store.list(chatId)
|
|
2888
|
+
});
|
|
2889
|
+
return receive(request, fromDeviceId);
|
|
2890
|
+
}
|
|
2825
2891
|
async _serveSkillOverlayOp(op, fromDeviceId) {
|
|
2826
2892
|
const mesh = this._currentMesh();
|
|
2827
2893
|
const deviceId = this.devicePublicKey;
|
|
@@ -2913,6 +2979,7 @@ export class Core extends ReadyResource {
|
|
|
2913
2979
|
this._skillOverlayHandoff.addStream(conn);
|
|
2914
2980
|
this._meshSeedHandoff.addStream(conn);
|
|
2915
2981
|
this._harnessLoan.addStream(conn);
|
|
2982
|
+
this._inferenceCallsHandoff.addStream(conn);
|
|
2916
2983
|
for (const entry of this._meshes.values()) {
|
|
2917
2984
|
entry.hostedAgents?.kick();
|
|
2918
2985
|
if (entry.mesh.ourMemberId)
|
|
@@ -3054,6 +3121,13 @@ export class Core extends ReadyResource {
|
|
|
3054
3121
|
this._diagnosticsProviders.add(provider);
|
|
3055
3122
|
return () => void this._diagnosticsProviders.delete(provider);
|
|
3056
3123
|
}
|
|
3124
|
+
registerInferenceCalls(source) {
|
|
3125
|
+
this._inferenceCalls = source;
|
|
3126
|
+
return () => {
|
|
3127
|
+
if (this._inferenceCalls === source)
|
|
3128
|
+
this._inferenceCalls = null;
|
|
3129
|
+
};
|
|
3130
|
+
}
|
|
3057
3131
|
registerListModels(hook) {
|
|
3058
3132
|
this._listModels = hook;
|
|
3059
3133
|
return () => {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface InferenceCallEntry {
|
|
2
|
+
runId: string;
|
|
3
|
+
at: number;
|
|
4
|
+
call: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare function defaultInferenceCallsDir(): string;
|
|
7
|
+
export declare const MAX_TOTAL_BYTES: number;
|
|
8
|
+
export declare const MAX_AGE_MS: number;
|
|
9
|
+
export declare class InferenceCallStore {
|
|
10
|
+
private readonly _dir;
|
|
11
|
+
private readonly _writes;
|
|
12
|
+
constructor(dir?: string);
|
|
13
|
+
record(chatId: string, entry: InferenceCallEntry): Promise<void>;
|
|
14
|
+
recordSent(chatId: string, sent: {
|
|
15
|
+
runId: string;
|
|
16
|
+
round: number;
|
|
17
|
+
messages: unknown;
|
|
18
|
+
tokens: unknown;
|
|
19
|
+
outcome: unknown;
|
|
20
|
+
reason: unknown;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
recordOutcome(chatId: string, verdict: {
|
|
23
|
+
runId: string;
|
|
24
|
+
outcome: string;
|
|
25
|
+
reason: string | null;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
list(chatId: string): {
|
|
28
|
+
calls: ReadonlyArray<InferenceCallEntry>;
|
|
29
|
+
truncated: boolean;
|
|
30
|
+
};
|
|
31
|
+
forget(chatId: string): Promise<void>;
|
|
32
|
+
sweep(limits?: {
|
|
33
|
+
maxTotalBytes?: number;
|
|
34
|
+
maxAgeMs?: number;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
removed: number;
|
|
37
|
+
}>;
|
|
38
|
+
private _drop;
|
|
39
|
+
private _chatSizes;
|
|
40
|
+
}
|