@agentshouse/mdruntime 0.1.0-c835af48a82d3 → 0.1.0-c83bc1fac9b35
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 +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +299 -0
- 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 +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +321 -0
- package/dist/adapter.d.ts +115 -57
- 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 +0 -5
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- 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 +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +7 -2
- package/dist/chat-types.d.ts +2 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +11 -2
- package/dist/client.d.ts +26 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +45 -58
- package/dist/collection.d.ts +26 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +28 -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 +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +31 -25
- package/dist/connection.d.ts +5 -149
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +112 -5364
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +152 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +261 -0
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +22 -3
- package/dist/conversation.d.ts +57 -45
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +977 -1031
- 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 +12 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- 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 +14 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +5 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +23 -12
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +8 -0
- package/dist/figures.d.ts +1 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +24 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +87 -20
- package/dist/house-query.d.ts +21 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +41 -0
- package/dist/index.d.ts +30 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -6
- package/dist/install.d.ts +60 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +290 -0
- package/dist/listing.d.ts +60 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +168 -0
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +74 -33
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +34 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- package/dist/media.d.ts +19 -2
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +105 -27
- package/dist/memory.d.ts +9 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +94 -32
- package/dist/messages.d.ts +12 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +35 -39
- 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 +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +217 -85
- 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 +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +69 -0
- package/dist/outcome.d.ts +16 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +32 -2
- package/dist/overlay.d.ts +6 -2
- 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 +5 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +28 -110
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +45 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +335 -0
- 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 +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +287 -0
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +3 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +4 -6
- 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 -5
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +164 -33
- package/dist/react.d.ts +18 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +16 -5
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +10 -10
- package/dist/reads.d.ts +6 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +61 -11
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +5 -13
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +17 -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 +31 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +273 -66
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +220 -0
- 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 +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +9 -10
- 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 +35 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +326 -225
- package/dist/saves.d.ts +34 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +437 -0
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +35 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +326 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +41 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +26 -0
- package/dist/socket.d.ts +68 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +165 -0
- package/dist/source.d.ts +5 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +18 -6
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +40 -0
- package/dist/store/readiness.d.ts +11 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +68 -0
- package/dist/store/records.d.ts +227 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +468 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- 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/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +119 -204
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +170 -394
- package/dist/stored.d.ts +26 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +101 -36
- package/dist/surface.d.ts +94 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +255 -0
- package/dist/sync.d.ts +21 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +557 -0
- package/dist/tables.d.ts +28 -59
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +106 -331
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +4 -10
- package/dist/wire.d.ts +68 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +26 -9
- package/package.json +3 -2
- 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 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/tables.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { sql } from '@agentshouse/mdmodel';
|
|
2
2
|
import { answerQuery } from './compile.js';
|
|
3
|
-
import {
|
|
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, offlineMode, opened, overlaid, presentation, rederive, referrers, refreshing, REPLICA_TABLES, resume, stage, typed, stagedLocators, tablesOf, typedWithin, unrefresh, } from './stored.js';
|
|
9
|
+
export { authoredEmptied, authoredTable, FILE_PART_BYTES, formatted, heldTables, } from './authored.js';
|
|
7
10
|
const STATEMENTS_HELD = 256;
|
|
8
11
|
export function sqliteConnection(engine, database) {
|
|
9
12
|
const decoder = new TextDecoder();
|
|
@@ -71,35 +74,16 @@ export function sqliteConnection(engine, database) {
|
|
|
71
74
|
},
|
|
72
75
|
};
|
|
73
76
|
}
|
|
74
|
-
export const FILE_PART_BYTES = 1_048_576;
|
|
75
77
|
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
78
|
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
79
|
'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
80
|
'CREATE INDEX opened_files_name ON opened_files (locator, path, revision)',
|
|
81
|
+
'CREATE TABLE opened_parts (key TEXT NOT NULL, part INTEGER NOT NULL, bytes BLOB NOT NULL, PRIMARY KEY (key, part))',
|
|
96
82
|
...REPLICA_TABLES,
|
|
97
83
|
...MESSAGE_TABLES,
|
|
98
84
|
...READ_TABLES,
|
|
99
85
|
];
|
|
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)`;
|
|
86
|
+
const UNOPENED_PARTS = 'DELETE FROM opened_parts WHERE key NOT IN (SELECT key FROM opened_files)';
|
|
103
87
|
const READS = new Set([
|
|
104
88
|
'authored.status',
|
|
105
89
|
'authored.moving',
|
|
@@ -131,14 +115,16 @@ const READS = new Set([
|
|
|
131
115
|
'replica.folders',
|
|
132
116
|
'replica.typedWithin',
|
|
133
117
|
'opened.find',
|
|
118
|
+
'opened.held',
|
|
134
119
|
'file.part',
|
|
135
120
|
'conversation.held',
|
|
136
121
|
'conversation.window',
|
|
137
122
|
'conversation.count',
|
|
138
123
|
'conversation.turn',
|
|
139
124
|
'conversation.rows',
|
|
140
|
-
'conversation.jobs',
|
|
141
125
|
'conversation.tallies',
|
|
126
|
+
'conversation.facts',
|
|
127
|
+
'conversation.stored',
|
|
142
128
|
'read.stored',
|
|
143
129
|
]);
|
|
144
130
|
const KINDS = new Set([
|
|
@@ -170,6 +156,7 @@ const KINDS = new Set([
|
|
|
170
156
|
'opened.drop',
|
|
171
157
|
'opened.clean',
|
|
172
158
|
'conversation.keep',
|
|
159
|
+
'conversation.fact',
|
|
173
160
|
'conversation.drop',
|
|
174
161
|
'space.probe',
|
|
175
162
|
'read.keep',
|
|
@@ -181,290 +168,75 @@ export function isRuntime(request) {
|
|
|
181
168
|
export function readsRuntime(request) {
|
|
182
169
|
return READS.has(request.kind);
|
|
183
170
|
}
|
|
184
|
-
function text(value) {
|
|
185
|
-
return typeof value === 'string' ? value : String(value);
|
|
186
|
-
}
|
|
187
|
-
function texts(rows, column) {
|
|
188
|
-
return rows.map((row) => text(row[column]));
|
|
189
|
-
}
|
|
190
|
-
function owned(files) {
|
|
191
|
-
return JSON.stringify([...new Set(files)]);
|
|
192
|
-
}
|
|
193
|
-
function fact(connection, name) {
|
|
194
|
-
const [held] = connection.rows('SELECT value FROM authored_facts WHERE name = ?', [name]);
|
|
195
|
-
return held === undefined ? null : text(held.value);
|
|
196
|
-
}
|
|
197
|
-
function remember(connection, name, value) {
|
|
198
|
-
connection.run('INSERT OR REPLACE INTO authored_facts (name, value) VALUES (?, ?)', [
|
|
199
|
-
name,
|
|
200
|
-
value,
|
|
201
|
-
]);
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
function fenced(connection, locator) {
|
|
205
|
-
return connection.rows('SELECT 1 FROM authored_fences WHERE locator = ?', [locator]).length > 0;
|
|
206
|
-
}
|
|
207
|
-
function stored(connection, key) {
|
|
208
|
-
return connection.rows('SELECT 1 FROM file_parts WHERE key = ? LIMIT 1', [key]).length > 0;
|
|
209
|
-
}
|
|
210
|
-
function storedPart(connection, key, part, bytes) {
|
|
211
|
-
connection.run('INSERT INTO file_parts (key, part, bytes) VALUES (?, ?, ?)', [key, part, bytes]);
|
|
212
|
-
}
|
|
213
|
-
async function storedFiles(connection, files) {
|
|
214
|
-
for (const { key, blob } of files) {
|
|
215
|
-
if (stored(connection, key))
|
|
216
|
-
continue;
|
|
217
|
-
for (let at = 0, part = 0; at < blob.size; at += FILE_PART_BYTES, part += 1) {
|
|
218
|
-
const bytes = new Uint8Array(await blob.slice(at, at + FILE_PART_BYTES).arrayBuffer());
|
|
219
|
-
storedPart(connection, key, part, bytes);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
function filePart(connection, key, part) {
|
|
224
|
-
const [held] = connection.rows('SELECT bytes FROM file_parts WHERE key = ? AND part = ?', [
|
|
225
|
-
key,
|
|
226
|
-
part,
|
|
227
|
-
]);
|
|
228
|
-
return held?.bytes instanceof Uint8Array ? held.bytes : null;
|
|
229
|
-
}
|
|
230
|
-
function* fileParts(connection, key) {
|
|
231
|
-
for (let part = 0;; part += 1) {
|
|
232
|
-
const bytes = filePart(connection, key, part);
|
|
233
|
-
if (bytes === null)
|
|
234
|
-
return;
|
|
235
|
-
yield bytes;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
async function spooled(connection, spool, { key, type }) {
|
|
239
|
-
for (const held of [...spool.held()]) {
|
|
240
|
-
if (held !== key && !stored(connection, held))
|
|
241
|
-
await spool.drop(held);
|
|
242
|
-
}
|
|
243
|
-
return spool.spool(key, type, fileParts(connection, key));
|
|
244
|
-
}
|
|
245
|
-
function unowned(connection) {
|
|
246
|
-
connection.run(UNOWNED_PARTS);
|
|
247
|
-
}
|
|
248
|
-
function queued(connection) {
|
|
249
|
-
return connection.rows('SELECT locator, ids FROM authored_queues').map((row) => ({
|
|
250
|
-
locator: text(row.locator),
|
|
251
|
-
ids: JSON.parse(text(row.ids)),
|
|
252
|
-
}));
|
|
253
|
-
}
|
|
254
171
|
function heldWork(connection, locator) {
|
|
255
172
|
const room = heldRoom(connection, locator);
|
|
256
|
-
const pending = new Map(connection
|
|
257
|
-
.rows('SELECT id, batch, state FROM authored_pending WHERE locator = ?', [locator])
|
|
258
|
-
.map((row) => [
|
|
259
|
-
text(row.id),
|
|
260
|
-
{ id: text(row.id), batch: text(row.batch), state: text(row.state) },
|
|
261
|
-
]));
|
|
262
173
|
return {
|
|
263
174
|
room: room === null ? null : { ...room, overlaid: overlaid(connection, room.key) },
|
|
264
|
-
queue:
|
|
265
|
-
const held = pending.get(id);
|
|
266
|
-
if (held === undefined)
|
|
267
|
-
throw new Error(`Missing Pending Change ${locator}/${id}`);
|
|
268
|
-
return held;
|
|
269
|
-
}),
|
|
175
|
+
queue: queueOf(connection, locator),
|
|
270
176
|
};
|
|
271
177
|
}
|
|
272
178
|
function status(connection) {
|
|
273
|
-
const [completed] = connection.rows("SELECT value FROM replica_facts WHERE name = 'lastCompleted'");
|
|
274
179
|
return {
|
|
275
|
-
|
|
276
|
-
lastCompleted:
|
|
277
|
-
changes: connection
|
|
278
|
-
.rows('SELECT p.locator, c.value AS path FROM authored_pending p, json_each(p.paths) c')
|
|
279
|
-
.map((row) => ({ locator: text(row.locator), path: text(row.path) })),
|
|
280
|
-
resets: connection
|
|
281
|
-
.rows(`SELECT locator, json_extract(state, '$.submission.reset') AS reset FROM authored_pending
|
|
282
|
-
WHERE json_extract(state, '$.submission.state') = 'reset'`)
|
|
283
|
-
.map((row) => ({ locator: text(row.locator), reset: text(row.reset) })),
|
|
284
|
-
returned: texts(connection.rows(`SELECT record FROM authored_room_drafts WHERE json_type(record, '$.returned') = 'object'`), 'record'),
|
|
180
|
+
...unsentStatus(connection),
|
|
181
|
+
lastCompleted: facts(connection, ['lastCompleted']).lastCompleted ?? null,
|
|
285
182
|
};
|
|
286
183
|
}
|
|
287
184
|
function pendingOf(connection, locator, id) {
|
|
288
|
-
const [held] = connection.rows('SELECT state FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
289
185
|
return {
|
|
290
|
-
state:
|
|
186
|
+
state: pendingState(connection, locator, id),
|
|
291
187
|
room: connection.rows('SELECT 1 FROM replica_rooms WHERE locator = ?', [locator]).length > 0,
|
|
292
188
|
};
|
|
293
189
|
}
|
|
294
|
-
function
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
function heldOrder(connection, locator) {
|
|
310
|
-
const [held] = connection.rows('SELECT ids FROM authored_queues WHERE locator = ?', [locator]);
|
|
311
|
-
return held === undefined ? [] : JSON.parse(text(held.ids));
|
|
312
|
-
}
|
|
313
|
-
function keptRows(connection, { locator, order, added, founded, roomDrafts, consumedRoomDrafts }) {
|
|
314
|
-
for (const path of consumedRoomDrafts ?? []) {
|
|
315
|
-
connection.run('DELETE FROM authored_room_drafts WHERE locator = ? AND path = ?', [
|
|
316
|
-
locator,
|
|
317
|
-
path,
|
|
318
|
-
]);
|
|
319
|
-
}
|
|
320
|
-
for (const { path, record, files } of roomDrafts ?? []) {
|
|
321
|
-
connection.run('INSERT OR REPLACE INTO authored_room_drafts (locator, path, record, files) VALUES (?, ?, ?, ?)', [locator, path, record, owned(files)]);
|
|
322
|
-
}
|
|
323
|
-
if (order === undefined)
|
|
324
|
-
return;
|
|
325
|
-
const before = new Set(heldOrder(connection, locator));
|
|
326
|
-
const after = new Set(order);
|
|
327
|
-
if (after.size === 0)
|
|
328
|
-
connection.run('DELETE FROM authored_queues WHERE locator = ?', [locator]);
|
|
329
|
-
else {
|
|
330
|
-
connection.run('INSERT OR REPLACE INTO authored_queues (locator, ids) VALUES (?, ?)', [
|
|
331
|
-
locator,
|
|
332
|
-
JSON.stringify([...after]),
|
|
333
|
-
]);
|
|
334
|
-
}
|
|
335
|
-
for (const id of before) {
|
|
336
|
-
if (!after.has(id)) {
|
|
337
|
-
connection.run('DELETE FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
for (const { id, batch, state, files, paths, moving } of added ?? []) {
|
|
341
|
-
if (before.has(id) || !after.has(id))
|
|
342
|
-
continue;
|
|
343
|
-
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]);
|
|
344
|
-
}
|
|
345
|
-
for (const { id, batch, files, paths, moving } of founded ?? []) {
|
|
346
|
-
const [held] = connection.rows('SELECT files FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
347
|
-
if (held === undefined || !before.has(id))
|
|
348
|
-
continue;
|
|
349
|
-
connection.run('UPDATE authored_pending SET batch = ?, files = ?, paths = ?, moving = ? WHERE locator = ? AND id = ?', [
|
|
350
|
-
batch,
|
|
351
|
-
owned([...JSON.parse(text(held.files)), ...files]),
|
|
352
|
-
JSON.stringify(paths),
|
|
353
|
-
moving ? 1 : 0,
|
|
354
|
-
locator,
|
|
355
|
-
id,
|
|
356
|
-
]);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
async function kept(connection, { writes, files, whole }) {
|
|
360
|
-
const refused = writes.find(({ locator }) => fenced(connection, locator));
|
|
361
|
-
if (refused !== undefined && whole)
|
|
362
|
-
return refused.locator;
|
|
363
|
-
await storedFiles(connection, files);
|
|
364
|
-
for (const write of writes) {
|
|
365
|
-
if (!fenced(connection, write.locator))
|
|
366
|
-
keptRows(connection, write);
|
|
367
|
-
}
|
|
368
|
-
unowned(connection);
|
|
369
|
-
return refused?.locator ?? null;
|
|
370
|
-
}
|
|
371
|
-
function amended(connection, { locator, id, amendment }) {
|
|
372
|
-
if (fenced(connection, locator))
|
|
373
|
-
return null;
|
|
374
|
-
const [held] = connection.rows('SELECT state FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
375
|
-
if (held === undefined)
|
|
376
|
-
return null;
|
|
377
|
-
connection.run('UPDATE authored_pending SET state = ? WHERE locator = ? AND id = ?', [
|
|
378
|
-
JSON.stringify({
|
|
379
|
-
...JSON.parse(text(held.state)),
|
|
380
|
-
...JSON.parse(amendment),
|
|
381
|
-
}),
|
|
382
|
-
locator,
|
|
383
|
-
id,
|
|
384
|
-
]);
|
|
385
|
-
return null;
|
|
386
|
-
}
|
|
387
|
-
async function roomDraft(connection, { locator, path, kept: draft, files }) {
|
|
388
|
-
if (fenced(connection, locator))
|
|
389
|
-
return locator;
|
|
390
|
-
await storedFiles(connection, files);
|
|
391
|
-
if (draft === null) {
|
|
392
|
-
connection.run('DELETE FROM authored_room_drafts WHERE locator = ? AND path = ?', [
|
|
393
|
-
locator,
|
|
394
|
-
path,
|
|
190
|
+
function storedConversations(connection, conversations) {
|
|
191
|
+
const named = conversations === null ? '' : ' WHERE conversation IN (SELECT value FROM json_each(?))';
|
|
192
|
+
const bound = conversations === null ? [] : [JSON.stringify(conversations)];
|
|
193
|
+
return [
|
|
194
|
+
...new Set([
|
|
195
|
+
...tablesOf(MESSAGE_TABLES).flatMap((table) => texts(connection.rows(`SELECT DISTINCT conversation FROM ${table}${named}`, bound), 'conversation')),
|
|
196
|
+
...chatDraftConversations(connection, conversations),
|
|
197
|
+
]),
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
function droppedConversations(connection, conversations) {
|
|
201
|
+
const held = storedConversations(connection, conversations);
|
|
202
|
+
for (const table of tablesOf(MESSAGE_TABLES)) {
|
|
203
|
+
connection.run(`DELETE FROM ${table} WHERE conversation IN (SELECT value FROM json_each(?))`, [
|
|
204
|
+
JSON.stringify(conversations),
|
|
395
205
|
]);
|
|
396
206
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
400
|
-
unowned(connection);
|
|
401
|
-
return null;
|
|
207
|
+
chatDraftsDropped(connection, conversations);
|
|
208
|
+
return held;
|
|
402
209
|
}
|
|
403
|
-
function
|
|
404
|
-
|
|
405
|
-
connection.run('DELETE FROM authored_chat_drafts WHERE conversation = ?', [conversation]);
|
|
406
|
-
}
|
|
407
|
-
for (const { conversation, record } of drafts) {
|
|
408
|
-
connection.run('INSERT OR REPLACE INTO authored_chat_drafts (conversation, record) VALUES (?, ?)', [conversation, record]);
|
|
409
|
-
}
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
async function call(connection, { operation, kept: held, files }) {
|
|
413
|
-
await storedFiles(connection, files);
|
|
414
|
-
if (held === null)
|
|
415
|
-
connection.run('DELETE FROM authored_calls WHERE operation = ?', [operation]);
|
|
416
|
-
else {
|
|
417
|
-
connection.run('INSERT OR REPLACE INTO authored_calls (operation, record, files) VALUES (?, ?, ?)', [operation, held.record, owned(held.files)]);
|
|
418
|
-
}
|
|
419
|
-
unowned(connection);
|
|
420
|
-
return null;
|
|
421
|
-
}
|
|
422
|
-
function roomWork(connection, locator) {
|
|
423
|
-
connection.run('DELETE FROM authored_queues WHERE locator = ?', [locator]);
|
|
424
|
-
connection.run('DELETE FROM authored_pending WHERE locator = ?', [locator]);
|
|
210
|
+
function unopened(connection) {
|
|
211
|
+
connection.run(UNOPENED_PARTS);
|
|
425
212
|
}
|
|
426
213
|
function fence(connection, locators) {
|
|
214
|
+
fencedWork(connection, locators);
|
|
427
215
|
for (const locator of locators) {
|
|
428
|
-
connection.run('INSERT OR REPLACE INTO authored_fences (locator) VALUES (?)', [locator]);
|
|
429
|
-
roomWork(connection, locator);
|
|
430
|
-
connection.run('DELETE FROM authored_room_drafts WHERE locator = ?', [locator]);
|
|
431
216
|
connection.run('DELETE FROM opened_files WHERE locator = ?', [locator]);
|
|
432
217
|
}
|
|
433
|
-
|
|
218
|
+
unopened(connection);
|
|
434
219
|
return fenceRooms(connection, locators);
|
|
435
220
|
}
|
|
436
221
|
function erased(connection, { locator, limit }) {
|
|
437
222
|
return erase(connection, locator, limit);
|
|
438
223
|
}
|
|
439
|
-
function
|
|
224
|
+
function unfencedRooms(connection, locators) {
|
|
440
225
|
const erased = locators.filter((locator) => connection.rows('SELECT 1 FROM replica_erasing WHERE locator = ? LIMIT 1', [locator])
|
|
441
226
|
.length === 0);
|
|
442
|
-
|
|
443
|
-
connection.run('DELETE FROM authored_fences WHERE locator = ?', [locator]);
|
|
444
|
-
}
|
|
227
|
+
unfenced(connection, erased);
|
|
445
228
|
return erased;
|
|
446
229
|
}
|
|
447
|
-
function claim(connection, holder) {
|
|
448
|
-
const held = fact(connection, 'holder');
|
|
449
|
-
if (held !== null)
|
|
450
|
-
return held === holder;
|
|
451
|
-
remember(connection, 'holder', holder);
|
|
452
|
-
return true;
|
|
453
|
-
}
|
|
454
230
|
function end(connection, holder) {
|
|
455
231
|
ended(connection);
|
|
456
|
-
|
|
232
|
+
forgottenConversations(connection);
|
|
457
233
|
if (holder !== null && claim(connection, holder))
|
|
458
234
|
return true;
|
|
459
|
-
|
|
460
|
-
connection.run(`DELETE FROM ${table}`);
|
|
235
|
+
authoredEmptied(connection);
|
|
461
236
|
connection.run('DELETE FROM opened_files');
|
|
462
|
-
connection.run('DELETE FROM
|
|
237
|
+
connection.run('DELETE FROM opened_parts');
|
|
463
238
|
return false;
|
|
464
239
|
}
|
|
465
|
-
function count(value) {
|
|
466
|
-
return typeof value === 'bigint' ? Number(value) : typeof value === 'number' ? value : 0;
|
|
467
|
-
}
|
|
468
240
|
function openedFile(connection, { locator, path, revision }) {
|
|
469
241
|
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]);
|
|
470
242
|
return held === undefined
|
|
@@ -479,7 +251,7 @@ function opening(connection, { key, locator, path, revision, mediaType }) {
|
|
|
479
251
|
if (fenced(connection, locator))
|
|
480
252
|
return false;
|
|
481
253
|
connection.run('DELETE FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND byte_length IS NULL', [locator, path, revision]);
|
|
482
|
-
|
|
254
|
+
unopened(connection);
|
|
483
255
|
connection.run('INSERT INTO opened_files (key, locator, path, revision, media_type) VALUES (?, ?, ?, ?, ?)', [key, locator, path, revision, mediaType]);
|
|
484
256
|
return true;
|
|
485
257
|
}
|
|
@@ -492,22 +264,26 @@ function fetching(connection, key) {
|
|
|
492
264
|
function openedPart(connection, { key, part, bytes }) {
|
|
493
265
|
if (fetching(connection, key) === null)
|
|
494
266
|
return false;
|
|
495
|
-
|
|
267
|
+
connection.run('INSERT INTO opened_parts (key, part, bytes) VALUES (?, ?, ?)', [
|
|
268
|
+
key,
|
|
269
|
+
part,
|
|
270
|
+
bytes,
|
|
271
|
+
]);
|
|
496
272
|
return true;
|
|
497
273
|
}
|
|
498
274
|
function dropped(connection, key) {
|
|
499
275
|
connection.run('DELETE FROM opened_files WHERE key = ?', [key]);
|
|
500
|
-
connection.run('DELETE FROM
|
|
276
|
+
connection.run('DELETE FROM opened_parts WHERE key = ?', [key]);
|
|
501
277
|
return null;
|
|
502
278
|
}
|
|
503
279
|
function keptOpened(connection, { key, sha256, byteLength, parts }) {
|
|
504
280
|
const fetched = fetching(connection, key);
|
|
505
281
|
if (fetched === null)
|
|
506
282
|
return false;
|
|
507
|
-
const [held] = connection.rows('SELECT count(*) AS parts, min(part) AS first, max(part) AS last, coalesce(sum(length(bytes)), 0) AS bytes FROM
|
|
508
|
-
const whole = count(held
|
|
509
|
-
count(held
|
|
510
|
-
(parts === 0 || (count(held
|
|
283
|
+
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]);
|
|
284
|
+
const whole = count(held.parts) === parts &&
|
|
285
|
+
count(held.bytes) === byteLength &&
|
|
286
|
+
(parts === 0 || (count(held.first) === 0 && count(held.last) === parts - 1));
|
|
511
287
|
if (!whole) {
|
|
512
288
|
dropped(connection, key);
|
|
513
289
|
return false;
|
|
@@ -518,24 +294,33 @@ function keptOpened(connection, { key, sha256, byteLength, parts }) {
|
|
|
518
294
|
key,
|
|
519
295
|
]);
|
|
520
296
|
connection.run('DELETE FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND key <> ?', [fetched.locator, fetched.path, fetched.revision, key]);
|
|
521
|
-
|
|
297
|
+
unopened(connection);
|
|
522
298
|
return true;
|
|
523
299
|
}
|
|
524
|
-
|
|
525
|
-
['
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
300
|
+
function heldPart(connection, key, part) {
|
|
301
|
+
const [held] = connection.rows('SELECT bytes FROM opened_parts WHERE key = ? AND part = ?', [
|
|
302
|
+
key,
|
|
303
|
+
part,
|
|
304
|
+
]);
|
|
305
|
+
return held?.bytes instanceof Uint8Array ? held.bytes : authoredPart(connection, key, part);
|
|
306
|
+
}
|
|
307
|
+
function cleanable(connection) {
|
|
308
|
+
const [held] = connection.rows('SELECT coalesce(sum(length(bytes)), 0) AS bytes FROM opened_parts');
|
|
309
|
+
return count(held.bytes);
|
|
533
310
|
}
|
|
534
311
|
function cleaned(connection) {
|
|
535
312
|
connection.run('DELETE FROM opened_files');
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
return
|
|
313
|
+
const freed = cleanable(connection);
|
|
314
|
+
unopened(connection);
|
|
315
|
+
return freed;
|
|
316
|
+
}
|
|
317
|
+
function openedHeld(connection) {
|
|
318
|
+
return {
|
|
319
|
+
rooms: connection
|
|
320
|
+
.rows('SELECT locator, count(*) AS files, sum(byte_length) AS bytes FROM opened_files WHERE byte_length IS NOT NULL GROUP BY locator ORDER BY locator')
|
|
321
|
+
.map((row) => ({ room: text(row.locator), count: count(row.files), size: count(row.bytes) })),
|
|
322
|
+
cleanable: cleanable(connection),
|
|
323
|
+
};
|
|
539
324
|
}
|
|
540
325
|
async function committed(connection, { authored, rooms }) {
|
|
541
326
|
const refused = authored === undefined ? null : await kept(connection, authored);
|
|
@@ -552,51 +337,39 @@ export function answerRuntime(connection, request, spool) {
|
|
|
552
337
|
case 'authored.status':
|
|
553
338
|
return status(connection);
|
|
554
339
|
case 'authored.moving':
|
|
555
|
-
return
|
|
556
|
-
queues: queued(connection),
|
|
557
|
-
pending: connection
|
|
558
|
-
.rows('SELECT locator, id, batch, state FROM authored_pending WHERE moving = 1 ORDER BY locator')
|
|
559
|
-
.map((row) => ({
|
|
560
|
-
locator: text(row.locator),
|
|
561
|
-
id: text(row.id),
|
|
562
|
-
batch: text(row.batch),
|
|
563
|
-
state: text(row.state),
|
|
564
|
-
})),
|
|
565
|
-
};
|
|
340
|
+
return moving(connection);
|
|
566
341
|
case 'authored.pending':
|
|
567
342
|
return pendingOf(connection, request.locator, request.id);
|
|
568
|
-
case 'authored.batch':
|
|
569
|
-
|
|
570
|
-
return held === undefined ? null : text(held.batch);
|
|
571
|
-
}
|
|
343
|
+
case 'authored.batch':
|
|
344
|
+
return pendingBatch(connection, request.locator, request.id);
|
|
572
345
|
case 'authored.order':
|
|
573
346
|
return heldOrder(connection, request.locator);
|
|
574
347
|
case 'authored.queued':
|
|
575
|
-
return
|
|
348
|
+
return queuedLocators(connection);
|
|
576
349
|
case 'authored.roomDrafts':
|
|
577
350
|
return roomDraftRecords(connection, request.locator, request.paths);
|
|
578
351
|
case 'authored.chatDraft.read':
|
|
579
352
|
return chatDraftRecord(connection, request.conversation);
|
|
580
353
|
case 'authored.chatDrafts':
|
|
581
|
-
return
|
|
354
|
+
return chatDraftRecords(connection);
|
|
582
355
|
case 'authored.calls':
|
|
583
|
-
return
|
|
356
|
+
return callRecords(connection);
|
|
584
357
|
case 'authored.fences':
|
|
585
|
-
return
|
|
358
|
+
return fences(connection);
|
|
586
359
|
case 'authored.unsent':
|
|
587
360
|
return unsent(connection);
|
|
588
361
|
case 'authored.fact':
|
|
589
362
|
return fact(connection, request.name);
|
|
590
363
|
case 'authored.file':
|
|
591
|
-
return spooled(connection, spool, request);
|
|
364
|
+
return spooled(connection, spool, request.key, request.type);
|
|
592
365
|
case 'authored.amend':
|
|
593
|
-
return amended(connection, request);
|
|
366
|
+
return amended(connection, request.locator, request.id, request.amendment);
|
|
594
367
|
case 'authored.roomDraft':
|
|
595
|
-
return roomDraft(connection, request);
|
|
368
|
+
return roomDraft(connection, request.locator, request.path, request.kept, request.files);
|
|
596
369
|
case 'authored.chatDraft':
|
|
597
|
-
return chatDraft(connection, request);
|
|
370
|
+
return chatDraft(connection, request.kept, request.dropped);
|
|
598
371
|
case 'authored.call':
|
|
599
|
-
return call(connection, request);
|
|
372
|
+
return call(connection, request.operation, request.kept, request.files);
|
|
600
373
|
case 'authored.remember':
|
|
601
374
|
return remember(connection, request.name, request.value);
|
|
602
375
|
case 'authored.claim':
|
|
@@ -610,18 +383,18 @@ export function answerRuntime(connection, request, spool) {
|
|
|
610
383
|
case 'replica.room':
|
|
611
384
|
return heldWork(connection, request.locator);
|
|
612
385
|
case 'replica.covering':
|
|
613
|
-
return {
|
|
614
|
-
rooms: covering(connection),
|
|
615
|
-
queues: queued(connection),
|
|
616
|
-
};
|
|
386
|
+
return { ...covering(connection, request.since), queues: queues(connection) };
|
|
617
387
|
case 'replica.offline':
|
|
618
388
|
return offlineMode(connection, request.locator);
|
|
619
389
|
case 'replica.held':
|
|
620
|
-
return {
|
|
390
|
+
return {
|
|
391
|
+
held: [...new Set([...heldLocators(connection), ...authoredLocators(connection)])],
|
|
392
|
+
staged: stagedLocators(connection),
|
|
393
|
+
};
|
|
621
394
|
case 'replica.demote':
|
|
622
395
|
return demoted(connection);
|
|
623
396
|
case 'replica.facts':
|
|
624
|
-
return facts(connection);
|
|
397
|
+
return facts(connection, request.names);
|
|
625
398
|
case 'replica.presentation':
|
|
626
399
|
return presentation(connection, request.app);
|
|
627
400
|
case 'replica.query':
|
|
@@ -635,7 +408,7 @@ export function answerRuntime(connection, request, spool) {
|
|
|
635
408
|
case 'replica.referrers':
|
|
636
409
|
return referrers(connection, request.key, request.view, request.targets);
|
|
637
410
|
case 'replica.folders':
|
|
638
|
-
return folders(connection, request.key, request.
|
|
411
|
+
return folders(connection, request.key, request.paths);
|
|
639
412
|
case 'replica.typedWithin':
|
|
640
413
|
return typedWithin(connection, request.key, request.view, request.roots, request.within);
|
|
641
414
|
case 'replica.stage':
|
|
@@ -655,7 +428,7 @@ export function answerRuntime(connection, request, spool) {
|
|
|
655
428
|
case 'replica.abandon':
|
|
656
429
|
return abandon(connection, request.locator);
|
|
657
430
|
case 'replica.unfence':
|
|
658
|
-
return
|
|
431
|
+
return unfencedRooms(connection, request.locators);
|
|
659
432
|
case 'replica.release':
|
|
660
433
|
return release(connection, request.key);
|
|
661
434
|
case 'replica.rederive':
|
|
@@ -684,8 +457,10 @@ export function answerRuntime(connection, request, spool) {
|
|
|
684
457
|
return dropped(connection, request.key);
|
|
685
458
|
case 'opened.clean':
|
|
686
459
|
return cleaned(connection);
|
|
460
|
+
case 'opened.held':
|
|
461
|
+
return openedHeld(connection);
|
|
687
462
|
case 'file.part':
|
|
688
|
-
return
|
|
463
|
+
return heldPart(connection, request.key, request.part);
|
|
689
464
|
case 'conversation.held':
|
|
690
465
|
return heldConversations(connection, request.conversations);
|
|
691
466
|
case 'conversation.keep': {
|
|
@@ -700,18 +475,18 @@ export function answerRuntime(connection, request, spool) {
|
|
|
700
475
|
return turnArrived(connection, request.conversation, request.turn);
|
|
701
476
|
case 'conversation.rows':
|
|
702
477
|
return conversationRows(connection, request.conversations);
|
|
703
|
-
case 'conversation.jobs':
|
|
704
|
-
return jobMarkers(connection, request.conversation);
|
|
705
478
|
case 'conversation.tallies':
|
|
706
479
|
return conversationTallies(connection, request.conversations, request.since);
|
|
480
|
+
case 'conversation.facts':
|
|
481
|
+
return conversationFacts(connection);
|
|
482
|
+
case 'conversation.fact': {
|
|
483
|
+
const { kind: _kind, ...fact } = request;
|
|
484
|
+
return keptFact(connection, fact);
|
|
485
|
+
}
|
|
486
|
+
case 'conversation.stored':
|
|
487
|
+
return storedConversations(connection, null);
|
|
707
488
|
case 'conversation.drop':
|
|
708
|
-
|
|
709
|
-
kind: 'authored.chatDraft',
|
|
710
|
-
kept: [],
|
|
711
|
-
dropped: request.conversations,
|
|
712
|
-
});
|
|
713
|
-
droppedMessages(connection, request.conversations);
|
|
714
|
-
return null;
|
|
489
|
+
return droppedConversations(connection, request.conversations);
|
|
715
490
|
case 'space.probe':
|
|
716
491
|
return spool.probe(PROBE_BYTES).then(() => null);
|
|
717
492
|
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"}
|