@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LoggerInterface } from '@qvac/logging';
|
|
1
2
|
export declare const PDF_RENDER_SCALE = 2;
|
|
2
3
|
export declare const MAX_PDF_PAGE_IMAGES = 10;
|
|
3
4
|
interface PageFlags {
|
|
@@ -14,5 +15,5 @@ export interface PdfDoc {
|
|
|
14
15
|
export interface PdfRasterizer {
|
|
15
16
|
open(bytes: Uint8Array): Promise<PdfDoc | null>;
|
|
16
17
|
}
|
|
17
|
-
export declare const
|
|
18
|
+
export declare const createPdfRasterizer: (log: LoggerInterface | null) => PdfRasterizer;
|
|
18
19
|
export {};
|
|
@@ -5,7 +5,7 @@ export function renderScale(pageWidth) {
|
|
|
5
5
|
return Math.min(PDF_RENDER_SCALE, MAX_IMAGE_WIDTH / pageWidth);
|
|
6
6
|
}
|
|
7
7
|
let pdfium;
|
|
8
|
-
async function loadPdfium() {
|
|
8
|
+
async function loadPdfium(log) {
|
|
9
9
|
if (pdfium !== undefined)
|
|
10
10
|
return pdfium;
|
|
11
11
|
try {
|
|
@@ -13,14 +13,14 @@ async function loadPdfium() {
|
|
|
13
13
|
pdfium = mod.default ?? mod;
|
|
14
14
|
}
|
|
15
15
|
catch (err) {
|
|
16
|
-
|
|
16
|
+
log?.warn('pdf', 'bare-pdfium did not load; PDF pages will not render', err);
|
|
17
17
|
pdfium = null;
|
|
18
18
|
}
|
|
19
19
|
return pdfium;
|
|
20
20
|
}
|
|
21
|
-
export const
|
|
21
|
+
export const createPdfRasterizer = (log) => ({
|
|
22
22
|
async open(bytes) {
|
|
23
|
-
const mod = await loadPdfium();
|
|
23
|
+
const mod = await loadPdfium(log);
|
|
24
24
|
if (!mod) {
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
@@ -54,4 +54,4 @@ export const pdfRasterizer = {
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
};
|
|
57
|
+
});
|
|
@@ -8,8 +8,8 @@ export interface PeerStream {
|
|
|
8
8
|
export interface PeerDuplexOptions {
|
|
9
9
|
readonly protocol: string;
|
|
10
10
|
readonly onaccept: (fromDeviceId: Uint8Array) => Promise<Duplex | null>;
|
|
11
|
-
readonly unreachable:
|
|
12
|
-
readonly revoked:
|
|
11
|
+
readonly unreachable: () => Error;
|
|
12
|
+
readonly revoked: () => Error;
|
|
13
13
|
readonly onchange?: (deviceId: string) => void;
|
|
14
14
|
}
|
|
15
15
|
export declare class PeerDuplexChannel {
|
|
@@ -21,7 +21,7 @@ export declare class PeerDuplexChannel {
|
|
|
21
21
|
addStream(stream: PeerStream): void;
|
|
22
22
|
openIds(): string[];
|
|
23
23
|
isOpen(deviceId: string): boolean;
|
|
24
|
-
closeDialled(deviceId: string, reason:
|
|
24
|
+
closeDialled(deviceId: string, reason: () => Error): void;
|
|
25
25
|
dial(deviceId: string): Duplex;
|
|
26
26
|
revalidate(allowed: (deviceId: Uint8Array) => Promise<boolean>): Promise<void>;
|
|
27
27
|
destroy(): void;
|
|
@@ -92,13 +92,13 @@ export class PeerDuplexChannel {
|
|
|
92
92
|
}
|
|
93
93
|
closeDialled(deviceId, reason) {
|
|
94
94
|
for (const stream of [...(this._peers.get(deviceId)?.dialled.values() ?? [])]) {
|
|
95
|
-
stream.destroy(
|
|
95
|
+
stream.destroy(reason());
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
dial(deviceId) {
|
|
99
99
|
const peer = this._peers.get(deviceId);
|
|
100
100
|
if (!peer) {
|
|
101
|
-
throw
|
|
101
|
+
throw this._opts.unreachable();
|
|
102
102
|
}
|
|
103
103
|
const id = this._nextId;
|
|
104
104
|
this._nextId += 1;
|
|
@@ -115,7 +115,7 @@ export class PeerDuplexChannel {
|
|
|
115
115
|
for (const [id, stream] of [...peer.served]) {
|
|
116
116
|
peer.served.delete(id);
|
|
117
117
|
peer.close.send({ id, mine: false });
|
|
118
|
-
stream.destroy(
|
|
118
|
+
stream.destroy(this._opts.revoked());
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -205,7 +205,7 @@ export class PeerDuplexChannel {
|
|
|
205
205
|
this._peers.delete(deviceId);
|
|
206
206
|
for (const held of [peer.dialled, peer.served]) {
|
|
207
207
|
for (const stream of held.values()) {
|
|
208
|
-
stream.destroy(
|
|
208
|
+
stream.destroy(this._opts.unreachable());
|
|
209
209
|
}
|
|
210
210
|
held.clear();
|
|
211
211
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ACK_TIMEOUT_MS,
|
|
1
|
+
import { ACK_TIMEOUT_MS, type HandoffStream } from './handoff-channel.ts';
|
|
2
2
|
import type { AssistantPushSkillSecretRequest, AssistantSkillSecretValue } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
-
export { ACK_TIMEOUT_MS,
|
|
3
|
+
export { ACK_TIMEOUT_MS, type HandoffStream };
|
|
4
4
|
export type SecretValue = AssistantSkillSecretValue;
|
|
5
5
|
export type SecretRequest = AssistantPushSkillSecretRequest;
|
|
6
6
|
export type SecretRequestHandler = (request: SecretRequest, fromDeviceId: Uint8Array) => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getStruct } from '../../spec/hyperschema/index.js';
|
|
2
|
-
import { ACK_TIMEOUT_MS, HandoffChannel
|
|
2
|
+
import { ACK_TIMEOUT_MS, HandoffChannel } from './handoff-channel.js';
|
|
3
3
|
const PROTOCOL = 'qvac/secret-handoff';
|
|
4
|
-
export { ACK_TIMEOUT_MS
|
|
4
|
+
export { ACK_TIMEOUT_MS };
|
|
5
5
|
const handoff = getStruct('@assistant/skill-secret-handoff');
|
|
6
6
|
const handoffAck = getStruct('@assistant/skill-secret-handoff-ack');
|
|
7
7
|
export class SecretHandoff {
|
|
@@ -12,8 +12,11 @@ export class SecretHandoff {
|
|
|
12
12
|
requestEncoding: handoff,
|
|
13
13
|
ackEncoding: handoffAck,
|
|
14
14
|
onrequest: opts.onrequest,
|
|
15
|
-
buildAck: (id,
|
|
16
|
-
readAck: (ack) => ({
|
|
15
|
+
buildAck: (id, { message, code }) => ({ id, error: message, code }),
|
|
16
|
+
readAck: (ack) => ({
|
|
17
|
+
error: { message: ack.error ?? '', code: ack.code ?? 0 },
|
|
18
|
+
result: undefined
|
|
19
|
+
}),
|
|
17
20
|
ackTimeoutMs: opts.ackTimeoutMs
|
|
18
21
|
});
|
|
19
22
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CoreError } from '../errors.js';
|
|
1
2
|
import { buildChat, enrichChat, mustGetActiveChat } from './chat.js';
|
|
2
3
|
import { appendChunk, listChunks } from './chunk.js';
|
|
3
4
|
import { randomId } from './id.js';
|
|
@@ -5,7 +6,7 @@ export async function sendMessage(mesh, input) {
|
|
|
5
6
|
const existing = input.chatId ? await mustGetActiveChat(mesh, input.chatId) : null;
|
|
6
7
|
const agentId = input.agentId ?? existing?.agentId;
|
|
7
8
|
if (!agentId) {
|
|
8
|
-
throw new
|
|
9
|
+
throw new CoreError('SEND_AGENT_REQUIRED');
|
|
9
10
|
}
|
|
10
11
|
const chat = existing ?? buildChat({ agentId, title: input.title ?? '' });
|
|
11
12
|
const chatId = chat.id;
|
|
@@ -46,7 +47,7 @@ export async function parentRequestId(mesh, chatId, parentRunId) {
|
|
|
46
47
|
const requests = await listChunks(mesh, { chatId, type: 'run-request' });
|
|
47
48
|
const parent = requests.find((chunk) => chunk.runId === parentRunId);
|
|
48
49
|
if (!parent) {
|
|
49
|
-
throw new
|
|
50
|
+
throw new CoreError('RUN_NOT_FOUND', [parentRunId]);
|
|
50
51
|
}
|
|
51
52
|
return parent.id;
|
|
52
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ACK_TIMEOUT_MS,
|
|
1
|
+
import { ACK_TIMEOUT_MS, type HandoffStream } from './handoff-channel.ts';
|
|
2
2
|
import type { AssistantManagedSkill, AssistantSkillOverlayOp } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
-
export { ACK_TIMEOUT_MS,
|
|
3
|
+
export { ACK_TIMEOUT_MS, type HandoffStream };
|
|
4
4
|
export type SkillOverlayOp = AssistantSkillOverlayOp;
|
|
5
5
|
export interface SkillOverlayResult {
|
|
6
6
|
readonly skills?: ReadonlyArray<AssistantManagedSkill>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getStruct } from '../../spec/hyperschema/index.js';
|
|
2
|
-
import { ACK_TIMEOUT_MS, HandoffChannel
|
|
2
|
+
import { ACK_TIMEOUT_MS, HandoffChannel } from './handoff-channel.js';
|
|
3
3
|
const PROTOCOL = 'qvac/skill-overlay-handoff';
|
|
4
|
-
export { ACK_TIMEOUT_MS
|
|
4
|
+
export { ACK_TIMEOUT_MS };
|
|
5
5
|
const handoff = getStruct('@assistant/skill-overlay-handoff');
|
|
6
6
|
const handoffAck = getStruct('@assistant/skill-overlay-handoff-ack');
|
|
7
7
|
export class SkillOverlayHandoff {
|
|
@@ -12,9 +12,10 @@ export class SkillOverlayHandoff {
|
|
|
12
12
|
requestEncoding: handoff,
|
|
13
13
|
ackEncoding: handoffAck,
|
|
14
14
|
onrequest: opts.onrequest,
|
|
15
|
-
buildAck: (id,
|
|
15
|
+
buildAck: (id, { message, code }, result) => ({
|
|
16
16
|
id,
|
|
17
|
-
error,
|
|
17
|
+
error: message,
|
|
18
|
+
code,
|
|
18
19
|
skills: result?.skills ? [...result.skills] : undefined,
|
|
19
20
|
found: result?.found,
|
|
20
21
|
content: result?.content ?? undefined,
|
|
@@ -24,7 +25,7 @@ export class SkillOverlayHandoff {
|
|
|
24
25
|
removed: result?.removed
|
|
25
26
|
}),
|
|
26
27
|
readAck: (ack) => ({
|
|
27
|
-
error: ack.error ?? '',
|
|
28
|
+
error: { message: ack.error ?? '', code: ack.code ?? 0 },
|
|
28
29
|
result: {
|
|
29
30
|
skills: ack.skills ?? undefined,
|
|
30
31
|
found: ack.found,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { getAgent } from './agent.js';
|
|
3
|
-
import { NO_SUCH_AGENT, NOT_THE_HOST, SENDER_REVOKED } from './skill-secrets.js';
|
|
4
3
|
import { DEVICES } from './collections.js';
|
|
4
|
+
import { CoreError } from '../errors.js';
|
|
5
5
|
export function createSkillOverlayReceiver(opts) {
|
|
6
6
|
return async (op, fromDeviceId) => {
|
|
7
7
|
const sender = await opts.mesh.view.get(DEVICES, { id: fromDeviceId });
|
|
8
8
|
if (!sender || sender.revoked) {
|
|
9
|
-
throw new
|
|
9
|
+
throw new CoreError('PEER_SENDER_REVOKED');
|
|
10
10
|
}
|
|
11
11
|
if (!op.agentId) {
|
|
12
|
-
throw new
|
|
12
|
+
throw new CoreError('AGENT_HOST_AGENT_UNKNOWN');
|
|
13
13
|
}
|
|
14
14
|
const agent = await getAgent(opts.mesh, op.agentId);
|
|
15
15
|
if (!agent) {
|
|
16
|
-
throw new
|
|
16
|
+
throw new CoreError('AGENT_HOST_AGENT_UNKNOWN');
|
|
17
17
|
}
|
|
18
18
|
if (!agent.providerDeviceId || !b4a.equals(agent.providerDeviceId, opts.deviceId)) {
|
|
19
|
-
throw new
|
|
19
|
+
throw new CoreError('AGENT_NOT_HOSTED_HERE');
|
|
20
20
|
}
|
|
21
21
|
return opts.runLocal(op);
|
|
22
22
|
};
|
|
@@ -3,11 +3,6 @@ import type { QvacAgent } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
|
3
3
|
import type { openLocalStore } from './local/index.ts';
|
|
4
4
|
import type { Mesh } from './mesh.ts';
|
|
5
5
|
import type { SecretRequestHandler } from './secret-handoff.ts';
|
|
6
|
-
export declare const NOT_THE_HOST = "this device does not host that agent";
|
|
7
|
-
export declare const SENDER_REVOKED = "the sending device is no longer in the mesh";
|
|
8
|
-
export declare const HOST_REVOKED = "the device hosting this agent is no longer in the mesh";
|
|
9
|
-
export declare const NO_SUCH_AGENT = "no agent with that id";
|
|
10
|
-
export declare const NOT_A_SETUP_FIELD = "that skill declares no such setup field";
|
|
11
6
|
export type SetupFields = (skillName: string) => Promise<ReadonlyMap<string, boolean> | null>;
|
|
12
7
|
export interface SkillSecretsOptions {
|
|
13
8
|
readonly mesh: Mesh;
|
|
@@ -5,27 +5,23 @@ import { settingConfigKey } from '../credential-pusher.js';
|
|
|
5
5
|
import { scopedKey } from '../oauth/keys.js';
|
|
6
6
|
import { getAgent } from './agent.js';
|
|
7
7
|
import { DEVICES } from './collections.js';
|
|
8
|
-
|
|
9
|
-
export const SENDER_REVOKED = 'the sending device is no longer in the mesh';
|
|
10
|
-
export const HOST_REVOKED = 'the device hosting this agent is no longer in the mesh';
|
|
11
|
-
export const NO_SUCH_AGENT = 'no agent with that id';
|
|
12
|
-
export const NOT_A_SETUP_FIELD = 'that skill declares no such setup field';
|
|
8
|
+
import { CoreError } from '../errors.js';
|
|
13
9
|
export function createSkillSecretReceiver(opts) {
|
|
14
10
|
return async (request, fromDeviceId) => {
|
|
15
11
|
const sender = await opts.mesh.view.get(DEVICES, { id: fromDeviceId });
|
|
16
12
|
if (!sender || sender.revoked) {
|
|
17
|
-
throw new
|
|
13
|
+
throw new CoreError('PEER_SENDER_REVOKED');
|
|
18
14
|
}
|
|
19
15
|
const agent = await getAgent(opts.mesh, request.agentId);
|
|
20
16
|
if (!agent) {
|
|
21
|
-
throw new
|
|
17
|
+
throw new CoreError('AGENT_HOST_AGENT_UNKNOWN');
|
|
22
18
|
}
|
|
23
19
|
if (!agent.providerDeviceId || !b4a.equals(agent.providerDeviceId, opts.deviceId)) {
|
|
24
|
-
throw new
|
|
20
|
+
throw new CoreError('AGENT_NOT_HOSTED_HERE');
|
|
25
21
|
}
|
|
26
22
|
const fields = await opts.setupFields(request.skillName);
|
|
27
23
|
if (fields && request.values.some(({ key }) => !fields.has(key))) {
|
|
28
|
-
throw new
|
|
24
|
+
throw new CoreError('SKILL_SETUP_FIELD_UNKNOWN');
|
|
29
25
|
}
|
|
30
26
|
const entries = request.values.map(({ key, value }) => ({
|
|
31
27
|
key: fields?.get(key) === false
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ViewChange } from 'hyperdb';
|
|
2
|
+
import type { QvacAgent, QvacChat, QvacChunk, QvacChunkCounter, QvacDevice, QvacIndexingStatus, QvacKnowledge, QvacKnowledgeArtifact, QvacPurgedChat } from '../../../spec/mesh/hyperschema/types.d.ts';
|
|
3
|
+
import { AGENTS, CHATS, CHUNKS, CHUNK_COUNTERS, DEVICES, INDEXING_STATUS, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, PURGED_CHATS } from '../collections.ts';
|
|
4
|
+
export interface ChangedRows {
|
|
5
|
+
[AGENTS]: QvacAgent;
|
|
6
|
+
[DEVICES]: QvacDevice;
|
|
7
|
+
[CHATS]: QvacChat;
|
|
8
|
+
[CHUNK_COUNTERS]: QvacChunkCounter;
|
|
9
|
+
[CHUNKS]: QvacChunk;
|
|
10
|
+
[INDEXING_STATUS]: QvacIndexingStatus;
|
|
11
|
+
[KNOWLEDGE]: QvacKnowledge;
|
|
12
|
+
[KNOWLEDGE_ARTIFACTS]: QvacKnowledgeArtifact;
|
|
13
|
+
[PURGED_CHATS]: QvacPurgedChat;
|
|
14
|
+
}
|
|
15
|
+
export type ChangedRow<C extends keyof ChangedRows> = ViewChange & {
|
|
16
|
+
readonly collection: C;
|
|
17
|
+
readonly value: ChangedRows[C];
|
|
18
|
+
};
|
|
19
|
+
export declare function changed<C extends keyof ChangedRows>(change: ViewChange, collection: C): change is ChangedRow<C>;
|
|
20
|
+
export declare function liveRow<C extends keyof ChangedRows>(change: ChangedRow<C>): ChangedRows[C] | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AGENTS, CHATS, CHUNKS, CHUNK_COUNTERS, DEVICES, INDEXING_STATUS, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, PURGED_CHATS } from '../collections.js';
|
|
2
|
+
export function changed(change, collection) {
|
|
3
|
+
return change.collection === collection;
|
|
4
|
+
}
|
|
5
|
+
export function liveRow(change) {
|
|
6
|
+
return change.type === 'delete' ? null : change.value;
|
|
7
|
+
}
|
|
@@ -9,6 +9,6 @@ export function syncOwnMember(mesh, device) {
|
|
|
9
9
|
export function syncDeviceRevocation(mesh, device) {
|
|
10
10
|
if (!isOwnKickedRow(mesh, device))
|
|
11
11
|
return;
|
|
12
|
-
|
|
12
|
+
mesh.log?.info('sync', 'our writer was revoked (kicked)');
|
|
13
13
|
mesh.emit('kicked');
|
|
14
14
|
}
|
|
@@ -1,91 +1,63 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { toolsetEnabled } from '@qvac/harness/lib/tools/toolsets.ts';
|
|
3
|
-
import { ACTIVE_CHATS_BY_AGENT, AGENTS, CHATS, CHUNKS,
|
|
3
|
+
import { ACTIVE_CHATS_BY_AGENT, AGENTS, AGENTS_BY_PROVIDER, CHATS, CHUNKS, DEVICES, INDEXING_STATUS, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, KNOWLEDGE_BY_CHAT } from '../collections.js';
|
|
4
|
+
import { findChunksOfType } from '../chunk.js';
|
|
5
|
+
import { changed, liveRow } from './changed.js';
|
|
4
6
|
export class FileChanges {
|
|
5
7
|
_snap;
|
|
6
8
|
_from;
|
|
7
9
|
_documents = new Set();
|
|
8
10
|
_chats = new Set();
|
|
9
11
|
_agents = new Set();
|
|
10
|
-
_devices = new
|
|
12
|
+
_devices = new Map();
|
|
11
13
|
constructor(snap, from) {
|
|
12
14
|
this._snap = snap;
|
|
13
15
|
this._from = from;
|
|
14
16
|
}
|
|
15
17
|
async add(change) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
case CHUNKS: {
|
|
21
|
-
const chunk = await this._snap.get(collection, query);
|
|
22
|
-
if (chunk?.attachment && chunk.id === chunk.attachment.id) {
|
|
23
|
-
this._documents.add(chunk.id);
|
|
24
|
-
}
|
|
25
|
-
break;
|
|
18
|
+
if (changed(change, CHUNKS)) {
|
|
19
|
+
const chunk = liveRow(change);
|
|
20
|
+
if (chunk && isCanonicalAttachment(chunk)) {
|
|
21
|
+
this._documents.add(chunk.id);
|
|
26
22
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (typeof row?.knowledgeId === 'string') {
|
|
36
|
-
this._documents.add(row.knowledgeId);
|
|
37
|
-
}
|
|
38
|
-
break;
|
|
23
|
+
}
|
|
24
|
+
else if (changed(change, KNOWLEDGE)) {
|
|
25
|
+
this._documents.add(change.value.id);
|
|
26
|
+
}
|
|
27
|
+
else if (changed(change, KNOWLEDGE_ARTIFACTS) || changed(change, INDEXING_STATUS)) {
|
|
28
|
+
const row = liveRow(change) ?? (await this._was(change));
|
|
29
|
+
if (row) {
|
|
30
|
+
this._documents.add(row.knowledgeId);
|
|
39
31
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
before.agentId !== after.agentId ||
|
|
46
|
-
!!before.deletedAt !== !!after.deletedAt) {
|
|
47
|
-
const row = after ?? before;
|
|
48
|
-
if (row) {
|
|
49
|
-
this._chats.add(row.id);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
break;
|
|
32
|
+
}
|
|
33
|
+
else if (changed(change, CHATS)) {
|
|
34
|
+
const [was, now] = [await this._was(change), liveRow(change)];
|
|
35
|
+
if (!was || !now || was.agentId !== now.agentId || !!was.deletedAt !== !!now.deletedAt) {
|
|
36
|
+
this._chats.add(change.value.id);
|
|
53
37
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
!b4a.equals(before.providerDeviceId, after.providerDeviceId) ||
|
|
60
|
-
!!before.deletedAt !== !!after.deletedAt ||
|
|
61
|
-
toolsetEnabled('knowledge', before.disabledToolsets) !==
|
|
62
|
-
toolsetEnabled('knowledge', after.disabledToolsets)) {
|
|
63
|
-
const row = after ?? before;
|
|
64
|
-
if (row) {
|
|
65
|
-
this._agents.add(row.id);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
break;
|
|
38
|
+
}
|
|
39
|
+
else if (changed(change, AGENTS)) {
|
|
40
|
+
const [was, now] = [await this._was(change), liveRow(change)];
|
|
41
|
+
if (!was || !now || movedKnowledge(was, now)) {
|
|
42
|
+
this._agents.add(change.value.id);
|
|
69
43
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (row) {
|
|
76
|
-
this._devices.add(b4a.toHex(row.id));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
44
|
+
}
|
|
45
|
+
else if (changed(change, DEVICES)) {
|
|
46
|
+
const [was, now] = [await this._was(change), liveRow(change)];
|
|
47
|
+
if (!was || !now || !!was.revoked !== !!now.revoked) {
|
|
48
|
+
this._devices.set(b4a.toHex(change.value.id), change.value.id);
|
|
80
49
|
}
|
|
81
50
|
}
|
|
82
51
|
}
|
|
52
|
+
_was(change) {
|
|
53
|
+
const query = { id: change.value.id };
|
|
54
|
+
return this._snap.get(change.collection, query, { checkout: this._from });
|
|
55
|
+
}
|
|
83
56
|
async ids() {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
57
|
+
for (const providerDeviceId of this._devices.values()) {
|
|
58
|
+
const range = { gte: { providerDeviceId }, lte: { providerDeviceId } };
|
|
59
|
+
for await (const agent of this._snap.find(AGENTS_BY_PROVIDER, range)) {
|
|
60
|
+
this._agents.add(agent.id);
|
|
89
61
|
}
|
|
90
62
|
}
|
|
91
63
|
for (const agentId of this._agents) {
|
|
@@ -103,11 +75,8 @@ export class FileChanges {
|
|
|
103
75
|
})) {
|
|
104
76
|
this._documents.add(document.id);
|
|
105
77
|
}
|
|
106
|
-
for
|
|
107
|
-
|
|
108
|
-
lte: { chatId }
|
|
109
|
-
})) {
|
|
110
|
-
if (chunk.attachment && chunk.id === chunk.attachment.id) {
|
|
78
|
+
for (const chunk of await findChunksOfType(this._snap, { chatId, type: 'attachment' })) {
|
|
79
|
+
if (isCanonicalAttachment(chunk)) {
|
|
111
80
|
this._documents.add(chunk.id);
|
|
112
81
|
}
|
|
113
82
|
}
|
|
@@ -115,3 +84,12 @@ export class FileChanges {
|
|
|
115
84
|
return this._documents;
|
|
116
85
|
}
|
|
117
86
|
}
|
|
87
|
+
function movedKnowledge(was, now) {
|
|
88
|
+
return (!b4a.equals(was.providerDeviceId, now.providerDeviceId) ||
|
|
89
|
+
!!was.deletedAt !== !!now.deletedAt ||
|
|
90
|
+
toolsetEnabled('knowledge', was.disabledToolsets) !==
|
|
91
|
+
toolsetEnabled('knowledge', now.disabledToolsets));
|
|
92
|
+
}
|
|
93
|
+
function isCanonicalAttachment(chunk) {
|
|
94
|
+
return !!chunk.attachment && chunk.id === chunk.attachment.id;
|
|
95
|
+
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { Mesh, MeshView, ViewHead } from '../mesh.ts';
|
|
2
|
-
export declare function syncChanges(mesh: Mesh, view: MeshView, from: ViewHead): Promise<
|
|
3
|
-
export declare function syncSnapshot(mesh: Mesh, view: MeshView, from: ViewHead): Promise<void>;
|
|
2
|
+
export declare function syncChanges(mesh: Mesh, view: MeshView, from: ViewHead): Promise<ViewHead | null>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { changed } from './changed.js';
|
|
1
2
|
import { FileChanges } from './files.js';
|
|
2
3
|
import { syncDeviceRevocation, syncOwnMember } from './devices.js';
|
|
3
4
|
import { syncChatTombstone } from './chats.js';
|
|
@@ -5,72 +6,54 @@ import { syncNotificationChunk } from './chunks.js';
|
|
|
5
6
|
import { AGENTS, CHATS, CHUNKS, CHUNK_COUNTERS, DEVICES, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, MEMBERS, MESH_NAMES, MESH_SEEDS, PURGED_CHATS } from '../collections.js';
|
|
6
7
|
export async function syncChanges(mesh, view, from) {
|
|
7
8
|
if (mesh.closing)
|
|
8
|
-
return;
|
|
9
|
+
return null;
|
|
9
10
|
const pass = newPass();
|
|
11
|
+
const reached = view.db.db.head();
|
|
10
12
|
const snap = view.db.snapshot();
|
|
11
13
|
const files = new FileChanges(snap, from);
|
|
12
14
|
try {
|
|
13
|
-
|
|
14
|
-
await walkChanges(mesh, { snap, from, files, pass });
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
logger.warn('sync', 'change sync cut short', err);
|
|
18
|
-
pass.membershipMoved = pass.agentsDirty = pass.meshesChanged = pass.nameChanged = true;
|
|
19
|
-
}
|
|
20
|
-
pass.indexingDirty = await files.ids();
|
|
15
|
+
await walkChanges(mesh, { snap, from, files, pass });
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
catch (err) {
|
|
18
|
+
mesh.log?.warn('sync', 'change sync cut short', err);
|
|
19
|
+
pass.membershipMoved = pass.agentsDirty = pass.meshesChanged = pass.nameChanged = true;
|
|
24
20
|
}
|
|
25
|
-
await settle(mesh, pass);
|
|
26
|
-
}
|
|
27
|
-
export async function syncSnapshot(mesh, view, from) {
|
|
28
|
-
if (mesh.closing)
|
|
29
|
-
return;
|
|
30
|
-
const pass = {
|
|
31
|
-
...newPass(),
|
|
32
|
-
whole: true,
|
|
33
|
-
membershipMoved: true,
|
|
34
|
-
agentsDirty: true,
|
|
35
|
-
meshesChanged: true,
|
|
36
|
-
nameChanged: true
|
|
37
|
-
};
|
|
38
|
-
const snap = view.db.snapshot();
|
|
39
21
|
try {
|
|
40
|
-
await
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
logger.warn('sync', 'snapshot sync cut short', err);
|
|
22
|
+
await settle(mesh, pass);
|
|
44
23
|
}
|
|
45
24
|
finally {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
void offPath(mesh, files, pass)
|
|
26
|
+
.catch((err) => {
|
|
27
|
+
if (!mesh.closing) {
|
|
28
|
+
mesh.log?.warn('sync', 'off-path sync failed', err);
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
.finally(() => snap.close());
|
|
32
|
+
}
|
|
33
|
+
return reached && { key: reached.key, length: reached.length };
|
|
49
34
|
}
|
|
50
|
-
async function
|
|
51
|
-
|
|
35
|
+
async function offPath(mesh, files, pass) {
|
|
36
|
+
const indexingDirty = await files.ids();
|
|
37
|
+
if (indexingDirty.size) {
|
|
38
|
+
mesh.emit('indexing-dirty', indexingDirty);
|
|
39
|
+
}
|
|
40
|
+
await mesh.files.reclaimAttachments(pass.attachments);
|
|
41
|
+
for (const row of pass.knowledge) {
|
|
52
42
|
if (mesh.closing)
|
|
53
43
|
return;
|
|
54
|
-
|
|
44
|
+
await mesh.files.syncKnowledge(row);
|
|
55
45
|
}
|
|
56
|
-
for
|
|
46
|
+
for (const row of pass.artifacts) {
|
|
57
47
|
if (mesh.closing)
|
|
58
48
|
return;
|
|
59
|
-
|
|
60
|
-
continue;
|
|
61
|
-
const before = await snap.get(CHATS, { id: chat.id }, { checkout: from });
|
|
62
|
-
if (!before?.deletedAt) {
|
|
63
|
-
syncChatTombstone(mesh, chat);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
for await (const row of snap.find(PURGED_CHATS)) {
|
|
67
|
-
pass.purged.set(row.chatId, row.at);
|
|
49
|
+
await mesh.files.syncArtifact(row);
|
|
68
50
|
}
|
|
69
51
|
}
|
|
70
52
|
function newPass() {
|
|
71
53
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
attachments: [],
|
|
55
|
+
knowledge: [],
|
|
56
|
+
artifacts: [],
|
|
74
57
|
orderDirty: new Set(),
|
|
75
58
|
purged: new Map(),
|
|
76
59
|
unattestedDevice: false,
|
|
@@ -95,25 +78,21 @@ async function settle(mesh, pass) {
|
|
|
95
78
|
mesh.emit('chat-purged', chatId);
|
|
96
79
|
}
|
|
97
80
|
}
|
|
98
|
-
if (pass.
|
|
99
|
-
mesh.
|
|
100
|
-
}
|
|
101
|
-
else if (pass.indexingDirty.size) {
|
|
102
|
-
mesh.emit('indexing-dirty', pass.indexingDirty);
|
|
81
|
+
if (pass.attachments.length) {
|
|
82
|
+
await mesh.fileIndex?.refresh(pass.attachments);
|
|
103
83
|
}
|
|
104
84
|
if (pass.unattestedDevice) {
|
|
105
85
|
mesh.emit('unattested-device');
|
|
106
86
|
}
|
|
107
87
|
if (pass.membershipMoved) {
|
|
108
|
-
await mesh.refreshMembership();
|
|
109
|
-
mesh.emit('membership-tallied');
|
|
110
88
|
mesh.emit('members-dirty');
|
|
89
|
+
mesh.tallyMembership();
|
|
111
90
|
}
|
|
112
91
|
if (pass.agentsDirty) {
|
|
113
92
|
mesh.emit('agents-dirty');
|
|
114
93
|
}
|
|
115
|
-
if (
|
|
116
|
-
await mesh.syncChatOrder(pass.
|
|
94
|
+
if (pass.orderDirty.size && mesh.syncChatOrder) {
|
|
95
|
+
await mesh.syncChatOrder(pass.orderDirty);
|
|
117
96
|
}
|
|
118
97
|
mesh.emit('meshes-dirty', pass.meshesChanged);
|
|
119
98
|
if (pass.nameChanged) {
|
|
@@ -147,13 +126,15 @@ async function walkChanges(mesh, { snap, from, files, pass }) {
|
|
|
147
126
|
}
|
|
148
127
|
else if (changed(change, CHUNKS)) {
|
|
149
128
|
syncNotificationChunk(mesh, change.value);
|
|
150
|
-
|
|
129
|
+
if (change.value.attachment) {
|
|
130
|
+
pass.attachments.push(change.value);
|
|
131
|
+
}
|
|
151
132
|
}
|
|
152
133
|
else if (changed(change, KNOWLEDGE)) {
|
|
153
|
-
|
|
134
|
+
pass.knowledge.push(change.value);
|
|
154
135
|
}
|
|
155
136
|
else if (changed(change, KNOWLEDGE_ARTIFACTS)) {
|
|
156
|
-
|
|
137
|
+
pass.artifacts.push(change.value);
|
|
157
138
|
}
|
|
158
139
|
else if (changed(change, PURGED_CHATS)) {
|
|
159
140
|
pass.purged.set(change.value.chatId, change.value.at);
|
|
@@ -166,6 +147,3 @@ async function walkChanges(mesh, { snap, from, files, pass }) {
|
|
|
166
147
|
}
|
|
167
148
|
}
|
|
168
149
|
}
|
|
169
|
-
function changed(change, collection) {
|
|
170
|
-
return change.collection === collection;
|
|
171
|
-
}
|