@qvac/core 1.0.0-rc.5 → 1.0.0-rc.6
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 +43 -2
- package/README.md +55 -4
- package/dist-lib/lib/api/agents.d.ts +2 -1
- package/dist-lib/lib/api/agents.js +5 -1
- package/dist-lib/lib/api/app-config.d.ts +3 -0
- package/dist-lib/lib/api/app-config.js +20 -0
- package/dist-lib/lib/api/device-routes.d.ts +1 -1
- package/dist-lib/lib/api/device-routes.js +3 -1
- package/dist-lib/lib/api/index.js +2 -1
- package/dist-lib/lib/api/projects.js +3 -4
- package/dist-lib/lib/api/served.d.ts +2 -2
- package/dist-lib/lib/api/served.js +24 -1
- package/dist-lib/lib/assistant/harness.d.ts +3 -0
- package/dist-lib/lib/assistant/history.js +14 -2
- package/dist-lib/lib/assistant/message.d.ts +1 -0
- package/dist-lib/lib/assistant/model-round.d.ts +3 -0
- package/dist-lib/lib/assistant/model-round.js +16 -2
- package/dist-lib/lib/assistant/round-host.d.ts +2 -0
- package/dist-lib/lib/assistant/round-host.js +8 -0
- package/dist-lib/lib/assistant-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +4 -2
- package/dist-lib/lib/assistant.d.ts +11 -1
- package/dist-lib/lib/assistant.js +115 -8
- package/dist-lib/lib/client.js +4 -1
- package/dist-lib/lib/core/agent-copies.js +2 -1
- package/dist-lib/lib/core/agent-hosting.js +9 -4
- package/dist-lib/lib/core/agent.js +2 -1
- package/dist-lib/lib/core/chat-copy.d.ts +1 -0
- package/dist-lib/lib/core/chat-copy.js +13 -2
- package/dist-lib/lib/core/chat.d.ts +0 -1
- package/dist-lib/lib/core/chat.js +0 -3
- package/dist-lib/lib/core/collections.d.ts +7 -7
- package/dist-lib/lib/core/collections.js +7 -7
- package/dist-lib/lib/core/contract/project-device-keys.d.ts +4 -2
- package/dist-lib/lib/core/contract/project-device-keys.js +12 -12
- package/dist-lib/lib/core/contract/project-host-keys.d.ts +5 -3
- package/dist-lib/lib/core/contract/project-host-keys.js +22 -11
- package/dist-lib/lib/core/contract/projects.d.ts +4 -2
- package/dist-lib/lib/core/contract/projects.js +29 -17
- package/dist-lib/lib/core/deleted-agent-runs.d.ts +1 -0
- package/dist-lib/lib/core/deleted-agent-runs.js +22 -11
- package/dist-lib/lib/core/helpers/index.d.ts +1 -1
- package/dist-lib/lib/core/helpers/index.js +2 -2
- package/dist-lib/lib/core/mesh.d.ts +1 -0
- package/dist-lib/lib/core/mesh.js +4 -4
- package/dist-lib/lib/core/project-keys.d.ts +5 -2
- package/dist-lib/lib/core/project-keys.js +15 -6
- package/dist-lib/lib/core/sync/index.js +5 -5
- package/dist-lib/lib/core.d.ts +2 -0
- package/dist-lib/lib/core.js +102 -25
- package/dist-lib/lib/kv-cache-ledger.d.ts +22 -0
- package/dist-lib/lib/kv-cache-ledger.js +72 -0
- package/dist-lib/lib/kv-cache-retention.d.ts +1 -0
- package/dist-lib/lib/kv-cache-retention.js +5 -2
- package/dist-lib/lib/model-memory-cap.d.ts +3 -0
- package/dist-lib/lib/model-memory-cap.js +15 -6
- package/dist-lib/lib/run-replay.d.ts +3 -2
- package/dist-lib/lib/run-replay.js +16 -5
- package/dist-lib/lib/run-transcript.js +1 -1
- package/dist-lib/schema/engine.js +54 -1
- package/dist-lib/schema/qvac.js +62 -1
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/capabilities.d.ts +2 -0
- package/dist-lib/spec/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +253 -3
- package/dist-lib/spec/hyperschema/index.js +253 -3
- package/dist-lib/spec/hyperschema/schema.json +187 -0
- package/dist-lib/spec/hyperschema/types.d.ts +33 -0
- package/dist-lib/spec/mesh/hyperdb/db.json +110 -0
- package/dist-lib/spec/mesh/hyperdb/index.js +498 -2
- package/dist-lib/spec/mesh/hyperdb/messages.js +865 -410
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +244 -3
- package/dist-lib/spec/mesh/hyperschema/index.js +244 -3
- package/dist-lib/spec/mesh/hyperschema/schema.json +155 -0
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +37 -0
- package/package.json +27 -11
- package/tui/README.md +190 -0
- package/tui/app.mjs +8247 -0
- package/tui/boot.mjs +159 -0
- package/tui/index.mjs +89 -0
- package/tui/lib/boot-timing.mjs +41 -0
- package/tui/lib/busy-words.mjs +116 -0
- package/tui/lib/connect-sheet.mjs +350 -0
- package/tui/lib/device-target.mjs +64 -0
- package/tui/lib/export.mjs +194 -0
- package/tui/lib/folders-command.mjs +84 -0
- package/tui/lib/fork-command.mjs +43 -0
- package/tui/lib/knowledge-command.mjs +190 -0
- package/tui/lib/knowledge-import.mjs +153 -0
- package/tui/lib/local-path.mjs +21 -0
- package/tui/lib/move-command.mjs +17 -0
- package/tui/lib/render.mjs +225 -0
- package/tui/lib/save-file.mjs +88 -0
- package/tui/lib/select.mjs +81 -0
- package/tui/lib/selection.mjs +18 -0
- package/tui/lib/setup.mjs +135 -0
- package/tui/lib/sidebar.mjs +63 -0
- package/tui/lib/skill-connect.mjs +145 -0
- package/tui/lib/splash-art.mjs +107 -0
- package/tui/lib/splash.mjs +18 -0
- package/tui/lib/upload-frames.mjs +9 -0
- package/tui/lib/usage.mjs +59 -0
- package/tui/lib/wrap.mjs +143 -0
- package/tui/main.mjs +279 -0
- package/tui/plugins.mjs +158 -0
- package/worker/assistant-sidecar.mjs +1 -0
|
@@ -7,26 +7,35 @@ import { dropMemberHostKeys, dropProjectHostKeys, readProjectHostKey } from './p
|
|
|
7
7
|
import { dropListingDeviceKeys, dropProjectDeviceKeys, readProjectDeviceKey } from './project-device-keys.js';
|
|
8
8
|
import b4a from 'b4a';
|
|
9
9
|
import { SEALED_SEED_BYTES } from '../device-seal.js';
|
|
10
|
-
import { AGENT_USERS, AGENTS, CHAT_GROUPS, DEVICES, MESH_FOUNDERS,
|
|
10
|
+
import { AGENT_USERS, AGENTS, CHAT_GROUPS, DEVICES, MESH_FOUNDERS, PROJECT_DEVICE_SEALS, PROJECT_HOST_SEALS, PROJECT_MEMBER_SEALS, PROJECT_MEMBER_SEALS_BY_MEMBER, PROJECT_MEMBERS, PROJECTS } from '../collections.js';
|
|
11
11
|
export const UNGROUPED = '@qvac/ungrouped';
|
|
12
12
|
export function readProject(tx, id) {
|
|
13
13
|
return tx.get(PROJECTS, { id });
|
|
14
14
|
}
|
|
15
|
-
export function readProjectKey(tx, projectId, memberId) {
|
|
16
|
-
return tx.get(
|
|
15
|
+
export function readProjectKey(tx, { projectId, memberId, sealedBy }) {
|
|
16
|
+
return tx.get(PROJECT_MEMBER_SEALS, { projectId, memberId, sealedBy });
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export function projectKeys(tx, projectId, memberId) {
|
|
19
|
+
const key = memberId ? { projectId, memberId } : { projectId };
|
|
20
|
+
return tx.find(PROJECT_MEMBER_SEALS, { gte: key, lte: key }).toArray();
|
|
21
|
+
}
|
|
22
|
+
function dropSeal(tx, { projectId, memberId, sealedBy }) {
|
|
23
|
+
return tx.delete(PROJECT_MEMBER_SEALS, { projectId, memberId, sealedBy });
|
|
24
|
+
}
|
|
25
|
+
async function dropProjectKeys(tx, projectId, match = () => true) {
|
|
26
|
+
for (const row of (await projectKeys(tx, projectId)).filter(match)) {
|
|
27
|
+
await dropSeal(tx, row);
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
30
|
export async function dropMemberProjectKeys(tx, memberId) {
|
|
25
31
|
const rows = await tx
|
|
26
|
-
.find(
|
|
32
|
+
.find(PROJECT_MEMBER_SEALS_BY_MEMBER, {
|
|
33
|
+
gte: { memberId },
|
|
34
|
+
lte: { memberId }
|
|
35
|
+
})
|
|
27
36
|
.toArray();
|
|
28
37
|
for (const row of rows) {
|
|
29
|
-
await tx
|
|
38
|
+
await dropSeal(tx, row);
|
|
30
39
|
}
|
|
31
40
|
}
|
|
32
41
|
export function listsMember(project, memberId) {
|
|
@@ -132,11 +141,11 @@ async function setProjectListing({ projectId, memberId, removed, removedAt }, co
|
|
|
132
141
|
const listed = memberIds.length === 0 ? await tombstone(next, context) : next;
|
|
133
142
|
await tx.insert(PROJECTS, listed);
|
|
134
143
|
if (removed) {
|
|
135
|
-
await tx
|
|
144
|
+
await dropProjectKeys(tx, projectId, (row) => [row.memberId, row.sealedBy].some((id) => b4a.equals(id, memberId)));
|
|
136
145
|
await dropListingDeviceKeys(tx, projectId, memberId);
|
|
137
146
|
await dropMemberAgentUses(tx, memberId, projectId);
|
|
138
147
|
}
|
|
139
|
-
await dropMemberHostKeys(tx, projectId, memberId);
|
|
148
|
+
await dropMemberHostKeys(tx, { projectId, memberId, removed });
|
|
140
149
|
return listed;
|
|
141
150
|
}
|
|
142
151
|
async function tombstone(project, { tx, node }) {
|
|
@@ -187,17 +196,18 @@ async function putProjectKey(op, context) {
|
|
|
187
196
|
log?.warn('contract', 'put-project-key dropped: not a sealed seed');
|
|
188
197
|
return;
|
|
189
198
|
}
|
|
190
|
-
const held = await readProjectKey(tx, op
|
|
199
|
+
const held = await readProjectKey(tx, { ...op, sealedBy: signer });
|
|
191
200
|
if (held && b4a.equals(held.boxKey, op.boxKey)) {
|
|
192
201
|
return;
|
|
193
202
|
}
|
|
194
203
|
const row = {
|
|
195
204
|
projectId: op.projectId,
|
|
196
205
|
memberId: op.memberId,
|
|
206
|
+
sealedBy: signer,
|
|
197
207
|
boxKey: op.boxKey,
|
|
198
208
|
sealedSeed: op.sealedSeed
|
|
199
209
|
};
|
|
200
|
-
await tx.insert(
|
|
210
|
+
await tx.insert(PROJECT_MEMBER_SEALS, row);
|
|
201
211
|
return row;
|
|
202
212
|
}
|
|
203
213
|
async function putProjectHostKey(op, context) {
|
|
@@ -235,16 +245,17 @@ async function putProjectHostKey(op, context) {
|
|
|
235
245
|
log?.warn('contract', 'put-project-host-key dropped: not a sealed seed');
|
|
236
246
|
return;
|
|
237
247
|
}
|
|
238
|
-
if (await readProjectHostKey(tx, op
|
|
248
|
+
if (await readProjectHostKey(tx, { ...op, sealedBy: signer })) {
|
|
239
249
|
return;
|
|
240
250
|
}
|
|
241
251
|
const row = {
|
|
242
252
|
projectId: op.projectId,
|
|
243
253
|
deviceId: op.deviceId,
|
|
254
|
+
sealedBy: signer,
|
|
244
255
|
agentId: op.agentId,
|
|
245
256
|
sealedSeed: op.sealedSeed
|
|
246
257
|
};
|
|
247
|
-
await tx.insert(
|
|
258
|
+
await tx.insert(PROJECT_HOST_SEALS, row);
|
|
248
259
|
return row;
|
|
249
260
|
}
|
|
250
261
|
async function countedDevice(tx, { memberId, deviceId }) {
|
|
@@ -276,16 +287,17 @@ async function putProjectDeviceKey(op, context) {
|
|
|
276
287
|
log?.warn('contract', 'put-project-device-key dropped: not a sealed seed');
|
|
277
288
|
return;
|
|
278
289
|
}
|
|
279
|
-
if (await readProjectDeviceKey(tx, op
|
|
290
|
+
if (await readProjectDeviceKey(tx, { ...op, sealedBy: signer })) {
|
|
280
291
|
return;
|
|
281
292
|
}
|
|
282
293
|
const row = {
|
|
283
294
|
projectId: op.projectId,
|
|
284
295
|
deviceId: op.deviceId,
|
|
296
|
+
sealedBy: signer,
|
|
285
297
|
memberId: op.memberId,
|
|
286
298
|
sealedSeed: op.sealedSeed
|
|
287
299
|
};
|
|
288
|
-
await tx.insert(
|
|
300
|
+
await tx.insert(PROJECT_DEVICE_SEALS, row);
|
|
289
301
|
return row;
|
|
290
302
|
}
|
|
291
303
|
async function putProjectMember({ memberId, addedAt }, context) {
|
|
@@ -5,3 +5,4 @@ export interface LandedRuns {
|
|
|
5
5
|
readonly deletedAgents: Set<string>;
|
|
6
6
|
}
|
|
7
7
|
export declare function cancelDeletedAgentRuns(mesh: Mesh, deviceId: Buffer, landed: LandedRuns | null): Promise<void>;
|
|
8
|
+
export declare function cancelRunsForAgent(mesh: Mesh, deviceId: Buffer, agentId: string): Promise<void>;
|
|
@@ -9,26 +9,37 @@ export async function cancelDeletedAgentRuns(mesh, deviceId, landed) {
|
|
|
9
9
|
const requests = landed && landed.deletedAgents.size === 0
|
|
10
10
|
? landed.requests
|
|
11
11
|
: await mesh.view.find(RUN_REQUESTS).toArray();
|
|
12
|
-
const
|
|
13
|
-
for (const
|
|
14
|
-
const asked = runId && deleted.has(runRequest?.agentId ?? '');
|
|
15
|
-
if (asked && !(await runHasTerminalStatus(mesh.view, chatId, runId))) {
|
|
16
|
-
chats.add(chatId);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
for (const chatId of chats) {
|
|
12
|
+
const asking = await openRunsOf(mesh, requests, deleted);
|
|
13
|
+
for (const [chatId, agentIds] of asking) {
|
|
20
14
|
if (mesh.closing || !mesh.writable)
|
|
21
15
|
return;
|
|
22
16
|
const chat = await mesh.view.get(CHATS, { id: chatId });
|
|
23
|
-
if (chat
|
|
17
|
+
if (!chat || chat.deletedAt) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
for (const agentId of agentIds) {
|
|
24
21
|
await cancelActiveRuns(mesh, chatId, {
|
|
25
22
|
deviceId,
|
|
26
|
-
agentId
|
|
27
|
-
reason: AGENT_DELETED
|
|
23
|
+
agentId,
|
|
24
|
+
reason: AGENT_DELETED,
|
|
25
|
+
queuedOnly: !deleted.has(chat.agentId)
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
}
|
|
30
|
+
export function cancelRunsForAgent(mesh, deviceId, agentId) {
|
|
31
|
+
return cancelDeletedAgentRuns(mesh, deviceId, { requests: [], deletedAgents: new Set([agentId]) });
|
|
32
|
+
}
|
|
33
|
+
async function openRunsOf(mesh, requests, deleted) {
|
|
34
|
+
const asking = new Map();
|
|
35
|
+
for (const { chatId, runId, runRequest } of requests) {
|
|
36
|
+
const agentId = runRequest?.agentId ?? '';
|
|
37
|
+
if (runId && deleted.has(agentId) && !(await runHasTerminalStatus(mesh.view, chatId, runId))) {
|
|
38
|
+
asking.set(chatId, (asking.get(chatId) ?? new Set()).add(agentId));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return asking;
|
|
42
|
+
}
|
|
32
43
|
async function deletedOf(mesh, { requests, deletedAgents }) {
|
|
33
44
|
const deleted = new Set(deletedAgents);
|
|
34
45
|
const asked = new Set(requests.map((r) => r.runRequest?.agentId).filter((id) => !!id));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { QvacDevice, QvacSeedDefaultsOperation } from '../../../spec/mesh/hyperschema/types.d.ts';
|
|
2
2
|
import type { Mesh } from '../mesh.ts';
|
|
3
3
|
export declare const DEFAULT_AGENT_NAME = "QV.AC";
|
|
4
|
-
export declare function buildDefaultSeed(device: Pick<QvacDevice, 'id' | 'recommendedModelName'>, blindPeerKeys: ReadonlyArray<Buffer
|
|
4
|
+
export declare function buildDefaultSeed(device: Pick<QvacDevice, 'id' | 'recommendedModelName'>, blindPeerKeys: ReadonlyArray<Buffer>, modelName?: string): QvacSeedDefaultsOperation;
|
|
5
5
|
export declare function isOwnRevokedRow(mesh: Mesh, device: QvacDevice): boolean;
|
|
6
6
|
export declare function isKickedRow(device: QvacDevice): boolean;
|
|
7
7
|
export declare function isOwnKickedRow(mesh: Mesh, device: QvacDevice): boolean;
|
|
@@ -33,7 +33,7 @@ function seedableChat(chat) {
|
|
|
33
33
|
updatedAt: chat.updatedAt
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
export function buildDefaultSeed(device, blindPeerKeys) {
|
|
36
|
+
export function buildDefaultSeed(device, blindPeerKeys, modelName = device.recommendedModelName) {
|
|
37
37
|
const now = Date.now();
|
|
38
38
|
const agentId = randomId();
|
|
39
39
|
return {
|
|
@@ -42,7 +42,7 @@ export function buildDefaultSeed(device, blindPeerKeys) {
|
|
|
42
42
|
name: DEFAULT_AGENT_NAME,
|
|
43
43
|
bio: DEFAULT_AGENT_BIO,
|
|
44
44
|
providerDeviceId: device.id,
|
|
45
|
-
modelName
|
|
45
|
+
modelName,
|
|
46
46
|
reasoning: 'inherit',
|
|
47
47
|
enabledSkills: [],
|
|
48
48
|
enabledTools: [],
|
|
@@ -686,7 +686,7 @@ export class Mesh extends ReadyResource {
|
|
|
686
686
|
get joined() {
|
|
687
687
|
return this._joined;
|
|
688
688
|
}
|
|
689
|
-
async _appendBirthOp(identity, device, { member, sharing = false, defaults = true, workspace, project } = {}) {
|
|
689
|
+
async _appendBirthOp(identity, device, { member, sharing = false, defaults = true, modelName, workspace, project } = {}) {
|
|
690
690
|
if (this.autobee.local.length > 0)
|
|
691
691
|
return;
|
|
692
692
|
const { publicKey: deviceId, secretKey } = 'secretKey' in identity ? identity : { publicKey: identity, secretKey: null };
|
|
@@ -722,7 +722,7 @@ export class Mesh extends ReadyResource {
|
|
|
722
722
|
birth.dispatch('name-mesh', { name: project.name, namedAt: row.joinedAt });
|
|
723
723
|
}
|
|
724
724
|
if (!sharing) {
|
|
725
|
-
this._seedDefaults(birth, row, defaults);
|
|
725
|
+
this._seedDefaults(birth, row, { defaults, modelName });
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
728
|
await birth.flush();
|
|
@@ -749,7 +749,7 @@ export class Mesh extends ReadyResource {
|
|
|
749
749
|
}
|
|
750
750
|
return this._role === 'workspace' || this._role === 'public' ? this._role : 'shared';
|
|
751
751
|
}
|
|
752
|
-
_seedDefaults(birth, row, defaults) {
|
|
752
|
+
_seedDefaults(birth, row, { defaults, modelName }) {
|
|
753
753
|
if (!inRole(this._role, '@qvac/seed-defaults')) {
|
|
754
754
|
for (const key of this._blindPeerKeys) {
|
|
755
755
|
birth.dispatch('put-mesh-blind-peer', { key });
|
|
@@ -760,7 +760,7 @@ export class Mesh extends ReadyResource {
|
|
|
760
760
|
return;
|
|
761
761
|
}
|
|
762
762
|
const peers = inRole(this._role, '@qvac/put-mesh-blind-peer') ? this._blindPeerKeys : [];
|
|
763
|
-
birth.dispatch('seed-defaults', buildDefaultSeed(row, peers));
|
|
763
|
+
birth.dispatch('seed-defaults', buildDefaultSeed(row, peers, modelName));
|
|
764
764
|
birth.dispatch('put-agent', { agent: buildHealthAssistant(row) });
|
|
765
765
|
}
|
|
766
766
|
get interrupted() {
|
|
@@ -3,11 +3,14 @@ import type { QvacAgent, QvacProject, QvacProjectDeviceKey, QvacProjectHostKey,
|
|
|
3
3
|
export interface ProjectSeed {
|
|
4
4
|
readonly projectId: Buffer;
|
|
5
5
|
readonly seed: Buffer;
|
|
6
|
+
readonly sealedBy: Buffer;
|
|
6
7
|
}
|
|
7
8
|
export interface ProjectHostSeed extends ProjectSeed {
|
|
8
9
|
readonly project: HyperDB;
|
|
9
10
|
readonly picking?: boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare function
|
|
12
|
+
export declare function seedFingerprint(seed: Buffer): Buffer;
|
|
13
|
+
export declare function seedOpens(project: QvacProject, seed: Buffer): boolean;
|
|
14
|
+
export declare function dueProjectKey(view: HyperDB, memberId: Buffer, { projectId, seed, sealedBy }: ProjectSeed): Promise<QvacProjectKey | null>;
|
|
12
15
|
export declare function dueProjectHostKey(view: HyperDB, agent: QvacAgent, seal: ProjectHostSeed): Promise<QvacProjectHostKey | null>;
|
|
13
|
-
export declare function dueProjectDeviceKeys(view: HyperDB, row: QvacProject, seed:
|
|
16
|
+
export declare function dueProjectDeviceKeys(view: HyperDB, row: QvacProject, { seed, sealedBy }: Omit<ProjectSeed, 'projectId'>): Promise<QvacProjectDeviceKey[]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
+
import crypto from 'hypercore-crypto';
|
|
2
3
|
import { AGENT_USERS, AGENTS, DEVICES } from './collections.js';
|
|
3
4
|
import { readProjectHostKey } from './contract/project-host-keys.js';
|
|
4
5
|
import { readProjectDeviceKey } from './contract/project-device-keys.js';
|
|
@@ -6,9 +7,16 @@ import { listsMember, readProject, readProjectKey } from './contract/projects.js
|
|
|
6
7
|
import { readMemberKey, upgradeMembers } from './contract/workspace.js';
|
|
7
8
|
import { sealToDevice } from './device-seal.js';
|
|
8
9
|
import { sealToMember } from './member-key.js';
|
|
9
|
-
|
|
10
|
+
const [SEED_FINGERPRINT] = crypto.namespace('qvac-assistant/seed-fingerprint', 1);
|
|
11
|
+
export function seedFingerprint(seed) {
|
|
12
|
+
return crypto.hash([SEED_FINGERPRINT, seed]);
|
|
13
|
+
}
|
|
14
|
+
export function seedOpens(project, seed) {
|
|
15
|
+
return !project.seedFingerprint || b4a.equals(seedFingerprint(seed), project.seedFingerprint);
|
|
16
|
+
}
|
|
17
|
+
export async function dueProjectKey(view, memberId, { projectId, seed, sealedBy }) {
|
|
10
18
|
const key = await readMemberKey(view, memberId);
|
|
11
|
-
const held = key && (await readProjectKey(view, projectId, memberId));
|
|
19
|
+
const held = key && (await readProjectKey(view, { projectId, memberId, sealedBy }));
|
|
12
20
|
if (!key || (held && b4a.equals(held.boxKey, key.boxKey))) {
|
|
13
21
|
return null;
|
|
14
22
|
}
|
|
@@ -22,7 +30,7 @@ async function usedBy(view, agent, seal) {
|
|
|
22
30
|
return (!!seal.picking || !!(await view.get(AGENT_USERS, { agentId: agent.id, userId: seal.projectId })));
|
|
23
31
|
}
|
|
24
32
|
export async function dueProjectHostKey(view, agent, seal) {
|
|
25
|
-
const { projectId, seed, project } = seal;
|
|
33
|
+
const { projectId, seed, project, sealedBy } = seal;
|
|
26
34
|
const deviceId = agent.providerDeviceId;
|
|
27
35
|
const row = await readProject(view, projectId);
|
|
28
36
|
const host = await view.get(DEVICES, { id: deviceId });
|
|
@@ -34,12 +42,12 @@ export async function dueProjectHostKey(view, agent, seal) {
|
|
|
34
42
|
if (!(await usedBy(view, agent, seal))) {
|
|
35
43
|
return null;
|
|
36
44
|
}
|
|
37
|
-
if (await readProjectHostKey(view, projectId, deviceId)) {
|
|
45
|
+
if (await readProjectHostKey(view, { projectId, deviceId, sealedBy })) {
|
|
38
46
|
return null;
|
|
39
47
|
}
|
|
40
48
|
return { projectId, deviceId, agentId: agent.id, sealedSeed: sealToDevice(seed, deviceId) };
|
|
41
49
|
}
|
|
42
|
-
export async function dueProjectDeviceKeys(view, row, seed) {
|
|
50
|
+
export async function dueProjectDeviceKeys(view, row, { seed, sealedBy }) {
|
|
43
51
|
if (!row.groupId) {
|
|
44
52
|
return [];
|
|
45
53
|
}
|
|
@@ -47,7 +55,8 @@ export async function dueProjectDeviceKeys(view, row, seed) {
|
|
|
47
55
|
const due = [];
|
|
48
56
|
for await (const { id, memberId, revoked } of view.find(DEVICES)) {
|
|
49
57
|
const listed = memberId && counted.some((member) => b4a.equals(member, memberId));
|
|
50
|
-
|
|
58
|
+
const slot = { projectId: row.id, deviceId: id, sealedBy };
|
|
59
|
+
if (!memberId || !listed || revoked || (await readProjectDeviceKey(view, slot))) {
|
|
51
60
|
continue;
|
|
52
61
|
}
|
|
53
62
|
due.push({ projectId: row.id, deviceId: id, memberId, sealedSeed: sealToDevice(seed, id) });
|
|
@@ -3,7 +3,7 @@ import { FileChanges } from './files.js';
|
|
|
3
3
|
import { syncDeviceRevocation, syncOwnMember } from './devices.js';
|
|
4
4
|
import { syncChatTombstone } from './chats.js';
|
|
5
5
|
import { syncNotificationChunk } from './chunks.js';
|
|
6
|
-
import { AGENT_HOSTS, AGENT_USERS, AGENTS, CHATS, CHAT_GROUPS, CHUNKS, CHUNK_COUNTERS, DEVICES, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, MEMBER_KEYS, MEMBERS, MESH_NAMES, MESH_RULES, MESH_SEEDS,
|
|
6
|
+
import { AGENT_HOSTS, AGENT_USERS, AGENTS, CHATS, CHAT_GROUPS, CHUNKS, CHUNK_COUNTERS, DEVICES, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, MEMBER_KEYS, MEMBERS, MESH_NAMES, MESH_RULES, MESH_SEEDS, PROJECT_DEVICE_SEALS, PROJECT_HOST_SEALS, PROJECT_MEMBER_SEALS, PROJECTS, PUBLIC_MESHES, PUBLIC_SEEDS, PURGED_CHATS, SKILL_SECRETS, WORKSPACE } from '../collections.js';
|
|
7
7
|
export async function syncChanges(mesh, view, from) {
|
|
8
8
|
if (mesh.closing)
|
|
9
9
|
return null;
|
|
@@ -125,7 +125,7 @@ async function walkChanges(mesh, { snap, from, files, pass }) {
|
|
|
125
125
|
await files.add(change);
|
|
126
126
|
if (HOSTING.has(change.collection)) {
|
|
127
127
|
pass.agentsDirty = true;
|
|
128
|
-
pass.meshesChanged ||= change.collection ===
|
|
128
|
+
pass.meshesChanged ||= change.collection === PROJECT_HOST_SEALS;
|
|
129
129
|
continue;
|
|
130
130
|
}
|
|
131
131
|
if (change.type === 'delete') {
|
|
@@ -189,7 +189,7 @@ async function walkChanges(mesh, { snap, from, files, pass }) {
|
|
|
189
189
|
const HOSTING = new Set([
|
|
190
190
|
AGENT_USERS,
|
|
191
191
|
PUBLIC_SEEDS,
|
|
192
|
-
|
|
192
|
+
PROJECT_HOST_SEALS,
|
|
193
193
|
AGENT_HOSTS
|
|
194
194
|
]);
|
|
195
195
|
const FOLLOWED = new Set([
|
|
@@ -197,7 +197,7 @@ const FOLLOWED = new Set([
|
|
|
197
197
|
MESH_SEEDS,
|
|
198
198
|
PUBLIC_MESHES,
|
|
199
199
|
PROJECTS,
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
PROJECT_MEMBER_SEALS,
|
|
201
|
+
PROJECT_DEVICE_SEALS,
|
|
202
202
|
MEMBER_KEYS
|
|
203
203
|
]);
|
package/dist-lib/lib/core.d.ts
CHANGED
|
@@ -359,6 +359,7 @@ export declare class Core extends ReadyResource {
|
|
|
359
359
|
private _holdIdentityPhrase;
|
|
360
360
|
private _pushIdentityPhrase;
|
|
361
361
|
private _offerIdentityPhrase;
|
|
362
|
+
private _skillOauth;
|
|
362
363
|
private _startBlindPeering;
|
|
363
364
|
setBlindPeering(enabled: boolean): Promise<AssistantBlindPeering>;
|
|
364
365
|
private _peeredMeshes;
|
|
@@ -473,6 +474,7 @@ export declare class Core extends ReadyResource {
|
|
|
473
474
|
private _listenMesh;
|
|
474
475
|
private _wireForeign;
|
|
475
476
|
private _adoptAccount;
|
|
477
|
+
private _backfillModelPick;
|
|
476
478
|
private _publicMesh;
|
|
477
479
|
private _publicIdOf;
|
|
478
480
|
private _workspaceOfPublic;
|
package/dist-lib/lib/core.js
CHANGED
|
@@ -14,7 +14,7 @@ import ReadyResource from 'ready-resource';
|
|
|
14
14
|
import ScopeLock from 'scope-lock';
|
|
15
15
|
import { isAndroid } from 'which-runtime';
|
|
16
16
|
import { createApi } from './api/index.js';
|
|
17
|
-
import { writeAutoDownloadModels } from './api/app-config.js';
|
|
17
|
+
import { backfillLastModelName, readLastModelName, writeAutoDownloadModels } from './api/app-config.js';
|
|
18
18
|
import { requireOurAdmin, requireWorkspace } from './api/members.js';
|
|
19
19
|
import { projectName } from './api/projects.js';
|
|
20
20
|
import { createServedApi } from './api/served.js';
|
|
@@ -25,7 +25,7 @@ import { openSealedToDevice, sealToDevice } from './core/device-seal.js';
|
|
|
25
25
|
import { removedBy } from './core/contract/invites.js';
|
|
26
26
|
import { meshKind } from './core/contract/mesh-kind.js';
|
|
27
27
|
import { WORKSPACES_RULES, bornUnderRules, rulesVersion } from './core/contract/mesh-rules.js';
|
|
28
|
-
import { inProject, listedProject, listsMember, liveMember, projectMember, projectOfGroup,
|
|
28
|
+
import { inProject, listedProject, listsMember, liveMember, projectMember, projectOfGroup, projectKeys, readProject, UNGROUPED } from './core/contract/projects.js';
|
|
29
29
|
import { requireMesh } from './api/current-mesh.js';
|
|
30
30
|
import { CoreError } from './errors.js';
|
|
31
31
|
import { ChatMoves } from './core/chat-move.js';
|
|
@@ -34,12 +34,12 @@ import { copyContent } from './core/chat-copy.js';
|
|
|
34
34
|
import { followAgentCopies, keepCopyChats } from './core/agent-copies.js';
|
|
35
35
|
import { cancelDeletedAgentRuns } from './core/deleted-agent-runs.js';
|
|
36
36
|
import { devicesOfMember } from './core/contract/activity.js';
|
|
37
|
-
import { followPickedAgents, followSharedAgents, liveSharedAgent, pickAgent, shareAgent, unpickAgent } from './core/shared-agents.js';
|
|
37
|
+
import { followPickedAgents, followSharedAgents, ownerOf, liveSharedAgent, pickAgent, shareAgent, unpickAgent } from './core/shared-agents.js';
|
|
38
38
|
import { inRole, publicRoute } from './core/contract/roles.js';
|
|
39
39
|
import { freshPublicRecord, isOwnWorkspace, isPublicRecord, lostMint, onOwnSeed, leftPublicRecordKey, ownWorkspaceSeed, ownWorkspaces, publicMeshKey, publicRecordKey, publicSeed, servesAgents, servesChat, servesChunk } from './core/public-mesh.js';
|
|
40
40
|
import { memberBoxKeyPair, openSealedToMember } from './core/member-key.js';
|
|
41
|
-
import { dueProjectDeviceKeys, dueProjectHostKey, dueProjectKey } from './core/project-keys.js';
|
|
42
|
-
import {
|
|
41
|
+
import { dueProjectDeviceKeys, dueProjectHostKey, dueProjectKey, seedFingerprint, seedOpens } from './core/project-keys.js';
|
|
42
|
+
import { projectDeviceKeys } from './core/contract/project-device-keys.js';
|
|
43
43
|
import { agentJoin, freshHostRecord, hostRecordKey, hostState, hostTargets, isHostRecord } from './core/agent-hosting.js';
|
|
44
44
|
import { hostForWriter } from './core/contract/model-requests.js';
|
|
45
45
|
import { asEncoded, watchModels } from './models-watch.js';
|
|
@@ -56,7 +56,8 @@ import { backgroundSyncKey } from './core/local/files.js';
|
|
|
56
56
|
import { FOLD_PENDING, GROUPS_PENDING, agentsFoldKey, groupBuckets, groupRecordKey, isGroupRecord, liveGroups, projectsByGroup, upgradeCheckedKey } from './core/workspace-upgrade.js';
|
|
57
57
|
import { foldAgents, ownCopies } from './core/upgrade-agents.js';
|
|
58
58
|
import { MAX_MESH_NAME_CHARS, meshNameWithinBounds } from '../schema/qvac.js';
|
|
59
|
-
import { rehomeAgents } from './core/agent.js';
|
|
59
|
+
import { getDefaultAgent, mustGetActiveAgent, rehomeAgents } from './core/agent.js';
|
|
60
|
+
import { pickRunner } from './core/run-requests.js';
|
|
60
61
|
import { countContents, migrateContents, withArchivedMesh } from './core/archived-mesh.js';
|
|
61
62
|
import { isMobilePlatform } from '@qvac/harness/lib/models/model-catalog.ts';
|
|
62
63
|
import { storeSkillSecret, syncSkillSecrets } from './core/skill-secrets.js';
|
|
@@ -658,6 +659,7 @@ export class Core extends ReadyResource {
|
|
|
658
659
|
})
|
|
659
660
|
: null
|
|
660
661
|
});
|
|
662
|
+
api.skillOauth = (request) => this._skillOauth(request);
|
|
661
663
|
this._servedToSiblings = servedToSiblings(api);
|
|
662
664
|
this._api = {
|
|
663
665
|
...api,
|
|
@@ -686,6 +688,7 @@ export class Core extends ReadyResource {
|
|
|
686
688
|
const rpc = settleOnClose(new HRPC(this._stream));
|
|
687
689
|
bindApi(rpc, this._api);
|
|
688
690
|
this._rpcs.add(rpc);
|
|
691
|
+
this._stream.on('close', () => this._rpcs.delete(rpc));
|
|
689
692
|
this._offlineBoot.exit();
|
|
690
693
|
void this._pushIdentityPhrase();
|
|
691
694
|
this._chatMoves
|
|
@@ -1297,6 +1300,7 @@ export class Core extends ReadyResource {
|
|
|
1297
1300
|
await mesh.appendBirthOp(this._requireDeviceKeyPair(), this._localDevice ?? undefined, {
|
|
1298
1301
|
member: birth?.member,
|
|
1299
1302
|
sharing,
|
|
1303
|
+
modelName: (await readLastModelName(this.local)) ?? undefined,
|
|
1300
1304
|
workspace,
|
|
1301
1305
|
project
|
|
1302
1306
|
});
|
|
@@ -1696,6 +1700,44 @@ export class Core extends ReadyResource {
|
|
|
1696
1700
|
return false;
|
|
1697
1701
|
}
|
|
1698
1702
|
}
|
|
1703
|
+
async _skillOauth(request) {
|
|
1704
|
+
const account = this._accountMesh();
|
|
1705
|
+
if (!account) {
|
|
1706
|
+
throw new CoreError('MESH_NOT_FOUND', ['account']);
|
|
1707
|
+
}
|
|
1708
|
+
const deviceId = this._requireDeviceKeyPair().publicKey;
|
|
1709
|
+
if (request.operation === 'target' && !isMobilePlatform(this._localDevice?.platform ?? '')) {
|
|
1710
|
+
return { phase: 'local', deviceId };
|
|
1711
|
+
}
|
|
1712
|
+
const agent = await mustGetActiveAgent(account, request.agentId);
|
|
1713
|
+
const owner = await ownerOf(account, agent);
|
|
1714
|
+
if (!owner || !account.ourMemberId || !b4a.equals(owner, account.ourMemberId)) {
|
|
1715
|
+
throw new CoreError('AGENT_NOT_OURS');
|
|
1716
|
+
}
|
|
1717
|
+
if (request.operation === 'target') {
|
|
1718
|
+
const mesh = await requireMesh(this._meshPool(), request.meshId ?? this._meshIdOf(account), {
|
|
1719
|
+
route: 'put-chat'
|
|
1720
|
+
});
|
|
1721
|
+
const runner = await pickRunner(mesh, {
|
|
1722
|
+
deviceId,
|
|
1723
|
+
peers: this.peerDeviceIds,
|
|
1724
|
+
agent
|
|
1725
|
+
});
|
|
1726
|
+
return { phase: runner ? 'ready' : 'local', deviceId: runner ?? deviceId };
|
|
1727
|
+
}
|
|
1728
|
+
for (const rpc of this._rpcs) {
|
|
1729
|
+
const response = await rpc.skillOauth(request);
|
|
1730
|
+
if (response.phase === 'unavailable') {
|
|
1731
|
+
continue;
|
|
1732
|
+
}
|
|
1733
|
+
if ((request.operation !== 'config' && response.phase === 'connected') ||
|
|
1734
|
+
(request.operation === 'disconnect' && response.phase === 'ready')) {
|
|
1735
|
+
await this._skillCatalog?.(request.agentId, null, { refresh: true });
|
|
1736
|
+
}
|
|
1737
|
+
return response;
|
|
1738
|
+
}
|
|
1739
|
+
throw new CoreError('DEVICE_ROUTE_NOT_SERVED', ['skillOauth']);
|
|
1740
|
+
}
|
|
1699
1741
|
_startBlindPeering(mesh) {
|
|
1700
1742
|
const peering = this._blindPeeringClient();
|
|
1701
1743
|
if (peering) {
|
|
@@ -2998,7 +3040,7 @@ export class Core extends ReadyResource {
|
|
|
2998
3040
|
}
|
|
2999
3041
|
async _copyGroup(workspace, project, { chats }) {
|
|
3000
3042
|
const deviceId = this._requireDeviceKeyPair().publicKey;
|
|
3001
|
-
await copyContent({ from: workspace, into: project, deviceId, chats });
|
|
3043
|
+
await copyContent({ from: workspace, into: project, deviceId, chats, endsOpenRuns: true });
|
|
3002
3044
|
}
|
|
3003
3045
|
async _addWorkspaceMembers(workspace, project) {
|
|
3004
3046
|
for (const memberId of await this._workspaceMembers(workspace)) {
|
|
@@ -3537,6 +3579,16 @@ export class Core extends ReadyResource {
|
|
|
3537
3579
|
this._notifyStatus();
|
|
3538
3580
|
void this._followPublicMesh(mesh);
|
|
3539
3581
|
void this._followSkillSecrets();
|
|
3582
|
+
void this._backfillModelPick(mesh);
|
|
3583
|
+
}
|
|
3584
|
+
async _backfillModelPick(mesh) {
|
|
3585
|
+
const deviceId = this._requireDeviceKeyPair().publicKey;
|
|
3586
|
+
try {
|
|
3587
|
+
await backfillLastModelName(this.local, async () => (await getDefaultAgent(mesh, deviceId))?.modelName ?? null);
|
|
3588
|
+
}
|
|
3589
|
+
catch (err) {
|
|
3590
|
+
this._log?.warn(['mesh'], 'backfilling the model pick failed', err);
|
|
3591
|
+
}
|
|
3540
3592
|
}
|
|
3541
3593
|
_publicMesh(workspaceId = this._accountId) {
|
|
3542
3594
|
return this._pooled(this._publicIdOf(workspaceId));
|
|
@@ -3583,8 +3635,9 @@ export class Core extends ReadyResource {
|
|
|
3583
3635
|
}
|
|
3584
3636
|
async _shareProjectSeed(batch, { workspace, project, agent, picking }) {
|
|
3585
3637
|
const projectId = project.key;
|
|
3586
|
-
const
|
|
3587
|
-
const
|
|
3638
|
+
const sealedBy = workspace.ourMemberId;
|
|
3639
|
+
const seed = sealedBy && (await this._heldProjectSeed(workspace, projectId));
|
|
3640
|
+
const sealing = seed && { projectId, seed, project: project.view, sealedBy, picking };
|
|
3588
3641
|
const due = sealing && (await dueProjectHostKey(workspace.view, agent, sealing));
|
|
3589
3642
|
if (due) {
|
|
3590
3643
|
batch.dispatch('put-project-host-key', due);
|
|
@@ -4069,7 +4122,12 @@ export class Core extends ReadyResource {
|
|
|
4069
4122
|
if (!this._isAccount(account) || !this._isPooled(into)) {
|
|
4070
4123
|
return;
|
|
4071
4124
|
}
|
|
4072
|
-
await copyContent({
|
|
4125
|
+
await copyContent({
|
|
4126
|
+
from: account,
|
|
4127
|
+
into,
|
|
4128
|
+
deviceId: this._requireDeviceKeyPair().publicKey,
|
|
4129
|
+
endsOpenRuns: true
|
|
4130
|
+
});
|
|
4073
4131
|
const latest = (await this._publicRecord(account, workspaceKey)) ?? record;
|
|
4074
4132
|
await this._savePublicRecord(account, workspaceKey, { ...latest, migrated: true });
|
|
4075
4133
|
this._log?.info(['p2p', 'mesh'], 'copied the account into its public mesh', {
|
|
@@ -5255,11 +5313,11 @@ export class Core extends ReadyResource {
|
|
|
5255
5313
|
}
|
|
5256
5314
|
async _listProject(workspace, project, listing) {
|
|
5257
5315
|
const batch = workspace.batch();
|
|
5258
|
-
|
|
5316
|
+
const listed = { id: project.key, ...listing, seedFingerprint: seedFingerprint(project.seed) };
|
|
5317
|
+
batch.dispatch('put-project', { project: listed });
|
|
5259
5318
|
const ours = workspace.ourMemberId;
|
|
5260
|
-
const
|
|
5261
|
-
|
|
5262
|
-
: null;
|
|
5319
|
+
const sealing = ours && { projectId: project.key, seed: project.seed, sealedBy: ours };
|
|
5320
|
+
const own = sealing ? await dueProjectKey(workspace.view, ours, sealing) : null;
|
|
5263
5321
|
if (own) {
|
|
5264
5322
|
batch.dispatch('put-project-key', own);
|
|
5265
5323
|
}
|
|
@@ -6310,27 +6368,36 @@ export class Core extends ReadyResource {
|
|
|
6310
6368
|
}
|
|
6311
6369
|
}
|
|
6312
6370
|
async _sealListedMembers(workspace, row, seed) {
|
|
6371
|
+
const sealedBy = workspace.ourMemberId;
|
|
6372
|
+
if (!sealedBy) {
|
|
6373
|
+
return;
|
|
6374
|
+
}
|
|
6313
6375
|
const batch = workspace.batch();
|
|
6314
6376
|
for (const memberId of row.memberIds ?? []) {
|
|
6315
|
-
const due = await dueProjectKey(workspace.view, memberId, {
|
|
6377
|
+
const due = await dueProjectKey(workspace.view, memberId, {
|
|
6378
|
+
projectId: row.id,
|
|
6379
|
+
seed,
|
|
6380
|
+
sealedBy
|
|
6381
|
+
});
|
|
6316
6382
|
if (due) {
|
|
6317
6383
|
batch.dispatch('put-project-key', due);
|
|
6318
6384
|
}
|
|
6319
6385
|
}
|
|
6320
|
-
for (const due of await dueProjectDeviceKeys(workspace.view, row, seed)) {
|
|
6386
|
+
for (const due of await dueProjectDeviceKeys(workspace.view, row, { seed, sealedBy })) {
|
|
6321
6387
|
batch.dispatch('put-project-device-key', due);
|
|
6322
6388
|
}
|
|
6323
6389
|
await batch.flush();
|
|
6324
6390
|
}
|
|
6325
6391
|
async _sealProjectHosts(workspace, projectId, seed) {
|
|
6326
6392
|
const project = this._pooled(b4a.toHex(projectId));
|
|
6327
|
-
|
|
6393
|
+
const sealedBy = workspace.ourMemberId;
|
|
6394
|
+
if (!project || this._isForeign(project) || !sealedBy) {
|
|
6328
6395
|
return;
|
|
6329
6396
|
}
|
|
6330
6397
|
const batch = workspace.batch();
|
|
6331
6398
|
for (const user of await workspace.view.find(AGENT_USERS).toArray()) {
|
|
6332
6399
|
const agent = b4a.equals(user.userId, projectId) && (await liveSharedAgent(workspace, user.agentId));
|
|
6333
|
-
const sealing = { projectId, seed, project: project.view };
|
|
6400
|
+
const sealing = { projectId, seed, project: project.view, sealedBy };
|
|
6334
6401
|
const due = agent && (await dueProjectHostKey(workspace.view, agent, sealing));
|
|
6335
6402
|
if (due) {
|
|
6336
6403
|
batch.dispatch('put-project-host-key', due);
|
|
@@ -6351,19 +6418,29 @@ export class Core extends ReadyResource {
|
|
|
6351
6418
|
async _memberProjectSeed(workspace, projectId) {
|
|
6352
6419
|
const ours = workspace.ourMemberId;
|
|
6353
6420
|
const account = this._accountMesh();
|
|
6354
|
-
|
|
6421
|
+
const project = await readProject(workspace.view, projectId);
|
|
6422
|
+
if (!ours || !account || !project) {
|
|
6355
6423
|
return null;
|
|
6356
6424
|
}
|
|
6357
|
-
const row = await readProjectKey(workspace.view, projectId, ours);
|
|
6358
6425
|
const pair = memberBoxKeyPair(account.seed);
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6426
|
+
for (const row of await projectKeys(workspace.view, projectId, ours)) {
|
|
6427
|
+
const seed = b4a.equals(row.boxKey, pair.publicKey) && openSealedToMember(row.sealedSeed, pair);
|
|
6428
|
+
if (seed && seedOpens(project, seed)) {
|
|
6429
|
+
return seed;
|
|
6430
|
+
}
|
|
6431
|
+
}
|
|
6432
|
+
return null;
|
|
6362
6433
|
}
|
|
6363
6434
|
async _deviceProjectSeed(workspace, projectId) {
|
|
6364
6435
|
const device = this._requireDeviceKeyPair();
|
|
6365
|
-
const
|
|
6366
|
-
|
|
6436
|
+
const project = await readProject(workspace.view, projectId);
|
|
6437
|
+
for (const row of await projectDeviceKeys(workspace.view, projectId, device.publicKey)) {
|
|
6438
|
+
const seed = openSealedToDevice(row.sealedSeed, device);
|
|
6439
|
+
if (project && seed && seedOpens(project, seed)) {
|
|
6440
|
+
return seed;
|
|
6441
|
+
}
|
|
6442
|
+
}
|
|
6443
|
+
return null;
|
|
6367
6444
|
}
|
|
6368
6445
|
async _projectGone(projectId) {
|
|
6369
6446
|
if (this._isHidden(projectId, this._pooled(projectId)?.workspaceKey)) {
|