@agentshouse/mdruntime 0.1.0-c069136dcb4e8 → 0.1.0-c09bf842921ff
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/adapter.d.ts +51 -22
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -56
- package/dist/bootstrap.d.ts +2 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +9 -8
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/client.d.ts +9 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -1
- package/dist/collection.d.ts +2 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/compile.d.ts +1 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +90 -277
- package/dist/connection.d.ts +8 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +362 -313
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation.d.ts +14 -8
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +85 -67
- package/dist/durability.d.ts +6 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +16 -7
- package/dist/host.d.ts +3 -6
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +16 -23
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/job.d.ts +14 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +28 -0
- package/dist/live.d.ts +2 -1
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +10 -7
- package/dist/memory.d.ts +8 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +116 -66
- package/dist/messages.d.ts +2 -2
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +15 -16
- package/dist/model.d.ts +2 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -3
- package/dist/observation.d.ts +2 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +7 -2
- package/dist/query.d.ts +4 -209
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/reach.d.ts +7 -7
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +33 -44
- package/dist/react.d.ts +3 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +0 -2
- package/dist/readiness.d.ts.map +1 -1
- package/dist/refresh.d.ts +2 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +25 -1
- package/dist/replica.d.ts +8 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +27 -9
- package/dist/room-draft.d.ts +4 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +65 -52
- package/dist/rows.d.ts +14 -21
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +48 -184
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +1 -1
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/store.d.ts +5 -7
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +11 -15
- package/dist/stored.d.ts +3 -4
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +90 -126
- package/dist/tables.d.ts +8 -6
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +22 -13
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +7 -4
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +9 -4
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +3 -1
- package/package.json +2 -2
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -370
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
package/dist/memory.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { documentFacts, parse } from '@agentshouse/mdmodel';
|
|
2
|
+
import { NO_ROOM_TYPES, schemaTypes } from './attached-model.js';
|
|
1
3
|
import { sameChange } from './overlay.js';
|
|
2
4
|
const ATTACHMENTS = 'attachments';
|
|
3
5
|
function lastName(path) {
|
|
@@ -5,7 +7,6 @@ function lastName(path) {
|
|
|
5
7
|
}
|
|
6
8
|
const FIXTURE_RETENTION = {
|
|
7
9
|
history: { kind: 'duration', seconds: 1 },
|
|
8
|
-
outcome: 604_800,
|
|
9
10
|
refreshHorizon: 1,
|
|
10
11
|
};
|
|
11
12
|
function declaredRetention(value) {
|
|
@@ -52,15 +53,16 @@ export function createMemoryAdapter(options = {}) {
|
|
|
52
53
|
const listeners = new Set();
|
|
53
54
|
const modeObservers = new Set();
|
|
54
55
|
const scripted = new Map();
|
|
55
|
-
const unsealed = new Map();
|
|
56
|
-
const sealed = new Set();
|
|
57
56
|
const sentTurns = new Map();
|
|
58
57
|
const historyPageSize = options.historyPageSize;
|
|
59
58
|
const attached = new Map();
|
|
60
59
|
const linked = new WeakMap();
|
|
61
60
|
const carried = new Map();
|
|
62
61
|
let expiring = [];
|
|
62
|
+
let openings = 0;
|
|
63
|
+
const declaredRooms = new Set();
|
|
63
64
|
let replicated = [];
|
|
65
|
+
let heldCursor = null;
|
|
64
66
|
let issued = 0;
|
|
65
67
|
function scriptConversations(entries) {
|
|
66
68
|
scripted.clear();
|
|
@@ -101,8 +103,35 @@ export function createMemoryAdapter(options = {}) {
|
|
|
101
103
|
return path;
|
|
102
104
|
}
|
|
103
105
|
}
|
|
106
|
+
const saved = new WeakMap();
|
|
107
|
+
function factsAt(room, path, content) {
|
|
108
|
+
const types = schemaTypes(room.model?.kind === 'model' ? room.model.snapshot.schema : null, NO_ROOM_TYPES);
|
|
109
|
+
let held = saved.get(types);
|
|
110
|
+
if (held === undefined) {
|
|
111
|
+
held = new Map();
|
|
112
|
+
saved.set(types, held);
|
|
113
|
+
}
|
|
114
|
+
const key = `${path}\u0000${content}`;
|
|
115
|
+
if (!held.has(key)) {
|
|
116
|
+
const facts = documentFacts(path, parse(content, path), { types });
|
|
117
|
+
held.set(key, facts === null ? null : JSON.parse(JSON.stringify(facts)));
|
|
118
|
+
}
|
|
119
|
+
return held.get(key);
|
|
120
|
+
}
|
|
121
|
+
function factsIn(room, paths) {
|
|
122
|
+
const facts = {};
|
|
123
|
+
for (const path of paths) {
|
|
124
|
+
const content = room.documents?.[path];
|
|
125
|
+
const held = room.facts?.[path] ?? (content === undefined ? null : factsAt(room, path, content));
|
|
126
|
+
if (held !== null)
|
|
127
|
+
facts[path] = held;
|
|
128
|
+
}
|
|
129
|
+
return facts;
|
|
130
|
+
}
|
|
104
131
|
function retain(entries) {
|
|
105
132
|
for (const room of entries) {
|
|
133
|
+
for (const [path, content] of Object.entries(room.documents ?? {}))
|
|
134
|
+
factsAt(room, path, content);
|
|
106
135
|
note(room.locator, room);
|
|
107
136
|
const versions = served.get(room.locator) ?? new Map();
|
|
108
137
|
versions.set(room.roomVersion, room);
|
|
@@ -135,6 +164,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
135
164
|
roomVersion: room.roomVersion,
|
|
136
165
|
...(opening ? { models: modelsOf(room) } : {}),
|
|
137
166
|
documents: named(room.documents ?? {}, taken),
|
|
167
|
+
facts: factsIn(room, taken),
|
|
138
168
|
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
139
169
|
...(room.fileIds === undefined
|
|
140
170
|
? {}
|
|
@@ -182,6 +212,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
182
212
|
roomVersion: room.roomVersion,
|
|
183
213
|
...(models === undefined ? {} : { models }),
|
|
184
214
|
documents: named(current, taken),
|
|
215
|
+
facts: factsIn(room, taken),
|
|
185
216
|
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
186
217
|
...(room.fileIds === undefined
|
|
187
218
|
? {}
|
|
@@ -232,16 +263,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
232
263
|
: {}),
|
|
233
264
|
};
|
|
234
265
|
}
|
|
235
|
-
function historiesOf(
|
|
236
|
-
const asked = input?.conversations;
|
|
237
|
-
if (!Array.isArray(asked))
|
|
238
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
266
|
+
function historiesOf(request) {
|
|
239
267
|
const histories = [];
|
|
240
|
-
for (const entry of
|
|
241
|
-
const conversation =
|
|
268
|
+
for (const entry of request.conversations) {
|
|
269
|
+
const conversation = scripted.get(entry.conversation);
|
|
242
270
|
if (conversation === undefined)
|
|
243
271
|
continue;
|
|
244
|
-
const outcome = conversation.outcomes?.
|
|
272
|
+
const outcome = conversation.outcomes?.history;
|
|
245
273
|
if (outcome !== undefined)
|
|
246
274
|
return outcome;
|
|
247
275
|
histories.push(pageOf(conversation, entry.after));
|
|
@@ -252,15 +280,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
252
280
|
function conversationAction(request) {
|
|
253
281
|
const name = request.name;
|
|
254
282
|
const input = (request.input ?? {});
|
|
255
|
-
if (name === '
|
|
256
|
-
return historiesOf(request.input);
|
|
257
|
-
if (name === 'conversation.create') {
|
|
283
|
+
if (name === 'conversations/create') {
|
|
258
284
|
issued += 1;
|
|
259
285
|
const conversation = `conversation-${issued}`;
|
|
260
286
|
scripted.set(conversation, { conversation });
|
|
261
|
-
return { kind: 'action', result: { conversation } };
|
|
287
|
+
return { kind: 'action', result: { conversation_id: conversation } };
|
|
262
288
|
}
|
|
263
|
-
const named = typeof input.
|
|
289
|
+
const named = typeof input.conversation_id === 'string' ? input.conversation_id : '';
|
|
264
290
|
const conversation = scripted.get(named);
|
|
265
291
|
if (conversation === undefined) {
|
|
266
292
|
return {
|
|
@@ -273,36 +299,28 @@ export function createMemoryAdapter(options = {}) {
|
|
|
273
299
|
const outcome = conversation.outcomes?.[name];
|
|
274
300
|
if (outcome !== undefined)
|
|
275
301
|
return outcome;
|
|
276
|
-
if (name === '
|
|
302
|
+
if (name === 'conversations/send') {
|
|
277
303
|
const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
|
|
278
304
|
const answered = operation === null ? undefined : sentTurns.get(operation);
|
|
279
305
|
if (answered !== undefined)
|
|
280
|
-
return { kind: 'action', result: {
|
|
306
|
+
return { kind: 'action', result: { message_id: answered } };
|
|
281
307
|
issued += 1;
|
|
282
308
|
const turn = `turn-${issued}`;
|
|
283
|
-
unsealed.set(turn, named);
|
|
284
309
|
if (operation !== null)
|
|
285
310
|
sentTurns.set(operation, turn);
|
|
286
|
-
return { kind: 'action', result: { turn } };
|
|
287
|
-
}
|
|
288
|
-
if (name === 'conversation.cancel') {
|
|
289
|
-
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
290
|
-
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
291
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
292
|
-
}
|
|
293
|
-
unsealed.delete(turn);
|
|
294
|
-
return { kind: 'action', result: { turn, cancelled: true } };
|
|
311
|
+
return { kind: 'action', result: { message_id: turn } };
|
|
295
312
|
}
|
|
296
|
-
if (name === '
|
|
313
|
+
if (name === 'conversations/delete')
|
|
297
314
|
scripted.delete(named);
|
|
298
|
-
return { kind: 'action', result: {
|
|
315
|
+
return { kind: 'action', result: { conversation_id: named } };
|
|
299
316
|
}
|
|
300
317
|
function announceList() {
|
|
301
318
|
const entries = [...scripted.values()].flatMap(({ conversation, listed, messages = [] }) => listed === undefined
|
|
302
319
|
? []
|
|
303
320
|
: [{ conversation, ...listed, newest: messages.at(-1)?.position ?? null }]);
|
|
304
|
-
for (const listener of listeners)
|
|
305
|
-
listener({ kind: 'list', entries });
|
|
321
|
+
for (const listener of listeners) {
|
|
322
|
+
listener({ kind: 'list', entries, whole: true, more: false, cursor: null });
|
|
323
|
+
}
|
|
306
324
|
}
|
|
307
325
|
function discovery() {
|
|
308
326
|
return {
|
|
@@ -314,9 +332,42 @@ export function createMemoryAdapter(options = {}) {
|
|
|
314
332
|
...(options.member === undefined ? {} : { member: options.member }),
|
|
315
333
|
};
|
|
316
334
|
}
|
|
335
|
+
function discovered() {
|
|
336
|
+
return resolveScript(scripts.discover, discovery, undefined).then((answer) => {
|
|
337
|
+
if (answer.kind === 'discovery')
|
|
338
|
+
for (const room of answer.rooms)
|
|
339
|
+
note(room.locator, room);
|
|
340
|
+
return answer;
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
function opened(notify) {
|
|
344
|
+
const opening = ++openings;
|
|
345
|
+
notify({ kind: 'opened' });
|
|
346
|
+
void discovered()
|
|
347
|
+
.catch(() => ({ kind: 'transport-uncertainty' }))
|
|
348
|
+
.then((answer) => {
|
|
349
|
+
if (opening !== openings)
|
|
350
|
+
return;
|
|
351
|
+
if (answer.kind !== 'discovery') {
|
|
352
|
+
openings += 1;
|
|
353
|
+
carried.clear();
|
|
354
|
+
const revoked = answer.kind === 'revoked-authorization';
|
|
355
|
+
notify({ kind: 'closed', revoked, lost: !revoked, authorityChanged: false });
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
declaredRooms.clear();
|
|
359
|
+
for (const room of answer.rooms)
|
|
360
|
+
declaredRooms.add(room.locator);
|
|
361
|
+
notify({ kind: 'discovered', discovery: answer });
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function emitAll(event) {
|
|
365
|
+
for (const observer of observers)
|
|
366
|
+
observer(event);
|
|
367
|
+
}
|
|
317
368
|
return {
|
|
318
|
-
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
319
369
|
...(options.roomTypes === undefined ? {} : { roomTypes: options.roomTypes }),
|
|
370
|
+
...(options.typedPaths === undefined ? {} : { typedPaths: options.typedPaths }),
|
|
320
371
|
setRooms(next) {
|
|
321
372
|
rooms = [...next];
|
|
322
373
|
retain(rooms);
|
|
@@ -327,13 +378,12 @@ export function createMemoryAdapter(options = {}) {
|
|
|
327
378
|
open() {
|
|
328
379
|
carried.clear();
|
|
329
380
|
announceList();
|
|
330
|
-
|
|
331
|
-
observer({ kind: 'opened' });
|
|
381
|
+
opened(emitAll);
|
|
332
382
|
},
|
|
333
|
-
close({ revoked = false, lost = !revoked } = {}) {
|
|
383
|
+
close({ revoked = false, lost = !revoked, authorityChanged = false } = {}) {
|
|
384
|
+
openings += 1;
|
|
334
385
|
carried.clear();
|
|
335
|
-
|
|
336
|
-
observer({ kind: 'closed', revoked, lost });
|
|
386
|
+
emitAll({ kind: 'closed', revoked, lost, authorityChanged });
|
|
337
387
|
},
|
|
338
388
|
expire(locators) {
|
|
339
389
|
expiring = [...locators];
|
|
@@ -341,18 +391,22 @@ export function createMemoryAdapter(options = {}) {
|
|
|
341
391
|
notifyRoomVersion({ locator }) {
|
|
342
392
|
carry(locator);
|
|
343
393
|
},
|
|
344
|
-
notifyAuthorityChanged(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
394
|
+
notifyAuthorityChanged(locators) {
|
|
395
|
+
const named = new Set(locators ?? [...declaredRooms, ...rooms.map((room) => room.locator)]);
|
|
396
|
+
const listed = rooms.filter((room) => named.has(room.locator));
|
|
397
|
+
const left = [...named].filter((locator) => !listed.some((room) => room.locator === locator));
|
|
398
|
+
for (const room of listed)
|
|
399
|
+
declaredRooms.add(room.locator);
|
|
400
|
+
for (const locator of left)
|
|
401
|
+
declaredRooms.delete(locator);
|
|
402
|
+
emitAll({
|
|
403
|
+
kind: 'authority-changed',
|
|
404
|
+
rooms: listed.map(declared),
|
|
405
|
+
left,
|
|
406
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
407
|
+
});
|
|
350
408
|
},
|
|
351
409
|
notifyConversation(event) {
|
|
352
|
-
if (event.kind === 'accepted-message') {
|
|
353
|
-
sealed.add(event.message.turn);
|
|
354
|
-
unsealed.delete(event.message.turn);
|
|
355
|
-
}
|
|
356
410
|
for (const listener of listeners)
|
|
357
411
|
listener(event);
|
|
358
412
|
},
|
|
@@ -366,16 +420,23 @@ export function createMemoryAdapter(options = {}) {
|
|
|
366
420
|
replicatedConversations() {
|
|
367
421
|
return replicated;
|
|
368
422
|
},
|
|
423
|
+
heldConversationCursor() {
|
|
424
|
+
return heldCursor;
|
|
425
|
+
},
|
|
369
426
|
conversations: {
|
|
370
427
|
replicate(next) {
|
|
371
428
|
replicated = [...next];
|
|
372
429
|
},
|
|
430
|
+
hold(cursor) {
|
|
431
|
+
heldCursor = cursor;
|
|
432
|
+
},
|
|
373
433
|
observe(notify) {
|
|
374
434
|
listeners.add(notify);
|
|
375
435
|
return () => {
|
|
376
436
|
listeners.delete(notify);
|
|
377
437
|
};
|
|
378
438
|
},
|
|
439
|
+
history: (request) => Promise.resolve(historiesOf(request)),
|
|
379
440
|
...(options.agents === undefined
|
|
380
441
|
? {}
|
|
381
442
|
: { agents: () => Promise.resolve(structuredClone(options.agents)) }),
|
|
@@ -412,16 +473,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
412
473
|
carry(room.locator);
|
|
413
474
|
}
|
|
414
475
|
}
|
|
415
|
-
|
|
416
|
-
observer({ kind: 'opening', expired });
|
|
417
|
-
});
|
|
418
|
-
},
|
|
419
|
-
reopen() {
|
|
420
|
-
queueMicrotask(() => {
|
|
421
|
-
carried.clear();
|
|
422
|
-
for (const observer of observers) {
|
|
423
|
-
observer({ kind: 'closed', revoked: false, lost: false });
|
|
424
|
-
}
|
|
476
|
+
emitAll({ kind: 'caught-up', expired });
|
|
425
477
|
});
|
|
426
478
|
},
|
|
427
479
|
observe(notify) {
|
|
@@ -430,11 +482,14 @@ export function createMemoryAdapter(options = {}) {
|
|
|
430
482
|
if (!observers.has(notify))
|
|
431
483
|
return;
|
|
432
484
|
if (options.unopened === true) {
|
|
433
|
-
notify({ kind: 'closed', revoked: false, lost: true });
|
|
485
|
+
notify({ kind: 'closed', revoked: false, lost: true, authorityChanged: false });
|
|
434
486
|
return;
|
|
435
487
|
}
|
|
436
488
|
announceList();
|
|
437
|
-
|
|
489
|
+
opened((event) => {
|
|
490
|
+
if (observers.has(notify))
|
|
491
|
+
notify(event);
|
|
492
|
+
});
|
|
438
493
|
});
|
|
439
494
|
return () => {
|
|
440
495
|
observers.delete(notify);
|
|
@@ -451,12 +506,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
451
506
|
return resolveScript(scripts.authorize, () => ({}), undefined);
|
|
452
507
|
},
|
|
453
508
|
async discover(_authorization) {
|
|
454
|
-
return
|
|
455
|
-
if (answer.kind === 'discovery')
|
|
456
|
-
for (const room of answer.rooms)
|
|
457
|
-
note(room.locator, room);
|
|
458
|
-
return answer;
|
|
459
|
-
});
|
|
509
|
+
return discovered();
|
|
460
510
|
},
|
|
461
511
|
reached,
|
|
462
512
|
follows(locator, roomVersion, next) {
|
|
@@ -570,7 +620,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
570
620
|
},
|
|
571
621
|
async action(_authorization, request) {
|
|
572
622
|
return resolveScript(scripts.action, () => {
|
|
573
|
-
if (request.name.startsWith('
|
|
623
|
+
if (request.name.startsWith('conversations/'))
|
|
574
624
|
return conversationAction(request);
|
|
575
625
|
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
576
626
|
}, request).then((answer) => {
|
package/dist/messages.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export type ConversationWrite = {
|
|
|
20
20
|
};
|
|
21
21
|
export declare function heldConversations(connection: Connection): HeldConversation[];
|
|
22
22
|
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
23
|
-
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null): MessageWindow;
|
|
24
|
-
export declare function messageCount(connection: Connection, conversation: string): number;
|
|
23
|
+
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
|
|
24
|
+
export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
|
|
25
25
|
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
26
26
|
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
27
27
|
export declare function forgottenMessages(connection: Connection): void;
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAE1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAM3C,CAAC;AAEF,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,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IAC9C,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3E,CAAC;AAMF,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,gBAAgB,EAAE,CAmB5E;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,iBAAiB,GAClD,IAAI,CA+BN;AAkBD,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,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;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAO/F;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAK9F;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAG9D"}
|
package/dist/messages.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sql } from '@agentshouse/mdmodel';
|
|
2
2
|
export const MESSAGE_TABLES = [
|
|
3
3
|
'CREATE TABLE conversation_reads (conversation TEXT PRIMARY KEY, read TEXT, partial INTEGER NOT NULL) WITHOUT ROWID',
|
|
4
4
|
'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)',
|
|
@@ -36,17 +36,12 @@ export function keptMessages(connection, { conversation, messages, read }) {
|
|
|
36
36
|
JSON.stringify(message.message ?? null),
|
|
37
37
|
message.text,
|
|
38
38
|
];
|
|
39
|
-
let id;
|
|
40
39
|
if (held === undefined) {
|
|
41
40
|
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, message, text) VALUES (?, ?, ?, ?, ?, ?)', [conversation, message.identity, ...record]);
|
|
42
|
-
id = Number(connection.rows('SELECT last_insert_rowid() AS id')[0].id);
|
|
43
41
|
}
|
|
44
42
|
else {
|
|
45
|
-
id =
|
|
46
|
-
unindexMessages(connection, [id]);
|
|
47
|
-
connection.run('UPDATE conversation_messages SET turn = ?, position = ?, message = ?, text = ? WHERE id = ?', [...record, id]);
|
|
43
|
+
connection.run('UPDATE conversation_messages SET turn = ?, position = ?, message = ?, text = ? WHERE id = ?', [...record, held.id]);
|
|
48
44
|
}
|
|
49
|
-
indexMessage(connection, id, message.text);
|
|
50
45
|
}
|
|
51
46
|
if (read !== undefined) {
|
|
52
47
|
connection.run('INSERT OR REPLACE INTO conversation_reads (conversation, read, partial) VALUES (?, ?, ?)', [conversation, read.at, read.partial ? 1 : 0]);
|
|
@@ -62,14 +57,21 @@ function accepted(row) {
|
|
|
62
57
|
message: JSON.parse(text(row.message)),
|
|
63
58
|
};
|
|
64
59
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
?
|
|
68
|
-
:
|
|
60
|
+
function holding(phrase) {
|
|
61
|
+
return phrase === null
|
|
62
|
+
? { sql: '', bind: [] }
|
|
63
|
+
: { sql: ` AND ${sql.HOLDS_PHRASE}(text, ?)`, bind: [phrase.toLowerCase()] };
|
|
64
|
+
}
|
|
65
|
+
export function messageWindow(connection, conversation, limit, before, phrase) {
|
|
66
|
+
const held = holding(phrase);
|
|
67
|
+
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
|
|
68
|
+
? [conversation, ...held.bind, limit + 1]
|
|
69
|
+
: [conversation, ...held.bind, before[0], before[0], before[1], limit + 1]);
|
|
69
70
|
return { messages: rows.slice(0, limit).map(accepted).reverse(), more: rows.length > limit };
|
|
70
71
|
}
|
|
71
|
-
export function messageCount(connection, conversation) {
|
|
72
|
-
const
|
|
72
|
+
export function messageCount(connection, conversation, phrase) {
|
|
73
|
+
const held = holding(phrase);
|
|
74
|
+
const [counted] = connection.rows(`SELECT count(*) AS held FROM conversation_messages WHERE conversation = ?${held.sql}`, [conversation, ...held.bind]);
|
|
73
75
|
return Number(counted?.held ?? 0);
|
|
74
76
|
}
|
|
75
77
|
export function turnArrived(connection, conversation, turn) {
|
|
@@ -77,9 +79,6 @@ export function turnArrived(connection, conversation, turn) {
|
|
|
77
79
|
}
|
|
78
80
|
export function droppedMessages(connection, conversations) {
|
|
79
81
|
for (const conversation of conversations) {
|
|
80
|
-
unindexMessages(connection, connection
|
|
81
|
-
.rows('SELECT id FROM conversation_messages WHERE conversation = ?', [conversation])
|
|
82
|
-
.map((row) => Number(row.id)));
|
|
83
82
|
connection.run('DELETE FROM conversation_messages WHERE conversation = ?', [conversation]);
|
|
84
83
|
connection.run('DELETE FROM conversation_reads WHERE conversation = ?', [conversation]);
|
|
85
84
|
}
|
package/dist/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Definition,
|
|
1
|
+
import type { Definition, VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { Open } from './open.js';
|
|
3
3
|
export type ModelIdentity = {
|
|
4
4
|
identity: string;
|
|
@@ -8,7 +8,7 @@ export type ModelSnapshot = ModelIdentity & {
|
|
|
8
8
|
schema: string | null;
|
|
9
9
|
revision: string | null;
|
|
10
10
|
};
|
|
11
|
-
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'>;
|
|
12
12
|
export type ModelResult = {
|
|
13
13
|
kind: 'model';
|
|
14
14
|
snapshot: ModelSnapshot;
|
|
@@ -20,8 +20,6 @@ export type MdType = Definition;
|
|
|
20
20
|
export type ModelState = {
|
|
21
21
|
status: 'unavailable';
|
|
22
22
|
reason: ModelUnavailableReason;
|
|
23
|
-
schema?: string | null;
|
|
24
|
-
revision?: string | null;
|
|
25
23
|
} | {
|
|
26
24
|
status: 'current' | 'cached';
|
|
27
25
|
snapshot: ModelSnapshot;
|
|
@@ -37,8 +35,6 @@ export type TypesResult = {
|
|
|
37
35
|
status: Open<'unavailable'>;
|
|
38
36
|
reason: ModelUnavailableReason;
|
|
39
37
|
types: null;
|
|
40
|
-
schema?: string | null;
|
|
41
|
-
revision?: string | null;
|
|
42
38
|
} | {
|
|
43
39
|
status: Open<'current' | 'cached'>;
|
|
44
40
|
identity: string;
|
|
@@ -59,5 +55,4 @@ export declare function modelTypes(state: ModelState): TypesResult;
|
|
|
59
55
|
export declare function storedModel(state: ModelState): StoredModel;
|
|
60
56
|
export declare function cached(state: ModelState): ModelState;
|
|
61
57
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
62
|
-
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
63
58
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG;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C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,aAAa,CAAC;IAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AACN,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC;CACpC,CAAC;AACF,eAAO,MAAM,QAAQ,EAAE,UAA8D,CAAC;AACtF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAGhG;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAczD;AACD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAI1D;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEpD;AACD,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAE5E"}
|
package/dist/model.js
CHANGED
|
@@ -29,6 +29,3 @@ export function cached(state) {
|
|
|
29
29
|
export function sameModel(left, right) {
|
|
30
30
|
return left.identity === right.identity && left.version === right.version;
|
|
31
31
|
}
|
|
32
|
-
export function referenceField(facts) {
|
|
33
|
-
return facts?.reference !== undefined || facts?.items?.reference !== undefined;
|
|
34
|
-
}
|
package/dist/observation.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export declare function rowsOf(result: QueryResult): readonly (QueryDocument | Q
|
|
|
27
27
|
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
28
|
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
29
29
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
30
|
-
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
31
|
-
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
30
|
+
export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
31
|
+
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
32
32
|
export type Digest = {
|
|
33
33
|
readonly pending: string;
|
|
34
34
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,IAAI,CAAC,CAAC;IACb,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACpD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC;IACpE,OAA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AAM,EAAE,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,IAAI,CA+BjF"}
|
package/dist/observation.js
CHANGED
|
@@ -98,6 +98,11 @@ export function opened(watch, keyed) {
|
|
|
98
98
|
}
|
|
99
99
|
handle = observed(message, () => stop(), keyed);
|
|
100
100
|
resolve(handle.observation);
|
|
101
|
+
}, (error) => {
|
|
102
|
+
if (handle !== undefined)
|
|
103
|
+
return;
|
|
104
|
+
stop();
|
|
105
|
+
reject(error);
|
|
101
106
|
});
|
|
102
107
|
}
|
|
103
108
|
catch (error) {
|
|
@@ -106,9 +111,9 @@ export function opened(watch, keyed) {
|
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
113
|
export function observing(watch) {
|
|
109
|
-
return (topic, ...input) => opened((deliver) => watch(topic, input, (message) => {
|
|
114
|
+
return (topic, ...input) => opened((deliver, fail) => watch(topic, input, (message) => {
|
|
110
115
|
deliver(structuredClone(message));
|
|
111
|
-
}), topic === 'query');
|
|
116
|
+
}, fail), topic === 'query');
|
|
112
117
|
}
|
|
113
118
|
export function hashed(text) {
|
|
114
119
|
let first = 0xdeadbeef;
|