@agentshouse/mdruntime 0.1.0-cefbc8bb8a1c0 → 0.1.0-cf1e7fdb9c600
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 +69 -49
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +5 -8
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +20 -21
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/client.d.ts +6 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +0 -1
- package/dist/collection.d.ts +2 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +1 -17
- package/dist/compile.d.ts +1 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +97 -281
- package/dist/connection.d.ts +5 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +816 -846
- 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 +15 -13
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +133 -142
- package/dist/durability.d.ts +0 -1
- 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 +14 -5
- package/dist/host.d.ts +3 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +12 -26
- package/dist/index.d.ts +9 -6
- 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 +9 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +132 -81
- 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 +1 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -12
- package/dist/observation.d.ts +2 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +7 -2
- package/dist/outcome.d.ts +0 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/query.d.ts +5 -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 +31 -44
- package/dist/react.d.ts +3 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +2 -15
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/refresh.d.ts +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +46 -6
- package/dist/replica.d.ts +2 -2
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +5 -5
- package/dist/room-draft.d.ts +2 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +65 -52
- package/dist/rows.d.ts +3 -19
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +36 -164
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/shared.d.ts +0 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -10
- package/dist/status.d.ts +0 -4
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +15 -19
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +40 -39
- package/dist/stored.d.ts +33 -6
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +87 -124
- package/dist/tables.d.ts +34 -33
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +21 -54
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +39 -97
- 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 +1 -4
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +1 -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/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -91
- 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
|
@@ -52,15 +52,16 @@ export function createMemoryAdapter(options = {}) {
|
|
|
52
52
|
const listeners = new Set();
|
|
53
53
|
const modeObservers = new Set();
|
|
54
54
|
const scripted = new Map();
|
|
55
|
-
const unsealed = new Map();
|
|
56
|
-
const sealed = new Set();
|
|
57
55
|
const sentTurns = new Map();
|
|
58
56
|
const historyPageSize = options.historyPageSize;
|
|
59
57
|
const attached = new Map();
|
|
60
58
|
const linked = new WeakMap();
|
|
61
|
-
|
|
59
|
+
const carried = new Map();
|
|
62
60
|
let expiring = [];
|
|
61
|
+
let openings = 0;
|
|
62
|
+
const declaredRooms = new Set();
|
|
63
63
|
let replicated = [];
|
|
64
|
+
let heldCursor = null;
|
|
64
65
|
let issued = 0;
|
|
65
66
|
function scriptConversations(entries) {
|
|
66
67
|
scripted.clear();
|
|
@@ -155,7 +156,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
155
156
|
...(folderRemovals.length === 0 ? {} : { folderRemovals }),
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
|
-
function advancement(room, from, at) {
|
|
159
|
+
function advancement(room, from, at, whole = false) {
|
|
159
160
|
const current = room.documents ?? {};
|
|
160
161
|
const previous = from.documents ?? {};
|
|
161
162
|
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
@@ -166,7 +167,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
166
167
|
const changed = Object.keys(current)
|
|
167
168
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
168
169
|
.sort();
|
|
169
|
-
const size = pageSize ?? changed.length;
|
|
170
|
+
const size = whole ? changed.length : (pageSize ?? changed.length);
|
|
170
171
|
const taken = changed.slice(at, at + size);
|
|
171
172
|
const next = at + taken.length;
|
|
172
173
|
const opening = at === 0;
|
|
@@ -198,6 +199,26 @@ export function createMemoryAdapter(options = {}) {
|
|
|
198
199
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
199
200
|
};
|
|
200
201
|
}
|
|
202
|
+
function carry(locator) {
|
|
203
|
+
const at = carried.get(locator);
|
|
204
|
+
const current = rooms.find((entry) => entry.locator === locator);
|
|
205
|
+
if (at === undefined || current === undefined || current.roomVersion === at)
|
|
206
|
+
return;
|
|
207
|
+
const from = served.get(locator)?.get(at);
|
|
208
|
+
carried.set(locator, current.roomVersion);
|
|
209
|
+
if (from === undefined)
|
|
210
|
+
return;
|
|
211
|
+
const page = advancement(current, from, 0, true);
|
|
212
|
+
for (const observer of observers) {
|
|
213
|
+
observer({
|
|
214
|
+
kind: 'room-change',
|
|
215
|
+
locator,
|
|
216
|
+
from: at,
|
|
217
|
+
roomVersion: current.roomVersion,
|
|
218
|
+
read: async () => page,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
201
222
|
function pageOf(conversation, after) {
|
|
202
223
|
const messages = conversation.messages ?? [];
|
|
203
224
|
const first = typeof after === 'string' ? messages.findIndex((message) => message.position > after) : 0;
|
|
@@ -212,16 +233,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
212
233
|
: {}),
|
|
213
234
|
};
|
|
214
235
|
}
|
|
215
|
-
function historiesOf(
|
|
216
|
-
const asked = input?.conversations;
|
|
217
|
-
if (!Array.isArray(asked))
|
|
218
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
236
|
+
function historiesOf(request) {
|
|
219
237
|
const histories = [];
|
|
220
|
-
for (const entry of
|
|
221
|
-
const conversation =
|
|
238
|
+
for (const entry of request.conversations) {
|
|
239
|
+
const conversation = scripted.get(entry.conversation);
|
|
222
240
|
if (conversation === undefined)
|
|
223
241
|
continue;
|
|
224
|
-
const outcome = conversation.outcomes?.
|
|
242
|
+
const outcome = conversation.outcomes?.history;
|
|
225
243
|
if (outcome !== undefined)
|
|
226
244
|
return outcome;
|
|
227
245
|
histories.push(pageOf(conversation, entry.after));
|
|
@@ -232,15 +250,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
232
250
|
function conversationAction(request) {
|
|
233
251
|
const name = request.name;
|
|
234
252
|
const input = (request.input ?? {});
|
|
235
|
-
if (name === '
|
|
236
|
-
return historiesOf(request.input);
|
|
237
|
-
if (name === 'conversation.create') {
|
|
253
|
+
if (name === 'conversations/create') {
|
|
238
254
|
issued += 1;
|
|
239
255
|
const conversation = `conversation-${issued}`;
|
|
240
256
|
scripted.set(conversation, { conversation });
|
|
241
|
-
return { kind: 'action', result: { conversation } };
|
|
257
|
+
return { kind: 'action', result: { conversation_id: conversation } };
|
|
242
258
|
}
|
|
243
|
-
const named = typeof input.
|
|
259
|
+
const named = typeof input.conversation_id === 'string' ? input.conversation_id : '';
|
|
244
260
|
const conversation = scripted.get(named);
|
|
245
261
|
if (conversation === undefined) {
|
|
246
262
|
return {
|
|
@@ -253,36 +269,28 @@ export function createMemoryAdapter(options = {}) {
|
|
|
253
269
|
const outcome = conversation.outcomes?.[name];
|
|
254
270
|
if (outcome !== undefined)
|
|
255
271
|
return outcome;
|
|
256
|
-
if (name === '
|
|
272
|
+
if (name === 'conversations/send') {
|
|
257
273
|
const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
|
|
258
274
|
const answered = operation === null ? undefined : sentTurns.get(operation);
|
|
259
275
|
if (answered !== undefined)
|
|
260
|
-
return { kind: 'action', result: {
|
|
276
|
+
return { kind: 'action', result: { message_id: answered } };
|
|
261
277
|
issued += 1;
|
|
262
278
|
const turn = `turn-${issued}`;
|
|
263
|
-
unsealed.set(turn, named);
|
|
264
279
|
if (operation !== null)
|
|
265
280
|
sentTurns.set(operation, turn);
|
|
266
|
-
return { kind: 'action', result: { turn } };
|
|
281
|
+
return { kind: 'action', result: { message_id: turn } };
|
|
267
282
|
}
|
|
268
|
-
if (name === '
|
|
269
|
-
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
270
|
-
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
271
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
272
|
-
}
|
|
273
|
-
unsealed.delete(turn);
|
|
274
|
-
return { kind: 'action', result: { turn, cancelled: true } };
|
|
275
|
-
}
|
|
276
|
-
if (name === 'conversation.delete')
|
|
283
|
+
if (name === 'conversations/delete')
|
|
277
284
|
scripted.delete(named);
|
|
278
|
-
return { kind: 'action', result: {
|
|
285
|
+
return { kind: 'action', result: { conversation_id: named } };
|
|
279
286
|
}
|
|
280
287
|
function announceList() {
|
|
281
288
|
const entries = [...scripted.values()].flatMap(({ conversation, listed, messages = [] }) => listed === undefined
|
|
282
289
|
? []
|
|
283
290
|
: [{ conversation, ...listed, newest: messages.at(-1)?.position ?? null }]);
|
|
284
|
-
for (const listener of listeners)
|
|
285
|
-
listener({ kind: 'list', entries });
|
|
291
|
+
for (const listener of listeners) {
|
|
292
|
+
listener({ kind: 'list', entries, whole: true, more: false, cursor: null });
|
|
293
|
+
}
|
|
286
294
|
}
|
|
287
295
|
function discovery() {
|
|
288
296
|
return {
|
|
@@ -294,9 +302,42 @@ export function createMemoryAdapter(options = {}) {
|
|
|
294
302
|
...(options.member === undefined ? {} : { member: options.member }),
|
|
295
303
|
};
|
|
296
304
|
}
|
|
305
|
+
function discovered() {
|
|
306
|
+
return resolveScript(scripts.discover, discovery, undefined).then((answer) => {
|
|
307
|
+
if (answer.kind === 'discovery')
|
|
308
|
+
for (const room of answer.rooms)
|
|
309
|
+
note(room.locator, room);
|
|
310
|
+
return answer;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function opened(notify) {
|
|
314
|
+
const opening = ++openings;
|
|
315
|
+
notify({ kind: 'opened' });
|
|
316
|
+
void discovered()
|
|
317
|
+
.catch(() => ({ kind: 'transport-uncertainty' }))
|
|
318
|
+
.then((answer) => {
|
|
319
|
+
if (opening !== openings)
|
|
320
|
+
return;
|
|
321
|
+
if (answer.kind !== 'discovery') {
|
|
322
|
+
openings += 1;
|
|
323
|
+
carried.clear();
|
|
324
|
+
const revoked = answer.kind === 'revoked-authorization';
|
|
325
|
+
notify({ kind: 'closed', revoked, lost: !revoked, authorityChanged: false });
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
declaredRooms.clear();
|
|
329
|
+
for (const room of answer.rooms)
|
|
330
|
+
declaredRooms.add(room.locator);
|
|
331
|
+
notify({ kind: 'discovered', discovery: answer });
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function emitAll(event) {
|
|
335
|
+
for (const observer of observers)
|
|
336
|
+
observer(event);
|
|
337
|
+
}
|
|
297
338
|
return {
|
|
298
|
-
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
299
339
|
...(options.roomTypes === undefined ? {} : { roomTypes: options.roomTypes }),
|
|
340
|
+
...(options.typedPaths === undefined ? {} : { typedPaths: options.typedPaths }),
|
|
300
341
|
setRooms(next) {
|
|
301
342
|
rooms = [...next];
|
|
302
343
|
retain(rooms);
|
|
@@ -305,33 +346,37 @@ export function createMemoryAdapter(options = {}) {
|
|
|
305
346
|
scriptConversations(next);
|
|
306
347
|
},
|
|
307
348
|
open() {
|
|
349
|
+
carried.clear();
|
|
308
350
|
announceList();
|
|
309
|
-
|
|
310
|
-
observer({ kind: 'opened' });
|
|
351
|
+
opened(emitAll);
|
|
311
352
|
},
|
|
312
|
-
close({ revoked = false, lost = !revoked } = {}) {
|
|
313
|
-
|
|
314
|
-
|
|
353
|
+
close({ revoked = false, lost = !revoked, authorityChanged = false } = {}) {
|
|
354
|
+
openings += 1;
|
|
355
|
+
carried.clear();
|
|
356
|
+
emitAll({ kind: 'closed', revoked, lost, authorityChanged });
|
|
315
357
|
},
|
|
316
358
|
expire(locators) {
|
|
317
359
|
expiring = [...locators];
|
|
318
360
|
},
|
|
319
|
-
notifyRoomVersion({ locator
|
|
320
|
-
|
|
321
|
-
observer({ kind: 'room-version', locator, roomVersion });
|
|
361
|
+
notifyRoomVersion({ locator }) {
|
|
362
|
+
carry(locator);
|
|
322
363
|
},
|
|
323
|
-
notifyAuthorityChanged(
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
364
|
+
notifyAuthorityChanged(locators) {
|
|
365
|
+
const named = new Set(locators ?? [...declaredRooms, ...rooms.map((room) => room.locator)]);
|
|
366
|
+
const listed = rooms.filter((room) => named.has(room.locator));
|
|
367
|
+
const left = [...named].filter((locator) => !listed.some((room) => room.locator === locator));
|
|
368
|
+
for (const room of listed)
|
|
369
|
+
declaredRooms.add(room.locator);
|
|
370
|
+
for (const locator of left)
|
|
371
|
+
declaredRooms.delete(locator);
|
|
372
|
+
emitAll({
|
|
373
|
+
kind: 'authority-changed',
|
|
374
|
+
rooms: listed.map(declared),
|
|
375
|
+
left,
|
|
376
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
377
|
+
});
|
|
329
378
|
},
|
|
330
379
|
notifyConversation(event) {
|
|
331
|
-
if (event.kind === 'accepted-message') {
|
|
332
|
-
sealed.add(event.message.turn);
|
|
333
|
-
unsealed.delete(event.message.turn);
|
|
334
|
-
}
|
|
335
380
|
for (const listener of listeners)
|
|
336
381
|
listener(event);
|
|
337
382
|
},
|
|
@@ -340,21 +385,31 @@ export function createMemoryAdapter(options = {}) {
|
|
|
340
385
|
observer(mode);
|
|
341
386
|
},
|
|
342
387
|
heldRooms() {
|
|
343
|
-
return
|
|
388
|
+
return [...carried.keys()].sort();
|
|
344
389
|
},
|
|
345
390
|
replicatedConversations() {
|
|
346
391
|
return replicated;
|
|
347
392
|
},
|
|
393
|
+
heldConversationCursor() {
|
|
394
|
+
return heldCursor;
|
|
395
|
+
},
|
|
348
396
|
conversations: {
|
|
349
397
|
replicate(next) {
|
|
350
398
|
replicated = [...next];
|
|
351
399
|
},
|
|
400
|
+
hold(cursor) {
|
|
401
|
+
heldCursor = cursor;
|
|
402
|
+
},
|
|
352
403
|
observe(notify) {
|
|
353
404
|
listeners.add(notify);
|
|
354
405
|
return () => {
|
|
355
406
|
listeners.delete(notify);
|
|
356
407
|
};
|
|
357
408
|
},
|
|
409
|
+
history: (request) => Promise.resolve(historiesOf(request)),
|
|
410
|
+
...(options.agents === undefined
|
|
411
|
+
? {}
|
|
412
|
+
: { agents: () => Promise.resolve(structuredClone(options.agents)) }),
|
|
358
413
|
},
|
|
359
414
|
serviceMode: {
|
|
360
415
|
observe(notify) {
|
|
@@ -366,44 +421,45 @@ export function createMemoryAdapter(options = {}) {
|
|
|
366
421
|
},
|
|
367
422
|
roomStream: {
|
|
368
423
|
hold(asked) {
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
expiring = [];
|
|
372
|
-
const moved = asked.flatMap((room) => {
|
|
424
|
+
const named = asked.map((room) => room.locator);
|
|
425
|
+
const unknown = asked.flatMap((room) => {
|
|
373
426
|
const current = rooms.find((entry) => entry.locator === room.locator);
|
|
374
427
|
return current === undefined ||
|
|
375
|
-
|
|
376
|
-
|
|
428
|
+
current.roomVersion === room.roomVersion ||
|
|
429
|
+
served.get(room.locator)?.has(room.roomVersion) === true
|
|
377
430
|
? []
|
|
378
|
-
: [
|
|
431
|
+
: [room.locator];
|
|
379
432
|
});
|
|
433
|
+
const expired = [
|
|
434
|
+
...new Set([...expiring.filter((locator) => named.includes(locator)), ...unknown]),
|
|
435
|
+
];
|
|
436
|
+
expiring = expiring.filter((locator) => !named.includes(locator));
|
|
380
437
|
queueMicrotask(() => {
|
|
381
|
-
for (const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
438
|
+
for (const room of asked) {
|
|
439
|
+
if (expired.includes(room.locator))
|
|
440
|
+
carried.delete(room.locator);
|
|
441
|
+
else {
|
|
442
|
+
carried.set(room.locator, room.roomVersion);
|
|
443
|
+
carry(room.locator);
|
|
444
|
+
}
|
|
385
445
|
}
|
|
446
|
+
emitAll({ kind: 'caught-up', expired });
|
|
386
447
|
});
|
|
387
448
|
},
|
|
388
|
-
reopen() {
|
|
389
|
-
queueMicrotask(() => {
|
|
390
|
-
for (const observer of observers) {
|
|
391
|
-
observer({ kind: 'closed', revoked: false, lost: false });
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
},
|
|
395
|
-
published() { },
|
|
396
449
|
observe(notify) {
|
|
397
450
|
observers.add(notify);
|
|
398
451
|
queueMicrotask(() => {
|
|
399
452
|
if (!observers.has(notify))
|
|
400
453
|
return;
|
|
401
454
|
if (options.unopened === true) {
|
|
402
|
-
notify({ kind: 'closed', revoked: false, lost: true });
|
|
455
|
+
notify({ kind: 'closed', revoked: false, lost: true, authorityChanged: false });
|
|
403
456
|
return;
|
|
404
457
|
}
|
|
405
458
|
announceList();
|
|
406
|
-
|
|
459
|
+
opened((event) => {
|
|
460
|
+
if (observers.has(notify))
|
|
461
|
+
notify(event);
|
|
462
|
+
});
|
|
407
463
|
});
|
|
408
464
|
return () => {
|
|
409
465
|
observers.delete(notify);
|
|
@@ -420,12 +476,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
420
476
|
return resolveScript(scripts.authorize, () => ({}), undefined);
|
|
421
477
|
},
|
|
422
478
|
async discover(_authorization) {
|
|
423
|
-
return
|
|
424
|
-
if (answer.kind === 'discovery')
|
|
425
|
-
for (const room of answer.rooms)
|
|
426
|
-
note(room.locator, room);
|
|
427
|
-
return answer;
|
|
428
|
-
});
|
|
479
|
+
return discovered();
|
|
429
480
|
},
|
|
430
481
|
reached,
|
|
431
482
|
follows(locator, roomVersion, next) {
|
|
@@ -539,7 +590,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
539
590
|
},
|
|
540
591
|
async action(_authorization, request) {
|
|
541
592
|
return resolveScript(scripts.action, () => {
|
|
542
|
-
if (request.name.startsWith('
|
|
593
|
+
if (request.name.startsWith('conversations/'))
|
|
543
594
|
return conversationAction(request);
|
|
544
595
|
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
545
596
|
}, 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;IAC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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;
|
|
@@ -59,6 +59,4 @@ export declare function modelTypes(state: ModelState): TypesResult;
|
|
|
59
59
|
export declare function storedModel(state: ModelState): StoredModel;
|
|
60
60
|
export declare function cached(state: ModelState): ModelState;
|
|
61
61
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
62
|
-
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
63
|
-
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
64
62
|
//# 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;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAC/F,MAAM,MAAM,s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;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,15 +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 sameTyping(left, right) {
|
|
33
|
-
if (left === right)
|
|
34
|
-
return true;
|
|
35
|
-
if (left.status === 'unavailable' || right.status === 'unavailable') {
|
|
36
|
-
return left.status === right.status;
|
|
37
|
-
}
|
|
38
|
-
return (left.snapshot.schema === right.snapshot.schema &&
|
|
39
|
-
sameModel(left.verifiedWith, right.verifiedWith));
|
|
40
|
-
}
|
|
41
|
-
export function referenceField(facts) {
|
|
42
|
-
return facts?.reference !== undefined || facts?.items?.reference !== undefined;
|
|
43
|
-
}
|
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;IA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C;AAMD,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,WAAW,GAAG,MAAM,CAU9D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAY3E;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,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;
|
package/dist/outcome.d.ts
CHANGED
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE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