@qvac/core 1.0.0-rc.5 → 1.0.0-rc.7
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 +10 -3
- 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/approval-rules.js +8 -5
- package/dist-lib/lib/api/chat.d.ts +1 -2
- package/dist-lib/lib/api/chat.js +4 -18
- 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.d.ts +0 -1
- package/dist-lib/lib/api/index.js +3 -3
- package/dist-lib/lib/api/mesh.d.ts +1 -1
- package/dist-lib/lib/api/mesh.js +1 -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/api/sync.js +12 -2
- 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 -2
- package/dist-lib/lib/assistant.js +124 -20
- 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/archived-mesh.d.ts +1 -0
- package/dist-lib/lib/core/archived-mesh.js +11 -14
- package/dist-lib/lib/core/chat-copy.d.ts +1 -1
- package/dist-lib/lib/core/chat-copy.js +14 -4
- package/dist-lib/lib/core/chat-move.d.ts +3 -1
- package/dist-lib/lib/core/chat-move.js +5 -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/joined-meshes.js +2 -1
- 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/local/index.d.ts +2 -1
- package/dist-lib/lib/core/local/index.js +3 -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/public-mesh.d.ts +6 -8
- package/dist-lib/lib/core/public-mesh.js +19 -29
- package/dist-lib/lib/core/sync/index.js +6 -6
- package/dist-lib/lib/core.d.ts +17 -8
- package/dist-lib/lib/core.js +317 -224
- package/dist-lib/lib/errors.d.ts +4 -12
- package/dist-lib/lib/errors.js +4 -12
- 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 +64 -4
- package/dist-lib/schema/local.js +4 -2
- package/dist-lib/schema/qvac.js +64 -2
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/capabilities.d.ts +4 -2
- package/dist-lib/spec/hrpc/hrpc.json +14 -1
- package/dist-lib/spec/hrpc/index.js +16 -4
- package/dist-lib/spec/hrpc/messages.js +508 -235
- package/dist-lib/spec/hyperschema/index.js +508 -235
- package/dist-lib/spec/hyperschema/schema.json +214 -6
- package/dist-lib/spec/hyperschema/types.d.ts +40 -1
- package/dist-lib/spec/local/hyperdb/messages.js +26 -12
- package/dist-lib/spec/local/hyperschema/index.js +13 -6
- package/dist-lib/spec/local/hyperschema/schema.json +10 -0
- package/dist-lib/spec/local/hyperschema/types.d.ts +2 -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 +895 -416
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +259 -6
- package/dist-lib/spec/mesh/hyperschema/index.js +259 -6
- package/dist-lib/spec/mesh/hyperschema/schema.json +160 -0
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +38 -0
- package/package.json +27 -11
- package/tui/README.md +190 -0
- package/tui/app.mjs +8282 -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
|
@@ -222,9 +222,8 @@ async function copyRows(snap, copy, remap) {
|
|
|
222
222
|
}
|
|
223
223
|
if (await newer(into, CHATS, chat)) {
|
|
224
224
|
const groupId = copy.chats ? undefined : chat.groupId;
|
|
225
|
-
const projectId = copy.unlinkProjects ? undefined : chat.projectId;
|
|
226
225
|
batch.dispatch('put-chat', {
|
|
227
|
-
chat: { ...stripped(chat), agentId: agent?.id ?? chat.agentId, groupId
|
|
226
|
+
chat: { ...stripped(chat), agentId: agent?.id ?? chat.agentId, groupId }
|
|
228
227
|
});
|
|
229
228
|
}
|
|
230
229
|
}
|
|
@@ -266,7 +265,7 @@ async function copyChatChunks(snap, chatId, copy) {
|
|
|
266
265
|
const { into } = copy;
|
|
267
266
|
const batch = into.batch();
|
|
268
267
|
const chunks = await chunksOf(snap, chatId);
|
|
269
|
-
const open = copy.
|
|
268
|
+
const open = copy.endsOpenRuns ? runsOf(chunks).open : new Set();
|
|
270
269
|
for (const chunk of chunks) {
|
|
271
270
|
const held = await into.view.get(CHUNKS, { id: chunk.id });
|
|
272
271
|
if (held) {
|
|
@@ -275,7 +274,8 @@ async function copyChatChunks(snap, chatId, copy) {
|
|
|
275
274
|
continue;
|
|
276
275
|
}
|
|
277
276
|
const { seq, updatedAt, attachment, runnerDeviceId, ...rest } = stripped(chunk);
|
|
278
|
-
const
|
|
277
|
+
const sent = copy.chats ? { ...rest, senderMemberId: await senderOf(snap, chunk) } : rest;
|
|
278
|
+
const op = deniedWhileOpen(sent, open);
|
|
279
279
|
if (!attachment) {
|
|
280
280
|
batch.dispatch('append-chunk', op);
|
|
281
281
|
if (chunk.type === 'run-request' && chunk.runId && open.has(chunk.runId)) {
|
|
@@ -295,6 +295,16 @@ async function copyChatChunks(snap, chatId, copy) {
|
|
|
295
295
|
}
|
|
296
296
|
await batch.flush();
|
|
297
297
|
}
|
|
298
|
+
function deniedWhileOpen(op, open) {
|
|
299
|
+
const ask = op.approvalRequest;
|
|
300
|
+
if (op.type !== 'approval-request' ||
|
|
301
|
+
ask?.status !== 'pending' ||
|
|
302
|
+
!op.runId ||
|
|
303
|
+
!open.has(op.runId)) {
|
|
304
|
+
return op;
|
|
305
|
+
}
|
|
306
|
+
return { ...op, approvalRequest: { ...ask, status: 'denied' } };
|
|
307
|
+
}
|
|
298
308
|
export const UPGRADED_RUN_REASON = 'the app was updated before this was answered, send it again';
|
|
299
309
|
async function endUpgradedRun(request, copy, batch) {
|
|
300
310
|
await appendChunk(copy.into, {
|
|
@@ -16,6 +16,7 @@ export interface ChatMovesOptions {
|
|
|
16
16
|
readonly log: LoggerInterface | null;
|
|
17
17
|
readonly account?: () => Mesh | null;
|
|
18
18
|
readonly agents?: AgentPicks | null;
|
|
19
|
+
readonly meshIdOf?: (key: Buffer) => string;
|
|
19
20
|
}
|
|
20
21
|
export declare class ChatMoves {
|
|
21
22
|
private readonly _open;
|
|
@@ -23,6 +24,7 @@ export declare class ChatMoves {
|
|
|
23
24
|
private readonly _deviceId;
|
|
24
25
|
private readonly _log;
|
|
25
26
|
private readonly _agents;
|
|
27
|
+
private readonly _meshIdOf;
|
|
26
28
|
private readonly _listeners;
|
|
27
29
|
private readonly _settling;
|
|
28
30
|
private readonly _moving;
|
|
@@ -30,7 +32,7 @@ export declare class ChatMoves {
|
|
|
30
32
|
private readonly _onChange;
|
|
31
33
|
private _patching;
|
|
32
34
|
private _closing;
|
|
33
|
-
constructor(open: OpenMesh, local: LocalStore, { deviceId, log, account, agents }: ChatMovesOptions);
|
|
35
|
+
constructor(open: OpenMesh, local: LocalStore, { deviceId, log, account, agents, meshIdOf }: ChatMovesOptions);
|
|
34
36
|
get closing(): boolean;
|
|
35
37
|
watch(listener: () => void): void;
|
|
36
38
|
unwatch(listener: () => void): void;
|
|
@@ -26,6 +26,7 @@ export class ChatMoves {
|
|
|
26
26
|
_deviceId;
|
|
27
27
|
_log;
|
|
28
28
|
_agents;
|
|
29
|
+
_meshIdOf;
|
|
29
30
|
_listeners = new Set();
|
|
30
31
|
_settling = new Map();
|
|
31
32
|
_moving = new Map();
|
|
@@ -33,12 +34,13 @@ export class ChatMoves {
|
|
|
33
34
|
_onChange = () => this._changed();
|
|
34
35
|
_patching = Promise.resolve();
|
|
35
36
|
_closing = false;
|
|
36
|
-
constructor(open, local, { deviceId, log, account, agents }) {
|
|
37
|
+
constructor(open, local, { deviceId, log, account, agents, meshIdOf = hex }) {
|
|
37
38
|
this._open = open;
|
|
38
39
|
this._local = local;
|
|
39
40
|
this._deviceId = deviceId;
|
|
40
41
|
this._log = log;
|
|
41
42
|
this._agents = agents ?? accountPicks(account ?? (() => null));
|
|
43
|
+
this._meshIdOf = meshIdOf;
|
|
42
44
|
}
|
|
43
45
|
get closing() {
|
|
44
46
|
return this._closing;
|
|
@@ -73,7 +75,7 @@ export class ChatMoves {
|
|
|
73
75
|
return {
|
|
74
76
|
meshId,
|
|
75
77
|
chatId,
|
|
76
|
-
targetMeshId:
|
|
78
|
+
targetMeshId: row.targetMeshId ?? this._meshIdOf(row.targetMeshKey),
|
|
77
79
|
targetChatId: row.targetChatId,
|
|
78
80
|
state: stateOf(row, waiting.length),
|
|
79
81
|
files: row.carried + waiting.length,
|
|
@@ -131,6 +133,7 @@ export class ChatMoves {
|
|
|
131
133
|
meshKey: pair.source.key,
|
|
132
134
|
chatId,
|
|
133
135
|
targetMeshKey: pair.target.key,
|
|
136
|
+
targetMeshId,
|
|
134
137
|
targetChatId,
|
|
135
138
|
agentId: await landingAgentId(pair.target, chat.agentId, agentId),
|
|
136
139
|
carried: 0,
|
|
@@ -75,4 +75,3 @@ export declare function removeChatAttachments(store: Mesh, chatId: string, { dev
|
|
|
75
75
|
export declare function deleteChat(store: Mesh, deviceId: Buffer | null, id: string): Promise<ChatListing>;
|
|
76
76
|
export declare function softDeleteChatsForAgent(store: Mesh, deviceId: Buffer | null, agentId: string): Promise<void>;
|
|
77
77
|
export declare const AGENT_DELETED = "agent-deleted";
|
|
78
|
-
export declare function cancelRunsForAgent(store: Mesh, deviceId: Buffer, agentId: string): Promise<void>;
|
|
@@ -358,9 +358,6 @@ export function softDeleteChatsForAgent(store, deviceId, agentId) {
|
|
|
358
358
|
return eachChatOfAgent(store, agentId, (chatId) => deleteChat(store, deviceId, chatId));
|
|
359
359
|
}
|
|
360
360
|
export const AGENT_DELETED = 'agent-deleted';
|
|
361
|
-
export function cancelRunsForAgent(store, deviceId, agentId) {
|
|
362
|
-
return eachChatOfAgent(store, agentId, (chatId) => cancelActiveRuns(store, chatId, { deviceId, agentId, reason: AGENT_DELETED }));
|
|
363
|
-
}
|
|
364
361
|
async function eachChatOfAgent(store, agentId, fn) {
|
|
365
362
|
const snap = store.view.snapshot();
|
|
366
363
|
try {
|
|
@@ -74,11 +74,11 @@ export declare const DEVICES_BY_MEMBER = "@qvac/devices-by-member";
|
|
|
74
74
|
export declare const AGENT_HOSTS_BY_AGENT = "@qvac/agent-hosts-by-agent";
|
|
75
75
|
export declare const AGENT_HOSTS_BY_DEVICE = "@qvac/agent-hosts-by-device";
|
|
76
76
|
export declare const PUBLIC_SEEDS_BY_DEVICE = "@qvac/public-seeds-by-device";
|
|
77
|
-
export declare const
|
|
78
|
-
export declare const
|
|
79
|
-
export declare const
|
|
77
|
+
export declare const PROJECT_HOST_SEALS_BY_DEVICE = "@qvac/project-host-seals-by-device";
|
|
78
|
+
export declare const PROJECT_DEVICE_SEALS_BY_DEVICE = "@qvac/project-device-seals-by-device";
|
|
79
|
+
export declare const PROJECT_DEVICE_SEALS_BY_MEMBER = "@qvac/project-device-seals-by-member";
|
|
80
80
|
export declare const AGENT_USERS_BY_USER = "@qvac/agent-users-by-user";
|
|
81
|
-
export declare const
|
|
81
|
+
export declare const PROJECT_MEMBER_SEALS_BY_MEMBER = "@qvac/project-member-seals-by-member";
|
|
82
82
|
export declare const TERMINAL_RUN_STATUSES = "@qvac/terminal-run-statuses";
|
|
83
83
|
export declare const MEMBER_REMOVALS = "@qvac/member-removals";
|
|
84
84
|
export declare const INVITE_SEQUENCES = "@qvac/invite-sequences";
|
|
@@ -103,7 +103,7 @@ export declare const LIVE_MODEL_REQUESTS = "@qvac/live-model-requests";
|
|
|
103
103
|
export declare const AGENT_HOSTS = "@qvac/agent-hosts";
|
|
104
104
|
export declare const AGENT_USERS = "@qvac/agent-users";
|
|
105
105
|
export declare const MEMBER_KEYS = "@qvac/member-keys";
|
|
106
|
-
export declare const
|
|
107
|
-
export declare const
|
|
108
|
-
export declare const
|
|
106
|
+
export declare const PROJECT_MEMBER_SEALS = "@qvac/project-member-seals";
|
|
107
|
+
export declare const PROJECT_HOST_SEALS = "@qvac/project-host-seals";
|
|
108
|
+
export declare const PROJECT_DEVICE_SEALS = "@qvac/project-device-seals";
|
|
109
109
|
export declare const SKILL_SECRETS = "@qvac/skill-secrets";
|
|
@@ -74,11 +74,11 @@ export const DEVICES_BY_MEMBER = '@qvac/devices-by-member';
|
|
|
74
74
|
export const AGENT_HOSTS_BY_AGENT = '@qvac/agent-hosts-by-agent';
|
|
75
75
|
export const AGENT_HOSTS_BY_DEVICE = '@qvac/agent-hosts-by-device';
|
|
76
76
|
export const PUBLIC_SEEDS_BY_DEVICE = '@qvac/public-seeds-by-device';
|
|
77
|
-
export const
|
|
78
|
-
export const
|
|
79
|
-
export const
|
|
77
|
+
export const PROJECT_HOST_SEALS_BY_DEVICE = '@qvac/project-host-seals-by-device';
|
|
78
|
+
export const PROJECT_DEVICE_SEALS_BY_DEVICE = '@qvac/project-device-seals-by-device';
|
|
79
|
+
export const PROJECT_DEVICE_SEALS_BY_MEMBER = '@qvac/project-device-seals-by-member';
|
|
80
80
|
export const AGENT_USERS_BY_USER = '@qvac/agent-users-by-user';
|
|
81
|
-
export const
|
|
81
|
+
export const PROJECT_MEMBER_SEALS_BY_MEMBER = '@qvac/project-member-seals-by-member';
|
|
82
82
|
export const TERMINAL_RUN_STATUSES = '@qvac/terminal-run-statuses';
|
|
83
83
|
export const MEMBER_REMOVALS = '@qvac/member-removals';
|
|
84
84
|
export const INVITE_SEQUENCES = '@qvac/invite-sequences';
|
|
@@ -103,7 +103,7 @@ export const LIVE_MODEL_REQUESTS = '@qvac/live-model-requests';
|
|
|
103
103
|
export const AGENT_HOSTS = '@qvac/agent-hosts';
|
|
104
104
|
export const AGENT_USERS = '@qvac/agent-users';
|
|
105
105
|
export const MEMBER_KEYS = '@qvac/member-keys';
|
|
106
|
-
export const
|
|
107
|
-
export const
|
|
108
|
-
export const
|
|
106
|
+
export const PROJECT_MEMBER_SEALS = '@qvac/project-member-seals';
|
|
107
|
+
export const PROJECT_HOST_SEALS = '@qvac/project-host-seals';
|
|
108
|
+
export const PROJECT_DEVICE_SEALS = '@qvac/project-device-seals';
|
|
109
109
|
export const SKILL_SECRETS = '@qvac/skill-secrets';
|
|
@@ -39,6 +39,7 @@ function merge(mesh, existing, rejoin) {
|
|
|
39
39
|
shared: remarks ? mesh.shared : existing.shared,
|
|
40
40
|
sharedAt: remarks ? mesh.sharedAt : existing.sharedAt,
|
|
41
41
|
workspace: existing.workspace || mesh.workspace,
|
|
42
|
-
kicked: rejoin ? mesh.kicked : mesh.kicked || existing.kicked
|
|
42
|
+
kicked: rejoin ? mesh.kicked : mesh.kicked || existing.kicked,
|
|
43
|
+
initial: existing.initial || mesh.initial
|
|
43
44
|
};
|
|
44
45
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type HyperDB from 'hyperdb';
|
|
2
|
-
import type {
|
|
3
|
-
export
|
|
2
|
+
import type { QvacProjectDeviceSeal } from '../../../spec/mesh/hyperschema/types.d.ts';
|
|
3
|
+
export type DeviceSealSlot = Pick<QvacProjectDeviceSeal, 'projectId' | 'deviceId' | 'sealedBy'>;
|
|
4
|
+
export declare function readProjectDeviceKey(tx: HyperDB, { projectId, deviceId, sealedBy }: DeviceSealSlot): Promise<QvacProjectDeviceSeal | null>;
|
|
5
|
+
export declare function projectDeviceKeys(tx: HyperDB, projectId: Buffer, deviceId?: Buffer): Promise<QvacProjectDeviceSeal[]>;
|
|
4
6
|
export declare function dropProjectDeviceKeys(tx: HyperDB, projectId: Buffer): Promise<void>;
|
|
5
7
|
export declare function dropListingDeviceKeys(tx: HyperDB, projectId: Buffer, memberId: Buffer): Promise<void>;
|
|
6
8
|
export declare function dropMemberDeviceKeys(tx: HyperDB, memberId: Buffer): Promise<void>;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import {
|
|
3
|
-
export function readProjectDeviceKey(tx, projectId, deviceId) {
|
|
4
|
-
return tx.get(
|
|
2
|
+
import { PROJECT_DEVICE_SEALS, PROJECT_DEVICE_SEALS_BY_DEVICE, PROJECT_DEVICE_SEALS_BY_MEMBER } from '../collections.js';
|
|
3
|
+
export function readProjectDeviceKey(tx, { projectId, deviceId, sealedBy }) {
|
|
4
|
+
return tx.get(PROJECT_DEVICE_SEALS, { projectId, deviceId, sealedBy });
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
return tx.find(
|
|
6
|
+
export function projectDeviceKeys(tx, projectId, deviceId) {
|
|
7
|
+
const key = deviceId ? { projectId, deviceId } : { projectId };
|
|
8
|
+
return tx.find(PROJECT_DEVICE_SEALS, { gte: key, lte: key }).toArray();
|
|
9
9
|
}
|
|
10
10
|
async function drop(tx, rows, match) {
|
|
11
|
-
for (const
|
|
12
|
-
await tx.delete(
|
|
11
|
+
for (const { projectId, deviceId, sealedBy } of rows.filter(match)) {
|
|
12
|
+
await tx.delete(PROJECT_DEVICE_SEALS, { projectId, deviceId, sealedBy });
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
export async function dropProjectDeviceKeys(tx, projectId) {
|
|
16
|
-
await drop(tx, await
|
|
16
|
+
await drop(tx, await projectDeviceKeys(tx, projectId), () => true);
|
|
17
17
|
}
|
|
18
18
|
export async function dropListingDeviceKeys(tx, projectId, memberId) {
|
|
19
|
-
await drop(tx, await
|
|
19
|
+
await drop(tx, await projectDeviceKeys(tx, projectId), (row) => [row.memberId, row.sealedBy].some((id) => b4a.equals(id, memberId)));
|
|
20
20
|
}
|
|
21
21
|
export async function dropMemberDeviceKeys(tx, memberId) {
|
|
22
22
|
const rows = await tx
|
|
23
|
-
.find(
|
|
23
|
+
.find(PROJECT_DEVICE_SEALS_BY_MEMBER, {
|
|
24
24
|
gte: { memberId },
|
|
25
25
|
lte: { memberId }
|
|
26
26
|
})
|
|
@@ -29,7 +29,7 @@ export async function dropMemberDeviceKeys(tx, memberId) {
|
|
|
29
29
|
}
|
|
30
30
|
export async function dropDeviceKeysOf(tx, deviceId) {
|
|
31
31
|
const rows = await tx
|
|
32
|
-
.find(
|
|
32
|
+
.find(PROJECT_DEVICE_SEALS_BY_DEVICE, {
|
|
33
33
|
gte: { deviceId },
|
|
34
34
|
lte: { deviceId }
|
|
35
35
|
})
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type HyperDB from 'hyperdb';
|
|
2
|
-
import type {
|
|
3
|
-
export
|
|
2
|
+
import type { QvacProjectHostSeal, QvacSetProjectListingOperation } from '../../../spec/mesh/hyperschema/types.d.ts';
|
|
3
|
+
export type HostKeySlot = Pick<QvacProjectHostSeal, 'projectId' | 'deviceId' | 'sealedBy'>;
|
|
4
|
+
export declare function readProjectHostKey(tx: HyperDB, { projectId, deviceId, sealedBy }: HostKeySlot): Promise<QvacProjectHostSeal | null>;
|
|
5
|
+
export declare function projectHostKeys(tx: HyperDB, projectId: Buffer, deviceId: Buffer): Promise<QvacProjectHostSeal[]>;
|
|
4
6
|
export declare function dropProjectHostKeys(tx: HyperDB, projectId: Buffer): Promise<void>;
|
|
5
|
-
export declare function dropMemberHostKeys(tx: HyperDB, projectId
|
|
7
|
+
export declare function dropMemberHostKeys(tx: HyperDB, { projectId, memberId, removed }: Omit<QvacSetProjectListingOperation, 'removedAt'>): Promise<void>;
|
|
6
8
|
export declare function dropDeviceHostKeys(tx: HyperDB, deviceId: Buffer): Promise<void>;
|
|
7
9
|
export declare function pruneProjectHostKeys(tx: HyperDB, deviceId: Buffer): Promise<void>;
|
|
@@ -1,41 +1,52 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import { DEVICES,
|
|
2
|
+
import { DEVICES, PROJECT_HOST_SEALS, PROJECT_HOST_SEALS_BY_DEVICE } from '../collections.js';
|
|
3
3
|
import { liveAgentsOn, usesAny } from './public-seeds.js';
|
|
4
|
-
export function readProjectHostKey(tx, projectId, deviceId) {
|
|
5
|
-
return tx.get(
|
|
4
|
+
export function readProjectHostKey(tx, { projectId, deviceId, sealedBy }) {
|
|
5
|
+
return tx.get(PROJECT_HOST_SEALS, { projectId, deviceId, sealedBy });
|
|
6
|
+
}
|
|
7
|
+
export function projectHostKeys(tx, projectId, deviceId) {
|
|
8
|
+
const range = { gte: { projectId, deviceId }, lte: { projectId, deviceId } };
|
|
9
|
+
return tx.find(PROJECT_HOST_SEALS, range).toArray();
|
|
10
|
+
}
|
|
11
|
+
function dropRow(tx, { projectId, deviceId, sealedBy }) {
|
|
12
|
+
return tx.delete(PROJECT_HOST_SEALS, { projectId, deviceId, sealedBy });
|
|
6
13
|
}
|
|
7
14
|
function hostKeysOf(tx, projectId) {
|
|
8
15
|
const range = { gte: { projectId }, lte: { projectId } };
|
|
9
|
-
return tx.find(
|
|
16
|
+
return tx.find(PROJECT_HOST_SEALS, range).toArray();
|
|
10
17
|
}
|
|
11
18
|
export async function dropProjectHostKeys(tx, projectId) {
|
|
12
19
|
for (const row of await hostKeysOf(tx, projectId)) {
|
|
13
|
-
await tx
|
|
20
|
+
await dropRow(tx, row);
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
|
-
export async function dropMemberHostKeys(tx, projectId, memberId) {
|
|
23
|
+
export async function dropMemberHostKeys(tx, { projectId, memberId, removed }) {
|
|
17
24
|
for (const row of await hostKeysOf(tx, projectId)) {
|
|
18
25
|
const device = await tx.get(DEVICES, { id: row.deviceId });
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
const hosted = !!device?.memberId && b4a.equals(device.memberId, memberId);
|
|
27
|
+
if (hosted || (removed && b4a.equals(row.sealedBy, memberId))) {
|
|
28
|
+
await dropRow(tx, row);
|
|
21
29
|
}
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
function hostKeysSealedTo(tx, deviceId) {
|
|
25
33
|
return tx
|
|
26
|
-
.find(
|
|
34
|
+
.find(PROJECT_HOST_SEALS_BY_DEVICE, {
|
|
35
|
+
gte: { deviceId },
|
|
36
|
+
lte: { deviceId }
|
|
37
|
+
})
|
|
27
38
|
.toArray();
|
|
28
39
|
}
|
|
29
40
|
export async function dropDeviceHostKeys(tx, deviceId) {
|
|
30
41
|
for (const row of await hostKeysSealedTo(tx, deviceId)) {
|
|
31
|
-
await tx
|
|
42
|
+
await dropRow(tx, row);
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
45
|
export async function pruneProjectHostKeys(tx, deviceId) {
|
|
35
46
|
const agents = await liveAgentsOn(tx, deviceId);
|
|
36
47
|
for (const row of await hostKeysSealedTo(tx, deviceId)) {
|
|
37
48
|
if (!(await usesAny(tx, agents, row.projectId))) {
|
|
38
|
-
await tx
|
|
49
|
+
await dropRow(tx, row);
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
52
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type HyperDB from 'hyperdb';
|
|
2
2
|
import type { Router } from '../../../spec/mesh/hyperdispatch/index.js';
|
|
3
|
-
import type { QvacProject,
|
|
3
|
+
import type { QvacProject, QvacProjectMemberSeal, QvacProjectMember } from '../../../spec/mesh/hyperschema/types.d.ts';
|
|
4
4
|
import type { RouterContext } from './types.ts';
|
|
5
5
|
type Signed = Pick<RouterContext, 'tx' | 'node'>;
|
|
6
6
|
export declare const UNGROUPED = "@qvac/ungrouped";
|
|
7
7
|
export declare function readProject(tx: HyperDB, id: Buffer): Promise<QvacProject | null>;
|
|
8
|
-
export
|
|
8
|
+
export type MemberSealSlot = Pick<QvacProjectMemberSeal, 'projectId' | 'memberId' | 'sealedBy'>;
|
|
9
|
+
export declare function readProjectKey(tx: HyperDB, { projectId, memberId, sealedBy }: MemberSealSlot): Promise<QvacProjectMemberSeal | null>;
|
|
10
|
+
export declare function projectKeys(tx: HyperDB, projectId: Buffer, memberId?: Buffer): Promise<QvacProjectMemberSeal[]>;
|
|
9
11
|
export declare function dropMemberProjectKeys(tx: HyperDB, memberId: Buffer): Promise<void>;
|
|
10
12
|
export declare function listsMember(project: Pick<QvacProject, 'memberIds'>, memberId: Buffer): boolean;
|
|
11
13
|
export declare function listedProject(project: QvacProject, memberId: Buffer): boolean;
|
|
@@ -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: [],
|
|
@@ -105,6 +105,7 @@ export interface CandidateSessionOptions {
|
|
|
105
105
|
export interface RecordMeshOptions {
|
|
106
106
|
readonly deviceId: Buffer;
|
|
107
107
|
readonly account?: boolean;
|
|
108
|
+
readonly initial?: boolean;
|
|
108
109
|
}
|
|
109
110
|
export interface DropMeshOptions {
|
|
110
111
|
readonly keepDeparture?: boolean;
|
|
@@ -182,7 +183,7 @@ declare class LocalStore {
|
|
|
182
183
|
private _membership;
|
|
183
184
|
private _migrateLegacySession;
|
|
184
185
|
private _legacyMembership;
|
|
185
|
-
recordMesh(key: Buffer, session: ResolvedSession, { deviceId, account }: RecordMeshOptions): Promise<void>;
|
|
186
|
+
recordMesh(key: Buffer, session: ResolvedSession, { deviceId, account, initial }: RecordMeshOptions): Promise<void>;
|
|
186
187
|
setAccountMesh(deviceId: Buffer, key: Buffer): Promise<void>;
|
|
187
188
|
recordDeparture(key: Buffer, opts: RecordDepartureOptions): Promise<void>;
|
|
188
189
|
departures(): Promise<LocalMeshDeparture[]>;
|
|
@@ -584,7 +584,7 @@ class LocalStore {
|
|
|
584
584
|
}
|
|
585
585
|
return { key: session.meshKey ?? null, seed: session.meshSeed, writerSeed: null };
|
|
586
586
|
}
|
|
587
|
-
recordMesh(key, session, { deviceId, account = false }) {
|
|
587
|
+
recordMesh(key, session, { deviceId, account = false, initial }) {
|
|
588
588
|
return this._locked(async () => {
|
|
589
589
|
const existing = await this._db.get(LOCAL_MESH_MEMBERSHIP, { key });
|
|
590
590
|
const minted = account && !existing && session.baseKey === undefined;
|
|
@@ -599,7 +599,8 @@ class LocalStore {
|
|
|
599
599
|
bootLength: session.bootFrom?.length,
|
|
600
600
|
role: session.role ?? existing?.role,
|
|
601
601
|
workspaceKey: session.workspaceKey ?? existing?.workspaceKey,
|
|
602
|
-
joinedAt: existing?.joinedAt
|
|
602
|
+
joinedAt: existing?.joinedAt,
|
|
603
|
+
initial: initial || existing?.initial
|
|
603
604
|
});
|
|
604
605
|
if (minted) {
|
|
605
606
|
await tx.insert(LOCAL_ACTIVE_MESH, { deviceId, homeMeshKey: key });
|
|
@@ -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() {
|