@agentshouse/mdruntime 0.1.0-c666b13a07022 → 0.1.0-c697ef79d87a3
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 +1 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +44 -7
- package/dist/adapter.d.ts +39 -15
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -2
- package/dist/authored.d.ts.map +1 -1
- package/dist/authored.js +2 -0
- package/dist/binary.d.ts +6 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +10 -3
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +2 -2
- package/dist/chat-types.js +2 -2
- package/dist/client.d.ts +9 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -13
- package/dist/collection.d.ts +1 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +7 -1
- package/dist/compile.d.ts +2 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +70 -38
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +5 -3
- package/dist/conversation-live.d.ts +2 -3
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +2 -2
- package/dist/conversation.d.ts +10 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +31 -19
- package/dist/declaration.js +1 -1
- package/dist/discovery.d.ts +1 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -5
- package/dist/entry.d.ts +13 -3
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +75 -41
- package/dist/host.d.ts +4 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +46 -22
- package/dist/house-query.d.ts +14 -11
- package/dist/house-query.d.ts.map +1 -1
- package/dist/house-query.js +48 -7
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +22 -19
- package/dist/live.d.ts +14 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +29 -12
- package/dist/loaded.d.ts +5 -3
- package/dist/loaded.d.ts.map +1 -1
- package/dist/loaded.js +12 -6
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -0
- package/dist/media.d.ts +5 -6
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +78 -22
- package/dist/memory.d.ts +2 -2
- package/dist/memory.js +5 -5
- package/dist/messages.d.ts +6 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +5 -0
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/opening.js +17 -2
- package/dist/outcome.d.ts +11 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +1 -1
- package/dist/overlay.d.ts +3 -3
- package/dist/preparation.d.ts +10 -5
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +78 -48
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +54 -11
- package/dist/query.d.ts +2 -2
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +2 -1
- package/dist/reach.d.ts +3 -2
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +28 -15
- package/dist/readiness.d.ts +14 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +16 -7
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +2 -1
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.js +2 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +5 -2
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +6 -4
- package/dist/rows.d.ts +9 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +18 -4
- package/dist/runtime.d.ts +4 -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 +6 -6
- package/dist/saves.d.ts +2 -2
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +36 -10
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +17 -4
- package/dist/socket/session.d.ts +3 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +2 -0
- package/dist/source.d.ts +2 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +2 -0
- package/dist/store/records.d.ts +5 -2
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +8 -2
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +3 -1
- package/dist/stored.d.ts +15 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +138 -31
- package/dist/surface.d.ts +4 -4
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +6 -6
- package/dist/sync.d.ts +2 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +26 -18
- package/dist/tables.d.ts +14 -2
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +10 -3
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +49 -3
- package/dist/wire.d.ts +6 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +6 -6
- package/package.json +3 -3
package/dist/conversation.js
CHANGED
|
@@ -25,7 +25,6 @@ export function unheldView(conversation) {
|
|
|
25
25
|
options: [],
|
|
26
26
|
starting: null,
|
|
27
27
|
state: null,
|
|
28
|
-
link: null,
|
|
29
28
|
deliveryWaiting: [],
|
|
30
29
|
deliveryUnknown: [],
|
|
31
30
|
chatDraft: null,
|
|
@@ -228,7 +227,6 @@ function viewOf(alive, conversation, held, frame, { draft, ended, dismissed, pin
|
|
|
228
227
|
options: structuredClone(facts.options),
|
|
229
228
|
starting: facts.starting,
|
|
230
229
|
state: sessionOf(facts, held, ended),
|
|
231
|
-
link: facts.link === null ? null : { ...facts.link },
|
|
232
230
|
deliveryWaiting: [...facts.deliveryWaiting],
|
|
233
231
|
deliveryUnknown: [...facts.deliveryUnknown],
|
|
234
232
|
chatDraft: draft === null || unwritten(draft) ? null : { text: draft.text, revision: draft.revision },
|
|
@@ -236,18 +234,23 @@ function viewOf(alive, conversation, held, frame, { draft, ended, dismissed, pin
|
|
|
236
234
|
pins: [...pins],
|
|
237
235
|
};
|
|
238
236
|
}
|
|
239
|
-
function
|
|
237
|
+
function standing(facts, saved, ended) {
|
|
240
238
|
if (facts.state !== null)
|
|
241
239
|
return structuredClone(facts.state);
|
|
240
|
+
if (saved === null)
|
|
241
|
+
return null;
|
|
242
|
+
const down = facts.process?.running === false;
|
|
243
|
+
return structuredClone(standingState(saved.state, saved.at, down ? saved.at : ended));
|
|
244
|
+
}
|
|
245
|
+
function sessionOf(facts, held, ended) {
|
|
242
246
|
const saved = [...held]
|
|
243
247
|
.reverse()
|
|
244
248
|
.map(({ message }) => record(message))
|
|
245
249
|
.find(({ content }) => isTurn(content));
|
|
246
250
|
const at = saved === undefined ? null : text(saved, 'accepted_at');
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return structuredClone(standingState(saved.content.state, at, down ? at : ended));
|
|
251
|
+
return standing(facts, saved === undefined || !isTurn(saved.content) || at === null
|
|
252
|
+
? null
|
|
253
|
+
: { state: saved.content.state, at }, ended);
|
|
251
254
|
}
|
|
252
255
|
function emit(alive, conversation) {
|
|
253
256
|
if (alive.deps.closed())
|
|
@@ -297,13 +300,14 @@ function stateOf(alive, conversation) {
|
|
|
297
300
|
return facts.turn === null ? 'idle' : 'working';
|
|
298
301
|
}
|
|
299
302
|
function rowOf(alive, conversation) {
|
|
300
|
-
const { turn, questions } = alive.liveOf(conversation);
|
|
303
|
+
const { turn, questions, deliveryWaiting } = alive.liveOf(conversation);
|
|
301
304
|
return {
|
|
302
305
|
state: stateOf(alive, conversation),
|
|
303
306
|
started: turn?.started ?? null,
|
|
304
307
|
line: turn === null ? null : runningLine(turn.parts),
|
|
305
308
|
question: openQuestion(questions),
|
|
306
309
|
asked: questionAsked(questions),
|
|
310
|
+
deliveryWaiting: [...deliveryWaiting],
|
|
307
311
|
};
|
|
308
312
|
}
|
|
309
313
|
async function entries(alive) {
|
|
@@ -325,12 +329,15 @@ async function entries(alive) {
|
|
|
325
329
|
agent: { identity: agent.id, name: agent.name, retired: agent.retired_at !== null },
|
|
326
330
|
name: entry.name,
|
|
327
331
|
created: entry.created,
|
|
328
|
-
finished: entry.finished,
|
|
329
332
|
outcome: entry.outcome,
|
|
330
333
|
waiting: entry.waiting,
|
|
331
334
|
subject: entry.subject,
|
|
335
|
+
room: entry.room,
|
|
336
|
+
model: entry.model,
|
|
337
|
+
effort: entry.effort,
|
|
332
338
|
...rowOf(alive, entry.conversation),
|
|
333
339
|
...heldFacts(rows.get(entry.conversation), entry),
|
|
340
|
+
jobs: standing(alive.liveOf(entry.conversation), rows.get(entry.conversation)?.saved ?? null, entry.processEnded)?.running ?? [],
|
|
334
341
|
};
|
|
335
342
|
});
|
|
336
343
|
}
|
|
@@ -392,7 +399,7 @@ function listChanged(alive, change) {
|
|
|
392
399
|
const list = listing.conversations;
|
|
393
400
|
endedAnew(alive, list);
|
|
394
401
|
if (change.cursor !== undefined) {
|
|
395
|
-
alive.held.set({ listKnown: true, openingListed: true });
|
|
402
|
+
alive.held.set({ listKnown: true, listHeld: true, openingListed: true });
|
|
396
403
|
settleBehind(alive, list);
|
|
397
404
|
openingEnded(alive);
|
|
398
405
|
alive.deps.settled();
|
|
@@ -519,11 +526,18 @@ function emitAgents(alive) {
|
|
|
519
526
|
}
|
|
520
527
|
});
|
|
521
528
|
}
|
|
529
|
+
function ran({ state, process }) {
|
|
530
|
+
return JSON.stringify([state?.running ?? null, process?.running ?? null]);
|
|
531
|
+
}
|
|
522
532
|
function setLive(alive, conversation, next) {
|
|
533
|
+
const was = ran(alive.liveOf(conversation));
|
|
523
534
|
const before = rowOf(alive, conversation);
|
|
524
535
|
alive.holdLive(conversation, next);
|
|
525
536
|
const after = rowOf(alive, conversation);
|
|
526
|
-
if (after.state !== before.state ||
|
|
537
|
+
if (after.state !== before.state ||
|
|
538
|
+
after.started !== before.started ||
|
|
539
|
+
ran(alive.liveOf(conversation)) !== was ||
|
|
540
|
+
after.deliveryWaiting.join() !== before.deliveryWaiting.join())
|
|
527
541
|
emitList(alive);
|
|
528
542
|
else if (after.line !== before.line ||
|
|
529
543
|
after.question !== before.question ||
|
|
@@ -554,7 +568,6 @@ function openingEnded(alive) {
|
|
|
554
568
|
options: facts.has('options') ? QUIET.options : held.options,
|
|
555
569
|
starting: facts.has('starting') ? QUIET.starting : held.starting,
|
|
556
570
|
state: facts.has('state') ? QUIET.state : held.state,
|
|
557
|
-
link: facts.has('link') ? QUIET.link : held.link,
|
|
558
571
|
deliveryWaiting: facts.has('deliveryWaiting') ? QUIET.deliveryWaiting : held.deliveryWaiting,
|
|
559
572
|
deliveryUnknown: facts.has('deliveryUnknown') ? QUIET.deliveryUnknown : held.deliveryUnknown,
|
|
560
573
|
});
|
|
@@ -786,10 +799,6 @@ function heard(alive, event) {
|
|
|
786
799
|
live(alive, conversation, { state: structuredClone(event.state) });
|
|
787
800
|
return;
|
|
788
801
|
}
|
|
789
|
-
if (event.kind === 'link') {
|
|
790
|
-
live(alive, conversation, { link: { connected: event.connected } });
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
802
|
if (event.kind === 'deliveries') {
|
|
794
803
|
live(alive, conversation, {
|
|
795
804
|
deliveryWaiting: [...event.waiting],
|
|
@@ -1027,8 +1036,8 @@ export function conversationSurface(alive, files) {
|
|
|
1027
1036
|
rename(conversation, name, operation) {
|
|
1028
1037
|
return invoke(alive, 'conversations/rename', conversation, operation, { name });
|
|
1029
1038
|
},
|
|
1030
|
-
|
|
1031
|
-
return invoke(alive, 'conversations/
|
|
1039
|
+
set(conversation, settings, operation) {
|
|
1040
|
+
return invoke(alive, 'conversations/set', conversation, operation, settings);
|
|
1032
1041
|
},
|
|
1033
1042
|
retry(conversation, message, operation) {
|
|
1034
1043
|
return invoke(alive, 'conversations/retry', conversation, operation, {
|
|
@@ -1092,7 +1101,10 @@ export function chatDraftSurface(alive) {
|
|
|
1092
1101
|
}
|
|
1093
1102
|
export async function conversationsOpened(alive, local) {
|
|
1094
1103
|
const { conversationList, agentList, conversationCursor } = await local.facts();
|
|
1095
|
-
if (conversationList === null || agentList === null
|
|
1104
|
+
if (conversationList === null || agentList === null)
|
|
1105
|
+
return;
|
|
1106
|
+
alive.held.set({ listHeld: true });
|
|
1107
|
+
if (alive.known())
|
|
1096
1108
|
return;
|
|
1097
1109
|
alive.deps.stream()?.hold(conversationCursor);
|
|
1098
1110
|
conversationsLearned(alive);
|
package/dist/declaration.js
CHANGED
|
@@ -8,7 +8,7 @@ export function sameDeclaration(left, right) {
|
|
|
8
8
|
}
|
|
9
9
|
export function writeRule({ operations, providerOwnedPaths, authoredPaths, }, pathRule, local) {
|
|
10
10
|
return (path, needs) => {
|
|
11
|
-
const normalized = normalize(path);
|
|
11
|
+
const normalized = normalize(path.normalize('NFC'));
|
|
12
12
|
if (normalized === null || normalized === '')
|
|
13
13
|
return { code: 'room-root', path };
|
|
14
14
|
if (covered(providerOwnedPaths, normalized) || !authoredAt(authoredPaths, normalized)) {
|
package/dist/discovery.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export declare function applyDiscovery(runtime: Runtime, found: readonly Discove
|
|
|
8
8
|
export declare const DISCOVERY = "discovery";
|
|
9
9
|
export declare function signIn(runtime: Runtime, local: RuntimeStore, signedIn: Member | null): Promise<void>;
|
|
10
10
|
export declare function zoned(runtime: Runtime, local: RuntimeStore, zone: string | null): Promise<void>;
|
|
11
|
-
export declare function discoverRooms(runtime: Runtime,
|
|
11
|
+
export declare function discoverRooms(runtime: Runtime, progress: CycleProgress, live: Live, found: Discovery | null): Promise<readonly DiscoveredRoom[] | null>;
|
|
12
12
|
//# sourceMappingURL=discovery.d.ts.map
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,GAAG,IAAI,CAsB1E;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GACvB,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,GAAG,IAAI,CAsB1E;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GACvB,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAgDpC;AAUD,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,wBAAsB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,iBAI1F;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,iBAIrF;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,OAAO,CAAC,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC,CA2E3C"}
|
package/dist/discovery.js
CHANGED
|
@@ -37,6 +37,12 @@ export function malformed(listed) {
|
|
|
37
37
|
}
|
|
38
38
|
export async function applyDiscovery(runtime, found, started, left) {
|
|
39
39
|
const { store, socket, presence } = runtime;
|
|
40
|
+
if (found.length === 0 && !store.needed()) {
|
|
41
|
+
const listed = presence.list([], { whole: left === undefined, live: socket.isOpen() });
|
|
42
|
+
socket.session.set({ roomsListed: true });
|
|
43
|
+
emitRooms(runtime);
|
|
44
|
+
return listed;
|
|
45
|
+
}
|
|
40
46
|
const lockedBefore = await lockedRooms(runtime);
|
|
41
47
|
const local = await store.open();
|
|
42
48
|
const fenced = new Set(await local.fences());
|
|
@@ -90,8 +96,8 @@ export async function zoned(runtime, local, zone) {
|
|
|
90
96
|
await local.fact('timeZone', zone);
|
|
91
97
|
emitTimeZone(runtime, zone);
|
|
92
98
|
}
|
|
93
|
-
export async function discoverRooms(runtime,
|
|
94
|
-
const { socket } = runtime;
|
|
99
|
+
export async function discoverRooms(runtime, progress, live, found) {
|
|
100
|
+
const { store, socket } = runtime;
|
|
95
101
|
const { session } = socket;
|
|
96
102
|
const { closed, authorization } = session.now();
|
|
97
103
|
if (closed || authorization === undefined) {
|
|
@@ -114,7 +120,8 @@ export async function discoverRooms(runtime, local, progress, live, found) {
|
|
|
114
120
|
if (result.kind === 'discovery')
|
|
115
121
|
runtime.retries.succeeded('connection', DISCOVERY);
|
|
116
122
|
if (result.kind === 'transport-uncertainty') {
|
|
117
|
-
|
|
123
|
+
if (store.needed())
|
|
124
|
+
await cachedModels(runtime, await store.open());
|
|
118
125
|
progress.reachable = false;
|
|
119
126
|
progress.complete = false;
|
|
120
127
|
socket.notifyReady();
|
|
@@ -144,17 +151,23 @@ export async function discoverRooms(runtime, local, progress, live, found) {
|
|
|
144
151
|
session.set({ refusal: null });
|
|
145
152
|
emitRefusal(runtime);
|
|
146
153
|
}
|
|
154
|
+
const queriesOnly = result.queriesOnly ?? [];
|
|
155
|
+
if (!store.needed() && result.rooms.length === 0) {
|
|
156
|
+
session.set({ queriesOnly, unstored: result });
|
|
157
|
+
socket.notifyReady();
|
|
158
|
+
return applyDiscovery(runtime, result.rooms, started);
|
|
159
|
+
}
|
|
160
|
+
const local = await store.open();
|
|
147
161
|
const held = await local.facts();
|
|
148
162
|
if (JSON.stringify(result.providerLimits) !== JSON.stringify(held.providerLimits) ||
|
|
149
163
|
JSON.stringify(result.capabilities) !== JSON.stringify(held.capabilities)) {
|
|
150
164
|
await local.fact('providerLimits', result.providerLimits);
|
|
151
165
|
await local.fact('capabilities', result.capabilities);
|
|
152
166
|
}
|
|
153
|
-
const queriesOnly = result.queriesOnly ?? [];
|
|
154
167
|
if (JSON.stringify(queriesOnly) !== JSON.stringify(held.queriesOnly)) {
|
|
155
168
|
await local.fact('queriesOnly', queriesOnly);
|
|
156
169
|
}
|
|
157
|
-
session.set({ queriesOnly });
|
|
170
|
+
session.set({ queriesOnly, unstored: null });
|
|
158
171
|
socket.notifyReady();
|
|
159
172
|
await signIn(runtime, local, result.member ?? null);
|
|
160
173
|
await zoned(runtime, local, result.timeZone ?? null);
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { type VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Attachment, HeadChange } from './adapter.js';
|
|
3
3
|
import { type QueryRows } from './query.js';
|
|
4
|
+
import { type ValuedEntry } from './stored.js';
|
|
4
5
|
import type { Connection } from './tables.js';
|
|
5
6
|
export { QueryError } from '@agentshouse/mdmodel';
|
|
7
|
+
export { documentKey, pathOfKey } from './rows.js';
|
|
8
|
+
export type { ValuedEntry } from './stored.js';
|
|
6
9
|
export type EntryRoom = {
|
|
7
10
|
locator: string;
|
|
11
|
+
handle?: string;
|
|
8
12
|
schema: string | null;
|
|
9
13
|
documents: Readonly<Record<string, string>>;
|
|
10
14
|
revisions?: Readonly<Record<string, string>>;
|
|
11
15
|
fileIds?: Readonly<Record<string, string>>;
|
|
12
16
|
created?: Readonly<Record<string, string>>;
|
|
13
17
|
changes?: Readonly<Record<string, HeadChange>>;
|
|
14
|
-
|
|
18
|
+
attachments?: Readonly<Record<string, Attachment>>;
|
|
15
19
|
};
|
|
16
20
|
export type EntryArguments = Readonly<Record<string, string>>;
|
|
17
21
|
export type EntryParameterKind = 'string' | 'integer' | 'number' | 'boolean';
|
|
@@ -21,5 +25,11 @@ export declare function entryRefusal(template: unknown): string | null;
|
|
|
21
25
|
export type EntryScope = {
|
|
22
26
|
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryRows>>;
|
|
23
27
|
};
|
|
24
|
-
export
|
|
28
|
+
export type CountedRoom = {
|
|
29
|
+
locator: string;
|
|
30
|
+
schema: string | null;
|
|
31
|
+
documents: readonly ValuedEntry[];
|
|
32
|
+
};
|
|
33
|
+
export declare function entryScope(rooms: readonly EntryRoom[], roomTypes: VerifiedModel, connection: Connection, followed?: readonly EntryRoom[]): EntryScope;
|
|
34
|
+
export declare function countScope(room: CountedRoom, roomTypes: VerifiedModel, connection: Connection): EntryScope;
|
|
25
35
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI3D,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI3D,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEnE,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,QAAQ,CAAC,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S,WAAW,EAAE,CAAC;CACnC,CAAC;AAsHF,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU,EACtB,QAAQ,GAAE,SAAS,SAAS,EAAO,GAClC,UAAU,CAOZ;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU,GACrB,UAAU,CAaZ"}
|
package/dist/entry.js
CHANGED
|
@@ -3,8 +3,9 @@ import { attachedModel } from './attached-model.js';
|
|
|
3
3
|
import { answerQuery } from './compile.js';
|
|
4
4
|
import { planWithin } from './query.js';
|
|
5
5
|
import { writtenFacts } from './rows.js';
|
|
6
|
-
import { entered, REPLICA_TABLES } from './stored.js';
|
|
6
|
+
import { entered, enteredValues, REPLICA_TABLES, } from './stored.js';
|
|
7
7
|
export { QueryError } from '@agentshouse/mdmodel';
|
|
8
|
+
export { documentKey, pathOfKey } from './rows.js';
|
|
8
9
|
const PARAMETER = '$param';
|
|
9
10
|
const KIND = 'as';
|
|
10
11
|
const INTEGER = /^-?(?:0|[1-9][0-9]*)$/u;
|
|
@@ -117,56 +118,89 @@ export function entryRefusal(template) {
|
|
|
117
118
|
throw error;
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
function enteredRoom(room, roomTypes, connection) {
|
|
122
|
+
const model = attachedModel({
|
|
123
|
+
kind: 'model',
|
|
124
|
+
snapshot: { identity: room.locator, version: '', schema: room.schema, revision: null },
|
|
125
|
+
}, roomTypes);
|
|
126
|
+
const composition = { model, selection: null, typedPaths: [] };
|
|
127
|
+
const key = room.enter(composition);
|
|
128
|
+
if (room.handle !== undefined)
|
|
129
|
+
connection.run("INSERT INTO replica_rooms (locator, key, record) VALUES (?, ?, json_object('declaration', json_object('handle', ?)))", [room.locator, key, room.handle]);
|
|
130
|
+
return {
|
|
131
|
+
locator: room.locator,
|
|
132
|
+
key,
|
|
133
|
+
composition,
|
|
134
|
+
...(room.handle === undefined ? {} : { handle: room.handle }),
|
|
135
|
+
facts: {
|
|
130
136
|
locator: room.locator,
|
|
131
137
|
available: model.status !== 'unavailable',
|
|
132
138
|
types: model.status === 'unavailable' ? [] : Object.values(model.types),
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
content,
|
|
146
|
-
facts: writtenFacts(path, content, composition),
|
|
147
|
-
binary: null,
|
|
148
|
-
...heads(path),
|
|
149
|
-
})),
|
|
150
|
-
...Object.entries(room.binaryFiles ?? {}).map(([path, binary]) => ({
|
|
151
|
-
path,
|
|
152
|
-
content: null,
|
|
153
|
-
facts: null,
|
|
154
|
-
binary: { state: 'accepted', ...binary },
|
|
155
|
-
...heads(path),
|
|
156
|
-
})),
|
|
157
|
-
];
|
|
158
|
-
const key = entered(connection, room.locator, composition, entries.sort((left, right) => (left.path < right.path ? -1 : 1)));
|
|
159
|
-
return { locator: room.locator, key, composition };
|
|
160
|
-
});
|
|
161
|
-
const planned = { listed: true, rooms: held };
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function scope(rooms, roomTypes, connection, followed = []) {
|
|
143
|
+
for (const table of REPLICA_TABLES)
|
|
144
|
+
connection.run(table);
|
|
145
|
+
const keys = rooms.map((room) => enteredRoom(room, roomTypes, connection));
|
|
146
|
+
const follows = [
|
|
147
|
+
...keys,
|
|
148
|
+
...followed.map((room) => enteredRoom(room, roomTypes, connection)),
|
|
149
|
+
].filter(({ handle }) => handle !== undefined);
|
|
150
|
+
const planned = { listed: true, rooms: keys.map(({ facts }) => facts) };
|
|
162
151
|
return {
|
|
163
152
|
async results(queries) {
|
|
164
153
|
const results = {};
|
|
165
154
|
for (const [name, query] of Object.entries(queries)) {
|
|
166
155
|
const plan = entryPlan(query, planned);
|
|
167
|
-
results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)));
|
|
156
|
+
results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)), null, follows);
|
|
168
157
|
}
|
|
169
158
|
return results;
|
|
170
159
|
},
|
|
171
160
|
};
|
|
172
161
|
}
|
|
162
|
+
function scopedRoom(room, connection) {
|
|
163
|
+
return {
|
|
164
|
+
locator: room.locator,
|
|
165
|
+
...(room.handle === undefined ? {} : { handle: room.handle }),
|
|
166
|
+
schema: room.schema,
|
|
167
|
+
enter(composition) {
|
|
168
|
+
const heads = (path) => ({
|
|
169
|
+
revision: room.revisions?.[path] ?? null,
|
|
170
|
+
fileId: room.fileIds?.[path] ?? null,
|
|
171
|
+
created: room.created?.[path] ?? null,
|
|
172
|
+
change: room.changes?.[path] ?? null,
|
|
173
|
+
written: null,
|
|
174
|
+
});
|
|
175
|
+
const entries = [
|
|
176
|
+
...Object.entries(room.documents).map(([path, content]) => ({
|
|
177
|
+
path,
|
|
178
|
+
content,
|
|
179
|
+
facts: writtenFacts(path, content, composition),
|
|
180
|
+
binary: null,
|
|
181
|
+
...heads(path),
|
|
182
|
+
})),
|
|
183
|
+
...Object.entries(room.attachments ?? {}).map(([path, binary]) => ({
|
|
184
|
+
path,
|
|
185
|
+
content: null,
|
|
186
|
+
facts: null,
|
|
187
|
+
binary: { state: 'accepted', ...binary },
|
|
188
|
+
...heads(path),
|
|
189
|
+
})),
|
|
190
|
+
];
|
|
191
|
+
return entered(connection, room.locator, composition, entries.sort((left, right) => (left.path < right.path ? -1 : 1)));
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export function entryScope(rooms, roomTypes, connection, followed = []) {
|
|
196
|
+
return scope(rooms.map((room) => scopedRoom(room, connection)), roomTypes, connection, followed.map((room) => scopedRoom(room, connection)));
|
|
197
|
+
}
|
|
198
|
+
export function countScope(room, roomTypes, connection) {
|
|
199
|
+
return scope([
|
|
200
|
+
{
|
|
201
|
+
locator: room.locator,
|
|
202
|
+
schema: room.schema,
|
|
203
|
+
enter: (composition) => enteredValues(connection, room.locator, composition, room.documents),
|
|
204
|
+
},
|
|
205
|
+
], roomTypes, connection);
|
|
206
|
+
}
|
package/dist/host.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type MdRuntimeOptions } from './connection.js';
|
|
2
2
|
import type { PortReach } from './reach.js';
|
|
3
|
-
import type { CodeAvailability, Persistence, Readiness } from './readiness.js';
|
|
3
|
+
import type { CodeAvailability, FirstTier, Persistence, Readiness } from './readiness.js';
|
|
4
4
|
import type { EntrySeed } from './seed.js';
|
|
5
5
|
import { type CallResult } from './outcome.js';
|
|
6
6
|
import { type RuntimePort } from './wire.js';
|
|
7
7
|
export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
8
8
|
deploymentFacts?: unknown;
|
|
9
|
+
saveMessages?: Readonly<Record<string, string>>;
|
|
9
10
|
};
|
|
10
11
|
export type Admitted = {
|
|
11
12
|
readonly admitted: unknown;
|
|
@@ -19,6 +20,7 @@ export type AttachOptions = {
|
|
|
19
20
|
readonly reach?: PortReach;
|
|
20
21
|
readonly admission?: ActionAdmission;
|
|
21
22
|
readonly code?: CodeAvailability;
|
|
23
|
+
readonly first?: FirstTier;
|
|
22
24
|
};
|
|
23
25
|
export type AttachedPort = {
|
|
24
26
|
detach(): void;
|
|
@@ -39,7 +41,7 @@ export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntime
|
|
|
39
41
|
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
40
42
|
export type { QueriedRoom } from './adapter.js';
|
|
41
43
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
42
|
-
export type { CodeAvailability, Persistence, Space } from './readiness.js';
|
|
44
|
+
export type { CodeAvailability, FirstTier, Persistence, Space } from './readiness.js';
|
|
43
45
|
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
44
46
|
export { replaces } from './observation.js';
|
|
45
47
|
export { undeclared } from './outcome.js';
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAWxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAEL,KAAK,WAAW,EAQjB,MAAM,WAAW,CAAC;AAgBnB,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC;AAEzF,MAAM,MAAM,eAAe,GAAG,CAAC,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AAC;IACjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAiLF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAsN3E;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EACL,cAAc,EACd,UAAU,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -6,7 +6,17 @@ import { observed } from './observation.js';
|
|
|
6
6
|
import { answeredResult } from './outcome.js';
|
|
7
7
|
import { AUTHORIZATION_ENDED, WIRE, wireRequest, } from './wire.js';
|
|
8
8
|
const NARROWED = new Set(['within', 'whole']);
|
|
9
|
-
|
|
9
|
+
const UNWAITED_MEMBERS = new Set(['call', 'queryHouse']);
|
|
10
|
+
const UNWAITED_TOPICS = new Set([
|
|
11
|
+
'deployment-facts',
|
|
12
|
+
'room-drafts',
|
|
13
|
+
'sync-status',
|
|
14
|
+
'connection-refusal',
|
|
15
|
+
'storage-loss',
|
|
16
|
+
'service-mode',
|
|
17
|
+
'authority-changes',
|
|
18
|
+
]);
|
|
19
|
+
function answered(md, app, writtenBy, member, input, said) {
|
|
10
20
|
switch (member) {
|
|
11
21
|
case 'rooms':
|
|
12
22
|
return md.rooms();
|
|
@@ -15,27 +25,31 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
15
25
|
case 'search':
|
|
16
26
|
return md.search(input[0]);
|
|
17
27
|
case 'queryHouse':
|
|
18
|
-
return md.queryHouse(input[0]);
|
|
28
|
+
return md.queryHouse(input[0], input[1]);
|
|
19
29
|
case 'types':
|
|
20
30
|
return md.types(input[0]);
|
|
21
31
|
case 'save':
|
|
22
|
-
return md
|
|
32
|
+
return md
|
|
33
|
+
.save(input[0], input[1], writtenBy)
|
|
34
|
+
.then(said);
|
|
23
35
|
case 'saveParts':
|
|
24
|
-
return md
|
|
36
|
+
return md
|
|
37
|
+
.saveParts(input[0], input[1], writtenBy)
|
|
38
|
+
.then(said);
|
|
25
39
|
case 'history':
|
|
26
40
|
return md.history(input[0], input[1], input[2]);
|
|
27
41
|
case 'resolve':
|
|
28
42
|
return md.resolve(input[0], input[1], input[2]);
|
|
29
|
-
case '
|
|
30
|
-
return md.
|
|
31
|
-
case '
|
|
32
|
-
return md.
|
|
33
|
-
case '
|
|
34
|
-
return md.
|
|
35
|
-
case '
|
|
36
|
-
return md.
|
|
37
|
-
case '
|
|
38
|
-
return md.
|
|
43
|
+
case 'attachment.read':
|
|
44
|
+
return md.attachment.read(input[0], input[1], input[2]);
|
|
45
|
+
case 'attachment.link':
|
|
46
|
+
return md.attachment.link(input[0], input[1], input[2]);
|
|
47
|
+
case 'attachment.show':
|
|
48
|
+
return md.attachment.show(input[0], input[1], input[2]);
|
|
49
|
+
case 'attachment.attach':
|
|
50
|
+
return md.attachment.attach(input[0], input[1]);
|
|
51
|
+
case 'attachment.part':
|
|
52
|
+
return md.attachment.part(input[0], input[1]);
|
|
39
53
|
case 'call':
|
|
40
54
|
return md.call(input[0], input[1]);
|
|
41
55
|
case 'answered':
|
|
@@ -94,8 +108,8 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
94
108
|
return md.conversation.decide(input[0], input[1], input[2]);
|
|
95
109
|
case 'conversation.rename':
|
|
96
110
|
return md.conversation.rename(input[0], input[1], input[2]);
|
|
97
|
-
case 'conversation.
|
|
98
|
-
return md.conversation.
|
|
111
|
+
case 'conversation.set':
|
|
112
|
+
return md.conversation.set(input[0], input[1], input[2]);
|
|
99
113
|
case 'conversation.retry':
|
|
100
114
|
return md.conversation.retry(input[0], input[1], input[2]);
|
|
101
115
|
case 'conversation.pin':
|
|
@@ -133,6 +147,13 @@ function answeredMessage(value) {
|
|
|
133
147
|
}
|
|
134
148
|
export function serveMdRuntime(options) {
|
|
135
149
|
const deploymentFacts = structuredClone(options.deploymentFacts);
|
|
150
|
+
const saveMessages = new Map(Object.entries(options.saveMessages ?? {}));
|
|
151
|
+
const said = (result) => {
|
|
152
|
+
if (result.outcome !== 'refused')
|
|
153
|
+
return result;
|
|
154
|
+
const message = saveMessages.get(result.code);
|
|
155
|
+
return message === undefined ? result : { ...result, message };
|
|
156
|
+
};
|
|
136
157
|
const closing = new AbortController();
|
|
137
158
|
const close = () => {
|
|
138
159
|
closing.abort();
|
|
@@ -153,9 +174,9 @@ export function serveMdRuntime(options) {
|
|
|
153
174
|
function attach(port, options) {
|
|
154
175
|
if (!authorized)
|
|
155
176
|
throw new Error(AUTHORIZATION_ENDED);
|
|
156
|
-
const { app, release, reach, admission, code = 'stored' } = options;
|
|
177
|
+
const { app, release, reach, admission, code = 'stored', first = null } = options;
|
|
157
178
|
const writtenBy = release === undefined ? undefined : { app, release };
|
|
158
|
-
const view = runtime.within(reach ?? null, { target: app, code });
|
|
179
|
+
const view = runtime.within(reach ?? null, { target: app, code, first, inboxed: null });
|
|
159
180
|
const observations = new Map();
|
|
160
181
|
const followed = new Set();
|
|
161
182
|
const answeredKeys = new Set();
|
|
@@ -181,6 +202,7 @@ export function serveMdRuntime(options) {
|
|
|
181
202
|
observations.clear();
|
|
182
203
|
for (const end of [...followed])
|
|
183
204
|
end();
|
|
205
|
+
view.close();
|
|
184
206
|
attachments.delete(detach);
|
|
185
207
|
};
|
|
186
208
|
const observe = (id, topic, input) => {
|
|
@@ -236,10 +258,12 @@ export function serveMdRuntime(options) {
|
|
|
236
258
|
return;
|
|
237
259
|
}
|
|
238
260
|
try {
|
|
239
|
-
if (message.kind
|
|
261
|
+
if (message.kind === 'observe') {
|
|
262
|
+
if (!UNWAITED_TOPICS.has(message.topic))
|
|
263
|
+
await opened();
|
|
264
|
+
}
|
|
265
|
+
else if (!UNWAITED_MEMBERS.has(message.member))
|
|
240
266
|
await md.loaded();
|
|
241
|
-
else if (message.topic !== 'room-drafts')
|
|
242
|
-
await opened();
|
|
243
267
|
if (message.kind === 'observe') {
|
|
244
268
|
if (serving)
|
|
245
269
|
observe(message.id, message.topic, message.input);
|
|
@@ -252,7 +276,7 @@ export function serveMdRuntime(options) {
|
|
|
252
276
|
return;
|
|
253
277
|
}
|
|
254
278
|
const { id, member, input } = message;
|
|
255
|
-
const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ? admitted : md, app, writtenBy, member, input));
|
|
279
|
+
const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ? admitted : md, app, writtenBy, member, input, said));
|
|
256
280
|
return reply(id, member === 'query' ? input[0] : undefined, pending);
|
|
257
281
|
};
|
|
258
282
|
port.addEventListener('message', (event) => {
|
package/dist/house-query.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { type DocumentQuery } from '@agentshouse/mdmodel';
|
|
2
|
-
import type { ProviderRefusal } from './adapter.js';
|
|
1
|
+
import { type DocumentQuery, type GroupQuery } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { HouseQueryGroups, HouseQueryRows, ProviderRefusal } from './adapter.js';
|
|
3
3
|
import { type Failure, type Offline } from './outcome.js';
|
|
4
|
-
import type { QueryDocument } from './query.js';
|
|
5
4
|
import { type PortReach } from './reach.js';
|
|
6
5
|
import type { Runtime } from './runtime.js';
|
|
7
|
-
|
|
8
|
-
rooms: readonly [string];
|
|
6
|
+
type HouseViewQuery = {
|
|
7
|
+
readonly rooms: readonly [string];
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly after?: string;
|
|
9
10
|
};
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export type HouseQuery = ((DocumentQuery | GroupQuery) & {
|
|
12
|
+
rooms: readonly [string];
|
|
13
|
+
}) | HouseViewQuery;
|
|
14
|
+
export type HouseQueryOptions = {
|
|
15
|
+
readonly fresh?: boolean;
|
|
14
16
|
};
|
|
15
|
-
export type HouseQueryResult = HouseQueryRows | Offline | (ProviderRefusal & {
|
|
17
|
+
export type HouseQueryResult = HouseQueryRows | HouseQueryGroups | Offline | (ProviderRefusal & {
|
|
16
18
|
kind: 'rejected';
|
|
17
19
|
}) | (ProviderRefusal & {
|
|
18
20
|
kind: 'undeclared';
|
|
19
21
|
}) | Failure;
|
|
20
|
-
export declare function queriedHouse(runtime: Runtime, input: unknown, reach: PortReach | null): Promise<HouseQueryResult>;
|
|
22
|
+
export declare function queriedHouse(runtime: Runtime, input: unknown, reach: PortReach | null, options: unknown): Promise<HouseQueryResult>;
|
|
23
|
+
export {};
|
|
21
24
|
//# sourceMappingURL=house-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"house-query.d.ts","sourceRoot":"","sources":["../src/house-query.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"house-query.d.ts","sourceRoot":"","sources":["../src/house-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EACd,eAAe,EAChB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAA2C,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAEnG,OAAO,EAAsB,KA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