@qvac/core 0.10.0 → 0.10.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/CHANGELOG.md +52 -1
- package/dist-lib/lib/api/agents.js +2 -2
- package/dist-lib/lib/api/execution.js +2 -0
- package/dist-lib/lib/assistant.d.ts +3 -1
- package/dist-lib/lib/assistant.js +40 -3
- package/dist-lib/lib/core/agent.d.ts +5 -1
- package/dist-lib/lib/core/agent.js +8 -3
- package/dist-lib/lib/core/chat.d.ts +3 -1
- package/dist-lib/lib/core/chat.js +11 -4
- package/dist-lib/lib/core/local/index.d.ts +2 -1
- package/dist-lib/lib/core/local/index.js +9 -1
- package/dist-lib/lib/core/send.js +2 -0
- package/dist-lib/lib/core.d.ts +1 -0
- package/dist-lib/lib/core.js +38 -12
- package/dist-lib/lib/run-notices.d.ts +2 -0
- package/dist-lib/lib/run-notices.js +7 -2
- package/dist-lib/schema/engine.js +9 -1
- package/dist-lib/spec/capabilities.d.ts +2 -2
- package/dist-lib/spec/hrpc/hrpc.json +1 -1
- package/dist-lib/spec/hrpc/index.js +1 -1
- package/dist-lib/spec/hrpc/messages.js +29 -0
- package/dist-lib/spec/hyperschema/index.js +29 -0
- package/dist-lib/spec/hyperschema/schema.json +25 -0
- package/dist-lib/spec/hyperschema/types.d.ts +7 -0
- package/package.json +3 -3
- package/tui/README.md +6 -0
- package/tui/app.mjs +51 -12
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,55 @@ release.
|
|
|
13
13
|
|
|
14
14
|
## [Unreleased]
|
|
15
15
|
|
|
16
|
+
## [0.10.2] - 2026-10-20
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- `deleteAgent` takes `keepChats`, so an app can take an agent off a space
|
|
21
|
+
without deleting the conversations it answered there. They stay readable, and
|
|
22
|
+
`setChatAgent` hands each to another agent. The agent's open runs in them are
|
|
23
|
+
canceled. (`AssistantDeleteAgentRequest`) (#469)
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- `sendMessage` and `runAgent` refuse an agent that is deleted with
|
|
28
|
+
`AGENT_NOT_FOUND` instead of writing a run no device would claim. (#469)
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- A device that pairs onto another account no longer lists its old workspace
|
|
33
|
+
beside the new one. An `openMesh` sent during the pair waits for it and is
|
|
34
|
+
refused with `MESH_NOT_FOUND` for a workspace the pair left. (#482)
|
|
35
|
+
- A device that pairs onto another account no longer renames that account's user
|
|
36
|
+
to the name it had before; it takes the account's name. (#475)
|
|
37
|
+
- An edited or reverted skill reaches chats that had already loaded it. A
|
|
38
|
+
skill write or delete clears the hosting device's KV caches and run replay
|
|
39
|
+
records, so each chat's next turn reloads the skill from disk; that turn
|
|
40
|
+
prefills cold (QVAC-26561). (#473)
|
|
41
|
+
- `duck`: `/models add` keeps a vision model's projector, so its images are no
|
|
42
|
+
longer dropped. (#480)
|
|
43
|
+
- `duck`: `/models use <name>` refuses a name that is neither an added model's
|
|
44
|
+
label or id nor an exact catalog or registry name, instead of setting it and
|
|
45
|
+
letting the harness load whatever file the registry search hit first, which
|
|
46
|
+
could be a vision projector. A path or URL is still set as given. (#481)
|
|
47
|
+
|
|
48
|
+
## [0.10.1] - 2026-10-19
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- `QvacAssistant` takes `runIdleTimeoutMs`, how long a run's harness may send
|
|
53
|
+
nothing before the run fails. It defaults to 15 minutes. (#468)
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- `@qvac/harness` is now `^0.8.11` and `@qvac/skills` `^0.1.16`. (#468)
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- A run whose harness goes silent fails with "the agent stopped responding"
|
|
62
|
+
instead of showing busy forever. A run parked on an approval does not count
|
|
63
|
+
as silent. (#468)
|
|
64
|
+
|
|
16
65
|
## [0.10.0] - 2026-10-16
|
|
17
66
|
|
|
18
67
|
### Added
|
|
@@ -1780,7 +1829,9 @@ Published under the `release-0.1` dist-tag.
|
|
|
1780
1829
|
await assistant.ready()
|
|
1781
1830
|
```
|
|
1782
1831
|
|
|
1783
|
-
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.10.
|
|
1832
|
+
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.10.2...HEAD
|
|
1833
|
+
[0.10.2]: https://github.com/tetherto/qvac-core/compare/v0.10.1...v0.10.2
|
|
1834
|
+
[0.10.1]: https://github.com/tetherto/qvac-core/compare/v0.10.0...v0.10.1
|
|
1784
1835
|
[0.10.0]: https://github.com/tetherto/qvac-core/compare/v0.9.0...v0.10.0
|
|
1785
1836
|
[0.9.0]: https://github.com/tetherto/qvac-core/compare/v0.8.0...v0.9.0
|
|
1786
1837
|
[0.8.0]: https://github.com/tetherto/qvac-core/compare/v0.7.6...v0.8.0
|
|
@@ -41,9 +41,9 @@ export function createAgentsApi(pool, { deviceId, computeLender, log }) {
|
|
|
41
41
|
const mesh = await requireMesh(pool, meshId);
|
|
42
42
|
return withOrphaned(mesh, await updateAgent(mesh, agentId, config));
|
|
43
43
|
},
|
|
44
|
-
deleteAgent: async ({ agentId, meshId }) => {
|
|
44
|
+
deleteAgent: async ({ agentId, meshId, keepChats }) => {
|
|
45
45
|
const mesh = await requireMesh(pool, meshId);
|
|
46
|
-
return withOrphaned(mesh, await deleteAgent(mesh, deviceId, agentId));
|
|
46
|
+
return withOrphaned(mesh, await deleteAgent(mesh, deviceId, { id: agentId, keepChats }));
|
|
47
47
|
},
|
|
48
48
|
agentsWatch: meshWatchable(pool, (request, mesh) => list(mesh, request.providerDeviceId ?? undefined), { name: 'agentsWatch', log })
|
|
49
49
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mustGetActiveAgent } from '../core/agent.js';
|
|
1
2
|
import { appendChunk, listChunks } from '../core/chunk.js';
|
|
2
3
|
import { randomId } from '../core/id.js';
|
|
3
4
|
import { parentRequestId, sendMessage } from '../core/send.js';
|
|
@@ -18,6 +19,7 @@ export function createExecutionApi(pool, deviceId) {
|
|
|
18
19
|
}),
|
|
19
20
|
runAgent: async ({ chatId, agentId, parentRunId, meshId, capability, capabilityArgs, enhance }) => {
|
|
20
21
|
const mesh = await requireMesh(pool, meshId);
|
|
22
|
+
await mustGetActiveAgent(mesh, agentId);
|
|
21
23
|
const parentId = parentRunId ? await parentRequestId(mesh, chatId, parentRunId) : undefined;
|
|
22
24
|
await appendChunk(mesh, {
|
|
23
25
|
chatId,
|
|
@@ -31,6 +31,7 @@ export interface AssistantOptions {
|
|
|
31
31
|
drives?: DriveHost;
|
|
32
32
|
borrowHarness?: (deviceId: string) => Duplex;
|
|
33
33
|
blobReadTimeoutMs?: number;
|
|
34
|
+
runIdleTimeoutMs?: number;
|
|
34
35
|
pdfRasterizer?: PdfRasterizer;
|
|
35
36
|
}
|
|
36
37
|
export interface SkillListOptions extends SkillOptions {
|
|
@@ -51,6 +52,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
51
52
|
private readonly _preloadCurrentAgentModel;
|
|
52
53
|
private readonly _drives?;
|
|
53
54
|
private readonly _blobReadTimeoutMs;
|
|
55
|
+
private readonly _runIdleTimeoutMs;
|
|
54
56
|
private readonly _pdfRasterizer;
|
|
55
57
|
private readonly _warmAbort;
|
|
56
58
|
private readonly _unloading;
|
|
@@ -99,7 +101,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
99
101
|
private readonly _modelCatalog;
|
|
100
102
|
private readonly _onHarnessStatus;
|
|
101
103
|
private readonly _onModelCatalogEvent;
|
|
102
|
-
constructor(engine: Capabilities, harness: Harness, { logger, imageCacheDir, inferenceCallsDir, runReplayDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform, preloadCurrentAgentModel, drives, borrowHarness, blobReadTimeoutMs, pdfRasterizer: pdfRasterizerOption }?: AssistantOptions);
|
|
104
|
+
constructor(engine: Capabilities, harness: Harness, { logger, imageCacheDir, inferenceCallsDir, runReplayDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform, preloadCurrentAgentModel, drives, borrowHarness, blobReadTimeoutMs, runIdleTimeoutMs, pdfRasterizer: pdfRasterizerOption }?: AssistantOptions);
|
|
103
105
|
private _requireDeviceId;
|
|
104
106
|
_open(): Promise<void>;
|
|
105
107
|
private _triggerModelWarm;
|
|
@@ -41,6 +41,7 @@ import { AbortedError, raceAbort } from '@qvac/harness/race-abort';
|
|
|
41
41
|
import { RunTranscript } from './run-transcript.js';
|
|
42
42
|
import { searchKnowledge } from './knowledge-search.js';
|
|
43
43
|
import { isLifecycleTeardown, knownAbortOutcome, RUN_ABORT_REASONS, RUN_FAILURE_REASONS, runFailureNotice } from './run-notices.js';
|
|
44
|
+
import { unref } from './unref.js';
|
|
44
45
|
import { encodeAgentSkillReadiness } from './skill-readiness.js';
|
|
45
46
|
import { harnessClearKvCache, harnessDeathReason, harnessDeleteModel, harnessDied, harnessListModels, harnessPreviewModelSource, harnessSkillCatalog, harnessSkillManagement, harnessDetectLanguage, harnessSpeak, harnessSpeakStream, harnessTools, harnessTranscribe, heldLoadModel, droppedHeldLoadModel, imageDownloadProgress, isHarnessEvent, modelCatalogChanged, toolReportEntry } from './assistant/harness.js';
|
|
46
47
|
import { annotateUnreadableImages, audioTranscriptBlock, backfillDocumentOnlyTurn, backfillImageOnlyTurns, silentAudioNotice, unheardAudioNotice, nameSenders } from './assistant/message.js';
|
|
@@ -57,6 +58,33 @@ const DEFAULT_PROFILE = 'mid';
|
|
|
57
58
|
const QvacState = local.getEnum('@local/qvac-state');
|
|
58
59
|
const FINAL_FLUSH_MS = 10_000;
|
|
59
60
|
const UPLOAD_FRAME_BYTES = 64 * 1024;
|
|
61
|
+
const RUN_IDLE_TIMEOUT_MS = 15 * 60_000;
|
|
62
|
+
function idleWatch(controller, ms) {
|
|
63
|
+
let last = 0;
|
|
64
|
+
let parked = 0;
|
|
65
|
+
const timer = setInterval(() => {
|
|
66
|
+
if (last && !parked && Date.now() - last >= ms) {
|
|
67
|
+
controller.abort(RUN_ABORT_REASONS.stalled);
|
|
68
|
+
}
|
|
69
|
+
}, Math.min(ms, 30_000));
|
|
70
|
+
unref(timer);
|
|
71
|
+
return {
|
|
72
|
+
touch: () => {
|
|
73
|
+
last = Date.now();
|
|
74
|
+
},
|
|
75
|
+
parks: (fn) => async (...args) => {
|
|
76
|
+
parked++;
|
|
77
|
+
try {
|
|
78
|
+
return await fn(...args);
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
parked--;
|
|
82
|
+
last = Date.now();
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
stop: () => clearInterval(timer)
|
|
86
|
+
};
|
|
87
|
+
}
|
|
60
88
|
function settledWithin(write, ms) {
|
|
61
89
|
let timer;
|
|
62
90
|
const expired = new Promise((resolve) => {
|
|
@@ -148,6 +176,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
148
176
|
_preloadCurrentAgentModel;
|
|
149
177
|
_drives;
|
|
150
178
|
_blobReadTimeoutMs;
|
|
179
|
+
_runIdleTimeoutMs;
|
|
151
180
|
_pdfRasterizer;
|
|
152
181
|
_warmAbort = new AbortController();
|
|
153
182
|
_unloading = new Map();
|
|
@@ -196,7 +225,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
196
225
|
_modelCatalog = new ModelCatalogRevisionHub();
|
|
197
226
|
_onHarnessStatus;
|
|
198
227
|
_onModelCatalogEvent;
|
|
199
|
-
constructor(engine, harness, { logger = null, imageCacheDir, inferenceCallsDir, runReplayDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform = os.platform(), preloadCurrentAgentModel = true, drives, borrowHarness, blobReadTimeoutMs = BLOB_READ_TIMEOUT_MS, pdfRasterizer: pdfRasterizerOption } = {}) {
|
|
228
|
+
constructor(engine, harness, { logger = null, imageCacheDir, inferenceCallsDir, runReplayDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform = os.platform(), preloadCurrentAgentModel = true, drives, borrowHarness, blobReadTimeoutMs = BLOB_READ_TIMEOUT_MS, runIdleTimeoutMs = RUN_IDLE_TIMEOUT_MS, pdfRasterizer: pdfRasterizerOption } = {}) {
|
|
200
229
|
super();
|
|
201
230
|
this._engine = engine;
|
|
202
231
|
this._harness = harness;
|
|
@@ -211,6 +240,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
211
240
|
this._mobileClass = isMobilePlatform(platform);
|
|
212
241
|
this._preloadCurrentAgentModel = preloadCurrentAgentModel;
|
|
213
242
|
this._blobReadTimeoutMs = blobReadTimeoutMs;
|
|
243
|
+
this._runIdleTimeoutMs = runIdleTimeoutMs;
|
|
214
244
|
this._pdfRasterizer = pdfRasterizerOption ?? createPdfRasterizer(logger);
|
|
215
245
|
this._deviceId = null;
|
|
216
246
|
this._info = { toolNames: [], skills: [], supportsImages: false };
|
|
@@ -1729,6 +1759,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1729
1759
|
agentId: agent.id,
|
|
1730
1760
|
hasRun: () => ran
|
|
1731
1761
|
});
|
|
1762
|
+
const idle = idleWatch(controller, this._runIdleTimeoutMs);
|
|
1732
1763
|
const modelWatch = this._watchModelProgress((runStatus) => transcript.progress(runStatusId, runStatus), busyChatId !== null);
|
|
1733
1764
|
let metrics;
|
|
1734
1765
|
const sourceTagFilter = createRagSourceTagFilter();
|
|
@@ -1889,6 +1920,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1889
1920
|
const input = nameSenders(messages);
|
|
1890
1921
|
inputLength = input.length;
|
|
1891
1922
|
const inspecting = await this._capturingInferenceCalls();
|
|
1923
|
+
idle.touch();
|
|
1892
1924
|
const events = this._harnessFor(runAgent).completion({
|
|
1893
1925
|
model,
|
|
1894
1926
|
agent: runAgent,
|
|
@@ -1902,7 +1934,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1902
1934
|
grantedDrives,
|
|
1903
1935
|
driveOp,
|
|
1904
1936
|
grantedWriteDirs: write,
|
|
1905
|
-
approve: approvals.approve,
|
|
1937
|
+
approve: idle.parks(approvals.approve),
|
|
1906
1938
|
attach: (input) => this._uploadGenerated(input, { meshId, chatId, runId, deviceId }),
|
|
1907
1939
|
fetchAttachment: (query) => this._fetchAttachment(engine, chatId, query),
|
|
1908
1940
|
ragSearch: async (input) => {
|
|
@@ -1939,7 +1971,10 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1939
1971
|
hits
|
|
1940
1972
|
};
|
|
1941
1973
|
},
|
|
1942
|
-
progress: (update) =>
|
|
1974
|
+
progress: (update) => {
|
|
1975
|
+
idle.touch();
|
|
1976
|
+
modelWatch.image(update);
|
|
1977
|
+
},
|
|
1943
1978
|
generationParams: diagramRepair ? { reasoning_budget: 0 } : undefined,
|
|
1944
1979
|
captureInferenceCalls: true,
|
|
1945
1980
|
signal: controller.signal
|
|
@@ -1947,6 +1982,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1947
1982
|
let harnessEvents = 0;
|
|
1948
1983
|
for await (const event of events) {
|
|
1949
1984
|
harnessEvents++;
|
|
1985
|
+
idle.touch();
|
|
1950
1986
|
modelWatch.clear();
|
|
1951
1987
|
if (isHarnessEvent(event, 'content') || isHarnessEvent(event, 'thinking')) {
|
|
1952
1988
|
await writeText(event.type, event.text);
|
|
@@ -2076,6 +2112,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
2076
2112
|
})
|
|
2077
2113
|
.catch((err) => this._log?.warn('assistant', 'run outcome not recorded', { err }));
|
|
2078
2114
|
transcript.close();
|
|
2115
|
+
idle.stop();
|
|
2079
2116
|
modelWatch.stop();
|
|
2080
2117
|
ownershipWatch.stop();
|
|
2081
2118
|
await approvals.settle({ preservePending: isLifecycleTeardown(controller.signal.reason) });
|
|
@@ -12,4 +12,8 @@ export declare function mustGetActiveAgent(store: Mesh, id: string): Promise<Qva
|
|
|
12
12
|
export declare function createAgent(store: Mesh, input: AssistantAgentConfig): Promise<QvacAgent>;
|
|
13
13
|
export declare function updateAgent(store: Mesh, agentId: string, input: AssistantAgentUpdateConfig): Promise<QvacAgent>;
|
|
14
14
|
export declare function rehomeAgents(store: Mesh, from: Buffer, to: Buffer): Promise<void>;
|
|
15
|
-
export
|
|
15
|
+
export interface DeleteAgentInput {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly keepChats?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function deleteAgent(store: Mesh, deviceId: Buffer | null, { id, keepChats }: DeleteAgentInput): Promise<QvacAgent>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { softDeleteChatsForAgent } from './chat.js';
|
|
1
|
+
import { cancelRunsForAgent, softDeleteChatsForAgent } from './chat.js';
|
|
2
2
|
import { randomId } from './id.js';
|
|
3
3
|
import { softDeleteToolConfigsForAgent } from './tool-configs.js';
|
|
4
4
|
import b4a from 'b4a';
|
|
@@ -201,7 +201,7 @@ export async function rehomeAgents(store, from, to) {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
export async function deleteAgent(store, deviceId, id) {
|
|
204
|
+
export async function deleteAgent(store, deviceId, { id, keepChats }) {
|
|
205
205
|
const current = await mustGetAgent(store, id);
|
|
206
206
|
if (current.isDefault) {
|
|
207
207
|
throw new CoreError('AGENT_DEFAULT_UNDELETABLE');
|
|
@@ -213,7 +213,12 @@ export async function deleteAgent(store, deviceId, id) {
|
|
|
213
213
|
updatedAt: Math.max(deletedAt, current.updatedAt + 1)
|
|
214
214
|
};
|
|
215
215
|
await store.dispatch('put-agent', { agent: updated });
|
|
216
|
-
|
|
216
|
+
if (!keepChats) {
|
|
217
|
+
await softDeleteChatsForAgent(store, deviceId, id);
|
|
218
|
+
}
|
|
219
|
+
else if (deviceId) {
|
|
220
|
+
await cancelRunsForAgent(store, deviceId, id);
|
|
221
|
+
}
|
|
217
222
|
await softDeleteToolConfigsForAgent(store, id);
|
|
218
223
|
return updated;
|
|
219
224
|
}
|
|
@@ -44,8 +44,9 @@ export declare function markChatRead(store: Mesh, id: string): Promise<ChatListi
|
|
|
44
44
|
export interface CancelActiveRunsOptions {
|
|
45
45
|
readonly deviceId: Buffer;
|
|
46
46
|
readonly reason?: string;
|
|
47
|
+
readonly agentId?: string;
|
|
47
48
|
}
|
|
48
|
-
export declare function cancelActiveRuns(store: Mesh, chatId: string, { deviceId, reason }: CancelActiveRunsOptions): Promise<string[]>;
|
|
49
|
+
export declare function cancelActiveRuns(store: Mesh, chatId: string, { deviceId, reason, agentId }: CancelActiveRunsOptions): Promise<string[]>;
|
|
49
50
|
export declare function removeChatKnowledge(store: Mesh, chatId: string, at: number): Promise<void>;
|
|
50
51
|
export interface RemoveChatAttachmentsOptions {
|
|
51
52
|
readonly deviceId: Buffer;
|
|
@@ -54,3 +55,4 @@ export interface RemoveChatAttachmentsOptions {
|
|
|
54
55
|
export declare function removeChatAttachments(store: Mesh, chatId: string, { deviceId, at }: RemoveChatAttachmentsOptions): Promise<void>;
|
|
55
56
|
export declare function deleteChat(store: Mesh, deviceId: Buffer | null, id: string): Promise<ChatListing>;
|
|
56
57
|
export declare function softDeleteChatsForAgent(store: Mesh, deviceId: Buffer | null, agentId: string): Promise<void>;
|
|
58
|
+
export declare function cancelRunsForAgent(store: Mesh, deviceId: Buffer, agentId: string): Promise<void>;
|
|
@@ -226,11 +226,12 @@ export async function markChatRead(store, id) {
|
|
|
226
226
|
await store.dispatch('put-chat', { chat: read });
|
|
227
227
|
return enrichChat(store, read);
|
|
228
228
|
}
|
|
229
|
-
export async function cancelActiveRuns(store, chatId, { deviceId, reason }) {
|
|
229
|
+
export async function cancelActiveRuns(store, chatId, { deviceId, reason, agentId }) {
|
|
230
230
|
const statuses = await listChunks(store, { chatId, type: 'run-status' });
|
|
231
231
|
const terminal = new Set(statuses.filter((c) => TERMINAL_RUN_STATES.has(c.runStatus?.state ?? '')).map((c) => c.runId));
|
|
232
232
|
const requests = await listChunks(store, { chatId, type: 'run-request' });
|
|
233
|
-
const
|
|
233
|
+
const asked = agentId ? requests.filter((c) => c.runRequest?.agentId === agentId) : requests;
|
|
234
|
+
const runIds = new Set(asked.map((c) => c.runId).filter((id) => Boolean(id)));
|
|
234
235
|
const canceled = [];
|
|
235
236
|
const batch = store.batch();
|
|
236
237
|
for (const runId of runIds) {
|
|
@@ -287,7 +288,13 @@ export async function deleteChat(store, deviceId, id) {
|
|
|
287
288
|
await reclaimReferences(store, references).catch((err) => store.log?.warn('sync', "reclaiming a deleted chat's files failed", { id, err }));
|
|
288
289
|
return listing;
|
|
289
290
|
}
|
|
290
|
-
export
|
|
291
|
+
export function softDeleteChatsForAgent(store, deviceId, agentId) {
|
|
292
|
+
return eachChatOfAgent(store, agentId, (chatId) => deleteChat(store, deviceId, chatId));
|
|
293
|
+
}
|
|
294
|
+
export function cancelRunsForAgent(store, deviceId, agentId) {
|
|
295
|
+
return eachChatOfAgent(store, agentId, (chatId) => cancelActiveRuns(store, chatId, { deviceId, agentId }));
|
|
296
|
+
}
|
|
297
|
+
async function eachChatOfAgent(store, agentId, fn) {
|
|
291
298
|
const snap = store.view.snapshot();
|
|
292
299
|
try {
|
|
293
300
|
for await (const chat of snap.find(ACTIVE_CHATS_BY_AGENT, {
|
|
@@ -296,7 +303,7 @@ export async function softDeleteChatsForAgent(store, deviceId, agentId) {
|
|
|
296
303
|
})) {
|
|
297
304
|
if (store.closing)
|
|
298
305
|
return;
|
|
299
|
-
await
|
|
306
|
+
await fn(chat.id);
|
|
300
307
|
}
|
|
301
308
|
}
|
|
302
309
|
finally {
|
|
@@ -61,6 +61,7 @@ export interface RecordDepartureOptions {
|
|
|
61
61
|
}
|
|
62
62
|
export interface AdoptAccountMeshOptions {
|
|
63
63
|
readonly account?: Buffer | null;
|
|
64
|
+
readonly keepName?: boolean;
|
|
64
65
|
}
|
|
65
66
|
export interface MarkAwaitingAdmissionOptions {
|
|
66
67
|
readonly awaitingAdmission: boolean;
|
|
@@ -129,7 +130,7 @@ declare class LocalStore {
|
|
|
129
130
|
markAwaitingAdmission(key: Buffer, opts: MarkAwaitingAdmissionOptions): Promise<void>;
|
|
130
131
|
awaitsAdmission(key: Buffer): Promise<boolean>;
|
|
131
132
|
markMeshMigrated(key: Buffer, migratedAt: number): Promise<void>;
|
|
132
|
-
adoptAccountMesh(deviceId: Buffer, key: Buffer, { account }: AdoptAccountMeshOptions): Promise<void>;
|
|
133
|
+
adoptAccountMesh(deviceId: Buffer, key: Buffer, { account, keepName }: AdoptAccountMeshOptions): Promise<void>;
|
|
133
134
|
private _pointersAt;
|
|
134
135
|
listMeshes(): Promise<LocalMeshMembership[]>;
|
|
135
136
|
listArchivedMeshes(): Promise<ArchivedMeshMembership[]>;
|
|
@@ -615,7 +615,7 @@ class LocalStore {
|
|
|
615
615
|
await tx.flush();
|
|
616
616
|
});
|
|
617
617
|
}
|
|
618
|
-
adoptAccountMesh(deviceId, key, { account }) {
|
|
618
|
+
adoptAccountMesh(deviceId, key, { account, keepName }) {
|
|
619
619
|
return this._locked(async () => {
|
|
620
620
|
const departed = [];
|
|
621
621
|
for await (const row of this._db.find(LOCAL_MESH_MEMBERSHIP)) {
|
|
@@ -632,6 +632,14 @@ class LocalStore {
|
|
|
632
632
|
await dropMeshFiles(tx, row.key);
|
|
633
633
|
await tx.delete(LOCAL_MESH_UPDATES, { meshKey: row.key });
|
|
634
634
|
}
|
|
635
|
+
const identity = await tx.get(LOCAL_IDENTITY, { id: IDENTITY_ID });
|
|
636
|
+
if (!keepName && identity?.displayName) {
|
|
637
|
+
await tx.insert(LOCAL_IDENTITY, {
|
|
638
|
+
...identity,
|
|
639
|
+
displayName: null,
|
|
640
|
+
displayNameAt: 0
|
|
641
|
+
});
|
|
642
|
+
}
|
|
635
643
|
await tx.insert(LOCAL_ACTIVE_MESH, { deviceId, homeMeshKey: key });
|
|
636
644
|
await tx.flush();
|
|
637
645
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CoreError } from '../errors.js';
|
|
2
|
+
import { mustGetActiveAgent } from './agent.js';
|
|
2
3
|
import { buildChat, enrichChat, mustGetActiveChat } from './chat.js';
|
|
3
4
|
import { appendChunk, listChunks } from './chunk.js';
|
|
4
5
|
import { randomId } from './id.js';
|
|
@@ -8,6 +9,7 @@ export async function sendMessage(mesh, input) {
|
|
|
8
9
|
if (!agentId) {
|
|
9
10
|
throw new CoreError('SEND_AGENT_REQUIRED');
|
|
10
11
|
}
|
|
12
|
+
await mustGetActiveAgent(mesh, agentId);
|
|
11
13
|
const chat = existing ?? buildChat({ agentId, title: input.title ?? '' });
|
|
12
14
|
const chatId = chat.id;
|
|
13
15
|
const parentId = input.parentRunId
|
package/dist-lib/lib/core.d.ts
CHANGED
|
@@ -457,6 +457,7 @@ export declare class Core extends ReadyResource {
|
|
|
457
457
|
private _meshHoldingChat;
|
|
458
458
|
private _serveSkillOverlayOp;
|
|
459
459
|
private _runLocalSkillOverlayOp;
|
|
460
|
+
private _forgetSkillBodies;
|
|
460
461
|
private _setupFields;
|
|
461
462
|
private _hostSkills;
|
|
462
463
|
private _onConnection;
|
package/dist-lib/lib/core.js
CHANGED
|
@@ -2099,12 +2099,13 @@ export class Core extends ReadyResource {
|
|
|
2099
2099
|
source,
|
|
2100
2100
|
deviceId,
|
|
2101
2101
|
memberInvite: !!invite.memberInvite,
|
|
2102
|
+
recovery: !!invite.recovery,
|
|
2102
2103
|
appended
|
|
2103
2104
|
});
|
|
2104
2105
|
}
|
|
2105
|
-
async _landJoinedMesh(candidate, { source, deviceId, memberInvite, appended }) {
|
|
2106
|
+
async _landJoinedMesh(candidate, { source, deviceId, memberInvite, recovery, appended }) {
|
|
2106
2107
|
if (!memberInvite) {
|
|
2107
|
-
await this._departOldAccount(candidate.key, source);
|
|
2108
|
+
await this._departOldAccount(candidate.key, source, { keepName: recovery });
|
|
2108
2109
|
}
|
|
2109
2110
|
if (this._blockedByMinVersion()) {
|
|
2110
2111
|
if (!memberInvite) {
|
|
@@ -2140,7 +2141,7 @@ export class Core extends ReadyResource {
|
|
|
2140
2141
|
this.emit('mesh-changed', candidate);
|
|
2141
2142
|
return candidate;
|
|
2142
2143
|
}
|
|
2143
|
-
async _departOldAccount(joined, source) {
|
|
2144
|
+
async _departOldAccount(joined, source, { keepName }) {
|
|
2144
2145
|
const account = (await this._storedAccountKey()) ?? source?.key;
|
|
2145
2146
|
if (account && b4a.equals(account, joined)) {
|
|
2146
2147
|
return;
|
|
@@ -2150,7 +2151,10 @@ export class Core extends ReadyResource {
|
|
|
2150
2151
|
for (const mesh of meshes) {
|
|
2151
2152
|
await this._departIfPooled(mesh.key, 'mesh');
|
|
2152
2153
|
}
|
|
2153
|
-
await this.local.adoptAccountMesh(this._requireDeviceKeyPair().publicKey, joined, {
|
|
2154
|
+
await this.local.adoptAccountMesh(this._requireDeviceKeyPair().publicKey, joined, {
|
|
2155
|
+
account,
|
|
2156
|
+
keepName
|
|
2157
|
+
});
|
|
2154
2158
|
if (account) {
|
|
2155
2159
|
await this._departIfPooled(account, 'account');
|
|
2156
2160
|
}
|
|
@@ -3188,7 +3192,15 @@ export class Core extends ReadyResource {
|
|
|
3188
3192
|
}
|
|
3189
3193
|
}
|
|
3190
3194
|
async openMesh(meshId) {
|
|
3191
|
-
|
|
3195
|
+
if (!this.opened)
|
|
3196
|
+
await this.ready();
|
|
3197
|
+
await this._meshTransitionLock.lock();
|
|
3198
|
+
try {
|
|
3199
|
+
await this._openPooledMesh(meshId);
|
|
3200
|
+
}
|
|
3201
|
+
finally {
|
|
3202
|
+
this._meshTransitionLock.unlock();
|
|
3203
|
+
}
|
|
3192
3204
|
}
|
|
3193
3205
|
async closeMesh(meshId) {
|
|
3194
3206
|
if (!this.opened)
|
|
@@ -4035,22 +4047,36 @@ export class Core extends ReadyResource {
|
|
|
4035
4047
|
const res = (await mgmt?.readSkillFile(op.name ?? '')) ?? { found: false };
|
|
4036
4048
|
return { found: res.found ?? false, content: res.content, origin: res.origin };
|
|
4037
4049
|
}
|
|
4038
|
-
case 'write':
|
|
4039
|
-
|
|
4040
|
-
ok:
|
|
4050
|
+
case 'write': {
|
|
4051
|
+
const { ok } = (await mgmt?.writeSkillFile(op.name ?? '', op.content ?? '')) ?? {
|
|
4052
|
+
ok: false
|
|
4041
4053
|
};
|
|
4054
|
+
if (ok) {
|
|
4055
|
+
await this._forgetSkillBodies();
|
|
4056
|
+
}
|
|
4057
|
+
return { ok };
|
|
4058
|
+
}
|
|
4042
4059
|
case 'copy':
|
|
4043
4060
|
return {
|
|
4044
4061
|
copied: ((await mgmt?.copySkillForEdit(op.name ?? '')) ?? { copied: false }).copied
|
|
4045
4062
|
};
|
|
4046
|
-
case 'delete':
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4063
|
+
case 'delete': {
|
|
4064
|
+
const { removed } = (await mgmt?.deleteOverlaySkill(op.name ?? '')) ?? { removed: false };
|
|
4065
|
+
if (removed) {
|
|
4066
|
+
await this._forgetSkillBodies();
|
|
4067
|
+
}
|
|
4068
|
+
return { removed };
|
|
4069
|
+
}
|
|
4050
4070
|
default:
|
|
4051
4071
|
throw new CoreError('SKILL_OVERLAY_OP_UNKNOWN', [op.op]);
|
|
4052
4072
|
}
|
|
4053
4073
|
}
|
|
4074
|
+
async _forgetSkillBodies() {
|
|
4075
|
+
const result = await this._clearKvCache?.();
|
|
4076
|
+
if (result?.status === 'failure') {
|
|
4077
|
+
this._log?.warn('skills', 'kv caches not cleared after a skill edit', { error: result.error });
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4054
4080
|
async _setupFields(skillName) {
|
|
4055
4081
|
const skills = await this._hostSkills();
|
|
4056
4082
|
if (skills.length === 0) {
|
|
@@ -5,12 +5,14 @@ export declare const RUN_ABORT_REASONS: {
|
|
|
5
5
|
readonly runnerDied: 'runner-died';
|
|
6
6
|
readonly runnerClosed: 'runner-closed';
|
|
7
7
|
readonly modelUnloaded: 'model-unloaded';
|
|
8
|
+
readonly stalled: 'stalled';
|
|
8
9
|
};
|
|
9
10
|
export type RunAbortReason = (typeof RUN_ABORT_REASONS)[keyof typeof RUN_ABORT_REASONS];
|
|
10
11
|
export declare const RUN_FAILURE_REASONS: {
|
|
11
12
|
readonly harnessDied: 'the model runtime died';
|
|
12
13
|
readonly runtimeEndedTurn: 'the model runtime ended this turn';
|
|
13
14
|
readonly capabilityUnavailable: 'this device cannot run a capability without a model';
|
|
15
|
+
readonly stalled: 'the agent stopped responding';
|
|
14
16
|
};
|
|
15
17
|
export type AbortOutcome = {
|
|
16
18
|
readonly kind: 'replay';
|
|
@@ -4,12 +4,14 @@ export const RUN_ABORT_REASONS = {
|
|
|
4
4
|
runSettled: 'run-settled',
|
|
5
5
|
runnerDied: 'runner-died',
|
|
6
6
|
runnerClosed: 'runner-closed',
|
|
7
|
-
modelUnloaded: 'model-unloaded'
|
|
7
|
+
modelUnloaded: 'model-unloaded',
|
|
8
|
+
stalled: 'stalled'
|
|
8
9
|
};
|
|
9
10
|
export const RUN_FAILURE_REASONS = {
|
|
10
11
|
harnessDied: 'the model runtime died',
|
|
11
12
|
runtimeEndedTurn: 'the model runtime ended this turn',
|
|
12
|
-
capabilityUnavailable: 'this device cannot run a capability without a model'
|
|
13
|
+
capabilityUnavailable: 'this device cannot run a capability without a model',
|
|
14
|
+
stalled: 'the agent stopped responding'
|
|
13
15
|
};
|
|
14
16
|
export function knownAbortOutcome(reason) {
|
|
15
17
|
if (reason === RUN_ABORT_REASONS.suspended ||
|
|
@@ -23,6 +25,9 @@ export function knownAbortOutcome(reason) {
|
|
|
23
25
|
if (reason === RUN_ABORT_REASONS.runnerDied) {
|
|
24
26
|
return { kind: 'failed', reason: RUN_FAILURE_REASONS.harnessDied };
|
|
25
27
|
}
|
|
28
|
+
if (reason === RUN_ABORT_REASONS.stalled) {
|
|
29
|
+
return { kind: 'failed', reason: RUN_FAILURE_REASONS.stalled };
|
|
30
|
+
}
|
|
26
31
|
return null;
|
|
27
32
|
}
|
|
28
33
|
export function isLifecycleTeardown(reason) {
|
|
@@ -2159,6 +2159,14 @@ export function registerEngineTypes(ns) {
|
|
|
2159
2159
|
]
|
|
2160
2160
|
});
|
|
2161
2161
|
ns.register({ name: 'device-scope', fields: [{ name: 'deviceId', type: 'fixed32' }] });
|
|
2162
|
+
ns.register({
|
|
2163
|
+
name: 'delete-agent-request',
|
|
2164
|
+
fields: [
|
|
2165
|
+
{ name: 'agentId', type: 'string', required: true },
|
|
2166
|
+
{ name: 'meshId', type: 'string', required: true },
|
|
2167
|
+
{ name: 'keepChats', type: 'bool' }
|
|
2168
|
+
]
|
|
2169
|
+
});
|
|
2162
2170
|
}
|
|
2163
2171
|
export function registerEngineApi(api) {
|
|
2164
2172
|
api.register({
|
|
@@ -2198,7 +2206,7 @@ export function registerEngineApi(api) {
|
|
|
2198
2206
|
});
|
|
2199
2207
|
api.register({
|
|
2200
2208
|
name: 'delete-agent',
|
|
2201
|
-
request: { name: '@assistant/agent-
|
|
2209
|
+
request: { name: '@assistant/delete-agent-request', stream: false },
|
|
2202
2210
|
response: { name: '@assistant/agent', stream: false }
|
|
2203
2211
|
});
|
|
2204
2212
|
api.register({
|
|
@@ -35,7 +35,7 @@ export interface Capabilities {
|
|
|
35
35
|
listAgents(input: T.AssistantListAgentsRequest): Promise<T.AssistantAgentList>
|
|
36
36
|
getAgent(input: T.AssistantAgentId): Promise<T.AssistantAgent>
|
|
37
37
|
updateAgent(input: T.AssistantUpdateAgentRequest): Promise<T.AssistantAgent>
|
|
38
|
-
deleteAgent(input: T.
|
|
38
|
+
deleteAgent(input: T.AssistantDeleteAgentRequest): Promise<T.AssistantAgent>
|
|
39
39
|
agentsWatch(input: T.AssistantListAgentsRequest): WatchStream<T.AssistantAgentList>
|
|
40
40
|
createChat(input: T.AssistantCreateChatRequest): Promise<T.AssistantChat>
|
|
41
41
|
listChats(input: T.AssistantListChatsRequest): Promise<T.AssistantChatList>
|
|
@@ -199,7 +199,7 @@ export interface CapabilityHandlers {
|
|
|
199
199
|
listAgents(input: T.AssistantListAgentsRequest): T.AssistantAgentList | Promise<T.AssistantAgentList>
|
|
200
200
|
getAgent(input: T.AssistantAgentId): T.AssistantAgent | Promise<T.AssistantAgent>
|
|
201
201
|
updateAgent(input: T.AssistantUpdateAgentRequest): T.AssistantAgent | Promise<T.AssistantAgent>
|
|
202
|
-
deleteAgent(input: T.
|
|
202
|
+
deleteAgent(input: T.AssistantDeleteAgentRequest): T.AssistantAgent | Promise<T.AssistantAgent>
|
|
203
203
|
agentsWatch(input: T.AssistantListAgentsRequest): AsyncIterable<T.AssistantAgentList>
|
|
204
204
|
createChat(input: T.AssistantCreateChatRequest): T.AssistantChat | Promise<T.AssistantChat>
|
|
205
205
|
listChats(input: T.AssistantListChatsRequest): T.AssistantChatList | Promise<T.AssistantChatList>
|
|
@@ -342,7 +342,7 @@ class HRPC {
|
|
|
342
342
|
['@assistant/list-agents', getEncoding('@assistant/list-agents-request')],
|
|
343
343
|
['@assistant/get-agent', getEncoding('@assistant/agent-id')],
|
|
344
344
|
['@assistant/update-agent', getEncoding('@assistant/update-agent-request')],
|
|
345
|
-
['@assistant/delete-agent', getEncoding('@assistant/agent-
|
|
345
|
+
['@assistant/delete-agent', getEncoding('@assistant/delete-agent-request')],
|
|
346
346
|
['@assistant/agents-watch', getEncoding('@assistant/list-agents-request')],
|
|
347
347
|
['@assistant/create-chat', getEncoding('@assistant/create-chat-request')],
|
|
348
348
|
['@assistant/list-chats', getEncoding('@assistant/list-chats-request')],
|
|
@@ -10492,6 +10492,33 @@ const encoding303 = {
|
|
|
10492
10492
|
}
|
|
10493
10493
|
}
|
|
10494
10494
|
|
|
10495
|
+
// @assistant/delete-agent-request
|
|
10496
|
+
const encoding304 = {
|
|
10497
|
+
preencode(state, m) {
|
|
10498
|
+
c.string.preencode(state, m.agentId)
|
|
10499
|
+
c.string.preencode(state, m.meshId)
|
|
10500
|
+
state.end++ // max flag is 1 so always one byte
|
|
10501
|
+
},
|
|
10502
|
+
encode(state, m) {
|
|
10503
|
+
const flags = m.keepChats ? 1 : 0
|
|
10504
|
+
|
|
10505
|
+
c.string.encode(state, m.agentId)
|
|
10506
|
+
c.string.encode(state, m.meshId)
|
|
10507
|
+
c.uint.encode(state, flags)
|
|
10508
|
+
},
|
|
10509
|
+
decode(state) {
|
|
10510
|
+
const r0 = c.string.decode(state)
|
|
10511
|
+
const r1 = c.string.decode(state)
|
|
10512
|
+
const flags = c.uint.decode(state)
|
|
10513
|
+
|
|
10514
|
+
return {
|
|
10515
|
+
agentId: r0,
|
|
10516
|
+
meshId: r1,
|
|
10517
|
+
keepChats: (flags & 1) !== 0
|
|
10518
|
+
}
|
|
10519
|
+
}
|
|
10520
|
+
}
|
|
10521
|
+
|
|
10495
10522
|
// @assistant/model-info-list.memory, deferred due to recusive use
|
|
10496
10523
|
const encoding156_1 = c.frame(encoding302)
|
|
10497
10524
|
|
|
@@ -11200,6 +11227,8 @@ function getEncoding(name) {
|
|
|
11200
11227
|
return encoding302
|
|
11201
11228
|
case '@assistant/device-scope':
|
|
11202
11229
|
return encoding303
|
|
11230
|
+
case '@assistant/delete-agent-request':
|
|
11231
|
+
return encoding304
|
|
11203
11232
|
default:
|
|
11204
11233
|
throw new Error('Encoder not found ' + name)
|
|
11205
11234
|
}
|
|
@@ -10492,6 +10492,33 @@ const encoding303 = {
|
|
|
10492
10492
|
}
|
|
10493
10493
|
}
|
|
10494
10494
|
|
|
10495
|
+
// @assistant/delete-agent-request
|
|
10496
|
+
const encoding304 = {
|
|
10497
|
+
preencode(state, m) {
|
|
10498
|
+
c.string.preencode(state, m.agentId)
|
|
10499
|
+
c.string.preencode(state, m.meshId)
|
|
10500
|
+
state.end++ // max flag is 1 so always one byte
|
|
10501
|
+
},
|
|
10502
|
+
encode(state, m) {
|
|
10503
|
+
const flags = m.keepChats ? 1 : 0
|
|
10504
|
+
|
|
10505
|
+
c.string.encode(state, m.agentId)
|
|
10506
|
+
c.string.encode(state, m.meshId)
|
|
10507
|
+
c.uint.encode(state, flags)
|
|
10508
|
+
},
|
|
10509
|
+
decode(state) {
|
|
10510
|
+
const r0 = c.string.decode(state)
|
|
10511
|
+
const r1 = c.string.decode(state)
|
|
10512
|
+
const flags = c.uint.decode(state)
|
|
10513
|
+
|
|
10514
|
+
return {
|
|
10515
|
+
agentId: r0,
|
|
10516
|
+
meshId: r1,
|
|
10517
|
+
keepChats: (flags & 1) !== 0
|
|
10518
|
+
}
|
|
10519
|
+
}
|
|
10520
|
+
}
|
|
10521
|
+
|
|
10495
10522
|
// @assistant/model-info-list.memory, deferred due to recusive use
|
|
10496
10523
|
const encoding156_1 = c.frame(encoding302)
|
|
10497
10524
|
|
|
@@ -11200,6 +11227,8 @@ function getEncoding(name) {
|
|
|
11200
11227
|
return encoding302
|
|
11201
11228
|
case '@assistant/device-scope':
|
|
11202
11229
|
return encoding303
|
|
11230
|
+
case '@assistant/delete-agent-request':
|
|
11231
|
+
return encoding304
|
|
11203
11232
|
default:
|
|
11204
11233
|
throw new Error('Encoder not found ' + name)
|
|
11205
11234
|
}
|
|
@@ -8748,6 +8748,31 @@
|
|
|
8748
8748
|
"version": 1
|
|
8749
8749
|
}
|
|
8750
8750
|
]
|
|
8751
|
+
},
|
|
8752
|
+
{
|
|
8753
|
+
"name": "delete-agent-request",
|
|
8754
|
+
"namespace": "assistant",
|
|
8755
|
+
"compact": false,
|
|
8756
|
+
"flagsPosition": 2,
|
|
8757
|
+
"fields": [
|
|
8758
|
+
{
|
|
8759
|
+
"name": "agentId",
|
|
8760
|
+
"required": true,
|
|
8761
|
+
"type": "string",
|
|
8762
|
+
"version": 1
|
|
8763
|
+
},
|
|
8764
|
+
{
|
|
8765
|
+
"name": "meshId",
|
|
8766
|
+
"required": true,
|
|
8767
|
+
"type": "string",
|
|
8768
|
+
"version": 1
|
|
8769
|
+
},
|
|
8770
|
+
{
|
|
8771
|
+
"name": "keepChats",
|
|
8772
|
+
"type": "bool",
|
|
8773
|
+
"version": 1
|
|
8774
|
+
}
|
|
8775
|
+
]
|
|
8751
8776
|
}
|
|
8752
8777
|
]
|
|
8753
8778
|
}
|
|
@@ -1885,6 +1885,12 @@ export interface AssistantDeviceScope {
|
|
|
1885
1885
|
deviceId?: Buffer | null
|
|
1886
1886
|
}
|
|
1887
1887
|
|
|
1888
|
+
export interface AssistantDeleteAgentRequest {
|
|
1889
|
+
agentId: string
|
|
1890
|
+
meshId: string
|
|
1891
|
+
keepChats?: boolean
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1888
1894
|
export interface SchemaTypes {
|
|
1889
1895
|
"@assistant/empty": AssistantEmpty
|
|
1890
1896
|
"@assistant/ok-response": AssistantOkResponse
|
|
@@ -2190,4 +2196,5 @@ export interface SchemaTypes {
|
|
|
2190
2196
|
"@assistant/chunk-delta": AssistantChunkDelta
|
|
2191
2197
|
"@assistant/model-memory": AssistantModelMemory
|
|
2192
2198
|
"@assistant/device-scope": AssistantDeviceScope
|
|
2199
|
+
"@assistant/delete-agent-request": AssistantDeleteAgentRequest
|
|
2193
2200
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/core",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Peer-to-peer AI across your devices",
|
|
6
6
|
"engines": {
|
|
@@ -240,9 +240,9 @@
|
|
|
240
240
|
},
|
|
241
241
|
"dependencies": {
|
|
242
242
|
"@qvac/error": "^0.2.0",
|
|
243
|
-
"@qvac/harness": "^0.8.
|
|
243
|
+
"@qvac/harness": "^0.8.11",
|
|
244
244
|
"@qvac/logging": "^0.2.0",
|
|
245
|
-
"@qvac/skills": "0.1.
|
|
245
|
+
"@qvac/skills": "^0.1.16",
|
|
246
246
|
"asenion": "^0.1.0",
|
|
247
247
|
"autobee": "^2.11.8",
|
|
248
248
|
"b4a": "^1.9.0",
|
package/tui/README.md
CHANGED
|
@@ -105,6 +105,12 @@ QVAC_MODEL=Qwen3.5-4B-Q4_K_M duck
|
|
|
105
105
|
The bare `Qwen3.5-4B` is not a catalog name: it falls through to a registry
|
|
106
106
|
search whose first match is that model's mmproj file, which fails to load.
|
|
107
107
|
|
|
108
|
+
A GGUF of your own runs vision once it is added with its projector:
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
/models add visionpsy https://host/visionpsy-nano-460m-q8_0.gguf https://host/mmproj-visionpsy-nano-460m-q8.gguf
|
|
112
|
+
```
|
|
113
|
+
|
|
108
114
|
Logs (Core's own lines, and the sidecar child's piped stdout/stderr — the
|
|
109
115
|
llama.cpp and SDK output) go to `<storage.root>/assistant.log`, as they do on
|
|
110
116
|
desktop. Nothing is printed: the TUI owns the tty.
|
package/tui/app.mjs
CHANGED
|
@@ -288,7 +288,7 @@ const COMMANDS = [
|
|
|
288
288
|
},
|
|
289
289
|
{
|
|
290
290
|
name: 'add',
|
|
291
|
-
desc: '<label> <src|n> [tools|vision|thinking] — add a gguf url or path'
|
|
291
|
+
desc: '<label> <src|n> [mmproj] [tools|vision|thinking] — add a gguf url or path'
|
|
292
292
|
},
|
|
293
293
|
{ name: 'use', desc: '<name|label> — make a model the agent’s model' },
|
|
294
294
|
{
|
|
@@ -364,6 +364,7 @@ const MODEL_TYPES = new Set([
|
|
|
364
364
|
'vad',
|
|
365
365
|
'other'
|
|
366
366
|
])
|
|
367
|
+
const MODEL_ADD_FLAGS = new Set(['tools', 'vision', 'thinking'])
|
|
367
368
|
const MODEL_VERBS = new Set([
|
|
368
369
|
'custom',
|
|
369
370
|
'preview',
|
|
@@ -602,6 +603,22 @@ async function catalogRow(engine, name) {
|
|
|
602
603
|
return entry ? (catalog.find((m) => m.registryPath === entry.registryPath) ?? null) : null
|
|
603
604
|
}
|
|
604
605
|
|
|
606
|
+
// the harness guesses at a bare name it cannot place, and can land on another file
|
|
607
|
+
async function isListedModel(engine, name) {
|
|
608
|
+
if (/^(\/|~|\.|file:|https?:|registry:|pear:|hyper:)/.test(name)) {
|
|
609
|
+
return true
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
const { models } = await engine.listModels({})
|
|
613
|
+
if ((models ?? []).some((m) => m.name === name)) {
|
|
614
|
+
return true
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const { models: registry } = await engine.listModels({ fullRegistry: true })
|
|
618
|
+
|
|
619
|
+
return (registry ?? []).some((m) => m.name === name)
|
|
620
|
+
}
|
|
621
|
+
|
|
605
622
|
const notOursToUse = (device) =>
|
|
606
623
|
`/models use picks this agent's model, not ${device.name}'s — /device here first`
|
|
607
624
|
|
|
@@ -1171,7 +1188,7 @@ export function formatModelPreview(preview) {
|
|
|
1171
1188
|
|
|
1172
1189
|
if (!preview.src && preview.files?.length) {
|
|
1173
1190
|
return [
|
|
1174
|
-
'several models here — pick one by number: /models preview <n> · /models add <name> <n>',
|
|
1191
|
+
'several models here — pick one by number: /models preview <n> [mmproj] · /models add <name> <n> [mmproj]',
|
|
1175
1192
|
...preview.files.map(
|
|
1176
1193
|
(file, index) =>
|
|
1177
1194
|
` ${index + 1}. ${file.label} ${bytesToGb(file.sizeBytes) ?? 'size unknown'}\n ${file.src}`
|
|
@@ -1191,7 +1208,8 @@ export function formatModelPreview(preview) {
|
|
|
1191
1208
|
` context ${preview.contextLength ? formatTokenCount(preview.contextLength) : 'unknown'}`,
|
|
1192
1209
|
` ${[preview.taskType, preview.architecture].filter(Boolean).join(' · ') || 'task unknown'}`,
|
|
1193
1210
|
` license ${preview.license || 'unknown'}`,
|
|
1194
|
-
` fit ${fit}${reasons}
|
|
1211
|
+
` fit ${fit}${reasons}`,
|
|
1212
|
+
...(preview.mmprojSrc ? [` projector ${preview.mmprojSrc}`] : [])
|
|
1195
1213
|
].join('\n')
|
|
1196
1214
|
}
|
|
1197
1215
|
|
|
@@ -1864,6 +1882,7 @@ export class ChatApp {
|
|
|
1864
1882
|
this._customModels = new Map()
|
|
1865
1883
|
this._modelsDevice = null // set by /device: the account device the /models commands act on
|
|
1866
1884
|
this._pickableFiles = []
|
|
1885
|
+
this._previewedProjections = new Map() // src → the projector its last preview checked, for /models add
|
|
1867
1886
|
this._statusIterator = null
|
|
1868
1887
|
this._downloadsIterator = null
|
|
1869
1888
|
this.modelDownloads = new Map()
|
|
@@ -2452,7 +2471,7 @@ export class ChatApp {
|
|
|
2452
2471
|
' /models idle <never|minutes> · cap <percent> · settings — free loaded models after that long with no request, the share of memory they may fill, and both settings',
|
|
2453
2472
|
' /device [list] · /device use <n|name|id> · /device here — point /models at another device of this account, or back at this one',
|
|
2454
2473
|
' /models [type] — browse every model in the SDK registry; type is an SDK addon (llm, tts, whisper, embeddings, diffusion, …) or an alias (transcription, embedding, image); ↑/↓ move, space selects',
|
|
2455
|
-
' /models custom · preview <src|n> [mmproj] · add <label> <src|n> [tools|vision|thinking] · use <name|label> · remove <name|label> — check a GGUF by url or local path, add it, and pick it; its context window caps /ctx',
|
|
2474
|
+
' /models custom · preview <src|n> [mmproj] · add <label> <src|n> [mmproj] [tools|vision|thinking] · use <name|label> · remove <name|label> — check a GGUF by url or local path, add it, and pick it; its context window caps /ctx',
|
|
2456
2475
|
' /image [model <choice> | steps <n> | size <WxH> | reset] — the agent’s image-generation defaults',
|
|
2457
2476
|
'',
|
|
2458
2477
|
'Connections — a skill that needs an account or a token (Menu ▸ Agent ▸ Connections lists them with their state)',
|
|
@@ -2648,7 +2667,7 @@ export class ChatApp {
|
|
|
2648
2667
|
if (cmd === 'models') {
|
|
2649
2668
|
const raw = rest[0]?.toLowerCase()
|
|
2650
2669
|
const USAGE =
|
|
2651
|
-
'usage: /models [type] · custom · preview <src|n> [mmproj] · add <label> <src|n> [tools] [vision] [thinking] · use <name|label> · remove <name|label> · load <model> · unload <model> · delete <name> · download <name> · pause <name> · resume <name> · idle <never|minutes> · cap <percent> · settings'
|
|
2670
|
+
'usage: /models [type] · custom · preview <src|n> [mmproj] · add <label> <src|n> [mmproj] [tools] [vision] [thinking] · use <name|label> · remove <name|label> · load <model> · unload <model> · delete <name> · download <name> · pause <name> · resume <name> · idle <never|minutes> · cap <percent> · settings'
|
|
2652
2671
|
const models = this._modelsEngine()
|
|
2653
2672
|
const on = this._modelsDevice
|
|
2654
2673
|
const where = (text) => (on ? `${on.name}: ${text}` : text)
|
|
@@ -2765,8 +2784,9 @@ export class ChatApp {
|
|
|
2765
2784
|
const ctx =
|
|
2766
2785
|
m.contextLength > 0 ? formatTokenCount(m.contextLength) : 'ctx window unknown'
|
|
2767
2786
|
const about = [m.taskType, m.license].filter(Boolean).join(' · ')
|
|
2787
|
+
const projector = m.mmprojSrc ? `\n projector ${m.mmprojSrc}` : ''
|
|
2768
2788
|
|
|
2769
|
-
return `${m.label || m.name} ${m.name}\n ${m.src}\n ${ctx}${about ? ` · ${about}` : ''}`
|
|
2789
|
+
return `${m.label || m.name} ${m.name}\n ${m.src}${projector}\n ${ctx}${about ? ` · ${about}` : ''}`
|
|
2770
2790
|
})
|
|
2771
2791
|
.join('\n')
|
|
2772
2792
|
)
|
|
@@ -2779,12 +2799,16 @@ export class ChatApp {
|
|
|
2779
2799
|
return notice(USAGE)
|
|
2780
2800
|
}
|
|
2781
2801
|
|
|
2802
|
+
const mmprojSrc = rest[2]
|
|
2803
|
+
|
|
2782
2804
|
return run(async () => {
|
|
2783
|
-
const preview = await models.previewCustomModel({ src, mmprojSrc
|
|
2805
|
+
const preview = await models.previewCustomModel({ src, mmprojSrc })
|
|
2784
2806
|
if (!preview.src && preview.files?.length) {
|
|
2785
2807
|
this._pickableFiles = preview.files
|
|
2786
2808
|
}
|
|
2787
2809
|
|
|
2810
|
+
this._previewedProjections.set(src, preview.mmprojSrc)
|
|
2811
|
+
|
|
2788
2812
|
return where(formatModelPreview(preview))
|
|
2789
2813
|
})
|
|
2790
2814
|
}
|
|
@@ -2792,18 +2816,20 @@ export class ChatApp {
|
|
|
2792
2816
|
if (raw === 'add') {
|
|
2793
2817
|
const label = rest[1]
|
|
2794
2818
|
const src = this._pickedSource(rest[2])
|
|
2795
|
-
|
|
2819
|
+
const flags = new Set(rest.slice(3).map((f) => f.toLowerCase()))
|
|
2820
|
+
const projections = rest.slice(3).filter((f) => !MODEL_ADD_FLAGS.has(f.toLowerCase()))
|
|
2821
|
+
if (!label || !src || projections.length > 1) {
|
|
2796
2822
|
return notice(USAGE)
|
|
2797
2823
|
}
|
|
2798
2824
|
|
|
2799
|
-
const flags = new Set(rest.slice(3).map((f) => f.toLowerCase()))
|
|
2800
|
-
|
|
2801
2825
|
return run(async () => {
|
|
2826
|
+
const mmprojSrc = projections[0] ?? (await this._pairedProjection(src))
|
|
2802
2827
|
const { id } = await models.addCustomModel({
|
|
2803
2828
|
label,
|
|
2804
2829
|
src,
|
|
2830
|
+
mmprojSrc,
|
|
2805
2831
|
supportsTools: flags.has('tools'),
|
|
2806
|
-
supportsVision: flags.has('vision'),
|
|
2832
|
+
supportsVision: flags.has('vision') || Boolean(mmprojSrc),
|
|
2807
2833
|
supportsThinking: flags.has('thinking')
|
|
2808
2834
|
})
|
|
2809
2835
|
const row = (await this._modelsLibrary()).get(id)
|
|
@@ -2812,7 +2838,9 @@ export class ChatApp {
|
|
|
2812
2838
|
? `context window ${formatTokenCount(row.contextLength)}`
|
|
2813
2839
|
: 'context window unknown — the picker uses the default range'
|
|
2814
2840
|
|
|
2815
|
-
|
|
2841
|
+
const projector = row?.mmprojSrc ? `\n projector ${row.mmprojSrc}` : ''
|
|
2842
|
+
|
|
2843
|
+
return where(`added ${label} as ${id}\n ${row?.src ?? src}${projector}\n ${ctx}`)
|
|
2816
2844
|
})
|
|
2817
2845
|
}
|
|
2818
2846
|
|
|
@@ -2834,6 +2862,10 @@ export class ChatApp {
|
|
|
2834
2862
|
return `${asked} was not set \u2014 ${unrunnable.message}`
|
|
2835
2863
|
}
|
|
2836
2864
|
|
|
2865
|
+
if (!custom && !(await isListedModel(engine, asked))) {
|
|
2866
|
+
return `${asked} was not set \u2014 no added model has that name, and it ${notInCatalog('this device')}`
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2837
2869
|
const name = custom?.name ?? asked
|
|
2838
2870
|
this.agent = await engine.updateAgent({
|
|
2839
2871
|
meshId: this.meshId,
|
|
@@ -4898,6 +4930,13 @@ export class ChatApp {
|
|
|
4898
4930
|
return (await this._customModelsOf(this._modelsEngine())) ?? new Map()
|
|
4899
4931
|
}
|
|
4900
4932
|
|
|
4933
|
+
// Core takes a re-added row whole, so a rename that names no projector keeps the one it had
|
|
4934
|
+
async _pairedProjection(src) {
|
|
4935
|
+
const stored = [...(await this._modelsLibrary()).values()].find((m) => m.src === src)
|
|
4936
|
+
|
|
4937
|
+
return this._previewedProjections.get(src) ?? stored?.mmprojSrc
|
|
4938
|
+
}
|
|
4939
|
+
|
|
4901
4940
|
async _customModelFor(nameOrLabel, customs = this._customModels, engine = this.engine) {
|
|
4902
4941
|
const byId = customs.get(nameOrLabel)
|
|
4903
4942
|
if (byId) {
|