@qvac/core 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +80 -1
  2. package/dist-lib/index.d.ts +1 -0
  3. package/dist-lib/index.js +1 -0
  4. package/dist-lib/lib/api/chunk-delta.d.ts +6 -2
  5. package/dist-lib/lib/api/chunk-delta.js +69 -7
  6. package/dist-lib/lib/api/chunks.js +6 -2
  7. package/dist-lib/lib/api/config.d.ts +4 -1
  8. package/dist-lib/lib/api/config.js +23 -4
  9. package/dist-lib/lib/api/devices.js +3 -1
  10. package/dist-lib/lib/api/rag.js +4 -2
  11. package/dist-lib/lib/assistant/harness.d.ts +3 -1
  12. package/dist-lib/lib/assistant/harness.js +10 -0
  13. package/dist-lib/lib/assistant/history.js +25 -3
  14. package/dist-lib/lib/assistant/message.js +2 -2
  15. package/dist-lib/lib/assistant-tree.js +1 -1
  16. package/dist-lib/lib/assistant.d.ts +1 -0
  17. package/dist-lib/lib/assistant.js +14 -4
  18. package/dist-lib/lib/client.js +10 -1
  19. package/dist-lib/lib/core/archived-mesh.js +1 -0
  20. package/dist-lib/lib/core/chunk.d.ts +5 -2
  21. package/dist-lib/lib/core/chunk.js +74 -18
  22. package/dist-lib/lib/core/collections.d.ts +1 -0
  23. package/dist-lib/lib/core/collections.js +1 -0
  24. package/dist-lib/lib/core/config-value.d.ts +6 -0
  25. package/dist-lib/lib/core/config-value.js +14 -0
  26. package/dist-lib/lib/core/contract/chat.d.ts +1 -0
  27. package/dist-lib/lib/core/contract/chat.js +8 -1
  28. package/dist-lib/lib/core/contract/chunks.js +20 -6
  29. package/dist-lib/lib/core/contract/compute.d.ts +1 -1
  30. package/dist-lib/lib/core/contract/compute.js +2 -1
  31. package/dist-lib/lib/core/contract/devices.js +3 -2
  32. package/dist-lib/lib/core/departures.js +1 -0
  33. package/dist-lib/lib/core/devices.d.ts +2 -1
  34. package/dist-lib/lib/core/devices.js +4 -2
  35. package/dist-lib/lib/core/files/index.d.ts +1 -1
  36. package/dist-lib/lib/core/files/index.js +1 -1
  37. package/dist-lib/lib/core/files/rag/index.d.ts +1 -1
  38. package/dist-lib/lib/core/files/rag/index.js +1 -1
  39. package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +1 -0
  40. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +4 -1
  41. package/dist-lib/lib/core/inference-calls-receiver.js +2 -2
  42. package/dist-lib/lib/core/known-sender.d.ts +3 -0
  43. package/dist-lib/lib/core/known-sender.js +26 -0
  44. package/dist-lib/lib/core/local/index.d.ts +2 -0
  45. package/dist-lib/lib/core/local/index.js +17 -10
  46. package/dist-lib/lib/core/mesh.d.ts +5 -1
  47. package/dist-lib/lib/core/mesh.js +6 -6
  48. package/dist-lib/lib/core/migrations/chat-chunks.d.ts +4 -0
  49. package/dist-lib/lib/core/migrations/chat-chunks.js +43 -0
  50. package/dist-lib/lib/core/skill-overlay-receiver.js +2 -2
  51. package/dist-lib/lib/core/skill-secrets.js +2 -2
  52. package/dist-lib/lib/core.d.ts +11 -1
  53. package/dist-lib/lib/core.js +50 -5
  54. package/dist-lib/lib/device-tree.d.ts +18 -0
  55. package/dist-lib/lib/device-tree.js +32 -0
  56. package/dist-lib/schema/engine.js +20 -3
  57. package/dist-lib/schema/field-order.js +8 -1
  58. package/dist-lib/schema/local.js +7 -3
  59. package/dist-lib/schema/qvac.js +19 -2
  60. package/dist-lib/spec/hrpc/messages.js +1236 -1184
  61. package/dist-lib/spec/hyperschema/index.js +1236 -1184
  62. package/dist-lib/spec/hyperschema/schema.json +47 -0
  63. package/dist-lib/spec/hyperschema/types.d.ts +11 -0
  64. package/dist-lib/spec/local/hyperdb/messages.js +70 -20
  65. package/dist-lib/spec/local/hyperschema/index.js +36 -11
  66. package/dist-lib/spec/local/hyperschema/schema.json +21 -1
  67. package/dist-lib/spec/local/hyperschema/types.d.ts +5 -1
  68. package/dist-lib/spec/mesh/hyperdb/db.json +17 -1
  69. package/dist-lib/spec/mesh/hyperdb/index.js +83 -2
  70. package/dist-lib/spec/mesh/hyperdb/messages.js +573 -255
  71. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +7 -1
  72. package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
  73. package/dist-lib/spec/mesh/hyperdispatch/messages.js +121 -8
  74. package/dist-lib/spec/mesh/hyperschema/index.js +121 -8
  75. package/dist-lib/spec/mesh/hyperschema/schema.json +69 -1
  76. package/dist-lib/spec/mesh/hyperschema/types.d.ts +19 -1
  77. package/package.json +9 -8
@@ -0,0 +1,43 @@
1
+ import { Range, Version, constants, satisfies } from 'bare-semver';
2
+ import { CHAT_CHUNKS, CHUNK_COUNTERS, PURGED_CHATS } from '../collections.js';
3
+ import { releaseVersion } from '../min-version.js';
4
+ export const REINDEX_FROM_APP_VERSION = '0.21.0';
5
+ export function floorExcludesBefore(range, release) {
6
+ let floor;
7
+ try {
8
+ floor = Range.parse(range ?? '');
9
+ }
10
+ catch {
11
+ return false;
12
+ }
13
+ const atLeast = Range.parse(`>=${releaseVersion(release)}`);
14
+ return (floor.comparators.length > 0 &&
15
+ floor.comparators.every((set) => set.some((bound) => LOWER_BOUNDS.has(bound.operator) && satisfies(releaseOf(bound.version), atLeast))));
16
+ }
17
+ const LOWER_BOUNDS = new Set([constants.GTE, constants.GT, constants.EQ]);
18
+ function releaseOf({ major, minor, patch }) {
19
+ return new Version(major, minor, patch);
20
+ }
21
+ export async function backfillChatChunks(mesh) {
22
+ const counters = await mesh.view.find(CHUNK_COUNTERS).toArray();
23
+ const purged = await mesh.view.find(PURGED_CHATS).toArray();
24
+ let sent = 0;
25
+ for (const chat of [...counters, ...purged]) {
26
+ if (mesh.closing || !mesh.writable)
27
+ break;
28
+ const due = 'count' in chat ? !(await holdsEnds(mesh.view, chat)) : await holdsAny(mesh.view, chat);
29
+ if (due) {
30
+ await mesh.dispatch('reindex-chat-chunks', { chatId: chat.chatId });
31
+ sent++;
32
+ }
33
+ }
34
+ return sent;
35
+ }
36
+ async function holdsEnds(db, { chatId, count }) {
37
+ const first = await db.get(CHAT_CHUNKS, { chatId, seq: 0 });
38
+ const last = await db.get(CHAT_CHUNKS, { chatId, seq: count - 1 });
39
+ return first !== null && last !== null;
40
+ }
41
+ async function holdsAny(db, { chatId }) {
42
+ return ((await db.find(CHAT_CHUNKS, { gte: { chatId }, lte: { chatId } }).one()) !== null);
43
+ }
@@ -1,10 +1,10 @@
1
1
  import b4a from 'b4a';
2
2
  import { getAgent } from './agent.js';
3
- import { DEVICES } from './collections.js';
4
3
  import { CoreError } from '../errors.js';
4
+ import { knownSender } from './known-sender.js';
5
5
  export function createSkillOverlayReceiver(opts) {
6
6
  return async (op, fromDeviceId) => {
7
- const sender = await opts.mesh.view.get(DEVICES, { id: fromDeviceId });
7
+ const sender = await knownSender(opts.mesh, fromDeviceId);
8
8
  if (!sender || sender.revoked) {
9
9
  throw new CoreError('PEER_SENDER_REVOKED');
10
10
  }
@@ -4,11 +4,11 @@ import { isDeviceSharedCredentialKey } from '@qvac/harness/lib/tools/skills/scop
4
4
  import { settingConfigKey } from '../credential-pusher.js';
5
5
  import { scopedKey } from '../oauth/keys.js';
6
6
  import { getAgent } from './agent.js';
7
- import { DEVICES } from './collections.js';
8
7
  import { CoreError } from '../errors.js';
8
+ import { knownSender } from './known-sender.js';
9
9
  export function createSkillSecretReceiver(opts) {
10
10
  return async (request, fromDeviceId) => {
11
- const sender = await opts.mesh.view.get(DEVICES, { id: fromDeviceId });
11
+ const sender = await knownSender(opts.mesh, fromDeviceId);
12
12
  if (!sender || sender.revoked) {
13
13
  throw new CoreError('PEER_SENDER_REVOKED');
14
14
  }
@@ -80,6 +80,13 @@ export interface CoreOptions {
80
80
  readonly suspend: () => Promise<void>;
81
81
  readonly resume: () => Promise<void>;
82
82
  };
83
+ network?: NetworkGate;
84
+ }
85
+ export interface NetworkConnection {
86
+ destroy(): void;
87
+ }
88
+ export interface NetworkGate {
89
+ readonly onConnection?: (conn: NetworkConnection) => void;
83
90
  }
84
91
  export declare const DEVICE_UNKNOWN = "This device has no device details: pass `device` when creating Core";
85
92
  export interface SharedMesh {
@@ -131,6 +138,7 @@ export declare class Core extends ReadyResource {
131
138
  private readonly _log;
132
139
  private readonly _spec;
133
140
  private readonly _bootstrapNodes;
141
+ private readonly _network;
134
142
  private readonly _device;
135
143
  private readonly _app;
136
144
  private _minSupportedVersion;
@@ -235,7 +243,7 @@ export declare class Core extends ReadyResource {
235
243
  private _systemInfo;
236
244
  private _statusError;
237
245
  private _upgradeRequired;
238
- constructor(transport: Transport, { storagePath, store, swarm, wakeup, logger, spec, bootstrapNodes, device, app, minSupportedVersion, otaConfigCore, blindPeerKeys, blindPeeringOpts, fileGc, autoDownloadModels, meshSeed, meshKey, additionalNodes, listModels, deleteModel, clearKvCache, deleteChatKvCache, compactChat, modelCatalogWatch, retryModelDownload, transcribe, detectLanguage, previewModelSource, speak, speakStream, embedder, extractors, skills, skillCatalog, tools, hostsModelSource, vectorIndex, apiLifecycle }: CoreOptions);
246
+ constructor(transport: Transport, { storagePath, store, swarm, wakeup, logger, spec, bootstrapNodes, device, app, minSupportedVersion, otaConfigCore, blindPeerKeys, blindPeeringOpts, fileGc, autoDownloadModels, meshSeed, meshKey, additionalNodes, listModels, deleteModel, clearKvCache, deleteChatKvCache, compactChat, modelCatalogWatch, retryModelDownload, transcribe, detectLanguage, previewModelSource, speak, speakStream, embedder, extractors, skills, skillCatalog, tools, hostsModelSource, vectorIndex, apiLifecycle, network }: CoreOptions);
239
247
  get devicePublicKey(): Buffer | null;
240
248
  private _requireDeviceKeyPair;
241
249
  get fsDrives(): DriveHost | null;
@@ -371,6 +379,7 @@ export declare class Core extends ReadyResource {
371
379
  private _pendingUpdatesFor;
372
380
  private _fileIndexFor;
373
381
  private _indexMeshFiles;
382
+ private _backfillChatChunks;
374
383
  private _servedFile;
375
384
  clearOldFiles({ olderThanMs, includeOwn }: ClearOldFilesOptions): Promise<number>;
376
385
  private _startFileGc;
@@ -437,6 +446,7 @@ export declare class Core extends ReadyResource {
437
446
  pushSkillSecret(request: SecretRequest): Promise<void>;
438
447
  private _storeHandedOffSecret;
439
448
  private _followJoinedMeshes;
449
+ private _followJoinedMeshesPass;
440
450
  private _followMeshRows;
441
451
  private _trackFollow;
442
452
  private _retireLeftMesh;
@@ -45,6 +45,7 @@ import { openRecoveryCore, publishRecovery, readRecovery, recoveryKeys } from '.
45
45
  import { claimOwnMembership, legacyNameStamp, namedAt, renameFoundedMember } from './core/membership.js';
46
46
  import { runMigrations } from './core/migrations/index.js';
47
47
  import { backfillFileIndex } from './core/migrations/file-index.js';
48
+ import { REINDEX_FROM_APP_VERSION, backfillChatChunks, floorExcludesBefore } from './core/migrations/chat-chunks.js';
48
49
  import { advertiseDeviceVersion, retractInventory } from './core/devices.js';
49
50
  import { DeviceControl } from './core/device-control.js';
50
51
  import { forwardToDevices, servedToSiblings } from './api/device-routes.js';
@@ -89,6 +90,7 @@ export class Core extends ReadyResource {
89
90
  _log;
90
91
  _spec;
91
92
  _bootstrapNodes;
93
+ _network;
92
94
  _device;
93
95
  _app;
94
96
  _minSupportedVersion;
@@ -193,7 +195,7 @@ export class Core extends ReadyResource {
193
195
  _systemInfo;
194
196
  _statusError;
195
197
  _upgradeRequired;
196
- constructor(transport, { storagePath, store = undefined, swarm = undefined, wakeup = undefined, logger = null, spec = openLocalSpec, bootstrapNodes = undefined, device = undefined, app = undefined, minSupportedVersion = undefined, otaConfigCore = undefined, blindPeerKeys = undefined, blindPeeringOpts = undefined, fileGc = null, autoDownloadModels = undefined, meshSeed = undefined, meshKey = undefined, additionalNodes = undefined, listModels = undefined, deleteModel = undefined, clearKvCache = undefined, deleteChatKvCache = undefined, compactChat = undefined, modelCatalogWatch = undefined, retryModelDownload = undefined, transcribe = undefined, detectLanguage = undefined, previewModelSource = undefined, speak = undefined, speakStream = undefined, embedder = undefined, extractors = undefined, skills = undefined, skillCatalog = undefined, tools = undefined, hostsModelSource = false, vectorIndex = undefined, apiLifecycle = undefined }) {
198
+ constructor(transport, { storagePath, store = undefined, swarm = undefined, wakeup = undefined, logger = null, spec = openLocalSpec, bootstrapNodes = undefined, device = undefined, app = undefined, minSupportedVersion = undefined, otaConfigCore = undefined, blindPeerKeys = undefined, blindPeeringOpts = undefined, fileGc = null, autoDownloadModels = undefined, meshSeed = undefined, meshKey = undefined, additionalNodes = undefined, listModels = undefined, deleteModel = undefined, clearKvCache = undefined, deleteChatKvCache = undefined, compactChat = undefined, modelCatalogWatch = undefined, retryModelDownload = undefined, transcribe = undefined, detectLanguage = undefined, previewModelSource = undefined, speak = undefined, speakStream = undefined, embedder = undefined, extractors = undefined, skills = undefined, skillCatalog = undefined, tools = undefined, hostsModelSource = false, vectorIndex = undefined, apiLifecycle = undefined, network = undefined }) {
197
199
  super();
198
200
  this._transport = transport;
199
201
  this._apiLifecycle = apiLifecycle ?? {
@@ -219,6 +221,7 @@ export class Core extends ReadyResource {
219
221
  this.state = QvacState.RESUME;
220
222
  this._spec = spec;
221
223
  this._bootstrapNodes = bootstrapNodes;
224
+ this._network = network;
222
225
  this._device = device;
223
226
  this._app = app;
224
227
  this._minSupportedVersion = minSupportedVersion;
@@ -774,6 +777,9 @@ export class Core extends ReadyResource {
774
777
  if (withheld) {
775
778
  void this._reopenMesh();
776
779
  }
780
+ for (const { mesh } of this._meshes.values()) {
781
+ void this._backfillChatChunks(mesh);
782
+ }
777
783
  return;
778
784
  }
779
785
  for (const { mesh } of [...this._meshes.values()]) {
@@ -984,6 +990,10 @@ export class Core extends ReadyResource {
984
990
  bootstrap: this._bootstrapNodes,
985
991
  relayThrough: this._bootstrapNodes ? undefined : () => BLIND_RELAY_KEYS
986
992
  });
993
+ const onConnection = this._network?.onConnection;
994
+ if (onConnection) {
995
+ this._swarm.on('connection', (conn) => onConnection(conn));
996
+ }
987
997
  this._swarm.on('connection', this._onSwarmConnection);
988
998
  for (const conn of this._swarm.connections) {
989
999
  if (isPeerConnection(conn)) {
@@ -1050,6 +1060,7 @@ export class Core extends ReadyResource {
1050
1060
  writerSeed: session.writerSeed,
1051
1061
  logger: this._log,
1052
1062
  blindPeerKeys: this._resolveBlindPeerKeys(blindPeerKeys),
1063
+ bootFrom: session.bootFrom,
1053
1064
  trustedDevice: (deviceId) => this._isOurMemberDevice(deviceId),
1054
1065
  wakeup: this._wakeup,
1055
1066
  attachmentUrl: (attachment) => this._linkAttachment(attachment, mesh),
@@ -2075,7 +2086,10 @@ export class Core extends ReadyResource {
2075
2086
  }
2076
2087
  }
2077
2088
  async _joinCandidate(invite, source, deviceId) {
2078
- const session = this.local.createCandidateSession(invite.seed, invite.baseKey, invite.compute);
2089
+ const session = {
2090
+ ...this.local.createCandidateSession(invite.seed, invite.baseKey, invite.compute),
2091
+ bootFrom: invite.fastForward
2092
+ };
2079
2093
  let candidate;
2080
2094
  try {
2081
2095
  candidate = await this._openCandidateMesh(invite, session);
@@ -2283,6 +2297,9 @@ export class Core extends ReadyResource {
2283
2297
  const held = key ? (this._pooled(b4a.toHex(key)) ?? this._opening.get(b4a.toHex(key))) : null;
2284
2298
  const mesh = key ? await this._openPooledMesh(b4a.toHex(key)).catch(noop) : null;
2285
2299
  if (mesh && !mesh.ourMemberId) {
2300
+ if (mesh.writable) {
2301
+ await mesh.autobee.update();
2302
+ }
2286
2303
  await mesh.refreshOurMember();
2287
2304
  }
2288
2305
  if (!mesh?.writable) {
@@ -2304,7 +2321,7 @@ export class Core extends ReadyResource {
2304
2321
  writerSeed: session.writerSeed,
2305
2322
  logger: this._log,
2306
2323
  blindPeerKeys: this._resolveBlindPeerKeys(invite.blindPeers),
2307
- bootFrom: invite.fastForward,
2324
+ bootFrom: session.bootFrom,
2308
2325
  trustedDevice: (deviceId) => this._isOurMemberDevice(deviceId),
2309
2326
  wakeup: this._wakeup,
2310
2327
  attachmentUrl: (attachment) => this._linkAttachment(attachment, candidate),
@@ -2431,11 +2448,11 @@ export class Core extends ReadyResource {
2431
2448
  }
2432
2449
  mesh.on('members-dirty', () => void this._revalidateLoans());
2433
2450
  mesh.on('members-dirty', () => void this._deviceControl.revalidate());
2451
+ mesh.on('members-dirty', () => void this._revokeInMeshes());
2434
2452
  mesh.on('members-dirty', () => {
2435
2453
  if (!this._isAccount(mesh))
2436
2454
  return;
2437
2455
  void this._followAccountName(mesh);
2438
- void this._revokeInMeshes();
2439
2456
  });
2440
2457
  mesh.on('meshes-dirty', (changed) => {
2441
2458
  if (changed || entry.meshesPending) {
@@ -2474,6 +2491,7 @@ export class Core extends ReadyResource {
2474
2491
  this._upgradeRequired = null;
2475
2492
  if (mesh.writable) {
2476
2493
  this._kicked = false;
2494
+ void this.local.markAwaitingAdmission(mesh.key, { awaitingAdmission: false }).catch(noop);
2477
2495
  }
2478
2496
  this._notifyStatus();
2479
2497
  }
@@ -2599,6 +2617,21 @@ export class Core extends ReadyResource {
2599
2617
  }
2600
2618
  }
2601
2619
  }
2620
+ async _backfillChatChunks(mesh) {
2621
+ if (!floorExcludesBefore(this._minSupportedVersion, REINDEX_FROM_APP_VERSION)) {
2622
+ return;
2623
+ }
2624
+ try {
2625
+ await mesh.waitForWritable();
2626
+ await mesh.autobee.update();
2627
+ await backfillChatChunks(mesh);
2628
+ }
2629
+ catch (err) {
2630
+ if (!mesh.closing) {
2631
+ this._log?.warn(['p2p', 'mesh'], 'copying chats into chat-chunks failed', err);
2632
+ }
2633
+ }
2634
+ }
2602
2635
  _servedFile(mesh, coreKey, blockOffset) {
2603
2636
  this.local.files
2604
2637
  .touch({ meshKey: mesh.key, coreKey, blockOffset })
@@ -2767,6 +2800,7 @@ export class Core extends ReadyResource {
2767
2800
  }
2768
2801
  };
2769
2802
  void this._indexMeshFiles(mesh).then(() => Promise.all([reclaim(), sweep()]));
2803
+ void this._backfillChatChunks(mesh);
2770
2804
  mesh.autobee.on('move-to', () => void sweep());
2771
2805
  entry.hostedAgents = new HostedAgents({
2772
2806
  mesh,
@@ -3726,7 +3760,18 @@ export class Core extends ReadyResource {
3726
3760
  });
3727
3761
  return receive(request, fromDeviceId);
3728
3762
  }
3729
- async _followJoinedMeshes(memberMesh) {
3763
+ _followJoinedMeshes(memberMesh) {
3764
+ return this._followJoinedMeshesPass(memberMesh).catch((err) => {
3765
+ const entry = this._meshes.get(this._meshIdOf(memberMesh));
3766
+ if (entry?.mesh === memberMesh) {
3767
+ entry.meshesPending = true;
3768
+ }
3769
+ if (!this.closing) {
3770
+ this._log?.warn(['p2p', 'mesh'], 'following the joined meshes failed', err);
3771
+ }
3772
+ });
3773
+ }
3774
+ async _followJoinedMeshesPass(memberMesh) {
3730
3775
  if (this.closing || !this._isPooled(memberMesh))
3731
3776
  return;
3732
3777
  const entry = this._meshes.get(this._meshIdOf(memberMesh));
@@ -0,0 +1,18 @@
1
+ import Supervisor from 'bare-supervisor';
2
+ import type { Transport } from '@qvac/harness/rpc';
3
+ import type { LoggerInterface } from '@qvac/logging';
4
+ import { type AssistantChildOptions } from './assistant-tree.ts';
5
+ import { Core, type CoreOptions } from './core.ts';
6
+ export interface DeviceTreeOptions {
7
+ core: Omit<CoreOptions, 'apiLifecycle'>;
8
+ assistant: Omit<AssistantChildOptions, 'core'>;
9
+ office?: {
10
+ close: () => unknown;
11
+ };
12
+ logger?: LoggerInterface | null;
13
+ }
14
+ export interface DeviceTree {
15
+ supervisor: Supervisor;
16
+ core: Core;
17
+ }
18
+ export declare function deviceTree(transport: Transport, opts: DeviceTreeOptions): DeviceTree;
@@ -0,0 +1,32 @@
1
+ import Supervisor from 'bare-supervisor';
2
+ import { assistantChild } from './assistant-tree.js';
3
+ import { Core } from './core.js';
4
+ export function deviceTree(transport, opts) {
5
+ const { office, logger = null } = opts;
6
+ const supervisor = new Supervisor();
7
+ const core = new Core(transport, {
8
+ ...opts.core,
9
+ apiLifecycle: {
10
+ suspend: () => supervisor.suspend(),
11
+ resume: () => supervisor.resume()
12
+ }
13
+ });
14
+ if (office) {
15
+ supervisor.add('office', { start: () => office });
16
+ }
17
+ supervisor.add('core', {
18
+ deps: office ? ['office'] : [],
19
+ start: () => core,
20
+ presuspend: (handle) => handle.presuspend(),
21
+ suspend: (handle) => handle.suspend(),
22
+ wakeup: (handle) => handle.wakeup(),
23
+ resume: (handle) => handle.resume()
24
+ });
25
+ supervisor.add('assistant', assistantChild({ logger, ...opts.assistant }));
26
+ for (const event of ['child-died', 'child-restarting', 'stall']) {
27
+ supervisor.on(event, (payload) => logger?.warn('device-tree', event, { ...payload, error: payload.error?.message }));
28
+ }
29
+ supervisor.on('gave-up', ({ name, error }) => logger?.error('device-tree', `${name} gave up`, error?.message));
30
+ supervisor.on('power', (payload) => logger?.info('device-tree', 'power', payload));
31
+ return { supervisor, core };
32
+ }
@@ -29,7 +29,13 @@ export function registerEngineTypes(ns) {
29
29
  { name: 'deviceId', type: 'fixed32' }
30
30
  ]
31
31
  });
32
- ns.register({ name: 'config-value', fields: [{ name: 'value', type: 'json' }] });
32
+ ns.register({
33
+ name: 'config-value',
34
+ fields: [
35
+ { name: 'value', type: 'json' },
36
+ { name: 'falsyValue', type: 'string' }
37
+ ]
38
+ });
33
39
  ns.register({
34
40
  name: 'config-set-request',
35
41
  fields: [
@@ -464,6 +470,15 @@ export function registerEngineTypes(ns) {
464
470
  { name: 'writeRootsRequired', type: 'bool' }
465
471
  ]
466
472
  });
473
+ ns.register({
474
+ name: 'custom-model-report-entry',
475
+ fields: [
476
+ { name: 'name', type: 'string', required: true },
477
+ { name: 'label', type: 'string', required: true },
478
+ { name: 'taskType', type: 'string' },
479
+ { name: 'expectedSize', type: 'uint' }
480
+ ]
481
+ });
467
482
  ns.register({
468
483
  name: 'device',
469
484
  fields: [
@@ -483,7 +498,8 @@ export function registerEngineTypes(ns) {
483
498
  { name: 'platform', type: 'string' },
484
499
  { name: 'readySkillNames', type: 'string', array: true },
485
500
  { name: 'toolCatalog', type: '@assistant/tool-report-entry', array: true },
486
- { name: 'memberId', type: 'fixed32' }
501
+ { name: 'memberId', type: 'fixed32' },
502
+ { name: 'customModels', type: '@assistant/custom-model-report-entry', array: true }
487
503
  ]
488
504
  });
489
505
  ns.register({
@@ -519,7 +535,8 @@ export function registerEngineTypes(ns) {
519
535
  { name: 'cachedModelNames', type: 'string', array: true },
520
536
  { name: 'readySkillNames', type: 'string', array: true },
521
537
  { name: 'toolCatalog', type: '@assistant/tool-report-entry', array: true },
522
- { name: 'meshId', type: 'string', required: true }
538
+ { name: 'meshId', type: 'string', required: true },
539
+ { name: 'customModels', type: '@assistant/custom-model-report-entry', array: true }
523
540
  ]
524
541
  });
525
542
  ns.register({
@@ -1,6 +1,13 @@
1
1
  import fs from 'bare-fs';
2
2
  import { spawnSync } from 'bare-subprocess';
3
- const EXEMPT = {};
3
+ const EXEMPT = {
4
+ '@qvac/writer-v1.device': 'add-writer carries a BirthRow or claimableDevice() from lib/core/mesh.ts, never customModels',
5
+ '@qvac/writer-claim-v1.device': 'claimableDevice() in lib/core/mesh.ts sends only the fields the released build decodes',
6
+ '@qvac/open-join-v1.device': 'claimableDevice() in lib/core/mesh.ts, as for the writer claim',
7
+ '@qvac/vouched-join-v1.device': 'deprecated: no build dispatches it, it is only replayed',
8
+ '@qvac/invite-claim-v1.device': 'deprecated: no build dispatches it, it is only replayed',
9
+ '@qvac/recovery-claim-v1.device': 'deprecated: no build dispatches it, it is only replayed'
10
+ };
4
11
  export function assertFieldOrder(root, schemaFile, tags) {
5
12
  const current = index(JSON.parse(fs.readFileSync(schemaFile, 'utf8')).schema);
6
13
  const seen = new Set();
@@ -8,7 +8,8 @@ export function registerLocalTypes(ns) {
8
8
  });
9
9
  versioned('config', [
10
10
  { name: 'key', type: 'string', required: true },
11
- { name: 'value', type: 'json' }
11
+ { name: 'value', type: 'json' },
12
+ { name: 'falsyValue', type: 'string' }
12
13
  ]);
13
14
  versioned('mesh-session', [
14
15
  { name: 'deviceId', type: 'buffer', required: true },
@@ -101,7 +102,8 @@ export function registerLocalTypes(ns) {
101
102
  { name: 'key', type: 'buffer', required: true },
102
103
  { name: 'seed', type: 'buffer', required: true },
103
104
  { name: 'creator', type: 'bool' },
104
- { name: 'writerSeed', type: 'string' }
105
+ { name: 'writerSeed', type: 'string' },
106
+ { name: 'compute', type: 'bool' }
105
107
  ]);
106
108
  versioned('active-mesh', [
107
109
  { name: 'deviceId', type: 'fixed32', required: true },
@@ -116,7 +118,9 @@ export function registerLocalTypes(ns) {
116
118
  { name: 'wasHome', type: 'bool' },
117
119
  { name: 'migratedAt', type: 'uint' },
118
120
  { name: 'compute', type: 'bool' },
119
- { name: 'awaitingAdmission', type: 'bool' }
121
+ { name: 'awaitingAdmission', type: 'bool' },
122
+ { name: 'bootKey', type: 'fixed32' },
123
+ { name: 'bootLength', type: 'uint' }
120
124
  ]);
121
125
  versioned('member-proof', [
122
126
  { name: 'meshKey', type: 'fixed32', required: true },
@@ -221,6 +221,15 @@ export function registerQvacTypes(ns) {
221
221
  { name: 'writeRootsRequired', type: 'bool' }
222
222
  ]
223
223
  });
224
+ ns.register({
225
+ name: 'custom-model-report-entry',
226
+ fields: [
227
+ { name: 'name', type: 'string', required: true },
228
+ { name: 'label', type: 'string', required: true },
229
+ { name: 'taskType', type: 'string' },
230
+ { name: 'expectedSize', type: 'uint' }
231
+ ]
232
+ });
224
233
  versioned('device', [
225
234
  { name: 'id', type: 'fixed32', required: true },
226
235
  { name: 'name', type: 'string', required: true },
@@ -246,7 +255,8 @@ export function registerQvacTypes(ns) {
246
255
  { name: 'attestedAt', type: 'uint' },
247
256
  { name: 'claimedMemberId', type: 'fixed32' },
248
257
  { name: 'inviteToken', type: 'fixed32' },
249
- { name: 'deviceSignature', type: 'buffer' }
258
+ { name: 'deviceSignature', type: 'buffer' },
259
+ { name: 'customModels', type: '@qvac/custom-model-report-entry', array: true }
250
260
  ]);
251
261
  versioned('writer', [
252
262
  { name: 'writerKey', type: 'buffer', required: true },
@@ -288,7 +298,8 @@ export function registerQvacTypes(ns) {
288
298
  { name: 'installedModelNames', type: 'string', array: true },
289
299
  { name: 'cachedModelNames', type: 'string', array: true },
290
300
  { name: 'readySkillNames', type: 'string', array: true },
291
- { name: 'toolCatalog', type: '@qvac/tool-report-entry', array: true }
301
+ { name: 'toolCatalog', type: '@qvac/tool-report-entry', array: true },
302
+ { name: 'customModels', type: '@qvac/custom-model-report-entry', array: true }
292
303
  ]);
293
304
  versioned('put-agent-operation', [{ name: 'agent', type: '@qvac/agent', required: true }]);
294
305
  versioned('put-chat-operation', [{ name: 'chat', type: '@qvac/chat', required: true }]);
@@ -587,6 +598,7 @@ export function registerQvacTypes(ns) {
587
598
  { name: 'meshKey', type: 'fixed32', required: true },
588
599
  { name: 'seed', type: 'fixed32', required: true }
589
600
  ]);
601
+ versioned('reindex-chat-chunks-operation', [{ name: 'chatId', type: 'string', required: true }]);
590
602
  }
591
603
  export function registerQvacCollections(dbns, helpersPath) {
592
604
  dbns.require(helpersPath);
@@ -918,6 +930,7 @@ export function registerQvacCollections(dbns, helpersPath) {
918
930
  dbns.collections.register({ name: 'purged-chats', schema: '@qvac/purged-chat', key: ['chatId'] });
919
931
  dbns.collections.register({ name: 'mesh-names', schema: '@qvac/mesh-name', key: ['id'] });
920
932
  dbns.collections.register({ name: 'mesh-seeds', schema: '@qvac/mesh-seed', key: ['meshKey'] });
933
+ dbns.collections.register({ name: 'chat-chunks', schema: '@qvac/chunk', key: ['chatId', 'seq'] });
921
934
  }
922
935
  export function registerQvacDispatch(ds) {
923
936
  ds.register({ name: 'append-chunk', requestType: '@qvac/append-chunk-operation' });
@@ -986,4 +999,8 @@ export function registerQvacDispatch(ds) {
986
999
  ds.register({ name: 'name-mesh', requestType: '@qvac/name-mesh-operation' });
987
1000
  ds.register({ name: 'open-join', requestType: '@qvac/open-join' });
988
1001
  ds.register({ name: 'put-mesh-seed', requestType: '@qvac/mesh-seed' });
1002
+ ds.register({
1003
+ name: 'reindex-chat-chunks',
1004
+ requestType: '@qvac/reindex-chat-chunks-operation'
1005
+ });
989
1006
  }