@qvac/core 0.6.7 → 0.7.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +145 -1
  2. package/README.md +2 -0
  3. package/dist-lib/lib/api/app-config.d.ts +3 -1
  4. package/dist-lib/lib/api/app-config.js +15 -4
  5. package/dist-lib/lib/assistant/fake-models.d.ts +22 -0
  6. package/dist-lib/lib/assistant/fake-models.js +112 -0
  7. package/dist-lib/lib/assistant/harness.d.ts +10 -0
  8. package/dist-lib/lib/assistant/harness.js +26 -0
  9. package/dist-lib/lib/assistant/history.d.ts +5 -1
  10. package/dist-lib/lib/assistant/history.js +14 -2
  11. package/dist-lib/lib/assistant-tree.d.ts +4 -0
  12. package/dist-lib/lib/assistant-tree.js +45 -7
  13. package/dist-lib/lib/assistant.d.ts +15 -2
  14. package/dist-lib/lib/assistant.js +175 -41
  15. package/dist-lib/lib/constants.d.ts +6 -0
  16. package/dist-lib/lib/constants.js +6 -0
  17. package/dist-lib/lib/core/chat-activity.d.ts +1 -1
  18. package/dist-lib/lib/core/chat-activity.js +3 -0
  19. package/dist-lib/lib/core/collections.d.ts +1 -0
  20. package/dist-lib/lib/core/collections.js +1 -0
  21. package/dist-lib/lib/core/contract/compute.d.ts +1 -1
  22. package/dist-lib/lib/core/contract/compute.js +2 -1
  23. package/dist-lib/lib/core/contract/index.js +6 -1
  24. package/dist-lib/lib/core/contract/invites.d.ts +1 -11
  25. package/dist-lib/lib/core/contract/invites.js +3 -3
  26. package/dist-lib/lib/core/contract/mesh-seeds.d.ts +2 -0
  27. package/dist-lib/lib/core/contract/mesh-seeds.js +26 -0
  28. package/dist-lib/lib/core/contract/open-join.d.ts +2 -0
  29. package/dist-lib/lib/core/contract/open-join.js +57 -0
  30. package/dist-lib/lib/core/departures.d.ts +3 -0
  31. package/dist-lib/lib/core/departures.js +44 -1
  32. package/dist-lib/lib/core/identity.d.ts +1 -1
  33. package/dist-lib/lib/core/identity.js +6 -4
  34. package/dist-lib/lib/core/invite.d.ts +2 -0
  35. package/dist-lib/lib/core/invite.js +6 -2
  36. package/dist-lib/lib/core/membership.d.ts +1 -12
  37. package/dist-lib/lib/core/membership.js +1 -94
  38. package/dist-lib/lib/core/mesh.d.ts +8 -13
  39. package/dist-lib/lib/core/mesh.js +41 -87
  40. package/dist-lib/lib/core/sync/index.js +2 -16
  41. package/dist-lib/lib/core.d.ts +30 -49
  42. package/dist-lib/lib/core.js +341 -868
  43. package/dist-lib/lib/diagnostics.d.ts +7 -0
  44. package/dist-lib/lib/diagnostics.js +22 -0
  45. package/dist-lib/lib/doctor/checks.d.ts +15 -0
  46. package/dist-lib/lib/doctor/checks.js +269 -0
  47. package/dist-lib/lib/doctor/redact.d.ts +4 -0
  48. package/dist-lib/lib/doctor/redact.js +31 -0
  49. package/dist-lib/lib/doctor/render.d.ts +8 -0
  50. package/dist-lib/lib/doctor/render.js +83 -0
  51. package/dist-lib/lib/doctor/tree.d.ts +5 -0
  52. package/dist-lib/lib/doctor/tree.js +167 -0
  53. package/dist-lib/lib/downloads-allowed-pusher.d.ts +10 -0
  54. package/dist-lib/lib/downloads-allowed-pusher.js +37 -0
  55. package/dist-lib/lib/guards.d.ts +1 -0
  56. package/dist-lib/lib/guards.js +4 -0
  57. package/dist-lib/lib/inference-calls.js +1 -5
  58. package/dist-lib/lib/kv-cache-reclaim.d.ts +2 -1
  59. package/dist-lib/lib/kv-cache-reclaim.js +24 -0
  60. package/dist-lib/lib/mesh-scoped-engine.js +1 -0
  61. package/dist-lib/lib/model-download-status.d.ts +1 -1
  62. package/dist-lib/lib/model-download.d.ts +9 -1
  63. package/dist-lib/lib/model-download.js +48 -3
  64. package/dist-lib/lib/model-memory-cap.d.ts +29 -0
  65. package/dist-lib/lib/model-memory-cap.js +69 -0
  66. package/dist-lib/lib/models-watch.d.ts +1 -1
  67. package/dist-lib/lib/models-watch.js +4 -4
  68. package/dist-lib/lib/oauth/flow.js +1 -1
  69. package/dist-lib/lib/oauth/loopback.js +16 -2
  70. package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
  71. package/dist-lib/lib/run-replay.d.ts +26 -0
  72. package/dist-lib/lib/run-replay.js +107 -0
  73. package/dist-lib/schema/config.d.ts +1 -1
  74. package/dist-lib/schema/config.js +1 -1
  75. package/dist-lib/schema/content.js +9 -1
  76. package/dist-lib/schema/engine.js +30 -5
  77. package/dist-lib/schema/local.js +3 -2
  78. package/dist-lib/schema/qvac.js +18 -1
  79. package/dist-lib/spec/bind.js +3 -0
  80. package/dist-lib/spec/calls.js +1 -0
  81. package/dist-lib/spec/capabilities.d.ts +2 -0
  82. package/dist-lib/spec/config/hyperconf/index.js +1 -1
  83. package/dist-lib/spec/hrpc/hrpc.json +13 -0
  84. package/dist-lib/spec/hrpc/index.js +15 -3
  85. package/dist-lib/spec/hrpc/messages.js +646 -557
  86. package/dist-lib/spec/hyperschema/index.js +646 -557
  87. package/dist-lib/spec/hyperschema/schema.json +80 -0
  88. package/dist-lib/spec/hyperschema/types.d.ts +20 -3
  89. package/dist-lib/spec/local/hyperdb/messages.js +22 -10
  90. package/dist-lib/spec/local/hyperschema/index.js +16 -7
  91. package/dist-lib/spec/local/hyperschema/schema.json +10 -1
  92. package/dist-lib/spec/local/hyperschema/types.d.ts +3 -2
  93. package/dist-lib/spec/mesh/hyperdb/db.json +16 -1
  94. package/dist-lib/spec/mesh/hyperdb/index.js +71 -2
  95. package/dist-lib/spec/mesh/hyperdb/messages.js +477 -240
  96. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +13 -1
  97. package/dist-lib/spec/mesh/hyperdispatch/index.js +35 -1
  98. package/dist-lib/spec/mesh/hyperdispatch/messages.js +180 -7
  99. package/dist-lib/spec/mesh/hyperschema/index.js +180 -7
  100. package/dist-lib/spec/mesh/hyperschema/schema.json +98 -1
  101. package/dist-lib/spec/mesh/hyperschema/types.d.ts +26 -2
  102. package/package.json +8 -16
  103. package/tui/README.md +7 -1
  104. package/tui/app.mjs +245 -11
  105. package/tui/boot.mjs +1 -0
  106. package/tui/index.mjs +1 -0
  107. package/tui/lib/render.mjs +25 -1
  108. package/worker/assistant-sidecar.mjs +5 -2
  109. package/dist-lib/lib/core/device-invites.d.ts +0 -11
  110. package/dist-lib/lib/core/device-invites.js +0 -63
  111. package/dist-lib/lib/core/grant-expiry.d.ts +0 -11
  112. package/dist-lib/lib/core/grant-expiry.js +0 -66
  113. package/dist-lib/lib/core/mesh-seed-handoff.d.ts +0 -27
  114. package/dist-lib/lib/core/mesh-seed-handoff.js +0 -53
  115. package/dist-lib/lib/oauth/loopback.stub.d.ts +0 -3
  116. package/dist-lib/lib/oauth/loopback.stub.js +0 -6
@@ -13,9 +13,6 @@ import { syncChanges } from './sync/index.js';
13
13
  import { buildDefaultSeed, isOwnKickedRow, isOwnRevokedRow } from './helpers/index.js';
14
14
  import { raceResource } from '../race-resource.js';
15
15
  import { signDeviceAttestation, signWriterClaim } from './device-attestation.js';
16
- import { attestMemberClaim, claimAttestation, deviceInviteToken } from './identity.js';
17
- import { GrantExpiry } from './grant-expiry.js';
18
- import { grantKeyPair, signInviteClaim } from './invite-grants.js';
19
16
  import { liveDeviceForWriter } from './contract/activity.js';
20
17
  import { assertComputeRoute } from './contract/compute.js';
21
18
  import { MESH_NAME_ROW } from './contract/mesh-name.js';
@@ -24,12 +21,12 @@ import { createSyncActivity } from './sync-status.js';
24
21
  import { buildHealthAssistant } from './health-assistant.js';
25
22
  import b4a from 'b4a';
26
23
  import { errorMessage, isRecord } from '../guards.js';
27
- import { ACTIVE_AGENTS, ACTIVE_CHATS, DEVICES, LIVE_WRITERS_BY_MOST_RECENT, MEMBERS, MESH_KINDS, MESH_NAMES } from './collections.js';
24
+ import { ACTIVE_AGENTS, ACTIVE_CHATS, DEVICES, LIVE_WRITERS_BY_MOST_RECENT, MEMBERS, MESH_NAMES } from './collections.js';
28
25
  const [MESH_KEYPAIR, MESH_ENCRYPTION, MESH_DEVICE] = crypto.namespace('qvac-assistant/mesh', 3);
26
+ export const MESH_JOINING = 'This mesh is still joining: it accepts writes once it is joined';
29
27
  export function meshPublicKeyFromSeed(seed) {
30
28
  return crypto.keyPair(crypto.hash([MESH_KEYPAIR, seed])).publicKey;
31
29
  }
32
- const GENESIS_POLL_MS = 250;
33
30
  const WARMUP_COLLECTIONS = [
34
31
  '@qvac/devices',
35
32
  '@qvac/active-agents',
@@ -91,8 +88,8 @@ export class Mesh extends ReadyResource {
91
88
  revoked: 0
92
89
  };
93
90
  _deviceId;
94
- _grantExpiry;
95
91
  _admitted = false;
92
+ _birth = null;
96
93
  _autobee = null;
97
94
  _blobs = null;
98
95
  _syncActivity = null;
@@ -210,28 +207,6 @@ export class Mesh extends ReadyResource {
210
207
  namedAt: Math.max(Date.now(), (current?.namedAt ?? 0) + 1)
211
208
  });
212
209
  }
213
- refreshGrantExpiry() {
214
- return this._grantExpiry.refresh();
215
- }
216
- async bornKind() {
217
- for await (const _device of this.view.find(DEVICES)) {
218
- return (await this.view.get(MESH_KINDS, { id: 'mesh' }))?.kind ?? null;
219
- }
220
- return undefined;
221
- }
222
- async waitForGenesis(timeout) {
223
- const deadline = Date.now() + timeout;
224
- let kind = await this.bornKind();
225
- while (kind === undefined && Date.now() < deadline) {
226
- await new Promise((resolve) => setTimeout(resolve, GENESIS_POLL_MS));
227
- if (this.closing) {
228
- return undefined;
229
- }
230
- await this.autobee.update();
231
- kind = await this.bornKind();
232
- }
233
- return kind;
234
- }
235
210
  sign(message) {
236
211
  return crypto.sign(message, this._keyPair.secretKey);
237
212
  }
@@ -260,7 +235,6 @@ export class Mesh extends ReadyResource {
260
235
  this.discoveryKey = crypto.discoveryKey(this._keyPair.publicKey);
261
236
  this._scope = ['p2p', 'mesh', b4a.toHex(this._keyPair.publicKey).slice(0, 8)];
262
237
  registerRoutes(this.router, { compute: this._compute });
263
- this._grantExpiry = new GrantExpiry(this, (err) => this._log?.warn(this._scope, 'revoking expired invite grants failed', err));
264
238
  }
265
239
  async _open() {
266
240
  this._log?.info(this._scope, 'opening');
@@ -296,7 +270,6 @@ export class Mesh extends ReadyResource {
296
270
  fastForwards: this.autobee.stats.fastForwards
297
271
  }));
298
272
  this.autobee.on('interrupt', (err) => this._log?.warn(this._scope, 'autobee interrupt', err));
299
- this.autobee.on('writable', () => void this._grantExpiry.refresh());
300
273
  if (this._bootInterrupted) {
301
274
  void this.autobee.close().catch(noop);
302
275
  }
@@ -312,7 +285,6 @@ export class Mesh extends ReadyResource {
312
285
  });
313
286
  this._syncActivity = createSyncActivity(this);
314
287
  void this.refreshOurMember().catch((err) => this._log?.warn(this._scope, 'reading our member failed', err));
315
- void this._grantExpiry.refresh();
316
288
  this._log?.info(this._scope, 'autobee opened', {
317
289
  writable: this.autobee.writable,
318
290
  creator: this._key === null
@@ -353,7 +325,6 @@ export class Mesh extends ReadyResource {
353
325
  }
354
326
  async _close() {
355
327
  this._log?.info(this._scope, 'closing');
356
- this._grantExpiry.close();
357
328
  await this._files?.close();
358
329
  await Promise.all([this.autobee.close(), this.blobs.close(), this._blindPeering?.close()]);
359
330
  this._blindPeering = null;
@@ -398,14 +369,30 @@ export class Mesh extends ReadyResource {
398
369
  get localLength() {
399
370
  return this.autobee.local.length;
400
371
  }
372
+ get joining() {
373
+ return this._birth !== null;
374
+ }
401
375
  async dispatch(name, payload, opts) {
402
376
  assertComputeRoute(this._compute, name);
377
+ assertJoined(this.autobee, opts);
403
378
  await this.autobee.append(encode(`@qvac/${name}`, payload), opts);
404
379
  }
405
380
  batch() {
406
- return new MeshBatch(this.autobee, { compute: this._compute });
381
+ return new MeshBatch(this.autobee, { compute: this._compute, joined: true });
382
+ }
383
+ appendBirthOp(identity, device, opts = {}) {
384
+ this._birth ??= (async () => {
385
+ await this._appendBirthOp(identity, device, typeof opts === 'function' ? await opts() : opts);
386
+ })().finally(() => {
387
+ this._birth = null;
388
+ });
389
+ return this._birth.then(() => this._settleBirth());
390
+ }
391
+ async _settleBirth() {
392
+ await this.autobee.update();
393
+ this.throwIfInterrupted();
407
394
  }
408
- async appendBirthOp(identity, device, { member, claim, sharing = false, grantSecret, recovery, vouched = false } = {}) {
395
+ async _appendBirthOp(identity, device, { member, sharing = false } = {}) {
409
396
  if (this.autobee.local.length > 0)
410
397
  return;
411
398
  const { publicKey: deviceId, secretKey } = 'secretKey' in identity ? identity : { publicKey: identity, secretKey: null };
@@ -415,7 +402,7 @@ export class Mesh extends ReadyResource {
415
402
  : undefined;
416
403
  const deviceSignature = secretKey && row ? this.signDeviceClaim(secretKey, deviceId, row.joinedAt) : undefined;
417
404
  if (this._key === null) {
418
- const birth = this.batch();
405
+ const birth = new MeshBatch(this.autobee, { compute: this._compute });
419
406
  birth.dispatch('add-writer', { writerKey: localKey, device: row, deviceSignature });
420
407
  if (sharing) {
421
408
  birth.dispatch('mint-mesh-kind', { id: 'mesh', kind: 'shared' });
@@ -432,63 +419,21 @@ export class Mesh extends ReadyResource {
432
419
  }
433
420
  await birth.flush();
434
421
  }
435
- else if (!this.autobee.writable && !vouched && (grantSecret || !sharing)) {
436
- const signature = this.sign(localKey);
437
- const device = row ? claimableDevice(row) : undefined;
438
- const join = this.batch();
439
- if (grantSecret) {
440
- const pair = grantKeyPair(grantSecret);
441
- join.dispatch('claim-invite', {
442
- signature,
443
- deviceId,
444
- device,
445
- deviceSignature,
446
- grantKey: pair.publicKey,
447
- inviteSignature: signInviteClaim(pair.secretKey, {
448
- meshPublicKey: this.publicKey,
449
- grantKey: pair.publicKey,
450
- deviceId,
451
- writerKey: localKey
452
- }),
453
- member: member?.member,
454
- memberClaim: member?.proof
455
- });
456
- }
457
- else if (recovery) {
458
- if (!device || !secretKey) {
459
- throw new Error('A recovery needs this device row and its key');
460
- }
461
- join.dispatch('recover-device', {
462
- signature,
463
- deviceId,
464
- device,
465
- deviceSignature,
466
- memberId: recovery.memberId,
467
- proof: await attestMemberClaim(claimAttestation(this.publicKey, deviceId, localKey), { publicKey: deviceId, secretKey }, recovery.proof)
468
- });
469
- }
470
- else {
471
- join.dispatch('join', {
472
- signature,
473
- deviceId,
474
- device,
475
- claimedMemberId: claim?.memberId,
476
- inviteToken: claim?.inviteNonce
477
- ? deviceInviteToken(claim.inviteNonce, deviceId)
478
- : undefined,
479
- deviceSignature
480
- });
481
- }
422
+ else if (!this.autobee.writable) {
423
+ const join = new MeshBatch(this.autobee, { compute: this._compute });
424
+ join.dispatch('open-join', {
425
+ signature: this.sign(localKey),
426
+ deviceId,
427
+ device: row ? claimableDevice(row) : undefined,
428
+ deviceSignature,
429
+ member: member?.member,
430
+ memberClaim: member?.proof
431
+ });
482
432
  if (row) {
483
433
  join.dispatch('attest-device', this.attestDevice(deviceId));
484
434
  }
485
- if (row && member && !grantSecret) {
486
- join.dispatch('join-member', member);
487
- }
488
435
  await join.flush({ optimistic: true });
489
436
  }
490
- await this.autobee.update();
491
- this.throwIfInterrupted();
492
437
  }
493
438
  get interrupted() {
494
439
  return this.autobee.interrupted;
@@ -707,10 +652,12 @@ export class Mesh extends ReadyResource {
707
652
  export class MeshBatch {
708
653
  _autobee;
709
654
  _compute;
655
+ _joined;
710
656
  _ops = [];
711
657
  constructor(autobee, opts = {}) {
712
658
  this._autobee = autobee;
713
659
  this._compute = opts.compute ?? false;
660
+ this._joined = opts.joined ?? false;
714
661
  }
715
662
  get size() {
716
663
  return this._ops.length;
@@ -722,12 +669,19 @@ export class MeshBatch {
722
669
  async flush(opts) {
723
670
  if (this._ops.length === 0)
724
671
  return;
672
+ if (this._joined) {
673
+ assertJoined(this._autobee, opts);
674
+ }
725
675
  const ops = this._ops;
726
676
  this._ops = [];
727
677
  await this._autobee.append(ops, opts);
728
678
  }
729
679
  }
730
680
  function noop() { }
681
+ function assertJoined(autobee, opts) {
682
+ if (!opts?.optimistic && !autobee.writable)
683
+ throw new Error(MESH_JOINING);
684
+ }
731
685
  function openedPart(part, name) {
732
686
  if (part === null)
733
687
  throw new Error(`mesh ${name} read before open`);
@@ -2,7 +2,7 @@ import { FileChanges } from './files.js';
2
2
  import { syncDeviceRevocation, syncOwnMember } from './devices.js';
3
3
  import { syncChatTombstone } from './chats.js';
4
4
  import { syncNotificationChunk } from './chunks.js';
5
- import { AGENTS, CHATS, CHUNKS, CHUNK_COUNTERS, DEVICES, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, MEMBERS, MESH_NAMES, PURGED_CHATS } from '../collections.js';
5
+ import { AGENTS, CHATS, CHUNKS, CHUNK_COUNTERS, DEVICES, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, MEMBERS, MESH_NAMES, MESH_SEEDS, PURGED_CHATS } from '../collections.js';
6
6
  export async function syncChanges(mesh, view, from) {
7
7
  if (mesh.closing)
8
8
  return;
@@ -11,10 +11,8 @@ export async function syncChanges(mesh, view, from) {
11
11
  let membershipMoved = false;
12
12
  let agentsDirty = false;
13
13
  let meshesChanged = false;
14
- let grantsChanged = false;
15
14
  const orderDirty = new Set();
16
15
  const purged = new Map();
17
- let kindChanged = false;
18
16
  let nameChanged = false;
19
17
  const snap = view.db.snapshot();
20
18
  const files = new FileChanges(snap, from);
@@ -58,15 +56,9 @@ export async function syncChanges(mesh, view, from) {
58
56
  else if (changed(change, PURGED_CHATS)) {
59
57
  purged.set(change.value.chatId, change.value.at);
60
58
  }
61
- else if (change.collection === '@qvac/joined-meshes') {
59
+ else if (change.collection === '@qvac/joined-meshes' || change.collection === MESH_SEEDS) {
62
60
  meshesChanged = true;
63
61
  }
64
- else if (change.collection === '@qvac/mesh-invite-grants') {
65
- grantsChanged = true;
66
- }
67
- else if (change.collection === '@qvac/mesh-kinds') {
68
- kindChanged = true;
69
- }
70
62
  else if (change.collection === MESH_NAMES) {
71
63
  nameChanged = true;
72
64
  }
@@ -100,12 +92,6 @@ export async function syncChanges(mesh, view, from) {
100
92
  await mesh.syncChatOrder(orderDirty);
101
93
  }
102
94
  mesh.emit('meshes-dirty', meshesChanged);
103
- if (grantsChanged) {
104
- void mesh.refreshGrantExpiry();
105
- }
106
- if (kindChanged) {
107
- mesh.emit('mesh-kind');
108
- }
109
95
  if (nameChanged) {
110
96
  await mesh.refreshName();
111
97
  mesh.emit('mesh-named');
@@ -9,6 +9,7 @@ import type { Logger } from '../index.ts';
9
9
  import type { AssistantArchivedMeshList, AssistantCompactChatResponse, AssistantCopySkillResponse, AssistantDeleteModelRequest, AssistantDeleteModelResponse, AssistantDeleteSkillResponse, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantLoadModelResponse, AssistantManagedSkillsResponse, AssistantMeshList, AssistantAccount, AssistantModelCatalogRevision, AssistantModelInfoList, AssistantOkResponse, AssistantSkillCatalogResponse, AssistantSkillFileResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantDetectLanguageRequest, AssistantDetectLanguageResponse, AssistantTranscribeRequest, AssistantTranscribeResponse, AssistantUnloadModelResponse, AssistantModelUsers, AssistantCustomModelPreview, AssistantPreviewCustomModelRequest } from '../spec/index.d.ts';
10
10
  import type { InferenceCallSource } from './api/inference-calls.ts';
11
11
  import { type SkillOptions } from './api/index.ts';
12
+ import type { ModelMemoryUse } from './model-memory-cap.ts';
12
13
  import { type BlindPeeringOpts } from './core/blind-peers.ts';
13
14
  import { type IndexingEmbedder, type RagExtractors, type VectorIndex } from './core/files/index.ts';
14
15
  import { type DriveHost } from './core/fs-drives.ts';
@@ -47,6 +48,7 @@ export interface CoreOptions {
47
48
  blindPeerKeys?: ReadonlyArray<Buffer>;
48
49
  blindPeeringOpts?: BlindPeeringOpts;
49
50
  fileGc?: FileGcOptions | null;
51
+ autoDownloadModels?: boolean;
50
52
  meshSeed?: Buffer;
51
53
  meshKey?: Buffer;
52
54
  additionalNodes?: ReadonlyArray<{
@@ -78,27 +80,15 @@ export interface CoreOptions {
78
80
  readonly suspend: () => Promise<void>;
79
81
  readonly resume: () => Promise<void>;
80
82
  };
81
- grantWritableMs?: number;
82
- accountWritableMs?: number;
83
- grantVisibleMs?: number;
84
83
  }
85
84
  export declare const ACCOUNT_MEMBER_UNKNOWN = "This device is not part of its account yet";
86
- export declare const AWAITING_ADMISSION = "awaiting-admission";
85
+ export declare const DEVICE_UNKNOWN = "This device has no device details: pass `device` when creating Core";
87
86
  export declare const MEMBER_INVITE_HOME_REFUSED = "An account mesh cannot be invited into";
88
87
  export declare const DEVICE_INVITE_MESH_REFUSED = "Only an account mesh can take a device invite";
89
88
  export declare const MESH_NAME_ACCOUNT_REFUSED = "An account mesh has no shared name";
90
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
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
- export declare const INVITE_GRANT_REVOKED = "This invite was revoked";
93
- export declare const MESH_ALREADY_JOINED = "This device is already in this mesh";
94
- export declare const MESH_ADMISSION_PENDING = "This mesh has not admitted this device yet: try again in a moment";
95
- export declare const MEMBER_ALREADY_IN_MESH = "Another of your devices is already in this mesh: join through it once it is online";
96
- export declare const DEVICE_OF_ANOTHER_MEMBER = "This device belongs to another member in this mesh";
97
- export declare const MEMBER_REMOVED_SINCE_INVITE = "You were removed from this mesh after this invite was made: ask for a new one";
98
- export declare const INVITE_GRANT_EXPIRED = "This invite has expired";
99
- export declare const INVITE_GRANT_EXHAUSTED = "This invite has already been used";
100
- export declare const SEALED_ACCOUNT_READER = "This account admits no device by its seed alone: pair this device with a device invite";
101
- export declare const INVITER_OFFLINE = "The device that made this invite is not online: bring it online and try again";
102
92
  export interface SharedMesh {
103
93
  readonly meshId: string;
104
94
  readonly notice?: string;
@@ -142,7 +132,6 @@ export declare class Core extends ReadyResource {
142
132
  private readonly _ownsSwarm;
143
133
  private readonly _ownsWakeup;
144
134
  local: ReturnType<typeof openLocalStore>;
145
- private readonly _deviceInvites;
146
135
  state: LocalQvacState;
147
136
  private readonly _transport;
148
137
  private readonly _apiLifecycle;
@@ -162,15 +151,14 @@ export declare class Core extends ReadyResource {
162
151
  private readonly _blindPeerKeys;
163
152
  private readonly _blindPeeringOpts;
164
153
  private readonly _fileGc;
154
+ private readonly _autoDownloadModels;
165
155
  private _fileGcTimer;
166
156
  private _fileGcRun;
167
157
  private readonly _meshSeed;
168
158
  private readonly _meshKey;
169
159
  private readonly _additionalNodes;
170
- private readonly _grantWritableMs;
171
- private readonly _accountWritableMs;
172
- private readonly _grantVisibleMs;
173
160
  private _listModels;
161
+ private _modelMemory;
174
162
  private _deleteModel;
175
163
  private _clearKvCache;
176
164
  private _deleteChatKvCache;
@@ -224,12 +212,9 @@ export declare class Core extends ReadyResource {
224
212
  private _fsDrives;
225
213
  private _blobServer;
226
214
  private readonly _wakeup;
227
- private readonly _meshSeedHandoff;
228
215
  private readonly _harnessLoan;
229
216
  private _serveLoanedHarness;
230
217
  private readonly _following;
231
- private readonly _admissionRetries;
232
- private readonly _admissionRetryPending;
233
218
  private _revokingInMeshes;
234
219
  private _revokeInMeshesAgain;
235
220
  private _sweepUnknownEverywhere;
@@ -238,6 +223,7 @@ export declare class Core extends ReadyResource {
238
223
  private readonly _skillOverlayHandoff;
239
224
  private readonly _inferenceCallsHandoff;
240
225
  private _minting;
226
+ private _backfill;
241
227
  private _leaving;
242
228
  private _kicked;
243
229
  private _kickedPending;
@@ -252,7 +238,7 @@ export declare class Core extends ReadyResource {
252
238
  private _systemInfo;
253
239
  private _statusError;
254
240
  private _upgradeRequired;
255
- constructor(transport: Transport, { storagePath, store, swarm, wakeup, logger, spec, bootstrapNodes, device, app, minSupportedVersion, otaConfigCore, blindPeerKeys, blindPeeringOpts, fileGc, meshSeed, meshKey, additionalNodes, listModels, deleteModel, clearKvCache, deleteChatKvCache, compactChat, modelCatalogWatch, retryModelDownload, transcribe, detectLanguage, previewModelSource, speak, speakStream, embedder, extractors, skills, skillCatalog, tools, hostsModelSource, vectorIndex, apiLifecycle, grantWritableMs, accountWritableMs, grantVisibleMs }: CoreOptions);
241
+ 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);
256
242
  get devicePublicKey(): Buffer | null;
257
243
  private _requireDeviceKeyPair;
258
244
  get fsDrives(): DriveHost | null;
@@ -290,6 +276,9 @@ export declare class Core extends ReadyResource {
290
276
  private _switchToMesh;
291
277
  private _openMesh;
292
278
  private _openMeshSession;
279
+ private _appendOwnBirth;
280
+ private _requireLocalDevice;
281
+ private _appendJoinLater;
293
282
  private _accountBirthMember;
294
283
  private _mintBirthMember;
295
284
  publishAccountRecovery(mnemonic: string): Promise<boolean>;
@@ -299,11 +288,14 @@ export declare class Core extends ReadyResource {
299
288
  private _openOwnRecoveryCore;
300
289
  private _adoptRecoveryCore;
301
290
  recoverAccount(mnemonic: string, { timeout }?: RecoverAccountOptions): Promise<void>;
302
- private _recoverAccount;
291
+ private _joinRecoveredAccount;
292
+ private _rerootRecovered;
303
293
  private _readRecovery;
304
294
  private _peerRecoveryCore;
305
295
  private _closeRecovery;
306
296
  private _joinBirthMember;
297
+ private _knownBirthMember;
298
+ private _recoveryBirthMember;
307
299
  private _holdIdentityPhrase;
308
300
  private _pushIdentityPhrase;
309
301
  private _offerIdentityPhrase;
@@ -312,12 +304,12 @@ export declare class Core extends ReadyResource {
312
304
  private _advertiseAppVersion;
313
305
  private _retractInventory;
314
306
  private _settleMembership;
315
- private _sealAccount;
316
307
  private _renameFoundedMember;
317
308
  private _adoptName;
318
309
  private _followAccountName;
319
310
  private _claimOwnMembership;
320
311
  private _knownMember;
312
+ private _recordedMember;
321
313
  private _migrationContext;
322
314
  private _recordMemberProof;
323
315
  private _ensureNotRevoked;
@@ -342,6 +334,8 @@ export declare class Core extends ReadyResource {
342
334
  private _reopenOwnAccount;
343
335
  private _claimJoin;
344
336
  private _joinMeshInvite;
337
+ private _reopenRecordedMesh;
338
+ private _keepsWriter;
345
339
  private _runJoinMesh;
346
340
  private _joinParkedMesh;
347
341
  private _joinCandidate;
@@ -350,23 +344,21 @@ export declare class Core extends ReadyResource {
350
344
  private _departIfPooled;
351
345
  private _recordJoinedMesh;
352
346
  private _registerMesh;
347
+ private _backfillMeshSeeds;
348
+ private _writeMeshSeeds;
349
+ private _registerRecordedMeshes;
350
+ private _seedRowDue;
353
351
  private _releaseJoinedMesh;
354
352
  private _writableAccount;
355
- private _awaitGrantRow;
356
- private _untilDeadline;
357
- private _refuseIfGrantUnusable;
358
- private _refuseUnredeemable;
359
- private _refuseFromOwnCopy;
360
353
  private _openCandidateMesh;
361
- private _requestInvitedAdmission;
362
- private _isRemovedFrom;
363
- private _waitForCandidateWritable;
354
+ private _candidateBirthMember;
355
+ private _delegatedBirthMember;
356
+ private _onMeshSeedDue;
364
357
  private _onMeshWritable;
365
358
  private _onMeshDead;
366
359
  private _onMeshStalled;
367
360
  private _wireMesh;
368
361
  private _adoptAccount;
369
- private _refuseSealedReader;
370
362
  private _pooled;
371
363
  private _accountMesh;
372
364
  private _meshIdOf;
@@ -387,6 +379,7 @@ export declare class Core extends ReadyResource {
387
379
  private _startMeshServices;
388
380
  private _stopHostedAgents;
389
381
  private _discardCandidateMesh;
382
+ private _recordDeparture;
390
383
  private _departureHasAudience;
391
384
  private _announceDeparture;
392
385
  leaveMesh(meshId: string): Promise<void>;
@@ -416,7 +409,6 @@ export declare class Core extends ReadyResource {
416
409
  private _openPooledMesh;
417
410
  private _openRecordedMesh;
418
411
  private _meshEntry;
419
- private _admission;
420
412
  private _meshEntryState;
421
413
  private _meshKeyOf;
422
414
  removeDeviceWriter(writerKey: Buffer, deviceId: Buffer, mesh?: Mesh): Promise<void>;
@@ -432,6 +424,7 @@ export declare class Core extends ReadyResource {
432
424
  waitForWritable(): Promise<void>;
433
425
  private _assertMeshIsHere;
434
426
  getMeshInvite(opts?: MeshInviteOptions): Promise<MeshInvite | null>;
427
+ private _delegatePairing;
435
428
  previewMeshInvite(invite: string): MeshInvitePreview;
436
429
  private _closeSwarm;
437
430
  pushSkillSecret(request: SecretRequest): Promise<void>;
@@ -441,28 +434,14 @@ export declare class Core extends ReadyResource {
441
434
  private _trackFollow;
442
435
  private _retireLeftMesh;
443
436
  private _archiveLeftMeshRow;
444
- private _openOwnMesh;
445
- private _adoptOwnMesh;
446
- private _refusedInMesh;
447
437
  private _openFollowedMesh;
448
- private _requestMeshSeed;
449
- private _requestMeshAdmission;
450
- private _askSiblingsToAdmit;
451
- private _retryAdmission;
452
- private _liveSiblings;
438
+ private _mayFollow;
453
439
  registerLoanableHarness(serve: (stream: LoanStreamDuplex) => void): () => void;
454
440
  borrowHarness(deviceId: string): LoanStreamDuplex;
455
441
  private _lendHarness;
456
442
  private _revalidateLoans;
457
443
  private _computeLender;
458
444
  private _sharesComputeMesh;
459
- private _serveMeshSeed;
460
- private _admitInvitedDevice;
461
- private _admitIntoMesh;
462
- private _admitIntoMeshLocked;
463
- private _isJoinedMeshKey;
464
- private _removedFor;
465
- private _askerStanding;
466
445
  private _skillOverlayOp;
467
446
  private _resolveAgentHost;
468
447
  private _listInferenceCalls;
@@ -489,6 +468,7 @@ export declare class Core extends ReadyResource {
489
468
  registerModelUsers(users: (name: string) => Promise<AssistantModelUsers>): () => void;
490
469
  registerInferenceCalls(source: InferenceCallSource): () => void;
491
470
  registerListModels(hook: (options: AssistantListModelsRequest) => Promise<AssistantModelInfoList>): () => void;
471
+ registerModelMemory(hook: () => Promise<ModelMemoryUse | null>): () => void;
492
472
  registerDeleteModel(hook: (options: AssistantDeleteModelRequest) => Promise<AssistantDeleteModelResponse>): () => void;
493
473
  registerClearKvCache(hook: () => Promise<AssistantKvCacheDeletionResponse>): () => void;
494
474
  registerDeleteChatKvCache(hook: (chatId: string) => Promise<AssistantKvCacheDeletionResponse>): () => void;
@@ -496,6 +476,7 @@ export declare class Core extends ReadyResource {
496
476
  registerModelCatalogWatch(hook: () => AsyncIterable<AssistantModelCatalogRevision>): () => void;
497
477
  private _watchModelCatalog;
498
478
  private _modelCatalogRevisions;
479
+ private _readModelList;
499
480
  private _readModels;
500
481
  private _openModelCatalogWatchSource;
501
482
  private _resetModelCatalogWatchSource;