@agentshouse/mdruntime 0.1.0-c0136de3edfbe → 0.1.0-c01d4615bfe46
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 +16 -15
- package/dist/acceptance.d.ts +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +74 -164
- 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 +122 -68
- package/dist/adapter.d.ts +49 -55
- 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/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +2 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +11 -2
- package/dist/client.d.ts +13 -19
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +35 -19
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +31 -24
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +32 -24
- package/dist/conversation-live.d.ts +147 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +258 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +7 -1
- package/dist/conversation.d.ts +52 -44
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +956 -1029
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +19 -44
- package/dist/durability.d.ts +13 -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 +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts +1 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- 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 +18 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +46 -11
- package/dist/index.d.ts +17 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/install.d.ts +2 -4
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +53 -83
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +45 -35
- package/dist/listing.d.ts +6 -11
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +25 -61
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +3 -3
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +10 -22
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +10 -13
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +58 -27
- package/dist/messages.d.ts +10 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +26 -36
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +95 -135
- package/dist/observation.d.ts +3 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +22 -21
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +7 -10
- package/dist/outcome.d.ts +10 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +23 -2
- package/dist/overlay.d.ts +5 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +36 -21
- 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 +3 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +10 -115
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +25 -24
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +24 -14
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +2 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -6
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +450 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +68 -23
- package/dist/react.d.ts +11 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +1 -2
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +4 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +47 -5
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -6
- package/dist/replica.d.ts +5 -10
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +15 -16
- 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 +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +48 -59
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +17 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -4
- package/dist/runtime.d.ts +11 -19
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +333 -163
- package/dist/saves.d.ts +2 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +109 -703
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -3
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +6 -4
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +43 -35
- 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/session.d.ts +0 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket.d.ts +3 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +5 -16
- package/dist/source.d.ts +0 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +5 -4
- package/dist/store/records.d.ts +11 -8
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +43 -12
- package/dist/store/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +12 -7
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +38 -13
- package/dist/stored.d.ts +2 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +27 -15
- package/dist/surface.d.ts +7 -4
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +30 -25
- package/dist/sync.d.ts +0 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +93 -89
- package/dist/tables.d.ts +19 -11
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +58 -21
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -2
- package/dist/wire.d.ts +53 -7
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +17 -4
- package/package.json +3 -2
- 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 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -43
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/memory.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { documentFacts, parse } from '@agentshouse/mdmodel';
|
|
1
|
+
import { definitionAt, documentFacts, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { NO_ROOM_TYPES, schemaTypes } from './attached-model.js';
|
|
3
|
+
import { selected } from './collection.js';
|
|
4
|
+
import { declaredType } from './outcome.js';
|
|
3
5
|
import { sameChange } from './overlay.js';
|
|
4
6
|
const ATTACHMENTS = 'attachments';
|
|
5
7
|
function lastName(path) {
|
|
@@ -53,7 +55,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
53
55
|
const listeners = new Set();
|
|
54
56
|
const modeObservers = new Set();
|
|
55
57
|
const scripted = new Map();
|
|
56
|
-
const
|
|
58
|
+
const repeats = new Map();
|
|
57
59
|
const historyPageSize = options.historyPageSize;
|
|
58
60
|
const attached = new Map();
|
|
59
61
|
const linked = new WeakMap();
|
|
@@ -63,6 +65,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
63
65
|
const declaredRooms = new Set();
|
|
64
66
|
let replicated = [];
|
|
65
67
|
let heldCursor = null;
|
|
68
|
+
let agents = structuredClone(options.agents ?? []);
|
|
66
69
|
let issued = 0;
|
|
67
70
|
function scriptConversations(entries) {
|
|
68
71
|
scripted.clear();
|
|
@@ -104,8 +107,11 @@ export function createMemoryAdapter(options = {}) {
|
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
const saved = new WeakMap();
|
|
110
|
+
const roomTypes = options.roomTypes ?? NO_ROOM_TYPES;
|
|
107
111
|
function factsAt(room, path, content) {
|
|
108
|
-
const types =
|
|
112
|
+
const types = selected({ selection: room.typedSelection ?? null }, path)
|
|
113
|
+
? roomTypes.types
|
|
114
|
+
: schemaTypes(room.model?.kind === 'model' ? room.model.snapshot.schema : null, roomTypes);
|
|
109
115
|
let held = saved.get(types);
|
|
110
116
|
if (held === undefined) {
|
|
111
117
|
held = new Map();
|
|
@@ -113,7 +119,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
113
119
|
}
|
|
114
120
|
const key = `${path}\u0000${content}`;
|
|
115
121
|
if (!held.has(key)) {
|
|
116
|
-
const facts = documentFacts(path, parse(content, path
|
|
122
|
+
const facts = documentFacts(path, parse(content, path, definitionAt({ types }, path, options.typedPaths)), {
|
|
123
|
+
types,
|
|
124
|
+
});
|
|
117
125
|
held.set(key, facts === null ? null : JSON.parse(JSON.stringify(facts)));
|
|
118
126
|
}
|
|
119
127
|
return held.get(key);
|
|
@@ -147,8 +155,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
147
155
|
roomVersion: room.roomVersion,
|
|
148
156
|
operations: room.operations,
|
|
149
157
|
replica: room.replica,
|
|
150
|
-
|
|
158
|
+
typedSelection: room.typedSelection ?? null,
|
|
151
159
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
160
|
+
authoredPaths: room.authoredPaths ?? ['**'],
|
|
152
161
|
};
|
|
153
162
|
}
|
|
154
163
|
function page(room, after) {
|
|
@@ -258,16 +267,14 @@ export function createMemoryAdapter(options = {}) {
|
|
|
258
267
|
}
|
|
259
268
|
function pageOf(conversation, after) {
|
|
260
269
|
const messages = conversation.messages ?? [];
|
|
261
|
-
const first = typeof after === 'string' ? messages.findIndex((message) => message.
|
|
270
|
+
const first = typeof after === 'string' ? messages.findIndex((message) => message.change > after) : 0;
|
|
262
271
|
const from = first === -1 ? messages.length : first;
|
|
263
272
|
const page = messages.slice(from, from + (historyPageSize ?? messages.length));
|
|
264
273
|
const last = page.at(-1);
|
|
265
274
|
return {
|
|
266
275
|
conversation: conversation.conversation,
|
|
267
276
|
messages: page,
|
|
268
|
-
...(last !== undefined && from + page.length < messages.length
|
|
269
|
-
? { next: last.position }
|
|
270
|
-
: {}),
|
|
277
|
+
...(last !== undefined && from + page.length < messages.length ? { next: last.change } : {}),
|
|
271
278
|
};
|
|
272
279
|
}
|
|
273
280
|
function historiesOf(request) {
|
|
@@ -287,11 +294,20 @@ export function createMemoryAdapter(options = {}) {
|
|
|
287
294
|
function conversationAction(request) {
|
|
288
295
|
const name = request.name;
|
|
289
296
|
const input = (request.input ?? {});
|
|
297
|
+
const operation = typeof input.operation_id === 'string' ? `${name}\u0000${input.operation_id}` : null;
|
|
298
|
+
const first = (answer) => {
|
|
299
|
+
if (operation !== null)
|
|
300
|
+
repeats.set(operation, answer);
|
|
301
|
+
return answer;
|
|
302
|
+
};
|
|
303
|
+
const repeated = operation === null ? undefined : repeats.get(operation);
|
|
290
304
|
if (name === 'conversations/create') {
|
|
305
|
+
if (repeated !== undefined)
|
|
306
|
+
return repeated;
|
|
291
307
|
issued += 1;
|
|
292
308
|
const conversation = `conversation-${issued}`;
|
|
293
309
|
scripted.set(conversation, { conversation });
|
|
294
|
-
return { kind: 'action', result: { conversation_id: conversation } };
|
|
310
|
+
return first({ kind: 'action', result: { conversation_id: conversation } });
|
|
295
311
|
}
|
|
296
312
|
const named = typeof input.conversation_id === 'string' ? input.conversation_id : '';
|
|
297
313
|
const conversation = scripted.get(named);
|
|
@@ -307,26 +323,39 @@ export function createMemoryAdapter(options = {}) {
|
|
|
307
323
|
if (outcome !== undefined)
|
|
308
324
|
return outcome;
|
|
309
325
|
if (name === 'conversations/send') {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (answered !== undefined)
|
|
313
|
-
return { kind: 'action', result: { message_id: answered } };
|
|
326
|
+
if (repeated !== undefined)
|
|
327
|
+
return repeated;
|
|
314
328
|
issued += 1;
|
|
315
|
-
|
|
316
|
-
if (operation !== null)
|
|
317
|
-
sentTurns.set(operation, turn);
|
|
318
|
-
return { kind: 'action', result: { message_id: turn } };
|
|
329
|
+
return first({ kind: 'action', result: { message_id: `turn-${issued}` } });
|
|
319
330
|
}
|
|
320
331
|
if (name === 'conversations/delete')
|
|
321
332
|
scripted.delete(named);
|
|
322
333
|
return { kind: 'action', result: { conversation_id: named } };
|
|
323
334
|
}
|
|
335
|
+
function decided(request) {
|
|
336
|
+
const { request: asked, message, decision, } = (request.input ?? {});
|
|
337
|
+
return {
|
|
338
|
+
kind: 'action',
|
|
339
|
+
result: {
|
|
340
|
+
request: asked,
|
|
341
|
+
...(message === undefined ? {} : { message }),
|
|
342
|
+
state: decision === 'approve' ? 'started' : 'declined',
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
}
|
|
324
346
|
function announceList() {
|
|
325
347
|
const entries = [...scripted.values()].flatMap(({ conversation, listed, messages = [] }) => listed === undefined
|
|
326
348
|
? []
|
|
327
|
-
: [{ conversation, ...listed, newest: messages.at(-1)?.
|
|
349
|
+
: [{ conversation, ...listed, newest: messages.at(-1)?.change ?? null }]);
|
|
328
350
|
for (const listener of listeners) {
|
|
329
|
-
listener({
|
|
351
|
+
listener({
|
|
352
|
+
kind: 'list',
|
|
353
|
+
agents: structuredClone(agents),
|
|
354
|
+
entries,
|
|
355
|
+
whole: true,
|
|
356
|
+
more: false,
|
|
357
|
+
cursor: null,
|
|
358
|
+
});
|
|
330
359
|
}
|
|
331
360
|
}
|
|
332
361
|
function discovery() {
|
|
@@ -382,6 +411,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
382
411
|
setConversations(next) {
|
|
383
412
|
scriptConversations(next);
|
|
384
413
|
},
|
|
414
|
+
setAgents(next) {
|
|
415
|
+
agents = structuredClone(next);
|
|
416
|
+
},
|
|
385
417
|
open() {
|
|
386
418
|
carried.clear();
|
|
387
419
|
announceList();
|
|
@@ -444,9 +476,6 @@ export function createMemoryAdapter(options = {}) {
|
|
|
444
476
|
};
|
|
445
477
|
},
|
|
446
478
|
history: (request) => Promise.resolve(historiesOf(request)),
|
|
447
|
-
...(options.agents === undefined
|
|
448
|
-
? {}
|
|
449
|
-
: { agents: () => Promise.resolve(structuredClone(options.agents)) }),
|
|
450
479
|
},
|
|
451
480
|
serviceMode: {
|
|
452
481
|
observe(notify) {
|
|
@@ -598,8 +627,8 @@ export function createMemoryAdapter(options = {}) {
|
|
|
598
627
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
599
628
|
const blob = heldBlob(room, request.path);
|
|
600
629
|
return blob === undefined
|
|
601
|
-
? { kind: 'rejected', code: '
|
|
602
|
-
: { kind: 'binary', body: blob.stream(), mediaType: blob
|
|
630
|
+
? { kind: 'rejected', code: 'not_found', fields: {}, retryable: false }
|
|
631
|
+
: { kind: 'binary', body: blob.stream(), mediaType: declaredType(blob) };
|
|
603
632
|
}, request);
|
|
604
633
|
},
|
|
605
634
|
async link(_authorization, request) {
|
|
@@ -609,11 +638,11 @@ export function createMemoryAdapter(options = {}) {
|
|
|
609
638
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
610
639
|
const blob = heldBlob(room, request.path);
|
|
611
640
|
if (blob === undefined) {
|
|
612
|
-
return { kind: 'rejected', code: '
|
|
641
|
+
return { kind: 'rejected', code: 'not_found', fields: {}, retryable: false };
|
|
613
642
|
}
|
|
614
643
|
const url = linked.get(blob) ?? URL.createObjectURL(blob);
|
|
615
644
|
linked.set(blob, url);
|
|
616
|
-
return { kind: 'link', url, name: lastName(request.path), mediaType: blob
|
|
645
|
+
return { kind: 'link', url, name: lastName(request.path), mediaType: declaredType(blob) };
|
|
617
646
|
}, request);
|
|
618
647
|
},
|
|
619
648
|
async attach(_authorization, request) {
|
|
@@ -630,6 +659,8 @@ export function createMemoryAdapter(options = {}) {
|
|
|
630
659
|
return resolveScript(scripts.action, () => {
|
|
631
660
|
if (request.name.startsWith('conversations/'))
|
|
632
661
|
return conversationAction(request);
|
|
662
|
+
if (request.name === 'agent-functions/decide')
|
|
663
|
+
return decided(request);
|
|
633
664
|
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
634
665
|
}, request).then((answer) => {
|
|
635
666
|
if (answer.kind === 'action' && answer.at !== undefined)
|
package/dist/messages.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
-
import type { JobMarker } from './job.js';
|
|
3
2
|
import type { Connection } from './tables.js';
|
|
4
3
|
export declare const MESSAGE_TABLES: readonly string[];
|
|
5
|
-
export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n
|
|
6
|
-
export declare const JOB_MARKERS = "SELECT json_extract(part.value, '$.text') AS said,\n json_extract(message, '$.accepted_at') AS at\n FROM conversation_messages, json_each(message, '$.parts') AS part\n WHERE conversation = ? AND instr(message, '\"marker\":\"job\"') > 0\n AND json_extract(part.value, '$.type') = 'marker'\n AND json_extract(part.value, '$.marker') = 'job'\n ORDER BY position, identity, part.key";
|
|
4
|
+
export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n asking.text AS asking_text,\n json_extract(asking.message, '$.accepted_at') AS asking_at,\n json_extract(asking.message, '$.source') AS asking_source,\n json_extract(asking.message, '$.sender') AS asking_sender\n FROM chosen\n LEFT JOIN conversation_messages said ON said.id = chosen.said\n LEFT JOIN conversation_messages answer ON answer.id = chosen.answer\n LEFT JOIN conversation_messages opened ON opened.id = chosen.opened\n LEFT JOIN conversation_messages asking ON asking.id = chosen.asking";
|
|
7
5
|
export type HeldConversation = {
|
|
8
6
|
readonly conversation: string;
|
|
9
7
|
readonly read: string | null | undefined;
|
|
@@ -32,6 +30,12 @@ export type HeldRow = {
|
|
|
32
30
|
readonly at: string | null;
|
|
33
31
|
}) | null;
|
|
34
32
|
};
|
|
33
|
+
export type ConversationFact = 'openedTurn' | 'dismissedSuggestion';
|
|
34
|
+
export type HeldFact = {
|
|
35
|
+
readonly conversation: string;
|
|
36
|
+
readonly name: ConversationFact;
|
|
37
|
+
readonly value: string;
|
|
38
|
+
};
|
|
35
39
|
export type ConversationWrite = {
|
|
36
40
|
readonly conversation: string;
|
|
37
41
|
readonly messages: readonly AcceptedMessage[];
|
|
@@ -45,8 +49,8 @@ export declare function keptMessages(connection: Connection, { conversation, mes
|
|
|
45
49
|
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
|
|
46
50
|
export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
|
|
47
51
|
export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
|
|
48
|
-
export declare function jobMarkers(connection: Connection, conversation: string): JobMarker[];
|
|
49
52
|
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
50
|
-
export declare function
|
|
51
|
-
export declare function
|
|
53
|
+
export declare function conversationFacts(connection: Connection): HeldFact[];
|
|
54
|
+
export declare function keptFact(connection: Connection, { conversation, name, value }: HeldFact): null;
|
|
55
|
+
export declare function forgottenConversations(connection: Connection): void;
|
|
52
56
|
//# sourceMappingURL=messages.d.ts.map
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAM1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAQ3C,CAAC;AAQF,eAAO,MAAM,IAAI,qwDAwBqD,CAAC;AAEvE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7F,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEtF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B,GAAG,IAAI,CAAC;IACT,QA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E,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,EACxC,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,aAAa,CAWf;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,CAOR;AAaD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,OAAO,EAAE,CAuBX;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAO/F;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,EAAE,CAMpE;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,QAAQ,GAAG,IAAI,CAM9F;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAEnE"}
|
package/dist/messages.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { sql } from '@agentshouse/mdmodel';
|
|
2
2
|
import { EXCERPT } from './read.js';
|
|
3
|
+
import { tablesOf } from './stored.js';
|
|
3
4
|
const SAID_BY_HOUSE = `json_extract(message, '$.role') = 'house'`;
|
|
4
5
|
const ANSWERS_THE_TURN = `json_extract(message, '$.role') = 'assistant'`;
|
|
5
|
-
const MARKS_A_JOB = `instr(message, '"marker":"job"') > 0`;
|
|
6
6
|
export const MESSAGE_TABLES = [
|
|
7
7
|
'CREATE TABLE conversation_reads (conversation TEXT PRIMARY KEY, read TEXT, partial INTEGER NOT NULL) WITHOUT ROWID',
|
|
8
|
-
'CREATE TABLE conversation_messages (id INTEGER PRIMARY KEY, conversation TEXT NOT NULL, identity TEXT NOT NULL, turn TEXT NOT NULL, position TEXT NOT NULL, message TEXT NOT NULL, text TEXT NOT NULL)',
|
|
8
|
+
'CREATE TABLE conversation_messages (id INTEGER PRIMARY KEY, conversation TEXT NOT NULL, identity TEXT NOT NULL, turn TEXT NOT NULL, position TEXT NOT NULL, change TEXT NOT NULL, message TEXT NOT NULL, text TEXT NOT NULL)',
|
|
9
9
|
'CREATE UNIQUE INDEX conversation_messages_identity ON conversation_messages (conversation, identity)',
|
|
10
10
|
'CREATE INDEX conversation_messages_position ON conversation_messages (conversation, position, identity)',
|
|
11
11
|
'CREATE INDEX conversation_messages_turn ON conversation_messages (conversation, turn)',
|
|
12
12
|
`CREATE INDEX conversation_messages_house ON conversation_messages (conversation, position, identity) WHERE ${SAID_BY_HOUSE}`,
|
|
13
|
-
|
|
13
|
+
'CREATE TABLE conversation_facts (conversation TEXT NOT NULL, name TEXT NOT NULL, value TEXT NOT NULL, PRIMARY KEY (conversation, name)) WITHOUT ROWID',
|
|
14
14
|
];
|
|
15
15
|
const NEWEST_FIRST = 'ORDER BY position DESC, identity DESC LIMIT 1';
|
|
16
16
|
const OLDEST_FIRST = 'ORDER BY position, identity LIMIT 1';
|
|
@@ -31,7 +31,7 @@ export const ROWS = `WITH chosen AS (
|
|
|
31
31
|
json_extract(opened.message, '$.source') AS opened_source,
|
|
32
32
|
json_extract(opened.message, '$.sender') AS opened_sender,
|
|
33
33
|
asking.identity AS asking_identity,
|
|
34
|
-
|
|
34
|
+
asking.text AS asking_text,
|
|
35
35
|
json_extract(asking.message, '$.accepted_at') AS asking_at,
|
|
36
36
|
json_extract(asking.message, '$.source') AS asking_source,
|
|
37
37
|
json_extract(asking.message, '$.sender') AS asking_sender
|
|
@@ -40,13 +40,6 @@ export const ROWS = `WITH chosen AS (
|
|
|
40
40
|
LEFT JOIN conversation_messages answer ON answer.id = chosen.answer
|
|
41
41
|
LEFT JOIN conversation_messages opened ON opened.id = chosen.opened
|
|
42
42
|
LEFT JOIN conversation_messages asking ON asking.id = chosen.asking`;
|
|
43
|
-
export const JOB_MARKERS = `SELECT json_extract(part.value, '$.text') AS said,
|
|
44
|
-
json_extract(message, '$.accepted_at') AS at
|
|
45
|
-
FROM conversation_messages, json_each(message, '$.parts') AS part
|
|
46
|
-
WHERE conversation = ? AND ${MARKS_A_JOB}
|
|
47
|
-
AND json_extract(part.value, '$.type') = 'marker'
|
|
48
|
-
AND json_extract(part.value, '$.marker') = 'job'
|
|
49
|
-
ORDER BY position, identity, part.key`;
|
|
50
43
|
function text(value) {
|
|
51
44
|
return typeof value === 'string' ? value : String(value);
|
|
52
45
|
}
|
|
@@ -72,19 +65,15 @@ export function heldConversations(connection, conversations) {
|
|
|
72
65
|
}
|
|
73
66
|
export function keptMessages(connection, { conversation, messages, read }) {
|
|
74
67
|
for (const message of messages) {
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, change, message, text) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (conversation, identity) DO UPDATE SET turn = excluded.turn, position = excluded.position, change = excluded.change, message = excluded.message, text = excluded.text', [
|
|
69
|
+
conversation,
|
|
70
|
+
message.identity,
|
|
77
71
|
message.turn,
|
|
78
72
|
message.position,
|
|
73
|
+
message.change,
|
|
79
74
|
JSON.stringify(message.message ?? null),
|
|
80
75
|
message.text,
|
|
81
|
-
];
|
|
82
|
-
if (held === undefined) {
|
|
83
|
-
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, message, text) VALUES (?, ?, ?, ?, ?, ?)', [conversation, message.identity, ...record]);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
connection.run('UPDATE conversation_messages SET turn = ?, position = ?, message = ?, text = ? WHERE id = ?', [...record, held.id]);
|
|
87
|
-
}
|
|
76
|
+
]);
|
|
88
77
|
}
|
|
89
78
|
if (read !== undefined) {
|
|
90
79
|
connection.run('INSERT OR REPLACE INTO conversation_reads (conversation, read, partial) VALUES (?, ?, ?)', [conversation, read.at, read.partial ? 1 : 0]);
|
|
@@ -96,6 +85,7 @@ function accepted(row) {
|
|
|
96
85
|
identity: text(row.identity),
|
|
97
86
|
turn: text(row.turn),
|
|
98
87
|
position: text(row.position),
|
|
88
|
+
change: text(row.change),
|
|
99
89
|
text: text(row.text),
|
|
100
90
|
message: JSON.parse(text(row.message)),
|
|
101
91
|
};
|
|
@@ -107,7 +97,7 @@ function holding(phrase) {
|
|
|
107
97
|
}
|
|
108
98
|
export function messageWindow(connection, conversation, limit, before, phrase) {
|
|
109
99
|
const held = holding(phrase);
|
|
110
|
-
const rows = connection.rows(`SELECT identity, turn, position, message, text FROM conversation_messages WHERE conversation = ?${held.sql}${before === null ? '' : ' AND (position < ? OR (position = ? AND identity < ?))'} ORDER BY position DESC, identity DESC LIMIT ?`, before === null
|
|
100
|
+
const rows = connection.rows(`SELECT identity, turn, position, change, message, text FROM conversation_messages WHERE conversation = ?${held.sql}${before === null ? '' : ' AND (position < ? OR (position = ? AND identity < ?))'} ORDER BY position DESC, identity DESC LIMIT ?`, before === null
|
|
111
101
|
? [conversation, ...held.bind, limit + 1]
|
|
112
102
|
: [conversation, ...held.bind, before[0], before[0], before[1], limit + 1]);
|
|
113
103
|
return { messages: rows.slice(0, limit).map(accepted).reverse(), more: rows.length > limit };
|
|
@@ -118,11 +108,11 @@ export function messageCount(connection, conversation, phrase) {
|
|
|
118
108
|
return Number(counted?.held ?? 0);
|
|
119
109
|
}
|
|
120
110
|
function textOrNull(value) {
|
|
121
|
-
return value === null
|
|
111
|
+
return value === null ? null : text(value);
|
|
122
112
|
}
|
|
123
113
|
function heldSource(source, sender) {
|
|
124
114
|
return {
|
|
125
|
-
source: source === null
|
|
115
|
+
source: source === null ? null : JSON.parse(text(source)),
|
|
126
116
|
sender: textOrNull(sender),
|
|
127
117
|
};
|
|
128
118
|
}
|
|
@@ -148,21 +138,21 @@ export function conversationRows(connection, conversations) {
|
|
|
148
138
|
},
|
|
149
139
|
}));
|
|
150
140
|
}
|
|
151
|
-
export function jobMarkers(connection, conversation) {
|
|
152
|
-
return connection
|
|
153
|
-
.rows(JOB_MARKERS, [conversation])
|
|
154
|
-
.map((row) => ({ said: text(row.said), at: text(row.at) }));
|
|
155
|
-
}
|
|
156
141
|
export function turnArrived(connection, conversation, turn) {
|
|
157
142
|
return (connection.rows('SELECT 1 FROM conversation_messages WHERE conversation = ? AND turn = ? LIMIT 1', [conversation, turn]).length > 0);
|
|
158
143
|
}
|
|
159
|
-
export function
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
144
|
+
export function conversationFacts(connection) {
|
|
145
|
+
return connection.rows('SELECT conversation, name, value FROM conversation_facts').map((row) => ({
|
|
146
|
+
conversation: text(row.conversation),
|
|
147
|
+
name: text(row.name),
|
|
148
|
+
value: text(row.value),
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
export function keptFact(connection, { conversation, name, value }) {
|
|
152
|
+
connection.run('INSERT OR REPLACE INTO conversation_facts (conversation, name, value) VALUES (?, ?, ?)', [conversation, name, value]);
|
|
153
|
+
return null;
|
|
164
154
|
}
|
|
165
|
-
export function
|
|
166
|
-
|
|
167
|
-
|
|
155
|
+
export function forgottenConversations(connection) {
|
|
156
|
+
for (const table of tablesOf(MESSAGE_TABLES))
|
|
157
|
+
connection.run(`DELETE FROM ${table}`);
|
|
168
158
|
}
|
package/dist/model.d.ts
CHANGED
|
@@ -50,7 +50,6 @@ export type ValidationReceipt = {
|
|
|
50
50
|
source: Open<'current' | 'cached'>;
|
|
51
51
|
};
|
|
52
52
|
export declare const NO_MODEL: ModelState;
|
|
53
|
-
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
54
53
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
55
54
|
export declare function storedModel(state: ModelState): StoredModel;
|
|
56
55
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","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,GAAG,QAAQ,CAAC,CAAC;CACpC,CAAC;AACF,eAAO,MAAM,QAAQ,EAAE,UAA8D,CAAC;AACtF,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAczD;AACD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAI1D"}
|
package/dist/model.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
export const NO_MODEL = { status: 'unavailable', reason: 'not-acquired' };
|
|
2
|
-
export function definitionOf(state, type) {
|
|
3
|
-
if (state.status === 'unavailable' || type === undefined)
|
|
4
|
-
return undefined;
|
|
5
|
-
return Object.hasOwn(state.types, type) ? state.types[type] : undefined;
|
|
6
|
-
}
|
|
7
2
|
export function modelTypes(state) {
|
|
8
3
|
return state.status === 'unavailable'
|
|
9
4
|
? { ...state, types: null }
|
package/dist/models.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type { ScopedRefusal } from './adapter.js';
|
|
1
|
+
import type { RoomDeclaration, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import { type ModelState } from './model.js';
|
|
3
|
-
import { type ReplicaRecord } from './replica.js';
|
|
4
3
|
import type { Runtime } from './runtime.js';
|
|
5
|
-
import type { RoomDeclaration } from './socket.js';
|
|
6
4
|
import type { RuntimeStore } from './store.js';
|
|
7
|
-
export declare function declaredAsHeld(held: ReplicaRecord | undefined, room: RoomDeclaration): boolean;
|
|
8
5
|
export declare function revoked(model: ModelState | undefined): boolean;
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function settleModels(runtime: Runtime, held: readonly RoomDeclaration[], status: 'current' | 'cached', local: RuntimeStore): Promise<void>;
|
|
6
|
+
export declare function retainModel(runtime: Runtime, locator: string, declaration: RoomDeclaration, given: ModelState | null, refused?: true): Promise<void>;
|
|
7
|
+
export declare function scoped(runtime: Runtime, result: ScopedRefusal, locator: string, declaration: RoomDeclaration): Promise<void>;
|
|
8
|
+
export declare function settleModels(runtime: Runtime, held: ReadonlyMap<string, RoomDeclaration>, status: 'current' | 'cached', local: RuntimeStore): Promise<void>;
|
|
13
9
|
export declare function cachedModels(runtime: Runtime, local: RuntimeStore): Promise<void>;
|
|
14
10
|
//# sourceMappingURL=models.d.ts.map
|
package/dist/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAOnE,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAGvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAc,YAAY,EAAS,MAAM,YAAY,CAAC;AAMlE,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAE9D;AA0DD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,eAAe,EAC5B,KAAK,EAAE,UAAU,GAAG,IAAI,EACxB,OAAO,CAAC,EAAE,IAAI,iBA2Bf;AAED,wBAAsB,MAAM,CAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,eAAe,iBAkB7B;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,EAC1C,MAAM,EAAE,SAAS,GAAG,QAAQ,EAC5B,KAAK,EAAE,YAAY,iBA8CpB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvF"}
|