@qvac/core 0.7.6 → 0.9.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 +83 -1
- package/README.md +1 -1
- package/dist-lib/lib/assistant/skill-encode.d.ts +1 -0
- package/dist-lib/lib/assistant/skill-encode.js +1 -0
- package/dist-lib/lib/core/blind-peers.d.ts +0 -3
- package/dist-lib/lib/core/chunk.d.ts +4 -0
- package/dist-lib/lib/core/contract/seed-defaults.js +2 -2
- package/dist-lib/lib/core/contract/writers.js +1 -1
- package/dist-lib/lib/core/departures.d.ts +5 -7
- package/dist-lib/lib/core/departures.js +14 -12
- package/dist-lib/lib/core/files/records/reclaim.js +1 -1
- package/dist-lib/lib/core/fs-drives.d.ts +2 -6
- package/dist-lib/lib/core/fs-drives.js +7 -30
- package/dist-lib/lib/core/invite.js +9 -4
- package/dist-lib/lib/core/mesh.d.ts +20 -7
- package/dist-lib/lib/core/mesh.js +205 -39
- package/dist-lib/lib/core/sync/index.d.ts +1 -0
- package/dist-lib/lib/core/sync/index.js +136 -67
- package/dist-lib/lib/core.d.ts +5 -10
- package/dist-lib/lib/core.js +156 -156
- package/dist-lib/schema/engine.js +5 -2
- package/dist-lib/spec/hrpc/messages.js +22 -6
- package/dist-lib/spec/hyperschema/index.js +22 -6
- package/dist-lib/spec/hyperschema/schema.json +15 -0
- package/dist-lib/spec/hyperschema/types.d.ts +3 -0
- package/package.json +1 -1
- package/tui/README.md +16 -14
- package/tui/app.mjs +10 -4
- package/tui/boot.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,86 @@ release.
|
|
|
13
13
|
|
|
14
14
|
## [Unreleased]
|
|
15
15
|
|
|
16
|
+
## [0.9.0] - 2026-10-15
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **Breaking:** `meshInvite` mints a member invite as `qvac://workspace/…` and
|
|
21
|
+
a device invite as `qvac://device/…`, instead of `qvac://mesh/…`
|
|
22
|
+
(QVAC-26926). `joinMesh`, `previewMeshInvite` and `decodeMeshInvite` read all
|
|
23
|
+
three, so a link shared before still works, but a release before this one
|
|
24
|
+
refuses the new links with `Invalid mesh invite`: both sides of a join need
|
|
25
|
+
this version. An app that matches the prefix itself has to accept all three
|
|
26
|
+
before it takes this release, as tetherto/qvac-app#2535 does. (#394)
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
const { invite } = await engine.meshInvite({ meshId, member: true })
|
|
30
|
+
// 0.8: qvac://mesh/… 0.9: qvac://workspace/…
|
|
31
|
+
const { invite: pairing } = await engine.meshInvite({})
|
|
32
|
+
// 0.8: qvac://mesh/… 0.9: qvac://device/…
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## [0.8.0] - 2026-10-15
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- `skillCatalog` entries carry `displayName`, the user-facing name and `@`
|
|
40
|
+
handle a skill's manifest declares, so an app can show Documents and
|
|
41
|
+
Spreadsheets for the `word` and `excel` skills without renaming them. (#392)
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const { skills } = await engine.skillCatalog({ agentId: agent.id })
|
|
45
|
+
const handle = skills.map((skill) => skill.displayName ?? skill.name)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- `meshStatusWatch` frames carry `blindPeersConnected` and `blindPeersTotal`,
|
|
49
|
+
the device's blind peers holding a connection of those it dials; a blind
|
|
50
|
+
peer connecting or dropping makes a frame. (#403)
|
|
51
|
+
- Every mesh lifecycle line carries where the mesh stood: `opening` names the
|
|
52
|
+
head it boots from (`null` is a replay from genesis), `autobee opened`,
|
|
53
|
+
`landed on the view`, `joined` and `closing` carry the local, system and
|
|
54
|
+
view lengths, the flushes, autobee's counters and the time since the open;
|
|
55
|
+
Core logs `mesh opened` with why (`route`, `follow`, `readmit`) and how long,
|
|
56
|
+
`followed the joined meshes` with its tally, and names the mesh it announces.
|
|
57
|
+
`diagnostics` returns the same counters under `stats.mesh.stats`. The two
|
|
58
|
+
seed lines (`seeded default agent`, `seeded first chat`) are debug: a rebuilt
|
|
59
|
+
view re-applies the genesis seed, and they read as a second seeding. (#403)
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- Joining a mesh reports joined as soon as the fast-forward lands, instead of
|
|
64
|
+
after a read of the whole view over the network. On a mesh with a long
|
|
65
|
+
history that read took tens of seconds, whatever the invite's head. The
|
|
66
|
+
member tally, mesh name, chat order and file index fill in moments after the
|
|
67
|
+
landing; a chat list in that window waits for the rebuild. (#400)
|
|
68
|
+
- The mesh logs `landed on the view` and `joined` with their timings, applies
|
|
69
|
+
and undos, and `device admitted` is a debug line: a catch-up re-applies every
|
|
70
|
+
claim on each re-linearisation. (#400)
|
|
71
|
+
- The meshes an account names open once the account's own join has settled,
|
|
72
|
+
instead of the moment the account lands, so they no longer compete with the
|
|
73
|
+
account's catch-up for the same peers. (#407)
|
|
74
|
+
|
|
75
|
+
### Fixed
|
|
76
|
+
|
|
77
|
+
- A mesh the account names on a sibling's behalf, opened with no head of its
|
|
78
|
+
own, fast-forwards onto the first head a sibling device offers, instead of
|
|
79
|
+
replaying from genesis until that device's row happened to land. The head's
|
|
80
|
+
own view carries the device's signed claim to the writer, and the account
|
|
81
|
+
says whose device that is. (#408)
|
|
82
|
+
- One blind-peering client per device, shared by every mesh and core. Each mesh
|
|
83
|
+
(and the config, recovery, departure and drive cores) built its own client,
|
|
84
|
+
all dialling under the device's one key, and a blind peer keeps one connection
|
|
85
|
+
per key: every connect by one mesh dropped another's, endlessly. A mesh's
|
|
86
|
+
invite still names the blind peers it is mirrored on; what is shared is the
|
|
87
|
+
connection to each. (#405)
|
|
88
|
+
- A device no longer dials every device in its account mesh directly on each
|
|
89
|
+
membership change; peers are found on the mesh topic. (#405)
|
|
90
|
+
- A device coming back after a long absence fast-forwards onto the new head
|
|
91
|
+
without diffing the whole view across cores: it reads the landed snapshot,
|
|
92
|
+
and the attachments deleted while it was away refresh on the sweep. On a mesh
|
|
93
|
+
with ~20k rows that jump took 110–150 s; it now takes a few seconds. (#399,
|
|
94
|
+
#402)
|
|
95
|
+
|
|
16
96
|
## [0.7.6] - 2026-10-14
|
|
17
97
|
|
|
18
98
|
### Added
|
|
@@ -1608,7 +1688,9 @@ Published under the `release-0.1` dist-tag.
|
|
|
1608
1688
|
await assistant.ready()
|
|
1609
1689
|
```
|
|
1610
1690
|
|
|
1611
|
-
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.
|
|
1691
|
+
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.9.0...HEAD
|
|
1692
|
+
[0.9.0]: https://github.com/tetherto/qvac-core/compare/v0.8.0...v0.9.0
|
|
1693
|
+
[0.8.0]: https://github.com/tetherto/qvac-core/compare/v0.7.6...v0.8.0
|
|
1612
1694
|
[0.7.6]: https://github.com/tetherto/qvac-core/compare/v0.7.5...v0.7.6
|
|
1613
1695
|
[0.7.5]: https://github.com/tetherto/qvac-core/compare/v0.7.4...v0.7.5
|
|
1614
1696
|
[0.7.4]: https://github.com/tetherto/qvac-core/compare/v0.7.3...v0.7.4
|
package/README.md
CHANGED
|
@@ -722,7 +722,7 @@ The TUI copies its mesh invite to the clipboard on ctrl+y. On a second machine
|
|
|
722
722
|
(or a second terminal), start `duck` and join from inside it:
|
|
723
723
|
|
|
724
724
|
```
|
|
725
|
-
/join qvac://
|
|
725
|
+
/join qvac://device/…
|
|
726
726
|
```
|
|
727
727
|
|
|
728
728
|
The preview says who you would join as. A device invite (`/invite`) retires the
|
|
@@ -2,6 +2,7 @@ import type { InstallStep, SkillRequires, SkillSetup } from '@qvac/harness';
|
|
|
2
2
|
import type { AssistantSkill } from '../../spec/hyperschema/types.d.ts';
|
|
3
3
|
export interface Skill {
|
|
4
4
|
name: string;
|
|
5
|
+
displayName?: string;
|
|
5
6
|
description: string;
|
|
6
7
|
status: string;
|
|
7
8
|
tools: string[];
|
|
@@ -7,6 +7,10 @@ type AppendChunkInput = Pick<QvacChunk, 'chatId' | 'runId' | 'type' | 'originDev
|
|
|
7
7
|
id?: string;
|
|
8
8
|
};
|
|
9
9
|
type UpdateChunkInput = Pick<QvacChunk, 'id' | 'runStatus' | 'attachment'>;
|
|
10
|
+
export interface ChunkByChatKey {
|
|
11
|
+
chatId: string;
|
|
12
|
+
seq: number;
|
|
13
|
+
}
|
|
10
14
|
export declare const HISTORY_CHUNK_TYPES: QvacChunk['type'][];
|
|
11
15
|
type MediaKind = 'audio' | 'image' | 'video' | 'other';
|
|
12
16
|
type AttachmentOrigin = 'uploaded' | 'generated';
|
|
@@ -5,7 +5,7 @@ export function registerSeedDefaultsRoutes(router) {
|
|
|
5
5
|
let seeded = false;
|
|
6
6
|
if (!(await tx.get(AGENTS, { id: op.agent.id }))) {
|
|
7
7
|
await tx.insert(AGENTS, op.agent);
|
|
8
|
-
log?.
|
|
8
|
+
log?.debug('contract', 'seeded default agent', {
|
|
9
9
|
id: op.agent.id,
|
|
10
10
|
model: op.agent.modelName
|
|
11
11
|
});
|
|
@@ -13,7 +13,7 @@ export function registerSeedDefaultsRoutes(router) {
|
|
|
13
13
|
}
|
|
14
14
|
if (!(await tx.get(CHATS, { id: op.chat.id }))) {
|
|
15
15
|
await tx.insert(CHATS, op.chat);
|
|
16
|
-
log?.
|
|
16
|
+
log?.debug('contract', 'seeded first chat', { id: op.chat.id });
|
|
17
17
|
seeded = true;
|
|
18
18
|
}
|
|
19
19
|
for (const peer of op.blindPeers ?? []) {
|
|
@@ -88,7 +88,7 @@ export async function admitDevice({ tx, node, host, meshPublicKey, log }, device
|
|
|
88
88
|
}
|
|
89
89
|
await markWriterRevoked(tx, writerKey, { revoked: false });
|
|
90
90
|
if (!alreadyAdmitted) {
|
|
91
|
-
log?.
|
|
91
|
+
log?.debug('contract', 'device admitted', { id: b4a.toHex(id).slice(0, 16) });
|
|
92
92
|
}
|
|
93
93
|
return 'admitted';
|
|
94
94
|
}
|
|
@@ -3,7 +3,7 @@ import type Hyperswarm from 'hyperswarm';
|
|
|
3
3
|
import type Wakeup from 'protomux-wakeup';
|
|
4
4
|
import type { Logger } from '../../index.ts';
|
|
5
5
|
import type { LocalMeshDeparture } from '../../spec/local/hyperschema/types.d.ts';
|
|
6
|
-
import type
|
|
6
|
+
import type BlindPeering from 'blind-peering';
|
|
7
7
|
interface DepartureRows {
|
|
8
8
|
departures(): Promise<LocalMeshDeparture[]>;
|
|
9
9
|
deleteDeparture(key: Buffer): Promise<void>;
|
|
@@ -14,8 +14,7 @@ export interface PendingDeparturesOptions {
|
|
|
14
14
|
deviceId: () => Buffer | null;
|
|
15
15
|
logger?: Logger | null;
|
|
16
16
|
blindPeerKeys?: ReadonlyArray<Buffer>;
|
|
17
|
-
|
|
18
|
-
blindPeering?: boolean;
|
|
17
|
+
blindPeering: () => BlindPeering | null;
|
|
19
18
|
wakeup?: Wakeup;
|
|
20
19
|
}
|
|
21
20
|
export declare class PendingDepartures {
|
|
@@ -24,7 +23,6 @@ export declare class PendingDepartures {
|
|
|
24
23
|
private readonly _swarm;
|
|
25
24
|
private readonly _log;
|
|
26
25
|
private readonly _blindPeerKeys;
|
|
27
|
-
private readonly _blindPeeringOpts;
|
|
28
26
|
private readonly _wakeup;
|
|
29
27
|
private readonly _isPooled;
|
|
30
28
|
private readonly _deviceId;
|
|
@@ -32,7 +30,7 @@ export declare class PendingDepartures {
|
|
|
32
30
|
private readonly _parked;
|
|
33
31
|
private readonly _lock;
|
|
34
32
|
private _closing;
|
|
35
|
-
private _blindPeering;
|
|
33
|
+
private readonly _blindPeering;
|
|
36
34
|
constructor(store: Corestore, local: DepartureRows, opts: PendingDeparturesOptions);
|
|
37
35
|
flush(): void;
|
|
38
36
|
private _flush;
|
|
@@ -41,8 +39,8 @@ export declare class PendingDepartures {
|
|
|
41
39
|
park(key: Buffer): Promise<void>;
|
|
42
40
|
unpark(key: Buffer): void;
|
|
43
41
|
drop(key: Buffer): Promise<void>;
|
|
44
|
-
startBlindPeering(
|
|
45
|
-
stopBlindPeering():
|
|
42
|
+
startBlindPeering(): void;
|
|
43
|
+
stopBlindPeering(): void;
|
|
46
44
|
suspend(): Promise<void>;
|
|
47
45
|
resume(): Promise<void>;
|
|
48
46
|
close(): Promise<void>;
|
|
@@ -8,7 +8,6 @@ export class PendingDepartures {
|
|
|
8
8
|
_swarm;
|
|
9
9
|
_log;
|
|
10
10
|
_blindPeerKeys;
|
|
11
|
-
_blindPeeringOpts;
|
|
12
11
|
_wakeup;
|
|
13
12
|
_isPooled;
|
|
14
13
|
_deviceId;
|
|
@@ -25,9 +24,8 @@ export class PendingDepartures {
|
|
|
25
24
|
this._deviceId = opts.deviceId;
|
|
26
25
|
this._log = opts.logger ?? null;
|
|
27
26
|
this._blindPeerKeys = opts.blindPeerKeys ?? [];
|
|
28
|
-
this._blindPeeringOpts = opts.blindPeeringOpts;
|
|
29
27
|
this._wakeup = opts.wakeup;
|
|
30
|
-
this._blindPeering = opts.blindPeering
|
|
28
|
+
this._blindPeering = opts.blindPeering;
|
|
31
29
|
}
|
|
32
30
|
flush() {
|
|
33
31
|
void this._flush().catch((err) => this._log?.warn(SCOPE, 'departure flush failed', err));
|
|
@@ -52,7 +50,6 @@ export class PendingDepartures {
|
|
|
52
50
|
deviceId: this._deviceId() ?? undefined,
|
|
53
51
|
logger: this._log,
|
|
54
52
|
blindPeerKeys: this._blindPeerKeys,
|
|
55
|
-
blindPeeringOpts: this._blindPeeringOpts,
|
|
56
53
|
wakeup: this._wakeup
|
|
57
54
|
});
|
|
58
55
|
const done = this._deliver(row, mesh)
|
|
@@ -73,8 +70,9 @@ export class PendingDepartures {
|
|
|
73
70
|
return;
|
|
74
71
|
}
|
|
75
72
|
this._swarm.join(mesh.discoveryKey, { server: true, client: true });
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
const peering = this._blindPeering();
|
|
74
|
+
if (peering) {
|
|
75
|
+
mesh.startBlindPeering(peering);
|
|
78
76
|
}
|
|
79
77
|
this._log?.info(scope, 'reopened a departed mesh to deliver its removal');
|
|
80
78
|
const announced = await this._announce(mesh);
|
|
@@ -128,15 +126,19 @@ export class PendingDepartures {
|
|
|
128
126
|
drop(key) {
|
|
129
127
|
return this._local.deleteDeparture(key);
|
|
130
128
|
}
|
|
131
|
-
startBlindPeering(
|
|
132
|
-
this._blindPeering
|
|
129
|
+
startBlindPeering() {
|
|
130
|
+
const peering = this._blindPeering();
|
|
131
|
+
if (!peering) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
133
134
|
for (const { mesh } of this._active.values()) {
|
|
134
|
-
mesh.startBlindPeering(
|
|
135
|
+
mesh.startBlindPeering(peering);
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
|
|
138
|
+
stopBlindPeering() {
|
|
139
|
+
for (const { mesh } of this._active.values()) {
|
|
140
|
+
mesh.stopBlindPeering();
|
|
141
|
+
}
|
|
140
142
|
}
|
|
141
143
|
async suspend() {
|
|
142
144
|
for (const { mesh } of this._active.values()) {
|
|
@@ -86,7 +86,7 @@ async function syncChatAttachmentChunks(mesh, chatId) {
|
|
|
86
86
|
for (const chunk of await listChunks(mesh, { chatId, type: 'attachment' })) {
|
|
87
87
|
if (mesh.closing)
|
|
88
88
|
return false;
|
|
89
|
-
await
|
|
89
|
+
await mesh.files.syncAttachment(chunk);
|
|
90
90
|
}
|
|
91
91
|
return true;
|
|
92
92
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import BlindPeering from 'blind-peering';
|
|
1
2
|
import Hyperdrive from 'hyperdrive';
|
|
2
3
|
import type Corestore from 'corestore';
|
|
3
4
|
import type Hyperswarm from 'hyperswarm';
|
|
4
|
-
import type { BlindPeeringOpts } from './blind-peers.ts';
|
|
5
5
|
export interface AcquiredDrive {
|
|
6
6
|
readonly drive: Hyperdrive;
|
|
7
7
|
readonly writable: boolean;
|
|
@@ -12,14 +12,10 @@ export interface DriveHost {
|
|
|
12
12
|
}
|
|
13
13
|
export interface PeeredDriveHost extends DriveHost {
|
|
14
14
|
startBlindPeering(): Promise<void>;
|
|
15
|
-
stopBlindPeering(): Promise<void>;
|
|
16
|
-
suspend(): Promise<void>;
|
|
17
|
-
resume(): Promise<void>;
|
|
18
15
|
}
|
|
19
16
|
export interface DriveHostOptions {
|
|
20
17
|
readonly swarm: Hyperswarm;
|
|
21
18
|
readonly blindPeerKeys: ReadonlyArray<Buffer>;
|
|
22
|
-
readonly
|
|
23
|
-
readonly blindPeering?: boolean;
|
|
19
|
+
readonly blindPeering: () => BlindPeering | null;
|
|
24
20
|
}
|
|
25
21
|
export declare function createFsDriveHost(store: Corestore, opts: DriveHostOptions): PeeredDriveHost;
|
|
@@ -26,20 +26,15 @@ async function openDrive(store, swarm, key) {
|
|
|
26
26
|
export function createFsDriveHost(store, opts) {
|
|
27
27
|
const namespaced = store.namespace(NAMESPACE);
|
|
28
28
|
const drives = new Map();
|
|
29
|
-
let suspended = false;
|
|
30
|
-
let peering = opts.blindPeering === false ? null : startPeering();
|
|
31
|
-
function startPeering() {
|
|
32
|
-
return new BlindPeering(opts.swarm.dht, namespaced, {
|
|
33
|
-
pick: 2,
|
|
34
|
-
suspended,
|
|
35
|
-
...opts.blindPeeringOpts
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
29
|
async function peer(held) {
|
|
30
|
+
const peering = opts.blindPeering();
|
|
31
|
+
if (!peering) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
39
34
|
const blobs = await held.drive.getBlobs();
|
|
40
|
-
peering
|
|
35
|
+
peering.addCoreBackground(held.drive.core, { keys: opts.blindPeerKeys, pick: 2 });
|
|
41
36
|
if (blobs) {
|
|
42
|
-
peering
|
|
37
|
+
peering.addCoreBackground(blobs.core, { keys: opts.blindPeerKeys, pick: 2 });
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
40
|
async function acquire(key) {
|
|
@@ -63,25 +58,8 @@ export function createFsDriveHost(store, opts) {
|
|
|
63
58
|
.map(({ value }) => value);
|
|
64
59
|
}
|
|
65
60
|
async function startBlindPeering() {
|
|
66
|
-
if (peering) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
peering = startPeering();
|
|
70
61
|
await Promise.all((await opened()).map(peer));
|
|
71
62
|
}
|
|
72
|
-
async function stopBlindPeering() {
|
|
73
|
-
const closing = peering;
|
|
74
|
-
peering = null;
|
|
75
|
-
await closing?.close();
|
|
76
|
-
}
|
|
77
|
-
async function suspend() {
|
|
78
|
-
suspended = true;
|
|
79
|
-
await peering?.suspend();
|
|
80
|
-
}
|
|
81
|
-
async function resume() {
|
|
82
|
-
suspended = false;
|
|
83
|
-
await peering?.resume();
|
|
84
|
-
}
|
|
85
63
|
async function close() {
|
|
86
64
|
const held = await opened();
|
|
87
65
|
drives.clear();
|
|
@@ -89,7 +67,6 @@ export function createFsDriveHost(store, opts) {
|
|
|
89
67
|
await topic.destroy();
|
|
90
68
|
await drive.close();
|
|
91
69
|
}));
|
|
92
|
-
await peering?.close();
|
|
93
70
|
}
|
|
94
|
-
return { acquire, startBlindPeering,
|
|
71
|
+
return { acquire, startBlindPeering, close };
|
|
95
72
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as z32 from 'z32';
|
|
2
2
|
import { decode as decodeStruct, encode as encodeStruct } from '../../spec/mesh/hyperschema/index.js';
|
|
3
3
|
const INVITE_STRUCT = '@qvac/mesh-invite';
|
|
4
|
-
const
|
|
4
|
+
const MEMBER_INVITE_PREFIX = 'qvac://workspace/';
|
|
5
|
+
const DEVICE_INVITE_PREFIX = 'qvac://device/';
|
|
6
|
+
const LEGACY_INVITE_PREFIX = 'qvac://mesh/';
|
|
7
|
+
const INVITE_PREFIXES = [MEMBER_INVITE_PREFIX, DEVICE_INVITE_PREFIX, LEGACY_INVITE_PREFIX];
|
|
5
8
|
export function encodeMeshInvite(invite) {
|
|
6
9
|
const payload = {
|
|
7
10
|
meshKey: invite.baseKey,
|
|
@@ -17,16 +20,18 @@ export function encodeMeshInvite(invite) {
|
|
|
17
20
|
deviceSeed: invite.deviceSeed ?? null,
|
|
18
21
|
deviceProof: invite.deviceProof ?? null
|
|
19
22
|
};
|
|
20
|
-
|
|
23
|
+
const prefix = invite.memberInvite ? MEMBER_INVITE_PREFIX : DEVICE_INVITE_PREFIX;
|
|
24
|
+
return prefix + z32.encode(encodeStruct(INVITE_STRUCT, payload));
|
|
21
25
|
}
|
|
22
26
|
export function decodeMeshInvite(raw) {
|
|
23
27
|
const value = raw.trim().toLowerCase();
|
|
24
|
-
|
|
28
|
+
const prefix = INVITE_PREFIXES.find((p) => value.startsWith(p));
|
|
29
|
+
if (!prefix) {
|
|
25
30
|
return null;
|
|
26
31
|
}
|
|
27
32
|
let payload;
|
|
28
33
|
try {
|
|
29
|
-
payload = decodeStruct(INVITE_STRUCT, z32.decode(value.slice(
|
|
34
|
+
payload = decodeStruct(INVITE_STRUCT, z32.decode(value.slice(prefix.length)));
|
|
30
35
|
}
|
|
31
36
|
catch {
|
|
32
37
|
return null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Autobee, { type AutobeeChanges, type AutobeeHost, type AutobeeNode, type AutobeeOplogRef } from 'autobee';
|
|
2
|
+
import BlindPeering from 'blind-peering';
|
|
2
3
|
import Corestore from 'corestore';
|
|
3
4
|
import HyperDB from 'hyperdb';
|
|
4
5
|
import Hyperblobs from 'hyperblobs';
|
|
@@ -9,7 +10,6 @@ import { Files } from './files/index.ts';
|
|
|
9
10
|
import type { Logger } from '../../index.ts';
|
|
10
11
|
import { Router } from '../../spec/mesh/hyperdispatch/index.js';
|
|
11
12
|
import type { QvacCapabilityProfile, QvacDevice, QvacMember, QvacMeshName } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
12
|
-
import type { BlindPeeringOpts, StartBlindPeeringOpts } from './blind-peers.ts';
|
|
13
13
|
import type { AttachmentUrl } from './attachment-link.ts';
|
|
14
14
|
import type { MeshFileIndex } from './files/local-index.ts';
|
|
15
15
|
import { type DeviceAttestation } from './device-attestation.ts';
|
|
@@ -35,8 +35,8 @@ export interface MeshOptions {
|
|
|
35
35
|
deviceId?: Buffer;
|
|
36
36
|
logger?: Logger | null;
|
|
37
37
|
blindPeerKeys?: ReadonlyArray<Buffer>;
|
|
38
|
-
blindPeeringOpts?: BlindPeeringOpts;
|
|
39
38
|
bootFrom?: AutobeeOplogRef | null;
|
|
39
|
+
trustedDevice?: (deviceId: Buffer) => Promise<boolean>;
|
|
40
40
|
wakeup?: Wakeup;
|
|
41
41
|
attachmentUrl?: AttachmentUrl | null;
|
|
42
42
|
fileIndex?: MeshFileIndex | null;
|
|
@@ -93,7 +93,6 @@ export declare class Mesh extends ReadyResource {
|
|
|
93
93
|
private readonly _writerSeed;
|
|
94
94
|
private readonly _log;
|
|
95
95
|
private readonly _blindPeerKeys;
|
|
96
|
-
private readonly _blindPeeringOpts;
|
|
97
96
|
private readonly _bootFrom;
|
|
98
97
|
private readonly _wakeup;
|
|
99
98
|
readonly attachmentUrl: AttachmentUrl | null;
|
|
@@ -104,6 +103,9 @@ export declare class Mesh extends ReadyResource {
|
|
|
104
103
|
private readonly _deviceKeyPair;
|
|
105
104
|
private readonly _encryptionKey;
|
|
106
105
|
private _blindPeering;
|
|
106
|
+
private _openedAt;
|
|
107
|
+
private readonly _trustedDevice;
|
|
108
|
+
private _joined;
|
|
107
109
|
private _orphanedBlobSweepStatus;
|
|
108
110
|
private _bootInterrupted;
|
|
109
111
|
private _localWriterUploadedLength;
|
|
@@ -144,8 +146,14 @@ export declare class Mesh extends ReadyResource {
|
|
|
144
146
|
attestDevice(deviceId: Buffer): DeviceAttestation;
|
|
145
147
|
constructor(store: Corestore, opts?: MeshOptions);
|
|
146
148
|
_open(): Promise<void>;
|
|
147
|
-
startBlindPeering(
|
|
148
|
-
stopBlindPeering():
|
|
149
|
+
startBlindPeering(peering: BlindPeering): void;
|
|
150
|
+
stopBlindPeering(): void;
|
|
151
|
+
get bootFrom(): number | null;
|
|
152
|
+
get writerCount(): number;
|
|
153
|
+
get uptimeMs(): number;
|
|
154
|
+
blindPeersConnected(): number;
|
|
155
|
+
private _sinceOpen;
|
|
156
|
+
private _lengths;
|
|
149
157
|
openBlobs(coreKey: Buffer): Promise<Hyperblobs>;
|
|
150
158
|
interruptBoot(): void;
|
|
151
159
|
_close(): Promise<void>;
|
|
@@ -166,25 +174,30 @@ export declare class Mesh extends ReadyResource {
|
|
|
166
174
|
batch(): MeshBatch;
|
|
167
175
|
appendBirthOp(identity: Buffer | KeyPair, device?: DeviceMetadata, opts?: BirthOptions | (() => Promise<BirthOptions>)): Promise<void>;
|
|
168
176
|
private _settleBirth;
|
|
177
|
+
get joined(): boolean;
|
|
169
178
|
private _appendBirthOp;
|
|
170
179
|
get interrupted(): unknown;
|
|
171
180
|
throwIfInterrupted(): void;
|
|
172
181
|
waitForWritable(timeout?: number): Promise<void>;
|
|
173
182
|
pendingUploads(): number;
|
|
174
183
|
suspend(): Promise<void>;
|
|
175
|
-
resume():
|
|
176
|
-
syncChatOrder: ((chatIds: Set<string>) => Promise<void>) | null;
|
|
184
|
+
resume(): void;
|
|
185
|
+
syncChatOrder: ((chatIds: Set<string> | null) => Promise<void>) | null;
|
|
177
186
|
chatOrderBuilt: Promise<void>;
|
|
178
187
|
watch(listener: () => void): void;
|
|
179
188
|
unwatch(listener: () => void): void;
|
|
180
189
|
_autobeeIsTrusted(key: Buffer, reference: MeshView): Promise<boolean>;
|
|
181
190
|
_autobeeMostRecentTrusted(target: MeshView, reference: MeshView | null): Promise<AutobeeOplogRef | null>;
|
|
191
|
+
private _vouchedByItsRow;
|
|
182
192
|
_autobeeOpen(bee: unknown): MeshView;
|
|
183
193
|
_autobeeWarmup(view: MeshView): Promise<void>;
|
|
184
194
|
_autobeeApply(nodes: ReadonlyArray<AutobeeNode>, view: MeshView, host: AutobeeHost): Promise<void>;
|
|
185
195
|
private _applyNode;
|
|
186
196
|
private _halt;
|
|
187
197
|
_autobeeUpdate(view: MeshView, changes: AutobeeChanges): Promise<void>;
|
|
198
|
+
private _arrive;
|
|
199
|
+
private _readLanding;
|
|
200
|
+
private _prefetchView;
|
|
188
201
|
checkOwnAdmission(): Promise<void>;
|
|
189
202
|
checkResumedRevocation(): Promise<'kicked' | 'left' | null>;
|
|
190
203
|
ownWriterRefused(): Promise<boolean>;
|