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