@agentshouse/mdruntime 0.1.0-cf04ede9fb796 → 0.1.0-cf08df9b663d8
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 +105 -166
- 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 +175 -85
- package/dist/adapter.d.ts +226 -74
- 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/{binary.d.ts → attachment.d.ts} +8 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +15 -0
- 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 -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 +7 -2
- 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 +30 -23
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +55 -68
- 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 +101 -63
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +42 -27
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +29 -15
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +26 -14
- package/dist/conversation-row.d.ts +23 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +37 -8
- package/dist/conversation.d.ts +48 -16
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +368 -262
- 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 +6 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +26 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +126 -36
- 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 -1
- 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.map +1 -1
- package/dist/holdings.js +5 -3
- 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/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +29 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -9
- package/dist/install.d.ts +10 -6
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +92 -111
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +80 -54
- package/dist/linked-file.d.ts +7 -0
- package/dist/linked-file.d.ts.map +1 -0
- package/dist/linked-file.js +13 -0
- 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 +97 -39
- 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 +12 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +11 -23
- package/dist/media.d.ts +20 -4
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +184 -37
- package/dist/memory.d.ts +10 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +105 -41
- package/dist/messages.d.ts +21 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +53 -41
- 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 +10 -8
- 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 +97 -139
- 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 +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 +6 -6
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +7 -7
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +24 -10
- package/dist/outcome.d.ts +33 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +36 -6
- package/dist/overlay.d.ts +23 -8
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +132 -48
- 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 +6 -59
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +32 -122
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +210 -92
- 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 +138 -80
- package/dist/query.d.ts +2 -3
- package/dist/query.d.ts.map +1 -1
- 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 +482 -0
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +200 -40
- package/dist/react.d.ts +17 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +23 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +18 -10
- package/dist/reads.d.ts +5 -3
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +30 -15
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- 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 +5 -6
- package/dist/replica.d.ts +6 -17
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +18 -20
- 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 +32 -9
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +282 -72
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +29 -23
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +47 -0
- package/dist/rows.d.ts +11 -3
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +28 -15
- package/dist/run-tables.d.ts +25 -0
- package/dist/run-tables.d.ts.map +1 -0
- package/dist/run-tables.js +98 -0
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +92 -0
- package/dist/runtime.d.ts +15 -20
- 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 +338 -236
- package/dist/saves.d.ts +9 -45
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +208 -752
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -5
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shared.d.ts +0 -5
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +4 -90
- package/dist/shown.d.ts +10 -6
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +105 -73
- 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 -2
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +9 -7
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +19 -18
- package/dist/source.d.ts +42 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +81 -13
- 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 +32 -10
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +71 -28
- 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 +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- 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 +42 -17
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +220 -62
- package/dist/surface.d.ts +20 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +70 -35
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +134 -109
- package/dist/tables.d.ts +40 -57
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +114 -334
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +8 -9
- 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 +72 -12
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +31 -14
- package/package.json +4 -3
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
- 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 -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';
|
|
6
|
+
import { forgottenRuns, heldRuns, keptRuns, RUN_TABLES, runMarks, runsLeft, } from './run-tables.js';
|
|
4
7
|
import { keptRead, READ_TABLES, readsOfOtherBuildsForgotten, storedRead, } from './reads.js';
|
|
5
8
|
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';
|
|
9
|
+
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';
|
|
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,17 @@ 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,
|
|
86
|
+
...RUN_TABLES,
|
|
99
87
|
];
|
|
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})`;
|
|
88
|
+
const UNOPENED_PARTS = 'DELETE FROM opened_parts WHERE key NOT IN (SELECT key FROM opened_files)';
|
|
104
89
|
const READS = new Set([
|
|
105
90
|
'authored.status',
|
|
106
91
|
'authored.moving',
|
|
@@ -125,10 +110,12 @@ const READS = new Set([
|
|
|
125
110
|
'replica.facts',
|
|
126
111
|
'replica.presentation',
|
|
127
112
|
'replica.query',
|
|
113
|
+
'replica.named',
|
|
128
114
|
'replica.tallies',
|
|
129
115
|
'replica.entries',
|
|
130
116
|
'replica.typed',
|
|
131
117
|
'replica.referrers',
|
|
118
|
+
'replica.holders',
|
|
132
119
|
'replica.folders',
|
|
133
120
|
'replica.typedWithin',
|
|
134
121
|
'opened.find',
|
|
@@ -139,9 +126,12 @@ const READS = new Set([
|
|
|
139
126
|
'conversation.count',
|
|
140
127
|
'conversation.turn',
|
|
141
128
|
'conversation.rows',
|
|
142
|
-
'conversation.jobs',
|
|
143
129
|
'conversation.tallies',
|
|
130
|
+
'conversation.facts',
|
|
131
|
+
'conversation.stored',
|
|
144
132
|
'read.stored',
|
|
133
|
+
'run.marks',
|
|
134
|
+
'run.held',
|
|
145
135
|
]);
|
|
146
136
|
const KINDS = new Set([
|
|
147
137
|
...READS,
|
|
@@ -172,10 +162,13 @@ const KINDS = new Set([
|
|
|
172
162
|
'opened.drop',
|
|
173
163
|
'opened.clean',
|
|
174
164
|
'conversation.keep',
|
|
165
|
+
'conversation.fact',
|
|
175
166
|
'conversation.drop',
|
|
176
167
|
'space.probe',
|
|
177
168
|
'read.keep',
|
|
178
169
|
'read.builds',
|
|
170
|
+
'run.keep',
|
|
171
|
+
'run.left',
|
|
179
172
|
]);
|
|
180
173
|
export function isRuntime(request) {
|
|
181
174
|
return KINDS.has(request.kind);
|
|
@@ -183,290 +176,76 @@ export function isRuntime(request) {
|
|
|
183
176
|
export function readsRuntime(request) {
|
|
184
177
|
return READS.has(request.kind);
|
|
185
178
|
}
|
|
186
|
-
function text(value) {
|
|
187
|
-
return typeof value === 'string' ? value : String(value);
|
|
188
|
-
}
|
|
189
|
-
function texts(rows, column) {
|
|
190
|
-
return rows.map((row) => text(row[column]));
|
|
191
|
-
}
|
|
192
|
-
function owned(files) {
|
|
193
|
-
return JSON.stringify([...new Set(files)]);
|
|
194
|
-
}
|
|
195
|
-
function fact(connection, name) {
|
|
196
|
-
const [held] = connection.rows('SELECT value FROM authored_facts WHERE name = ?', [name]);
|
|
197
|
-
return held === undefined ? null : text(held.value);
|
|
198
|
-
}
|
|
199
|
-
function remember(connection, name, value) {
|
|
200
|
-
connection.run('INSERT OR REPLACE INTO authored_facts (name, value) VALUES (?, ?)', [
|
|
201
|
-
name,
|
|
202
|
-
value,
|
|
203
|
-
]);
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
function fenced(connection, locator) {
|
|
207
|
-
return connection.rows('SELECT 1 FROM authored_fences WHERE locator = ?', [locator]).length > 0;
|
|
208
|
-
}
|
|
209
|
-
function stored(connection, key) {
|
|
210
|
-
return connection.rows('SELECT 1 FROM file_parts WHERE key = ? LIMIT 1', [key]).length > 0;
|
|
211
|
-
}
|
|
212
|
-
function storedPart(connection, key, part, bytes) {
|
|
213
|
-
connection.run('INSERT INTO file_parts (key, part, bytes) VALUES (?, ?, ?)', [key, part, bytes]);
|
|
214
|
-
}
|
|
215
|
-
async function storedFiles(connection, files) {
|
|
216
|
-
for (const { key, blob } of files) {
|
|
217
|
-
if (stored(connection, key))
|
|
218
|
-
continue;
|
|
219
|
-
for (let at = 0, part = 0; at < blob.size; at += FILE_PART_BYTES, part += 1) {
|
|
220
|
-
const bytes = new Uint8Array(await blob.slice(at, at + FILE_PART_BYTES).arrayBuffer());
|
|
221
|
-
storedPart(connection, key, part, bytes);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
function filePart(connection, key, part) {
|
|
226
|
-
const [held] = connection.rows('SELECT bytes FROM file_parts WHERE key = ? AND part = ?', [
|
|
227
|
-
key,
|
|
228
|
-
part,
|
|
229
|
-
]);
|
|
230
|
-
return held?.bytes instanceof Uint8Array ? held.bytes : null;
|
|
231
|
-
}
|
|
232
|
-
function* fileParts(connection, key) {
|
|
233
|
-
for (let part = 0;; part += 1) {
|
|
234
|
-
const bytes = filePart(connection, key, part);
|
|
235
|
-
if (bytes === null)
|
|
236
|
-
return;
|
|
237
|
-
yield bytes;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
async function spooled(connection, spool, { key, type }) {
|
|
241
|
-
for (const held of [...spool.held()]) {
|
|
242
|
-
if (held !== key && !stored(connection, held))
|
|
243
|
-
await spool.drop(held);
|
|
244
|
-
}
|
|
245
|
-
return spool.spool(key, type, fileParts(connection, key));
|
|
246
|
-
}
|
|
247
|
-
function unowned(connection) {
|
|
248
|
-
connection.run(UNOWNED_PARTS);
|
|
249
|
-
}
|
|
250
|
-
function queued(connection) {
|
|
251
|
-
return connection.rows('SELECT locator, ids FROM authored_queues').map((row) => ({
|
|
252
|
-
locator: text(row.locator),
|
|
253
|
-
ids: JSON.parse(text(row.ids)),
|
|
254
|
-
}));
|
|
255
|
-
}
|
|
256
179
|
function heldWork(connection, locator) {
|
|
257
180
|
const room = heldRoom(connection, locator);
|
|
258
|
-
const pending = new Map(connection
|
|
259
|
-
.rows('SELECT id, batch, state FROM authored_pending WHERE locator = ?', [locator])
|
|
260
|
-
.map((row) => [
|
|
261
|
-
text(row.id),
|
|
262
|
-
{ id: text(row.id), batch: text(row.batch), state: text(row.state) },
|
|
263
|
-
]));
|
|
264
181
|
return {
|
|
265
182
|
room: room === null ? null : { ...room, overlaid: overlaid(connection, room.key) },
|
|
266
|
-
queue:
|
|
267
|
-
const held = pending.get(id);
|
|
268
|
-
if (held === undefined)
|
|
269
|
-
throw new Error(`Missing Pending Change ${locator}/${id}`);
|
|
270
|
-
return held;
|
|
271
|
-
}),
|
|
183
|
+
queue: queueOf(connection, locator),
|
|
272
184
|
};
|
|
273
185
|
}
|
|
274
186
|
function status(connection) {
|
|
275
|
-
const [completed] = connection.rows("SELECT value FROM replica_facts WHERE name = 'lastCompleted'");
|
|
276
187
|
return {
|
|
277
|
-
|
|
278
|
-
lastCompleted:
|
|
279
|
-
changes: connection
|
|
280
|
-
.rows('SELECT p.locator, c.value AS path FROM authored_pending p, json_each(p.paths) c')
|
|
281
|
-
.map((row) => ({ locator: text(row.locator), path: text(row.path) })),
|
|
282
|
-
resets: connection
|
|
283
|
-
.rows(`SELECT locator, json_extract(state, '$.submission.reset') AS reset FROM authored_pending
|
|
284
|
-
WHERE json_extract(state, '$.submission.state') = 'reset'`)
|
|
285
|
-
.map((row) => ({ locator: text(row.locator), reset: text(row.reset) })),
|
|
286
|
-
returned: texts(connection.rows(`SELECT record FROM authored_room_drafts WHERE json_type(record, '$.returned') = 'object'`), 'record'),
|
|
188
|
+
...unsentStatus(connection),
|
|
189
|
+
lastCompleted: facts(connection, ['lastCompleted']).lastCompleted ?? null,
|
|
287
190
|
};
|
|
288
191
|
}
|
|
289
192
|
function pendingOf(connection, locator, id) {
|
|
290
|
-
const [held] = connection.rows('SELECT state FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
291
193
|
return {
|
|
292
|
-
state:
|
|
194
|
+
state: pendingState(connection, locator, id),
|
|
293
195
|
room: connection.rows('SELECT 1 FROM replica_rooms WHERE locator = ?', [locator]).length > 0,
|
|
294
196
|
};
|
|
295
197
|
}
|
|
296
|
-
function
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
function heldOrder(connection, locator) {
|
|
312
|
-
const [held] = connection.rows('SELECT ids FROM authored_queues WHERE locator = ?', [locator]);
|
|
313
|
-
return held === undefined ? [] : JSON.parse(text(held.ids));
|
|
314
|
-
}
|
|
315
|
-
function keptRows(connection, { locator, order, added, founded, roomDrafts, consumedRoomDrafts }) {
|
|
316
|
-
for (const path of consumedRoomDrafts ?? []) {
|
|
317
|
-
connection.run('DELETE FROM authored_room_drafts WHERE locator = ? AND path = ?', [
|
|
318
|
-
locator,
|
|
319
|
-
path,
|
|
320
|
-
]);
|
|
321
|
-
}
|
|
322
|
-
for (const { path, record, files } of roomDrafts ?? []) {
|
|
323
|
-
connection.run('INSERT OR REPLACE INTO authored_room_drafts (locator, path, record, files) VALUES (?, ?, ?, ?)', [locator, path, record, owned(files)]);
|
|
324
|
-
}
|
|
325
|
-
if (order === undefined)
|
|
326
|
-
return;
|
|
327
|
-
const before = new Set(heldOrder(connection, locator));
|
|
328
|
-
const after = new Set(order);
|
|
329
|
-
if (after.size === 0)
|
|
330
|
-
connection.run('DELETE FROM authored_queues WHERE locator = ?', [locator]);
|
|
331
|
-
else {
|
|
332
|
-
connection.run('INSERT OR REPLACE INTO authored_queues (locator, ids) VALUES (?, ?)', [
|
|
333
|
-
locator,
|
|
334
|
-
JSON.stringify([...after]),
|
|
335
|
-
]);
|
|
336
|
-
}
|
|
337
|
-
for (const id of before) {
|
|
338
|
-
if (!after.has(id)) {
|
|
339
|
-
connection.run('DELETE FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
for (const { id, batch, state, files, paths, moving } of added ?? []) {
|
|
343
|
-
if (before.has(id) || !after.has(id))
|
|
344
|
-
continue;
|
|
345
|
-
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]);
|
|
346
|
-
}
|
|
347
|
-
for (const { id, batch, files, paths, moving } of founded ?? []) {
|
|
348
|
-
const [held] = connection.rows('SELECT files FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
349
|
-
if (held === undefined || !before.has(id))
|
|
350
|
-
continue;
|
|
351
|
-
connection.run('UPDATE authored_pending SET batch = ?, files = ?, paths = ?, moving = ? WHERE locator = ? AND id = ?', [
|
|
352
|
-
batch,
|
|
353
|
-
owned([...JSON.parse(text(held.files)), ...files]),
|
|
354
|
-
JSON.stringify(paths),
|
|
355
|
-
moving ? 1 : 0,
|
|
356
|
-
locator,
|
|
357
|
-
id,
|
|
358
|
-
]);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
async function kept(connection, { writes, files, whole }) {
|
|
362
|
-
const refused = writes.find(({ locator }) => fenced(connection, locator));
|
|
363
|
-
if (refused !== undefined && whole)
|
|
364
|
-
return refused.locator;
|
|
365
|
-
await storedFiles(connection, files);
|
|
366
|
-
for (const write of writes) {
|
|
367
|
-
if (!fenced(connection, write.locator))
|
|
368
|
-
keptRows(connection, write);
|
|
369
|
-
}
|
|
370
|
-
unowned(connection);
|
|
371
|
-
return refused?.locator ?? null;
|
|
372
|
-
}
|
|
373
|
-
function amended(connection, { locator, id, amendment }) {
|
|
374
|
-
if (fenced(connection, locator))
|
|
375
|
-
return null;
|
|
376
|
-
const [held] = connection.rows('SELECT state FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
|
|
377
|
-
if (held === undefined)
|
|
378
|
-
return null;
|
|
379
|
-
connection.run('UPDATE authored_pending SET state = ? WHERE locator = ? AND id = ?', [
|
|
380
|
-
JSON.stringify({
|
|
381
|
-
...JSON.parse(text(held.state)),
|
|
382
|
-
...JSON.parse(amendment),
|
|
383
|
-
}),
|
|
384
|
-
locator,
|
|
385
|
-
id,
|
|
386
|
-
]);
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
async function roomDraft(connection, { locator, path, kept: draft, files }) {
|
|
390
|
-
if (fenced(connection, locator))
|
|
391
|
-
return locator;
|
|
392
|
-
await storedFiles(connection, files);
|
|
393
|
-
if (draft === null) {
|
|
394
|
-
connection.run('DELETE FROM authored_room_drafts WHERE locator = ? AND path = ?', [
|
|
395
|
-
locator,
|
|
396
|
-
path,
|
|
198
|
+
function storedConversations(connection, conversations) {
|
|
199
|
+
const named = conversations === null ? '' : ' WHERE conversation IN (SELECT value FROM json_each(?))';
|
|
200
|
+
const bound = conversations === null ? [] : [JSON.stringify(conversations)];
|
|
201
|
+
return [
|
|
202
|
+
...new Set([
|
|
203
|
+
...tablesOf(MESSAGE_TABLES).flatMap((table) => texts(connection.rows(`SELECT DISTINCT conversation FROM ${table}${named}`, bound), 'conversation')),
|
|
204
|
+
...chatDraftConversations(connection, conversations),
|
|
205
|
+
]),
|
|
206
|
+
];
|
|
207
|
+
}
|
|
208
|
+
function droppedConversations(connection, conversations) {
|
|
209
|
+
const held = storedConversations(connection, conversations);
|
|
210
|
+
for (const table of tablesOf(MESSAGE_TABLES)) {
|
|
211
|
+
connection.run(`DELETE FROM ${table} WHERE conversation IN (SELECT value FROM json_each(?))`, [
|
|
212
|
+
JSON.stringify(conversations),
|
|
397
213
|
]);
|
|
398
214
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
unowned(connection);
|
|
403
|
-
return null;
|
|
404
|
-
}
|
|
405
|
-
function chatDraft(connection, { kept: drafts, dropped }) {
|
|
406
|
-
for (const conversation of dropped) {
|
|
407
|
-
connection.run('DELETE FROM authored_chat_drafts WHERE conversation = ?', [conversation]);
|
|
408
|
-
}
|
|
409
|
-
for (const { conversation, record } of drafts) {
|
|
410
|
-
connection.run('INSERT OR REPLACE INTO authored_chat_drafts (conversation, record) VALUES (?, ?)', [conversation, record]);
|
|
411
|
-
}
|
|
412
|
-
return null;
|
|
215
|
+
chatDraftsDropped(connection, conversations);
|
|
216
|
+
return held;
|
|
413
217
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (held === null)
|
|
417
|
-
connection.run('DELETE FROM authored_calls WHERE operation = ?', [operation]);
|
|
418
|
-
else {
|
|
419
|
-
connection.run('INSERT OR REPLACE INTO authored_calls (operation, record, files) VALUES (?, ?, ?)', [operation, held.record, owned(held.files)]);
|
|
420
|
-
}
|
|
421
|
-
unowned(connection);
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
424
|
-
function roomWork(connection, locator) {
|
|
425
|
-
connection.run('DELETE FROM authored_queues WHERE locator = ?', [locator]);
|
|
426
|
-
connection.run('DELETE FROM authored_pending WHERE locator = ?', [locator]);
|
|
218
|
+
function unopened(connection) {
|
|
219
|
+
connection.run(UNOPENED_PARTS);
|
|
427
220
|
}
|
|
428
221
|
function fence(connection, locators) {
|
|
222
|
+
fencedWork(connection, locators);
|
|
429
223
|
for (const locator of locators) {
|
|
430
|
-
connection.run('INSERT OR REPLACE INTO authored_fences (locator) VALUES (?)', [locator]);
|
|
431
|
-
roomWork(connection, locator);
|
|
432
|
-
connection.run('DELETE FROM authored_room_drafts WHERE locator = ?', [locator]);
|
|
433
224
|
connection.run('DELETE FROM opened_files WHERE locator = ?', [locator]);
|
|
434
225
|
}
|
|
435
|
-
|
|
226
|
+
unopened(connection);
|
|
436
227
|
return fenceRooms(connection, locators);
|
|
437
228
|
}
|
|
438
229
|
function erased(connection, { locator, limit }) {
|
|
439
230
|
return erase(connection, locator, limit);
|
|
440
231
|
}
|
|
441
|
-
function
|
|
232
|
+
function unfencedRooms(connection, locators) {
|
|
442
233
|
const erased = locators.filter((locator) => connection.rows('SELECT 1 FROM replica_erasing WHERE locator = ? LIMIT 1', [locator])
|
|
443
234
|
.length === 0);
|
|
444
|
-
|
|
445
|
-
connection.run('DELETE FROM authored_fences WHERE locator = ?', [locator]);
|
|
446
|
-
}
|
|
235
|
+
unfenced(connection, erased);
|
|
447
236
|
return erased;
|
|
448
237
|
}
|
|
449
|
-
function claim(connection, holder) {
|
|
450
|
-
const held = fact(connection, 'holder');
|
|
451
|
-
if (held !== null)
|
|
452
|
-
return held === holder;
|
|
453
|
-
remember(connection, 'holder', holder);
|
|
454
|
-
return true;
|
|
455
|
-
}
|
|
456
238
|
function end(connection, holder) {
|
|
457
239
|
ended(connection);
|
|
458
|
-
|
|
240
|
+
forgottenConversations(connection);
|
|
241
|
+
forgottenRuns(connection);
|
|
459
242
|
if (holder !== null && claim(connection, holder))
|
|
460
243
|
return true;
|
|
461
|
-
|
|
462
|
-
connection.run(`DELETE FROM ${table}`);
|
|
244
|
+
authoredEmptied(connection);
|
|
463
245
|
connection.run('DELETE FROM opened_files');
|
|
464
|
-
connection.run('DELETE FROM
|
|
246
|
+
connection.run('DELETE FROM opened_parts');
|
|
465
247
|
return false;
|
|
466
248
|
}
|
|
467
|
-
function count(value) {
|
|
468
|
-
return typeof value === 'bigint' ? Number(value) : typeof value === 'number' ? value : 0;
|
|
469
|
-
}
|
|
470
249
|
function openedFile(connection, { locator, path, revision }) {
|
|
471
250
|
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]);
|
|
472
251
|
return held === undefined
|
|
@@ -481,7 +260,7 @@ function opening(connection, { key, locator, path, revision, mediaType }) {
|
|
|
481
260
|
if (fenced(connection, locator))
|
|
482
261
|
return false;
|
|
483
262
|
connection.run('DELETE FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND byte_length IS NULL', [locator, path, revision]);
|
|
484
|
-
|
|
263
|
+
unopened(connection);
|
|
485
264
|
connection.run('INSERT INTO opened_files (key, locator, path, revision, media_type) VALUES (?, ?, ?, ?, ?)', [key, locator, path, revision, mediaType]);
|
|
486
265
|
return true;
|
|
487
266
|
}
|
|
@@ -494,22 +273,26 @@ function fetching(connection, key) {
|
|
|
494
273
|
function openedPart(connection, { key, part, bytes }) {
|
|
495
274
|
if (fetching(connection, key) === null)
|
|
496
275
|
return false;
|
|
497
|
-
|
|
276
|
+
connection.run('INSERT INTO opened_parts (key, part, bytes) VALUES (?, ?, ?)', [
|
|
277
|
+
key,
|
|
278
|
+
part,
|
|
279
|
+
bytes,
|
|
280
|
+
]);
|
|
498
281
|
return true;
|
|
499
282
|
}
|
|
500
283
|
function dropped(connection, key) {
|
|
501
284
|
connection.run('DELETE FROM opened_files WHERE key = ?', [key]);
|
|
502
|
-
connection.run('DELETE FROM
|
|
285
|
+
connection.run('DELETE FROM opened_parts WHERE key = ?', [key]);
|
|
503
286
|
return null;
|
|
504
287
|
}
|
|
505
288
|
function keptOpened(connection, { key, sha256, byteLength, parts }) {
|
|
506
289
|
const fetched = fetching(connection, key);
|
|
507
290
|
if (fetched === null)
|
|
508
291
|
return false;
|
|
509
|
-
const [held] = connection.rows('SELECT count(*) AS parts, min(part) AS first, max(part) AS last, coalesce(sum(length(bytes)), 0) AS bytes FROM
|
|
510
|
-
const whole = count(held
|
|
511
|
-
count(held
|
|
512
|
-
(parts === 0 || (count(held
|
|
292
|
+
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]);
|
|
293
|
+
const whole = count(held.parts) === parts &&
|
|
294
|
+
count(held.bytes) === byteLength &&
|
|
295
|
+
(parts === 0 || (count(held.first) === 0 && count(held.last) === parts - 1));
|
|
513
296
|
if (!whole) {
|
|
514
297
|
dropped(connection, key);
|
|
515
298
|
return false;
|
|
@@ -520,27 +303,24 @@ function keptOpened(connection, { key, sha256, byteLength, parts }) {
|
|
|
520
303
|
key,
|
|
521
304
|
]);
|
|
522
305
|
connection.run('DELETE FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND key <> ?', [fetched.locator, fetched.path, fetched.revision, key]);
|
|
523
|
-
|
|
306
|
+
unopened(connection);
|
|
524
307
|
return true;
|
|
525
308
|
}
|
|
526
|
-
|
|
527
|
-
['
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
function unsent(connection) {
|
|
533
|
-
const [held] = connection.rows(`SELECT ${UNSENT.map(([kind, table]) => `(SELECT count(*) FROM ${table}) AS "${kind}"`).join(', ')}`);
|
|
534
|
-
return UNSENT.map(([kind]) => ({ kind, count: count(held?.[kind]) })).filter((work) => work.count > 0);
|
|
309
|
+
function heldPart(connection, key, part) {
|
|
310
|
+
const [held] = connection.rows('SELECT bytes FROM opened_parts WHERE key = ? AND part = ?', [
|
|
311
|
+
key,
|
|
312
|
+
part,
|
|
313
|
+
]);
|
|
314
|
+
return held?.bytes instanceof Uint8Array ? held.bytes : authoredPart(connection, key, part);
|
|
535
315
|
}
|
|
536
316
|
function cleanable(connection) {
|
|
537
|
-
const [held] = connection.rows(
|
|
538
|
-
return count(held
|
|
317
|
+
const [held] = connection.rows('SELECT coalesce(sum(length(bytes)), 0) AS bytes FROM opened_parts');
|
|
318
|
+
return count(held.bytes);
|
|
539
319
|
}
|
|
540
320
|
function cleaned(connection) {
|
|
541
321
|
connection.run('DELETE FROM opened_files');
|
|
542
322
|
const freed = cleanable(connection);
|
|
543
|
-
|
|
323
|
+
unopened(connection);
|
|
544
324
|
return freed;
|
|
545
325
|
}
|
|
546
326
|
function openedHeld(connection) {
|
|
@@ -566,51 +346,39 @@ export function answerRuntime(connection, request, spool) {
|
|
|
566
346
|
case 'authored.status':
|
|
567
347
|
return status(connection);
|
|
568
348
|
case 'authored.moving':
|
|
569
|
-
return
|
|
570
|
-
queues: queued(connection),
|
|
571
|
-
pending: connection
|
|
572
|
-
.rows('SELECT locator, id, batch, state FROM authored_pending WHERE moving = 1 ORDER BY locator')
|
|
573
|
-
.map((row) => ({
|
|
574
|
-
locator: text(row.locator),
|
|
575
|
-
id: text(row.id),
|
|
576
|
-
batch: text(row.batch),
|
|
577
|
-
state: text(row.state),
|
|
578
|
-
})),
|
|
579
|
-
};
|
|
349
|
+
return moving(connection);
|
|
580
350
|
case 'authored.pending':
|
|
581
351
|
return pendingOf(connection, request.locator, request.id);
|
|
582
|
-
case 'authored.batch':
|
|
583
|
-
|
|
584
|
-
return held === undefined ? null : text(held.batch);
|
|
585
|
-
}
|
|
352
|
+
case 'authored.batch':
|
|
353
|
+
return pendingBatch(connection, request.locator, request.id);
|
|
586
354
|
case 'authored.order':
|
|
587
355
|
return heldOrder(connection, request.locator);
|
|
588
356
|
case 'authored.queued':
|
|
589
|
-
return
|
|
357
|
+
return queuedLocators(connection);
|
|
590
358
|
case 'authored.roomDrafts':
|
|
591
359
|
return roomDraftRecords(connection, request.locator, request.paths);
|
|
592
360
|
case 'authored.chatDraft.read':
|
|
593
361
|
return chatDraftRecord(connection, request.conversation);
|
|
594
362
|
case 'authored.chatDrafts':
|
|
595
|
-
return
|
|
363
|
+
return chatDraftRecords(connection);
|
|
596
364
|
case 'authored.calls':
|
|
597
|
-
return
|
|
365
|
+
return callRecords(connection);
|
|
598
366
|
case 'authored.fences':
|
|
599
|
-
return
|
|
367
|
+
return fences(connection);
|
|
600
368
|
case 'authored.unsent':
|
|
601
369
|
return unsent(connection);
|
|
602
370
|
case 'authored.fact':
|
|
603
371
|
return fact(connection, request.name);
|
|
604
372
|
case 'authored.file':
|
|
605
|
-
return spooled(connection, spool, request);
|
|
373
|
+
return spooled(connection, spool, request.key, request.type);
|
|
606
374
|
case 'authored.amend':
|
|
607
|
-
return amended(connection, request);
|
|
375
|
+
return amended(connection, request.locator, request.id, request.amendment);
|
|
608
376
|
case 'authored.roomDraft':
|
|
609
|
-
return roomDraft(connection, request);
|
|
377
|
+
return roomDraft(connection, request.locator, request.path, request.kept, request.files);
|
|
610
378
|
case 'authored.chatDraft':
|
|
611
|
-
return chatDraft(connection, request);
|
|
379
|
+
return chatDraft(connection, request.kept, request.dropped);
|
|
612
380
|
case 'authored.call':
|
|
613
|
-
return call(connection, request);
|
|
381
|
+
return call(connection, request.operation, request.kept, request.files);
|
|
614
382
|
case 'authored.remember':
|
|
615
383
|
return remember(connection, request.name, request.value);
|
|
616
384
|
case 'authored.claim':
|
|
@@ -624,22 +392,24 @@ export function answerRuntime(connection, request, spool) {
|
|
|
624
392
|
case 'replica.room':
|
|
625
393
|
return heldWork(connection, request.locator);
|
|
626
394
|
case 'replica.covering':
|
|
627
|
-
return {
|
|
628
|
-
rooms: covering(connection),
|
|
629
|
-
queues: queued(connection),
|
|
630
|
-
};
|
|
395
|
+
return { ...covering(connection, request.since), queues: queues(connection) };
|
|
631
396
|
case 'replica.offline':
|
|
632
397
|
return offlineMode(connection, request.locator);
|
|
633
398
|
case 'replica.held':
|
|
634
|
-
return {
|
|
399
|
+
return {
|
|
400
|
+
held: [...new Set([...heldLocators(connection), ...authoredLocators(connection)])],
|
|
401
|
+
staged: stagedLocators(connection),
|
|
402
|
+
};
|
|
635
403
|
case 'replica.demote':
|
|
636
404
|
return demoted(connection);
|
|
637
405
|
case 'replica.facts':
|
|
638
|
-
return facts(connection);
|
|
406
|
+
return facts(connection, request.names);
|
|
639
407
|
case 'replica.presentation':
|
|
640
408
|
return presentation(connection, request.app);
|
|
641
409
|
case 'replica.query':
|
|
642
|
-
return answerQuery(connection, request.plan, request.rooms, request.budget);
|
|
410
|
+
return answerQuery(connection, request.plan, request.rooms, request.budget, request.follows);
|
|
411
|
+
case 'replica.named':
|
|
412
|
+
return namedHandles(connection, request.plan, request.rooms, request.handles);
|
|
643
413
|
case 'replica.tallies':
|
|
644
414
|
return roomTallies(connection, request.totals, request.rooms, request.since);
|
|
645
415
|
case 'replica.entries':
|
|
@@ -648,8 +418,10 @@ export function answerRuntime(connection, request, spool) {
|
|
|
648
418
|
return typed(connection, request.key, request.view, request.paths);
|
|
649
419
|
case 'replica.referrers':
|
|
650
420
|
return referrers(connection, request.key, request.view, request.targets);
|
|
421
|
+
case 'replica.holders':
|
|
422
|
+
return holders(connection, request.key, request.view, request.sought);
|
|
651
423
|
case 'replica.folders':
|
|
652
|
-
return folders(connection, request.key, request.
|
|
424
|
+
return folders(connection, request.key, request.paths);
|
|
653
425
|
case 'replica.typedWithin':
|
|
654
426
|
return typedWithin(connection, request.key, request.view, request.roots, request.within);
|
|
655
427
|
case 'replica.stage':
|
|
@@ -669,7 +441,7 @@ export function answerRuntime(connection, request, spool) {
|
|
|
669
441
|
case 'replica.abandon':
|
|
670
442
|
return abandon(connection, request.locator);
|
|
671
443
|
case 'replica.unfence':
|
|
672
|
-
return
|
|
444
|
+
return unfencedRooms(connection, request.locators);
|
|
673
445
|
case 'replica.release':
|
|
674
446
|
return release(connection, request.key);
|
|
675
447
|
case 'replica.rederive':
|
|
@@ -701,7 +473,7 @@ export function answerRuntime(connection, request, spool) {
|
|
|
701
473
|
case 'opened.held':
|
|
702
474
|
return openedHeld(connection);
|
|
703
475
|
case 'file.part':
|
|
704
|
-
return
|
|
476
|
+
return heldPart(connection, request.key, request.part);
|
|
705
477
|
case 'conversation.held':
|
|
706
478
|
return heldConversations(connection, request.conversations);
|
|
707
479
|
case 'conversation.keep': {
|
|
@@ -716,18 +488,18 @@ export function answerRuntime(connection, request, spool) {
|
|
|
716
488
|
return turnArrived(connection, request.conversation, request.turn);
|
|
717
489
|
case 'conversation.rows':
|
|
718
490
|
return conversationRows(connection, request.conversations);
|
|
719
|
-
case 'conversation.jobs':
|
|
720
|
-
return jobMarkers(connection, request.conversation);
|
|
721
491
|
case 'conversation.tallies':
|
|
722
492
|
return conversationTallies(connection, request.conversations, request.since);
|
|
493
|
+
case 'conversation.facts':
|
|
494
|
+
return conversationFacts(connection);
|
|
495
|
+
case 'conversation.fact': {
|
|
496
|
+
const { kind: _kind, ...fact } = request;
|
|
497
|
+
return keptFact(connection, fact);
|
|
498
|
+
}
|
|
499
|
+
case 'conversation.stored':
|
|
500
|
+
return storedConversations(connection, null);
|
|
723
501
|
case 'conversation.drop':
|
|
724
|
-
|
|
725
|
-
kind: 'authored.chatDraft',
|
|
726
|
-
kept: [],
|
|
727
|
-
dropped: request.conversations,
|
|
728
|
-
});
|
|
729
|
-
droppedMessages(connection, request.conversations);
|
|
730
|
-
return null;
|
|
502
|
+
return droppedConversations(connection, request.conversations);
|
|
731
503
|
case 'space.probe':
|
|
732
504
|
return spool.probe(PROBE_BYTES).then(() => null);
|
|
733
505
|
case 'read.stored':
|
|
@@ -736,5 +508,13 @@ export function answerRuntime(connection, request, spool) {
|
|
|
736
508
|
return keptRead(connection, request, request.answer);
|
|
737
509
|
case 'read.builds':
|
|
738
510
|
return readsOfOtherBuildsForgotten(connection, request.build);
|
|
511
|
+
case 'run.marks':
|
|
512
|
+
return runMarks(connection);
|
|
513
|
+
case 'run.held':
|
|
514
|
+
return heldRuns(connection, request.asked, request.sight);
|
|
515
|
+
case 'run.keep':
|
|
516
|
+
return keptRuns(connection, request.event);
|
|
517
|
+
case 'run.left':
|
|
518
|
+
return runsLeft(connection, request.sight);
|
|
739
519
|
}
|
|
740
520
|
}
|