@qvac/core 0.1.4 → 0.2.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 (105) hide show
  1. package/.claude/skills/asana/SKILL.md +86 -0
  2. package/.claude/skills/compaction/SKILL.md +127 -0
  3. package/.claude/skills/device-mesh-debug/SKILL.md +328 -0
  4. package/.claude/skills/gh-stack/SKILL.md +181 -0
  5. package/.claude/skills/gh-stack/references/commands.md +177 -0
  6. package/.claude/skills/gh-stack/references/stack-design.md +97 -0
  7. package/.claude/skills/gh-stack/references/troubleshooting.md +159 -0
  8. package/.claude/skills/js-house-style/SKILL.md +670 -0
  9. package/.claude/skills/pr-create/SKILL.md +180 -0
  10. package/.claude/skills/pr-review/SKILL.md +216 -0
  11. package/CLAUDE.md +45 -0
  12. package/README.md +10 -5
  13. package/dist-lib/lib/api/agents.js +3 -3
  14. package/dist-lib/lib/api/chat-groups.d.ts +1 -1
  15. package/dist-lib/lib/api/chat-groups.js +5 -3
  16. package/dist-lib/lib/api/chat.js +2 -2
  17. package/dist-lib/lib/api/current-mesh.d.ts +3 -2
  18. package/dist-lib/lib/api/current-mesh.js +4 -3
  19. package/dist-lib/lib/api/devices.js +1 -0
  20. package/dist-lib/lib/api/index.js +2 -0
  21. package/dist-lib/lib/api/members.d.ts +3 -0
  22. package/dist-lib/lib/api/members.js +23 -0
  23. package/dist-lib/lib/api/mesh.d.ts +14 -3
  24. package/dist-lib/lib/api/mesh.js +20 -3
  25. package/dist-lib/lib/api/watchable.d.ts +1 -1
  26. package/dist-lib/lib/api/watchable.js +1 -1
  27. package/dist-lib/lib/assistant.js +2 -1
  28. package/dist-lib/lib/core/agent.d.ts +1 -0
  29. package/dist-lib/lib/core/agent.js +29 -1
  30. package/dist-lib/lib/core/chat-group.d.ts +4 -0
  31. package/dist-lib/lib/core/chat-group.js +43 -1
  32. package/dist-lib/lib/core/chat.d.ts +10 -0
  33. package/dist-lib/lib/core/chat.js +75 -9
  34. package/dist-lib/lib/core/contract/index.js +2 -0
  35. package/dist-lib/lib/core/contract/joined-meshes.d.ts +2 -0
  36. package/dist-lib/lib/core/contract/joined-meshes.js +41 -0
  37. package/dist-lib/lib/core/contract/members.js +68 -2
  38. package/dist-lib/lib/core/contract/writers.js +19 -3
  39. package/dist-lib/lib/core/departures.d.ts +3 -1
  40. package/dist-lib/lib/core/departures.js +6 -4
  41. package/dist-lib/lib/core/device-attestation.d.ts +8 -0
  42. package/dist-lib/lib/core/device-attestation.js +25 -0
  43. package/dist-lib/lib/core/device-invites.d.ts +9 -0
  44. package/dist-lib/lib/core/device-invites.js +40 -0
  45. package/dist-lib/lib/core/files/index.d.ts +2 -1
  46. package/dist-lib/lib/core/files/index.js +1 -1
  47. package/dist-lib/lib/core/files/store/index.d.ts +1 -0
  48. package/dist-lib/lib/core/files/store/server.d.ts +5 -4
  49. package/dist-lib/lib/core/files/store/server.js +10 -6
  50. package/dist-lib/lib/core/helpers/index.d.ts +1 -1
  51. package/dist-lib/lib/core/hosted-agents.d.ts +3 -1
  52. package/dist-lib/lib/core/hosted-agents.js +9 -3
  53. package/dist-lib/lib/core/identity.d.ts +10 -0
  54. package/dist-lib/lib/core/identity.js +45 -0
  55. package/dist-lib/lib/core/invite.d.ts +3 -0
  56. package/dist-lib/lib/core/invite.js +8 -2
  57. package/dist-lib/lib/core/local/index.d.ts +22 -7
  58. package/dist-lib/lib/core/local/index.js +202 -66
  59. package/dist-lib/lib/core/membership.d.ts +8 -2
  60. package/dist-lib/lib/core/membership.js +33 -9
  61. package/dist-lib/lib/core/mesh-seed-handoff.d.ts +17 -0
  62. package/dist-lib/lib/core/mesh-seed-handoff.js +34 -0
  63. package/dist-lib/lib/core/mesh.d.ts +13 -1
  64. package/dist-lib/lib/core/mesh.js +61 -8
  65. package/dist-lib/lib/core/migrations/index.d.ts +3 -1
  66. package/dist-lib/lib/core/migrations/index.js +2 -2
  67. package/dist-lib/lib/core/migrations/membership.js +27 -15
  68. package/dist-lib/lib/core/rank.d.ts +14 -0
  69. package/dist-lib/lib/core/rank.js +23 -0
  70. package/dist-lib/lib/core/sync/index.js +6 -0
  71. package/dist-lib/lib/core.d.ts +91 -13
  72. package/dist-lib/lib/core.js +1051 -207
  73. package/dist-lib/schema/build.js +3 -2
  74. package/dist-lib/schema/engine.js +153 -9
  75. package/dist-lib/schema/field-order.js +4 -1
  76. package/dist-lib/schema/local.js +32 -0
  77. package/dist-lib/schema/qvac.js +45 -6
  78. package/dist-lib/spec/bind.js +35 -0
  79. package/dist-lib/spec/calls.js +37 -27
  80. package/dist-lib/spec/capabilities.d.ts +30 -10
  81. package/dist-lib/spec/hrpc/hrpc.json +135 -5
  82. package/dist-lib/spec/hrpc/index.js +130 -9
  83. package/dist-lib/spec/hrpc/messages.js +408 -14
  84. package/dist-lib/spec/hyperschema/index.js +408 -14
  85. package/dist-lib/spec/hyperschema/schema.json +309 -1
  86. package/dist-lib/spec/hyperschema/types.d.ts +90 -1
  87. package/dist-lib/spec/local/hyperdb/db.json +46 -1
  88. package/dist-lib/spec/local/hyperdb/index.js +209 -2
  89. package/dist-lib/spec/local/hyperdb/messages.js +557 -90
  90. package/dist-lib/spec/local/hyperschema/index.js +240 -2
  91. package/dist-lib/spec/local/hyperschema/schema.json +120 -1
  92. package/dist-lib/spec/local/hyperschema/types.d.ts +33 -1
  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 +571 -192
  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 +283 -20
  99. package/dist-lib/spec/mesh/hyperschema/index.js +283 -20
  100. package/dist-lib/spec/mesh/hyperschema/schema.json +179 -1
  101. package/dist-lib/spec/mesh/hyperschema/types.d.ts +45 -1
  102. package/package.json +6 -6
  103. package/tui/app.mjs +416 -50
  104. package/tui/boot.mjs +1 -1
  105. package/tui/lib/sidebar.mjs +3 -2
@@ -1,4 +1,6 @@
1
+ import c from 'compact-encoding';
1
2
  import crypto from 'hypercore-crypto';
3
+ const [WRITER_CLAIM_NAMESPACE] = crypto.namespace('@qvac/core/device-writer-claim', 1);
2
4
  export function signDeviceAttestation(secretKey, deviceId) {
3
5
  return { deviceId, signature: crypto.sign(deviceId, secretKey) };
4
6
  }
@@ -10,3 +12,26 @@ export function verifyDeviceAttestation(publicKey, attestation) {
10
12
  return false;
11
13
  }
12
14
  }
15
+ function writerClaimMessage(binding) {
16
+ const joinedAt = c.encode(c.uint, binding.joinedAt);
17
+ return crypto.hash([
18
+ WRITER_CLAIM_NAMESPACE,
19
+ binding.meshPublicKey,
20
+ binding.deviceId,
21
+ binding.writerKey,
22
+ joinedAt
23
+ ]);
24
+ }
25
+ export function signWriterClaim(secretKey, binding) {
26
+ return crypto.sign(writerClaimMessage(binding), secretKey);
27
+ }
28
+ export function verifyWriterClaim(signature, binding) {
29
+ if (!signature)
30
+ return false;
31
+ try {
32
+ return crypto.verify(writerClaimMessage(binding), signature, binding.deviceId);
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ }
@@ -0,0 +1,9 @@
1
+ export interface DeviceInvites {
2
+ issue(): Promise<Buffer>;
3
+ redeem(token: Buffer | null | undefined, deviceId: Buffer): Promise<boolean>;
4
+ }
5
+ export interface DeviceInviteStore {
6
+ get(key: string): Promise<unknown>;
7
+ set(key: string, value: unknown): Promise<void>;
8
+ }
9
+ export declare function openDeviceInvites(store: DeviceInviteStore): DeviceInvites;
@@ -0,0 +1,40 @@
1
+ import crypto from 'hypercore-crypto';
2
+ import ScopeLock from 'scope-lock';
3
+ import { deviceInviteToken } from "./identity.js";
4
+ const NONCES_KEY = 'device-invite-nonces';
5
+ export function openDeviceInvites(store) {
6
+ const lock = new ScopeLock();
7
+ async function nonces() {
8
+ const value = await store.get(NONCES_KEY);
9
+ return Array.isArray(value) ? value.filter((entry) => typeof entry === 'string') : [];
10
+ }
11
+ return {
12
+ async issue() {
13
+ const nonce = crypto.randomBytes(32);
14
+ await lock.lock();
15
+ try {
16
+ await store.set(NONCES_KEY, [...(await nonces()), nonce.toString('hex')]);
17
+ }
18
+ finally {
19
+ lock.unlock();
20
+ }
21
+ return nonce;
22
+ },
23
+ async redeem(token, deviceId) {
24
+ if (!token)
25
+ return false;
26
+ await lock.lock();
27
+ try {
28
+ const issued = await nonces();
29
+ const spent = issued.findIndex((hex) => deviceInviteToken(Buffer.from(hex, 'hex'), deviceId).equals(token));
30
+ if (spent === -1)
31
+ return false;
32
+ await store.set(NONCES_KEY, issued.filter((_, index) => index !== spent));
33
+ return true;
34
+ }
35
+ finally {
36
+ lock.unlock();
37
+ }
38
+ }
39
+ };
40
+ }
@@ -130,4 +130,5 @@ export declare class Files extends EventEmitter {
130
130
  export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from './rag/index.ts';
131
131
  export type { IndexingEmbedder, RagExtractors, RagSource, VectorIndex } from './rag/index.ts';
132
132
  export { attachTurnDocumentIds, groupAttachmentsByMessage } from './records/index.ts';
133
- export { CoreBlobServer } from './store/index.ts';
133
+ export { CoreBlobServer, parseBlobReferenceCoreKey } from './store/index.ts';
134
+ export type { MeshBlobKeys } from './store/index.ts';
@@ -582,4 +582,4 @@ export class Files extends EventEmitter {
582
582
  }
583
583
  export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from "./rag/index.js";
584
584
  export { attachTurnDocumentIds, groupAttachmentsByMessage } from "./records/index.js";
585
- export { CoreBlobServer } from "./store/index.js";
585
+ export { CoreBlobServer, parseBlobReferenceCoreKey } from "./store/index.js";
@@ -4,6 +4,7 @@ import type Hyperblobs from 'hyperblobs';
4
4
  import { stringifyBlobId, writeBlob, type BlobHost } from './blob.ts';
5
5
  import { readBlobReference, readBlobReferenceBytes, downloadBlobReference } from './reference.ts';
6
6
  export { CoreBlobServer } from './server.ts';
7
+ export type { MeshBlobKeys, MeshForBlobCore } from './server.ts';
7
8
  export { compareBlobReferences, isInvalidBlobReferenceError, parseBlobReference, parseBlobReferenceCoreKey } from './reference.ts';
8
9
  export type { BlobReferenceReadOptions } from './reference.ts';
9
10
  export type { WriteProgress } from './blob.ts';
@@ -2,10 +2,11 @@ import type Corestore from 'corestore';
2
2
  import ReadyResource from 'ready-resource';
3
3
  import type { LinkableAttachment } from '../../attachment-link.ts';
4
4
  import type Hyperblobs from 'hyperblobs';
5
- export type CurrentMeshKeys = () => {
5
+ export type MeshBlobKeys = {
6
6
  blobs: Hyperblobs;
7
7
  encryptionKey: Buffer;
8
- } | null;
8
+ };
9
+ export type MeshForBlobCore = (coreKey: string | null) => MeshBlobKeys | null;
9
10
  export declare class CoreBlobServer extends ReadyResource {
10
11
  private readonly _store;
11
12
  private readonly _mesh;
@@ -13,11 +14,11 @@ export declare class CoreBlobServer extends ReadyResource {
13
14
  private readonly _probes;
14
15
  private readonly _readTimeoutMs;
15
16
  private _suspended;
16
- constructor(store: Corestore, mesh: CurrentMeshKeys, { readTimeoutMs }?: {
17
+ constructor(store: Corestore, mesh: MeshForBlobCore, { readTimeoutMs }?: {
17
18
  readTimeoutMs?: number | undefined;
18
19
  });
19
20
  get port(): number;
20
- link({ blobId, mimeType }: LinkableAttachment): string | null;
21
+ link({ blobId, mimeType }: LinkableAttachment, source?: MeshBlobKeys | null): string | null;
21
22
  suspend(): Promise<void>;
22
23
  resume(): Promise<void>;
23
24
  _open(): Promise<void>;
@@ -20,16 +20,15 @@ export class CoreBlobServer extends ReadyResource {
20
20
  get port() {
21
21
  return this._server.port;
22
22
  }
23
- link({ blobId, mimeType }) {
23
+ link({ blobId, mimeType }, source = this._mesh(null)) {
24
24
  if (!this.opened || this.closing)
25
25
  return null;
26
- const current = this._mesh();
27
- if (!current)
26
+ if (!source)
28
27
  return null;
29
28
  const parsed = this._parse(blobId);
30
29
  if (!parsed || parsed.inline)
31
30
  return null;
32
- return this._server.getLink(parsed.coreKey ?? current.blobs.core.key.toString('hex'), {
31
+ return this._server.getLink(parsed.coreKey ?? source.blobs.core.key.toString('hex'), {
33
32
  blob: parsed.blobId,
34
33
  type: mimeType || 'application/octet-stream'
35
34
  });
@@ -65,7 +64,7 @@ export class CoreBlobServer extends ReadyResource {
65
64
  await this._store.close();
66
65
  }
67
66
  async _resolve(key, info) {
68
- const current = this._mesh();
67
+ const current = this._mesh(key.toString('hex'));
69
68
  if (!current || this.closing || this._suspended)
70
69
  return null;
71
70
  const keys = { encryptionKey: current.encryptionKey };
@@ -91,7 +90,12 @@ export class CoreBlobServer extends ReadyResource {
91
90
  if (!position || this.closing || this._suspended || Date.now() >= deadline)
92
91
  return null;
93
92
  const bytes = await core.get(position[0], { timeout: Math.max(1, deadline - Date.now()) });
94
- return bytes && this._mesh() === current && !this.closing && !this._suspended ? keys : null;
93
+ return bytes &&
94
+ this._mesh(key.toString('hex')) === current &&
95
+ !this.closing &&
96
+ !this._suspended
97
+ ? keys
98
+ : null;
95
99
  }
96
100
  catch {
97
101
  return null;
@@ -1,5 +1,5 @@
1
1
  import type { QvacDevice, QvacSeedDefaultsOperation } from '../../../spec/mesh/hyperschema/types.d.ts';
2
2
  import type { Mesh } from '../mesh.ts';
3
- export declare function buildDefaultSeed(device: QvacDevice, blindPeerKeys: ReadonlyArray<Buffer>): QvacSeedDefaultsOperation;
3
+ export declare function buildDefaultSeed(device: Pick<QvacDevice, 'id' | 'recommendedModelName'>, blindPeerKeys: ReadonlyArray<Buffer>): QvacSeedDefaultsOperation;
4
4
  export declare function isOwnRevokedRow(mesh: Mesh, device: QvacDevice): boolean;
5
5
  export declare function isOwnKickedRow(mesh: Mesh, device: QvacDevice): boolean;
@@ -3,7 +3,8 @@ import type { AssistantSkill } from '../../spec/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 { SecretRequest } from './secret-handoff.ts';
6
- export declare const HELD_AGENTS_KEY = "skill-values.held-agents";
6
+ export declare const LEGACY_HELD_AGENTS_KEY = "skill-values.held-agents";
7
+ export declare function heldAgentsKey(meshKey: Buffer): string;
7
8
  export interface HostedAgentsOptions {
8
9
  readonly mesh: Mesh;
9
10
  readonly local: ReturnType<typeof openLocalStore>;
@@ -21,6 +22,7 @@ export declare class HostedAgents {
21
22
  private readonly _send;
22
23
  private readonly _onmoved;
23
24
  private readonly _log;
25
+ private readonly _heldKey;
24
26
  private readonly _lock;
25
27
  private _closed;
26
28
  private readonly _onDirty;
@@ -3,7 +3,10 @@ import ScopeLock from 'scope-lock';
3
3
  import { getAgent, listAgents } from "./agent.js";
4
4
  import { agentSkillValues } from "./skill-secrets.js";
5
5
  const SCOPE = ['p2p', 'skill-values'];
6
- export const HELD_AGENTS_KEY = 'skill-values.held-agents';
6
+ export const LEGACY_HELD_AGENTS_KEY = 'skill-values.held-agents';
7
+ export function heldAgentsKey(meshKey) {
8
+ return `${LEGACY_HELD_AGENTS_KEY}.${meshKey.toString('hex')}`;
9
+ }
7
10
  export class HostedAgents {
8
11
  _mesh;
9
12
  _local;
@@ -12,11 +15,13 @@ export class HostedAgents {
12
15
  _send;
13
16
  _onmoved;
14
17
  _log;
18
+ _heldKey;
15
19
  _lock = new ScopeLock({ debounce: true });
16
20
  _closed;
17
21
  _onDirty = () => this.kick();
18
22
  constructor(opts) {
19
23
  this._mesh = opts.mesh;
24
+ this._heldKey = heldAgentsKey(opts.mesh.key);
20
25
  this._local = opts.local;
21
26
  this._deviceId = opts.deviceId;
22
27
  this._catalog = opts.catalog;
@@ -74,7 +79,7 @@ export class HostedAgents {
74
79
  }
75
80
  }
76
81
  if (!sameIds(held, holding))
77
- await this._local.set(HELD_AGENTS_KEY, [...holding]);
82
+ await this._local.set(this._heldKey, [...holding]);
78
83
  }
79
84
  async _handOver(id, catalog) {
80
85
  const agent = await getAgent(this._mesh, id);
@@ -102,7 +107,8 @@ export class HostedAgents {
102
107
  return stored;
103
108
  }
104
109
  async _held() {
105
- const stored = await this._local.get(HELD_AGENTS_KEY);
110
+ const stored = (await this._local.get(this._heldKey)) ??
111
+ (await this._local.rekey(LEGACY_HELD_AGENTS_KEY, this._heldKey));
106
112
  const ids = new Set();
107
113
  if (Array.isArray(stored)) {
108
114
  for (const id of stored) {
@@ -8,7 +8,17 @@ export interface ExpectedDeviceProof {
8
8
  readonly memberId: Buffer;
9
9
  readonly deviceId: Buffer;
10
10
  }
11
+ export interface ExpectedMemberClaim {
12
+ readonly memberId: Buffer;
13
+ readonly deviceId: Buffer;
14
+ readonly attestation: Buffer;
15
+ }
11
16
  export declare function generateMnemonic(): Promise<string>;
12
17
  export declare function mintIdentity(mnemonic: string, devicePublicKey: Buffer): Promise<MintedIdentity>;
13
18
  export declare function attestDeviceProof(devicePublicKey: Buffer, parent: KeyPair, parentProof: Buffer): Promise<Buffer>;
14
19
  export declare function verifyDeviceProof(proof: Buffer, expected: ExpectedDeviceProof): Promise<boolean>;
20
+ export declare function claimAttestation(meshPublicKey: Buffer, deviceId: Buffer, writerKey: Buffer): Buffer;
21
+ export declare function deviceInviteToken(nonce: Buffer, deviceId: Buffer): Buffer;
22
+ export declare function attestMemberClaim(attestation: Buffer, deviceKeyPair: KeyPair, deviceProof: Buffer): Promise<Buffer>;
23
+ export declare function verifyMemberClaim(proof: Buffer, expected: ExpectedMemberClaim): Promise<boolean>;
24
+ export declare function bareDeviceProof(proof: Buffer): Buffer | null;
@@ -1,6 +1,9 @@
1
1
  import c from 'compact-encoding';
2
+ import crypto from 'hypercore-crypto';
2
3
  import { ProofEncoding } from 'keet-identity-key/lib/encoding.js';
3
4
  export const MAX_PROOF_BYTES = 1024;
5
+ const [CLAIM_NAMESPACE] = crypto.namespace('@qvac/core/member-claim', 1);
6
+ const [INVITE_NAMESPACE] = crypto.namespace('@qvac/core/device-invite', 1);
4
7
  let loaded = null;
5
8
  async function identityKey() {
6
9
  if (loaded === null)
@@ -43,3 +46,45 @@ export async function verifyDeviceProof(proof, expected) {
43
46
  return false;
44
47
  }
45
48
  }
49
+ export function claimAttestation(meshPublicKey, deviceId, writerKey) {
50
+ return crypto.hash([CLAIM_NAMESPACE, meshPublicKey, deviceId, writerKey]);
51
+ }
52
+ export function deviceInviteToken(nonce, deviceId) {
53
+ return crypto.hash([INVITE_NAMESPACE, nonce, deviceId]);
54
+ }
55
+ export async function attestMemberClaim(attestation, deviceKeyPair, deviceProof) {
56
+ return (await identityKey()).attestData(attestation, deviceKeyPair, deviceProof);
57
+ }
58
+ export async function verifyMemberClaim(proof, expected) {
59
+ if (proof.byteLength > MAX_PROOF_BYTES)
60
+ return false;
61
+ let decoded;
62
+ try {
63
+ decoded = c.decode(ProofEncoding, proof);
64
+ }
65
+ catch {
66
+ return false;
67
+ }
68
+ if (!decoded.data)
69
+ return false;
70
+ try {
71
+ const IdentityKey = await identityKey();
72
+ return !!IdentityKey.verify(proof, expected.attestation, {
73
+ expectedIdentity: expected.memberId,
74
+ expectedDevice: expected.deviceId
75
+ });
76
+ }
77
+ catch {
78
+ return false;
79
+ }
80
+ }
81
+ export function bareDeviceProof(proof) {
82
+ let decoded;
83
+ try {
84
+ decoded = c.decode(ProofEncoding, proof);
85
+ }
86
+ catch {
87
+ return null;
88
+ }
89
+ return c.encode(ProofEncoding, { ...decoded, data: null });
90
+ }
@@ -9,6 +9,9 @@ export interface MeshInvite {
9
9
  readonly fastForward: QvacAutobeeHead | null;
10
10
  readonly additionalNodes?: ReadonlyArray<MeshInviteNode>;
11
11
  readonly blindPeers?: ReadonlyArray<Buffer>;
12
+ readonly memberInvite?: boolean;
13
+ readonly memberId?: Buffer;
14
+ readonly inviteNonce?: Buffer;
12
15
  }
13
16
  export declare function encodeMeshInvite(invite: MeshInvite): string;
14
17
  export declare function decodeMeshInvite(raw: string): MeshInvite | null;
@@ -8,7 +8,10 @@ export function encodeMeshInvite(invite) {
8
8
  seed: invite.seed,
9
9
  fastForward: invite.fastForward,
10
10
  additionalNodes: [...(invite.additionalNodes ?? [])],
11
- blindPeers: [...(invite.blindPeers ?? [])]
11
+ blindPeers: [...(invite.blindPeers ?? [])],
12
+ memberInvite: invite.memberInvite ?? false,
13
+ memberId: invite.memberId ?? null,
14
+ inviteNonce: invite.inviteNonce ?? null
12
15
  };
13
16
  return INVITE_PREFIX + z32.encode(encodeStruct(INVITE_STRUCT, payload));
14
17
  }
@@ -31,6 +34,9 @@ export function decodeMeshInvite(raw) {
31
34
  host: node.host,
32
35
  port: node.port
33
36
  })),
34
- blindPeers: payload.blindPeers ?? []
37
+ blindPeers: payload.blindPeers ?? [],
38
+ memberInvite: payload.memberInvite ?? false,
39
+ memberId: payload.memberId ?? undefined,
40
+ inviteNonce: payload.inviteNonce ?? undefined
35
41
  };
36
42
  }
@@ -1,12 +1,11 @@
1
1
  import CorestoreStorage from 'hypercore-storage';
2
2
  import HyperDB from 'hyperdb';
3
- import type { LocalAppConfig, LocalCapabilityProfile, LocalChatNotify, LocalCustomModel, LocalIdentity, LocalMembership, LocalMeshDeparture, LocalModelDownload, LocalModelNotify } from '../../../spec/local/hyperschema/types.d.ts';
3
+ import type { LocalAppConfig, LocalCapabilityProfile, LocalChatNotify, LocalCustomModel, LocalIdentity, LocalMemberProof, LocalMeshDeparture, LocalMeshMembership, LocalModelDownload, LocalModelNotify } from '../../../spec/local/hyperschema/types.d.ts';
4
4
  import type { DeviceMetadata } from '../mesh.ts';
5
5
  export interface ResolvedSession {
6
6
  readonly seed: Buffer;
7
7
  readonly baseKey: Buffer | undefined;
8
8
  readonly writerSeed: string | undefined;
9
- readonly creator: boolean;
10
9
  }
11
10
  export declare function openLocalStore(storage: CorestoreStorage): LocalStore;
12
11
  declare class LocalStore {
@@ -20,6 +19,7 @@ declare class LocalStore {
20
19
  readonly key: string;
21
20
  readonly value: unknown;
22
21
  }>): Promise<void>;
22
+ rekey(fromKey: string, toKey: string): Promise<unknown>;
23
23
  deleteAll(keys: ReadonlyArray<string>): Promise<void>;
24
24
  getAppConfigRow(): Promise<LocalAppConfig | null>;
25
25
  updateAppConfigRow(mutate: (current: LocalAppConfig | null) => Omit<LocalAppConfig, 'id'>): Promise<LocalAppConfig>;
@@ -46,8 +46,8 @@ declare class LocalStore {
46
46
  renameDevice(publicKey: Buffer, name: string): Promise<void>;
47
47
  saveDeviceProfile(publicKey: Buffer, capabilityProfile: LocalCapabilityProfile, recommendedModelName: string, platform?: string): Promise<void>;
48
48
  readIdentity(): Promise<LocalIdentity | null>;
49
- readMembership(): Promise<LocalMembership | null>;
50
- recordMembership(link: Omit<LocalMembership, 'id'>): Promise<void>;
49
+ readMemberProof(meshKey: Buffer): Promise<LocalMemberProof | null>;
50
+ recordMemberProof(link: LocalMemberProof): Promise<void>;
51
51
  ensureIdentity(devicePublicKey: Buffer, createdAt: number): Promise<{
52
52
  identity: LocalIdentity;
53
53
  mnemonic: string | null;
@@ -57,13 +57,28 @@ declare class LocalStore {
57
57
  baseKey?: Buffer;
58
58
  new?: boolean;
59
59
  writerSeed?: string;
60
- creator?: boolean;
61
60
  }): Promise<ResolvedSession>;
62
61
  createCandidateSession(seed: Buffer, baseKey: Buffer): ResolvedSession;
63
- recordMesh(deviceId: Buffer, key: Buffer, seed: Buffer, creator: boolean, writerSeed: string | undefined): Promise<void>;
64
- recordDeparture(key: Buffer): Promise<void>;
62
+ private _activeMembership;
63
+ private _membership;
64
+ private _migrateLegacySession;
65
+ private _legacyMembership;
66
+ recordMesh(deviceId: Buffer, key: Buffer, session: ResolvedSession, { account }?: {
67
+ account?: boolean;
68
+ }): Promise<void>;
69
+ setActiveMesh(deviceId: Buffer, key: Buffer): Promise<void>;
70
+ recordDeparture(key: Buffer, opts: {
71
+ creator: boolean;
72
+ }): Promise<void>;
65
73
  departures(): Promise<LocalMeshDeparture[]>;
66
74
  deleteDeparture(key: Buffer): Promise<void>;
75
+ archiveMesh(key: Buffer): Promise<void>;
76
+ adoptHomeMesh(deviceId: Buffer, key: Buffer): Promise<void>;
77
+ private _pointersAt;
78
+ listMeshes(): Promise<LocalMeshMembership[]>;
79
+ listArchivedMeshes(): Promise<LocalMeshMembership[]>;
80
+ homeMesh(deviceId: Buffer): Promise<LocalMeshMembership | null>;
81
+ readMeshSession(key: Buffer): Promise<ResolvedSession | null>;
67
82
  watch(listener: () => void): void;
68
83
  unwatch(listener: () => void): void;
69
84
  close(): Promise<void>;