@agentshouse/mdruntime 0.1.0-cef76ea952695 → 0.1.0-cefb45338245d
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/README.md +21 -19
- package/dist/acceptance.d.ts +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +72 -158
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +174 -75
- package/dist/adapter.d.ts +149 -34
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -7
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/binary.d.ts +6 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +10 -3
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -19
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +2 -4
- package/dist/client.d.ts +22 -23
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +51 -66
- package/dist/collection.d.ts +27 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +34 -10
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +4 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +87 -43
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +36 -27
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +25 -11
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +23 -11
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +43 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +312 -184
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +47 -47
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +5 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +22 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +91 -34
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/host.d.ts +24 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +108 -32
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +102 -0
- package/dist/index.d.ts +23 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -8
- package/dist/install.d.ts +10 -6
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +89 -108
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +74 -54
- package/dist/listing.d.ts +29 -22
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +71 -79
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +94 -36
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -38
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +11 -23
- package/dist/media.d.ts +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +167 -33
- package/dist/memory.d.ts +10 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +98 -37
- package/dist/messages.d.ts +17 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +34 -13
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +4 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +94 -138
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +206 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +21 -12
- package/dist/outcome.d.ts +24 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +33 -3
- package/dist/overlay.d.ts +9 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +37 -24
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +4 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -15
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +207 -96
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +136 -78
- package/dist/query.d.ts +2 -2
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -8
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +182 -38
- package/dist/react.d.ts +11 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/readiness.d.ts +20 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -10
- package/dist/reads.d.ts +4 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +9 -4
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +6 -6
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -4
- package/dist/replica.d.ts +5 -11
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +16 -18
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +30 -5
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +275 -65
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +11 -6
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +11 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +27 -14
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +13 -19
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +43 -90
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +314 -223
- package/dist/saves.d.ts +6 -42
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +176 -718
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -4
- package/dist/shown.d.ts +9 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +93 -57
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +4 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +4 -14
- package/dist/source.d.ts +7 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +15 -2
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +24 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +68 -22
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +25 -15
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +50 -18
- package/dist/stored.d.ts +39 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +217 -59
- package/dist/surface.d.ts +14 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +65 -34
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +127 -102
- package/dist/tables.d.ts +28 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +95 -326
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +1 -2
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +51 -11
- package/dist/wire.d.ts +71 -12
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +30 -14
- package/package.json +4 -4
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -5
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -7
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -44
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/tables.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { sql } from '@agentshouse/mdmodel';
|
|
2
|
-
import { answerQuery } from './compile.js';
|
|
3
|
-
import {
|
|
2
|
+
import { answerQuery, namedHandles } from './compile.js';
|
|
3
|
+
import { amended, authoredLocators, authoredPart, call, callRecords, chatDraft, chatDraftConversations, chatDraftRecord, chatDraftRecords, chatDraftsDropped, claim, fact, fenced, fencedWork, fences, FILE_PART_BYTES, authoredEmptied, heldOrder, kept, moving, pendingBatch, pendingState, queuedLocators, queueOf, queues, remember, roomDraft, roomDraftRecords, spooled, unfenced, unsent, unsentStatus, } from './authored.js';
|
|
4
|
+
import { count, text, texts } from './column.js';
|
|
5
|
+
import { conversationFacts, conversationRows, forgottenConversations, heldConversations, keptFact, keptMessages, messageCount, messageWindow, MESSAGE_TABLES, turnArrived, } from './messages.js';
|
|
4
6
|
import { keptRead, READ_TABLES, readsOfOtherBuildsForgotten, storedRead, } from './reads.js';
|
|
5
7
|
import { conversationTallies, roomTallies, } from './tallies.js';
|
|
6
|
-
import { abandon, release, commit, covering, demoted, ended, entries, erase, facts, fenceRooms, folders, heldLocators, heldRoom, heldRooms, offlineMode, opened, overlaid, presentation, rederive, referrers, refreshing, REPLICA_TABLES, resume, stage, typed, stagedLocators, typedWithin, unrefresh, } from './stored.js';
|
|
8
|
+
import { abandon, release, commit, covering, demoted, ended, entries, erase, facts, fenceRooms, folders, heldLocators, heldRoom, heldRooms, holders, offlineMode, opened, overlaid, presentation, rederive, referrers, refreshing, REPLICA_TABLES, resume, stage, typed, stagedLocators, tablesOf, typedWithin, unrefresh, } from './stored.js';
|
|
9
|
+
export { kindedRevision } from './reference-forms.js';
|
|
10
|
+
export { authoredEmptied, authoredTable, FILE_PART_BYTES, formatted, heldTables, } from './authored.js';
|
|
7
11
|
const STATEMENTS_HELD = 256;
|
|
8
12
|
export function sqliteConnection(engine, database) {
|
|
9
13
|
const decoder = new TextDecoder();
|
|
@@ -71,36 +75,16 @@ export function sqliteConnection(engine, database) {
|
|
|
71
75
|
},
|
|
72
76
|
};
|
|
73
77
|
}
|
|
74
|
-
export const FILE_PART_BYTES = 1_048_576;
|
|
75
78
|
const PROBE_BYTES = 4 * FILE_PART_BYTES;
|
|
76
|
-
const TABLES = [
|
|
77
|
-
['authored_facts', 'name TEXT PRIMARY KEY, value TEXT NOT NULL'],
|
|
78
|
-
['authored_queues', 'locator TEXT PRIMARY KEY, ids TEXT NOT NULL'],
|
|
79
|
-
[
|
|
80
|
-
'authored_pending',
|
|
81
|
-
'locator TEXT NOT NULL, id TEXT NOT NULL, batch TEXT NOT NULL, state TEXT NOT NULL, files TEXT NOT NULL, paths TEXT NOT NULL, moving INTEGER NOT NULL, PRIMARY KEY (locator, id)',
|
|
82
|
-
],
|
|
83
|
-
[
|
|
84
|
-
'authored_room_drafts',
|
|
85
|
-
'locator TEXT NOT NULL, path TEXT NOT NULL, record TEXT NOT NULL, files TEXT NOT NULL, PRIMARY KEY (locator, path)',
|
|
86
|
-
],
|
|
87
|
-
['authored_chat_drafts', 'conversation TEXT PRIMARY KEY, record TEXT NOT NULL'],
|
|
88
|
-
['authored_calls', 'operation TEXT PRIMARY KEY, record TEXT NOT NULL, files TEXT NOT NULL'],
|
|
89
|
-
['authored_fences', 'locator TEXT PRIMARY KEY'],
|
|
90
|
-
];
|
|
91
79
|
export const RUNTIME_TABLES = [
|
|
92
|
-
...TABLES.map(([name, columns]) => `CREATE TABLE ${name} (${columns}) WITHOUT ROWID`),
|
|
93
|
-
'CREATE TABLE file_parts (key TEXT NOT NULL, part INTEGER NOT NULL, bytes BLOB NOT NULL, PRIMARY KEY (key, part))',
|
|
94
80
|
'CREATE TABLE opened_files (key TEXT PRIMARY KEY, locator TEXT NOT NULL, path TEXT NOT NULL, revision TEXT NOT NULL, media_type TEXT NOT NULL, sha256 TEXT, byte_length INTEGER) WITHOUT ROWID',
|
|
95
81
|
'CREATE INDEX opened_files_name ON opened_files (locator, path, revision)',
|
|
82
|
+
'CREATE TABLE opened_parts (key TEXT NOT NULL, part INTEGER NOT NULL, bytes BLOB NOT NULL, PRIMARY KEY (key, part))',
|
|
96
83
|
...REPLICA_TABLES,
|
|
97
84
|
...MESSAGE_TABLES,
|
|
98
85
|
...READ_TABLES,
|
|
99
86
|
];
|
|
100
|
-
const
|
|
101
|
-
const AUTHORED_KEYS = OWNERS.map((table) => `SELECT value FROM ${table}, json_each(${table}.files)`).join(' UNION ');
|
|
102
|
-
const UNOWNED_PARTS = `DELETE FROM file_parts WHERE key NOT IN (${AUTHORED_KEYS} UNION SELECT key FROM opened_files)`;
|
|
103
|
-
const CLEANABLE_BYTES = `SELECT coalesce(sum(length(bytes)), 0) AS bytes FROM file_parts WHERE key NOT IN (${AUTHORED_KEYS})`;
|
|
87
|
+
const UNOPENED_PARTS = 'DELETE FROM opened_parts WHERE key NOT IN (SELECT key FROM opened_files)';
|
|
104
88
|
const READS = new Set([
|
|
105
89
|
'authored.status',
|
|
106
90
|
'authored.moving',
|
|
@@ -125,10 +109,12 @@ const READS = new Set([
|
|
|
125
109
|
'replica.facts',
|
|
126
110
|
'replica.presentation',
|
|
127
111
|
'replica.query',
|
|
112
|
+
'replica.named',
|
|
128
113
|
'replica.tallies',
|
|
129
114
|
'replica.entries',
|
|
130
115
|
'replica.typed',
|
|
131
116
|
'replica.referrers',
|
|
117
|
+
'replica.holders',
|
|
132
118
|
'replica.folders',
|
|
133
119
|
'replica.typedWithin',
|
|
134
120
|
'opened.find',
|
|
@@ -140,6 +126,8 @@ const READS = new Set([
|
|
|
140
126
|
'conversation.turn',
|
|
141
127
|
'conversation.rows',
|
|
142
128
|
'conversation.tallies',
|
|
129
|
+
'conversation.facts',
|
|
130
|
+
'conversation.stored',
|
|
143
131
|
'read.stored',
|
|
144
132
|
]);
|
|
145
133
|
const KINDS = new Set([
|
|
@@ -171,6 +159,7 @@ const KINDS = new Set([
|
|
|
171
159
|
'opened.drop',
|
|
172
160
|
'opened.clean',
|
|
173
161
|
'conversation.keep',
|
|
162
|
+
'conversation.fact',
|
|
174
163
|
'conversation.drop',
|
|
175
164
|
'space.probe',
|
|
176
165
|
'read.keep',
|
|
@@ -182,290 +171,75 @@ export function isRuntime(request) {
|
|
|
182
171
|
export function readsRuntime(request) {
|
|
183
172
|
return READS.has(request.kind);
|
|
184
173
|
}
|
|
185
|
-
function text(value) {
|
|
186
|
-
return typeof value === 'string' ? value : String(value);
|
|
187
|
-
}
|
|
188
|
-
function texts(rows, column) {
|
|
189
|
-
return rows.map((row) => text(row[column]));
|
|
190
|
-
}
|
|
191
|
-
function owned(files) {
|
|
192
|
-
return JSON.stringify([...new Set(files)]);
|
|
193
|
-
}
|
|
194
|
-
function fact(connection, name) {
|
|
195
|
-
const [held] = connection.rows('SELECT value FROM authored_facts WHERE name = ?', [name]);
|
|
196
|
-
return held === undefined ? null : text(held.value);
|
|
197
|
-
}
|
|
198
|
-
function remember(connection, name, value) {
|
|
199
|
-
connection.run('INSERT OR REPLACE INTO authored_facts (name, value) VALUES (?, ?)', [
|
|
200
|
-
name,
|
|
201
|
-
value,
|
|
202
|
-
]);
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
function fenced(connection, locator) {
|
|
206
|
-
return connection.rows('SELECT 1 FROM authored_fences WHERE locator = ?', [locator]).length > 0;
|
|
207
|
-
}
|
|
208
|
-
function stored(connection, key) {
|
|
209
|
-
return connection.rows('SELECT 1 FROM file_parts WHERE key = ? LIMIT 1', [key]).length > 0;
|
|
210
|
-
}
|
|
211
|
-
function storedPart(connection, key, part, bytes) {
|
|
212
|
-
connection.run('INSERT INTO file_parts (key, part, bytes) VALUES (?, ?, ?)', [key, part, bytes]);
|
|
213
|
-
}
|
|
214
|
-
async function storedFiles(connection, files) {
|
|
215
|
-
for (const { key, blob } of files) {
|
|
216
|
-
if (stored(connection, key))
|
|
217
|
-
continue;
|
|
218
|
-
for (let at = 0, part = 0; at < blob.size; at += FILE_PART_BYTES, part += 1) {
|
|
219
|
-
const bytes = new Uint8Array(await blob.slice(at, at + FILE_PART_BYTES).arrayBuffer());
|
|
220
|
-
storedPart(connection, key, part, bytes);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
function filePart(connection, key, part) {
|
|
225
|
-
const [held] = connection.rows('SELECT bytes FROM file_parts WHERE key = ? AND part = ?', [
|
|
226
|
-
key,
|
|
227
|
-
part,
|
|
228
|
-
]);
|
|
229
|
-
return held?.bytes instanceof Uint8Array ? held.bytes : null;
|
|
230
|
-
}
|
|
231
|
-
function* fileParts(connection, key) {
|
|
232
|
-
for (let part = 0;; part += 1) {
|
|
233
|
-
const bytes = filePart(connection, key, part);
|
|
234
|
-
if (bytes === null)
|
|
235
|
-
return;
|
|
236
|
-
yield bytes;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
async function spooled(connection, spool, { key, type }) {
|
|
240
|
-
for (const held of [...spool.held()]) {
|
|
241
|
-
if (held !== key && !stored(connection, held))
|
|
242
|
-
await spool.drop(held);
|
|
243
|
-
}
|
|
244
|
-
return spool.spool(key, type, fileParts(connection, key));
|
|
245
|
-
}
|
|
246
|
-
function unowned(connection) {
|
|
247
|
-
connection.run(UNOWNED_PARTS);
|
|
248
|
-
}
|
|
249
|
-
function queued(connection) {
|
|
250
|
-
return connection.rows('SELECT locator, ids FROM authored_queues').map((row) => ({
|
|
251
|
-
locator: text(row.locator),
|
|
252
|
-
ids: JSON.parse(text(row.ids)),
|
|
253
|
-
}));
|
|
254
|
-
}
|
|
255
174
|
function heldWork(connection, locator) {
|
|
256
175
|
const room = heldRoom(connection, locator);
|
|
257
|
-
const pending = new Map(connection
|
|
258
|
-
.rows('SELECT id, batch, state FROM authored_pending WHERE locator = ?', [locator])
|
|
259
|
-
.map((row) => [
|
|
260
|
-
text(row.id),
|
|
261
|
-
{ id: text(row.id), batch: text(row.batch), state: text(row.state) },
|
|
262
|
-
]));
|
|
263
176
|
return {
|
|
264
177
|
room: room === null ? null : { ...room, overlaid: overlaid(connection, room.key) },
|
|
265
|
-
queue:
|
|
266
|
-
const held = pending.get(id);
|
|
267
|
-
if (held === undefined)
|
|
268
|
-
throw new Error(`Missing Pending Change ${locator}/${id}`);
|
|
269
|
-
return held;
|
|
270
|
-
}),
|
|
178
|
+
queue: queueOf(connection, locator),
|
|
271
179
|
};
|
|
272
180
|
}
|
|
273
181
|
function status(connection) {
|
|
274
|
-
const [completed] = connection.rows("SELECT value FROM replica_facts WHERE name = 'lastCompleted'");
|
|
275
182
|
return {
|
|
276
|
-
|
|
277
|
-
lastCompleted:
|
|
278
|
-
changes: connection
|
|
279
|
-
.rows('SELECT p.locator, c.value AS path FROM authored_pending p, json_each(p.paths) c')
|
|
280
|
-
.map((row) => ({ locator: text(row.locator), path: text(row.path) })),
|
|
281
|
-
resets: connection
|
|
282
|
-
.rows(`SELECT locator, json_extract(state, '$.submission.reset') AS reset FROM authored_pending
|
|
283
|
-
WHERE json_extract(state, '$.submission.state') = 'reset'`)
|
|
284
|
-
.map((row) => ({ locator: text(row.locator), reset: text(row.reset) })),
|
|
285
|
-
returned: texts(connection.rows(`SELECT record FROM authored_room_drafts WHERE json_type(record, '$.returned') = 'object'`), 'record'),
|
|
183
|
+
...unsentStatus(connection),
|
|
184
|
+
lastCompleted: facts(connection, ['lastCompleted']).lastCompleted ?? null,
|
|
286
185
|
};
|
|
287
186
|
}
|
|
288
187
|
function pendingOf(connection, locator, id) {
|
|
289
|
-
const [held] = connection.rows('SELECT state FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
290
188
|
return {
|
|
291
|
-
state:
|
|
189
|
+
state: pendingState(connection, locator, id),
|
|
292
190
|
room: connection.rows('SELECT 1 FROM replica_rooms WHERE locator = ?', [locator]).length > 0,
|
|
293
191
|
};
|
|
294
192
|
}
|
|
295
|
-
function
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
function heldOrder(connection, locator) {
|
|
311
|
-
const [held] = connection.rows('SELECT ids FROM authored_queues WHERE locator = ?', [locator]);
|
|
312
|
-
return held === undefined ? [] : JSON.parse(text(held.ids));
|
|
313
|
-
}
|
|
314
|
-
function keptRows(connection, { locator, order, added, founded, roomDrafts, consumedRoomDrafts }) {
|
|
315
|
-
for (const path of consumedRoomDrafts ?? []) {
|
|
316
|
-
connection.run('DELETE FROM authored_room_drafts WHERE locator = ? AND path = ?', [
|
|
317
|
-
locator,
|
|
318
|
-
path,
|
|
319
|
-
]);
|
|
320
|
-
}
|
|
321
|
-
for (const { path, record, files } of roomDrafts ?? []) {
|
|
322
|
-
connection.run('INSERT OR REPLACE INTO authored_room_drafts (locator, path, record, files) VALUES (?, ?, ?, ?)', [locator, path, record, owned(files)]);
|
|
323
|
-
}
|
|
324
|
-
if (order === undefined)
|
|
325
|
-
return;
|
|
326
|
-
const before = new Set(heldOrder(connection, locator));
|
|
327
|
-
const after = new Set(order);
|
|
328
|
-
if (after.size === 0)
|
|
329
|
-
connection.run('DELETE FROM authored_queues WHERE locator = ?', [locator]);
|
|
330
|
-
else {
|
|
331
|
-
connection.run('INSERT OR REPLACE INTO authored_queues (locator, ids) VALUES (?, ?)', [
|
|
332
|
-
locator,
|
|
333
|
-
JSON.stringify([...after]),
|
|
334
|
-
]);
|
|
335
|
-
}
|
|
336
|
-
for (const id of before) {
|
|
337
|
-
if (!after.has(id)) {
|
|
338
|
-
connection.run('DELETE FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
for (const { id, batch, state, files, paths, moving } of added ?? []) {
|
|
342
|
-
if (before.has(id))
|
|
343
|
-
continue;
|
|
344
|
-
connection.run('INSERT OR REPLACE INTO authored_pending (locator, id, batch, state, files, paths, moving) VALUES (?, ?, ?, ?, ?, ?, ?)', [locator, id, batch, state, owned(files), JSON.stringify(paths), moving ? 1 : 0]);
|
|
345
|
-
}
|
|
346
|
-
for (const { id, batch, files, paths, moving } of founded ?? []) {
|
|
347
|
-
const [held] = connection.rows('SELECT files FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
348
|
-
if (held === undefined || !before.has(id))
|
|
349
|
-
continue;
|
|
350
|
-
connection.run('UPDATE authored_pending SET batch = ?, files = ?, paths = ?, moving = ? WHERE locator = ? AND id = ?', [
|
|
351
|
-
batch,
|
|
352
|
-
owned([...JSON.parse(text(held.files)), ...files]),
|
|
353
|
-
JSON.stringify(paths),
|
|
354
|
-
moving ? 1 : 0,
|
|
355
|
-
locator,
|
|
356
|
-
id,
|
|
357
|
-
]);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
async function kept(connection, { writes, files, whole }) {
|
|
361
|
-
const refused = writes.find(({ locator }) => fenced(connection, locator));
|
|
362
|
-
if (refused !== undefined && whole)
|
|
363
|
-
return refused.locator;
|
|
364
|
-
await storedFiles(connection, files);
|
|
365
|
-
for (const write of writes) {
|
|
366
|
-
if (!fenced(connection, write.locator))
|
|
367
|
-
keptRows(connection, write);
|
|
368
|
-
}
|
|
369
|
-
unowned(connection);
|
|
370
|
-
return refused?.locator ?? null;
|
|
371
|
-
}
|
|
372
|
-
function amended(connection, { locator, id, amendment }) {
|
|
373
|
-
if (fenced(connection, locator))
|
|
374
|
-
return null;
|
|
375
|
-
const [held] = connection.rows('SELECT state FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
376
|
-
if (held === undefined)
|
|
377
|
-
return null;
|
|
378
|
-
connection.run('UPDATE authored_pending SET state = ? WHERE locator = ? AND id = ?', [
|
|
379
|
-
JSON.stringify({
|
|
380
|
-
...JSON.parse(text(held.state)),
|
|
381
|
-
...JSON.parse(amendment),
|
|
382
|
-
}),
|
|
383
|
-
locator,
|
|
384
|
-
id,
|
|
385
|
-
]);
|
|
386
|
-
return null;
|
|
387
|
-
}
|
|
388
|
-
async function roomDraft(connection, { locator, path, kept: draft, files }) {
|
|
389
|
-
if (fenced(connection, locator))
|
|
390
|
-
return locator;
|
|
391
|
-
await storedFiles(connection, files);
|
|
392
|
-
if (draft === null) {
|
|
393
|
-
connection.run('DELETE FROM authored_room_drafts WHERE locator = ? AND path = ?', [
|
|
394
|
-
locator,
|
|
395
|
-
path,
|
|
193
|
+
function storedConversations(connection, conversations) {
|
|
194
|
+
const named = conversations === null ? '' : ' WHERE conversation IN (SELECT value FROM json_each(?))';
|
|
195
|
+
const bound = conversations === null ? [] : [JSON.stringify(conversations)];
|
|
196
|
+
return [
|
|
197
|
+
...new Set([
|
|
198
|
+
...tablesOf(MESSAGE_TABLES).flatMap((table) => texts(connection.rows(`SELECT DISTINCT conversation FROM ${table}${named}`, bound), 'conversation')),
|
|
199
|
+
...chatDraftConversations(connection, conversations),
|
|
200
|
+
]),
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
function droppedConversations(connection, conversations) {
|
|
204
|
+
const held = storedConversations(connection, conversations);
|
|
205
|
+
for (const table of tablesOf(MESSAGE_TABLES)) {
|
|
206
|
+
connection.run(`DELETE FROM ${table} WHERE conversation IN (SELECT value FROM json_each(?))`, [
|
|
207
|
+
JSON.stringify(conversations),
|
|
396
208
|
]);
|
|
397
209
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
unowned(connection);
|
|
402
|
-
return null;
|
|
403
|
-
}
|
|
404
|
-
function chatDraft(connection, { kept: drafts, dropped }) {
|
|
405
|
-
for (const conversation of dropped) {
|
|
406
|
-
connection.run('DELETE FROM authored_chat_drafts WHERE conversation = ?', [conversation]);
|
|
407
|
-
}
|
|
408
|
-
for (const { conversation, record } of drafts) {
|
|
409
|
-
connection.run('INSERT OR REPLACE INTO authored_chat_drafts (conversation, record) VALUES (?, ?)', [conversation, record]);
|
|
410
|
-
}
|
|
411
|
-
return null;
|
|
210
|
+
chatDraftsDropped(connection, conversations);
|
|
211
|
+
return held;
|
|
412
212
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
if (held === null)
|
|
416
|
-
connection.run('DELETE FROM authored_calls WHERE operation = ?', [operation]);
|
|
417
|
-
else {
|
|
418
|
-
connection.run('INSERT OR REPLACE INTO authored_calls (operation, record, files) VALUES (?, ?, ?)', [operation, held.record, owned(held.files)]);
|
|
419
|
-
}
|
|
420
|
-
unowned(connection);
|
|
421
|
-
return null;
|
|
422
|
-
}
|
|
423
|
-
function roomWork(connection, locator) {
|
|
424
|
-
connection.run('DELETE FROM authored_queues WHERE locator = ?', [locator]);
|
|
425
|
-
connection.run('DELETE FROM authored_pending WHERE locator = ?', [locator]);
|
|
213
|
+
function unopened(connection) {
|
|
214
|
+
connection.run(UNOPENED_PARTS);
|
|
426
215
|
}
|
|
427
216
|
function fence(connection, locators) {
|
|
217
|
+
fencedWork(connection, locators);
|
|
428
218
|
for (const locator of locators) {
|
|
429
|
-
connection.run('INSERT OR REPLACE INTO authored_fences (locator) VALUES (?)', [locator]);
|
|
430
|
-
roomWork(connection, locator);
|
|
431
|
-
connection.run('DELETE FROM authored_room_drafts WHERE locator = ?', [locator]);
|
|
432
219
|
connection.run('DELETE FROM opened_files WHERE locator = ?', [locator]);
|
|
433
220
|
}
|
|
434
|
-
|
|
221
|
+
unopened(connection);
|
|
435
222
|
return fenceRooms(connection, locators);
|
|
436
223
|
}
|
|
437
224
|
function erased(connection, { locator, limit }) {
|
|
438
225
|
return erase(connection, locator, limit);
|
|
439
226
|
}
|
|
440
|
-
function
|
|
227
|
+
function unfencedRooms(connection, locators) {
|
|
441
228
|
const erased = locators.filter((locator) => connection.rows('SELECT 1 FROM replica_erasing WHERE locator = ? LIMIT 1', [locator])
|
|
442
229
|
.length === 0);
|
|
443
|
-
|
|
444
|
-
connection.run('DELETE FROM authored_fences WHERE locator = ?', [locator]);
|
|
445
|
-
}
|
|
230
|
+
unfenced(connection, erased);
|
|
446
231
|
return erased;
|
|
447
232
|
}
|
|
448
|
-
function claim(connection, holder) {
|
|
449
|
-
const held = fact(connection, 'holder');
|
|
450
|
-
if (held !== null)
|
|
451
|
-
return held === holder;
|
|
452
|
-
remember(connection, 'holder', holder);
|
|
453
|
-
return true;
|
|
454
|
-
}
|
|
455
233
|
function end(connection, holder) {
|
|
456
234
|
ended(connection);
|
|
457
|
-
|
|
235
|
+
forgottenConversations(connection);
|
|
458
236
|
if (holder !== null && claim(connection, holder))
|
|
459
237
|
return true;
|
|
460
|
-
|
|
461
|
-
connection.run(`DELETE FROM ${table}`);
|
|
238
|
+
authoredEmptied(connection);
|
|
462
239
|
connection.run('DELETE FROM opened_files');
|
|
463
|
-
connection.run('DELETE FROM
|
|
240
|
+
connection.run('DELETE FROM opened_parts');
|
|
464
241
|
return false;
|
|
465
242
|
}
|
|
466
|
-
function count(value) {
|
|
467
|
-
return typeof value === 'bigint' ? Number(value) : typeof value === 'number' ? value : 0;
|
|
468
|
-
}
|
|
469
243
|
function openedFile(connection, { locator, path, revision }) {
|
|
470
244
|
const [held] = connection.rows('SELECT key, media_type, byte_length FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND byte_length IS NOT NULL', [locator, path, revision]);
|
|
471
245
|
return held === undefined
|
|
@@ -480,7 +254,7 @@ function opening(connection, { key, locator, path, revision, mediaType }) {
|
|
|
480
254
|
if (fenced(connection, locator))
|
|
481
255
|
return false;
|
|
482
256
|
connection.run('DELETE FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND byte_length IS NULL', [locator, path, revision]);
|
|
483
|
-
|
|
257
|
+
unopened(connection);
|
|
484
258
|
connection.run('INSERT INTO opened_files (key, locator, path, revision, media_type) VALUES (?, ?, ?, ?, ?)', [key, locator, path, revision, mediaType]);
|
|
485
259
|
return true;
|
|
486
260
|
}
|
|
@@ -493,19 +267,23 @@ function fetching(connection, key) {
|
|
|
493
267
|
function openedPart(connection, { key, part, bytes }) {
|
|
494
268
|
if (fetching(connection, key) === null)
|
|
495
269
|
return false;
|
|
496
|
-
|
|
270
|
+
connection.run('INSERT INTO opened_parts (key, part, bytes) VALUES (?, ?, ?)', [
|
|
271
|
+
key,
|
|
272
|
+
part,
|
|
273
|
+
bytes,
|
|
274
|
+
]);
|
|
497
275
|
return true;
|
|
498
276
|
}
|
|
499
277
|
function dropped(connection, key) {
|
|
500
278
|
connection.run('DELETE FROM opened_files WHERE key = ?', [key]);
|
|
501
|
-
connection.run('DELETE FROM
|
|
279
|
+
connection.run('DELETE FROM opened_parts WHERE key = ?', [key]);
|
|
502
280
|
return null;
|
|
503
281
|
}
|
|
504
282
|
function keptOpened(connection, { key, sha256, byteLength, parts }) {
|
|
505
283
|
const fetched = fetching(connection, key);
|
|
506
284
|
if (fetched === null)
|
|
507
285
|
return false;
|
|
508
|
-
const [held] = connection.rows('SELECT count(*) AS parts, min(part) AS first, max(part) AS last, coalesce(sum(length(bytes)), 0) AS bytes FROM
|
|
286
|
+
const [held] = connection.rows('SELECT count(*) AS parts, min(part) AS first, max(part) AS last, coalesce(sum(length(bytes)), 0) AS bytes FROM opened_parts WHERE key = ?', [key]);
|
|
509
287
|
const whole = count(held.parts) === parts &&
|
|
510
288
|
count(held.bytes) === byteLength &&
|
|
511
289
|
(parts === 0 || (count(held.first) === 0 && count(held.last) === parts - 1));
|
|
@@ -519,27 +297,24 @@ function keptOpened(connection, { key, sha256, byteLength, parts }) {
|
|
|
519
297
|
key,
|
|
520
298
|
]);
|
|
521
299
|
connection.run('DELETE FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND key <> ?', [fetched.locator, fetched.path, fetched.revision, key]);
|
|
522
|
-
|
|
300
|
+
unopened(connection);
|
|
523
301
|
return true;
|
|
524
302
|
}
|
|
525
|
-
|
|
526
|
-
['
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
function unsent(connection) {
|
|
532
|
-
const [held] = connection.rows(`SELECT ${UNSENT.map(([kind, table]) => `(SELECT count(*) FROM ${table}) AS "${kind}"`).join(', ')}`);
|
|
533
|
-
return UNSENT.map(([kind]) => ({ kind, count: count(held[kind]) })).filter((work) => work.count > 0);
|
|
303
|
+
function heldPart(connection, key, part) {
|
|
304
|
+
const [held] = connection.rows('SELECT bytes FROM opened_parts WHERE key = ? AND part = ?', [
|
|
305
|
+
key,
|
|
306
|
+
part,
|
|
307
|
+
]);
|
|
308
|
+
return held?.bytes instanceof Uint8Array ? held.bytes : authoredPart(connection, key, part);
|
|
534
309
|
}
|
|
535
310
|
function cleanable(connection) {
|
|
536
|
-
const [held] = connection.rows(
|
|
311
|
+
const [held] = connection.rows('SELECT coalesce(sum(length(bytes)), 0) AS bytes FROM opened_parts');
|
|
537
312
|
return count(held.bytes);
|
|
538
313
|
}
|
|
539
314
|
function cleaned(connection) {
|
|
540
315
|
connection.run('DELETE FROM opened_files');
|
|
541
316
|
const freed = cleanable(connection);
|
|
542
|
-
|
|
317
|
+
unopened(connection);
|
|
543
318
|
return freed;
|
|
544
319
|
}
|
|
545
320
|
function openedHeld(connection) {
|
|
@@ -565,51 +340,39 @@ export function answerRuntime(connection, request, spool) {
|
|
|
565
340
|
case 'authored.status':
|
|
566
341
|
return status(connection);
|
|
567
342
|
case 'authored.moving':
|
|
568
|
-
return
|
|
569
|
-
queues: queued(connection),
|
|
570
|
-
pending: connection
|
|
571
|
-
.rows('SELECT locator, id, batch, state FROM authored_pending WHERE moving = 1 ORDER BY locator')
|
|
572
|
-
.map((row) => ({
|
|
573
|
-
locator: text(row.locator),
|
|
574
|
-
id: text(row.id),
|
|
575
|
-
batch: text(row.batch),
|
|
576
|
-
state: text(row.state),
|
|
577
|
-
})),
|
|
578
|
-
};
|
|
343
|
+
return moving(connection);
|
|
579
344
|
case 'authored.pending':
|
|
580
345
|
return pendingOf(connection, request.locator, request.id);
|
|
581
|
-
case 'authored.batch':
|
|
582
|
-
|
|
583
|
-
return held === undefined ? null : text(held.batch);
|
|
584
|
-
}
|
|
346
|
+
case 'authored.batch':
|
|
347
|
+
return pendingBatch(connection, request.locator, request.id);
|
|
585
348
|
case 'authored.order':
|
|
586
349
|
return heldOrder(connection, request.locator);
|
|
587
350
|
case 'authored.queued':
|
|
588
|
-
return
|
|
351
|
+
return queuedLocators(connection);
|
|
589
352
|
case 'authored.roomDrafts':
|
|
590
353
|
return roomDraftRecords(connection, request.locator, request.paths);
|
|
591
354
|
case 'authored.chatDraft.read':
|
|
592
355
|
return chatDraftRecord(connection, request.conversation);
|
|
593
356
|
case 'authored.chatDrafts':
|
|
594
|
-
return
|
|
357
|
+
return chatDraftRecords(connection);
|
|
595
358
|
case 'authored.calls':
|
|
596
|
-
return
|
|
359
|
+
return callRecords(connection);
|
|
597
360
|
case 'authored.fences':
|
|
598
|
-
return
|
|
361
|
+
return fences(connection);
|
|
599
362
|
case 'authored.unsent':
|
|
600
363
|
return unsent(connection);
|
|
601
364
|
case 'authored.fact':
|
|
602
365
|
return fact(connection, request.name);
|
|
603
366
|
case 'authored.file':
|
|
604
|
-
return spooled(connection, spool, request);
|
|
367
|
+
return spooled(connection, spool, request.key, request.type);
|
|
605
368
|
case 'authored.amend':
|
|
606
|
-
return amended(connection, request);
|
|
369
|
+
return amended(connection, request.locator, request.id, request.amendment);
|
|
607
370
|
case 'authored.roomDraft':
|
|
608
|
-
return roomDraft(connection, request);
|
|
371
|
+
return roomDraft(connection, request.locator, request.path, request.kept, request.files);
|
|
609
372
|
case 'authored.chatDraft':
|
|
610
|
-
return chatDraft(connection, request);
|
|
373
|
+
return chatDraft(connection, request.kept, request.dropped);
|
|
611
374
|
case 'authored.call':
|
|
612
|
-
return call(connection, request);
|
|
375
|
+
return call(connection, request.operation, request.kept, request.files);
|
|
613
376
|
case 'authored.remember':
|
|
614
377
|
return remember(connection, request.name, request.value);
|
|
615
378
|
case 'authored.claim':
|
|
@@ -623,22 +386,24 @@ export function answerRuntime(connection, request, spool) {
|
|
|
623
386
|
case 'replica.room':
|
|
624
387
|
return heldWork(connection, request.locator);
|
|
625
388
|
case 'replica.covering':
|
|
626
|
-
return {
|
|
627
|
-
rooms: covering(connection),
|
|
628
|
-
queues: queued(connection),
|
|
629
|
-
};
|
|
389
|
+
return { ...covering(connection, request.since), queues: queues(connection) };
|
|
630
390
|
case 'replica.offline':
|
|
631
391
|
return offlineMode(connection, request.locator);
|
|
632
392
|
case 'replica.held':
|
|
633
|
-
return {
|
|
393
|
+
return {
|
|
394
|
+
held: [...new Set([...heldLocators(connection), ...authoredLocators(connection)])],
|
|
395
|
+
staged: stagedLocators(connection),
|
|
396
|
+
};
|
|
634
397
|
case 'replica.demote':
|
|
635
398
|
return demoted(connection);
|
|
636
399
|
case 'replica.facts':
|
|
637
|
-
return facts(connection);
|
|
400
|
+
return facts(connection, request.names);
|
|
638
401
|
case 'replica.presentation':
|
|
639
402
|
return presentation(connection, request.app);
|
|
640
403
|
case 'replica.query':
|
|
641
|
-
return answerQuery(connection, request.plan, request.rooms, request.budget);
|
|
404
|
+
return answerQuery(connection, request.plan, request.rooms, request.budget, request.follows);
|
|
405
|
+
case 'replica.named':
|
|
406
|
+
return namedHandles(connection, request.plan, request.rooms, request.handles);
|
|
642
407
|
case 'replica.tallies':
|
|
643
408
|
return roomTallies(connection, request.totals, request.rooms, request.since);
|
|
644
409
|
case 'replica.entries':
|
|
@@ -647,6 +412,8 @@ export function answerRuntime(connection, request, spool) {
|
|
|
647
412
|
return typed(connection, request.key, request.view, request.paths);
|
|
648
413
|
case 'replica.referrers':
|
|
649
414
|
return referrers(connection, request.key, request.view, request.targets);
|
|
415
|
+
case 'replica.holders':
|
|
416
|
+
return holders(connection, request.key, request.view, request.sought);
|
|
650
417
|
case 'replica.folders':
|
|
651
418
|
return folders(connection, request.key, request.paths);
|
|
652
419
|
case 'replica.typedWithin':
|
|
@@ -668,7 +435,7 @@ export function answerRuntime(connection, request, spool) {
|
|
|
668
435
|
case 'replica.abandon':
|
|
669
436
|
return abandon(connection, request.locator);
|
|
670
437
|
case 'replica.unfence':
|
|
671
|
-
return
|
|
438
|
+
return unfencedRooms(connection, request.locators);
|
|
672
439
|
case 'replica.release':
|
|
673
440
|
return release(connection, request.key);
|
|
674
441
|
case 'replica.rederive':
|
|
@@ -700,7 +467,7 @@ export function answerRuntime(connection, request, spool) {
|
|
|
700
467
|
case 'opened.held':
|
|
701
468
|
return openedHeld(connection);
|
|
702
469
|
case 'file.part':
|
|
703
|
-
return
|
|
470
|
+
return heldPart(connection, request.key, request.part);
|
|
704
471
|
case 'conversation.held':
|
|
705
472
|
return heldConversations(connection, request.conversations);
|
|
706
473
|
case 'conversation.keep': {
|
|
@@ -717,14 +484,16 @@ export function answerRuntime(connection, request, spool) {
|
|
|
717
484
|
return conversationRows(connection, request.conversations);
|
|
718
485
|
case 'conversation.tallies':
|
|
719
486
|
return conversationTallies(connection, request.conversations, request.since);
|
|
487
|
+
case 'conversation.facts':
|
|
488
|
+
return conversationFacts(connection);
|
|
489
|
+
case 'conversation.fact': {
|
|
490
|
+
const { kind: _kind, ...fact } = request;
|
|
491
|
+
return keptFact(connection, fact);
|
|
492
|
+
}
|
|
493
|
+
case 'conversation.stored':
|
|
494
|
+
return storedConversations(connection, null);
|
|
720
495
|
case 'conversation.drop':
|
|
721
|
-
|
|
722
|
-
kind: 'authored.chatDraft',
|
|
723
|
-
kept: [],
|
|
724
|
-
dropped: request.conversations,
|
|
725
|
-
});
|
|
726
|
-
droppedMessages(connection, request.conversations);
|
|
727
|
-
return null;
|
|
496
|
+
return droppedConversations(connection, request.conversations);
|
|
728
497
|
case 'space.probe':
|
|
729
498
|
return spool.probe(PROBE_BYTES).then(() => null);
|
|
730
499
|
case 'read.stored':
|
package/dist/tallies.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tallies.d.ts","sourceRoot":"","sources":["../src/tallies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tallies.d.ts","sourceRoot":"","sources":["../src/tallies.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAI1D,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC;IAC7E,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAmHpG,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,KAAK,EAAE,MAAM,GACZ,SAAS,EAAE,CAwBb;AA0BD,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,EACvC,KAAK,EAAE,MAAM,GACZ,iBAAiB,EAAE,CAerB"}
|
package/dist/tallies.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { instantKey, sql } from '@agentshouse/mdmodel';
|
|
2
|
-
import { CHAT_MESSAGE_TYPE, CHAT_TYPE } from './chat-types.js';
|
|
1
|
+
import { CHAT_MESSAGE_TYPE, CHAT_TYPE, instantKey, sql } from '@agentshouse/mdmodel';
|
|
3
2
|
import { answerQuery, VISIBLE, within } from './compile.js';
|
|
4
3
|
import { HOUSE_DIRECTORY } from './figures.js';
|
|
5
4
|
const NONE = { count: 0, size: 0 };
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Validation } from '@agentshouse/mdmodel';
|
|
2
2
|
import { type Composition } from './collection.js';
|
|
3
|
+
import type { Holder, Sought } from './stored.js';
|
|
3
4
|
type Examined = {
|
|
4
5
|
readonly path: string;
|
|
5
6
|
readonly content: string | null;
|
|
@@ -23,6 +24,7 @@ type Neighbourhood = {
|
|
|
23
24
|
readonly lookup: Lookup;
|
|
24
25
|
readonly texts: (paths: readonly string[]) => Promise<ReadonlyMap<string, string | null>>;
|
|
25
26
|
readonly referrers: (targets: readonly string[]) => Promise<readonly string[]>;
|
|
27
|
+
readonly holders: (sought: readonly Sought[]) => Promise<readonly Holder[]>;
|
|
26
28
|
};
|
|
27
29
|
export declare function validatedNeighbourhood(changes: readonly Changed[], composition: Composition, source: Neighbourhood): Promise<Validation>;
|
|
28
30
|
export {};
|