@agentshouse/mdruntime 0.1.0-cb0eb0d87ff49 → 0.1.0-cb2e390ee7b89
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 +275 -285
- 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 +25 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +2 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +2 -1
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/kit.d.ts +2 -1
- package/dist/chat/kit.d.ts.map +1 -1
- package/dist/chat/kit.js +3 -3
- package/dist/chat/list.d.ts +2 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +42 -5
- package/dist/chat/messages.d.ts +1 -0
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +4 -0
- package/dist/chat/provider.d.ts +1 -1
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +34 -19
- package/dist/chat/question.d.ts +1 -1
- package/dist/chat/question.d.ts.map +1 -1
- package/dist/chat/question.js +7 -18
- package/dist/chat/ready.d.ts +1 -0
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +2 -2
- package/dist/chat/style.js +1 -1
- package/dist/client.d.ts +8 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -5
- package/dist/connection.d.ts +19 -3
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +741 -100
- package/dist/conversation.d.ts +7 -0
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +202 -39
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/host.d.ts +15 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +85 -8
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/memory.d.ts +8 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +26 -6
- package/dist/model.d.ts +3 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +1 -1
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +9 -3
- package/dist/outcome.d.ts +8 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +27 -3
- package/dist/query.d.ts +24 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +32 -5
- package/dist/reach.d.ts +6 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +18 -3
- package/dist/react.d.ts +4 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +6 -4
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +169 -47
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +6 -0
- package/dist/replica.d.ts +5 -1
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +30 -5
- package/dist/room-draft.d.ts +13 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +2 -2
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +17 -1
- package/dist/search.d.ts +28 -7
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +93 -13
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +26 -4
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +92 -25
- package/dist/windows.d.ts +18 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +80 -0
- package/dist/wire.d.ts +144 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +50 -31
- package/package.json +2 -2
package/dist/conversation.d.ts
CHANGED
|
@@ -36,10 +36,14 @@ export type ChatDraft = {
|
|
|
36
36
|
};
|
|
37
37
|
export type ConversationOptions = {
|
|
38
38
|
limit?: number;
|
|
39
|
+
after?: string;
|
|
40
|
+
total?: true;
|
|
39
41
|
};
|
|
40
42
|
export type ConversationView = {
|
|
41
43
|
conversation: string;
|
|
42
44
|
messages: readonly ConversationMessage[];
|
|
45
|
+
next?: string;
|
|
46
|
+
total?: number;
|
|
43
47
|
turn: RunningTurn | null;
|
|
44
48
|
questions: readonly unknown[];
|
|
45
49
|
process: {
|
|
@@ -86,8 +90,10 @@ export type ConversationStore = {
|
|
|
86
90
|
catchUp(progress: CycleProgress): Promise<void>;
|
|
87
91
|
resend(progress: CycleProgress): Promise<void>;
|
|
88
92
|
current(): boolean;
|
|
93
|
+
known(): boolean;
|
|
89
94
|
reconnected(): void;
|
|
90
95
|
reopened(): void;
|
|
96
|
+
lost(): void;
|
|
91
97
|
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
92
98
|
watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
|
|
93
99
|
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
@@ -99,5 +105,6 @@ export type ConversationStore = {
|
|
|
99
105
|
};
|
|
100
106
|
export declare function unheldView(conversation: string): ConversationView;
|
|
101
107
|
export declare const SESSION_STARTED = "Session started";
|
|
108
|
+
export declare function newChat(agent: string): string;
|
|
102
109
|
export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
|
|
103
110
|
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -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,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;
|
|
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,EAA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AAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAiQD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CAs1BzF"}
|
package/dist/conversation.js
CHANGED
|
@@ -3,6 +3,7 @@ import { runtimeError } from './failure.js';
|
|
|
3
3
|
import { declaredFile } from './file.js';
|
|
4
4
|
import { changeBatchIdentity, chatDraftRevision } from './identity.js';
|
|
5
5
|
import { OFFLINE } from './outcome.js';
|
|
6
|
+
import { cursorOf, decodedCursor, FROM_START } from './windows.js';
|
|
6
7
|
const QUIET = {
|
|
7
8
|
turn: null,
|
|
8
9
|
questions: [],
|
|
@@ -23,6 +24,16 @@ export function unheldView(conversation) {
|
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
export const SESSION_STARTED = 'Session started';
|
|
27
|
+
const NEW_CHAT = 'new:';
|
|
28
|
+
export function newChat(agent) {
|
|
29
|
+
return `${NEW_CHAT}${agent}`;
|
|
30
|
+
}
|
|
31
|
+
function creationOf(input) {
|
|
32
|
+
if (typeof input !== 'object' || input === null)
|
|
33
|
+
return null;
|
|
34
|
+
const { agent_id: agent, operation_id: operation } = input;
|
|
35
|
+
return typeof agent === 'string' && typeof operation === 'string' ? { agent, operation } : null;
|
|
36
|
+
}
|
|
26
37
|
function startedTurn(turn, operation) {
|
|
27
38
|
if (operation.op === 'begin')
|
|
28
39
|
return { turn, started: operation.at, parts: [], context: null };
|
|
@@ -84,7 +95,25 @@ function windowOf(held, arriving, limit) {
|
|
|
84
95
|
for (const message of arriving)
|
|
85
96
|
byIdentity.set(message.identity, message);
|
|
86
97
|
const next = [...byIdentity.values()].sort(ordered);
|
|
87
|
-
|
|
98
|
+
const start = limit === undefined ? 0 : Math.max(0, next.length - limit);
|
|
99
|
+
return { messages: next.slice(start), dropped: start > 0 };
|
|
100
|
+
}
|
|
101
|
+
function precedes(message, before) {
|
|
102
|
+
return (before === null ||
|
|
103
|
+
message.position < before[0] ||
|
|
104
|
+
(message.position === before[0] && message.identity < before[1]));
|
|
105
|
+
}
|
|
106
|
+
function frameOf(asked, messages, more, total) {
|
|
107
|
+
const oldest = messages[0];
|
|
108
|
+
const next = !more
|
|
109
|
+
? undefined
|
|
110
|
+
: oldest === undefined
|
|
111
|
+
? (asked.after ?? FROM_START)
|
|
112
|
+
: cursorOf([oldest.position, oldest.identity]);
|
|
113
|
+
return {
|
|
114
|
+
...(next === undefined ? {} : { next }),
|
|
115
|
+
...(total === null ? {} : { total }),
|
|
116
|
+
};
|
|
88
117
|
}
|
|
89
118
|
function newestOf(arriving, from) {
|
|
90
119
|
return arriving.reduce((top, message) => (top === null || message.position > top ? message.position : top), from);
|
|
@@ -146,30 +175,46 @@ function historyPages(result) {
|
|
|
146
175
|
}
|
|
147
176
|
return pages;
|
|
148
177
|
}
|
|
149
|
-
function
|
|
178
|
+
function answered(result, field) {
|
|
150
179
|
if (result.kind !== 'action')
|
|
151
180
|
return null;
|
|
152
181
|
const answer = result.result;
|
|
153
182
|
if (typeof answer !== 'object' || answer === null)
|
|
154
183
|
return null;
|
|
155
|
-
const
|
|
156
|
-
return typeof
|
|
184
|
+
const value = answer[field];
|
|
185
|
+
return typeof value === 'string' ? value : null;
|
|
186
|
+
}
|
|
187
|
+
function beforeOf(after) {
|
|
188
|
+
if (after === undefined)
|
|
189
|
+
return null;
|
|
190
|
+
const decoded = typeof after === 'string' ? decodedCursor(after) : null;
|
|
191
|
+
if (decoded?.length === 0)
|
|
192
|
+
return null;
|
|
193
|
+
const [position, identity] = decoded ?? [];
|
|
194
|
+
if (decoded?.length !== 2 || typeof position !== 'string' || typeof identity !== 'string') {
|
|
195
|
+
throw runtimeError('invalid-after', `conversation after must be the next an earlier view returned, got ${String(after)}`);
|
|
196
|
+
}
|
|
197
|
+
return [position, identity];
|
|
157
198
|
}
|
|
158
|
-
function
|
|
159
|
-
const { limit } = options;
|
|
160
|
-
if (limit
|
|
161
|
-
return undefined;
|
|
162
|
-
if (!Number.isInteger(limit) || limit < 0) {
|
|
199
|
+
function askedOf(options) {
|
|
200
|
+
const { limit, after, total } = options;
|
|
201
|
+
if (limit !== undefined && (!Number.isInteger(limit) || limit < 0)) {
|
|
163
202
|
throw runtimeError('invalid-limit', `conversation limit must be a non-negative integer, got ${String(limit)}`);
|
|
164
203
|
}
|
|
165
|
-
return limit;
|
|
204
|
+
return { limit, after, before: beforeOf(after), total: total === true };
|
|
166
205
|
}
|
|
167
206
|
const EXPIRED = { kind: 'rejected', code: 'expired', fields: {}, retryable: false };
|
|
168
207
|
function unwritten(draft) {
|
|
169
208
|
return draft.text === '' && draft.files.length === 0;
|
|
170
209
|
}
|
|
171
210
|
function pending(draft) {
|
|
172
|
-
return
|
|
211
|
+
return {
|
|
212
|
+
...(draft.submitted === undefined ? {} : { submitted: draft.submitted }),
|
|
213
|
+
...(draft.moves === undefined ? {} : { moves: draft.moves }),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function empty(draft) {
|
|
217
|
+
return unwritten(draft) && draft.submitted === undefined && draft.moves === undefined;
|
|
173
218
|
}
|
|
174
219
|
function withSubmitted(draft, submitted) {
|
|
175
220
|
const { submitted: _held, ...unsent } = draft;
|
|
@@ -190,10 +235,12 @@ export function createConversationStore(deps) {
|
|
|
190
235
|
const drafts = new Map();
|
|
191
236
|
const sending = new Map();
|
|
192
237
|
const behind = new Set();
|
|
238
|
+
const catching = new Map();
|
|
193
239
|
const gaps = new Map();
|
|
194
240
|
const lives = new Map();
|
|
195
241
|
const views = new Map();
|
|
196
242
|
const listing = new Map();
|
|
243
|
+
const creations = new Set();
|
|
197
244
|
const listWatchers = new Set();
|
|
198
245
|
let listKnown = false;
|
|
199
246
|
const agentWatchers = new Set();
|
|
@@ -205,17 +252,18 @@ export function createConversationStore(deps) {
|
|
|
205
252
|
function liveOf(conversation) {
|
|
206
253
|
return lives.get(conversation) ?? QUIET;
|
|
207
254
|
}
|
|
208
|
-
function viewOf(conversation,
|
|
255
|
+
function viewOf(conversation, held, frame) {
|
|
209
256
|
const draft = drafts.get(conversation);
|
|
210
257
|
const facts = liveOf(conversation);
|
|
211
258
|
return {
|
|
212
259
|
conversation,
|
|
213
|
-
messages:
|
|
260
|
+
messages: held.map(({ identity, turn, text, message }) => ({
|
|
214
261
|
identity,
|
|
215
262
|
turn,
|
|
216
263
|
text,
|
|
217
264
|
message,
|
|
218
265
|
})),
|
|
266
|
+
...frame,
|
|
219
267
|
turn: structuredClone(facts.turn),
|
|
220
268
|
questions: structuredClone(facts.questions),
|
|
221
269
|
process: facts.process === null ? null : { ...facts.process },
|
|
@@ -235,16 +283,34 @@ export function createConversationStore(deps) {
|
|
|
235
283
|
const ready = [...view.watchers].filter((watcher) => watcher.ready);
|
|
236
284
|
if (ready.length === 0)
|
|
237
285
|
continue;
|
|
238
|
-
const value = viewOf(conversation, view.window);
|
|
286
|
+
const value = viewOf(conversation, view.window, sharedFrame(view, view.window));
|
|
239
287
|
for (const watcher of ready)
|
|
240
288
|
watcher.notify(value);
|
|
241
289
|
}
|
|
242
290
|
}
|
|
243
|
-
function
|
|
291
|
+
function sharedFrame(view, window) {
|
|
292
|
+
return frameOf(view.asked, window, view.more, view.total);
|
|
293
|
+
}
|
|
294
|
+
async function slide(local, conversation, arriving) {
|
|
295
|
+
let count;
|
|
244
296
|
for (const view of views.values()) {
|
|
245
297
|
if (view.conversation !== conversation || view.window === null)
|
|
246
298
|
continue;
|
|
247
|
-
|
|
299
|
+
if (arriving === null) {
|
|
300
|
+
view.window = [];
|
|
301
|
+
view.more = false;
|
|
302
|
+
if (view.total !== null)
|
|
303
|
+
view.total = 0;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
const joining = arriving.filter((message) => precedes(message, view.asked.before));
|
|
307
|
+
const next = windowOf(view.window, joining, view.asked.limit);
|
|
308
|
+
view.window = next.messages;
|
|
309
|
+
view.more ||= next.dropped;
|
|
310
|
+
if (view.total !== null && arriving.length > 0) {
|
|
311
|
+
count ??= await local.messageCount(conversation);
|
|
312
|
+
view.total = count;
|
|
313
|
+
}
|
|
248
314
|
}
|
|
249
315
|
}
|
|
250
316
|
function changesOf(conversation, arriving) {
|
|
@@ -332,6 +398,12 @@ export function createConversationStore(deps) {
|
|
|
332
398
|
if (named)
|
|
333
399
|
emitList();
|
|
334
400
|
emitAgents();
|
|
401
|
+
const ended = [...drafts.keys()].filter(retiredChat);
|
|
402
|
+
if (ended.length > 0)
|
|
403
|
+
await remove(ended);
|
|
404
|
+
}
|
|
405
|
+
function retiredChat(conversation) {
|
|
406
|
+
return (conversation.startsWith(NEW_CHAT) && retiredAgents.has(conversation.slice(NEW_CHAT.length)));
|
|
335
407
|
}
|
|
336
408
|
function agentsReady() {
|
|
337
409
|
agentsRead ??= readAgents().catch(() => {
|
|
@@ -387,7 +459,7 @@ export function createConversationStore(deps) {
|
|
|
387
459
|
drafts.delete(conversation);
|
|
388
460
|
behind.delete(conversation);
|
|
389
461
|
setLive(conversation, null);
|
|
390
|
-
slide(conversation, null);
|
|
462
|
+
await slide(local, conversation, null);
|
|
391
463
|
}
|
|
392
464
|
if (changed.length > 0)
|
|
393
465
|
deps.publish(conversationChangeSet(removed, changed));
|
|
@@ -415,11 +487,11 @@ export function createConversationStore(deps) {
|
|
|
415
487
|
if (advances)
|
|
416
488
|
reads.set(conversation, message.position);
|
|
417
489
|
sealTurns(conversation, new Set([message.turn]));
|
|
418
|
-
slide(conversation, [message]);
|
|
490
|
+
await slide(local, conversation, [message]);
|
|
419
491
|
deps.publish(conversationChangeSet(changesOf(conversation, [message]), [conversation]));
|
|
420
492
|
});
|
|
421
493
|
}
|
|
422
|
-
async function readHistories(conversations) {
|
|
494
|
+
async function readHistories(conversations, ended) {
|
|
423
495
|
const generations = new Map(conversations.map((one) => [one, gaps.get(one) ?? 0]));
|
|
424
496
|
let asking = conversations.map((conversation) => ({
|
|
425
497
|
conversation,
|
|
@@ -445,10 +517,33 @@ export function createConversationStore(deps) {
|
|
|
445
517
|
following.push({ conversation: page.conversation, after: page.next });
|
|
446
518
|
}
|
|
447
519
|
}
|
|
520
|
+
for (const { conversation } of asking) {
|
|
521
|
+
if (!following.some((next) => next.conversation === conversation))
|
|
522
|
+
ended(conversation);
|
|
523
|
+
}
|
|
448
524
|
asking = following;
|
|
449
525
|
}
|
|
450
526
|
return null;
|
|
451
527
|
}
|
|
528
|
+
function caughtUp(conversations) {
|
|
529
|
+
const ends = new Map();
|
|
530
|
+
for (const conversation of conversations) {
|
|
531
|
+
const held = new Promise((end) => ends.set(conversation, end));
|
|
532
|
+
catching.set(conversation, held);
|
|
533
|
+
void held.then(() => {
|
|
534
|
+
if (catching.get(conversation) === held)
|
|
535
|
+
catching.delete(conversation);
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
const ended = (conversation) => ends.get(conversation)?.();
|
|
539
|
+
const read = readHistories(conversations, ended);
|
|
540
|
+
const endAll = () => {
|
|
541
|
+
for (const conversation of conversations)
|
|
542
|
+
ended(conversation);
|
|
543
|
+
};
|
|
544
|
+
read.then(endAll, endAll);
|
|
545
|
+
return read;
|
|
546
|
+
}
|
|
452
547
|
function keepPage(conversation, arriving, from, next, generation) {
|
|
453
548
|
return deps.durably(async (local) => {
|
|
454
549
|
if (!replicated.has(conversation))
|
|
@@ -467,7 +562,7 @@ export function createConversationStore(deps) {
|
|
|
467
562
|
sealTurns(conversation, new Set(arriving.map((message) => message.turn)));
|
|
468
563
|
if (whole && (gaps.get(conversation) ?? 0) === generation)
|
|
469
564
|
behind.delete(conversation);
|
|
470
|
-
slide(conversation, arriving);
|
|
565
|
+
await slide(local, conversation, arriving);
|
|
471
566
|
if (arriving.length > 0 || sealing || whole) {
|
|
472
567
|
deps.publish(conversationChangeSet(changesOf(conversation, arriving), [conversation]));
|
|
473
568
|
}
|
|
@@ -516,12 +611,12 @@ export function createConversationStore(deps) {
|
|
|
516
611
|
emit(conversation);
|
|
517
612
|
}
|
|
518
613
|
async function kept(local, conversation, following) {
|
|
519
|
-
if (following === null || (
|
|
614
|
+
if (following === null || empty(following)) {
|
|
520
615
|
await local.dropChatDraft(conversation);
|
|
521
616
|
drafts.delete(conversation);
|
|
522
617
|
}
|
|
523
618
|
else {
|
|
524
|
-
await local.
|
|
619
|
+
await local.keepChatDrafts([following]);
|
|
525
620
|
drafts.set(conversation, following);
|
|
526
621
|
}
|
|
527
622
|
}
|
|
@@ -534,6 +629,29 @@ export function createConversationStore(deps) {
|
|
|
534
629
|
await kept(local, conversation, withSubmitted(held, left));
|
|
535
630
|
return true;
|
|
536
631
|
}
|
|
632
|
+
function moved(agent, operation, to) {
|
|
633
|
+
const from = newChat(agent);
|
|
634
|
+
return deps.durably(async (local) => {
|
|
635
|
+
const held = drafts.get(from);
|
|
636
|
+
const earlier = (held?.moves ?? []).filter((one) => !deps.expired(one));
|
|
637
|
+
if (earlier.includes(operation))
|
|
638
|
+
return;
|
|
639
|
+
const blank = {
|
|
640
|
+
conversation: from,
|
|
641
|
+
text: '',
|
|
642
|
+
files: [],
|
|
643
|
+
revision: chatDraftRevision(),
|
|
644
|
+
};
|
|
645
|
+
const { moves: _answered, ...unsent } = held ?? blank;
|
|
646
|
+
const taken = drafts.has(to) || empty(unsent) ? [] : [{ ...unsent, conversation: to }];
|
|
647
|
+
const left = { ...(taken.length === 0 ? unsent : blank), moves: [...earlier, operation] };
|
|
648
|
+
await local.keepChatDrafts([left, ...taken]);
|
|
649
|
+
drafts.set(from, left);
|
|
650
|
+
for (const one of taken)
|
|
651
|
+
drafts.set(to, one);
|
|
652
|
+
deps.publish(conversationChangeSet([], [from, to]));
|
|
653
|
+
});
|
|
654
|
+
}
|
|
537
655
|
function withDraft(conversation, next) {
|
|
538
656
|
return deps.durably(async (local) => {
|
|
539
657
|
const following = await next(drafts.get(conversation), local);
|
|
@@ -592,7 +710,7 @@ export function createConversationStore(deps) {
|
|
|
592
710
|
deps.unanswered();
|
|
593
711
|
return result;
|
|
594
712
|
}
|
|
595
|
-
const turn =
|
|
713
|
+
const turn = answered(result, 'turn');
|
|
596
714
|
await withDraft(conversation, async (current, local) => {
|
|
597
715
|
const held = current?.submitted?.find((one) => one.operation === submission.operation);
|
|
598
716
|
if (current === undefined || held === undefined || held.turn !== null)
|
|
@@ -621,11 +739,24 @@ export function createConversationStore(deps) {
|
|
|
621
739
|
return entries();
|
|
622
740
|
},
|
|
623
741
|
async read(conversation, options = {}) {
|
|
624
|
-
const
|
|
625
|
-
return deps.durably(async (local) =>
|
|
742
|
+
const asked = askedOf(options);
|
|
743
|
+
return deps.durably(async (local) => {
|
|
744
|
+
const { messages, more } = await local.messageWindow(conversation, asked.limit, asked.before);
|
|
745
|
+
const total = asked.total ? await local.messageCount(conversation) : null;
|
|
746
|
+
return structuredClone(viewOf(conversation, messages, frameOf(asked, messages, more, total)));
|
|
747
|
+
});
|
|
626
748
|
},
|
|
627
|
-
create(input) {
|
|
628
|
-
|
|
749
|
+
async create(input) {
|
|
750
|
+
const result = await deps.call('conversation.create', input);
|
|
751
|
+
const conversation = answered(result, 'conversation');
|
|
752
|
+
if (conversation === null)
|
|
753
|
+
return result;
|
|
754
|
+
if (!listing.has(conversation))
|
|
755
|
+
creations.add(conversation);
|
|
756
|
+
const creation = creationOf(input);
|
|
757
|
+
if (creation !== null)
|
|
758
|
+
await moved(creation.agent, creation.operation, conversation);
|
|
759
|
+
return result;
|
|
629
760
|
},
|
|
630
761
|
async send(conversation, operation = changeBatchIdentity(), draft) {
|
|
631
762
|
if (deps.online()) {
|
|
@@ -674,7 +805,7 @@ export function createConversationStore(deps) {
|
|
|
674
805
|
text: draft.text,
|
|
675
806
|
files: [...draft.files],
|
|
676
807
|
revision,
|
|
677
|
-
...(current
|
|
808
|
+
...(current === undefined ? {} : pending(current)),
|
|
678
809
|
}));
|
|
679
810
|
},
|
|
680
811
|
discard(conversation) {
|
|
@@ -713,7 +844,9 @@ export function createConversationStore(deps) {
|
|
|
713
844
|
const named = new Set(listing.keys());
|
|
714
845
|
const leaving = [
|
|
715
846
|
...new Set([...replicated, ...stored, ...reads.keys(), ...drafts.keys()]),
|
|
716
|
-
].filter((conversation) => !named.has(conversation)
|
|
847
|
+
].filter((conversation) => !named.has(conversation) &&
|
|
848
|
+
!creations.has(conversation) &&
|
|
849
|
+
(!conversation.startsWith(NEW_CHAT) || retiredChat(conversation)));
|
|
717
850
|
for (const conversation of named) {
|
|
718
851
|
if (!replicated.has(conversation))
|
|
719
852
|
behind.add(conversation);
|
|
@@ -724,12 +857,20 @@ export function createConversationStore(deps) {
|
|
|
724
857
|
await remove(leaving);
|
|
725
858
|
},
|
|
726
859
|
async catchUp(progress) {
|
|
727
|
-
const
|
|
728
|
-
|
|
729
|
-
|
|
860
|
+
const owed = (conversation) => behind.has(conversation) && replicated.has(conversation);
|
|
861
|
+
const read = async (conversations) => {
|
|
862
|
+
if (conversations.length === 0 || deps.closed())
|
|
863
|
+
return;
|
|
864
|
+
const failed = await caughtUp(conversations);
|
|
730
865
|
if (failed?.kind === 'transport-uncertainty')
|
|
731
866
|
progress.reachable = false;
|
|
732
|
-
}
|
|
867
|
+
};
|
|
868
|
+
const asking = [...behind].filter(owed).sort();
|
|
869
|
+
const awaited = asking.filter((conversation) => catching.has(conversation));
|
|
870
|
+
await Promise.all([
|
|
871
|
+
read(asking.filter((conversation) => !catching.has(conversation))),
|
|
872
|
+
Promise.all(awaited.map((conversation) => catching.get(conversation))).then(() => read(awaited.filter((conversation) => owed(conversation) && !catching.has(conversation)))),
|
|
873
|
+
]);
|
|
733
874
|
if (behind.size > 0)
|
|
734
875
|
progress.complete = false;
|
|
735
876
|
},
|
|
@@ -761,6 +902,9 @@ export function createConversationStore(deps) {
|
|
|
761
902
|
current() {
|
|
762
903
|
return behind.size === 0;
|
|
763
904
|
},
|
|
905
|
+
known() {
|
|
906
|
+
return listKnown;
|
|
907
|
+
},
|
|
764
908
|
reconnected() {
|
|
765
909
|
for (const conversation of replicated)
|
|
766
910
|
gap(conversation);
|
|
@@ -768,27 +912,43 @@ export function createConversationStore(deps) {
|
|
|
768
912
|
reopened() {
|
|
769
913
|
sending.clear();
|
|
770
914
|
},
|
|
915
|
+
lost() {
|
|
916
|
+
catching.clear();
|
|
917
|
+
},
|
|
771
918
|
watch(conversation, options, deliver) {
|
|
772
|
-
const
|
|
773
|
-
const key = JSON.stringify([
|
|
919
|
+
const asked = askedOf(options);
|
|
920
|
+
const key = JSON.stringify([
|
|
921
|
+
conversation,
|
|
922
|
+
asked.limit ?? null,
|
|
923
|
+
asked.after ?? null,
|
|
924
|
+
asked.total,
|
|
925
|
+
]);
|
|
774
926
|
const view = views.get(key) ?? {
|
|
775
927
|
conversation,
|
|
776
|
-
|
|
928
|
+
asked,
|
|
777
929
|
watchers: new Set(),
|
|
778
930
|
window: null,
|
|
931
|
+
more: false,
|
|
932
|
+
total: null,
|
|
779
933
|
};
|
|
780
934
|
views.set(key, view);
|
|
781
935
|
const watcher = { notify: deliver, ready: false };
|
|
782
936
|
view.watchers.add(watcher);
|
|
783
937
|
void deps
|
|
784
938
|
.durably(async (local) => {
|
|
785
|
-
view.window
|
|
939
|
+
if (view.window !== null)
|
|
940
|
+
return;
|
|
941
|
+
const { messages, more } = await local.messageWindow(conversation, asked.limit, asked.before);
|
|
942
|
+
view.window = messages;
|
|
943
|
+
view.more = more;
|
|
944
|
+
view.total = asked.total ? await local.messageCount(conversation) : null;
|
|
786
945
|
})
|
|
787
946
|
.then(() => {
|
|
788
947
|
if (deps.closed() || !view.watchers.has(watcher))
|
|
789
948
|
return;
|
|
790
949
|
watcher.ready = true;
|
|
791
|
-
|
|
950
|
+
const window = view.window ?? [];
|
|
951
|
+
watcher.notify(viewOf(conversation, window, sharedFrame(view, window)));
|
|
792
952
|
})
|
|
793
953
|
.catch(() => { });
|
|
794
954
|
return () => {
|
|
@@ -835,12 +995,15 @@ export function createConversationStore(deps) {
|
|
|
835
995
|
if (event.kind === 'list' || event.kind === 'listed' || event.kind === 'unlisted') {
|
|
836
996
|
if (event.kind === 'list') {
|
|
837
997
|
listing.clear();
|
|
838
|
-
for (const entry of event.entries)
|
|
998
|
+
for (const entry of event.entries) {
|
|
839
999
|
listing.set(entry.conversation, { ...entry });
|
|
1000
|
+
creations.delete(entry.conversation);
|
|
1001
|
+
}
|
|
840
1002
|
listKnown = true;
|
|
841
1003
|
}
|
|
842
1004
|
else if (event.kind === 'listed') {
|
|
843
1005
|
listing.set(event.entry.conversation, { ...event.entry });
|
|
1006
|
+
creations.delete(event.entry.conversation);
|
|
844
1007
|
}
|
|
845
1008
|
else {
|
|
846
1009
|
listing.delete(event.conversation);
|
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,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Q,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,CAsDlE"}
|
package/dist/entry.js
CHANGED
|
@@ -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, passingFrontmatter(collection, path) ?? null, composition, null, null),
|
|
134
|
+
after: rowsOf(room.locator, path, passingFrontmatter(collection, path) ?? null, composition, null, null, null),
|
|
135
135
|
}));
|
|
136
136
|
});
|
|
137
137
|
readSide.apply({
|
package/dist/host.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
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, SearchObligation } from './readiness.js';
|
|
5
|
+
import type { EntrySeed } from './seed.js';
|
|
3
6
|
import { type RuntimePort } from './wire.js';
|
|
4
7
|
export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
5
8
|
deploymentFacts?: unknown;
|
|
@@ -7,16 +10,26 @@ export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
|
7
10
|
export type AttachedPort = {
|
|
8
11
|
detach(): void;
|
|
9
12
|
narrow(reach: PortReach): void;
|
|
13
|
+
readiness(deliver: (readiness: Readiness) => void): () => void;
|
|
14
|
+
answered(queries: readonly unknown[], done: () => void): void;
|
|
15
|
+
code(code: CodeAvailability, capacity: CapacityCause | null): void;
|
|
16
|
+
search(search: SearchObligation): void;
|
|
10
17
|
};
|
|
11
18
|
export type MdRuntimeHost = {
|
|
12
|
-
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach): AttachedPort;
|
|
19
|
+
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability, search?: SearchObligation): AttachedPort;
|
|
20
|
+
acquire(demand: RuntimeDemand): void;
|
|
21
|
+
seed(entry: EntrySeed): void;
|
|
22
|
+
persisted(answer: Persistence): void;
|
|
13
23
|
endAuthorization(holder?: string): Promise<void>;
|
|
14
24
|
lose(locators: readonly string[]): Promise<void>;
|
|
15
25
|
stop(): Promise<void>;
|
|
16
26
|
};
|
|
17
27
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
28
|
+
export type { RuntimeDemand } from './acquisition.js';
|
|
29
|
+
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
18
30
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
31
|
+
export type { CapacityCause, CodeAvailability, Persistence, SearchObligation, } from './readiness.js';
|
|
19
32
|
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
20
|
-
export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, STORE_SCHEMA, } from './store.js';
|
|
33
|
+
export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, openDatabase, STORE_SCHEMA, } from './store.js';
|
|
21
34
|
export type { RuntimePort } from './wire.js';
|
|
22
35
|
//# 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,gBAAgB,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,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