@qvac/core 1.0.0-rc.11 → 1.0.0-rc.13
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 +66 -1
- package/dist-lib/lib/assistant/harness.d.ts +2 -2
- package/dist-lib/lib/assistant/history.js +30 -2
- package/dist-lib/lib/assistant.js +2 -1
- package/dist-lib/lib/core/archived-mesh.js +7 -3
- package/dist-lib/lib/core/chat-copy.d.ts +18 -3
- package/dist-lib/lib/core/chat-copy.js +73 -23
- package/dist-lib/lib/core/chat-group.js +14 -9
- package/dist-lib/lib/core/chat-move.d.ts +9 -0
- package/dist-lib/lib/core/chat-move.js +94 -3
- package/dist-lib/lib/core/chat.js +21 -8
- package/dist-lib/lib/core/collections.d.ts +1 -0
- package/dist-lib/lib/core/collections.js +1 -0
- package/dist-lib/lib/core/contract/activity.js +2 -2
- package/dist-lib/lib/core/contract/chat-group.d.ts +1 -0
- package/dist-lib/lib/core/contract/chat-group.js +21 -1
- package/dist-lib/lib/core/contract/chat.d.ts +9 -0
- package/dist-lib/lib/core/contract/chat.js +127 -5
- package/dist-lib/lib/core/contract/chunks.d.ts +1 -0
- package/dist-lib/lib/core/contract/chunks.js +37 -6
- package/dist-lib/lib/core/contract/features.d.ts +21 -0
- package/dist-lib/lib/core/contract/features.js +22 -0
- package/dist-lib/lib/core/contract/indexing.js +4 -2
- package/dist-lib/lib/core/contract/knowledge.js +5 -4
- package/dist-lib/lib/core/contract/members.js +2 -2
- package/dist-lib/lib/core/contract/projects.d.ts +5 -0
- package/dist-lib/lib/core/contract/projects.js +12 -4
- package/dist-lib/lib/core/contract/roles.js +30 -4
- package/dist-lib/lib/core/contract/run-requests.js +2 -2
- package/dist-lib/lib/core/contract/seed-defaults.js +2 -2
- package/dist-lib/lib/core/contract/tool-configs.js +3 -2
- package/dist-lib/lib/core/contract/workspace.d.ts +2 -0
- package/dist-lib/lib/core/contract/workspace.js +40 -7
- package/dist-lib/lib/core/contract/writers.js +2 -2
- package/dist-lib/lib/core/files/attachments.js +4 -1
- package/dist-lib/lib/core/files/index.d.ts +1 -0
- package/dist-lib/lib/core/files/index.js +19 -6
- package/dist-lib/lib/core/files/processing/index.js +4 -1
- package/dist-lib/lib/core/files/rag/build.js +23 -1
- package/dist-lib/lib/core/files/rag/load.d.ts +3 -0
- package/dist-lib/lib/core/files/rag/load.js +27 -6
- package/dist-lib/lib/core/local/index.d.ts +6 -2
- package/dist-lib/lib/core/local/index.js +12 -3
- package/dist-lib/lib/core/mesh.d.ts +6 -0
- package/dist-lib/lib/core/mesh.js +22 -12
- package/dist-lib/lib/core/migrations/workspace-from-0-21/index.d.ts +85 -0
- package/dist-lib/lib/core/migrations/workspace-from-0-21/index.js +690 -0
- package/dist-lib/lib/core/migrations/writer-links.d.ts +0 -1
- package/dist-lib/lib/core/migrations/writer-links.js +12 -10
- package/dist-lib/lib/core/project-keys.d.ts +6 -0
- package/dist-lib/lib/core/project-keys.js +11 -0
- package/dist-lib/lib/core/public-mesh.d.ts +2 -0
- package/dist-lib/lib/core/public-mesh.js +5 -0
- package/dist-lib/lib/core/sync/changed.d.ts +4 -2
- package/dist-lib/lib/core/sync/changed.js +1 -1
- package/dist-lib/lib/core/sync/index.js +27 -2
- package/dist-lib/lib/core/workspace-upgrade.d.ts +6 -0
- package/dist-lib/lib/core/workspace-upgrade.js +26 -16
- package/dist-lib/lib/core.d.ts +4 -32
- package/dist-lib/lib/core.js +143 -482
- package/dist-lib/lib/errors.d.ts +4 -0
- package/dist-lib/lib/errors.js +4 -0
- package/dist-lib/lib/run-transcript.d.ts +2 -1
- package/dist-lib/lib/run-transcript.js +11 -5
- package/dist-lib/schema/engine.js +2 -1
- package/dist-lib/schema/qvac.js +26 -1
- package/dist-lib/spec/hrpc/messages.js +17 -8
- package/dist-lib/spec/hyperschema/index.js +17 -8
- package/dist-lib/spec/hyperschema/schema.json +5 -0
- package/dist-lib/spec/hyperschema/types.d.ts +1 -0
- package/dist-lib/spec/mesh/hyperdb/db.json +15 -0
- package/dist-lib/spec/mesh/hyperdb/index.js +70 -1
- package/dist-lib/spec/mesh/hyperdb/messages.js +806 -438
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +18 -0
- package/dist-lib/spec/mesh/hyperdispatch/index.js +52 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +303 -3
- package/dist-lib/spec/mesh/hyperschema/index.js +303 -3
- package/dist-lib/spec/mesh/hyperschema/schema.json +146 -0
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +39 -0
- package/package.json +10 -8
- package/tui/README.md +2 -1
- package/tui/boot.mjs +2 -0
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { LIVE_WRITERS_BY_MOST_RECENT } from '../collections.js';
|
|
2
2
|
import { linkedTo, liveDeviceForWriter } from '../contract/activity.js';
|
|
3
|
-
|
|
4
|
-
const BACKFILL_TAIL = 64;
|
|
3
|
+
const PAGE = 64;
|
|
5
4
|
export async function backfillWriterLinks(mesh) {
|
|
6
5
|
const due = await unmarkedLinkedWriters(mesh.view);
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let sent = 0;
|
|
7
|
+
for (let i = 0; i < due.length; i += PAGE) {
|
|
8
|
+
if (mesh.closing || !mesh.writable)
|
|
9
|
+
break;
|
|
10
|
+
const writerKeys = due.slice(i, i + PAGE);
|
|
11
|
+
await mesh.dispatch('reindex-writers', { writerKeys });
|
|
12
|
+
sent += writerKeys.length;
|
|
9
13
|
}
|
|
10
|
-
|
|
11
|
-
return due.length;
|
|
14
|
+
return sent;
|
|
12
15
|
}
|
|
13
16
|
async function unmarkedLinkedWriters(db) {
|
|
14
17
|
const snap = db.snapshot();
|
|
15
18
|
try {
|
|
16
19
|
const due = [];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.toArray()) {
|
|
20
|
+
for await (const row of snap.find(LIVE_WRITERS_BY_MOST_RECENT, {
|
|
21
|
+
reverse: true
|
|
22
|
+
})) {
|
|
21
23
|
if (!row.linked && linkedTo(await liveDeviceForWriter(snap, row.writerKey))) {
|
|
22
24
|
due.push(row.writerKey);
|
|
23
25
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type HyperDB from 'hyperdb';
|
|
2
2
|
import type { QvacAgent, QvacProject, QvacProjectDeviceKey, QvacProjectHostKey, QvacProjectKey } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
3
|
+
import type { MeshBatch } from './mesh.ts';
|
|
3
4
|
export interface ProjectSeed {
|
|
4
5
|
readonly projectId: Buffer;
|
|
5
6
|
readonly seed: Buffer;
|
|
@@ -14,3 +15,8 @@ export declare function seedOpens(project: QvacProject, seed: Buffer): boolean;
|
|
|
14
15
|
export declare function dueProjectKey(view: HyperDB, memberId: Buffer, { projectId, seed, sealedBy }: ProjectSeed): Promise<QvacProjectKey | null>;
|
|
15
16
|
export declare function dueProjectHostKey(view: HyperDB, agent: QvacAgent, seal: ProjectHostSeed): Promise<QvacProjectHostKey | null>;
|
|
16
17
|
export declare function dueProjectDeviceKeys(view: HyperDB, row: QvacProject, { seed, sealedBy }: Omit<ProjectSeed, 'projectId'>): Promise<QvacProjectDeviceKey[]>;
|
|
18
|
+
export interface MemberSealing extends Omit<ProjectSeed, 'projectId'> {
|
|
19
|
+
readonly view: HyperDB;
|
|
20
|
+
readonly row: QvacProject;
|
|
21
|
+
}
|
|
22
|
+
export declare function sealMembers(batch: MeshBatch, { view, row, seed, sealedBy }: MemberSealing): Promise<void>;
|
|
@@ -63,3 +63,14 @@ export async function dueProjectDeviceKeys(view, row, { seed, sealedBy }) {
|
|
|
63
63
|
}
|
|
64
64
|
return due;
|
|
65
65
|
}
|
|
66
|
+
export async function sealMembers(batch, { view, row, seed, sealedBy }) {
|
|
67
|
+
for (const memberId of row.memberIds ?? []) {
|
|
68
|
+
const due = await dueProjectKey(view, memberId, { projectId: row.id, seed, sealedBy });
|
|
69
|
+
if (due) {
|
|
70
|
+
batch.dispatch('put-project-key', due);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (const due of await dueProjectDeviceKeys(view, row, { seed, sealedBy })) {
|
|
74
|
+
batch.dispatch('put-project-device-key', due);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { QvacChat, QvacJoinedMesh } from '../../spec/mesh/hyperschema/types
|
|
|
2
2
|
import type { Mesh } from './mesh.ts';
|
|
3
3
|
export declare function publicSeed(accountSeed: Buffer, workspaceKey: Buffer): Buffer;
|
|
4
4
|
export declare function ourRows(account: Mesh): Promise<QvacJoinedMesh[]>;
|
|
5
|
+
export declare function firstWorkspace(account: Mesh): Promise<string | null>;
|
|
5
6
|
export interface OldChats {
|
|
6
7
|
readonly mark: string;
|
|
7
8
|
readonly messages: boolean;
|
|
@@ -17,6 +18,7 @@ export interface PublicRecord {
|
|
|
17
18
|
readonly key: string | null;
|
|
18
19
|
readonly writerSeed: string;
|
|
19
20
|
readonly migrated: boolean;
|
|
21
|
+
readonly copied?: string;
|
|
20
22
|
}
|
|
21
23
|
export declare function publicRecordsOf(accountKey: Buffer): string;
|
|
22
24
|
export declare function publicRecordKey(accountKey: Buffer, workspaceKey: Buffer): string;
|
|
@@ -11,6 +11,11 @@ export async function ourRows(account) {
|
|
|
11
11
|
const rows = await account.view.find(JOINED_MESHES).toArray();
|
|
12
12
|
return rows.filter((row) => ours && b4a.equals(row.memberId, ours));
|
|
13
13
|
}
|
|
14
|
+
export async function firstWorkspace(account) {
|
|
15
|
+
const live = (await ourRows(account)).filter((row) => row.workspace && !row.leftAt);
|
|
16
|
+
const [first] = live.sort((a, b) => a.joinedAt - b.joinedAt);
|
|
17
|
+
return first ? b4a.toHex(first.meshKey) : null;
|
|
18
|
+
}
|
|
14
19
|
export async function oldChats(account) {
|
|
15
20
|
let chats = 0;
|
|
16
21
|
let chunks = 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ViewChange } from 'hyperdb';
|
|
2
|
-
import type { QvacAgent, QvacChat, QvacChunk, QvacChunkCounter, QvacDevice, QvacIndexingStatus, QvacKnowledge, QvacKnowledgeArtifact, QvacPurgedChat } from '../../../spec/mesh/hyperschema/types.d.ts';
|
|
3
|
-
import { AGENTS, CHATS, CHUNKS, CHUNK_COUNTERS, DEVICES, INDEXING_STATUS, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, PURGED_CHATS } from '../collections.ts';
|
|
2
|
+
import type { QvacAgent, QvacChat, QvacChunk, QvacChunkCounter, QvacDevice, QvacIndexingStatus, QvacKnowledge, QvacKnowledgeArtifact, QvacMovedOutChat, QvacPurgedChat, QvacToolActivity } from '../../../spec/mesh/hyperschema/types.d.ts';
|
|
3
|
+
import { AGENTS, CHATS, CHUNKS, CHUNK_COUNTERS, DEVICES, INDEXING_STATUS, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, MOVED_OUT_CHATS, PURGED_CHATS, TOOL_ACTIVITY } from '../collections.ts';
|
|
4
4
|
export interface ChangedRows {
|
|
5
5
|
[AGENTS]: QvacAgent;
|
|
6
6
|
[DEVICES]: QvacDevice;
|
|
@@ -10,7 +10,9 @@ export interface ChangedRows {
|
|
|
10
10
|
[INDEXING_STATUS]: QvacIndexingStatus;
|
|
11
11
|
[KNOWLEDGE]: QvacKnowledge;
|
|
12
12
|
[KNOWLEDGE_ARTIFACTS]: QvacKnowledgeArtifact;
|
|
13
|
+
[MOVED_OUT_CHATS]: QvacMovedOutChat;
|
|
13
14
|
[PURGED_CHATS]: QvacPurgedChat;
|
|
15
|
+
[TOOL_ACTIVITY]: QvacToolActivity;
|
|
14
16
|
}
|
|
15
17
|
export type ChangedRow<C extends keyof ChangedRows> = ViewChange & {
|
|
16
18
|
readonly collection: C;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AGENTS, CHATS, CHUNKS, CHUNK_COUNTERS, DEVICES, INDEXING_STATUS, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, PURGED_CHATS } from '../collections.js';
|
|
1
|
+
import { AGENTS, CHATS, CHUNKS, CHUNK_COUNTERS, DEVICES, INDEXING_STATUS, KNOWLEDGE, KNOWLEDGE_ARTIFACTS, MOVED_OUT_CHATS, PURGED_CHATS, TOOL_ACTIVITY } from '../collections.js';
|
|
2
2
|
export function changed(change, collection) {
|
|
3
3
|
return change.collection === collection;
|
|
4
4
|
}
|
|
@@ -5,7 +5,8 @@ import { syncChatTombstone } from './chats.js';
|
|
|
5
5
|
import { syncNotificationChunk } from './chunks.js';
|
|
6
6
|
import { isRecord } from '../../guards.js';
|
|
7
7
|
import { isMissingBlock } from '../view-read.js';
|
|
8
|
-
import {
|
|
8
|
+
import { isPendingBlobReference } from '../files/store/index.js';
|
|
9
|
+
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, MOVED_OUT_CHATS, PROJECT_DEVICE_SEALS, PROJECT_HOST_SEALS, PROJECT_MEMBER_SEALS, PROJECTS, PUBLIC_MESHES, PUBLIC_SEEDS, PURGED_CHATS, SKILL_SECRETS, TOOL_ACTIVITY, WORKSPACE } from '../collections.js';
|
|
9
10
|
export async function syncChanges(mesh, view, from) {
|
|
10
11
|
if (mesh.closing)
|
|
11
12
|
return null;
|
|
@@ -23,7 +24,7 @@ export async function syncChanges(mesh, view, from) {
|
|
|
23
24
|
}
|
|
24
25
|
mesh.reportError(err);
|
|
25
26
|
pass.membershipMoved = pass.agentsDirty = pass.meshesChanged = pass.nameChanged = true;
|
|
26
|
-
pass.runs = null;
|
|
27
|
+
pass.runs = pass.edited = null;
|
|
27
28
|
pass.groupsChanged = pass.secretsChanged = true;
|
|
28
29
|
}
|
|
29
30
|
try {
|
|
@@ -63,6 +64,7 @@ function newPass() {
|
|
|
63
64
|
knowledge: [],
|
|
64
65
|
artifacts: [],
|
|
65
66
|
orderDirty: new Set(),
|
|
67
|
+
edited: new Set(),
|
|
66
68
|
purged: new Map(),
|
|
67
69
|
notifications: [],
|
|
68
70
|
runs: { requests: [], deletedAgents: new Set() },
|
|
@@ -101,6 +103,9 @@ async function deriveFromPass(mesh, pass) {
|
|
|
101
103
|
if (pass.nameChanged) {
|
|
102
104
|
await mesh.refreshName();
|
|
103
105
|
}
|
|
106
|
+
if (pass.edited === null || pass.edited.size > 0) {
|
|
107
|
+
await mesh.history?.edited(pass.edited);
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
function announcePass(mesh, pass) {
|
|
106
111
|
for (const chatId of pass.purged.keys()) {
|
|
@@ -121,12 +126,18 @@ function announcePass(mesh, pass) {
|
|
|
121
126
|
if (pass.agentsDirty) {
|
|
122
127
|
mesh.emit('agents-dirty');
|
|
123
128
|
}
|
|
129
|
+
if (pass.edited === null || pass.edited.size > 0) {
|
|
130
|
+
mesh.emit('chats-edited', pass.edited);
|
|
131
|
+
}
|
|
124
132
|
if (!pass.runs || pass.runs.requests.length || pass.runs.deletedAgents.size) {
|
|
125
133
|
mesh.emit('runs-landed', pass.runs);
|
|
126
134
|
}
|
|
127
135
|
if (pass.secretsChanged) {
|
|
128
136
|
mesh.emit('skill-secrets-dirty');
|
|
129
137
|
}
|
|
138
|
+
if (pass.attachments.some(({ attachment }) => isPendingBlobReference(attachment?.blobId ?? ''))) {
|
|
139
|
+
mesh.emit('files-pending');
|
|
140
|
+
}
|
|
130
141
|
mesh.emit('meshes-dirty', pass.meshesChanged, pass.groupsChanged, pass.orderDirty.size > 0);
|
|
131
142
|
if (pass.nameChanged) {
|
|
132
143
|
mesh.emit('mesh-named');
|
|
@@ -160,6 +171,7 @@ async function walkChanges(mesh, { snap, from, files, pass }) {
|
|
|
160
171
|
}
|
|
161
172
|
else if (changed(change, CHATS)) {
|
|
162
173
|
pass.orderDirty.add(change.value.id);
|
|
174
|
+
edit(pass, { chatId: change.value.id });
|
|
163
175
|
syncChatTombstone(mesh, change.value);
|
|
164
176
|
}
|
|
165
177
|
else if (changed(change, CHUNK_COUNTERS)) {
|
|
@@ -169,6 +181,7 @@ async function walkChanges(mesh, { snap, from, files, pass }) {
|
|
|
169
181
|
pass.rulesRaised = true;
|
|
170
182
|
}
|
|
171
183
|
else if (changed(change, CHUNKS)) {
|
|
184
|
+
edit(pass, change.value);
|
|
172
185
|
pass.notifications.push(change.value);
|
|
173
186
|
if (change.value.type === 'run-request') {
|
|
174
187
|
pass.runs?.requests.push(change.value);
|
|
@@ -178,11 +191,18 @@ async function walkChanges(mesh, { snap, from, files, pass }) {
|
|
|
178
191
|
}
|
|
179
192
|
}
|
|
180
193
|
else if (changed(change, KNOWLEDGE)) {
|
|
194
|
+
edit(pass, change.value);
|
|
181
195
|
pass.knowledge.push(change.value);
|
|
182
196
|
}
|
|
183
197
|
else if (changed(change, KNOWLEDGE_ARTIFACTS)) {
|
|
184
198
|
pass.artifacts.push(change.value);
|
|
185
199
|
}
|
|
200
|
+
else if (changed(change, TOOL_ACTIVITY)) {
|
|
201
|
+
edit(pass, change.value);
|
|
202
|
+
}
|
|
203
|
+
else if (changed(change, MOVED_OUT_CHATS)) {
|
|
204
|
+
edit(pass, change.value);
|
|
205
|
+
}
|
|
186
206
|
else if (changed(change, PURGED_CHATS)) {
|
|
187
207
|
pass.purged.set(change.value.chatId, change.value.at);
|
|
188
208
|
}
|
|
@@ -200,6 +220,11 @@ async function walkChanges(mesh, { snap, from, files, pass }) {
|
|
|
200
220
|
}
|
|
201
221
|
}
|
|
202
222
|
}
|
|
223
|
+
function edit(pass, { chatId }) {
|
|
224
|
+
if (chatId) {
|
|
225
|
+
pass.edited?.add(chatId);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
203
228
|
function unserved(err) {
|
|
204
229
|
return isMissingBlock(err) || (isRecord(err) && err.code === 'SESSION_CLOSED');
|
|
205
230
|
}
|
|
@@ -6,11 +6,17 @@ export declare const UPGRADE_RECORDS = "workspace-upgrade/";
|
|
|
6
6
|
export declare function upgradeCheckedKey(meshKey: Buffer): string;
|
|
7
7
|
export declare function agentsFoldKey(workspaceKey: Buffer): string;
|
|
8
8
|
export declare function groupRecordKey(workspaceKey: Buffer, groupId: string): string;
|
|
9
|
+
export declare function groupRecordsOf(workspaceKey: Buffer): string;
|
|
10
|
+
export declare function historyEditsOf(workspaceKey: Buffer): string;
|
|
11
|
+
export declare function editedChats(prefix: string, keys: ReadonlyArray<string>): ReadonlySet<string> | null;
|
|
12
|
+
export declare function touches(bucket: Bucket, edited: ReadonlySet<string> | null): boolean;
|
|
9
13
|
export interface GroupRecord {
|
|
10
14
|
readonly key?: string;
|
|
11
15
|
readonly copied?: boolean;
|
|
12
16
|
readonly listedMembers?: ReadonlyArray<string>;
|
|
17
|
+
readonly listedSettled?: boolean;
|
|
13
18
|
readonly done?: boolean;
|
|
19
|
+
readonly into?: string;
|
|
14
20
|
}
|
|
15
21
|
export declare function isGroupRecord(value: unknown): value is GroupRecord;
|
|
16
22
|
export interface Bucket {
|
|
@@ -12,7 +12,20 @@ export function agentsFoldKey(workspaceKey) {
|
|
|
12
12
|
return `workspace-agents/${b4a.toHex(workspaceKey)}`;
|
|
13
13
|
}
|
|
14
14
|
export function groupRecordKey(workspaceKey, groupId) {
|
|
15
|
-
return
|
|
15
|
+
return `${groupRecordsOf(workspaceKey)}${groupId}`;
|
|
16
|
+
}
|
|
17
|
+
export function groupRecordsOf(workspaceKey) {
|
|
18
|
+
return `workspace-upgrade/${b4a.toHex(workspaceKey)}/`;
|
|
19
|
+
}
|
|
20
|
+
export function historyEditsOf(workspaceKey) {
|
|
21
|
+
return `workspace-edits/${b4a.toHex(workspaceKey)}/`;
|
|
22
|
+
}
|
|
23
|
+
export function editedChats(prefix, keys) {
|
|
24
|
+
const chats = new Set(keys.map((key) => key.slice(prefix.length)));
|
|
25
|
+
return chats.has('') ? null : chats;
|
|
26
|
+
}
|
|
27
|
+
export function touches(bucket, edited) {
|
|
28
|
+
return !edited || [...bucket.chats].some((chatId) => edited.has(chatId));
|
|
16
29
|
}
|
|
17
30
|
export function isGroupRecord(value) {
|
|
18
31
|
return isRecord(value) && (value.key === undefined || typeof value.key === 'string');
|
|
@@ -31,21 +44,18 @@ export async function projectsByGroup(view) {
|
|
|
31
44
|
return rows;
|
|
32
45
|
}
|
|
33
46
|
export async function groupBuckets(view, workspaceName) {
|
|
34
|
-
const live = await liveGroups(view)
|
|
35
|
-
|
|
36
|
-
|
|
47
|
+
const live = (await liveGroups(view)).map(({ id, name }) => ({
|
|
48
|
+
groupId: id,
|
|
49
|
+
name,
|
|
50
|
+
chats: new Set()
|
|
51
|
+
}));
|
|
52
|
+
const buckets = new Map(live.map((bucket) => [bucket.groupId, bucket]));
|
|
53
|
+
const ungrouped = { groupId: UNGROUPED, name: workspaceName, chats: new Set() };
|
|
37
54
|
for (const chat of await view.find(CHATS).toArray()) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
const bucket = buckets.get(chat.groupId ?? '') ?? ungrouped;
|
|
56
|
+
if (!chat.deletedAt) {
|
|
57
|
+
bucket.chats.add(chat.id);
|
|
58
|
+
}
|
|
42
59
|
}
|
|
43
|
-
|
|
44
|
-
groupId: group.id,
|
|
45
|
-
name: group.name,
|
|
46
|
-
chats: chats.get(group.id) ?? new Set()
|
|
47
|
-
}));
|
|
48
|
-
return ungrouped.size > 0
|
|
49
|
-
? [...buckets, { groupId: UNGROUPED, name: workspaceName, chats: ungrouped }]
|
|
50
|
-
: buckets;
|
|
60
|
+
return ungrouped.chats.size > 0 ? [...live, ungrouped] : live;
|
|
51
61
|
}
|
package/dist-lib/lib/core.d.ts
CHANGED
|
@@ -252,9 +252,7 @@ export declare class Core extends ReadyResource {
|
|
|
252
252
|
private readonly _wakeup;
|
|
253
253
|
private readonly _following;
|
|
254
254
|
private readonly _kickedProjects;
|
|
255
|
-
private readonly
|
|
256
|
-
private readonly _groupPasses;
|
|
257
|
-
private readonly _groupPassesDue;
|
|
255
|
+
private readonly _upgrade;
|
|
258
256
|
private readonly _purging;
|
|
259
257
|
private readonly _publicIds;
|
|
260
258
|
private _publicBoots;
|
|
@@ -267,9 +265,6 @@ export declare class Core extends ReadyResource {
|
|
|
267
265
|
private readonly _publicFollow;
|
|
268
266
|
private readonly _publicMerges;
|
|
269
267
|
private readonly _publicDrops;
|
|
270
|
-
private _publicMigration;
|
|
271
|
-
private _copyAgain;
|
|
272
|
-
private _accountCopied;
|
|
273
268
|
private readonly _agentCopies;
|
|
274
269
|
private readonly _sharedAgents;
|
|
275
270
|
private readonly _memberKeyWrites;
|
|
@@ -423,7 +418,7 @@ export declare class Core extends ReadyResource {
|
|
|
423
418
|
private _isHidden;
|
|
424
419
|
private _retireKickedAccount;
|
|
425
420
|
private _restoreAccount;
|
|
426
|
-
private
|
|
421
|
+
private _keepVoided;
|
|
427
422
|
private _replaceRevokedAccount;
|
|
428
423
|
private _leaveKicked;
|
|
429
424
|
private _departKicked;
|
|
@@ -451,28 +446,6 @@ export declare class Core extends ReadyResource {
|
|
|
451
446
|
private _departOldAccount;
|
|
452
447
|
private _departIfPooled;
|
|
453
448
|
private _recordJoinedMesh;
|
|
454
|
-
private _followUpgrade;
|
|
455
|
-
private _followGroups;
|
|
456
|
-
private _passGroups;
|
|
457
|
-
private _groupBuckets;
|
|
458
|
-
private _markFoldDue;
|
|
459
|
-
private _passAgents;
|
|
460
|
-
private _heldProjects;
|
|
461
|
-
private _groupRecord;
|
|
462
|
-
private _scanBuckets;
|
|
463
|
-
private _passGroup;
|
|
464
|
-
private _foundGroupProject;
|
|
465
|
-
private _mergeGroupInto;
|
|
466
|
-
private _winnerOf;
|
|
467
|
-
private _copyGroup;
|
|
468
|
-
private _addWorkspaceMembers;
|
|
469
|
-
private _listNewMembers;
|
|
470
|
-
private _listWorkspaceMembers;
|
|
471
|
-
private _workspaceMembers;
|
|
472
|
-
private _openUpgradable;
|
|
473
|
-
private _markUpgradeChecked;
|
|
474
|
-
private _upgradable;
|
|
475
|
-
private _markJoinedWorkspace;
|
|
476
449
|
private _reopenInRole;
|
|
477
450
|
private _registerMesh;
|
|
478
451
|
private _backfillMeshSeeds;
|
|
@@ -526,9 +499,6 @@ export declare class Core extends ReadyResource {
|
|
|
526
499
|
private _openPublicMesh;
|
|
527
500
|
private _mintPublicBirth;
|
|
528
501
|
private _mergeLostMint;
|
|
529
|
-
private _migrateIntoPublic;
|
|
530
|
-
private _recordCopied;
|
|
531
|
-
private _markCopied;
|
|
532
502
|
private _followAgentCopies;
|
|
533
503
|
private _keepAgentCopies;
|
|
534
504
|
private _agentPicks;
|
|
@@ -551,6 +521,7 @@ export declare class Core extends ReadyResource {
|
|
|
551
521
|
private _restorePublicWriters;
|
|
552
522
|
private _pooled;
|
|
553
523
|
private _backfillWriterLinks;
|
|
524
|
+
private _upgradeHost;
|
|
554
525
|
private _accountMesh;
|
|
555
526
|
private _meshIdOf;
|
|
556
527
|
private _poolEntry;
|
|
@@ -663,6 +634,7 @@ export declare class Core extends ReadyResource {
|
|
|
663
634
|
private _openFollowedMesh;
|
|
664
635
|
private _followProjects;
|
|
665
636
|
private _passProjects;
|
|
637
|
+
private _dropUnlistedFollows;
|
|
666
638
|
private _mayFollowProjects;
|
|
667
639
|
private _sealProjectKeys;
|
|
668
640
|
private _sealWorkspaceProjectKeys;
|