@qvac/core 0.9.0 → 0.10.0
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 +94 -1
- package/README.md +4 -4
- package/dist-lib/index.d.ts +0 -1
- package/dist-lib/index.js +0 -1
- package/dist-lib/lib/api/agents.d.ts +7 -1
- package/dist-lib/lib/api/agents.js +2 -2
- package/dist-lib/lib/api/app-config.d.ts +2 -1
- package/dist-lib/lib/api/app-config.js +2 -2
- package/dist-lib/lib/api/attachments.js +3 -2
- package/dist-lib/lib/api/chat-move.d.ts +2 -1
- package/dist-lib/lib/api/chat-move.js +2 -2
- package/dist-lib/lib/api/chat.d.ts +3 -1
- package/dist-lib/lib/api/chat.js +5 -5
- package/dist-lib/lib/api/chunks.d.ts +2 -1
- package/dist-lib/lib/api/chunks.js +3 -3
- package/dist-lib/lib/api/config.d.ts +2 -1
- package/dist-lib/lib/api/config.js +2 -2
- package/dist-lib/lib/api/current-mesh.d.ts +1 -3
- package/dist-lib/lib/api/current-mesh.js +4 -10
- package/dist-lib/lib/api/custom-models.d.ts +7 -1
- package/dist-lib/lib/api/custom-models.js +10 -8
- package/dist-lib/lib/api/device-routes.d.ts +0 -2
- package/dist-lib/lib/api/device-routes.js +4 -5
- package/dist-lib/lib/api/devices.d.ts +3 -1
- package/dist-lib/lib/api/devices.js +9 -8
- package/dist-lib/lib/api/diagnostics.d.ts +2 -1
- package/dist-lib/lib/api/diagnostics.js +2 -2
- package/dist-lib/lib/api/index.d.ts +2 -0
- package/dist-lib/lib/api/index.js +39 -21
- package/dist-lib/lib/api/instrument.d.ts +2 -2
- package/dist-lib/lib/api/instrument.js +10 -11
- package/dist-lib/lib/api/knowledge.d.ts +3 -1
- package/dist-lib/lib/api/knowledge.js +9 -7
- package/dist-lib/lib/api/logs.js +3 -3
- package/dist-lib/lib/api/members.d.ts +6 -1
- package/dist-lib/lib/api/members.js +11 -10
- package/dist-lib/lib/api/mesh.d.ts +2 -2
- package/dist-lib/lib/api/mesh.js +6 -6
- package/dist-lib/lib/api/model-download.d.ts +2 -1
- package/dist-lib/lib/api/model-download.js +2 -2
- package/dist-lib/lib/api/network.d.ts +3 -2
- package/dist-lib/lib/api/network.js +4 -4
- package/dist-lib/lib/api/notifications.d.ts +3 -1
- package/dist-lib/lib/api/notifications.js +5 -4
- package/dist-lib/lib/api/rag.d.ts +0 -1
- package/dist-lib/lib/api/rag.js +3 -4
- package/dist-lib/lib/api/sync.d.ts +2 -1
- package/dist-lib/lib/api/sync.js +2 -2
- package/dist-lib/lib/api/tool-activity.d.ts +2 -1
- package/dist-lib/lib/api/tool-activity.js +4 -3
- package/dist-lib/lib/api/tool-configs.d.ts +2 -1
- package/dist-lib/lib/api/tool-configs.js +4 -3
- package/dist-lib/lib/api/upload-frames.d.ts +0 -1
- package/dist-lib/lib/api/upload-frames.js +0 -1
- package/dist-lib/lib/api/watchable.d.ts +3 -2
- package/dist-lib/lib/api/watchable.js +2 -3
- package/dist-lib/lib/assistant/fake-models.d.ts +2 -4
- package/dist-lib/lib/assistant/harness.js +8 -6
- package/dist-lib/lib/assistant-client.d.ts +2 -0
- package/dist-lib/lib/assistant-client.js +4 -3
- package/dist-lib/lib/assistant-tree.d.ts +3 -3
- package/dist-lib/lib/assistant.d.ts +2 -2
- package/dist-lib/lib/assistant.js +11 -11
- package/dist-lib/lib/client.d.ts +2 -2
- package/dist-lib/lib/core/agent.js +5 -4
- package/dist-lib/lib/core/archived-mesh.d.ts +2 -3
- package/dist-lib/lib/core/archived-mesh.js +3 -3
- package/dist-lib/lib/core/chat-activity.js +5 -3
- package/dist-lib/lib/core/chat-copy.d.ts +0 -1
- package/dist-lib/lib/core/chat-copy.js +2 -2
- package/dist-lib/lib/core/chat-fork.d.ts +0 -6
- package/dist-lib/lib/core/chat-fork.js +11 -17
- package/dist-lib/lib/core/chat-group.js +8 -7
- package/dist-lib/lib/core/chat-move.d.ts +4 -6
- package/dist-lib/lib/core/chat-move.js +14 -15
- package/dist-lib/lib/core/chat-order.d.ts +2 -1
- package/dist-lib/lib/core/chat-order.js +15 -2
- package/dist-lib/lib/core/chat.js +8 -7
- package/dist-lib/lib/core/chunk.js +13 -8
- package/dist-lib/lib/core/collections.d.ts +1 -0
- package/dist-lib/lib/core/collections.js +1 -0
- package/dist-lib/lib/core/contract/compute.d.ts +0 -4
- package/dist-lib/lib/core/contract/compute.js +2 -9
- package/dist-lib/lib/core/contract/types.d.ts +2 -2
- package/dist-lib/lib/core/departures.d.ts +2 -2
- package/dist-lib/lib/core/device-control.d.ts +0 -2
- package/dist-lib/lib/core/device-control.js +5 -6
- package/dist-lib/lib/core/files/attachments.js +5 -4
- package/dist-lib/lib/core/files/index.d.ts +2 -1
- package/dist-lib/lib/core/files/index.js +20 -8
- package/dist-lib/lib/core/files/processing/claims.js +3 -3
- package/dist-lib/lib/core/files/processing/document.d.ts +2 -0
- package/dist-lib/lib/core/files/processing/document.js +3 -0
- package/dist-lib/lib/core/files/processing/index.js +4 -2
- package/dist-lib/lib/core/files/processing/source.d.ts +3 -0
- package/dist-lib/lib/core/files/processing/source.js +5 -3
- package/dist-lib/lib/core/files/processing/state.js +1 -0
- package/dist-lib/lib/core/files/rag/index.d.ts +3 -0
- package/dist-lib/lib/core/files/rag/index.js +3 -1
- package/dist-lib/lib/core/files/rag/load.js +6 -3
- package/dist-lib/lib/core/files/rag/produce.js +3 -3
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +1 -1
- package/dist-lib/lib/core/files/rag/similarity.d.ts +2 -2
- package/dist-lib/lib/core/files/rag/similarity.js +2 -3
- package/dist-lib/lib/core/files/records/chunks.js +1 -1
- package/dist-lib/lib/core/files/records/knowledge.js +2 -1
- package/dist-lib/lib/core/files/records/purge.js +9 -5
- package/dist-lib/lib/core/files/records/reclaim.js +20 -48
- package/dist-lib/lib/core/files/records/sweep.d.ts +3 -0
- package/dist-lib/lib/core/files/records/sweep.js +9 -3
- package/dist-lib/lib/core/files/store/blob.d.ts +2 -0
- package/dist-lib/lib/core/files/store/blob.js +2 -2
- package/dist-lib/lib/core/files/store/index.d.ts +1 -0
- package/dist-lib/lib/core/files/store/index.js +2 -0
- package/dist-lib/lib/core/files/store/reference.js +4 -2
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/files/upload.js +10 -9
- package/dist-lib/lib/core/handoff-channel.d.ts +6 -4
- package/dist-lib/lib/core/handoff-channel.js +8 -9
- package/dist-lib/lib/core/harness-loan.d.ts +0 -2
- package/dist-lib/lib/core/harness-loan.js +3 -4
- package/dist-lib/lib/core/hosted-agents.d.ts +2 -2
- package/dist-lib/lib/core/inference-calls-handoff.d.ts +2 -2
- package/dist-lib/lib/core/inference-calls-handoff.js +6 -5
- package/dist-lib/lib/core/inference-calls-receiver.d.ts +0 -2
- package/dist-lib/lib/core/inference-calls-receiver.js +5 -7
- package/dist-lib/lib/core/local/index.d.ts +4 -1
- package/dist-lib/lib/core/local/index.js +23 -2
- package/dist-lib/lib/core/membership.d.ts +2 -2
- package/dist-lib/lib/core/mesh.d.ts +13 -7
- package/dist-lib/lib/core/mesh.js +55 -47
- package/dist-lib/lib/core/migrations/file-index.js +2 -4
- package/dist-lib/lib/core/next-frame.js +2 -1
- package/dist-lib/lib/core/pdf/rasterize.d.ts +2 -1
- package/dist-lib/lib/core/pdf/rasterize.js +5 -5
- package/dist-lib/lib/core/peer-duplex.d.ts +3 -3
- package/dist-lib/lib/core/peer-duplex.js +4 -4
- package/dist-lib/lib/core/secret-handoff.d.ts +2 -2
- package/dist-lib/lib/core/secret-handoff.js +7 -4
- package/dist-lib/lib/core/send.js +3 -2
- package/dist-lib/lib/core/skill-overlay-handoff.d.ts +2 -2
- package/dist-lib/lib/core/skill-overlay-handoff.js +6 -5
- package/dist-lib/lib/core/skill-overlay-receiver.js +5 -5
- package/dist-lib/lib/core/skill-secrets.d.ts +0 -5
- package/dist-lib/lib/core/skill-secrets.js +5 -9
- package/dist-lib/lib/core/sync/changed.d.ts +20 -0
- package/dist-lib/lib/core/sync/changed.js +7 -0
- package/dist-lib/lib/core/sync/devices.js +1 -1
- package/dist-lib/lib/core/sync/files.d.ts +1 -0
- package/dist-lib/lib/core/sync/files.js +50 -72
- package/dist-lib/lib/core/sync/index.d.ts +1 -2
- package/dist-lib/lib/core/sync/index.js +40 -62
- package/dist-lib/lib/core/sync/view-updates.d.ts +33 -0
- package/dist-lib/lib/core/sync/view-updates.js +133 -0
- package/dist-lib/lib/core/system-info.d.ts +2 -2
- package/dist-lib/lib/core/system-info.js +10 -11
- package/dist-lib/lib/core/tool-configs.js +6 -6
- package/dist-lib/lib/core.d.ts +1 -7
- package/dist-lib/lib/core.js +147 -131
- package/dist-lib/lib/custom-model-pusher.d.ts +2 -4
- package/dist-lib/lib/custom-model-task.d.ts +2 -1
- package/dist-lib/lib/custom-model-task.js +2 -2
- package/dist-lib/lib/downloads-allowed-pusher.d.ts +2 -4
- package/dist-lib/lib/errors.d.ts +603 -0
- package/dist-lib/lib/errors.js +552 -0
- package/dist-lib/lib/log.d.ts +7 -6
- package/dist-lib/lib/log.js +10 -6
- package/dist-lib/lib/logger-type.d.ts +2 -5
- package/dist-lib/lib/model-download-status.d.ts +2 -2
- package/dist-lib/lib/model-download.d.ts +2 -2
- package/dist-lib/lib/model-download.js +3 -2
- package/dist-lib/lib/model-idle-pusher.d.ts +2 -4
- package/dist-lib/lib/model-memory-cap.d.ts +2 -4
- package/dist-lib/lib/oauth/browser-connect.js +3 -2
- package/dist-lib/lib/oauth/flow-core.js +3 -3
- package/dist-lib/lib/oauth/loopback.js +10 -9
- package/dist-lib/lib/oauth/providers.js +4 -2
- package/dist-lib/lib/oauth/register.js +3 -2
- package/dist-lib/lib/oauth/token-exchange-core.js +5 -4
- package/dist-lib/lib/run-transcript.d.ts +2 -2
- package/dist-lib/lib/task.js +2 -1
- package/dist-lib/schema/engine.js +6 -3
- package/dist-lib/schema/field-order.js +1 -3
- package/dist-lib/schema/local.js +11 -0
- package/dist-lib/spec/hrpc/messages.js +20 -9
- package/dist-lib/spec/hyperschema/index.js +20 -9
- package/dist-lib/spec/hyperschema/schema.json +15 -0
- package/dist-lib/spec/hyperschema/types.d.ts +3 -0
- package/dist-lib/spec/local/hyperdb/db.json +16 -1
- package/dist-lib/spec/local/hyperdb/index.js +71 -2
- package/dist-lib/spec/local/hyperdb/messages.js +300 -143
- package/dist-lib/spec/local/hyperschema/index.js +82 -2
- package/dist-lib/spec/local/hyperschema/schema.json +43 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +12 -1
- package/package.json +9 -2
- package/tui/app.mjs +1 -1
- package/worker/assistant-sidecar.mjs +7 -0
- package/dist-lib/lib/log-levels.d.ts +0 -7
- package/dist-lib/lib/log-levels.js +0 -1
- package/dist-lib/lib/logger.d.ts +0 -5
- package/dist-lib/lib/logger.js +0 -18
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ViewHead } from '../mesh.ts';
|
|
2
|
+
export interface ViewUpdate {
|
|
3
|
+
readonly from: ViewHead | null;
|
|
4
|
+
readonly to: number;
|
|
5
|
+
readonly incremental: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface PendingUpdates {
|
|
8
|
+
read(): Promise<ViewUpdate | null>;
|
|
9
|
+
write(update: ViewUpdate): Promise<void>;
|
|
10
|
+
clear(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
type Run = (update: ViewUpdate) => Promise<ViewHead | null | void>;
|
|
13
|
+
export declare class ViewUpdates {
|
|
14
|
+
private readonly _run;
|
|
15
|
+
private readonly _pending;
|
|
16
|
+
private _next;
|
|
17
|
+
private _running;
|
|
18
|
+
private _kept;
|
|
19
|
+
private _started;
|
|
20
|
+
private _closed;
|
|
21
|
+
constructor(run: Run, pending?: PendingUpdates | null);
|
|
22
|
+
start(): Promise<void>;
|
|
23
|
+
push(update: ViewUpdate): Promise<void>;
|
|
24
|
+
close(): void;
|
|
25
|
+
flush(): Promise<void>;
|
|
26
|
+
private _kick;
|
|
27
|
+
private _drain;
|
|
28
|
+
private _queue;
|
|
29
|
+
private _keepNext;
|
|
30
|
+
private _keep;
|
|
31
|
+
private _clear;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
export class ViewUpdates {
|
|
3
|
+
_run;
|
|
4
|
+
_pending;
|
|
5
|
+
_next = null;
|
|
6
|
+
_running = null;
|
|
7
|
+
_kept = null;
|
|
8
|
+
_started = false;
|
|
9
|
+
_closed = false;
|
|
10
|
+
constructor(run, pending = null) {
|
|
11
|
+
this._run = run;
|
|
12
|
+
this._pending = pending;
|
|
13
|
+
}
|
|
14
|
+
async start() {
|
|
15
|
+
try {
|
|
16
|
+
const resumed = await this._pending?.read();
|
|
17
|
+
if (this._closed) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (resumed) {
|
|
21
|
+
this._kept = resumed;
|
|
22
|
+
this._queue(resumed, { older: true });
|
|
23
|
+
}
|
|
24
|
+
if (this._next) {
|
|
25
|
+
await this._keep(this._next.update);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
this._started = true;
|
|
30
|
+
this._kick();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
push(update) {
|
|
34
|
+
const next = this._queue(update);
|
|
35
|
+
if (!this._started) {
|
|
36
|
+
return Promise.resolve();
|
|
37
|
+
}
|
|
38
|
+
const running = this._running && !this._running.done ? this._running : null;
|
|
39
|
+
const written = this._keep(running ? merged(running.update, next) : next);
|
|
40
|
+
this._kick();
|
|
41
|
+
return written;
|
|
42
|
+
}
|
|
43
|
+
close() {
|
|
44
|
+
this._closed = true;
|
|
45
|
+
this._running?.settle();
|
|
46
|
+
this._next?.settle();
|
|
47
|
+
}
|
|
48
|
+
flush() {
|
|
49
|
+
return (this._next ?? this._running)?.synced ?? Promise.resolve();
|
|
50
|
+
}
|
|
51
|
+
_kick() {
|
|
52
|
+
if (this._started && !this._closed && this._next && !this._running) {
|
|
53
|
+
void this._drain();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async _drain() {
|
|
57
|
+
try {
|
|
58
|
+
while (this._next) {
|
|
59
|
+
this._running = this._next;
|
|
60
|
+
this._next = null;
|
|
61
|
+
const reached = await this._run(this._running.update);
|
|
62
|
+
if (this._closed) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this._running.done = true;
|
|
66
|
+
await this._keepNext(reached || null);
|
|
67
|
+
this._running.settle();
|
|
68
|
+
this._running = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
this._running = null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
_queue(update, { older = false } = {}) {
|
|
76
|
+
if (!this._next) {
|
|
77
|
+
this._next = pass(update);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const queued = this._next.update;
|
|
81
|
+
this._next.update = older ? merged(update, queued) : merged(queued, update);
|
|
82
|
+
}
|
|
83
|
+
return this._next.update;
|
|
84
|
+
}
|
|
85
|
+
_keepNext(reached) {
|
|
86
|
+
if (!this._next) {
|
|
87
|
+
return this._clear();
|
|
88
|
+
}
|
|
89
|
+
if (reached) {
|
|
90
|
+
this._next.update = rebased(this._next.update, reached);
|
|
91
|
+
}
|
|
92
|
+
return this._keep(this._next.update);
|
|
93
|
+
}
|
|
94
|
+
_keep(update) {
|
|
95
|
+
if (!this._pending || (this._kept && sameUpdate(this._kept, update))) {
|
|
96
|
+
return Promise.resolve();
|
|
97
|
+
}
|
|
98
|
+
this._kept = update;
|
|
99
|
+
return this._pending.write(update);
|
|
100
|
+
}
|
|
101
|
+
_clear() {
|
|
102
|
+
if (!this._pending || !this._kept) {
|
|
103
|
+
return Promise.resolve();
|
|
104
|
+
}
|
|
105
|
+
this._kept = null;
|
|
106
|
+
return this._pending.clear();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function pass(update) {
|
|
110
|
+
let settle = () => { };
|
|
111
|
+
const synced = new Promise((resolve) => (settle = resolve));
|
|
112
|
+
return { update, done: false, synced, settle };
|
|
113
|
+
}
|
|
114
|
+
function merged(pending, next) {
|
|
115
|
+
return {
|
|
116
|
+
from: pending.from,
|
|
117
|
+
to: next.to,
|
|
118
|
+
incremental: pending.incremental && next.incremental
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function rebased(update, reached) {
|
|
122
|
+
const { from } = update;
|
|
123
|
+
if (!update.incremental || !from || !b4a.equals(from.key, reached.key)) {
|
|
124
|
+
return update;
|
|
125
|
+
}
|
|
126
|
+
return reached.length > from.length ? { ...update, from: reached } : update;
|
|
127
|
+
}
|
|
128
|
+
function sameUpdate(a, b) {
|
|
129
|
+
return a.incremental === b.incremental && sameHead(a.from, b.from);
|
|
130
|
+
}
|
|
131
|
+
function sameHead(a, b) {
|
|
132
|
+
return a && b ? a.length === b.length && b4a.equals(a.key, b.key) : a === b;
|
|
133
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type CPUInfo from 'bare-cpu-info';
|
|
2
2
|
import type { Drivers, GPU, Usage as GpuUsage } from 'bare-gpu-info';
|
|
3
|
-
import '
|
|
3
|
+
import type { LoggerInterface } from '@qvac/logging';
|
|
4
4
|
export type CpuQuery = ReturnType<CPUInfo['query']>;
|
|
5
5
|
export type CpuUsage = ReturnType<CPUInfo['sample']>;
|
|
6
6
|
export type CpuDiagnostics = CpuQuery & {
|
|
@@ -21,4 +21,4 @@ export interface SystemInfoSampler {
|
|
|
21
21
|
snapshot(): SystemInfoSnapshot;
|
|
22
22
|
destroy(): void;
|
|
23
23
|
}
|
|
24
|
-
export declare function createSystemInfoSampler(): SystemInfoSampler;
|
|
24
|
+
export declare function createSystemInfoSampler(log: LoggerInterface | null): SystemInfoSampler;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import CPUInfoCtor from '#cpu-info';
|
|
2
2
|
import GPUInfoCtor from '#gpu-info';
|
|
3
|
-
import '../logger.js';
|
|
4
3
|
const LOG_TAG = ['diagnostics', 'system-info'];
|
|
5
|
-
function readCpu(cpu) {
|
|
4
|
+
function readCpu(cpu, log) {
|
|
6
5
|
try {
|
|
7
6
|
return { ...cpu.query(), usage: cpu.sample() };
|
|
8
7
|
}
|
|
9
8
|
catch (err) {
|
|
10
|
-
|
|
9
|
+
log?.warn(LOG_TAG, 'cpu sample failed', err);
|
|
11
10
|
return null;
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
|
-
function readGpu(gpu) {
|
|
13
|
+
function readGpu(gpu, log) {
|
|
15
14
|
try {
|
|
16
15
|
const drivers = gpu.drivers();
|
|
17
16
|
const devices = [];
|
|
@@ -20,17 +19,17 @@ function readGpu(gpu) {
|
|
|
20
19
|
devices.push({ ...gpu.gpu(i), usage: gpu.sample(i) });
|
|
21
20
|
}
|
|
22
21
|
catch (err) {
|
|
23
|
-
|
|
22
|
+
log?.warn(LOG_TAG, `gpu device ${i} sample failed`, err);
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
return { drivers, devices };
|
|
27
26
|
}
|
|
28
27
|
catch (err) {
|
|
29
|
-
|
|
28
|
+
log?.warn(LOG_TAG, 'gpu drivers query failed', err);
|
|
30
29
|
return null;
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
|
-
export function createSystemInfoSampler() {
|
|
32
|
+
export function createSystemInfoSampler(log) {
|
|
34
33
|
let cpu = null;
|
|
35
34
|
let gpu = null;
|
|
36
35
|
try {
|
|
@@ -39,7 +38,7 @@ export function createSystemInfoSampler() {
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
catch (err) {
|
|
42
|
-
|
|
41
|
+
log?.warn(LOG_TAG, 'bare-cpu-info constructor failed', err);
|
|
43
42
|
cpu = null;
|
|
44
43
|
}
|
|
45
44
|
try {
|
|
@@ -48,14 +47,14 @@ export function createSystemInfoSampler() {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
catch (err) {
|
|
51
|
-
|
|
50
|
+
log?.warn(LOG_TAG, 'bare-gpu-info constructor failed', err);
|
|
52
51
|
gpu = null;
|
|
53
52
|
}
|
|
54
53
|
return {
|
|
55
54
|
snapshot() {
|
|
56
55
|
return {
|
|
57
|
-
cpu: cpu ? readCpu(cpu) : null,
|
|
58
|
-
gpu: gpu ? readGpu(gpu) : null
|
|
56
|
+
cpu: cpu ? readCpu(cpu, log) : null,
|
|
57
|
+
gpu: gpu ? readGpu(gpu, log) : null
|
|
59
58
|
};
|
|
60
59
|
},
|
|
61
60
|
destroy() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MAX_TOOL_CONFIGS_BYTES, toolConfigsWithinBounds } from '../../schema/qvac.js';
|
|
2
2
|
import { mustGetAgent } from './agent.js';
|
|
3
3
|
import { isRecord } from '../guards.js';
|
|
4
|
+
import { CoreError } from '../errors.js';
|
|
4
5
|
import { ACTIVE_TOOL_CONFIGS_BY_AGENT, TOOL_CONFIGS } from './collections.js';
|
|
5
6
|
function isPlainObject(value) {
|
|
6
7
|
if (!isRecord(value)) {
|
|
@@ -62,8 +63,7 @@ function findReplicatedSecret(value, path) {
|
|
|
62
63
|
function assertNoReplicatedSecrets(value, path) {
|
|
63
64
|
const hit = findReplicatedSecret(value, path);
|
|
64
65
|
if (hit) {
|
|
65
|
-
throw new
|
|
66
|
-
'keep the secret device-local and store a mesh-safe reference instead');
|
|
66
|
+
throw new CoreError('TOOL_CONFIGS_SECRET', [hit]);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
export function toolConfigsCarrySecret(settings) {
|
|
@@ -91,15 +91,15 @@ export async function listToolConfigs(store, agentId) {
|
|
|
91
91
|
export async function setToolConfigs(store, input) {
|
|
92
92
|
const agent = await mustGetAgent(store, input.agentId);
|
|
93
93
|
if (agent.deletedAt) {
|
|
94
|
-
throw new
|
|
94
|
+
throw new CoreError('AGENT_DELETED', [input.agentId]);
|
|
95
95
|
}
|
|
96
96
|
if (!isPlainObject(input.settings)) {
|
|
97
|
-
throw new
|
|
97
|
+
throw new CoreError('TOOL_CONFIGS_INVALID');
|
|
98
98
|
}
|
|
99
99
|
assertNoReplicatedSecrets(input.settings, 'settings');
|
|
100
100
|
const normalized = { ...input.settings };
|
|
101
101
|
if (!toolConfigsWithinBounds(normalized)) {
|
|
102
|
-
throw new
|
|
102
|
+
throw new CoreError('TOOL_CONFIGS_TOO_LARGE', [MAX_TOOL_CONFIGS_BYTES]);
|
|
103
103
|
}
|
|
104
104
|
const now = Date.now();
|
|
105
105
|
const current = await getToolConfigs(store, input.agentId, input.toolName);
|
|
@@ -118,7 +118,7 @@ export async function deleteToolConfigs(store, agentId, toolName) {
|
|
|
118
118
|
await mustGetAgent(store, agentId);
|
|
119
119
|
const current = await getToolConfigs(store, agentId, toolName);
|
|
120
120
|
if (!current || current.deletedAt) {
|
|
121
|
-
throw new
|
|
121
|
+
throw new CoreError('TOOL_CONFIGS_NOT_FOUND', [agentId, toolName]);
|
|
122
122
|
}
|
|
123
123
|
const now = Date.now();
|
|
124
124
|
const settings = { ...current, deletedAt: now, updatedAt: now };
|
package/dist-lib/lib/core.d.ts
CHANGED
|
@@ -81,14 +81,7 @@ export interface CoreOptions {
|
|
|
81
81
|
readonly resume: () => Promise<void>;
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
export declare const ACCOUNT_MEMBER_UNKNOWN = "This device is not part of its account yet";
|
|
85
84
|
export declare const DEVICE_UNKNOWN = "This device has no device details: pass `device` when creating Core";
|
|
86
|
-
export declare const MEMBER_INVITE_HOME_REFUSED = "An account mesh cannot be invited into";
|
|
87
|
-
export declare const DEVICE_INVITE_MESH_REFUSED = "Only an account mesh can take a device invite";
|
|
88
|
-
export declare const MESH_NAME_ACCOUNT_REFUSED = "An account mesh has no shared name";
|
|
89
|
-
export declare const INVITE_ACCOUNT_UNREADABLE = "This device cannot reach its account to check";
|
|
90
|
-
export declare const DEVICE_INVITE_CHAIN_TOO_LONG = "This device cannot invite another one: invite from another of your devices, or recover from your phrase";
|
|
91
|
-
export declare const MESH_HELD_BY_SIBLING = "Another of your devices holds this mesh: bring that device online, or invite from it instead";
|
|
92
85
|
export interface SharedMesh {
|
|
93
86
|
readonly meshId: string;
|
|
94
87
|
readonly notice?: string;
|
|
@@ -375,6 +368,7 @@ export declare class Core extends ReadyResource {
|
|
|
375
368
|
private _meshIdOf;
|
|
376
369
|
private _poolEntry;
|
|
377
370
|
private _meshForBlobCore;
|
|
371
|
+
private _pendingUpdatesFor;
|
|
378
372
|
private _fileIndexFor;
|
|
379
373
|
private _indexMeshFiles;
|
|
380
374
|
private _servedFile;
|