@agentshouse/mdruntime 0.1.0-cb2e390ee7b89 → 0.1.0-cb4f25b82f4b6
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 +23 -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 +302 -0
- package/dist/adapter.d.ts +163 -125
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +7 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +40 -41
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +30 -11
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +309 -113
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/chain.d.ts +12 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +13 -16
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +17 -89
- package/dist/change.d.ts +32 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +14 -3
- package/dist/chat-types.d.ts +5 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +13 -0
- package/dist/client.d.ts +36 -24
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +118 -23
- package/dist/collection.d.ts +29 -21
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +48 -290
- package/dist/compile.d.ts +18 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +724 -0
- package/dist/connection.d.ts +7 -134
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +107 -3606
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/{chat/context.js → context.js} +1 -4
- package/dist/conversation-live.d.ts +143 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +254 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +53 -0
- package/dist/conversation.d.ts +73 -49
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +1010 -794
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +150 -0
- package/dist/durability.d.ts +20 -4
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +9 -0
- package/dist/entry.d.ts +5 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +33 -28
- 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 +6 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +7 -122
- 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 +21 -11
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +113 -49
- package/dist/identity.d.ts +0 -2
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -6
- package/dist/index.d.ts +39 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -4
- package/dist/install.d.ts +54 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +530 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +277 -0
- package/dist/listing.d.ts +48 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +139 -0
- package/dist/live.d.ts +23 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +165 -0
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +32 -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 +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +17 -8
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +273 -121
- package/dist/messages.d.ts +56 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +158 -0
- package/dist/model.d.ts +8 -11
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -23
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +17 -3
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +107 -17
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +53 -0
- package/dist/outcome.d.ts +47 -9
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +56 -2
- package/dist/overlay.d.ts +7 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +123 -182
- 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 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +13 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +26 -0
- package/dist/preparation.d.ts +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +227 -0
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +282 -0
- package/dist/query.d.ts +21 -203
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -491
- package/dist/{chat/questions.d.ts → questions.d.ts} +5 -7
- package/dist/questions.d.ts.map +1 -0
- package/dist/{chat/questions.js → questions.js} +11 -7
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +450 -0
- package/dist/reach.d.ts +20 -9
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +341 -111
- package/dist/react.d.ts +16 -4
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +35 -15
- package/dist/{chat/read.d.ts → read.d.ts} +2 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/{chat/read.js → read.js} +4 -0
- package/dist/readiness.d.ts +14 -18
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -8
- package/dist/reads.d.ts +38 -10
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +163 -83
- package/dist/recovery.d.ts +5 -2
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +65 -8
- package/dist/refresh.d.ts +18 -15
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +145 -60
- 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 +49 -36
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +320 -196
- 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 +28 -11
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +194 -118
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -0
- package/dist/rows.d.ts +31 -30
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +60 -120
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +43 -49
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +776 -275
- package/dist/saves.d.ts +32 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +410 -0
- package/dist/search.d.ts +12 -95
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +10 -266
- 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 +6 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +75 -104
- package/dist/shown.d.ts +33 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +302 -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 +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +67 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +164 -0
- package/dist/source.d.ts +54 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +82 -0
- package/dist/status.d.ts +4 -5
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -7
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +34 -0
- package/dist/store/readiness.d.ts +10 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +52 -0
- package/dist/store/records.d.ts +214 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +438 -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/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 +111 -164
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +159 -754
- package/dist/stored.d.ts +157 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +649 -0
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +220 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +535 -0
- package/dist/tables.d.ts +415 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +761 -0
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/turn.d.ts +5 -3
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +51 -21
- package/dist/validation.d.ts +29 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +104 -0
- package/dist/windows.d.ts +9 -16
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +11 -75
- package/dist/wire.d.ts +89 -9
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +29 -6
- package/package.json +19 -19
- package/AGENTS.md +0 -299
- package/dist/acquisition.d.ts +0 -14
- package/dist/acquisition.d.ts.map +0 -1
- package/dist/acquisition.js +0 -24
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/chat/acts.d.ts +0 -33
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/earlier.d.ts +0 -10
- package/dist/chat/earlier.d.ts.map +0 -1
- package/dist/chat/earlier.js +0 -54
- package/dist/chat/input.d.ts +0 -9
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -99
- package/dist/chat/kit.d.ts +0 -61
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -27
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -99
- package/dist/chat/markdown.d.ts +0 -20
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -188
- package/dist/chat/message.d.ts +0 -6
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -192
- package/dist/chat/messages.d.ts +0 -22
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -155
- package/dist/chat/name.d.ts +0 -6
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -11
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -17
- package/dist/chat/overlay.d.ts +0 -31
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -97
- package/dist/chat/parts.d.ts +0 -57
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -119
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -63
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -635
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -69
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/ready.d.ts +0 -34
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -91
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -302
- package/dist/chat.d.ts +0 -14
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/read-side.d.ts +0 -25
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -761
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { plain } from '@agentshouse/mdmodel';
|
|
2
|
+
import { changeSet } from './change-set.js';
|
|
3
|
+
import { collectionOf } from './collection.js';
|
|
4
|
+
import { runtimeError, uncaught } from './failure.js';
|
|
5
|
+
import { roomDraftRevision } from './identity.js';
|
|
6
|
+
import { normalize } from './paths.js';
|
|
7
|
+
import { slicing } from './replica.js';
|
|
8
|
+
import { binaryBase, gatheredParts, held, heldFile, readParts, staleWrite, underneath, } from './room-draft.js';
|
|
9
|
+
import { stepped } from './turn.js';
|
|
10
|
+
const ROOM_DRAFTS = 'room-drafts';
|
|
11
|
+
const presentationTopic = (app) => `presentation\u0000${app}`;
|
|
12
|
+
export async function visibleOf(store, locator, paths) {
|
|
13
|
+
const kept = await store.record(locator);
|
|
14
|
+
if (kept === undefined)
|
|
15
|
+
return undefined;
|
|
16
|
+
const local = await store.open();
|
|
17
|
+
const slice = await stepped(slicing(await local.entries(kept.key, 'visible', paths), paths));
|
|
18
|
+
return { ...slice, collection: collectionOf(slice.documents, store.composed(kept)) };
|
|
19
|
+
}
|
|
20
|
+
function roomDraftOf(record, visible) {
|
|
21
|
+
return structuredClone({
|
|
22
|
+
room: record.locator,
|
|
23
|
+
path: record.path,
|
|
24
|
+
revision: record.revision,
|
|
25
|
+
parts: record.parts,
|
|
26
|
+
changedUnderneath: underneath(record.parts, record.path, visible),
|
|
27
|
+
returned: record.returned,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async function roomDraftsOf(store, records) {
|
|
31
|
+
const rooms = new Map();
|
|
32
|
+
for (const record of records) {
|
|
33
|
+
const paths = rooms.get(record.locator) ?? [];
|
|
34
|
+
paths.push(record.path);
|
|
35
|
+
rooms.set(record.locator, paths);
|
|
36
|
+
}
|
|
37
|
+
const layers = new Map();
|
|
38
|
+
for (const [locator, paths] of rooms) {
|
|
39
|
+
layers.set(locator, await visibleOf(store, locator, paths));
|
|
40
|
+
}
|
|
41
|
+
return records.map((record) => roomDraftOf(record, layers.get(record.locator)));
|
|
42
|
+
}
|
|
43
|
+
function inOrder(records) {
|
|
44
|
+
return [...records].sort((left, right) => {
|
|
45
|
+
if (left.locator !== right.locator)
|
|
46
|
+
return left.locator < right.locator ? -1 : 1;
|
|
47
|
+
if (left.path !== right.path)
|
|
48
|
+
return left.path < right.path ? -1 : 1;
|
|
49
|
+
return 0;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function snapshotRoomDrafts(store) {
|
|
53
|
+
return roomDraftsOf(store, inOrder(await store.drafts()));
|
|
54
|
+
}
|
|
55
|
+
export function publishRoomDrafts({ store, socket }, waitingOnly, touched = null) {
|
|
56
|
+
const unwatched = () => socket.closed() || store.watching(ROOM_DRAFTS).length === 0;
|
|
57
|
+
if (unwatched())
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
return store.publication(async () => {
|
|
60
|
+
if (unwatched())
|
|
61
|
+
return;
|
|
62
|
+
const records = await store.drafts();
|
|
63
|
+
if (socket.closed())
|
|
64
|
+
return;
|
|
65
|
+
if (touched !== null &&
|
|
66
|
+
!records.some((record) => touched.some(({ locator, path }) => locator === record.locator && (path === null || path === record.path)))) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const value = await roomDraftsOf(store, inOrder(records));
|
|
70
|
+
if (socket.closed())
|
|
71
|
+
return;
|
|
72
|
+
const answered = store.watching(ROOM_DRAFTS, waitingOnly ? 'waiting' : 'all');
|
|
73
|
+
for (const watcher of answered)
|
|
74
|
+
watcher.answer(value);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async function presentationOf(store, app) {
|
|
78
|
+
const value = await (await store.open()).presentation(app);
|
|
79
|
+
return value === undefined ? null : structuredClone(value);
|
|
80
|
+
}
|
|
81
|
+
export function emitPresentation({ store, socket }, app) {
|
|
82
|
+
const topic = presentationTopic(app);
|
|
83
|
+
const listening = () => store.watching(topic, 'ready');
|
|
84
|
+
if (socket.closed() || listening().length === 0)
|
|
85
|
+
return Promise.resolve();
|
|
86
|
+
return store.publication(async () => {
|
|
87
|
+
if (socket.closed() || listening().length === 0)
|
|
88
|
+
return;
|
|
89
|
+
const value = await presentationOf(store, app);
|
|
90
|
+
if (socket.closed())
|
|
91
|
+
return;
|
|
92
|
+
for (const watcher of listening())
|
|
93
|
+
watcher.answer(value);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async function writtenRoomDraft({ store }, room, path, revision, input, next) {
|
|
97
|
+
const parts = readParts(input, path);
|
|
98
|
+
if (path === '' || normalize(path) !== path)
|
|
99
|
+
throw runtimeError('room-draft-malformed', `room-draft-malformed at ${path}: a path inside the Room, such as notes/a.md`);
|
|
100
|
+
const local = await store.open();
|
|
101
|
+
const current = await store.draft(room, path);
|
|
102
|
+
if ((current?.revision ?? null) !== revision) {
|
|
103
|
+
return staleWrite(current === undefined ? null : (await roomDraftsOf(store, [current]))[0]);
|
|
104
|
+
}
|
|
105
|
+
const file = parts.file === undefined
|
|
106
|
+
? undefined
|
|
107
|
+
: await heldFile(parts.file.blob, parts.file.base === undefined
|
|
108
|
+
? binaryBase(await visibleOf(store, room, [path]), path)
|
|
109
|
+
: parts.file.base);
|
|
110
|
+
const record = {
|
|
111
|
+
locator: room,
|
|
112
|
+
path,
|
|
113
|
+
revision: next,
|
|
114
|
+
parts: held(current?.parts, parts, file),
|
|
115
|
+
returned: current?.returned ?? null,
|
|
116
|
+
};
|
|
117
|
+
await local.keepRoomDraft(record, parts.file === undefined || file === undefined
|
|
118
|
+
? []
|
|
119
|
+
: [{ key: file.localId, blob: parts.file.blob }]);
|
|
120
|
+
await store.changed(changeSet(room, { drafts: [path] }));
|
|
121
|
+
return { outcome: 'written', roomDraft: (await roomDraftsOf(store, [record]))[0] };
|
|
122
|
+
}
|
|
123
|
+
async function keptPresentation({ store }, app, value) {
|
|
124
|
+
await (await store.open()).present({ app, value });
|
|
125
|
+
await store.changed(changeSet('', { presentation: app }));
|
|
126
|
+
}
|
|
127
|
+
export function roomDraftSurface(runtime) {
|
|
128
|
+
const { store } = runtime;
|
|
129
|
+
return {
|
|
130
|
+
list() {
|
|
131
|
+
return store
|
|
132
|
+
.exclusive(async () => {
|
|
133
|
+
await store.open();
|
|
134
|
+
return snapshotRoomDrafts(store);
|
|
135
|
+
})
|
|
136
|
+
.then((listed) => {
|
|
137
|
+
publishRoomDrafts(runtime, true);
|
|
138
|
+
return listed;
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
async read(room, path) {
|
|
142
|
+
const record = await store.draft(room, path);
|
|
143
|
+
return record === undefined ? null : (await roomDraftsOf(store, [record]))[0];
|
|
144
|
+
},
|
|
145
|
+
write(room, path, revision, input, next = roomDraftRevision()) {
|
|
146
|
+
if (typeof next !== 'string' || next === '')
|
|
147
|
+
return Promise.reject(runtimeError('room-draft-malformed'));
|
|
148
|
+
return store.gathered(`room-draft\u0000${room}\u0000${path}`, { revision, input, next }, (earlier, later) => {
|
|
149
|
+
if (later.revision !== earlier.next)
|
|
150
|
+
return null;
|
|
151
|
+
const parts = gatheredParts(earlier.input, later.input);
|
|
152
|
+
return parts === null
|
|
153
|
+
? null
|
|
154
|
+
: { revision: earlier.revision, input: parts, next: later.next };
|
|
155
|
+
}, (written) => writtenRoomDraft(runtime, room, path, written.revision, written.input, written.next));
|
|
156
|
+
},
|
|
157
|
+
discard(room, path, revision) {
|
|
158
|
+
return store.exclusive(async () => {
|
|
159
|
+
const local = await store.open();
|
|
160
|
+
const current = await store.draft(room, path);
|
|
161
|
+
if (current === undefined || current.revision !== revision) {
|
|
162
|
+
return staleWrite(current === undefined ? null : (await roomDraftsOf(store, [current]))[0]);
|
|
163
|
+
}
|
|
164
|
+
await local.discardRoomDraft(room, path);
|
|
165
|
+
await store.changed(changeSet(room, { drafts: [path] }));
|
|
166
|
+
return { outcome: 'written', roomDraft: null };
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export function presentationSurface(runtime) {
|
|
172
|
+
const { store } = runtime;
|
|
173
|
+
return {
|
|
174
|
+
read(app) {
|
|
175
|
+
return store.exclusive(() => presentationOf(store, app));
|
|
176
|
+
},
|
|
177
|
+
write(app, value) {
|
|
178
|
+
return store.exclusive(() => keptPresentation(runtime, app, structuredClone(value)));
|
|
179
|
+
},
|
|
180
|
+
edit(app, members) {
|
|
181
|
+
return store.gathered(`presentation\u0000${app}`, structuredClone(members), (earlier, later) => ({ ...earlier, ...later }), async (edited) => {
|
|
182
|
+
const kept = await (await store.open()).presentation(app);
|
|
183
|
+
await keptPresentation(runtime, app, Object.fromEntries([
|
|
184
|
+
...Object.entries(plain(kept) ? kept : {}).filter(([member]) => !Object.hasOwn(edited, member)),
|
|
185
|
+
...Object.entries(edited).filter(([, value]) => value !== null),
|
|
186
|
+
]));
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
export function watchRoomDrafts({ store, socket }, deliver) {
|
|
192
|
+
const watcher = store.watch(ROOM_DRAFTS, deliver);
|
|
193
|
+
const unwatched = () => socket.closed() || !watcher.held();
|
|
194
|
+
void store
|
|
195
|
+
.exclusive(async () => {
|
|
196
|
+
await store.open();
|
|
197
|
+
})
|
|
198
|
+
.then(() => store.publication(async () => {
|
|
199
|
+
if (unwatched())
|
|
200
|
+
return;
|
|
201
|
+
const value = await snapshotRoomDrafts(store);
|
|
202
|
+
if (!unwatched())
|
|
203
|
+
watcher.answer(value);
|
|
204
|
+
}), uncaught);
|
|
205
|
+
return watcher.stop;
|
|
206
|
+
}
|
|
207
|
+
export function watchPresentation({ store, socket }, app, deliver) {
|
|
208
|
+
const watcher = store.watch(presentationTopic(app), deliver);
|
|
209
|
+
void store
|
|
210
|
+
.exclusive(async () => {
|
|
211
|
+
const value = await presentationOf(store, app);
|
|
212
|
+
if (!socket.closed() && watcher.held())
|
|
213
|
+
watcher.answer(value);
|
|
214
|
+
})
|
|
215
|
+
.catch(uncaught);
|
|
216
|
+
return watcher.stop;
|
|
217
|
+
}
|
package/dist/rows.d.ts
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type {
|
|
3
|
-
import type { BinaryFileRecord } from './binary.js';
|
|
1
|
+
import { type HeldValue } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { SavedFacts } from './adapter.js';
|
|
4
3
|
import { type Composition } from './collection.js';
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fields: Fields;
|
|
13
|
-
values: Fields;
|
|
14
|
-
reached: Readonly<Record<string, readonly unknown[]>>;
|
|
15
|
-
directories: readonly string[];
|
|
16
|
-
text: string | null;
|
|
17
|
-
change: HeadChange | null;
|
|
18
|
-
fileId: string | null;
|
|
19
|
-
binary: BinaryFileRecord | null;
|
|
4
|
+
type LinkKind = 'field' | 'link';
|
|
5
|
+
type HeldLink = {
|
|
6
|
+
readonly kind: LinkKind;
|
|
7
|
+
readonly keys: string;
|
|
8
|
+
readonly places: string;
|
|
9
|
+
readonly target: string;
|
|
10
|
+
readonly field: string;
|
|
20
11
|
};
|
|
21
|
-
export type
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
type: string;
|
|
12
|
+
export type Described = {
|
|
13
|
+
readonly type: string | null;
|
|
14
|
+
readonly declared: string | null;
|
|
15
|
+
readonly queried: boolean;
|
|
16
|
+
readonly folder: string;
|
|
17
|
+
readonly fields: string | null;
|
|
18
|
+
readonly links: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type Held = {
|
|
21
|
+
readonly type: string | null;
|
|
22
|
+
readonly fields: Readonly<Record<string, unknown>> | null;
|
|
23
|
+
readonly links: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
export type Derived = {
|
|
26
|
+
readonly values: readonly HeldValue[];
|
|
27
|
+
readonly links: readonly HeldLink[];
|
|
31
28
|
};
|
|
32
|
-
export type Row = DocumentRow | ReferenceRow;
|
|
33
29
|
export declare function documentKey(room: string, path: string): string;
|
|
34
30
|
export declare function roomOfKey(key: string): string;
|
|
31
|
+
export declare function pathOfKey(key: string): string;
|
|
35
32
|
export declare function markdownPath(path: string): boolean;
|
|
36
|
-
export declare function
|
|
33
|
+
export declare function folderOf(path: string): string;
|
|
34
|
+
export declare function writtenFacts(path: string, content: string, composition: Composition): SavedFacts | null;
|
|
35
|
+
export declare function described(path: string, content: string | null, facts: SavedFacts | null): Described;
|
|
36
|
+
export declare function heldOf(path: string, content: string | null, facts: SavedFacts | null): Held;
|
|
37
|
+
export declare function derived(path: string, held: Held, composition: Composition): Derived;
|
|
37
38
|
export {};
|
|
38
39
|
//# sourceMappingURL=rows.d.ts.map
|
package/dist/rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE7E,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjC,KAAK,QAAQ,GAAG;IACd,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1D,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CACrC,CAAC;AAMF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAaD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,GACvB,UAAU,GAAG,IAAI,CAQnB;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,KAAK,EAAE,UAAU,GAAG,IAAI,GACvB,SAAS,CAeX;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAK3F;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAYnF"}
|
package/dist/rows.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { governing } from './collection.js';
|
|
3
|
-
import { definitionOf } from './model.js';
|
|
1
|
+
import { byCodePoint, documentFacts, indexed, parse } from '@agentshouse/mdmodel';
|
|
2
|
+
import { definitionsAt, governing } from './collection.js';
|
|
4
3
|
function keyOf(...parts) {
|
|
5
4
|
return `${parts.join('\u0000')}\u0000`;
|
|
6
5
|
}
|
|
@@ -10,128 +9,69 @@ export function documentKey(room, path) {
|
|
|
10
9
|
export function roomOfKey(key) {
|
|
11
10
|
return key.split('\u0000')[1];
|
|
12
11
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
12
|
+
export function pathOfKey(key) {
|
|
13
|
+
return key.split('\u0000')[2];
|
|
15
14
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
return value;
|
|
19
|
-
return (typeof value === 'string' ? target(reading.path, value) : null) ?? undefined;
|
|
15
|
+
export function markdownPath(path) {
|
|
16
|
+
return path.endsWith('.md');
|
|
20
17
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
? node.map((item, index) => compared(reading, `${exact}/${index}`, item))
|
|
24
|
-
: compared(reading, exact, node);
|
|
25
|
-
for (const form of forms) {
|
|
26
|
-
if (form.pending)
|
|
27
|
-
continue;
|
|
28
|
-
(reading.reached[form.text] ??= []).push(value);
|
|
29
|
-
if (!form.through && value !== undefined && !plainObject(value)) {
|
|
30
|
-
reading.values[form.text] = value;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (Array.isArray(node) || plainObject(node) || !reading.references.has(exact))
|
|
34
|
-
return;
|
|
35
|
-
const found = compared(reading, exact, node);
|
|
36
|
-
if (typeof found !== 'string')
|
|
37
|
-
return;
|
|
38
|
-
const field = forms
|
|
39
|
-
.map((form) => form.text)
|
|
40
|
-
.reduce((left, right) => (right.length < left.length ? right : left));
|
|
41
|
-
const known = reading.targets.get(`${field}\u0000${found}`);
|
|
42
|
-
const kept = known ?? { field, target: found, forms: new Set() };
|
|
43
|
-
for (const form of forms)
|
|
44
|
-
kept.forms.add(form.text);
|
|
45
|
-
reading.targets.set(`${field}\u0000${found}`, kept);
|
|
18
|
+
export function folderOf(path) {
|
|
19
|
+
return path.slice(0, Math.max(path.lastIndexOf('/'), 0));
|
|
46
20
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
...(form.pending
|
|
52
|
-
? []
|
|
53
|
-
: [{ text: `${form.text}/${index}`, through: form.through, pending: false }]),
|
|
54
|
-
{ text: form.text, through: true, pending: true },
|
|
55
|
-
]), `${exact}/${index}`));
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (!plainObject(node))
|
|
59
|
-
return;
|
|
60
|
-
for (const [key, value] of Object.entries(node)) {
|
|
61
|
-
const segment = escapePointer(key);
|
|
62
|
-
walk(reading, value, forms.flatMap((form) => form.pending && ARRAY_INDEX.test(key)
|
|
63
|
-
? []
|
|
64
|
-
: [{ text: `${form.text}/${segment}`, through: form.through, pending: false }]), `${exact}/${segment}`);
|
|
65
|
-
}
|
|
21
|
+
function byKey(_key, value) {
|
|
22
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
23
|
+
return value;
|
|
24
|
+
return Object.fromEntries(Object.entries(value).sort(([one], [other]) => byCodePoint(one, other)));
|
|
66
25
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
return ['', ...parts.map((_, index) => parts.slice(0, index + 1).join('/'))];
|
|
26
|
+
function fieldsText(fields) {
|
|
27
|
+
return JSON.stringify(fields, byKey);
|
|
70
28
|
}
|
|
71
|
-
export function
|
|
72
|
-
|
|
29
|
+
export function writtenFacts(path, content, composition) {
|
|
30
|
+
const model = governing(composition, path);
|
|
31
|
+
const facts = documentFacts(path, parse(content, path, definitionsAt(composition, path)), {
|
|
32
|
+
types: model.status === 'unavailable' ? {} : model.types,
|
|
33
|
+
});
|
|
34
|
+
return facts === null
|
|
35
|
+
? null
|
|
36
|
+
: { ...facts, fields: JSON.parse(fieldsText(facts.fields)) };
|
|
73
37
|
}
|
|
74
|
-
export function
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
binary,
|
|
92
|
-
},
|
|
93
|
-
];
|
|
94
|
-
}
|
|
95
|
-
const type = document.type ?? 'any';
|
|
96
|
-
const definition = definitionOf(governing(composition, path), document.type);
|
|
97
|
-
const reading = {
|
|
98
|
-
path,
|
|
99
|
-
references: new Set(definition === undefined ? [] : references(document, definition).map((one) => one.pointer)),
|
|
100
|
-
values: {},
|
|
101
|
-
reached: {},
|
|
102
|
-
targets: new Map(),
|
|
38
|
+
export function described(path, content, facts) {
|
|
39
|
+
const folder = folderOf(path);
|
|
40
|
+
const unread = { type: null, fields: null, links: null, folder };
|
|
41
|
+
if (content === null)
|
|
42
|
+
return { ...unread, declared: null, queried: true };
|
|
43
|
+
if (facts === null)
|
|
44
|
+
return { ...unread, declared: null, queried: !markdownPath(path) };
|
|
45
|
+
const links = JSON.stringify(facts.links);
|
|
46
|
+
if (!markdownPath(path))
|
|
47
|
+
return { ...unread, declared: facts.type, queried: true, links };
|
|
48
|
+
return {
|
|
49
|
+
type: facts.type,
|
|
50
|
+
declared: facts.type,
|
|
51
|
+
queried: true,
|
|
52
|
+
folder,
|
|
53
|
+
fields: fieldsText(facts.fields),
|
|
54
|
+
links,
|
|
103
55
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
...[...reading.targets.values()].map(({ field, target: found, forms }) => ({
|
|
126
|
-
key: keyOf('r', room, path, field, found),
|
|
127
|
-
kind: 'reference',
|
|
128
|
-
room,
|
|
129
|
-
source: key,
|
|
130
|
-
target: documentKey(room, found),
|
|
131
|
-
field,
|
|
132
|
-
forms: [...forms].sort(),
|
|
133
|
-
path,
|
|
134
|
-
type,
|
|
135
|
-
})),
|
|
136
|
-
];
|
|
56
|
+
}
|
|
57
|
+
export function heldOf(path, content, facts) {
|
|
58
|
+
if (content === null || facts === null)
|
|
59
|
+
return { type: null, fields: null, links: [] };
|
|
60
|
+
return markdownPath(path)
|
|
61
|
+
? { type: facts.type, fields: facts.fields, links: facts.links }
|
|
62
|
+
: { type: null, fields: null, links: facts.links };
|
|
63
|
+
}
|
|
64
|
+
export function derived(path, held, composition) {
|
|
65
|
+
const stored = held.links.map((target) => ({
|
|
66
|
+
kind: 'link',
|
|
67
|
+
keys: '',
|
|
68
|
+
places: '',
|
|
69
|
+
target,
|
|
70
|
+
field: '',
|
|
71
|
+
}));
|
|
72
|
+
if (held.type === null || held.fields === null)
|
|
73
|
+
return { values: [], links: stored };
|
|
74
|
+
const definition = definitionsAt(composition, path)(held.type);
|
|
75
|
+
const { values, links: fields } = indexed(path, held.fields, definition);
|
|
76
|
+
return { values, links: [...fields, ...stored] };
|
|
137
77
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RoomDeclaration, TypedPath } from './adapter.js';
|
|
2
|
+
import type { RuntimeShell } from './durability.js';
|
|
3
|
+
import type { LiveConversations } from './conversation-live.js';
|
|
4
|
+
import type { WriteRule } from './declaration.js';
|
|
5
|
+
import type { FiguresRead } from './figures.js';
|
|
6
|
+
import type { LiveQueries } from './live.js';
|
|
7
|
+
import type { ModelState } from './model.js';
|
|
8
|
+
import type { Presence } from './presence.js';
|
|
9
|
+
import type { ReadAnswers } from './reads.js';
|
|
10
|
+
import type { Recovery } from './recovery.js';
|
|
11
|
+
import type { Retries } from './retried.js';
|
|
12
|
+
import type { RuntimeSocket } from './socket.js';
|
|
13
|
+
import type { HeldCover, Store } from './store.js';
|
|
14
|
+
import type { schemaTypes } from './attached-model.js';
|
|
15
|
+
export type Runtime = {
|
|
16
|
+
readonly store: Store;
|
|
17
|
+
readonly socket: RuntimeSocket;
|
|
18
|
+
readonly presence: Presence;
|
|
19
|
+
readonly recovery: Recovery;
|
|
20
|
+
readonly retries: Retries;
|
|
21
|
+
readonly shell: RuntimeShell;
|
|
22
|
+
readonly localSaves: boolean;
|
|
23
|
+
readonly roomTypes: Parameters<typeof schemaTypes>[1];
|
|
24
|
+
readonly builtIn: ModelState;
|
|
25
|
+
readonly typedPaths: readonly TypedPath[];
|
|
26
|
+
readonly writeRule: (declaration: RoomDeclaration) => WriteRule;
|
|
27
|
+
readonly usableWhenHeld: readonly string[];
|
|
28
|
+
readonly build: string;
|
|
29
|
+
readonly conversations: LiveConversations;
|
|
30
|
+
readonly liveQueries: LiveQueries<HeldCover>;
|
|
31
|
+
readonly figures: FiguresRead;
|
|
32
|
+
readonly lastAnswers: ReadAnswers;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,CAAC,WAAW,EAAE,eAAe,KAAK,SAAS,CAAC;IAChE,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,iBAAiB,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC,CAAC"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/save.d.ts
CHANGED
|
@@ -1,65 +1,59 @@
|
|
|
1
|
+
import { type Validation } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { ProviderLimit } from './adapter.js';
|
|
2
|
-
import { type
|
|
3
|
+
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
3
4
|
import { type Composition } from './collection.js';
|
|
4
|
-
import type {
|
|
5
|
-
import type
|
|
5
|
+
import type { WriteRule } from './declaration.js';
|
|
6
|
+
import { type Layer } from './overlay.js';
|
|
7
|
+
import type { ReplicaRecord, VisibleLayer } from './replica.js';
|
|
8
|
+
import { type ChangedPart, type RoomDraftRecord, type SavedDraft } from './room-draft.js';
|
|
6
9
|
export type SaveRefusal = {
|
|
7
10
|
code: string;
|
|
8
11
|
retryable: boolean;
|
|
9
12
|
file?: string;
|
|
10
13
|
location?: string;
|
|
14
|
+
line?: number;
|
|
11
15
|
referrers?: readonly string[];
|
|
12
16
|
parts?: readonly ChangedPart[];
|
|
13
17
|
};
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
providerLimits: readonly ProviderLimit[];
|
|
21
|
-
visible: VisibleLayer;
|
|
22
|
-
handle: string;
|
|
23
|
-
changes: readonly Change[];
|
|
24
|
-
bases: readonly Precondition[];
|
|
25
|
-
queued?: ReadonlySet<string>;
|
|
26
|
-
writtenBy?: WrittenBy;
|
|
27
|
-
clean?: {
|
|
28
|
-
text: Readonly<Record<string, string>>;
|
|
29
|
-
binaries: Readonly<Record<string, unknown>>;
|
|
30
|
-
composition: Composition;
|
|
31
|
-
};
|
|
18
|
+
export type SaveAsk = {
|
|
19
|
+
readonly saved: readonly SavedDraft[];
|
|
20
|
+
readonly consumed: ReadonlySet<string>;
|
|
21
|
+
readonly writtenBy?: WrittenBy;
|
|
22
|
+
readonly local: boolean;
|
|
23
|
+
readonly providerLimits: readonly ProviderLimit[];
|
|
32
24
|
};
|
|
33
|
-
export type
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
export type SavingRoom = {
|
|
26
|
+
readonly record: ReplicaRecord;
|
|
27
|
+
readonly rule: WriteRule;
|
|
28
|
+
readonly composition: Composition;
|
|
29
|
+
readonly queue: readonly ChangeBatch[];
|
|
30
|
+
readonly changeable: ReadonlySet<string>;
|
|
31
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
32
|
+
readonly replay: (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
|
|
33
|
+
readonly folders: ReadonlySet<string>;
|
|
34
|
+
readonly modelled: boolean;
|
|
35
|
+
readonly drafts: ReadonlyMap<string, RoomDraftRecord>;
|
|
36
|
+
readonly validate: Validator;
|
|
39
37
|
};
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
queued: ReadonlySet<string>;
|
|
47
|
-
withdrawn: ReadonlyMap<string, ChangeBatch | null>;
|
|
48
|
-
owners: ReadonlySet<string>;
|
|
49
|
-
} | {
|
|
50
|
-
kind: 'refused';
|
|
51
|
-
refusal: SaveRefusal;
|
|
38
|
+
export type PlannedRoom = {
|
|
39
|
+
readonly locator: string;
|
|
40
|
+
readonly queue: readonly ChangeBatch[];
|
|
41
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
42
|
+
readonly consumed: readonly string[];
|
|
43
|
+
readonly carried: readonly RoomDraftRecord[];
|
|
52
44
|
};
|
|
53
|
-
export type
|
|
54
|
-
kind: '
|
|
55
|
-
|
|
56
|
-
queue: readonly ChangeBatch[];
|
|
45
|
+
export type SavePlan = {
|
|
46
|
+
readonly kind: 'refused';
|
|
47
|
+
readonly refusal: SaveRefusal;
|
|
57
48
|
} | {
|
|
58
|
-
kind: '
|
|
59
|
-
|
|
49
|
+
readonly kind: 'planned';
|
|
50
|
+
readonly identifier: string;
|
|
51
|
+
readonly rooms: readonly PlannedRoom[];
|
|
60
52
|
};
|
|
61
|
-
export
|
|
62
|
-
export declare function
|
|
63
|
-
export declare function
|
|
64
|
-
export declare function
|
|
53
|
+
export type Validator = (resulting: Layer, touched: readonly string[]) => Promise<Validation>;
|
|
54
|
+
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
55
|
+
export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
|
|
56
|
+
export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
57
|
+
export declare function destination(locator: string, saved: readonly SavedDraft[]): string | null;
|
|
58
|
+
export declare function planSave(ask: SaveAsk, room: SavingRoom, into?: SavingRoom): Promise<SavePlan>;
|
|
65
59
|
//# sourceMappingURL=save.d.ts.map
|