@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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
2
|
import { type CurrentMesh } from './current-mesh.ts';
|
|
3
3
|
type ChatCapabilities = Pick<CapabilityHandlers, 'createChat' | 'listChats' | 'getChat' | 'renameChat' | 'setChatRagEnabled' | 'setChatWebSearchEnabled' | 'deleteChat' | 'chatsWatch' | 'listChatActivity' | 'chatActivityWatch' | 'searchChats'>;
|
|
4
|
-
export declare function createChatApi(current: CurrentMesh, deviceId: Buffer | null
|
|
4
|
+
export declare function createChatApi(current: CurrentMesh, deviceId: Buffer | null, inferenceCalls?: {
|
|
5
|
+
forget(chatId: string): Promise<void>;
|
|
6
|
+
} | null): ChatCapabilities;
|
|
5
7
|
export {};
|
package/dist-lib/lib/api/chat.js
CHANGED
|
@@ -5,7 +5,7 @@ import { searchChats } from '../core/chat-search.js';
|
|
|
5
5
|
import { meshWatchable, requireMesh, selectionPin } from './current-mesh.js';
|
|
6
6
|
import { watchable } from './watchable.js';
|
|
7
7
|
const SEARCH_SUPERSEDED_ABORT = 'superseded by a newer chat search';
|
|
8
|
-
export function createChatApi(current, deviceId) {
|
|
8
|
+
export function createChatApi(current, deviceId, inferenceCalls = null) {
|
|
9
9
|
let searchAbort = null;
|
|
10
10
|
const chatList = (mesh) => listSidebar(mesh);
|
|
11
11
|
const chatActivity = (mesh, chatIds) => listChatActivity(mesh, chatIds ?? undefined).then((activities) => ({ activities }));
|
|
@@ -16,7 +16,11 @@ export function createChatApi(current, deviceId) {
|
|
|
16
16
|
renameChat: async ({ id, title, meshId }) => renameChat(await requireMesh(current, meshId), id, title),
|
|
17
17
|
setChatRagEnabled: async ({ id, enabled }) => setChatRagEnabled(await requireMesh(current), id, enabled ?? false),
|
|
18
18
|
setChatWebSearchEnabled: async ({ id, enabled }) => setChatWebSearchEnabled(await requireMesh(current), id, enabled ?? false),
|
|
19
|
-
deleteChat: async ({ id, meshId }) =>
|
|
19
|
+
deleteChat: async ({ id, meshId }) => {
|
|
20
|
+
const deleted = await deleteChat(await requireMesh(current, meshId), deviceId, id);
|
|
21
|
+
await inferenceCalls?.forget(id);
|
|
22
|
+
return deleted;
|
|
23
|
+
},
|
|
20
24
|
chatsWatch: meshWatchable('chatsWatch', current, (_request, store) => chatList(store)),
|
|
21
25
|
listChatActivity: async (input) => chatActivity(await requireMesh(current), input?.chatIds),
|
|
22
26
|
chatActivityWatch: watchable('chatActivityWatch', () => requireMesh(current), (request, store) => chatActivity(store, request?.chatIds), () => selectionPin(current)),
|
|
@@ -3,6 +3,7 @@ import type { AssistantCapabilityProfile, AssistantClearModelDownloadRequest, As
|
|
|
3
3
|
import type { openLocalStore } from '../core/local/index.ts';
|
|
4
4
|
import type { CurrentMesh } from './current-mesh.ts';
|
|
5
5
|
import { type DiagnosticsSource } from './diagnostics.ts';
|
|
6
|
+
import { type InferenceCallReader } from './inference-calls.ts';
|
|
6
7
|
import { type LogSource } from './logs.ts';
|
|
7
8
|
import { type MeshStatusSource } from './mesh.ts';
|
|
8
9
|
import { type NetworkSource } from './network.ts';
|
|
@@ -15,6 +16,7 @@ interface ApiDeps {
|
|
|
15
16
|
meshStatus?: MeshStatusSource | null;
|
|
16
17
|
network?: NetworkSource | null;
|
|
17
18
|
diagnostics?: DiagnosticsSource | null;
|
|
19
|
+
inferenceCalls?: InferenceCallReader | null;
|
|
18
20
|
logs?: LogSource | null;
|
|
19
21
|
deviceId?: Buffer | null;
|
|
20
22
|
lifecycle?: {
|
|
@@ -11,6 +11,7 @@ import { createAppConfigApi } from './app-config.js';
|
|
|
11
11
|
import { createConfigApi } from './config.js';
|
|
12
12
|
import { createDevicesApi } from './devices.js';
|
|
13
13
|
import { createDiagnosticsApi } from './diagnostics.js';
|
|
14
|
+
import { createInferenceCallsApi } from './inference-calls.js';
|
|
14
15
|
import { createExecutionApi } from './execution.js';
|
|
15
16
|
import { createKnowledgeApi } from './knowledge.js';
|
|
16
17
|
import { createFilesApi } from './files.js';
|
|
@@ -38,7 +39,7 @@ export function createApi(deps = {}) {
|
|
|
38
39
|
...(state ? createModelDownloadApi(state) : null),
|
|
39
40
|
...(state ? createCustomModelApi(state) : null),
|
|
40
41
|
...(mesh ? createAgentsApi(mesh, deps.deviceId ?? null, deps.computeLender ?? null) : null),
|
|
41
|
-
...(mesh ? createChatApi(mesh, deps.deviceId ?? null) : null),
|
|
42
|
+
...(mesh ? createChatApi(mesh, deps.deviceId ?? null, deps.inferenceCalls ?? null) : null),
|
|
42
43
|
...(mesh ? createChatGroupsApi(mesh) : null),
|
|
43
44
|
...(mesh ? createApprovalRulesApi(mesh) : null),
|
|
44
45
|
...(mesh ? createChunksApi(mesh, deps.deviceId ?? null) : null),
|
|
@@ -68,6 +69,7 @@ export function createApi(deps = {}) {
|
|
|
68
69
|
...(mesh ? createMembersApi(mesh, state) : null),
|
|
69
70
|
...(deps.network ? createNetworkApi(deps.network) : null),
|
|
70
71
|
...(deps.diagnostics ? createDiagnosticsApi(deps.diagnostics) : null),
|
|
72
|
+
...(deps.inferenceCalls ? createInferenceCallsApi(deps.inferenceCalls) : null),
|
|
71
73
|
...(deps.logs ? createLogsApi(deps.logs) : null),
|
|
72
74
|
...(deps.lifecycle
|
|
73
75
|
? {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
|
+
import type { InferenceCallEntry } from '../inference-calls.ts';
|
|
3
|
+
export interface InferenceCallSource {
|
|
4
|
+
list(chatId: string): {
|
|
5
|
+
calls: ReadonlyArray<InferenceCallEntry>;
|
|
6
|
+
truncated: boolean;
|
|
7
|
+
};
|
|
8
|
+
forget(chatId: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface InferenceCallAnswer {
|
|
11
|
+
calls: ReadonlyArray<InferenceCallEntry>;
|
|
12
|
+
truncated: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface InferenceCallReader {
|
|
15
|
+
list(chatId: string): Promise<InferenceCallAnswer>;
|
|
16
|
+
forget(chatId: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createInferenceCallsApi(reader: InferenceCallReader): Pick<CapabilityHandlers, 'inferenceCalls'>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function createInferenceCallsApi(reader) {
|
|
2
|
+
return {
|
|
3
|
+
inferenceCalls: async ({ chatId }) => {
|
|
4
|
+
const answer = await reader.list(chatId);
|
|
5
|
+
return {
|
|
6
|
+
calls: answer.calls.map((entry) => ({
|
|
7
|
+
runId: entry.runId,
|
|
8
|
+
at: entry.at,
|
|
9
|
+
call: entry.call
|
|
10
|
+
})),
|
|
11
|
+
truncated: answer.truncated
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
package/dist-lib/lib/api/rag.js
CHANGED
|
@@ -138,7 +138,11 @@ export function createRagApi(current, index, embedder, effectiveCtxSize = null)
|
|
|
138
138
|
chatId,
|
|
139
139
|
limit: clampLimit(limit),
|
|
140
140
|
liveSourceIds: rows.map((row) => row.id)
|
|
141
|
-
}, {
|
|
141
|
+
}, {
|
|
142
|
+
index: vectorIndex,
|
|
143
|
+
embed: (texts) => embed.embed({ texts }),
|
|
144
|
+
debug: (message) => logger.debug('rag', message)
|
|
145
|
+
});
|
|
142
146
|
return respond({
|
|
143
147
|
searchedCount: hits.length,
|
|
144
148
|
indexEmpty,
|
|
@@ -163,7 +167,11 @@ export function createRagApi(current, index, embedder, effectiveCtxSize = null)
|
|
|
163
167
|
documents: hydratedDocuments,
|
|
164
168
|
liveSourceIds: rows.map((row) => row.id),
|
|
165
169
|
scopeDocumentIds: scopeDocumentIds.length > 0 ? scopeDocumentIds : undefined
|
|
166
|
-
}, {
|
|
170
|
+
}, {
|
|
171
|
+
index: vectorIndex,
|
|
172
|
+
embed: (texts) => embed.embed({ texts }),
|
|
173
|
+
debug: (message) => logger.debug('rag', message)
|
|
174
|
+
});
|
|
167
175
|
return respond({
|
|
168
176
|
searchedCount: result.searchedCount,
|
|
169
177
|
indexEmpty,
|
|
@@ -23,7 +23,16 @@ export interface CompactResult {
|
|
|
23
23
|
readonly foldedTurns?: number;
|
|
24
24
|
readonly reason?: string;
|
|
25
25
|
}
|
|
26
|
-
export declare function
|
|
26
|
+
export declare function couldNameSenders(chunks: ReadonlyArray<AssistantChunk>): boolean;
|
|
27
|
+
export declare function senderNamesFrom(chunks: ReadonlyArray<AssistantChunk>, members: ReadonlyArray<{
|
|
28
|
+
id: Buffer;
|
|
29
|
+
name: string;
|
|
30
|
+
}>, devices: ReadonlyArray<{
|
|
31
|
+
id: Buffer;
|
|
32
|
+
memberId?: Buffer | null;
|
|
33
|
+
}>): ReadonlyMap<string, string>;
|
|
34
|
+
export declare function senderAttribution(names: ReadonlyMap<string, string>): string;
|
|
35
|
+
export declare function historyFromChunks(chunks: ReadonlyArray<AssistantChunk>, stale?: Partial<StaleToolRuns>, senderNames?: ReadonlyMap<string, string>): ChatMessage[];
|
|
27
36
|
export declare function inputAvailableToRun(chunk: AssistantChunk, requestSeq: number): boolean;
|
|
28
37
|
export declare function normalizeQuestion(text: string): string;
|
|
29
38
|
export declare const GENERIC_ACKNOWLEDGEMENTS: Set<string>;
|
|
@@ -39,8 +39,40 @@ export function beforeLatestAttempt(chunk, starts) {
|
|
|
39
39
|
const start = starts.get(chunk.runId);
|
|
40
40
|
return start !== undefined && chunk.seq < start;
|
|
41
41
|
}
|
|
42
|
-
export function
|
|
42
|
+
export function couldNameSenders(chunks) {
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
for (const chunk of chunks) {
|
|
45
|
+
if (chunk.type !== 'user-message')
|
|
46
|
+
continue;
|
|
47
|
+
seen.add((chunk.senderMemberId ?? chunk.originDeviceId).toString('hex'));
|
|
48
|
+
if (seen.size > 1)
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
export function senderNamesFrom(chunks, members, devices) {
|
|
54
|
+
if (members.length < 2)
|
|
55
|
+
return new Map();
|
|
56
|
+
const byMember = new Map(members.map((member) => [member.id.toString('hex'), member.name]));
|
|
57
|
+
const deviceMember = new Map(devices.map((device) => [device.id.toString('hex'), device.memberId]));
|
|
58
|
+
const names = new Map();
|
|
59
|
+
for (const chunk of chunks) {
|
|
60
|
+
if (chunk.type !== 'user-message')
|
|
61
|
+
continue;
|
|
62
|
+
const memberId = chunk.senderMemberId ?? deviceMember.get(chunk.originDeviceId.toString('hex'));
|
|
63
|
+
const name = memberId ? byMember.get(memberId.toString('hex')) : undefined;
|
|
64
|
+
if (name)
|
|
65
|
+
names.set(chunk.id, name);
|
|
66
|
+
}
|
|
67
|
+
return names;
|
|
68
|
+
}
|
|
69
|
+
export function senderAttribution(names) {
|
|
70
|
+
const distinct = [...new Set(names.values())].sort();
|
|
71
|
+
return distinct.length > 1 ? distinct.join('\u0000') : '';
|
|
72
|
+
}
|
|
73
|
+
export function historyFromChunks(chunks, stale = {}, senderNames = new Map()) {
|
|
43
74
|
const attemptStarts = latestAttemptStarts(chunks);
|
|
75
|
+
const shared = new Set(senderNames.values()).size > 1;
|
|
44
76
|
const staleRunIds = stale.runIds ?? new Set();
|
|
45
77
|
const staleQuestionChunkIds = stale.questionChunkIds ?? new Set();
|
|
46
78
|
const folded = foldCompactedChunks(chunks);
|
|
@@ -72,7 +104,10 @@ export function historyFromChunks(chunks, stale = {}) {
|
|
|
72
104
|
if (chunk.userMessage) {
|
|
73
105
|
if (staleQuestionChunkIds.has(chunk.id))
|
|
74
106
|
continue;
|
|
107
|
+
const sender = shared ? senderNames.get(chunk.id) : undefined;
|
|
75
108
|
const turn = { role: 'user', content: chunk.userMessage.text };
|
|
109
|
+
if (sender)
|
|
110
|
+
turn.sender = sender;
|
|
76
111
|
const refs = (byMessage.get(chunk.id) ?? [])
|
|
77
112
|
.map((attachmentChunk) => attachmentChunk.attachment)
|
|
78
113
|
.filter((ref) => !ref.deletedAt);
|
|
@@ -2,6 +2,7 @@ import type { DocumentAttachment } from '../core/document-attachment.ts';
|
|
|
2
2
|
export interface ChatMessage {
|
|
3
3
|
role: 'user' | 'assistant' | 'tool';
|
|
4
4
|
content: string;
|
|
5
|
+
sender?: string;
|
|
5
6
|
attachments?: {
|
|
6
7
|
path: string;
|
|
7
8
|
}[];
|
|
@@ -43,3 +44,4 @@ export interface AttachmentMeta {
|
|
|
43
44
|
export interface FetchedAttachment extends AttachmentMeta {
|
|
44
45
|
bytes: Uint8Array;
|
|
45
46
|
}
|
|
47
|
+
export declare function nameSenders(messages: ReadonlyArray<ChatMessage>): ChatMessage[];
|
|
@@ -45,3 +45,14 @@ export function audioTranscriptBlock(fileName, transcript) {
|
|
|
45
45
|
transcript
|
|
46
46
|
].join('\n');
|
|
47
47
|
}
|
|
48
|
+
const MAX_SENDER_NAME_CHARS = 64;
|
|
49
|
+
function displayableSender(name) {
|
|
50
|
+
const flat = name?.replace(/\s+/g, ' ').trim();
|
|
51
|
+
return flat ? Array.from(flat).slice(0, MAX_SENDER_NAME_CHARS).join('') : undefined;
|
|
52
|
+
}
|
|
53
|
+
export function nameSenders(messages) {
|
|
54
|
+
return messages.map(({ sender, ...turn }) => {
|
|
55
|
+
const name = displayableSender(sender);
|
|
56
|
+
return name ? { ...turn, content: `${name}: ${turn.content}` } : turn;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readSetup as normalizeSkillSetup } from '@qvac/harness/lib/tools/skills/manifest-parse.ts';
|
|
2
|
+
const TOKEN_AUTH = ['pkce-only', 'secret-in-body', 'secret-in-basic'];
|
|
2
3
|
export function toEngineSkill(skill) {
|
|
3
4
|
const setup = normalizeSkillSetup(skill.setup);
|
|
4
5
|
return {
|
|
@@ -63,7 +64,32 @@ export function toEngineSkillSetup(setup) {
|
|
|
63
64
|
}))
|
|
64
65
|
}
|
|
65
66
|
: {}),
|
|
66
|
-
...(route.satisfied !== undefined ? { satisfied: route.satisfied } : {})
|
|
67
|
+
...(route.satisfied !== undefined ? { satisfied: route.satisfied } : {}),
|
|
68
|
+
...(route.oauth &&
|
|
69
|
+
route.oauth.stateKey &&
|
|
70
|
+
route.oauth.authUrl &&
|
|
71
|
+
route.oauth.tokenUrl &&
|
|
72
|
+
TOKEN_AUTH.includes(route.oauth.tokenAuth)
|
|
73
|
+
? {
|
|
74
|
+
oauth: {
|
|
75
|
+
stateKey: route.oauth.stateKey,
|
|
76
|
+
authUrl: route.oauth.authUrl,
|
|
77
|
+
tokenUrl: route.oauth.tokenUrl,
|
|
78
|
+
tokenAuth: route.oauth.tokenAuth,
|
|
79
|
+
scopes: [...(route.oauth.scopes ?? [])],
|
|
80
|
+
...(route.oauth.extraAuthParams
|
|
81
|
+
? { extraAuthParams: route.oauth.extraAuthParams }
|
|
82
|
+
: {}),
|
|
83
|
+
...(route.oauth.registrationEndpoint
|
|
84
|
+
? { registrationEndpoint: route.oauth.registrationEndpoint }
|
|
85
|
+
: {}),
|
|
86
|
+
...(route.oauth.port !== undefined ? { port: route.oauth.port } : {}),
|
|
87
|
+
...(route.oauth.sharedIosSession !== undefined
|
|
88
|
+
? { sharedIosSession: route.oauth.sharedIosSession }
|
|
89
|
+
: {})
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
: {})
|
|
67
93
|
}))
|
|
68
94
|
}
|
|
69
95
|
: {})
|
|
@@ -21,6 +21,7 @@ export interface AssistantTreeOptions {
|
|
|
21
21
|
harness: HarnessFactory | ChildSpec<Harness>;
|
|
22
22
|
logger?: Logger | null;
|
|
23
23
|
imageCacheDir?: string;
|
|
24
|
+
inferenceCallsDir?: string;
|
|
24
25
|
imageCacheMaxBytes?: number;
|
|
25
26
|
imageCacheMaxAgeMs?: number;
|
|
26
27
|
embedder?: EmbedderFactory;
|
|
@@ -35,6 +36,7 @@ export interface AssistantChildOptions {
|
|
|
35
36
|
core?: string;
|
|
36
37
|
logger?: Logger | null;
|
|
37
38
|
imageCacheDir?: string;
|
|
39
|
+
inferenceCallsDir?: string;
|
|
38
40
|
imageCacheMaxBytes?: number;
|
|
39
41
|
imageCacheMaxAgeMs?: number;
|
|
40
42
|
embedder?: EmbedderFactory;
|
|
@@ -5,7 +5,7 @@ import { startCustomModelPusher } from './custom-model-pusher.js';
|
|
|
5
5
|
import { serveHarness } from '@qvac/harness';
|
|
6
6
|
import { duplexPair } from '@qvac/harness/transport';
|
|
7
7
|
export function assistantTree(opts) {
|
|
8
|
-
const { core, harness, logger = null, imageCacheDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, platform, preloadCurrentAgentModel } = opts;
|
|
8
|
+
const { core, harness, logger = null, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, platform, preloadCurrentAgentModel } = opts;
|
|
9
9
|
const sup = new Supervisor();
|
|
10
10
|
const logged = ['child-died', 'child-restarting', 'child-ready', 'gave-up', 'stall'];
|
|
11
11
|
for (const event of logged) {
|
|
@@ -13,6 +13,7 @@ export function assistantTree(opts) {
|
|
|
13
13
|
}
|
|
14
14
|
sup.on('power', (payload) => logger?.info('assistant-tree', 'power', payload));
|
|
15
15
|
let offDiagnostics = null;
|
|
16
|
+
let offInferenceCalls = null;
|
|
16
17
|
let offListModels = null;
|
|
17
18
|
let offDeleteModel = null;
|
|
18
19
|
let offClearKvCache = null;
|
|
@@ -59,6 +60,7 @@ export function assistantTree(opts) {
|
|
|
59
60
|
const assistant = new QvacAssistant(engine, harness, {
|
|
60
61
|
logger,
|
|
61
62
|
imageCacheDir,
|
|
63
|
+
...(inferenceCallsDir ? { inferenceCallsDir } : {}),
|
|
62
64
|
imageCacheMaxBytes,
|
|
63
65
|
imageCacheMaxAgeMs,
|
|
64
66
|
...(platform ? { platform } : {}),
|
|
@@ -67,6 +69,10 @@ export function assistantTree(opts) {
|
|
|
67
69
|
borrowHarness: (deviceId) => core.borrowHarness(deviceId)
|
|
68
70
|
});
|
|
69
71
|
offDiagnostics = core.registerDiagnostics(() => assistant.diagnosticsSlice());
|
|
72
|
+
offInferenceCalls = core.registerInferenceCalls({
|
|
73
|
+
list: (chatId) => assistant.inferenceCalls(chatId),
|
|
74
|
+
forget: (chatId) => assistant.forgetInferenceCalls(chatId)
|
|
75
|
+
});
|
|
70
76
|
offListModels = core.registerListModels(harnessListModels(harness));
|
|
71
77
|
offDeleteModel = core.registerDeleteModel(harnessDeleteModel(harness));
|
|
72
78
|
offClearKvCache = core.registerClearKvCache(harnessClearKvCache(harness));
|
|
@@ -116,6 +122,8 @@ export function assistantTree(opts) {
|
|
|
116
122
|
stop: async (assistant) => {
|
|
117
123
|
offDiagnostics?.();
|
|
118
124
|
offDiagnostics = null;
|
|
125
|
+
offInferenceCalls?.();
|
|
126
|
+
offInferenceCalls = null;
|
|
119
127
|
offListModels?.();
|
|
120
128
|
offListModels = null;
|
|
121
129
|
offDeleteModel?.();
|
|
@@ -162,7 +170,7 @@ export function assistantTree(opts) {
|
|
|
162
170
|
return sup;
|
|
163
171
|
}
|
|
164
172
|
export function assistantChild(opts) {
|
|
165
|
-
const { harness, core = 'core', logger = null, imageCacheDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, preloadCurrentAgentModel, ...spec } = opts;
|
|
173
|
+
const { harness, core = 'core', logger = null, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, preloadCurrentAgentModel, ...spec } = opts;
|
|
166
174
|
return {
|
|
167
175
|
...spec,
|
|
168
176
|
deps: [core],
|
|
@@ -172,6 +180,7 @@ export function assistantChild(opts) {
|
|
|
172
180
|
harness,
|
|
173
181
|
logger,
|
|
174
182
|
imageCacheDir,
|
|
183
|
+
...(inferenceCallsDir ? { inferenceCallsDir } : {}),
|
|
175
184
|
imageCacheMaxBytes,
|
|
176
185
|
imageCacheMaxAgeMs,
|
|
177
186
|
embedder,
|
|
@@ -5,17 +5,22 @@ import type { AssistantKvCacheDeletionResponse, AssistantModelCatalogRevision }
|
|
|
5
5
|
import type { Capabilities } from './api/index.ts';
|
|
6
6
|
import type { DriveHost } from './core/fs-drives.ts';
|
|
7
7
|
import { type DiagnosticsSlice } from './diagnostics.ts';
|
|
8
|
+
import { type InferenceCallEntry } from './inference-calls.ts';
|
|
8
9
|
import type { Logger } from './log.ts';
|
|
9
10
|
import { type DeleteModelSummary, type Harness, type ListModelsOptions, type ModelInfo, type ToolCatalogEntry } from './assistant/harness.ts';
|
|
10
11
|
import type { Skill } from './assistant/skill-encode.ts';
|
|
11
12
|
import { type CompactOptions, type CompactResult } from './assistant/history.ts';
|
|
12
13
|
export { harnessClearKvCache, harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessSkillManagement, harnessSpeak, harnessSpeakStream, harnessTools, harnessTranscribe, type DeleteModelSummary, type Harness, type HarnessInfo, type ListModelsOptions, type ModelInfo, type ModelType, type ToolCatalogEntry } from './assistant/harness.ts';
|
|
13
14
|
export { type Skill } from './assistant/skill-encode.ts';
|
|
14
|
-
export { annotateUnreadableImages, unheardAudioNotice, unreadableImagesNotice, DOCUMENT_ONLY_USER_PROMPT, IMAGE_AND_DOCUMENT_USER_PROMPT, IMAGE_ONLY_USER_PROMPT } from './assistant/message.ts';
|
|
15
|
-
export { historyFromChunks, listHistoryChunks, staleToolRunIds, type CompactOptions, type CompactResult, type CompactionTrigger, type StaleToolRuns } from './assistant/history.ts';
|
|
15
|
+
export { annotateUnreadableImages, unheardAudioNotice, unreadableImagesNotice, DOCUMENT_ONLY_USER_PROMPT, IMAGE_AND_DOCUMENT_USER_PROMPT, IMAGE_ONLY_USER_PROMPT, nameSenders } from './assistant/message.ts';
|
|
16
|
+
export { couldNameSenders, historyFromChunks, listHistoryChunks, senderAttribution, senderNamesFrom, staleToolRunIds, type CompactOptions, type CompactResult, type CompactionTrigger, type StaleToolRuns } from './assistant/history.ts';
|
|
17
|
+
export declare const CAPTURE_INFERENCE_CALLS_KEY = "inspector.captureInferenceCalls";
|
|
18
|
+
export declare const CAPTURE_ON = "on";
|
|
19
|
+
export declare const CAPTURE_OFF = "off";
|
|
16
20
|
export interface AssistantOptions {
|
|
17
21
|
logger?: Logger | null;
|
|
18
22
|
imageCacheDir?: string;
|
|
23
|
+
inferenceCallsDir?: string;
|
|
19
24
|
imageCacheMaxBytes?: number;
|
|
20
25
|
imageCacheMaxAgeMs?: number;
|
|
21
26
|
downloadRetryMs?: number;
|
|
@@ -68,15 +73,17 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
68
73
|
private readonly _runConsumers;
|
|
69
74
|
private readonly _runs;
|
|
70
75
|
private readonly _seen;
|
|
76
|
+
private readonly _inferenceCalls;
|
|
71
77
|
private readonly _lifecycle;
|
|
72
78
|
private readonly _audioTranscripts;
|
|
73
79
|
private readonly _chats;
|
|
74
80
|
private readonly _runImageCacheNames;
|
|
75
81
|
private readonly _reconciledCompactions;
|
|
82
|
+
private readonly _chatAttribution;
|
|
76
83
|
private readonly _modelCatalog;
|
|
77
84
|
private readonly _onHarnessStatus;
|
|
78
85
|
private readonly _onModelCatalogEvent;
|
|
79
|
-
constructor(engine: Capabilities, harness: Harness, { logger, imageCacheDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform, preloadCurrentAgentModel, drives, borrowHarness, blobReadTimeoutMs }?: AssistantOptions);
|
|
86
|
+
constructor(engine: Capabilities, harness: Harness, { logger, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform, preloadCurrentAgentModel, drives, borrowHarness, blobReadTimeoutMs }?: AssistantOptions);
|
|
80
87
|
_open(): Promise<void>;
|
|
81
88
|
private _triggerModelWarm;
|
|
82
89
|
private _warmCurrentAgentModel;
|
|
@@ -87,9 +94,16 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
87
94
|
ensureMediaModelUnpaused(category: ModelCategory, model?: string | null): Promise<boolean>;
|
|
88
95
|
private _persistedProfile;
|
|
89
96
|
private _sweepImageCache;
|
|
97
|
+
private _sweepInferenceCalls;
|
|
90
98
|
private _imageCacheInUse;
|
|
91
99
|
private _referencedImageNames;
|
|
92
100
|
private _describeHarness;
|
|
101
|
+
private _capturingInferenceCalls;
|
|
102
|
+
inferenceCalls(chatId: string): {
|
|
103
|
+
calls: ReadonlyArray<InferenceCallEntry>;
|
|
104
|
+
truncated: boolean;
|
|
105
|
+
};
|
|
106
|
+
forgetInferenceCalls(chatId: string): Promise<void>;
|
|
93
107
|
diagnosticsSlice(): DiagnosticsSlice;
|
|
94
108
|
private _refreshHarnessDiagnostics;
|
|
95
109
|
private _reportCapabilities;
|
|
@@ -116,6 +130,8 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
116
130
|
private _watchAgents;
|
|
117
131
|
private _reclaimAgentChatCaches;
|
|
118
132
|
private _reconcileCompaction;
|
|
133
|
+
private _senderNames;
|
|
134
|
+
private _reconcileAttribution;
|
|
119
135
|
deleteChatKvCache(chatId: string): Promise<AssistantKvCacheDeletionResponse>;
|
|
120
136
|
private _deleteChatKvCache;
|
|
121
137
|
private _watchMeshList;
|