@agentshouse/mdruntime 0.1.0-cee9c8aa4cd86 → 0.1.0-cef76ea952695
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 +19 -17
- package/dist/acceptance.d.ts +6 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +385 -0
- package/dist/actions.d.ts +20 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +251 -0
- package/dist/adapter.d.ts +111 -109
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -11
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +36 -47
- 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 +22 -10
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +303 -123
- 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 +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- 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 +30 -14
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +61 -10
- package/dist/collection.d.ts +7 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +24 -19
- package/dist/compile.d.ts +6 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +290 -297
- package/dist/connection.d.ts +6 -142
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +105 -4827
- 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 +135 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +247 -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 +42 -46
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +901 -815
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- package/dist/durability.d.ts +15 -4
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +3 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -8
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/failure.d.ts +1 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -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 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- 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 +4 -6
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +59 -38
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +30 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/install.d.ts +56 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +556 -0
- package/dist/job.d.ts +5 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +7 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +270 -0
- package/dist/listing.d.ts +53 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +176 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +63 -21
- package/dist/locks.d.ts +9 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +62 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +61 -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 +13 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +219 -102
- package/dist/messages.d.ts +24 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +89 -31
- package/dist/model.d.ts +8 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -18
- package/dist/models.d.ts +14 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +197 -0
- package/dist/observation.d.ts +3 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +15 -15
- package/dist/opened.js +3 -3
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +60 -0
- package/dist/outcome.d.ts +17 -7
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +19 -5
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +12 -1
- package/dist/parts.d.ts +11 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +21 -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 +233 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +272 -0
- package/dist/query.d.ts +19 -206
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -494
- package/dist/{chat/questions.d.ts → questions.d.ts} +5 -2
- package/dist/questions.d.ts.map +1 -0
- package/dist/{chat/questions.js → questions.js} +13 -2
- package/dist/reach.d.ts +20 -13
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +204 -135
- package/dist/react.d.ts +14 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +10 -1
- 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 +12 -16
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -8
- package/dist/reads.d.ts +36 -10
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +159 -83
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +35 -1
- package/dist/refresh.d.ts +10 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +92 -30
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +57 -0
- package/dist/replica.d.ts +11 -10
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +56 -23
- package/dist/room-draft.d.ts +22 -7
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +134 -54
- 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 +18 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +45 -153
- package/dist/runtime.d.ts +43 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +7 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +46 -27
- package/dist/saves.d.ts +70 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +1005 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- 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 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -105
- package/dist/shown.d.ts +31 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +290 -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 +20 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +77 -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/rooms.d.ts +44 -0
- package/dist/socket/rooms.d.ts.map +1 -0
- package/dist/socket/rooms.js +90 -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 +70 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +175 -0
- package/dist/source.d.ts +61 -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/fences.d.ts +16 -0
- package/dist/store/fences.d.ts.map +1 -0
- package/dist/store/fences.js +26 -0
- 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 +210 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +428 -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 +105 -149
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +143 -390
- package/dist/stored.d.ts +67 -49
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +358 -253
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +224 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +532 -0
- package/dist/tables.d.ts +140 -60
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +268 -101
- 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/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +42 -100
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +22 -10
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +9 -3
- package/package.json +12 -18
- package/AGENTS.md +0 -320
- 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/house.d.ts +0 -25
- package/dist/chat/house.d.ts.map +0 -1
- package/dist/chat/house.js +0 -38
- package/dist/chat/input.d.ts +0 -11
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -92
- 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 -28
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -103
- package/dist/chat/markdown.d.ts +0 -21
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -246
- package/dist/chat/message.d.ts +0 -7
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -254
- package/dist/chat/messages.d.ts +0 -35
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -210
- package/dist/chat/name.d.ts +0 -7
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -12
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -19
- package/dist/chat/overlay.d.ts +0 -32
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -103
- package/dist/chat/parts.d.ts +0 -58
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -120
- package/dist/chat/pieces.d.ts +0 -62
- package/dist/chat/pieces.d.ts.map +0 -1
- package/dist/chat/pieces.js +0 -1110
- 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 -70
- 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 -37
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -93
- package/dist/chat/room-file.d.ts +0 -8
- package/dist/chat/room-file.d.ts.map +0 -1
- package/dist/chat/room-file.js +0 -72
- package/dist/chat/steady.d.ts +0 -3
- package/dist/chat/steady.d.ts.map +0 -1
- package/dist/chat/steady.js +0 -26
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -307
- package/dist/chat.d.ts +0 -15
- 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/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -368
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -150
package/dist/actions.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { roomTarget, target } from '@agentshouse/mdmodel';
|
|
2
|
+
import { resendConversations } from './conversation.js';
|
|
3
|
+
import { listingNow } from './listing.js';
|
|
4
|
+
import { locked, lockedRooms } from './locks.js';
|
|
5
|
+
import { scoped } from './models.js';
|
|
6
|
+
import { ABSENT_TARGET, calledResult, failure, historyAnswer, LOCKED_UNREADABLE, lockedRoom, undeclared, UNCERTAIN, UNREADABLE, } from './outcome.js';
|
|
7
|
+
import { refuse } from './refusal.js';
|
|
8
|
+
function operationOf(input) {
|
|
9
|
+
const operation = input?.operation_id;
|
|
10
|
+
return typeof operation === 'string' ? operation : null;
|
|
11
|
+
}
|
|
12
|
+
export async function readHistory(runtime, locator, path, query = {}) {
|
|
13
|
+
const { store, socket, journal } = runtime;
|
|
14
|
+
const { session } = socket;
|
|
15
|
+
if (socket.closed() || session.now().refusal !== null)
|
|
16
|
+
return UNCERTAIN;
|
|
17
|
+
await socket.firstDiscovery;
|
|
18
|
+
if (!session.now().roomsNamed)
|
|
19
|
+
return UNCERTAIN;
|
|
20
|
+
try {
|
|
21
|
+
await socket.authorize();
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return UNCERTAIN;
|
|
25
|
+
}
|
|
26
|
+
const { closed, authorization, refusal } = session.now();
|
|
27
|
+
if (closed || authorization === undefined || refusal !== null)
|
|
28
|
+
return UNCERTAIN;
|
|
29
|
+
const since = store.fences.count();
|
|
30
|
+
const transfer = ['transfer', 'history', locator, path];
|
|
31
|
+
if (query.revision !== undefined)
|
|
32
|
+
transfer.push(query.revision);
|
|
33
|
+
if (query.pageToken !== undefined)
|
|
34
|
+
transfer.push(query.pageToken);
|
|
35
|
+
journal.record(transfer.join(' '));
|
|
36
|
+
try {
|
|
37
|
+
const result = await socket.history(authorization, {
|
|
38
|
+
locator,
|
|
39
|
+
path,
|
|
40
|
+
...(query.revision === undefined ? {} : { revision: query.revision }),
|
|
41
|
+
...(query.pageToken === undefined ? {} : { pageToken: query.pageToken }),
|
|
42
|
+
});
|
|
43
|
+
journal.record(`outcome history ${result.kind}`);
|
|
44
|
+
if (store.fences.since(locator, since))
|
|
45
|
+
return failure({ kind: 'room-not-readable', locator });
|
|
46
|
+
if (result.kind === 'scoped-refusal') {
|
|
47
|
+
const room = await store.record(result.locator);
|
|
48
|
+
if (room !== undefined)
|
|
49
|
+
await scoped(runtime, result, room, await store.open());
|
|
50
|
+
}
|
|
51
|
+
if (result.kind === 'revoked-authorization')
|
|
52
|
+
await refuse(runtime, 'revoked-authorization');
|
|
53
|
+
return historyAnswer(result);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
journal.record('outcome history transport-uncertainty');
|
|
57
|
+
return UNCERTAIN;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export async function located(runtime, room, path, destination) {
|
|
61
|
+
const crossing = roomTarget(destination);
|
|
62
|
+
const listing = await listingNow(runtime);
|
|
63
|
+
if (crossing === null) {
|
|
64
|
+
const named = target(path, destination);
|
|
65
|
+
return named === null || !listing.has(room) ? null : { room, path: named };
|
|
66
|
+
}
|
|
67
|
+
const held = [...listing.values()].find((listed) => listed.handle === crossing.handle);
|
|
68
|
+
return held === undefined ? null : { room: held.locator, path: crossing.path };
|
|
69
|
+
}
|
|
70
|
+
export async function resolveReference(runtime, room, path, destination) {
|
|
71
|
+
const { store } = runtime;
|
|
72
|
+
if (roomTarget(destination) === null && target(path, destination) === null) {
|
|
73
|
+
return ABSENT_TARGET;
|
|
74
|
+
}
|
|
75
|
+
const at = await located(runtime, room, path, destination);
|
|
76
|
+
if (at === null)
|
|
77
|
+
return UNREADABLE;
|
|
78
|
+
if (await locked(runtime, at.room))
|
|
79
|
+
return LOCKED_UNREADABLE;
|
|
80
|
+
const held = await store.record(at.room);
|
|
81
|
+
if (held !== undefined &&
|
|
82
|
+
(await (await store.open()).entries(held.key, 'visible', [at.path])).length > 0) {
|
|
83
|
+
return { kind: 'document', ...at };
|
|
84
|
+
}
|
|
85
|
+
const history = await readHistory(runtime, at.room, at.path);
|
|
86
|
+
if (history.kind === 'no-history' || history.kind === 'revision')
|
|
87
|
+
return ABSENT_TARGET;
|
|
88
|
+
if (history.kind !== 'history')
|
|
89
|
+
return history;
|
|
90
|
+
const [last] = history.revisions;
|
|
91
|
+
if (last === undefined)
|
|
92
|
+
return ABSENT_TARGET;
|
|
93
|
+
return history.deleted === true
|
|
94
|
+
? { kind: 'deleted', ...at, revision: last }
|
|
95
|
+
: { kind: 'document', ...at };
|
|
96
|
+
}
|
|
97
|
+
async function declaredAction({ store }, name) {
|
|
98
|
+
for (const capability of (await (await store.open()).facts()).capabilities) {
|
|
99
|
+
for (const action of capability.actions ?? []) {
|
|
100
|
+
if (action.name === name)
|
|
101
|
+
return action;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
async function calledRooms(runtime, name, input) {
|
|
107
|
+
const member = (await declaredAction(runtime, name))?.room;
|
|
108
|
+
if (member === undefined || input === null || typeof input !== 'object')
|
|
109
|
+
return [];
|
|
110
|
+
const named = input[member];
|
|
111
|
+
return (Array.isArray(named) ? named : [named]).filter((room) => typeof room === 'string');
|
|
112
|
+
}
|
|
113
|
+
export async function invokeAction(runtime, name, input, dispatching) {
|
|
114
|
+
const { store, socket, journal } = runtime;
|
|
115
|
+
const { session } = socket;
|
|
116
|
+
await socket.ready;
|
|
117
|
+
if (socket.closed() || session.now().refusal !== null)
|
|
118
|
+
return UNCERTAIN;
|
|
119
|
+
if ((await declaredAction(runtime, name)) === undefined)
|
|
120
|
+
return undeclared(name);
|
|
121
|
+
try {
|
|
122
|
+
await socket.authorize();
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return UNCERTAIN;
|
|
126
|
+
}
|
|
127
|
+
const { closed, authorization, refusal } = session.now();
|
|
128
|
+
if (closed || authorization === undefined || refusal !== null)
|
|
129
|
+
return UNCERTAIN;
|
|
130
|
+
await dispatching?.();
|
|
131
|
+
journal.record(`transfer action ${name}`);
|
|
132
|
+
try {
|
|
133
|
+
const result = await socket.action(authorization, { name, input });
|
|
134
|
+
if (result.kind === 'scoped-refusal') {
|
|
135
|
+
const room = await store.record(result.locator);
|
|
136
|
+
if (room !== undefined)
|
|
137
|
+
await scoped(runtime, result, room, await store.open());
|
|
138
|
+
}
|
|
139
|
+
if (result.kind === 'revoked-authorization')
|
|
140
|
+
await refuse(runtime, 'revoked-authorization');
|
|
141
|
+
journal.record(`outcome action ${result.kind}`);
|
|
142
|
+
if (result.kind === 'rejected')
|
|
143
|
+
journal.record(`refusal rejected ${result.code}`);
|
|
144
|
+
return calledResult(result);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
journal.record('outcome action transport-uncertainty');
|
|
148
|
+
return UNCERTAIN;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export async function readConversationHistory(runtime, request) {
|
|
152
|
+
const { socket, journal } = runtime;
|
|
153
|
+
await socket.ready;
|
|
154
|
+
const stream = socket.conversations();
|
|
155
|
+
if (socket.closed() || socket.session.now().refusal !== null || stream?.history === undefined) {
|
|
156
|
+
return UNCERTAIN;
|
|
157
|
+
}
|
|
158
|
+
journal.record('transfer conversation history');
|
|
159
|
+
try {
|
|
160
|
+
const result = await stream.history(request);
|
|
161
|
+
if (result.kind === 'revoked-authorization')
|
|
162
|
+
await refuse(runtime, 'revoked-authorization');
|
|
163
|
+
journal.record(`outcome conversation history ${result.kind}`);
|
|
164
|
+
return calledResult(result);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
journal.record('outcome conversation history transport-uncertainty');
|
|
168
|
+
return UNCERTAIN;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function unsettled(result) {
|
|
172
|
+
if (result.kind === 'action')
|
|
173
|
+
return false;
|
|
174
|
+
return result.retryable && (result.kind !== 'rejected' || result.reset === undefined);
|
|
175
|
+
}
|
|
176
|
+
async function recoveredAction(runtime, name, input) {
|
|
177
|
+
const { store, socket, recovery } = runtime;
|
|
178
|
+
const { lanes } = socket;
|
|
179
|
+
const operation = operationOf(input);
|
|
180
|
+
if (operation === null)
|
|
181
|
+
return invokeAction(runtime, name, input);
|
|
182
|
+
const kept = async () => (await store.open()).keepCall({ operation, name, input });
|
|
183
|
+
lanes.call(operation);
|
|
184
|
+
try {
|
|
185
|
+
let result = await invokeAction(runtime, name, input, kept);
|
|
186
|
+
if (unsettled(result)) {
|
|
187
|
+
await recovery.attempt(`action ${operation}`, async () => {
|
|
188
|
+
if (socket.closed() || socket.session.now().refusal !== null)
|
|
189
|
+
return 'done';
|
|
190
|
+
if (!socket.isOpen())
|
|
191
|
+
return 'again';
|
|
192
|
+
result = await invokeAction(runtime, name, input, kept);
|
|
193
|
+
return unsettled(result) ? 'again' : 'done';
|
|
194
|
+
}, { again: true });
|
|
195
|
+
}
|
|
196
|
+
if (!unsettled(result))
|
|
197
|
+
await (await store.open()).dropCall(operation);
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
lanes.called(operation);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
export async function called(runtime, name, input) {
|
|
205
|
+
await runtime.socket.ready;
|
|
206
|
+
const lockedNow = await lockedRooms(runtime);
|
|
207
|
+
const room = (await calledRooms(runtime, name, input)).find((one) => lockedNow.includes(one));
|
|
208
|
+
return room === undefined ? recoveredAction(runtime, name, input) : lockedRoom(room);
|
|
209
|
+
}
|
|
210
|
+
export async function resendCalls(runtime, signal) {
|
|
211
|
+
const { store, socket } = runtime;
|
|
212
|
+
const { lanes } = socket;
|
|
213
|
+
if (!socket.isOpen() || socket.closed() || socket.stopping())
|
|
214
|
+
return 'done';
|
|
215
|
+
const local = await store.open();
|
|
216
|
+
for (const held of await local.calls()) {
|
|
217
|
+
if (lanes.calling(held.operation))
|
|
218
|
+
continue;
|
|
219
|
+
if (socket.closed() || signal.aborted)
|
|
220
|
+
return 'done';
|
|
221
|
+
lanes.call(held.operation);
|
|
222
|
+
try {
|
|
223
|
+
if (unsettled(await invokeAction(runtime, held.name, held.input)))
|
|
224
|
+
return 'again';
|
|
225
|
+
await local.dropCall(held.operation);
|
|
226
|
+
}
|
|
227
|
+
finally {
|
|
228
|
+
lanes.called(held.operation);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return 'done';
|
|
232
|
+
}
|
|
233
|
+
async function resendPass({ socket, conversations }, signal) {
|
|
234
|
+
if (!socket.continuing() || !socket.isOpen() || socket.stopping())
|
|
235
|
+
return 'done';
|
|
236
|
+
const reading = { complete: true, reachable: true };
|
|
237
|
+
try {
|
|
238
|
+
await resendConversations(conversations, reading);
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
reading.reachable = false;
|
|
242
|
+
}
|
|
243
|
+
if (signal.aborted)
|
|
244
|
+
return 'done';
|
|
245
|
+
return reading.reachable && reading.complete ? 'done' : 'again';
|
|
246
|
+
}
|
|
247
|
+
export function resendLater(runtime) {
|
|
248
|
+
if (!runtime.socket.isOpen())
|
|
249
|
+
return;
|
|
250
|
+
void runtime.recovery.attempt('resend', (signal) => resendPass(runtime, signal), { again: true });
|
|
251
|
+
}
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { SavedFacts, TypedPath } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Operation, SessionState } from '@agentshouse/session-content';
|
|
1
3
|
import type { ModelResult } from './model.js';
|
|
4
|
+
export type { SavedFacts, TypedPath };
|
|
2
5
|
import type { Open } from './open.js';
|
|
3
6
|
import type { ChangeBatch } from './change.js';
|
|
4
7
|
export type Authorization = object;
|
|
@@ -11,7 +14,7 @@ export type TypedSelection = {
|
|
|
11
14
|
};
|
|
12
15
|
export type OperationScopes = {
|
|
13
16
|
write: readonly string[];
|
|
14
|
-
|
|
17
|
+
erase: readonly string[];
|
|
15
18
|
};
|
|
16
19
|
export type ReplicaAdmission = {
|
|
17
20
|
selection: string;
|
|
@@ -27,30 +30,27 @@ export type DiscoveredRoom = {
|
|
|
27
30
|
replica: ReplicaAdmission;
|
|
28
31
|
typedSelection?: TypedSelection;
|
|
29
32
|
providerOwnedPaths: readonly string[];
|
|
33
|
+
authoredPaths?: readonly string[];
|
|
30
34
|
};
|
|
31
35
|
export type Capability = {
|
|
32
36
|
name: string;
|
|
33
37
|
limits?: readonly ProviderLimit[];
|
|
34
38
|
actions?: readonly ActionDeclaration[];
|
|
35
|
-
conversationAgents?: ConversationAgents;
|
|
36
|
-
};
|
|
37
|
-
export type ConversationAgents = {
|
|
38
|
-
locator: string;
|
|
39
|
-
type: string;
|
|
40
|
-
identity: string;
|
|
41
|
-
name: string;
|
|
42
|
-
retired?: string;
|
|
43
39
|
};
|
|
44
40
|
export type ListedConversation = {
|
|
45
41
|
conversation: string;
|
|
46
42
|
agent: string;
|
|
43
|
+
agentName: string;
|
|
44
|
+
agentRetired: boolean;
|
|
47
45
|
name: string;
|
|
48
46
|
created: string;
|
|
49
47
|
finished: string | null;
|
|
50
48
|
outcome: string | null;
|
|
51
49
|
waiting: boolean;
|
|
50
|
+
newest: string | null;
|
|
51
|
+
processEnded: string | null;
|
|
52
52
|
};
|
|
53
|
-
export type ConversationAction = '
|
|
53
|
+
export type ConversationAction = 'conversations/create' | 'conversations/send' | 'conversations/interaction/answer' | 'conversations/interrupt' | 'conversations/kill' | 'conversations/delete';
|
|
54
54
|
export type ConversationMessage = {
|
|
55
55
|
identity: string;
|
|
56
56
|
turn: string;
|
|
@@ -74,37 +74,10 @@ export type ConversationHistoryPage = {
|
|
|
74
74
|
export type ConversationHistories = {
|
|
75
75
|
histories: readonly ConversationHistoryPage[];
|
|
76
76
|
};
|
|
77
|
-
export type TurnContext = {
|
|
78
|
-
used: number;
|
|
79
|
-
window: number;
|
|
80
|
-
};
|
|
81
77
|
export type TurnOperation = {
|
|
82
78
|
op: 'begin';
|
|
83
79
|
at: string;
|
|
84
|
-
} |
|
|
85
|
-
op: 'start';
|
|
86
|
-
index: number;
|
|
87
|
-
part: unknown;
|
|
88
|
-
} | {
|
|
89
|
-
op: 'append';
|
|
90
|
-
index: number;
|
|
91
|
-
text: string;
|
|
92
|
-
} | {
|
|
93
|
-
op: 'status';
|
|
94
|
-
index: number;
|
|
95
|
-
status: string;
|
|
96
|
-
result: unknown;
|
|
97
|
-
} | {
|
|
98
|
-
op: 'count';
|
|
99
|
-
index: number;
|
|
100
|
-
count: number;
|
|
101
|
-
} | {
|
|
102
|
-
op: 'plan';
|
|
103
|
-
index: number;
|
|
104
|
-
entries: readonly unknown[];
|
|
105
|
-
} | ({
|
|
106
|
-
op: 'context';
|
|
107
|
-
} & TurnContext);
|
|
80
|
+
} | Operation;
|
|
108
81
|
export type ProcessCommand = {
|
|
109
82
|
[field: string]: unknown;
|
|
110
83
|
name: string;
|
|
@@ -166,6 +139,10 @@ export type ConversationEvent = {
|
|
|
166
139
|
kind: 'starting';
|
|
167
140
|
conversation: string;
|
|
168
141
|
step: string | null;
|
|
142
|
+
} | {
|
|
143
|
+
kind: 'state';
|
|
144
|
+
conversation: string;
|
|
145
|
+
state: SessionState | null;
|
|
169
146
|
} | {
|
|
170
147
|
kind: 'link';
|
|
171
148
|
conversation: string;
|
|
@@ -184,6 +161,9 @@ export type ConversationEvent = {
|
|
|
184
161
|
} | {
|
|
185
162
|
kind: 'list';
|
|
186
163
|
entries: readonly ListedConversation[];
|
|
164
|
+
whole: boolean;
|
|
165
|
+
more: boolean;
|
|
166
|
+
cursor: string | null;
|
|
187
167
|
} | {
|
|
188
168
|
kind: 'listed';
|
|
189
169
|
entry: ListedConversation;
|
|
@@ -191,9 +171,17 @@ export type ConversationEvent = {
|
|
|
191
171
|
kind: 'unlisted';
|
|
192
172
|
conversation: string;
|
|
193
173
|
};
|
|
174
|
+
export type ListedAgent = {
|
|
175
|
+
agent: string;
|
|
176
|
+
name: string;
|
|
177
|
+
retired: boolean;
|
|
178
|
+
};
|
|
194
179
|
export type ConversationStream = {
|
|
195
180
|
replicate(conversations: readonly string[]): void;
|
|
181
|
+
hold(cursor: string | null): void;
|
|
196
182
|
observe(notify: (event: ConversationEvent) => void): () => void;
|
|
183
|
+
agents?(): Promise<readonly ListedAgent[] | null>;
|
|
184
|
+
history?(request: ConversationHistoryRequest): Promise<ActionResult>;
|
|
197
185
|
};
|
|
198
186
|
export type ActionDeclaration = {
|
|
199
187
|
name: string;
|
|
@@ -213,7 +201,6 @@ export type HistoryRetention = {
|
|
|
213
201
|
};
|
|
214
202
|
export type Retention = {
|
|
215
203
|
history: HistoryRetention;
|
|
216
|
-
outcome: number;
|
|
217
204
|
refreshHorizon: number;
|
|
218
205
|
};
|
|
219
206
|
export type Discovery = {
|
|
@@ -223,10 +210,6 @@ export type Discovery = {
|
|
|
223
210
|
providerLimits: readonly ProviderLimit[];
|
|
224
211
|
retention: Retention;
|
|
225
212
|
member?: Member;
|
|
226
|
-
covered?: readonly string[];
|
|
227
|
-
};
|
|
228
|
-
export type DiscoveryScope = {
|
|
229
|
-
readonly authorities: readonly string[];
|
|
230
213
|
};
|
|
231
214
|
export type TransportUncertainty = {
|
|
232
215
|
kind: 'transport-uncertainty';
|
|
@@ -255,7 +238,7 @@ export type ContractUnavailable = ProviderRefusal & {
|
|
|
255
238
|
export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
|
|
256
239
|
export type PageToken = string;
|
|
257
240
|
export type ChangeAuthor = {
|
|
258
|
-
kind: Open<'user' | 'site' | 'inbox'>;
|
|
241
|
+
kind: Open<'user' | 'site' | 'inbox' | 'app'>;
|
|
259
242
|
id: string;
|
|
260
243
|
name: string;
|
|
261
244
|
};
|
|
@@ -269,47 +252,49 @@ export type HeadChange = {
|
|
|
269
252
|
time: string;
|
|
270
253
|
};
|
|
271
254
|
export type BinaryFile = {
|
|
272
|
-
fileRef: string;
|
|
273
255
|
byteLength: number;
|
|
274
256
|
mediaType: string;
|
|
275
257
|
sha256: string;
|
|
276
258
|
};
|
|
277
|
-
export type HeldFile = {
|
|
278
|
-
readonly path: string;
|
|
279
|
-
readonly revision: string;
|
|
280
|
-
};
|
|
281
|
-
export type HeldContent = {
|
|
282
|
-
files(after: string | null, limit: number): Promise<readonly HeldFile[]>;
|
|
283
|
-
contents(paths: readonly string[]): Promise<ReadonlyMap<string, {
|
|
284
|
-
readonly content: string;
|
|
285
|
-
readonly revision: string;
|
|
286
|
-
}>>;
|
|
287
|
-
};
|
|
288
259
|
export type BootstrapRequest = {
|
|
289
260
|
locator: string;
|
|
290
261
|
selection: string;
|
|
291
262
|
pageToken?: PageToken;
|
|
292
|
-
|
|
263
|
+
arriving?: (bytes: number) => void;
|
|
264
|
+
signal?: AbortSignal;
|
|
265
|
+
};
|
|
266
|
+
export type BootstrapPart = {
|
|
267
|
+
readonly id: string;
|
|
268
|
+
readonly bytes: number;
|
|
269
|
+
};
|
|
270
|
+
export type BootstrapInventory = {
|
|
271
|
+
readonly bytes: number;
|
|
293
272
|
};
|
|
294
273
|
export type RoomModels = {
|
|
295
274
|
collection?: ModelResult;
|
|
296
|
-
selection?: ModelResult;
|
|
297
275
|
};
|
|
298
276
|
export type BootstrapPage = {
|
|
299
277
|
kind: 'bootstrap';
|
|
300
278
|
roomVersion: string;
|
|
301
279
|
models?: RoomModels;
|
|
302
280
|
documents: Readonly<Record<string, string>>;
|
|
281
|
+
facts: Readonly<Record<string, SavedFacts>>;
|
|
303
282
|
revisions: Readonly<Record<string, string>>;
|
|
304
283
|
fileIds?: Readonly<Record<string, string>>;
|
|
284
|
+
created?: Readonly<Record<string, string>>;
|
|
305
285
|
changes: Readonly<Record<string, HeadChange>>;
|
|
306
286
|
binaryFiles: Readonly<Record<string, BinaryFile>>;
|
|
307
287
|
folders?: readonly string[];
|
|
308
288
|
pageToken?: PageToken;
|
|
289
|
+
parts?: readonly BootstrapPart[];
|
|
290
|
+
bytes?: number;
|
|
291
|
+
};
|
|
292
|
+
export type NotReady = {
|
|
293
|
+
kind: 'not-ready';
|
|
309
294
|
};
|
|
310
295
|
export type BootstrapResult = BootstrapPage | {
|
|
311
296
|
kind: 'beyond-horizon';
|
|
312
|
-
} | AdapterFailure;
|
|
297
|
+
} | NotReady | AdapterFailure;
|
|
313
298
|
export type RefreshRequest = {
|
|
314
299
|
locator: string;
|
|
315
300
|
selection: string;
|
|
@@ -321,8 +306,10 @@ export type RefreshPage = {
|
|
|
321
306
|
roomVersion: string;
|
|
322
307
|
models?: RoomModels;
|
|
323
308
|
documents: Readonly<Record<string, string>>;
|
|
309
|
+
facts: Readonly<Record<string, SavedFacts>>;
|
|
324
310
|
revisions: Readonly<Record<string, string>>;
|
|
325
311
|
fileIds?: Readonly<Record<string, string>>;
|
|
312
|
+
created?: Readonly<Record<string, string>>;
|
|
326
313
|
changes: Readonly<Record<string, HeadChange>>;
|
|
327
314
|
binaryFiles: Readonly<Record<string, BinaryFile>>;
|
|
328
315
|
removals: readonly string[];
|
|
@@ -372,15 +359,9 @@ export type MutationResult = (AcceptedRoom & {
|
|
|
372
359
|
affected: Readonly<Record<string, string>>;
|
|
373
360
|
}) | RetryableRefusal | {
|
|
374
361
|
kind: 'write-halted';
|
|
375
|
-
} | {
|
|
376
|
-
kind: 'expired';
|
|
377
|
-
restored?: true;
|
|
378
362
|
} | AdapterFailure;
|
|
379
363
|
export type HistoryAuthor = {
|
|
380
|
-
kind: 'user';
|
|
381
|
-
id: string;
|
|
382
|
-
} | {
|
|
383
|
-
kind: 'site' | 'inbox';
|
|
364
|
+
kind: 'user' | 'site' | 'inbox' | 'app';
|
|
384
365
|
id: string;
|
|
385
366
|
name: string;
|
|
386
367
|
};
|
|
@@ -412,15 +393,6 @@ export type BinaryRequest = {
|
|
|
412
393
|
locator: string;
|
|
413
394
|
path: string;
|
|
414
395
|
revision: string;
|
|
415
|
-
fileRef?: string;
|
|
416
|
-
} | {
|
|
417
|
-
kind: 'reference';
|
|
418
|
-
fileRef: string;
|
|
419
|
-
referrer: unknown;
|
|
420
|
-
};
|
|
421
|
-
export type ReferrerScope = {
|
|
422
|
-
locator: string;
|
|
423
|
-
path?: string;
|
|
424
396
|
};
|
|
425
397
|
export type BinaryResult = {
|
|
426
398
|
kind: 'binary';
|
|
@@ -434,6 +406,22 @@ export type BinaryLinkResult = {
|
|
|
434
406
|
kind: 'link';
|
|
435
407
|
url: string;
|
|
436
408
|
name: string;
|
|
409
|
+
mediaType?: string;
|
|
410
|
+
} | (ProviderRefusal & {
|
|
411
|
+
kind: 'rejected';
|
|
412
|
+
}) | AdapterFailure;
|
|
413
|
+
export type AttachRequest = {
|
|
414
|
+
locator: string;
|
|
415
|
+
name: string;
|
|
416
|
+
mediaType: string;
|
|
417
|
+
byteLength: number;
|
|
418
|
+
sha256: string;
|
|
419
|
+
blob: Blob;
|
|
420
|
+
};
|
|
421
|
+
export type AttachResult = {
|
|
422
|
+
kind: 'attached';
|
|
423
|
+
path: string;
|
|
424
|
+
revision: string;
|
|
437
425
|
} | (ProviderRefusal & {
|
|
438
426
|
kind: 'rejected';
|
|
439
427
|
}) | AdapterFailure;
|
|
@@ -449,71 +437,85 @@ export type ActionResult = {
|
|
|
449
437
|
kind: 'action';
|
|
450
438
|
result: unknown;
|
|
451
439
|
at?: RoomVersionAt;
|
|
440
|
+
} | (ProviderRefusal & {
|
|
441
|
+
kind: 'rejected';
|
|
442
|
+
reset?: string;
|
|
443
|
+
}) | AdapterFailure;
|
|
444
|
+
export type SearchHit = {
|
|
445
|
+
room: string;
|
|
446
|
+
path: string;
|
|
447
|
+
line?: number;
|
|
448
|
+
snippet?: string;
|
|
449
|
+
};
|
|
450
|
+
export type SearchAsk = {
|
|
451
|
+
text: string;
|
|
452
|
+
rooms: readonly string[] | null;
|
|
453
|
+
};
|
|
454
|
+
export type SearchAnswer = {
|
|
455
|
+
kind: 'found';
|
|
456
|
+
documents: readonly SearchHit[];
|
|
452
457
|
} | (ProviderRefusal & {
|
|
453
458
|
kind: 'rejected';
|
|
454
459
|
}) | AdapterFailure;
|
|
455
460
|
export type HeldRoom = {
|
|
456
461
|
locator: string;
|
|
462
|
+
roomVersion: string | null;
|
|
463
|
+
};
|
|
464
|
+
export type RoomChange = {
|
|
465
|
+
kind: 'room-change';
|
|
466
|
+
locator: string;
|
|
467
|
+
from: string | null;
|
|
457
468
|
roomVersion: string;
|
|
469
|
+
read(): Promise<RefreshPage>;
|
|
470
|
+
};
|
|
471
|
+
export type AuthorityChange = {
|
|
472
|
+
kind: 'authority-changed';
|
|
473
|
+
rooms: readonly DiscoveredRoom[];
|
|
474
|
+
left: readonly string[];
|
|
475
|
+
member?: Member;
|
|
458
476
|
};
|
|
459
|
-
export type HeldRevisions = (locator: string, paths: readonly string[]) => Promise<ReadonlyMap<string, string>>;
|
|
460
477
|
export type RoomStreamEvent = {
|
|
461
478
|
kind: 'opened';
|
|
479
|
+
} | {
|
|
480
|
+
kind: 'discovered';
|
|
481
|
+
discovery: Discovery;
|
|
462
482
|
} | {
|
|
463
483
|
kind: 'closed';
|
|
464
484
|
revoked: boolean;
|
|
465
485
|
lost: boolean;
|
|
486
|
+
authorityChanged: boolean;
|
|
466
487
|
} | {
|
|
467
|
-
kind: '
|
|
488
|
+
kind: 'caught-up';
|
|
468
489
|
expired: readonly string[];
|
|
469
|
-
} |
|
|
470
|
-
kind: 'authority-changed';
|
|
471
|
-
scope?: DiscoveryScope;
|
|
472
|
-
} | {
|
|
473
|
-
kind: 'room-version';
|
|
474
|
-
locator: string;
|
|
475
|
-
roomVersion: string;
|
|
476
|
-
};
|
|
477
|
-
export type KeptReceipt = {
|
|
478
|
-
key: string;
|
|
479
|
-
head: unknown;
|
|
480
|
-
};
|
|
481
|
-
export type StreamReceipts = {
|
|
482
|
-
heads(): Promise<readonly KeptReceipt[]>;
|
|
483
|
-
parts(key: string, count: number): Promise<readonly unknown[]>;
|
|
484
|
-
keep(key: string, head: unknown, part?: {
|
|
485
|
-
index: number;
|
|
486
|
-
value: unknown;
|
|
487
|
-
}): Promise<void>;
|
|
488
|
-
drop(keys: readonly string[]): Promise<void>;
|
|
489
|
-
};
|
|
490
|
+
} | AuthorityChange | RoomChange;
|
|
490
491
|
export type RoomStream = {
|
|
491
492
|
hold(rooms: readonly HeldRoom[]): void;
|
|
492
|
-
|
|
493
|
-
published(locator: string, roomVersion: string): void;
|
|
494
|
-
observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts, revisions: HeldRevisions): () => void;
|
|
493
|
+
observe(notify: (event: RoomStreamEvent) => void): () => void;
|
|
495
494
|
};
|
|
495
|
+
export type PathRule = (path: string) => boolean;
|
|
496
496
|
export type Adapter = {
|
|
497
497
|
readonly localSaves?: true;
|
|
498
|
-
readonly exhaustiveDiscovery?: true;
|
|
499
498
|
readonly roomTypes?: string;
|
|
499
|
+
readonly nameableRoomTypes?: readonly string[];
|
|
500
|
+
readonly typedPaths?: readonly TypedPath[];
|
|
501
|
+
readonly pathRule?: PathRule;
|
|
502
|
+
readonly unkeptReads?: readonly string[];
|
|
503
|
+
readonly leadingReads?: readonly string[];
|
|
500
504
|
authorize(): Promise<Authorization>;
|
|
501
|
-
discover(authorization: Authorization
|
|
505
|
+
discover?(authorization: Authorization): Promise<DiscoverResult>;
|
|
502
506
|
bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
|
|
503
|
-
refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
|
|
507
|
+
refresh?(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
|
|
504
508
|
mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
|
|
505
509
|
history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
|
|
506
510
|
binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
|
|
507
|
-
link(authorization: Authorization, request:
|
|
508
|
-
|
|
509
|
-
}>): Promise<BinaryLinkResult>;
|
|
510
|
-
referrerScope(referrer: unknown): ReferrerScope | null;
|
|
511
|
+
link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
|
|
512
|
+
attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
|
|
511
513
|
action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
|
|
514
|
+
search?(authorization: Authorization, request: SearchAsk): Promise<SearchAnswer>;
|
|
512
515
|
reached(locator: string, roomVersion: string, target: string): boolean;
|
|
513
516
|
follows(locator: string, roomVersion: string, next: string): boolean;
|
|
514
517
|
roomStream?: RoomStream;
|
|
515
518
|
conversations?: ConversationStream;
|
|
516
519
|
serviceMode?: ServiceModeSignal;
|
|
517
520
|
};
|
|
518
|
-
export {};
|
|
519
521
|
//# sourceMappingURL=adapter.d.ts.map
|