@agentshouse/mdruntime 0.1.0-cf24798931067 → 0.1.0-cf281e8224a5d
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 +22 -10
- 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 +177 -54
- 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/attempt.d.ts.map +1 -1
- package/dist/attempt.js +14 -1
- package/dist/binary.d.ts +18 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +31 -11
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +324 -92
- 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 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -62
- package/dist/change.d.ts +42 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +36 -0
- 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 +50 -15
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +110 -9
- package/dist/collection.d.ts +11 -7
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +38 -79
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +711 -0
- package/dist/connection.d.ts +8 -111
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +104 -2219
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-live.d.ts +136 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +248 -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 +57 -40
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +992 -543
- 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 +19 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +20 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +161 -0
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- 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 +12 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +132 -18
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +3 -0
- package/dist/index.d.ts +35 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/install.d.ts +56 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +554 -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 +268 -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 +23 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +163 -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 +21 -7
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +271 -91
- package/dist/messages.d.ts +52 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +162 -0
- package/dist/model.d.ts +11 -11
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -10
- package/dist/models.d.ts +14 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +195 -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 +22 -4
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +127 -26
- 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 +57 -0
- package/dist/outcome.d.ts +56 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +49 -0
- package/dist/overlay.d.ts +16 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +140 -177
- package/dist/{chat/parts.d.ts → parts.d.ts} +12 -9
- package/dist/parts.d.ts.map +1 -0
- package/dist/{chat/parts.js → parts.js} +53 -46
- 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 +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 +51 -183
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -464
- 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 +21 -5
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +291 -69
- package/dist/react.d.ts +20 -6
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +17 -18
- 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 +49 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +27 -0
- package/dist/reads.d.ts +37 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +171 -0
- package/dist/recovery.d.ts +26 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +232 -0
- package/dist/refresh.d.ts +17 -14
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +143 -56
- 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 +59 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +342 -158
- package/dist/room-draft.d.ts +54 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +268 -63
- 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 +30 -35
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +59 -124
- 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 +74 -3
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +812 -153
- 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 +15 -55
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +10 -121
- package/dist/seed.d.ts +25 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +145 -0
- package/dist/shared.d.ts +10 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +339 -0
- package/dist/shown.d.ts +31 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +292 -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 +5 -2
- 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 +431 -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 +106 -117
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +137 -496
- package/dist/stored.d.ts +156 -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 +223 -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 +416 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +740 -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 +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- 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 +11 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +16 -0
- package/dist/wire.d.ts +181 -31
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +62 -29
- package/package.json +26 -15
- package/AGENTS.md +0 -290
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
- package/dist/chat/acts.d.ts +0 -34
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/messages.d.ts +0 -21
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -151
- 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 -57
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -637
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat.d.ts +0 -7
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -2
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -433
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,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;
|
|
@@ -28,29 +29,27 @@ export type DiscoveredRoom = {
|
|
|
28
29
|
replica: ReplicaAdmission;
|
|
29
30
|
typedSelection?: TypedSelection;
|
|
30
31
|
providerOwnedPaths: readonly string[];
|
|
32
|
+
authoredPaths?: readonly string[];
|
|
31
33
|
};
|
|
32
34
|
export type Capability = {
|
|
33
35
|
name: string;
|
|
34
36
|
limits?: readonly ProviderLimit[];
|
|
35
37
|
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
38
|
};
|
|
45
39
|
export type ListedConversation = {
|
|
46
40
|
conversation: string;
|
|
47
41
|
agent: string;
|
|
42
|
+
agentName: string;
|
|
43
|
+
agentRetired: boolean;
|
|
48
44
|
name: string;
|
|
49
45
|
created: string;
|
|
50
46
|
finished: string | null;
|
|
51
47
|
outcome: string | null;
|
|
48
|
+
waiting: boolean;
|
|
49
|
+
newest: string | null;
|
|
50
|
+
processEnded: string | null;
|
|
52
51
|
};
|
|
53
|
-
export type ConversationAction = '
|
|
52
|
+
export type ConversationAction = 'conversations/create' | 'conversations/send' | 'conversations/interaction/answer' | 'conversations/interrupt' | 'conversations/kill' | 'conversations/delete';
|
|
54
53
|
export type ConversationMessage = {
|
|
55
54
|
identity: string;
|
|
56
55
|
turn: string;
|
|
@@ -141,6 +140,10 @@ export type SessionOption = (SessionOptionNaming & {
|
|
|
141
140
|
type: 'boolean';
|
|
142
141
|
currentValue: boolean;
|
|
143
142
|
});
|
|
143
|
+
export type RunningSubagent = {
|
|
144
|
+
description: string;
|
|
145
|
+
activity: string | null;
|
|
146
|
+
};
|
|
144
147
|
export type ConversationEvent = {
|
|
145
148
|
kind: 'turn';
|
|
146
149
|
conversation: string;
|
|
@@ -162,6 +165,22 @@ export type ConversationEvent = {
|
|
|
162
165
|
kind: 'options';
|
|
163
166
|
conversation: string;
|
|
164
167
|
options: readonly SessionOption[];
|
|
168
|
+
} | {
|
|
169
|
+
kind: 'starting';
|
|
170
|
+
conversation: string;
|
|
171
|
+
step: string | null;
|
|
172
|
+
} | {
|
|
173
|
+
kind: 'subagents';
|
|
174
|
+
conversation: string;
|
|
175
|
+
subagents: readonly RunningSubagent[];
|
|
176
|
+
} | {
|
|
177
|
+
kind: 'link';
|
|
178
|
+
conversation: string;
|
|
179
|
+
connected: boolean;
|
|
180
|
+
} | {
|
|
181
|
+
kind: 'deliveries';
|
|
182
|
+
conversation: string;
|
|
183
|
+
unknown: readonly string[];
|
|
165
184
|
} | {
|
|
166
185
|
kind: 'accepted-message';
|
|
167
186
|
conversation: string;
|
|
@@ -172,6 +191,9 @@ export type ConversationEvent = {
|
|
|
172
191
|
} | {
|
|
173
192
|
kind: 'list';
|
|
174
193
|
entries: readonly ListedConversation[];
|
|
194
|
+
whole: boolean;
|
|
195
|
+
more: boolean;
|
|
196
|
+
cursor: string | null;
|
|
175
197
|
} | {
|
|
176
198
|
kind: 'listed';
|
|
177
199
|
entry: ListedConversation;
|
|
@@ -179,14 +201,23 @@ export type ConversationEvent = {
|
|
|
179
201
|
kind: 'unlisted';
|
|
180
202
|
conversation: string;
|
|
181
203
|
};
|
|
204
|
+
export type ListedAgent = {
|
|
205
|
+
agent: string;
|
|
206
|
+
name: string;
|
|
207
|
+
retired: boolean;
|
|
208
|
+
};
|
|
182
209
|
export type ConversationStream = {
|
|
183
210
|
replicate(conversations: readonly string[]): void;
|
|
211
|
+
hold(cursor: string | null): void;
|
|
184
212
|
observe(notify: (event: ConversationEvent) => void): () => void;
|
|
213
|
+
agents?(): Promise<readonly ListedAgent[] | null>;
|
|
214
|
+
history?(request: ConversationHistoryRequest): Promise<ActionResult>;
|
|
185
215
|
};
|
|
186
216
|
export type ActionDeclaration = {
|
|
187
217
|
name: string;
|
|
188
218
|
inputShape: unknown;
|
|
189
219
|
resultKind: unknown;
|
|
220
|
+
room?: string;
|
|
190
221
|
};
|
|
191
222
|
export type ProviderLimit = {
|
|
192
223
|
name: string;
|
|
@@ -200,7 +231,6 @@ export type HistoryRetention = {
|
|
|
200
231
|
};
|
|
201
232
|
export type Retention = {
|
|
202
233
|
history: HistoryRetention;
|
|
203
|
-
outcome: number;
|
|
204
234
|
refreshHorizon: number;
|
|
205
235
|
};
|
|
206
236
|
export type Discovery = {
|
|
@@ -229,7 +259,7 @@ export type ProviderRefusal = {
|
|
|
229
259
|
export type ScopedRefusal = ProviderRefusal & {
|
|
230
260
|
kind: 'scoped-refusal';
|
|
231
261
|
locator: string;
|
|
232
|
-
scope: Open<'content' | '
|
|
262
|
+
scope: Open<'content' | 'model' | 'operation' | 'undisclosed'>;
|
|
233
263
|
};
|
|
234
264
|
export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
|
|
235
265
|
export type ContractUnavailable = ProviderRefusal & {
|
|
@@ -238,49 +268,63 @@ export type ContractUnavailable = ProviderRefusal & {
|
|
|
238
268
|
export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
|
|
239
269
|
export type PageToken = string;
|
|
240
270
|
export type ChangeAuthor = {
|
|
241
|
-
kind: 'user'
|
|
271
|
+
kind: Open<'user' | 'site' | 'inbox' | 'app'>;
|
|
242
272
|
id: string;
|
|
243
273
|
name: string;
|
|
244
|
-
}
|
|
245
|
-
|
|
274
|
+
};
|
|
275
|
+
export type Member = {
|
|
276
|
+
kind: Open<'user'>;
|
|
246
277
|
id: string;
|
|
247
278
|
name: string;
|
|
248
279
|
};
|
|
249
|
-
export type Member = Extract<ChangeAuthor, {
|
|
250
|
-
kind: 'user';
|
|
251
|
-
}>;
|
|
252
280
|
export type HeadChange = {
|
|
253
281
|
author: ChangeAuthor | null;
|
|
254
282
|
time: string;
|
|
255
283
|
};
|
|
256
|
-
export type
|
|
257
|
-
reference: string;
|
|
258
|
-
name: string;
|
|
284
|
+
export type BinaryFile = {
|
|
259
285
|
byteLength: number;
|
|
260
|
-
mediaType: string
|
|
261
|
-
|
|
286
|
+
mediaType: string;
|
|
287
|
+
sha256: string;
|
|
262
288
|
};
|
|
263
289
|
export type BootstrapRequest = {
|
|
264
290
|
locator: string;
|
|
265
291
|
selection: string;
|
|
266
292
|
pageToken?: PageToken;
|
|
293
|
+
arriving?: (bytes: number) => void;
|
|
294
|
+
signal?: AbortSignal;
|
|
295
|
+
};
|
|
296
|
+
export type BootstrapPart = {
|
|
297
|
+
readonly id: string;
|
|
298
|
+
readonly bytes: number;
|
|
299
|
+
};
|
|
300
|
+
export type BootstrapInventory = {
|
|
301
|
+
readonly bytes: number;
|
|
267
302
|
};
|
|
268
303
|
export type RoomModels = {
|
|
269
304
|
collection?: ModelResult;
|
|
270
|
-
selection?: ModelResult;
|
|
271
305
|
};
|
|
272
306
|
export type BootstrapPage = {
|
|
273
307
|
kind: 'bootstrap';
|
|
274
308
|
roomVersion: string;
|
|
275
309
|
models?: RoomModels;
|
|
276
310
|
documents: Readonly<Record<string, string>>;
|
|
311
|
+
facts: Readonly<Record<string, SavedFacts>>;
|
|
277
312
|
revisions: Readonly<Record<string, string>>;
|
|
313
|
+
fileIds?: Readonly<Record<string, string>>;
|
|
314
|
+
created?: Readonly<Record<string, string>>;
|
|
278
315
|
changes: Readonly<Record<string, HeadChange>>;
|
|
279
|
-
|
|
280
|
-
|
|
316
|
+
binaryFiles: Readonly<Record<string, BinaryFile>>;
|
|
317
|
+
folders?: readonly string[];
|
|
281
318
|
pageToken?: PageToken;
|
|
319
|
+
parts?: readonly BootstrapPart[];
|
|
320
|
+
bytes?: number;
|
|
321
|
+
};
|
|
322
|
+
export type NotReady = {
|
|
323
|
+
kind: 'not-ready';
|
|
282
324
|
};
|
|
283
|
-
export type BootstrapResult = BootstrapPage |
|
|
325
|
+
export type BootstrapResult = BootstrapPage | {
|
|
326
|
+
kind: 'beyond-horizon';
|
|
327
|
+
} | NotReady | AdapterFailure;
|
|
284
328
|
export type RefreshRequest = {
|
|
285
329
|
locator: string;
|
|
286
330
|
selection: string;
|
|
@@ -292,11 +336,15 @@ export type RefreshPage = {
|
|
|
292
336
|
roomVersion: string;
|
|
293
337
|
models?: RoomModels;
|
|
294
338
|
documents: Readonly<Record<string, string>>;
|
|
339
|
+
facts: Readonly<Record<string, SavedFacts>>;
|
|
295
340
|
revisions: Readonly<Record<string, string>>;
|
|
341
|
+
fileIds?: Readonly<Record<string, string>>;
|
|
342
|
+
created?: Readonly<Record<string, string>>;
|
|
296
343
|
changes: Readonly<Record<string, HeadChange>>;
|
|
297
|
-
|
|
344
|
+
binaryFiles: Readonly<Record<string, BinaryFile>>;
|
|
298
345
|
removals: readonly string[];
|
|
299
|
-
|
|
346
|
+
folders?: readonly string[];
|
|
347
|
+
folderRemovals?: readonly string[];
|
|
300
348
|
pageToken?: PageToken;
|
|
301
349
|
};
|
|
302
350
|
export type RefreshResult = {
|
|
@@ -307,6 +355,7 @@ export type RefreshResult = {
|
|
|
307
355
|
export type MutationRequest = {
|
|
308
356
|
locator: string;
|
|
309
357
|
changeBatch: ChangeBatch;
|
|
358
|
+
file(localId: string): Promise<Blob>;
|
|
310
359
|
upload?: unknown;
|
|
311
360
|
};
|
|
312
361
|
export type RetryableRefusal = ProviderRefusal & {
|
|
@@ -317,17 +366,21 @@ export type ServiceMode = Open<'open' | 'write-halted'>;
|
|
|
317
366
|
export type ServiceModeSignal = {
|
|
318
367
|
observe(notify: (mode: ServiceMode) => void): () => void;
|
|
319
368
|
};
|
|
320
|
-
export type
|
|
321
|
-
kind: 'accepted';
|
|
369
|
+
export type AcceptedRoom = {
|
|
322
370
|
roomVersion: string;
|
|
323
371
|
documents: Readonly<Record<string, string>>;
|
|
324
372
|
revisions: Readonly<Record<string, string>>;
|
|
373
|
+
fileIds?: Readonly<Record<string, string>>;
|
|
325
374
|
changes: Readonly<Record<string, HeadChange>>;
|
|
326
375
|
removals: readonly string[];
|
|
327
|
-
|
|
376
|
+
binaryFiles?: Readonly<Record<string, BinaryFile>>;
|
|
377
|
+
};
|
|
378
|
+
export type MutationResult = (AcceptedRoom & {
|
|
379
|
+
kind: 'accepted';
|
|
328
380
|
author?: string;
|
|
329
381
|
time?: string;
|
|
330
|
-
|
|
382
|
+
destination?: AcceptedRoom;
|
|
383
|
+
}) | (ProviderRefusal & {
|
|
331
384
|
kind: 'conflicted';
|
|
332
385
|
roomVersion?: string;
|
|
333
386
|
affected: Readonly<Record<string, string>>;
|
|
@@ -336,14 +389,9 @@ export type MutationResult = {
|
|
|
336
389
|
affected: Readonly<Record<string, string>>;
|
|
337
390
|
}) | RetryableRefusal | {
|
|
338
391
|
kind: 'write-halted';
|
|
339
|
-
} | {
|
|
340
|
-
kind: 'expired';
|
|
341
392
|
} | AdapterFailure;
|
|
342
393
|
export type HistoryAuthor = {
|
|
343
|
-
kind: 'user';
|
|
344
|
-
id: string;
|
|
345
|
-
} | {
|
|
346
|
-
kind: 'site';
|
|
394
|
+
kind: 'user' | 'site' | 'inbox' | 'app';
|
|
347
395
|
id: string;
|
|
348
396
|
name: string;
|
|
349
397
|
};
|
|
@@ -351,6 +399,7 @@ export type HistoryRevision = {
|
|
|
351
399
|
revision: string;
|
|
352
400
|
author: HistoryAuthor;
|
|
353
401
|
time: string;
|
|
402
|
+
binaryFile?: BinaryFile;
|
|
354
403
|
};
|
|
355
404
|
export type HistoryRequest = {
|
|
356
405
|
locator: string;
|
|
@@ -369,6 +418,43 @@ export type HistoryResult = {
|
|
|
369
418
|
} | {
|
|
370
419
|
kind: 'no-history';
|
|
371
420
|
} | AdapterFailure;
|
|
421
|
+
export type BinaryRequest = {
|
|
422
|
+
kind: 'path';
|
|
423
|
+
locator: string;
|
|
424
|
+
path: string;
|
|
425
|
+
revision: string;
|
|
426
|
+
};
|
|
427
|
+
export type BinaryResult = {
|
|
428
|
+
kind: 'binary';
|
|
429
|
+
body: ReadableStream<Uint8Array>;
|
|
430
|
+
mediaType: string;
|
|
431
|
+
sha256?: string;
|
|
432
|
+
} | (ProviderRefusal & {
|
|
433
|
+
kind: 'rejected';
|
|
434
|
+
}) | AdapterFailure;
|
|
435
|
+
export type BinaryLinkResult = {
|
|
436
|
+
kind: 'link';
|
|
437
|
+
url: string;
|
|
438
|
+
name: string;
|
|
439
|
+
mediaType?: string;
|
|
440
|
+
} | (ProviderRefusal & {
|
|
441
|
+
kind: 'rejected';
|
|
442
|
+
}) | AdapterFailure;
|
|
443
|
+
export type AttachRequest = {
|
|
444
|
+
locator: string;
|
|
445
|
+
name: string;
|
|
446
|
+
mediaType: string;
|
|
447
|
+
byteLength: number;
|
|
448
|
+
sha256: string;
|
|
449
|
+
blob: Blob;
|
|
450
|
+
};
|
|
451
|
+
export type AttachResult = {
|
|
452
|
+
kind: 'attached';
|
|
453
|
+
path: string;
|
|
454
|
+
revision: string;
|
|
455
|
+
} | (ProviderRefusal & {
|
|
456
|
+
kind: 'rejected';
|
|
457
|
+
}) | AdapterFailure;
|
|
372
458
|
export type ActionRequest = {
|
|
373
459
|
name: string;
|
|
374
460
|
input: unknown;
|
|
@@ -381,48 +467,85 @@ export type ActionResult = {
|
|
|
381
467
|
kind: 'action';
|
|
382
468
|
result: unknown;
|
|
383
469
|
at?: RoomVersionAt;
|
|
470
|
+
} | (ProviderRefusal & {
|
|
471
|
+
kind: 'rejected';
|
|
472
|
+
reset?: string;
|
|
473
|
+
}) | AdapterFailure;
|
|
474
|
+
export type SearchHit = {
|
|
475
|
+
room: string;
|
|
476
|
+
path: string;
|
|
477
|
+
line?: number;
|
|
478
|
+
snippet?: string;
|
|
479
|
+
};
|
|
480
|
+
export type SearchAsk = {
|
|
481
|
+
text: string;
|
|
482
|
+
rooms: readonly string[] | null;
|
|
483
|
+
};
|
|
484
|
+
export type SearchAnswer = {
|
|
485
|
+
kind: 'found';
|
|
486
|
+
documents: readonly SearchHit[];
|
|
384
487
|
} | (ProviderRefusal & {
|
|
385
488
|
kind: 'rejected';
|
|
386
489
|
}) | AdapterFailure;
|
|
387
490
|
export type HeldRoom = {
|
|
388
491
|
locator: string;
|
|
492
|
+
roomVersion: string | null;
|
|
493
|
+
};
|
|
494
|
+
export type RoomChange = {
|
|
495
|
+
kind: 'room-change';
|
|
496
|
+
locator: string;
|
|
497
|
+
from: string | null;
|
|
389
498
|
roomVersion: string;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
499
|
+
read(): Promise<RefreshPage>;
|
|
500
|
+
};
|
|
501
|
+
export type AuthorityChange = {
|
|
502
|
+
kind: 'authority-changed';
|
|
503
|
+
rooms: readonly DiscoveredRoom[];
|
|
504
|
+
left: readonly string[];
|
|
505
|
+
member?: Member;
|
|
393
506
|
};
|
|
394
507
|
export type RoomStreamEvent = {
|
|
395
508
|
kind: 'opened';
|
|
509
|
+
} | {
|
|
510
|
+
kind: 'discovered';
|
|
511
|
+
discovery: Discovery;
|
|
396
512
|
} | {
|
|
397
513
|
kind: 'closed';
|
|
398
514
|
revoked: boolean;
|
|
515
|
+
lost: boolean;
|
|
516
|
+
authorityChanged: boolean;
|
|
399
517
|
} | {
|
|
400
|
-
kind: '
|
|
518
|
+
kind: 'caught-up';
|
|
401
519
|
expired: readonly string[];
|
|
402
|
-
} |
|
|
403
|
-
kind: 'room-version';
|
|
404
|
-
locator: string;
|
|
405
|
-
roomVersion: string;
|
|
406
|
-
};
|
|
520
|
+
} | AuthorityChange | RoomChange;
|
|
407
521
|
export type RoomStream = {
|
|
408
522
|
hold(rooms: readonly HeldRoom[]): void;
|
|
409
|
-
reopen(): void;
|
|
410
523
|
observe(notify: (event: RoomStreamEvent) => void): () => void;
|
|
411
524
|
};
|
|
525
|
+
export type PathRule = (path: string) => boolean;
|
|
412
526
|
export type Adapter = {
|
|
413
527
|
readonly localSaves?: true;
|
|
528
|
+
readonly roomTypes?: string;
|
|
529
|
+
readonly nameableRoomTypes?: readonly string[];
|
|
530
|
+
readonly typedPaths?: readonly TypedPath[];
|
|
531
|
+
readonly pathRule?: PathRule;
|
|
532
|
+
readonly unkeptReads?: readonly string[];
|
|
533
|
+
readonly leadingReads?: readonly string[];
|
|
414
534
|
authorize(): Promise<Authorization>;
|
|
415
|
-
discover(authorization: Authorization): Promise<DiscoverResult>;
|
|
535
|
+
discover?(authorization: Authorization): Promise<DiscoverResult>;
|
|
416
536
|
bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
|
|
417
|
-
refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
|
|
537
|
+
refresh?(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
|
|
418
538
|
mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
|
|
419
539
|
history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
|
|
540
|
+
binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
|
|
541
|
+
link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
|
|
542
|
+
attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
|
|
420
543
|
action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
|
|
544
|
+
search?(authorization: Authorization, request: SearchAsk): Promise<SearchAnswer>;
|
|
421
545
|
reached(locator: string, roomVersion: string, target: string): boolean;
|
|
422
546
|
follows(locator: string, roomVersion: string, next: string): boolean;
|
|
423
547
|
roomStream?: RoomStream;
|
|
424
548
|
conversations?: ConversationStream;
|
|
425
549
|
serviceMode?: ServiceModeSignal;
|
|
426
550
|
};
|
|
427
|
-
export {};
|
|
428
551
|
//# sourceMappingURL=adapter.d.ts.map
|