@agentshouse/mdruntime 0.1.0-ca14c49c06d90 → 0.1.0-ca4dc698bd0c4
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/AGENTS.md +260 -259
- package/dist/acquisition.d.ts +14 -0
- package/dist/acquisition.d.ts.map +1 -0
- package/dist/acquisition.js +24 -0
- package/dist/adapter.d.ts +6 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/change-set.d.ts +2 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +34 -9
- package/dist/client.d.ts +8 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -0
- package/dist/collection.d.ts +17 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +230 -19
- package/dist/connection.d.ts +20 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +926 -175
- package/dist/conversation.d.ts +8 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +128 -83
- package/dist/durability.d.ts +7 -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 +3 -3
- package/dist/host.d.ts +11 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +33 -3
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +6 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/memory.d.ts +2 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +7 -2
- package/dist/model.d.ts +1 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +9 -0
- package/dist/observation.d.ts +5 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +22 -11
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +25 -54
- package/dist/query.d.ts +28 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts +6 -2
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +16 -4
- package/dist/react.d.ts +5 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/read-side.d.ts +13 -6
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +282 -83
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +197 -0
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +11 -10
- package/dist/replica.d.ts +1 -1
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +47 -19
- package/dist/rows.d.ts +4 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +2 -12
- package/dist/save.d.ts +5 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +36 -13
- package/dist/search.d.ts +28 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +108 -45
- package/dist/shared.d.ts +11 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +368 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +18 -3
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +147 -49
- package/dist/turn.d.ts +7 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +45 -0
- package/dist/wire.d.ts +2 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -0
- package/package.json +2 -2
package/dist/conversation.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import { type ChangeSet } from './change-set.js';
|
|
|
3
3
|
import { type ChatDraftFile } from './file.js';
|
|
4
4
|
import type { Open } from './open.js';
|
|
5
5
|
import { type CallResult, type Offline } from './outcome.js';
|
|
6
|
-
import type { DocumentResult } from './query.js';
|
|
7
|
-
import type { SearchedMessage } from './search.js';
|
|
6
|
+
import type { DocumentResult, PendingResult } from './query.js';
|
|
8
7
|
import type { CycleProgress } from './status.js';
|
|
9
8
|
import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
|
|
10
9
|
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
@@ -69,13 +68,15 @@ export type ChatDraftSurface = {
|
|
|
69
68
|
};
|
|
70
69
|
export type ConversationDependencies = {
|
|
71
70
|
agents(): ConversationAgents | undefined;
|
|
72
|
-
documents(
|
|
71
|
+
documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
|
|
73
72
|
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
74
73
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
75
74
|
stream(): ConversationStream | undefined;
|
|
76
75
|
publish(set: ChangeSet): void;
|
|
77
76
|
online(): boolean;
|
|
78
77
|
closed(): boolean;
|
|
78
|
+
unanswered(): void;
|
|
79
|
+
expired(operation: string): boolean;
|
|
79
80
|
};
|
|
80
81
|
export type ConversationStore = {
|
|
81
82
|
surface: ConversationSurface;
|
|
@@ -85,14 +86,16 @@ export type ConversationStore = {
|
|
|
85
86
|
catchUp(progress: CycleProgress): Promise<void>;
|
|
86
87
|
resend(progress: CycleProgress): Promise<void>;
|
|
87
88
|
current(): boolean;
|
|
89
|
+
known(): boolean;
|
|
88
90
|
reconnected(): void;
|
|
91
|
+
reopened(): void;
|
|
89
92
|
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
90
93
|
watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
|
|
91
94
|
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
92
95
|
changed(set: ChangeSet): void;
|
|
93
96
|
receive(event: ConversationEvent): boolean;
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
searchable(): readonly string[];
|
|
98
|
+
acquired(conversation: string): boolean;
|
|
96
99
|
close(): void;
|
|
97
100
|
};
|
|
98
101
|
export declare function unheldView(conversation: string): ConversationView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAEjB,mBAAmB,EACnB,kBAAkB,EAElB,cAAc,EACd,aAAa,EACb,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAE5F,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAEjB,mBAAmB,EACnB,kBAAkB,EAElB,cAAc,EACd,aAAa,EACb,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAE5F,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAkB,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAElG,MAAM,MAAM,iBAA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AAI,CAAC;IACjB,KAAK,CACH,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GACxC,MAAM,IAAI,CAAC;IACd,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChF,WAAW,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACjF,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC3C,UAAU,IAAI,SAAS,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;IACxC,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAuBF,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAWjE;AAED,eAAO,MAAM,eAAe,oBAAoB,CAAC;AA8LjD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CA+sBzF"}
|
package/dist/conversation.js
CHANGED
|
@@ -79,11 +79,15 @@ function ordered(left, right) {
|
|
|
79
79
|
return left.identity < right.identity ? -1 : 1;
|
|
80
80
|
return 0;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function windowOf(held, arriving, limit) {
|
|
83
83
|
const byIdentity = new Map(held.map((message) => [message.identity, message]));
|
|
84
84
|
for (const message of arriving)
|
|
85
85
|
byIdentity.set(message.identity, message);
|
|
86
|
-
|
|
86
|
+
const next = [...byIdentity.values()].sort(ordered);
|
|
87
|
+
return limit === undefined ? next : next.slice(Math.max(0, next.length - limit));
|
|
88
|
+
}
|
|
89
|
+
function newestOf(arriving, from) {
|
|
90
|
+
return arriving.reduce((top, message) => (top === null || message.position > top ? message.position : top), from);
|
|
87
91
|
}
|
|
88
92
|
function acceptedMessage(value) {
|
|
89
93
|
if (typeof value !== 'object' || value === null)
|
|
@@ -160,6 +164,7 @@ function limitOf(options) {
|
|
|
160
164
|
}
|
|
161
165
|
return limit;
|
|
162
166
|
}
|
|
167
|
+
const EXPIRED = { kind: 'rejected', code: 'expired', fields: {}, retryable: false };
|
|
163
168
|
function unwritten(draft) {
|
|
164
169
|
return draft.text === '' && draft.files.length === 0;
|
|
165
170
|
}
|
|
@@ -179,10 +184,11 @@ function returned(draft, submission, others) {
|
|
|
179
184
|
}, others);
|
|
180
185
|
}
|
|
181
186
|
export function createConversationStore(deps) {
|
|
182
|
-
const
|
|
187
|
+
const stored = new Set();
|
|
183
188
|
const reads = new Map();
|
|
189
|
+
const partials = new Set();
|
|
184
190
|
const drafts = new Map();
|
|
185
|
-
const sending = new
|
|
191
|
+
const sending = new Map();
|
|
186
192
|
const behind = new Set();
|
|
187
193
|
const gaps = new Map();
|
|
188
194
|
const lives = new Map();
|
|
@@ -199,22 +205,17 @@ export function createConversationStore(deps) {
|
|
|
199
205
|
function liveOf(conversation) {
|
|
200
206
|
return lives.get(conversation) ?? QUIET;
|
|
201
207
|
}
|
|
202
|
-
function
|
|
203
|
-
const held = messages.get(conversation) ?? [];
|
|
204
|
-
const shown = limit === undefined ? held : held.slice(Math.max(0, held.length - limit));
|
|
205
|
-
return shown.map(({ identity, turn, text, message }) => ({
|
|
206
|
-
identity,
|
|
207
|
-
turn,
|
|
208
|
-
text,
|
|
209
|
-
message: structuredClone(message),
|
|
210
|
-
}));
|
|
211
|
-
}
|
|
212
|
-
function viewOf(conversation, limit, shown = shownMessages(conversation, limit)) {
|
|
208
|
+
function viewOf(conversation, held) {
|
|
213
209
|
const draft = drafts.get(conversation);
|
|
214
210
|
const facts = liveOf(conversation);
|
|
215
211
|
return {
|
|
216
212
|
conversation,
|
|
217
|
-
messages:
|
|
213
|
+
messages: held.map(({ identity, turn, text, message }) => ({
|
|
214
|
+
identity,
|
|
215
|
+
turn,
|
|
216
|
+
text,
|
|
217
|
+
message,
|
|
218
|
+
})),
|
|
218
219
|
turn: structuredClone(facts.turn),
|
|
219
220
|
questions: structuredClone(facts.questions),
|
|
220
221
|
process: facts.process === null ? null : { ...facts.process },
|
|
@@ -225,23 +226,30 @@ export function createConversationStore(deps) {
|
|
|
225
226
|
: { text: draft.text, files: [...draft.files], revision: draft.revision },
|
|
226
227
|
};
|
|
227
228
|
}
|
|
228
|
-
function emit(conversation
|
|
229
|
+
function emit(conversation) {
|
|
229
230
|
if (deps.closed())
|
|
230
231
|
return;
|
|
231
232
|
for (const view of views.values()) {
|
|
232
|
-
if (view.conversation !== conversation)
|
|
233
|
+
if (view.conversation !== conversation || view.window === null)
|
|
233
234
|
continue;
|
|
234
|
-
if (messagesChanged)
|
|
235
|
-
view.messages = null;
|
|
236
235
|
const ready = [...view.watchers].filter((watcher) => watcher.ready);
|
|
237
236
|
if (ready.length === 0)
|
|
238
237
|
continue;
|
|
239
|
-
|
|
240
|
-
const value = viewOf(conversation, view.limit, view.messages);
|
|
238
|
+
const value = viewOf(conversation, view.window);
|
|
241
239
|
for (const watcher of ready)
|
|
242
240
|
watcher.notify(value);
|
|
243
241
|
}
|
|
244
242
|
}
|
|
243
|
+
function slide(conversation, arriving) {
|
|
244
|
+
for (const view of views.values()) {
|
|
245
|
+
if (view.conversation !== conversation || view.window === null)
|
|
246
|
+
continue;
|
|
247
|
+
view.window = arriving === null ? [] : windowOf(view.window, arriving, view.limit);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function changesOf(conversation, arriving) {
|
|
251
|
+
return arriving.map(({ identity, text }) => ({ conversation, identity, text }));
|
|
252
|
+
}
|
|
245
253
|
function stateOf(conversation) {
|
|
246
254
|
const facts = liveOf(conversation);
|
|
247
255
|
if (facts.questions.length > 0)
|
|
@@ -298,7 +306,10 @@ export function createConversationStore(deps) {
|
|
|
298
306
|
const declaration = deps.agents();
|
|
299
307
|
if (declaration === undefined)
|
|
300
308
|
return;
|
|
301
|
-
const
|
|
309
|
+
const held = await deps.documents(declaration);
|
|
310
|
+
if ('pending' in held)
|
|
311
|
+
return;
|
|
312
|
+
const { documents } = held;
|
|
302
313
|
const names = new Map();
|
|
303
314
|
const retired = new Set();
|
|
304
315
|
for (const document of documents) {
|
|
@@ -330,7 +341,7 @@ export function createConversationStore(deps) {
|
|
|
330
341
|
}
|
|
331
342
|
function live(conversation, change) {
|
|
332
343
|
setLive(conversation, { ...liveOf(conversation), ...change });
|
|
333
|
-
emit(conversation
|
|
344
|
+
emit(conversation);
|
|
334
345
|
}
|
|
335
346
|
function relayed(conversation, turn, operation) {
|
|
336
347
|
const held = liveOf(conversation).turn;
|
|
@@ -358,21 +369,25 @@ export function createConversationStore(deps) {
|
|
|
358
369
|
}
|
|
359
370
|
async function remove(leaving) {
|
|
360
371
|
await deps.durably(async (local) => {
|
|
361
|
-
await local.dropConversations(leaving);
|
|
362
372
|
const removed = [];
|
|
363
|
-
const changed = [];
|
|
364
373
|
for (const conversation of leaving) {
|
|
365
|
-
for (const
|
|
366
|
-
removed.push({ conversation, identity:
|
|
374
|
+
for (const identity of await local.messageIdentities(conversation)) {
|
|
375
|
+
removed.push({ conversation, identity, text: null });
|
|
367
376
|
}
|
|
368
|
-
|
|
377
|
+
}
|
|
378
|
+
await local.dropConversations(leaving);
|
|
379
|
+
const changed = [];
|
|
380
|
+
for (const conversation of leaving) {
|
|
381
|
+
if (stored.has(conversation) || drafts.has(conversation) || lives.has(conversation)) {
|
|
369
382
|
changed.push(conversation);
|
|
370
383
|
}
|
|
371
|
-
|
|
384
|
+
stored.delete(conversation);
|
|
372
385
|
reads.delete(conversation);
|
|
386
|
+
partials.delete(conversation);
|
|
373
387
|
drafts.delete(conversation);
|
|
374
388
|
behind.delete(conversation);
|
|
375
389
|
setLive(conversation, null);
|
|
390
|
+
slide(conversation, null);
|
|
376
391
|
}
|
|
377
392
|
if (changed.length > 0)
|
|
378
393
|
deps.publish(conversationChangeSet(removed, changed));
|
|
@@ -394,23 +409,21 @@ export function createConversationStore(deps) {
|
|
|
394
409
|
await local.keepMessages({
|
|
395
410
|
conversation,
|
|
396
411
|
messages: [message],
|
|
397
|
-
...(advances ? { read: message.position } : {}),
|
|
412
|
+
...(advances ? { read: { at: message.position, partial: false } } : {}),
|
|
398
413
|
});
|
|
399
|
-
|
|
414
|
+
stored.add(conversation);
|
|
400
415
|
if (advances)
|
|
401
416
|
reads.set(conversation, message.position);
|
|
402
417
|
sealTurns(conversation, new Set([message.turn]));
|
|
403
|
-
|
|
418
|
+
slide(conversation, [message]);
|
|
419
|
+
deps.publish(conversationChangeSet(changesOf(conversation, [message]), [conversation]));
|
|
404
420
|
});
|
|
405
421
|
}
|
|
406
422
|
async function readHistories(conversations) {
|
|
407
423
|
const generations = new Map(conversations.map((one) => [one, gaps.get(one) ?? 0]));
|
|
408
|
-
const starts = new Map(conversations.map((one) => [one, reads.get(one)]));
|
|
409
|
-
const arriving = new Map();
|
|
410
|
-
const complete = new Set();
|
|
411
424
|
let asking = conversations.map((conversation) => ({
|
|
412
425
|
conversation,
|
|
413
|
-
after:
|
|
426
|
+
after: reads.get(conversation) ?? undefined,
|
|
414
427
|
}));
|
|
415
428
|
while (asking.length > 0) {
|
|
416
429
|
const result = await deps.call('conversation.history', {
|
|
@@ -422,43 +435,41 @@ export function createConversationStore(deps) {
|
|
|
422
435
|
const pages = historyPages(result);
|
|
423
436
|
if (pages === null)
|
|
424
437
|
return result;
|
|
425
|
-
const asked = new
|
|
438
|
+
const asked = new Map(asking.map(({ conversation, after }) => [conversation, after]));
|
|
426
439
|
const following = [];
|
|
427
440
|
for (const page of pages) {
|
|
428
441
|
if (!asked.has(page.conversation))
|
|
429
442
|
continue;
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
...page.messages,
|
|
433
|
-
]);
|
|
434
|
-
if (page.next === undefined)
|
|
435
|
-
complete.add(page.conversation);
|
|
436
|
-
else
|
|
443
|
+
await keepPage(page.conversation, page.messages, asked.get(page.conversation) ?? null, page.next, generations.get(page.conversation) ?? 0);
|
|
444
|
+
if (page.next !== undefined) {
|
|
437
445
|
following.push({ conversation: page.conversation, after: page.next });
|
|
446
|
+
}
|
|
438
447
|
}
|
|
439
448
|
asking = following;
|
|
440
449
|
}
|
|
441
|
-
for (const [conversation, held] of arriving) {
|
|
442
|
-
if (!complete.has(conversation))
|
|
443
|
-
continue;
|
|
444
|
-
await keepHistory(conversation, held, starts.get(conversation), generations.get(conversation) ?? 0);
|
|
445
|
-
}
|
|
446
450
|
return null;
|
|
447
451
|
}
|
|
448
|
-
function
|
|
452
|
+
function keepPage(conversation, arriving, from, next, generation) {
|
|
449
453
|
return deps.durably(async (local) => {
|
|
450
454
|
if (!replicated.has(conversation))
|
|
451
455
|
return;
|
|
452
|
-
const
|
|
456
|
+
const whole = next === undefined;
|
|
457
|
+
const cursor = next ?? newestOf(arriving, from);
|
|
458
|
+
const partial = !whole && (partials.has(conversation) || !reads.has(conversation));
|
|
453
459
|
const sealing = await sealed(local, conversation, new Set(arriving.map((message) => message.turn)));
|
|
454
|
-
await local.keepMessages({ conversation, messages: arriving, read:
|
|
455
|
-
|
|
456
|
-
reads.set(conversation,
|
|
460
|
+
await local.keepMessages({ conversation, messages: arriving, read: { at: cursor, partial } });
|
|
461
|
+
stored.add(conversation);
|
|
462
|
+
reads.set(conversation, cursor);
|
|
463
|
+
if (partial)
|
|
464
|
+
partials.add(conversation);
|
|
465
|
+
else
|
|
466
|
+
partials.delete(conversation);
|
|
457
467
|
sealTurns(conversation, new Set(arriving.map((message) => message.turn)));
|
|
458
|
-
if ((gaps.get(conversation) ?? 0) === generation)
|
|
468
|
+
if (whole && (gaps.get(conversation) ?? 0) === generation)
|
|
459
469
|
behind.delete(conversation);
|
|
460
|
-
|
|
461
|
-
|
|
470
|
+
slide(conversation, arriving);
|
|
471
|
+
if (arriving.length > 0 || sealing || whole) {
|
|
472
|
+
deps.publish(conversationChangeSet(changesOf(conversation, arriving), [conversation]));
|
|
462
473
|
}
|
|
463
474
|
});
|
|
464
475
|
}
|
|
@@ -471,7 +482,7 @@ export function createConversationStore(deps) {
|
|
|
471
482
|
if (held === undefined)
|
|
472
483
|
return;
|
|
473
484
|
setLive(conversation, { ...QUIET, turn: held.turn });
|
|
474
|
-
emit(conversation
|
|
485
|
+
emit(conversation);
|
|
475
486
|
return;
|
|
476
487
|
}
|
|
477
488
|
if (event.kind === 'turn') {
|
|
@@ -525,7 +536,7 @@ export function createConversationStore(deps) {
|
|
|
525
536
|
}
|
|
526
537
|
function withDraft(conversation, next) {
|
|
527
538
|
return deps.durably(async (local) => {
|
|
528
|
-
const following = next(drafts.get(conversation));
|
|
539
|
+
const following = await next(drafts.get(conversation), local);
|
|
529
540
|
if (following === undefined)
|
|
530
541
|
return;
|
|
531
542
|
await kept(local, conversation, following);
|
|
@@ -534,8 +545,10 @@ export function createConversationStore(deps) {
|
|
|
534
545
|
}
|
|
535
546
|
async function submitted(conversation, operation, draft) {
|
|
536
547
|
let submission;
|
|
548
|
+
let earlier = false;
|
|
537
549
|
await withDraft(conversation, (current) => {
|
|
538
550
|
submission = current?.submitted?.find((one) => one.operation === operation);
|
|
551
|
+
earlier = submission !== undefined;
|
|
539
552
|
if (submission !== undefined)
|
|
540
553
|
return undefined;
|
|
541
554
|
const said = draft ?? current;
|
|
@@ -553,10 +566,19 @@ export function createConversationStore(deps) {
|
|
|
553
566
|
submitted: [...(current?.submitted ?? []), submission],
|
|
554
567
|
};
|
|
555
568
|
});
|
|
556
|
-
return submission;
|
|
569
|
+
return { submission: submission, earlier };
|
|
570
|
+
}
|
|
571
|
+
function forgotten(conversation, submission) {
|
|
572
|
+
return withDraft(conversation, (current) => {
|
|
573
|
+
const held = current?.submitted ?? [];
|
|
574
|
+
if (current === undefined || !held.includes(submission))
|
|
575
|
+
return undefined;
|
|
576
|
+
return withSubmitted(current, held.filter((one) => one !== submission));
|
|
577
|
+
});
|
|
557
578
|
}
|
|
558
579
|
async function dispatched(conversation, submission) {
|
|
559
|
-
|
|
580
|
+
const dispatch = {};
|
|
581
|
+
sending.set(submission.operation, dispatch);
|
|
560
582
|
try {
|
|
561
583
|
const files = await Promise.all(submission.files.map(async (file) => ({ ...(await declaredFile(file)), blob: file.blob })));
|
|
562
584
|
const result = await invoke('conversation.send', conversation, {
|
|
@@ -566,17 +588,19 @@ export function createConversationStore(deps) {
|
|
|
566
588
|
});
|
|
567
589
|
if (result.kind === 'revoked-authorization')
|
|
568
590
|
return result;
|
|
569
|
-
if (result.kind !== 'action' && result.retryable)
|
|
591
|
+
if (result.kind !== 'action' && result.retryable) {
|
|
592
|
+
deps.unanswered();
|
|
570
593
|
return result;
|
|
594
|
+
}
|
|
571
595
|
const turn = turnOf(result);
|
|
572
|
-
await withDraft(conversation, (current) => {
|
|
596
|
+
await withDraft(conversation, async (current, local) => {
|
|
573
597
|
const held = current?.submitted?.find((one) => one.operation === submission.operation);
|
|
574
598
|
if (current === undefined || held === undefined || held.turn !== null)
|
|
575
599
|
return undefined;
|
|
576
600
|
const others = current.submitted.filter((one) => one !== held);
|
|
577
601
|
if (result.kind !== 'action')
|
|
578
602
|
return returned(current, held, others);
|
|
579
|
-
const arrived =
|
|
603
|
+
const arrived = turn !== null && (await local.turnArrived(conversation, turn));
|
|
580
604
|
return withSubmitted(current, turn === null || arrived
|
|
581
605
|
? others
|
|
582
606
|
: current.submitted.map((one) => (one === held ? { ...held, turn } : one)));
|
|
@@ -584,7 +608,8 @@ export function createConversationStore(deps) {
|
|
|
584
608
|
return result;
|
|
585
609
|
}
|
|
586
610
|
finally {
|
|
587
|
-
sending.
|
|
611
|
+
if (sending.get(submission.operation) === dispatch)
|
|
612
|
+
sending.delete(submission.operation);
|
|
588
613
|
}
|
|
589
614
|
}
|
|
590
615
|
function invoke(name, conversation, extra = {}) {
|
|
@@ -597,14 +622,18 @@ export function createConversationStore(deps) {
|
|
|
597
622
|
},
|
|
598
623
|
async read(conversation, options = {}) {
|
|
599
624
|
const limit = limitOf(options);
|
|
600
|
-
return deps.durably(() =>
|
|
625
|
+
return deps.durably(async (local) => structuredClone(viewOf(conversation, await local.messageWindow(conversation, limit))));
|
|
601
626
|
},
|
|
602
627
|
create(input) {
|
|
603
628
|
return deps.call('conversation.create', input);
|
|
604
629
|
},
|
|
605
630
|
async send(conversation, operation = changeBatchIdentity(), draft) {
|
|
606
631
|
if (deps.online()) {
|
|
607
|
-
|
|
632
|
+
const { submission, earlier } = await submitted(conversation, operation, draft);
|
|
633
|
+
if (!earlier || !deps.expired(operation))
|
|
634
|
+
return dispatched(conversation, submission);
|
|
635
|
+
await forgotten(conversation, submission);
|
|
636
|
+
return EXPIRED;
|
|
608
637
|
}
|
|
609
638
|
if (draft !== undefined) {
|
|
610
639
|
await withDraft(conversation, (current) => current?.submitted?.some((one) => one.operation === operation) === true
|
|
@@ -663,18 +692,19 @@ export function createConversationStore(deps) {
|
|
|
663
692
|
return {
|
|
664
693
|
surface,
|
|
665
694
|
chatDraft,
|
|
666
|
-
hydrate(held,
|
|
667
|
-
|
|
695
|
+
hydrate(held, kept) {
|
|
696
|
+
stored.clear();
|
|
668
697
|
reads.clear();
|
|
669
|
-
|
|
670
|
-
view.messages = null;
|
|
698
|
+
partials.clear();
|
|
671
699
|
for (const entry of held) {
|
|
672
|
-
|
|
700
|
+
stored.add(entry.conversation);
|
|
673
701
|
if (entry.read !== undefined)
|
|
674
702
|
reads.set(entry.conversation, entry.read);
|
|
703
|
+
if (entry.partial)
|
|
704
|
+
partials.add(entry.conversation);
|
|
675
705
|
}
|
|
676
706
|
drafts.clear();
|
|
677
|
-
for (const record of
|
|
707
|
+
for (const record of kept)
|
|
678
708
|
drafts.set(record.conversation, record);
|
|
679
709
|
},
|
|
680
710
|
async reconcile() {
|
|
@@ -682,7 +712,7 @@ export function createConversationStore(deps) {
|
|
|
682
712
|
return;
|
|
683
713
|
const named = new Set(listing.keys());
|
|
684
714
|
const leaving = [
|
|
685
|
-
...new Set([...replicated, ...
|
|
715
|
+
...new Set([...replicated, ...stored, ...reads.keys(), ...drafts.keys()]),
|
|
686
716
|
].filter((conversation) => !named.has(conversation));
|
|
687
717
|
for (const conversation of named) {
|
|
688
718
|
if (!replicated.has(conversation))
|
|
@@ -710,6 +740,10 @@ export function createConversationStore(deps) {
|
|
|
710
740
|
continue;
|
|
711
741
|
if (deps.closed())
|
|
712
742
|
return;
|
|
743
|
+
if (deps.expired(submission.operation)) {
|
|
744
|
+
await forgotten(conversation, submission);
|
|
745
|
+
continue;
|
|
746
|
+
}
|
|
713
747
|
const result = await dispatched(conversation, submission);
|
|
714
748
|
if (result.kind === 'revoked-authorization')
|
|
715
749
|
return;
|
|
@@ -717,16 +751,26 @@ export function createConversationStore(deps) {
|
|
|
717
751
|
progress.reachable = false;
|
|
718
752
|
return;
|
|
719
753
|
}
|
|
754
|
+
if (result.kind !== 'action' && result.retryable) {
|
|
755
|
+
progress.complete = false;
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
720
758
|
}
|
|
721
759
|
}
|
|
722
760
|
},
|
|
723
761
|
current() {
|
|
724
762
|
return behind.size === 0;
|
|
725
763
|
},
|
|
764
|
+
known() {
|
|
765
|
+
return listKnown;
|
|
766
|
+
},
|
|
726
767
|
reconnected() {
|
|
727
768
|
for (const conversation of replicated)
|
|
728
769
|
gap(conversation);
|
|
729
770
|
},
|
|
771
|
+
reopened() {
|
|
772
|
+
sending.clear();
|
|
773
|
+
},
|
|
730
774
|
watch(conversation, options, deliver) {
|
|
731
775
|
const limit = limitOf(options);
|
|
732
776
|
const key = JSON.stringify([conversation, limit ?? null]);
|
|
@@ -734,18 +778,20 @@ export function createConversationStore(deps) {
|
|
|
734
778
|
conversation,
|
|
735
779
|
limit,
|
|
736
780
|
watchers: new Set(),
|
|
737
|
-
|
|
781
|
+
window: null,
|
|
738
782
|
};
|
|
739
783
|
views.set(key, view);
|
|
740
784
|
const watcher = { notify: deliver, ready: false };
|
|
741
785
|
view.watchers.add(watcher);
|
|
742
786
|
void deps
|
|
743
|
-
.durably(() =>
|
|
787
|
+
.durably(async (local) => {
|
|
788
|
+
view.window ??= await local.messageWindow(conversation, limit);
|
|
789
|
+
})
|
|
744
790
|
.then(() => {
|
|
745
791
|
if (deps.closed() || !view.watchers.has(watcher))
|
|
746
792
|
return;
|
|
747
793
|
watcher.ready = true;
|
|
748
|
-
watcher.notify(viewOf(conversation,
|
|
794
|
+
watcher.notify(viewOf(conversation, view.window ?? []));
|
|
749
795
|
})
|
|
750
796
|
.catch(() => { });
|
|
751
797
|
return () => {
|
|
@@ -811,12 +857,11 @@ export function createConversationStore(deps) {
|
|
|
811
857
|
heard(event);
|
|
812
858
|
return false;
|
|
813
859
|
},
|
|
814
|
-
|
|
815
|
-
return [...
|
|
860
|
+
searchable() {
|
|
861
|
+
return [...(listKnown ? listing.keys() : stored)].sort();
|
|
816
862
|
},
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
return held === undefined ? null : { conversation, identity, text: held.text };
|
|
863
|
+
acquired(conversation) {
|
|
864
|
+
return reads.has(conversation) && !partials.has(conversation);
|
|
820
865
|
},
|
|
821
866
|
close() {
|
|
822
867
|
views.clear();
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { Persistence } from './readiness.js';
|
|
2
|
+
export type StorageEstimate = {
|
|
3
|
+
readonly usage: number;
|
|
4
|
+
readonly quota: number;
|
|
5
|
+
};
|
|
1
6
|
export type RuntimeShell = {
|
|
2
|
-
|
|
7
|
+
persistence: Persistence;
|
|
3
8
|
generation: string | null;
|
|
4
9
|
keepGeneration(value: string): void | Promise<void>;
|
|
5
10
|
dropGeneration(): void | Promise<void>;
|
|
11
|
+
estimate?(): Promise<StorageEstimate | null>;
|
|
6
12
|
};
|
|
7
13
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
8
14
|
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
package/dist/durability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,cAAc,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAG/F;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGrF"}
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type QueryRows } from './query.js';
|
|
2
2
|
export { QueryError } from './query.js';
|
|
3
3
|
export type EntryRoom = {
|
|
4
4
|
locator: string;
|
|
@@ -11,7 +11,7 @@ export declare function boundQuery(template: unknown, args: EntryArguments): unk
|
|
|
11
11
|
export declare function entryParameters(template: unknown): readonly string[];
|
|
12
12
|
export declare function entryRefusal(template: unknown): string | null;
|
|
13
13
|
export type EntryScope = {
|
|
14
|
-
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string,
|
|
14
|
+
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryRows>>;
|
|
15
15
|
};
|
|
16
16
|
export declare function entryScope(rooms: readonly EntryRoom[]): EntryScope;
|
|
17
17
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,SAAS,EAEf,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AA0D7E,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAE3E;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAMpE;AAkCD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAQ7D;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;CACzF,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,UAAU,CAqDlE"}
|
package/dist/entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attachedModel } from './attached-model.js';
|
|
2
|
-
import { collectionOf,
|
|
2
|
+
import { collectionOf, passingFrontmatter } from './collection.js';
|
|
3
3
|
import { NO_MODEL } from './model.js';
|
|
4
4
|
import { invalid, planOf, plain, QueryError, } from './query.js';
|
|
5
5
|
import { createReadSide } from './read-side.js';
|
|
@@ -131,7 +131,7 @@ export function entryScope(rooms) {
|
|
|
131
131
|
locator: room.locator,
|
|
132
132
|
path,
|
|
133
133
|
before: [],
|
|
134
|
-
after: rowsOf(room.locator, path,
|
|
134
|
+
after: rowsOf(room.locator, path, passingFrontmatter(collection, path) ?? null, composition, null, null),
|
|
135
135
|
}));
|
|
136
136
|
});
|
|
137
137
|
readSide.apply({
|
|
@@ -148,7 +148,7 @@ export function entryScope(rooms) {
|
|
|
148
148
|
async results(queries) {
|
|
149
149
|
const results = {};
|
|
150
150
|
for (const [name, query] of Object.entries(queries)) {
|
|
151
|
-
results[name] = await readSide.query(planOf(query, planned));
|
|
151
|
+
results[name] = (await readSide.query(planOf(query, planned), () => null)).rows;
|
|
152
152
|
}
|
|
153
153
|
return results;
|
|
154
154
|
},
|
package/dist/host.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type MdRuntimeOptions } from './connection.js';
|
|
2
|
+
import type { RuntimeDemand } from './acquisition.js';
|
|
2
3
|
import type { PortReach } from './reach.js';
|
|
4
|
+
import type { CapacityCause, CodeAvailability, Persistence, Readiness } from './readiness.js';
|
|
3
5
|
import { type RuntimePort } from './wire.js';
|
|
4
6
|
export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
5
7
|
deploymentFacts?: unknown;
|
|
@@ -7,15 +9,22 @@ export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
|
7
9
|
export type AttachedPort = {
|
|
8
10
|
detach(): void;
|
|
9
11
|
narrow(reach: PortReach): void;
|
|
12
|
+
readiness(deliver: (readiness: Readiness) => void): () => void;
|
|
13
|
+
code(code: CodeAvailability, capacity: CapacityCause | null): void;
|
|
10
14
|
};
|
|
11
15
|
export type MdRuntimeHost = {
|
|
12
|
-
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach): AttachedPort;
|
|
16
|
+
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability): AttachedPort;
|
|
17
|
+
acquire(demand: RuntimeDemand): void;
|
|
18
|
+
persisted(answer: Persistence): void;
|
|
13
19
|
endAuthorization(holder?: string): Promise<void>;
|
|
14
20
|
lose(locators: readonly string[]): Promise<void>;
|
|
15
21
|
stop(): Promise<void>;
|
|
16
22
|
};
|
|
17
23
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
24
|
+
export type { RuntimeDemand } from './acquisition.js';
|
|
18
25
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
19
|
-
export {
|
|
26
|
+
export type { CapacityCause, CodeAvailability, Persistence } from './readiness.js';
|
|
27
|
+
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
28
|
+
export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, openDatabase, STORE_SCHEMA, } from './store.js';
|
|
20
29
|
export type { RuntimePort } from './wire.js';
|
|
21
30
|
//# sourceMappingURL=host.d.ts.map
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK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