@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
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { persistent } from 'bare-storage';
|
|
4
|
+
import { WriteQueue } from './write-queue.js';
|
|
5
|
+
export function defaultInferenceCallsDir() {
|
|
6
|
+
return join(persistent(), 'qvac', 'inspector');
|
|
7
|
+
}
|
|
8
|
+
const CALLS_FILE = 'calls.jsonl';
|
|
9
|
+
const BLOCKS_DIR = 'blocks';
|
|
10
|
+
const MAX_CALLS_BYTES = 8 * 1024 * 1024;
|
|
11
|
+
export const MAX_TOTAL_BYTES = 64 * 1024 * 1024;
|
|
12
|
+
export const MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;
|
|
13
|
+
const MAX_LINES_READ = 600;
|
|
14
|
+
export class InferenceCallStore {
|
|
15
|
+
_dir;
|
|
16
|
+
_writes;
|
|
17
|
+
constructor(dir = defaultInferenceCallsDir()) {
|
|
18
|
+
this._dir = dir;
|
|
19
|
+
this._writes = new WriteQueue();
|
|
20
|
+
}
|
|
21
|
+
record(chatId, entry) {
|
|
22
|
+
return this._writes.run(chatId, 'inference-call', async () => {
|
|
23
|
+
const { system, tools, promptPrefix, rest } = split(entry.call);
|
|
24
|
+
const chatDir = join(this._dir, safeName(chatId));
|
|
25
|
+
await fs.promises.mkdir(join(chatDir, BLOCKS_DIR), { recursive: true });
|
|
26
|
+
const callsPath = join(chatDir, CALLS_FILE);
|
|
27
|
+
if (((await sizeOf(callsPath)) ?? 0) > MAX_CALLS_BYTES)
|
|
28
|
+
return;
|
|
29
|
+
if (promptPrefix) {
|
|
30
|
+
const blockPath = join(chatDir, BLOCKS_DIR, `${safeName(promptPrefix)}.json`);
|
|
31
|
+
await fs.promises
|
|
32
|
+
.writeFile(blockPath, JSON.stringify({ system, tools }), { flag: 'wx' })
|
|
33
|
+
.catch(() => undefined);
|
|
34
|
+
}
|
|
35
|
+
const line = JSON.stringify({ runId: entry.runId, at: entry.at, ...rest });
|
|
36
|
+
await fs.promises.appendFile(callsPath, `${line}\n`);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
recordSent(chatId, sent) {
|
|
40
|
+
return this._writes.run(chatId, 'inference-sent', async () => {
|
|
41
|
+
const chatDir = join(this._dir, safeName(chatId));
|
|
42
|
+
const callsPath = join(chatDir, CALLS_FILE);
|
|
43
|
+
const size = await sizeOf(callsPath);
|
|
44
|
+
if (size === null || size > MAX_CALLS_BYTES)
|
|
45
|
+
return;
|
|
46
|
+
const line = JSON.stringify({
|
|
47
|
+
sentFor: sent.round,
|
|
48
|
+
sentRun: sent.runId,
|
|
49
|
+
sent: sent.messages,
|
|
50
|
+
tokens: sent.tokens,
|
|
51
|
+
outcome: sent.outcome,
|
|
52
|
+
reason: sent.reason
|
|
53
|
+
});
|
|
54
|
+
await fs.promises.appendFile(callsPath, `${line}\n`);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
recordOutcome(chatId, verdict) {
|
|
58
|
+
return this._writes.run(chatId, 'inference-outcome', async () => {
|
|
59
|
+
const callsPath = join(this._dir, safeName(chatId), CALLS_FILE);
|
|
60
|
+
const size = await sizeOf(callsPath);
|
|
61
|
+
if (size === null || size > MAX_CALLS_BYTES)
|
|
62
|
+
return;
|
|
63
|
+
const line = JSON.stringify({
|
|
64
|
+
outcomeFor: verdict.runId,
|
|
65
|
+
outcome: verdict.outcome,
|
|
66
|
+
reason: verdict.reason
|
|
67
|
+
});
|
|
68
|
+
await fs.promises.appendFile(callsPath, `${line}\n`);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
list(chatId) {
|
|
72
|
+
const chatDir = join(this._dir, safeName(chatId));
|
|
73
|
+
const all = readLines(join(chatDir, CALLS_FILE));
|
|
74
|
+
const lines = all.slice(-MAX_LINES_READ);
|
|
75
|
+
const blocks = new Map();
|
|
76
|
+
const entries = [];
|
|
77
|
+
for (const line of lines) {
|
|
78
|
+
const parsed = parseLine(line);
|
|
79
|
+
if (!parsed)
|
|
80
|
+
continue;
|
|
81
|
+
if ('sentFor' in parsed) {
|
|
82
|
+
foldSent(entries, parsed);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if ('outcomeFor' in parsed) {
|
|
86
|
+
foldOutcome(entries, parsed);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const { runId, at, ...rest } = parsed;
|
|
90
|
+
const prefix = typeof rest.promptPrefix === 'string' ? rest.promptPrefix : '';
|
|
91
|
+
const block = prefix ? readBlock(blocks, chatDir, prefix) : null;
|
|
92
|
+
const messages = Array.isArray(rest.messages) ? rest.messages : [];
|
|
93
|
+
entries.push({
|
|
94
|
+
runId: String(runId ?? ''),
|
|
95
|
+
at: Number(at ?? 0),
|
|
96
|
+
call: {
|
|
97
|
+
...rest,
|
|
98
|
+
tools: block ? block.tools : (rest.tools ?? null),
|
|
99
|
+
messages: block?.system
|
|
100
|
+
? [{ role: 'system', content: block.system }, ...messages]
|
|
101
|
+
: messages
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return { calls: entries, truncated: all.length > lines.length };
|
|
106
|
+
}
|
|
107
|
+
forget(chatId) {
|
|
108
|
+
return this._writes.run(chatId, 'inference-forget', () => fs.promises.rm(join(this._dir, safeName(chatId)), { recursive: true, force: true }));
|
|
109
|
+
}
|
|
110
|
+
async sweep(limits = {}) {
|
|
111
|
+
const maxTotalBytes = limits.maxTotalBytes ?? MAX_TOTAL_BYTES;
|
|
112
|
+
const maxAgeMs = limits.maxAgeMs ?? MAX_AGE_MS;
|
|
113
|
+
const chats = await this._chatSizes();
|
|
114
|
+
const cutoff = Date.now() - maxAgeMs;
|
|
115
|
+
const aged = chats.filter((chat) => chat.mtimeMs < cutoff);
|
|
116
|
+
let removed = 0;
|
|
117
|
+
for (const chat of aged) {
|
|
118
|
+
await this._drop(chat.name);
|
|
119
|
+
removed++;
|
|
120
|
+
}
|
|
121
|
+
const kept = chats
|
|
122
|
+
.filter((chat) => chat.mtimeMs >= cutoff)
|
|
123
|
+
.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
124
|
+
let total = kept.reduce((sum, chat) => sum + chat.bytes, 0);
|
|
125
|
+
for (const chat of kept) {
|
|
126
|
+
if (total <= maxTotalBytes)
|
|
127
|
+
break;
|
|
128
|
+
await this._drop(chat.name);
|
|
129
|
+
total -= chat.bytes;
|
|
130
|
+
removed++;
|
|
131
|
+
}
|
|
132
|
+
return { removed };
|
|
133
|
+
}
|
|
134
|
+
async _drop(name) {
|
|
135
|
+
await fs.promises.rm(join(this._dir, name), { recursive: true, force: true });
|
|
136
|
+
}
|
|
137
|
+
async _chatSizes() {
|
|
138
|
+
let names;
|
|
139
|
+
try {
|
|
140
|
+
names = await fs.promises.readdir(this._dir);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
const chats = [];
|
|
146
|
+
for (const name of names) {
|
|
147
|
+
const measured = await measureDir(join(this._dir, name));
|
|
148
|
+
if (measured)
|
|
149
|
+
chats.push({ name, ...measured });
|
|
150
|
+
}
|
|
151
|
+
return chats;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function measureDir(dir) {
|
|
155
|
+
let bytes = 0;
|
|
156
|
+
let mtimeMs = 0;
|
|
157
|
+
const visit = async (path) => {
|
|
158
|
+
const stat = await fs.promises.stat(path);
|
|
159
|
+
if (stat.isDirectory()) {
|
|
160
|
+
for (const child of await fs.promises.readdir(path))
|
|
161
|
+
await visit(join(path, child));
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
bytes += stat.size;
|
|
165
|
+
mtimeMs = Math.max(mtimeMs, stat.mtimeMs);
|
|
166
|
+
};
|
|
167
|
+
try {
|
|
168
|
+
await visit(dir);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return { bytes, mtimeMs };
|
|
174
|
+
}
|
|
175
|
+
function foldSent(entries, parsed) {
|
|
176
|
+
const round = Number(parsed.sentFor ?? -1);
|
|
177
|
+
const runId = parsed.sentRun === undefined ? null : String(parsed.sentRun);
|
|
178
|
+
for (let index = entries.length - 1; index >= 0; index--) {
|
|
179
|
+
const entry = entries[index];
|
|
180
|
+
if (runId !== null && entry?.runId !== runId)
|
|
181
|
+
continue;
|
|
182
|
+
if (entry && Number(entry.call.round ?? -1) === round) {
|
|
183
|
+
entry.call.sent = parsed.sent ?? null;
|
|
184
|
+
entry.call.tokens = parsed.tokens ?? null;
|
|
185
|
+
entry.call.outcome = parsed.outcome ?? null;
|
|
186
|
+
entry.call.reason = parsed.reason ?? null;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function foldOutcome(entries, parsed) {
|
|
192
|
+
const runId = String(parsed.outcomeFor ?? '');
|
|
193
|
+
for (const entry of entries) {
|
|
194
|
+
if (entry.runId !== runId || entry.call.outcome)
|
|
195
|
+
continue;
|
|
196
|
+
entry.call.outcome = parsed.outcome ?? null;
|
|
197
|
+
entry.call.reason = parsed.reason ?? null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function split(call) {
|
|
201
|
+
const { messages, tools, ...rest } = call;
|
|
202
|
+
const turns = Array.isArray(messages) ? messages : [];
|
|
203
|
+
const promptPrefix = typeof rest.promptPrefix === 'string' ? rest.promptPrefix : '';
|
|
204
|
+
if (!promptPrefix) {
|
|
205
|
+
return { system: null, tools: null, promptPrefix, rest: { ...rest, messages: turns, tools } };
|
|
206
|
+
}
|
|
207
|
+
const system = turns.find((turn) => isSystemTurn(turn));
|
|
208
|
+
return {
|
|
209
|
+
system: system ? String(system.content) : null,
|
|
210
|
+
tools: tools ?? null,
|
|
211
|
+
promptPrefix,
|
|
212
|
+
rest: { ...rest, messages: turns.filter((turn) => !isSystemTurn(turn)) }
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function isSystemTurn(turn) {
|
|
216
|
+
return typeof turn === 'object' && turn !== null && 'role' in turn && turn.role === 'system';
|
|
217
|
+
}
|
|
218
|
+
function readBlock(cache, chatDir, prefix) {
|
|
219
|
+
const hit = cache.get(prefix);
|
|
220
|
+
if (hit)
|
|
221
|
+
return hit;
|
|
222
|
+
const raw = readFile(join(chatDir, BLOCKS_DIR, `${safeName(prefix)}.json`));
|
|
223
|
+
if (!raw)
|
|
224
|
+
return null;
|
|
225
|
+
const parsed = parseBlock(raw);
|
|
226
|
+
if (parsed)
|
|
227
|
+
cache.set(prefix, parsed);
|
|
228
|
+
return parsed;
|
|
229
|
+
}
|
|
230
|
+
function parseLine(line) {
|
|
231
|
+
try {
|
|
232
|
+
const value = JSON.parse(line);
|
|
233
|
+
return typeof value === 'object' && value !== null ? value : null;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function parseBlock(raw) {
|
|
240
|
+
const parsed = parseLine(raw);
|
|
241
|
+
return parsed ? { system: parsed.system ?? null, tools: parsed.tools ?? null } : null;
|
|
242
|
+
}
|
|
243
|
+
function readLines(path) {
|
|
244
|
+
const raw = readFile(path);
|
|
245
|
+
return raw ? raw.split('\n').filter((line) => line.length > 0) : [];
|
|
246
|
+
}
|
|
247
|
+
function readFile(path) {
|
|
248
|
+
try {
|
|
249
|
+
return fs.readFileSync(path, 'utf8');
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async function sizeOf(path) {
|
|
256
|
+
try {
|
|
257
|
+
return (await fs.promises.stat(path)).size;
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function safeName(value) {
|
|
264
|
+
const fenced = value.replace(/[^A-Za-z0-9._-]/g, '_');
|
|
265
|
+
return /^\.*$/.test(fenced) ? `_${fenced}` : fenced;
|
|
266
|
+
}
|
|
@@ -29,7 +29,11 @@ export const CHUNK_PAYLOAD_FIELDS = {
|
|
|
29
29
|
export function versionedRegistrar(ns, namespace) {
|
|
30
30
|
return (name, fields) => {
|
|
31
31
|
ns.register({ name: `${name}-v1`, fields });
|
|
32
|
-
ns.register({
|
|
32
|
+
ns.register({
|
|
33
|
+
name,
|
|
34
|
+
framed: false,
|
|
35
|
+
versions: [{ version: 1, type: `@${namespace}/${name}-v1` }]
|
|
36
|
+
});
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
39
|
export function registerContentTypes(ns, namespace) {
|
|
@@ -407,7 +407,8 @@ export function registerEngineTypes(ns) {
|
|
|
407
407
|
{ name: 'intent', type: 'string' },
|
|
408
408
|
{ name: 'display', type: 'json' },
|
|
409
409
|
{ name: 'rawCall', type: 'string' },
|
|
410
|
-
{ name: 'compaction', type: '@assistant/chunk-content-compaction' }
|
|
410
|
+
{ name: 'compaction', type: '@assistant/chunk-content-compaction' },
|
|
411
|
+
{ name: 'senderMemberId', type: 'fixed32' }
|
|
411
412
|
]);
|
|
412
413
|
ns.register({
|
|
413
414
|
name: 'chunk-list',
|
|
@@ -1630,6 +1631,41 @@ export function registerEngineTypes(ns) {
|
|
|
1630
1631
|
name: 'display-name',
|
|
1631
1632
|
fields: [{ name: 'name', type: 'string' }]
|
|
1632
1633
|
});
|
|
1634
|
+
ns.register({
|
|
1635
|
+
name: 'inference-call-entry',
|
|
1636
|
+
fields: [
|
|
1637
|
+
{ name: 'runId', type: 'string', required: true },
|
|
1638
|
+
{ name: 'at', type: 'uint', required: true },
|
|
1639
|
+
{ name: 'call', type: 'json', required: true }
|
|
1640
|
+
]
|
|
1641
|
+
});
|
|
1642
|
+
ns.register({
|
|
1643
|
+
name: 'inference-call-list',
|
|
1644
|
+
fields: [
|
|
1645
|
+
{ name: 'calls', type: '@assistant/inference-call-entry', array: true },
|
|
1646
|
+
{ name: 'truncated', type: 'bool' }
|
|
1647
|
+
]
|
|
1648
|
+
});
|
|
1649
|
+
ns.register({
|
|
1650
|
+
name: 'inference-calls-request',
|
|
1651
|
+
fields: [{ name: 'chatId', type: 'string', required: true }]
|
|
1652
|
+
});
|
|
1653
|
+
ns.register({
|
|
1654
|
+
name: 'inference-calls-handoff',
|
|
1655
|
+
fields: [
|
|
1656
|
+
{ name: 'id', type: 'uint', required: true },
|
|
1657
|
+
{ name: 'request', type: '@assistant/inference-calls-request', required: true }
|
|
1658
|
+
]
|
|
1659
|
+
});
|
|
1660
|
+
ns.register({
|
|
1661
|
+
name: 'inference-calls-handoff-ack',
|
|
1662
|
+
fields: [
|
|
1663
|
+
{ name: 'id', type: 'uint', required: true },
|
|
1664
|
+
{ name: 'error', type: 'string' },
|
|
1665
|
+
{ name: 'calls', type: '@assistant/inference-call-entry', array: true },
|
|
1666
|
+
{ name: 'truncated', type: 'bool' }
|
|
1667
|
+
]
|
|
1668
|
+
});
|
|
1633
1669
|
}
|
|
1634
1670
|
export function registerEngineApi(api) {
|
|
1635
1671
|
api.register({
|
|
@@ -2317,4 +2353,9 @@ export function registerEngineApi(api) {
|
|
|
2317
2353
|
request: { name: '@assistant/display-name', stream: false },
|
|
2318
2354
|
response: { name: '@assistant/ok-response', stream: false }
|
|
2319
2355
|
});
|
|
2356
|
+
api.register({
|
|
2357
|
+
name: 'inference-calls',
|
|
2358
|
+
request: { name: '@assistant/inference-calls-request', stream: false },
|
|
2359
|
+
response: { name: '@assistant/inference-call-list', stream: false }
|
|
2360
|
+
});
|
|
2320
2361
|
}
|
package/dist-lib/schema/qvac.js
CHANGED
|
@@ -70,7 +70,8 @@ export function registerQvacTypes(ns) {
|
|
|
70
70
|
{ name: 'intent', type: 'string' },
|
|
71
71
|
{ name: 'display', type: 'json' },
|
|
72
72
|
{ name: 'rawCall', type: 'string' },
|
|
73
|
-
{ name: 'compaction', type: '@qvac/chunk-content-compaction' }
|
|
73
|
+
{ name: 'compaction', type: '@qvac/chunk-content-compaction' },
|
|
74
|
+
{ name: 'senderMemberId', type: 'fixed32' }
|
|
74
75
|
]);
|
|
75
76
|
versioned('chunk-counter', [
|
|
76
77
|
{ name: 'chatId', type: 'string', required: true },
|
|
@@ -99,7 +100,8 @@ export function registerQvacTypes(ns) {
|
|
|
99
100
|
{ name: 'intent', type: 'string' },
|
|
100
101
|
{ name: 'display', type: 'json' },
|
|
101
102
|
{ name: 'rawCall', type: 'string' },
|
|
102
|
-
{ name: 'compaction', type: '@qvac/chunk-content-compaction' }
|
|
103
|
+
{ name: 'compaction', type: '@qvac/chunk-content-compaction' },
|
|
104
|
+
{ name: 'senderMemberId', type: 'fixed32' }
|
|
103
105
|
]);
|
|
104
106
|
versioned('update-chunk-operation', [
|
|
105
107
|
{ name: 'id', type: 'string', required: true },
|
package/dist-lib/spec/bind.js
CHANGED
package/dist-lib/spec/calls.js
CHANGED
|
@@ -147,5 +147,6 @@ export function engineClient(rpc) {
|
|
|
147
147
|
recoverAccount: (input) => rpc.recoverAccount(input),
|
|
148
148
|
displayName: (input) => rpc.displayName(input ?? {}),
|
|
149
149
|
setDisplayName: (input) => rpc.setDisplayName(input),
|
|
150
|
+
inferenceCalls: (input) => rpc.inferenceCalls(input),
|
|
150
151
|
};
|
|
151
152
|
}
|
|
@@ -165,6 +165,7 @@ export interface Capabilities {
|
|
|
165
165
|
recoverAccount(input: T.AssistantIdentityPhrase): Promise<T.AssistantOkResponse>
|
|
166
166
|
displayName(input?: T.AssistantEmpty): Promise<T.AssistantDisplayName>
|
|
167
167
|
setDisplayName(input: T.AssistantDisplayName): Promise<T.AssistantOkResponse>
|
|
168
|
+
inferenceCalls(input: T.AssistantInferenceCallsRequest): Promise<T.AssistantInferenceCallList>
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
export interface CapabilityHandlers {
|
|
@@ -305,4 +306,5 @@ export interface CapabilityHandlers {
|
|
|
305
306
|
recoverAccount(input: T.AssistantIdentityPhrase): T.AssistantOkResponse | Promise<T.AssistantOkResponse>
|
|
306
307
|
displayName(input?: T.AssistantEmpty): T.AssistantDisplayName | Promise<T.AssistantDisplayName>
|
|
307
308
|
setDisplayName(input: T.AssistantDisplayName): T.AssistantOkResponse | Promise<T.AssistantOkResponse>
|
|
309
|
+
inferenceCalls(input: T.AssistantInferenceCallsRequest): T.AssistantInferenceCallList | Promise<T.AssistantInferenceCallList>
|
|
308
310
|
}
|
|
@@ -1781,6 +1781,19 @@
|
|
|
1781
1781
|
"stream": false
|
|
1782
1782
|
},
|
|
1783
1783
|
"version": 1
|
|
1784
|
+
},
|
|
1785
|
+
{
|
|
1786
|
+
"id": 137,
|
|
1787
|
+
"name": "@assistant/inference-calls",
|
|
1788
|
+
"request": {
|
|
1789
|
+
"name": "@assistant/inference-calls-request",
|
|
1790
|
+
"stream": false
|
|
1791
|
+
},
|
|
1792
|
+
"response": {
|
|
1793
|
+
"name": "@assistant/inference-call-list",
|
|
1794
|
+
"stream": false
|
|
1795
|
+
},
|
|
1796
|
+
"version": 1
|
|
1784
1797
|
}
|
|
1785
1798
|
]
|
|
1786
1799
|
}
|
|
@@ -279,7 +279,9 @@ const methods = new Map([
|
|
|
279
279
|
['@assistant/display-name', 135],
|
|
280
280
|
[135, '@assistant/display-name'],
|
|
281
281
|
['@assistant/set-display-name', 136],
|
|
282
|
-
[136, '@assistant/set-display-name']
|
|
282
|
+
[136, '@assistant/set-display-name'],
|
|
283
|
+
['@assistant/inference-calls', 137],
|
|
284
|
+
[137, '@assistant/inference-calls']
|
|
283
285
|
])
|
|
284
286
|
|
|
285
287
|
class HRPC {
|
|
@@ -423,7 +425,8 @@ class HRPC {
|
|
|
423
425
|
['@assistant/recovery-publish', getEncoding('@assistant/identity-phrase')],
|
|
424
426
|
['@assistant/recover-account', getEncoding('@assistant/identity-phrase')],
|
|
425
427
|
['@assistant/display-name', getEncoding('@assistant/empty')],
|
|
426
|
-
['@assistant/set-display-name', getEncoding('@assistant/display-name')]
|
|
428
|
+
['@assistant/set-display-name', getEncoding('@assistant/display-name')],
|
|
429
|
+
['@assistant/inference-calls', getEncoding('@assistant/inference-calls-request')]
|
|
427
430
|
])
|
|
428
431
|
this._responseEncodings = new Map([
|
|
429
432
|
['@assistant/config-get', getEncoding('@assistant/config-value')],
|
|
@@ -562,7 +565,8 @@ class HRPC {
|
|
|
562
565
|
['@assistant/recovery-publish', getEncoding('@assistant/account-recovery-state')],
|
|
563
566
|
['@assistant/recover-account', getEncoding('@assistant/ok-response')],
|
|
564
567
|
['@assistant/display-name', getEncoding('@assistant/display-name')],
|
|
565
|
-
['@assistant/set-display-name', getEncoding('@assistant/ok-response')]
|
|
568
|
+
['@assistant/set-display-name', getEncoding('@assistant/ok-response')],
|
|
569
|
+
['@assistant/inference-calls', getEncoding('@assistant/inference-call-list')]
|
|
566
570
|
])
|
|
567
571
|
this._rpc = new RPC(stream, async (req) => {
|
|
568
572
|
const command = methods.get(req.command)
|
|
@@ -1208,6 +1212,10 @@ class HRPC {
|
|
|
1208
1212
|
return this._call('@assistant/set-display-name', args)
|
|
1209
1213
|
}
|
|
1210
1214
|
|
|
1215
|
+
async inferenceCalls(args) {
|
|
1216
|
+
return this._call('@assistant/inference-calls', args)
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1211
1219
|
onConfigGet(responseFn) {
|
|
1212
1220
|
this._handlers['@assistant/config-get'] = responseFn
|
|
1213
1221
|
}
|
|
@@ -1756,6 +1764,10 @@ class HRPC {
|
|
|
1756
1764
|
this._handlers['@assistant/set-display-name'] = responseFn
|
|
1757
1765
|
}
|
|
1758
1766
|
|
|
1767
|
+
onInferenceCalls(responseFn) {
|
|
1768
|
+
this._handlers['@assistant/inference-calls'] = responseFn
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1759
1771
|
_requestIsStream(command) {
|
|
1760
1772
|
return [
|
|
1761
1773
|
'@assistant/upload-attachment',
|