@agentshouse/mdruntime 0.1.0-cbbae1fff01c6 → 0.1.0-cc00e9289ddf4
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 +17 -15
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +14 -23
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +114 -63
- package/dist/adapter.d.ts +30 -12
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +0 -5
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +0 -2
- package/dist/client.d.ts +8 -18
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +27 -15
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +17 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +15 -13
- package/dist/conversation-live.d.ts +23 -8
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +21 -9
- package/dist/conversation-row.d.ts +2 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +2 -0
- package/dist/conversation.d.ts +27 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +279 -168
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +8 -6
- package/dist/durability.d.ts +4 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.js +1 -1
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- package/dist/host.d.ts +1 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +39 -11
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -6
- package/dist/install.d.ts +10 -4
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +45 -46
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +22 -16
- package/dist/listing.d.ts +7 -3
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +26 -13
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +71 -30
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -3
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +2 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +7 -10
- package/dist/memory.d.ts +3 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +50 -22
- package/dist/messages.d.ts +12 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +24 -10
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +5 -8
- package/dist/observation.d.ts +27 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +173 -69
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +3 -9
- package/dist/outcome.d.ts +7 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +23 -2
- package/dist/overlay.d.ts +3 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +8 -4
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +2 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +6 -14
- package/dist/preparation.d.ts +27 -6
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +137 -56
- package/dist/presence.d.ts +7 -1
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +22 -9
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +62 -24
- package/dist/questions.d.ts +0 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +0 -7
- package/dist/queue.d.ts +2 -2
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +25 -30
- package/dist/reach.d.ts +2 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +75 -21
- package/dist/react.d.ts +7 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/readiness.d.ts +9 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +3 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +5 -1
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +1 -3
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +2 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +26 -21
- package/dist/rows.d.ts +2 -0
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -0
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +105 -55
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +3 -6
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/shown.d.ts +3 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +58 -39
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket.d.ts +3 -3
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +3 -9
- package/dist/source.d.ts +0 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +11 -4
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +56 -20
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +9 -6
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +11 -2
- package/dist/stored.d.ts +24 -13
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +73 -17
- package/dist/surface.d.ts +4 -3
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +12 -13
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +31 -17
- package/dist/tables.d.ts +14 -7
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +36 -15
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +1 -2
- package/dist/wire.d.ts +40 -3
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +11 -1
- package/package.json +3 -3
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -5
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -7
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/queries.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { identityOf } from '@agentshouse/mdmodel';
|
|
2
2
|
import { ROOM_TOTALS } from './figures.js';
|
|
3
3
|
import { roomInFlight } from './install.js';
|
|
4
|
-
import {
|
|
4
|
+
import { readerOf } from './live.js';
|
|
5
|
+
import { compositionFor, roomFacts } from './listing.js';
|
|
5
6
|
import { lockedRooms } from './locks.js';
|
|
6
7
|
import { OFFLINE, UNCERTAIN, failure } from './outcome.js';
|
|
7
|
-
import { connectionNow, prepare
|
|
8
|
+
import { connectionNow, prepare } from './preparation.js';
|
|
8
9
|
import { planWithin, } from './query.js';
|
|
9
10
|
import { planReach } from './reach.js';
|
|
10
11
|
import { refuse } from './refusal.js';
|
|
11
|
-
import { documentKey } from './rows.js';
|
|
12
|
+
import { documentKey, roomsOfReach } from './rows.js';
|
|
12
13
|
import { searchPlanOf } from './search.js';
|
|
13
14
|
import { seedApplies, seededResult, watchSeeded } from './seed.js';
|
|
14
15
|
import { capped, MAXIMUM_WINDOW } from './windows.js';
|
|
@@ -22,16 +23,30 @@ function everyRoom({ presence }, held) {
|
|
|
22
23
|
]),
|
|
23
24
|
];
|
|
24
25
|
}
|
|
26
|
+
function anyHeld({ presence }, held, locator) {
|
|
27
|
+
return (presence.room(locator) !== undefined || held.rooms.has(locator) || held.queues.has(locator));
|
|
28
|
+
}
|
|
29
|
+
function anyRoom(plan) {
|
|
30
|
+
return plan.rooms === null && plan.reach === null;
|
|
31
|
+
}
|
|
32
|
+
function reaching(runtime, plan, reads, held) {
|
|
33
|
+
if (!anyRoom(plan))
|
|
34
|
+
return reads;
|
|
35
|
+
return (locator) => reads(locator) && anyHeld(runtime, held, locator);
|
|
36
|
+
}
|
|
25
37
|
function reachedRooms(runtime, plan, held) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return [...new Set(named)]
|
|
29
|
-
.filter((locator) => (reached === null || reached.has(locator)) && !plan.locked.includes(locator))
|
|
30
|
-
.sort();
|
|
38
|
+
const named = plan.rooms ?? (plan.reach === null ? everyRoom(runtime, held) : roomsOfReach(plan.reach));
|
|
39
|
+
return [...new Set(named)].filter(reaching(runtime, plan, readerOf(plan), held)).sort();
|
|
31
40
|
}
|
|
32
41
|
function awaited({ socket, presence }, locator) {
|
|
33
42
|
return (!socket.session.now().roomsListed || presence.room(locator)?.replica.admission === 'admitted');
|
|
34
43
|
}
|
|
44
|
+
function awaitsOf(runtime, locator, held) {
|
|
45
|
+
const replica = held.rooms.get(locator);
|
|
46
|
+
if (replica === undefined)
|
|
47
|
+
return awaited(runtime, locator) ? 'acquisition' : null;
|
|
48
|
+
return replica.indexed ? null : 'preparation';
|
|
49
|
+
}
|
|
35
50
|
function coveredRooms(runtime, locators, whole, held) {
|
|
36
51
|
const { store, socket } = runtime;
|
|
37
52
|
if (locators.length === 0 && whole && !socket.session.now().roomsListed)
|
|
@@ -41,16 +56,12 @@ function coveredRooms(runtime, locators, whole, held) {
|
|
|
41
56
|
const overlay = [];
|
|
42
57
|
const read = [];
|
|
43
58
|
for (const locator of locators) {
|
|
59
|
+
const awaits = awaitsOf(runtime, locator, held);
|
|
60
|
+
if (awaits !== null)
|
|
61
|
+
pending.push({ room: locator, awaits });
|
|
44
62
|
const replica = held.rooms.get(locator);
|
|
45
|
-
if (replica === undefined)
|
|
46
|
-
if (awaited(runtime, locator))
|
|
47
|
-
pending.push({ room: locator, awaits: 'acquisition' });
|
|
63
|
+
if (awaits !== null || replica === undefined)
|
|
48
64
|
continue;
|
|
49
|
-
}
|
|
50
|
-
if (!replica.indexed) {
|
|
51
|
-
pending.push({ room: locator, awaits: 'preparation' });
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
65
|
coverage.push({
|
|
55
66
|
room: locator,
|
|
56
67
|
generation: replica.transfer,
|
|
@@ -65,7 +76,19 @@ function coveredRooms(runtime, locators, whole, held) {
|
|
|
65
76
|
return { coverage: { rooms: coverage, overlay }, rooms: read };
|
|
66
77
|
}
|
|
67
78
|
function covered(runtime, plan, held) {
|
|
68
|
-
return coveredRooms(runtime, reachedRooms(runtime, plan, held), plan
|
|
79
|
+
return coveredRooms(runtime, reachedRooms(runtime, plan, held), anyRoom(plan), held);
|
|
80
|
+
}
|
|
81
|
+
function pendingAt(runtime, plan, reads, held, rooms) {
|
|
82
|
+
const reached = reaching(runtime, plan, reads, held);
|
|
83
|
+
const at = new Map();
|
|
84
|
+
for (const room of rooms) {
|
|
85
|
+
const awaits = reached(room) ? awaitsOf(runtime, room, held) : null;
|
|
86
|
+
at.set(room, awaits === null ? null : { room, awaits });
|
|
87
|
+
}
|
|
88
|
+
awaitPreparation(runtime, {
|
|
89
|
+
pending: [...at.values()].filter((room) => room !== null),
|
|
90
|
+
});
|
|
91
|
+
return at;
|
|
69
92
|
}
|
|
70
93
|
function awaitPreparation(runtime, cover) {
|
|
71
94
|
if (!('pending' in cover))
|
|
@@ -117,7 +140,22 @@ async function windowRows(local, plan, rooms, unchanged) {
|
|
|
117
140
|
}
|
|
118
141
|
return null;
|
|
119
142
|
}
|
|
120
|
-
|
|
143
|
+
function freeTextAsked(plan) {
|
|
144
|
+
return plan.shape.kind === 'documents' && (plan.shape.sections !== null || plan.shape.preamble);
|
|
145
|
+
}
|
|
146
|
+
async function composedRooms(runtime, plan, rooms) {
|
|
147
|
+
if (!freeTextAsked(plan))
|
|
148
|
+
return rooms;
|
|
149
|
+
const held = await runtime.store.rooms(rooms.map(({ locator }) => locator));
|
|
150
|
+
return rooms.map((room) => {
|
|
151
|
+
const stored = held.get(room.locator);
|
|
152
|
+
return stored === undefined
|
|
153
|
+
? room
|
|
154
|
+
: { ...room, composition: compositionFor(runtime, stored.record) };
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async function coveredRows(runtime, plan, cover) {
|
|
158
|
+
const { store } = runtime;
|
|
121
159
|
for (;;) {
|
|
122
160
|
const before = await cover();
|
|
123
161
|
if ('pending' in before)
|
|
@@ -126,7 +164,7 @@ async function coveredRows({ store }, plan, cover) {
|
|
|
126
164
|
const keys = before.rooms.map(({ key }) => key);
|
|
127
165
|
const changes = local.changes(keys);
|
|
128
166
|
const current = () => local.changes(keys) === changes;
|
|
129
|
-
const rows = await windowRows(local, plan, before.rooms, current);
|
|
167
|
+
const rows = await windowRows(local, plan, await composedRooms(runtime, plan, before.rooms), current);
|
|
130
168
|
const after = await cover();
|
|
131
169
|
if (rows !== null && sameCover(before, after))
|
|
132
170
|
return { rows, cover: before, current };
|
|
@@ -189,11 +227,14 @@ export async function roomTallies(runtime, rooms, since) {
|
|
|
189
227
|
});
|
|
190
228
|
}
|
|
191
229
|
export function watchPlan(runtime, plan, deliver, fail) {
|
|
230
|
+
const reads = readerOf(plan);
|
|
192
231
|
return watchSeeded(runtime, plan, deliver, (behind, answered) => runtime.liveQueries.watch(plan, identityOf(plan), (held) => {
|
|
193
232
|
const cover = covered(runtime, plan, held);
|
|
194
233
|
awaitPreparation(runtime, cover);
|
|
195
234
|
return behind(cover, held);
|
|
196
|
-
},
|
|
235
|
+
}, (held, rooms) => runtime.store.seeds.of(plan.key) === undefined
|
|
236
|
+
? pendingAt(runtime, plan, reads, held, rooms)
|
|
237
|
+
: null, answered, fail));
|
|
197
238
|
}
|
|
198
239
|
export function watchPlanned(runtime, planning, deliver, fail) {
|
|
199
240
|
let stop = null;
|
|
@@ -211,7 +252,7 @@ export function watchPlanned(runtime, planning, deliver, fail) {
|
|
|
211
252
|
};
|
|
212
253
|
}
|
|
213
254
|
export async function searched(runtime, input, reach) {
|
|
214
|
-
const { store, socket
|
|
255
|
+
const { store, socket } = runtime;
|
|
215
256
|
const { session } = socket;
|
|
216
257
|
const asked = searchPlanOf(input);
|
|
217
258
|
await socket.ready;
|
|
@@ -247,12 +288,10 @@ export async function searched(runtime, input, reach) {
|
|
|
247
288
|
const { closed, authorization, refusal } = session.now();
|
|
248
289
|
if (closed || authorization === undefined || refusal !== null)
|
|
249
290
|
return UNCERTAIN;
|
|
250
|
-
journal.record('transfer search');
|
|
251
291
|
try {
|
|
252
292
|
const result = await search(authorization, { text: asked.text, rooms });
|
|
253
293
|
if (result.kind === 'revoked-authorization')
|
|
254
294
|
await refuse(runtime, 'revoked-authorization');
|
|
255
|
-
journal.record(`outcome search ${result.kind}`);
|
|
256
295
|
if (result.kind === 'rejected')
|
|
257
296
|
return result;
|
|
258
297
|
if (result.kind !== 'found')
|
|
@@ -264,7 +303,6 @@ export async function searched(runtime, input, reach) {
|
|
|
264
303
|
};
|
|
265
304
|
}
|
|
266
305
|
catch {
|
|
267
|
-
journal.record('outcome search transport-uncertainty');
|
|
268
306
|
return UNCERTAIN;
|
|
269
307
|
}
|
|
270
308
|
}
|
package/dist/questions.d.ts
CHANGED
|
@@ -26,9 +26,4 @@ export declare function entered(field: ChatField): boolean;
|
|
|
26
26
|
export declare function questionsOf(view: Pick<ConversationView, 'questions'> | null): readonly ChatQuestion[];
|
|
27
27
|
export declare function openQuestion(questions: readonly unknown[]): string | null;
|
|
28
28
|
export declare function questionAsked(questions: readonly unknown[]): string | null;
|
|
29
|
-
export type ChatLone = {
|
|
30
|
-
readonly question: ChatQuestion;
|
|
31
|
-
readonly field: ChatField;
|
|
32
|
-
};
|
|
33
|
-
export declare function loneOf(questions: readonly ChatQuestion[]): ChatLone | null;
|
|
34
29
|
//# sourceMappingURL=questions.d.ts.map
|
package/dist/questions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../src/questions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAA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AAa,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAE1E"}
|
package/dist/questions.js
CHANGED
|
@@ -113,10 +113,3 @@ export function openQuestion(questions) {
|
|
|
113
113
|
export function questionAsked(questions) {
|
|
114
114
|
return questionsOf({ questions })[0]?.asked ?? null;
|
|
115
115
|
}
|
|
116
|
-
export function loneOf(questions) {
|
|
117
|
-
const asked = questions.length === 1 && !questions[0].secret ? questions[0] : undefined;
|
|
118
|
-
const only = asked?.fields.length === 1 ? asked.fields[0] : undefined;
|
|
119
|
-
return asked !== undefined && only !== undefined && entered(only)
|
|
120
|
-
? { question: asked, field: only }
|
|
121
|
-
: null;
|
|
122
|
-
}
|
package/dist/queue.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import type { Runtime } from './runtime.js';
|
|
|
5
5
|
import type { SavePlan } from './save.js';
|
|
6
6
|
import type { SaveResult } from './saves.js';
|
|
7
7
|
import type { PendingState, RoomCommit, Store, StoredFile, View, Work } from './store.js';
|
|
8
|
-
export type Queueing = Pick<Runtime, 'store' | '
|
|
8
|
+
export type Queueing = Pick<Runtime, 'store' | 'localSaves'> & {
|
|
9
9
|
readonly socket: Pick<Runtime['socket'], 'continuing'>;
|
|
10
|
-
readonly presence: Pick<Runtime['presence'], 'lost'>;
|
|
10
|
+
readonly presence: Pick<Runtime['presence'], 'lost' | 'unheldModel' | 'room'>;
|
|
11
11
|
};
|
|
12
12
|
export type Restand = {
|
|
13
13
|
readonly locator: string;
|
package/dist/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAmC,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":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MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAiDf;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvD;AAED,wBAAsB,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CA4DzF"}
|
package/dist/queue.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
2
|
import { leaving as leavingIn, partnerOf } from './change.js';
|
|
3
3
|
import { composedOf, definitionsAt } from './collection.js';
|
|
4
|
+
import { declared } from './declaration.js';
|
|
4
5
|
import { runtimeError } from './failure.js';
|
|
5
6
|
import { roomDraftRevision } from './identity.js';
|
|
6
7
|
import { landed, movedBy, overlayOf, replaying, slicing, slicingWith, standing, storedRecord, touchedBy, } from './replica.js';
|
|
@@ -44,18 +45,23 @@ async function returnedDrafts(store, locator, work, leaving, composition) {
|
|
|
44
45
|
continue;
|
|
45
46
|
for (const saved of work.states.get(batch.id)?.drafts ?? []) {
|
|
46
47
|
const existing = written.get(saved.path) ?? (await store.draft(locator, saved.path));
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
revision: roomDraftRevision(),
|
|
51
|
-
parts: returnedInto(existing?.parts, saved.parts, composition === undefined ? undefined : definitionsAt(composition, saved.path)),
|
|
52
|
-
returned,
|
|
53
|
-
});
|
|
48
|
+
const parts = returnedInto(existing?.parts, saved.parts, composition === undefined ? undefined : definitionsAt(composition, saved.path));
|
|
49
|
+
written.set(saved.path, parts === null
|
|
50
|
+
? { ...existing, returned }
|
|
51
|
+
: { locator, path: saved.path, revision: roomDraftRevision(), parts, returned });
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
return written;
|
|
57
55
|
}
|
|
58
|
-
|
|
56
|
+
function unheldComposition({ store, presence }, locator) {
|
|
57
|
+
const model = presence.unheldModel(locator);
|
|
58
|
+
const listed = presence.room(locator);
|
|
59
|
+
if (model === null || listed === undefined)
|
|
60
|
+
return undefined;
|
|
61
|
+
return store.composed({ model, declaration: declared(listed) });
|
|
62
|
+
}
|
|
63
|
+
async function carriedBack(runtime, locator, unlanded, written) {
|
|
64
|
+
const { store } = runtime;
|
|
59
65
|
const back = new Map();
|
|
60
66
|
const taken = [];
|
|
61
67
|
for (const batch of unlanded) {
|
|
@@ -74,12 +80,16 @@ async function carriedBack(store, locator, unlanded, written) {
|
|
|
74
80
|
const [into, key] = source === locator ? [written, path] : [back, documentKey(source, path)];
|
|
75
81
|
const existing = into.get(key) ?? (await store.draft(source, path));
|
|
76
82
|
const held = await store.record(source);
|
|
83
|
+
const composition = held === undefined ? unheldComposition(runtime, source) : store.composed(held);
|
|
84
|
+
const parts = returnedInto(existing?.parts, record.parts, composition === undefined ? undefined : definitionsAt(composition, path));
|
|
85
|
+
if (parts === null)
|
|
86
|
+
continue;
|
|
77
87
|
taken.push({ locator: destination, path: to });
|
|
78
88
|
into.set(key, {
|
|
79
89
|
locator: source,
|
|
80
90
|
path,
|
|
81
91
|
revision: roomDraftRevision(),
|
|
82
|
-
parts
|
|
92
|
+
parts,
|
|
83
93
|
returned: existing?.returned ?? null,
|
|
84
94
|
});
|
|
85
95
|
}
|
|
@@ -156,7 +166,7 @@ async function together(runtime, local, settlements) {
|
|
|
156
166
|
return mergeChangeSets(all.map((one) => one.apply(answer)));
|
|
157
167
|
}
|
|
158
168
|
async function settlement(runtime, local, locator, work, record, queue, settling = {}) {
|
|
159
|
-
const { store,
|
|
169
|
+
const { store, localSaves } = runtime;
|
|
160
170
|
const before = work.replica;
|
|
161
171
|
const view = settling.view ?? 'confirmed';
|
|
162
172
|
const previousQueue = work.queue;
|
|
@@ -191,7 +201,7 @@ async function settlement(runtime, local, locator, work, record, queue, settling
|
|
|
191
201
|
...(settling.leaving ?? []),
|
|
192
202
|
];
|
|
193
203
|
const written = await returnedDrafts(store, locator, work, returning, composition);
|
|
194
|
-
const carried = await carriedBack(
|
|
204
|
+
const carried = await carriedBack(runtime, locator, [
|
|
195
205
|
...[...unqueued].reverse().flatMap(({ batch, landed: held }) => (held ? [] : [batch])),
|
|
196
206
|
...(settling.leaving ?? []).flatMap(({ batch, returned }) => returned === null ? [] : [batch]),
|
|
197
207
|
], written);
|
|
@@ -235,10 +245,6 @@ async function settlement(runtime, local, locator, work, record, queue, settling
|
|
|
235
245
|
store.landed.drop(locator, batch.id);
|
|
236
246
|
}
|
|
237
247
|
const drafts = [...written.keys(), ...carried.taken];
|
|
238
|
-
for (const { batch, landed: held } of unqueued) {
|
|
239
|
-
const outcome = localSaves ? 'dropped' : held ? 'landed' : 'withdrawn';
|
|
240
|
-
journal.record(`outcome ${locator} ${batch.id} ${outcome}`);
|
|
241
|
-
}
|
|
242
248
|
const changed = answer.changed[locator];
|
|
243
249
|
if (settling.commit?.published !== undefined ||
|
|
244
250
|
settling.commit?.refreshed === true ||
|
|
@@ -260,29 +266,20 @@ async function settlement(runtime, local, locator, work, record, queue, settling
|
|
|
260
266
|
};
|
|
261
267
|
}
|
|
262
268
|
async function unpairing(runtime, local, locator, batches) {
|
|
263
|
-
const { store,
|
|
269
|
+
const { store, localSaves } = runtime;
|
|
264
270
|
const ids = new Set(batches.map(({ id }) => id));
|
|
265
271
|
const leaving = batches.map((batch) => ({
|
|
266
272
|
batch,
|
|
267
273
|
returned: !localSaves && leavingIn(batch, locator) ? returnedBy() : null,
|
|
268
274
|
}));
|
|
269
|
-
const outcome = localSaves ? 'dropped' : 'unpaired';
|
|
270
275
|
const work = await store.work(locator);
|
|
271
276
|
const current = work.replica;
|
|
272
277
|
if (current !== undefined) {
|
|
273
|
-
|
|
274
|
-
return {
|
|
275
|
-
...settled,
|
|
276
|
-
apply(answer) {
|
|
277
|
-
for (const batch of batches)
|
|
278
|
-
journal.record(`outcome ${locator} ${batch.id} ${outcome}`);
|
|
279
|
-
return settled.apply(answer);
|
|
280
|
-
},
|
|
281
|
-
};
|
|
278
|
+
return settlement(runtime, local, locator, work, current.record, current.queue.filter((one) => !ids.has(one.id)), { leaving });
|
|
282
279
|
}
|
|
283
280
|
const queue = work.queue.filter((one) => !ids.has(one.id));
|
|
284
|
-
const written = await returnedDrafts(store, locator, work, leaving,
|
|
285
|
-
const carried = await carriedBack(
|
|
281
|
+
const written = await returnedDrafts(store, locator, work, leaving, unheldComposition(runtime, locator));
|
|
282
|
+
const carried = await carriedBack(runtime, locator, leaving.flatMap(({ batch, returned }) => (returned === null ? [] : [batch])), written);
|
|
286
283
|
return {
|
|
287
284
|
locator,
|
|
288
285
|
left: batches,
|
|
@@ -300,8 +297,6 @@ async function unpairing(runtime, local, locator, batches) {
|
|
|
300
297
|
],
|
|
301
298
|
},
|
|
302
299
|
apply() {
|
|
303
|
-
for (const batch of batches)
|
|
304
|
-
journal.record(`outcome ${locator} ${batch.id} ${outcome}`);
|
|
305
300
|
return mergeChangeSets([
|
|
306
301
|
changeSet(locator, {
|
|
307
302
|
queue: true,
|
package/dist/reach.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { AppRoom } from './listing.js';
|
|
2
|
-
import type { ReadinessPort } from './preparation.js';
|
|
2
|
+
import type { ReadinessMessage, ReadinessPort } from './preparation.js';
|
|
3
3
|
import type { MdRuntime, RuntimeTopic } from './surface.js';
|
|
4
4
|
import type { Plan, PlanReach, QueryResult } from './query.js';
|
|
5
|
-
import type { Readiness } from './readiness.js';
|
|
6
5
|
import type { SearchResult } from './search.js';
|
|
7
6
|
export type ReachedDocument = {
|
|
8
7
|
readonly room: string;
|
|
@@ -34,7 +33,7 @@ export type Reachable = RuntimeView & {
|
|
|
34
33
|
query(plan: Plan): Promise<QueryResult>;
|
|
35
34
|
watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
|
|
36
35
|
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
37
|
-
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness:
|
|
36
|
+
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
|
|
38
37
|
locked(room: string): Promise<boolean>;
|
|
39
38
|
lockedRooms(): Promise<readonly string[]>;
|
|
40
39
|
watchLocks(notify: () => void): () => void;
|
package/dist/reach.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AA6BzE,OAAO,KAAK,EAAiB,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAS9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,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C,CAAC;IACvC,WAAW,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IAC1C,UAAU,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC3C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IAC1F,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;CACrD,CAAC;AA+CF,wBAAgB,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMpE;AAMD,wBAAgB,OAAO,CACrB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,IAAI,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE;QAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC/F;IAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAS/D;AAiCD,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAcnE;AAwHD,wBAAgB,QAAQ,CACtB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,IAAI,EAAE,aAAa,GAClB,YAAY,CAqZd"}
|
package/dist/reach.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { QueryError } from '@agentshouse/mdmodel';
|
|
1
2
|
import { selected } from './collection.js';
|
|
2
3
|
import { unheldView } from './conversation.js';
|
|
3
4
|
import { modelTypes, NO_MODEL } from './model.js';
|
|
4
|
-
import { changeOf, digestApplied, digestOf, observing, } from './observation.js';
|
|
5
|
+
import { changeOf, digestApplied, digestOf, observing, unchanged, } from './observation.js';
|
|
5
6
|
import { runtimeError, uncaught } from './failure.js';
|
|
6
7
|
import { failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
7
8
|
import { beneath } from './paths.js';
|
|
@@ -20,10 +21,19 @@ const NO_CONVERSATION = {
|
|
|
20
21
|
interrupt: unconversed('conversations/interrupt'),
|
|
21
22
|
kill: unconversed('conversations/kill'),
|
|
22
23
|
delete: unconversed('conversations/delete'),
|
|
24
|
+
takeOut: unconversed('conversations/take-out'),
|
|
25
|
+
decide: unconversed('agent-functions/decide'),
|
|
26
|
+
rename: unconversed('conversations/rename'),
|
|
27
|
+
option: unconversed('conversations/option/set'),
|
|
28
|
+
retry: unconversed('conversations/retry'),
|
|
29
|
+
pin: () => Promise.resolve(),
|
|
30
|
+
openTurn: () => Promise.resolve(),
|
|
31
|
+
dismissSuggestion: () => Promise.resolve(),
|
|
23
32
|
};
|
|
24
33
|
const NO_CHAT_DRAFT = {
|
|
25
34
|
write: () => Promise.resolve(),
|
|
26
35
|
prepend: () => Promise.resolve(),
|
|
36
|
+
append: () => Promise.resolve(),
|
|
27
37
|
discard: () => Promise.resolve(),
|
|
28
38
|
};
|
|
29
39
|
function areasOf(reach) {
|
|
@@ -61,6 +71,19 @@ function covers(reach, room, path) {
|
|
|
61
71
|
function conversing(reach) {
|
|
62
72
|
return reach === null || reach.conversations;
|
|
63
73
|
}
|
|
74
|
+
function roomsAwaited(error, reach) {
|
|
75
|
+
return error.code === 'unknown-type' && reach !== null && reach.rooms.length === 0;
|
|
76
|
+
}
|
|
77
|
+
async function planInReach(runtime, input, reach, answered) {
|
|
78
|
+
try {
|
|
79
|
+
return await runtime.plan(input, reach);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (error instanceof QueryError && (answered || roomsAwaited(error, reach)))
|
|
83
|
+
return null;
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
64
87
|
export function planReach(reach) {
|
|
65
88
|
return reach === null
|
|
66
89
|
? null
|
|
@@ -77,6 +100,14 @@ export function planReach(reach) {
|
|
|
77
100
|
function roomsWithin(reach, rooms) {
|
|
78
101
|
return rooms.filter((room) => wholly(reach, room.locator));
|
|
79
102
|
}
|
|
103
|
+
function roomsChangeWithin(reach, { changed, removed, order }) {
|
|
104
|
+
const within = {
|
|
105
|
+
changed: changed.filter(([locator]) => wholly(reach, locator)),
|
|
106
|
+
removed,
|
|
107
|
+
order: order === null ? null : order.filter((locator) => wholly(reach, locator)),
|
|
108
|
+
};
|
|
109
|
+
return unchanged(within) ? null : within;
|
|
110
|
+
}
|
|
80
111
|
function typesWithin(reach, room, types) {
|
|
81
112
|
if (room === undefined)
|
|
82
113
|
return structuredClone(UNHELD_TYPES);
|
|
@@ -106,12 +137,13 @@ function writeWithin(reach, write) {
|
|
|
106
137
|
function savedWithin(reach, room, result) {
|
|
107
138
|
if (reach === null || result.outcome === 'saved')
|
|
108
139
|
return result;
|
|
109
|
-
const { file, location, referrers, ...refusal } = result;
|
|
140
|
+
const { file, location, line, referrers, ...refusal } = result;
|
|
110
141
|
const hidden = file !== undefined && !covers(reach, room, file);
|
|
111
142
|
return {
|
|
112
143
|
...refusal,
|
|
113
144
|
...(file === undefined || hidden ? {} : { file }),
|
|
114
145
|
...(location === undefined || hidden ? {} : { location }),
|
|
146
|
+
...(line === undefined || hidden ? {} : { line }),
|
|
115
147
|
...(referrers === undefined
|
|
116
148
|
? {}
|
|
117
149
|
: { referrers: referrers.filter((path) => covers(reach, room, path)) }),
|
|
@@ -231,7 +263,13 @@ export function narrowed(runtime, given, port) {
|
|
|
231
263
|
return () => { };
|
|
232
264
|
}
|
|
233
265
|
if (topic === 'rooms') {
|
|
234
|
-
return following(() => watch(topic, input, (rooms) =>
|
|
266
|
+
return following(() => watch(topic, input, (rooms) => {
|
|
267
|
+
const shown = Array.isArray(rooms)
|
|
268
|
+
? roomsWithin(reach, rooms)
|
|
269
|
+
: roomsChangeWithin(reach, rooms);
|
|
270
|
+
if (shown !== null)
|
|
271
|
+
deliver(shown);
|
|
272
|
+
}, fail));
|
|
235
273
|
}
|
|
236
274
|
if (topic === 'readiness') {
|
|
237
275
|
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
@@ -250,24 +288,31 @@ export function narrowed(runtime, given, port) {
|
|
|
250
288
|
return following(() => lockedFirst(room, () => watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)), fail), () => deliver([])), true);
|
|
251
289
|
}
|
|
252
290
|
if (topic === 'query') {
|
|
253
|
-
const planning = runtime.plan(input[0], reach);
|
|
254
291
|
let held = null;
|
|
292
|
+
let planning = null;
|
|
293
|
+
const waiting = (result) => {
|
|
294
|
+
const answer = { result, keys: [] };
|
|
295
|
+
if (held === null || changeOf(held, answer) !== null)
|
|
296
|
+
deliver(answer);
|
|
297
|
+
held = digestOf(answer);
|
|
298
|
+
};
|
|
255
299
|
return following(() => {
|
|
256
300
|
let open = true;
|
|
257
301
|
let stop = () => { };
|
|
302
|
+
if (planning?.reach !== reach) {
|
|
303
|
+
planning = { reach, plan: planInReach(runtime, input[0], reach, held !== null) };
|
|
304
|
+
}
|
|
305
|
+
const planned = planning.plan;
|
|
258
306
|
void (async () => {
|
|
259
|
-
const plan = await
|
|
307
|
+
const plan = await planned;
|
|
260
308
|
const locked = await runtime.lockedRooms();
|
|
261
309
|
if (!open)
|
|
262
310
|
return;
|
|
311
|
+
if (plan === null)
|
|
312
|
+
return waiting({ pending: [] });
|
|
263
313
|
const pending = unlocking(plan.rooms, locked);
|
|
264
|
-
if (pending !== null)
|
|
265
|
-
|
|
266
|
-
if (held === null || changeOf(held, answer) !== null)
|
|
267
|
-
deliver(answer);
|
|
268
|
-
held = digestOf(answer);
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
314
|
+
if (pending !== null)
|
|
315
|
+
return waiting(pending);
|
|
271
316
|
let first = true;
|
|
272
317
|
const heard = (message) => {
|
|
273
318
|
if (!first) {
|
|
@@ -281,8 +326,7 @@ export function narrowed(runtime, given, port) {
|
|
|
281
326
|
if (change !== null)
|
|
282
327
|
deliver(change);
|
|
283
328
|
};
|
|
284
|
-
|
|
285
|
-
stop = runtime.watchPlan(current, (message) => {
|
|
329
|
+
stop = runtime.watchPlan({ ...plan, locked }, (message) => {
|
|
286
330
|
if (open)
|
|
287
331
|
heard(message);
|
|
288
332
|
}, (error) => {
|
|
@@ -315,7 +359,7 @@ export function narrowed(runtime, given, port) {
|
|
|
315
359
|
return () => { };
|
|
316
360
|
});
|
|
317
361
|
}
|
|
318
|
-
if (topic === 'figures' || topic === 'holdings') {
|
|
362
|
+
if (topic === 'figures' || topic === 'holdings' || topic === 'listed-agents') {
|
|
319
363
|
if (reach === null)
|
|
320
364
|
return watch(topic, input, deliver, fail);
|
|
321
365
|
fail(deviceUnreached());
|
|
@@ -340,7 +384,9 @@ export function narrowed(runtime, given, port) {
|
|
|
340
384
|
...md,
|
|
341
385
|
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, rooms)),
|
|
342
386
|
query: (async (input) => {
|
|
343
|
-
const plan = await runtime
|
|
387
|
+
const plan = await planInReach(runtime, input, reach, false);
|
|
388
|
+
if (plan === null)
|
|
389
|
+
return { pending: [] };
|
|
344
390
|
const locked = await runtime.lockedRooms();
|
|
345
391
|
return unlocking(plan.rooms, locked) ?? runtime.query({ ...plan, locked });
|
|
346
392
|
}),
|
|
@@ -432,7 +478,6 @@ export function narrowed(runtime, given, port) {
|
|
|
432
478
|
reached: async (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
433
479
|
!(await runtime.locked(room)) &&
|
|
434
480
|
(await md.reached(room, roomVersion, path)),
|
|
435
|
-
log: () => (reach === null ? md.log() : ''),
|
|
436
481
|
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
437
482
|
unsent: () => (reach === null ? md.unsent() : Promise.reject(deviceUnreached())),
|
|
438
483
|
reset: () => (reach === null ? md.reset() : Promise.reject(deviceUnreached())),
|
|
@@ -471,14 +516,23 @@ export function narrowed(runtime, given, port) {
|
|
|
471
516
|
read: (id, options) => conversation().read(id, options),
|
|
472
517
|
create: (input) => conversation().create(input),
|
|
473
518
|
send: (id, operation, draft) => conversation().send(id, operation, draft),
|
|
474
|
-
answer: (id, answer) => conversation().answer(id, answer),
|
|
475
|
-
interrupt: (id) => conversation().interrupt(id),
|
|
476
|
-
kill: (id) => conversation().kill(id),
|
|
477
|
-
delete: (id) => conversation().delete(id),
|
|
519
|
+
answer: (id, answer, operation) => conversation().answer(id, answer, operation),
|
|
520
|
+
interrupt: (id, operation) => conversation().interrupt(id, operation),
|
|
521
|
+
kill: (id, operation) => conversation().kill(id, operation),
|
|
522
|
+
delete: (id, operation) => conversation().delete(id, operation),
|
|
523
|
+
takeOut: (id, message, operation) => conversation().takeOut(id, message, operation),
|
|
524
|
+
decide: (request, decision, operation) => conversation().decide(request, decision, operation),
|
|
525
|
+
rename: (id, name, operation) => conversation().rename(id, name, operation),
|
|
526
|
+
option: (id, option, value, operation) => conversation().option(id, option, value, operation),
|
|
527
|
+
retry: (id, message, operation) => conversation().retry(id, message, operation),
|
|
528
|
+
pin: (figures) => conversation().pin(figures),
|
|
529
|
+
openTurn: (id, turn) => conversation().openTurn(id, turn),
|
|
530
|
+
dismissSuggestion: (id, suggestion) => conversation().dismissSuggestion(id, suggestion),
|
|
478
531
|
},
|
|
479
532
|
chatDraft: {
|
|
480
533
|
write: (id, draft, revision) => chatDraft().write(id, draft, revision),
|
|
481
534
|
prepend: (id, draft) => chatDraft().prepend(id, draft),
|
|
535
|
+
append: (id, draft) => chatDraft().append(id, draft),
|
|
482
536
|
discard: (id) => chatDraft().discard(id),
|
|
483
537
|
},
|
|
484
538
|
observe: observing(within),
|
package/dist/react.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Acting, Lane, LaneShown } from './act-lanes.js';
|
|
2
3
|
import type { MdRuntimeClient } from './client.js';
|
|
3
4
|
import type { AppRoom } from './listing.js';
|
|
4
5
|
import type { ConnectionRefusal } from './socket.js';
|
|
5
6
|
import type { SavedRoomDraft, SaveResult } from './saves.js';
|
|
6
|
-
import type { Member, ServiceMode } from './adapter.js';
|
|
7
|
+
import type { ListedAgent, Member, ServiceMode } from './adapter.js';
|
|
7
8
|
import type { ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
8
9
|
import { type RuntimeError } from './failure.js';
|
|
9
10
|
import type { FiguresResult } from './figures.js';
|
|
10
11
|
import type { Holdings } from './holdings.js';
|
|
11
|
-
import type { Expecting } from './expectation.js';
|
|
12
|
+
import type { Descriptor, Expecting } from './expectation.js';
|
|
12
13
|
import type { QueueEntry } from './outcome.js';
|
|
13
14
|
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
14
15
|
import type { Readiness } from './readiness.js';
|
|
@@ -38,11 +39,12 @@ export declare function useObserve(client: Client, topic: 'presentation'): Obser
|
|
|
38
39
|
export declare function useObserve(client: Client, topic: 'conversation', conversation: string, options: ConversationOptions): Observed<ConversationView>;
|
|
39
40
|
export declare function useObserve(client: Client, topic: 'conversations'): Observed<readonly ConversationEntry[]>;
|
|
40
41
|
export declare function useObserve(client: Client, topic: 'agents'): Observed<readonly ConversationAgent[]>;
|
|
42
|
+
export declare function useObserve(client: Client, topic: 'listed-agents'): Observed<readonly ListedAgent[]>;
|
|
41
43
|
export declare function useObserve(client: Client, topic: 'figures'): Observed<FiguresResult>;
|
|
42
44
|
export declare function useObserve(client: Client, topic: 'holdings'): Observed<Holdings>;
|
|
43
|
-
export declare function
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
export declare function useExpected<A, T>(store: Expecting, descriptor: Descriptor<A, T>, places: readonly A[], held: ReadonlyMap<A, T> | null): (place: A, held: T) => T;
|
|
46
|
+
export type LaneHeld<O> = LaneShown<O> & Pick<Lane<O>, 'run' | 'forget'>;
|
|
47
|
+
export declare function useLane<O>(lanes: Acting<O>): LaneHeld<O>;
|
|
46
48
|
export type Saving = {
|
|
47
49
|
readonly busy: boolean;
|
|
48
50
|
readonly outcome: SaveResult | null;
|