@agentshouse/mdruntime 0.1.0-ccd098ff75bbf → 0.1.0-cce1d81ef3d6d
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/dist/adapter.d.ts +65 -48
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +18 -1
- package/dist/bootstrap.d.ts +9 -11
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +97 -85
- package/dist/client.d.ts +6 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +52 -6
- package/dist/collection.d.ts +5 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -17
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +65 -19
- package/dist/connection.d.ts +5 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +925 -900
- package/dist/conversation.d.ts +11 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +204 -129
- package/dist/durability.d.ts +0 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +1 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/fulltext.d.ts.map +1 -1
- package/dist/fulltext.js +8 -6
- package/dist/host.d.ts +0 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +10 -11
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +8 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +174 -82
- package/dist/model.d.ts +6 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -9
- package/dist/observation.d.ts +1 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +1 -1
- package/dist/outcome.d.ts +13 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -2
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +6 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts +8 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +49 -22
- package/dist/readiness.d.ts +3 -15
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +26 -0
- package/dist/refresh.d.ts +5 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +2 -3
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +2 -5
- package/dist/room-draft.d.ts +17 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +40 -6
- package/dist/rows.d.ts +4 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +29 -20
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +11 -5
- 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 +4 -3
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +18 -32
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +25 -60
- package/dist/stored.d.ts +9 -24
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +207 -204
- package/dist/tables.d.ts +16 -45
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +7 -53
- 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 +35 -96
- package/dist/wire.d.ts +8 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -2
- package/dist/words.d.ts.map +1 -1
- package/dist/words.js +8 -2
- package/package.json +2 -2
- package/dist/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -100
package/dist/conversation.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { ConversationAction,
|
|
1
|
+
import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ListedConversation, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
|
|
2
2
|
import { type ChangeSet } from './change-set.js';
|
|
3
|
-
import { type ChosenFile } from './file.js';
|
|
4
3
|
import type { Open } from './open.js';
|
|
5
4
|
import { type CallResult, type Offline } from './outcome.js';
|
|
6
|
-
import type { DocumentResult, PendingResult } from './query.js';
|
|
7
5
|
import type { CycleProgress } from './status.js';
|
|
8
6
|
import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
|
|
9
7
|
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
@@ -11,7 +9,7 @@ export type ConversationEntry = {
|
|
|
11
9
|
conversation: string;
|
|
12
10
|
agent: {
|
|
13
11
|
identity: string;
|
|
14
|
-
name: string
|
|
12
|
+
name: string;
|
|
15
13
|
};
|
|
16
14
|
name: string;
|
|
17
15
|
created: string;
|
|
@@ -52,6 +50,7 @@ export type ConversationView = {
|
|
|
52
50
|
commands: readonly ProcessCommand[];
|
|
53
51
|
options: readonly SessionOption[];
|
|
54
52
|
starting: string | null;
|
|
53
|
+
subagents: readonly RunningSubagent[];
|
|
55
54
|
link: {
|
|
56
55
|
connected: boolean;
|
|
57
56
|
} | null;
|
|
@@ -65,22 +64,23 @@ export type ConversationSurface = {
|
|
|
65
64
|
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
66
65
|
create(input: unknown): Promise<CallResult>;
|
|
67
66
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
68
|
-
|
|
69
|
-
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
67
|
+
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
70
68
|
interrupt(conversation: string): Promise<CallResult>;
|
|
71
69
|
kill(conversation: string): Promise<CallResult>;
|
|
72
|
-
cancel(conversation: string, turn: string): Promise<CallResult>;
|
|
73
70
|
delete(conversation: string): Promise<CallResult>;
|
|
74
71
|
};
|
|
72
|
+
export type ConversationAnswer = {
|
|
73
|
+
interaction_id: string;
|
|
74
|
+
response: unknown;
|
|
75
|
+
};
|
|
75
76
|
export type ChatDraftSurface = {
|
|
76
77
|
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
77
78
|
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
78
79
|
discard(conversation: string): Promise<void>;
|
|
79
80
|
};
|
|
80
81
|
export type ConversationDependencies = {
|
|
81
|
-
agents(): ConversationAgents | undefined;
|
|
82
|
-
documents(agents: ConversationAgents, after: string | undefined): Promise<DocumentResult | PendingResult>;
|
|
83
82
|
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
83
|
+
history(request: ConversationHistoryRequest): Promise<CallResult>;
|
|
84
84
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
85
85
|
stream(): ConversationStream | undefined;
|
|
86
86
|
publish(set: ChangeSet): void;
|
|
@@ -93,13 +93,13 @@ export type ConversationDependencies = {
|
|
|
93
93
|
export type ConversationStore = {
|
|
94
94
|
surface: ConversationSurface;
|
|
95
95
|
chatDraft: ChatDraftSurface;
|
|
96
|
-
hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[]): void;
|
|
96
|
+
hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null, cursor: string | null): void;
|
|
97
97
|
reconcile(): Promise<void>;
|
|
98
98
|
catchUp(progress: CycleProgress): Promise<void>;
|
|
99
99
|
resend(progress: CycleProgress): Promise<void>;
|
|
100
100
|
current(): boolean;
|
|
101
101
|
known(): boolean;
|
|
102
|
-
|
|
102
|
+
learned(): void;
|
|
103
103
|
reopened(): void;
|
|
104
104
|
lost(): void;
|
|
105
105
|
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,iBAAiB,EAEjB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAElB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,aAAa,EACb,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIxE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAkB,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGlG,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC;AAEpE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EA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|
|
3
3
|
import { refusedForSpace } from './durability.js';
|
|
4
|
-
import { declaredFile } from './file.js';
|
|
5
4
|
import { changeBatchIdentity, chatDraftRevision } from './identity.js';
|
|
6
5
|
import { OFFLINE } from './outcome.js';
|
|
6
|
+
import { untilAnswered } from './recovery.js';
|
|
7
7
|
import { capped, cursorOf, decodedCursor, FROM_START, messageOrder, precedes } from './windows.js';
|
|
8
8
|
const QUIET = {
|
|
9
9
|
turn: null,
|
|
@@ -12,6 +12,7 @@ const QUIET = {
|
|
|
12
12
|
commands: [],
|
|
13
13
|
options: [],
|
|
14
14
|
starting: null,
|
|
15
|
+
subagents: [],
|
|
15
16
|
link: null,
|
|
16
17
|
deliveryUnknown: [],
|
|
17
18
|
};
|
|
@@ -21,6 +22,7 @@ const FACTS = [
|
|
|
21
22
|
'commands',
|
|
22
23
|
'options',
|
|
23
24
|
'starting',
|
|
25
|
+
'subagents',
|
|
24
26
|
'link',
|
|
25
27
|
'deliveryUnknown',
|
|
26
28
|
];
|
|
@@ -34,6 +36,7 @@ export function unheldView(conversation) {
|
|
|
34
36
|
commands: [],
|
|
35
37
|
options: [],
|
|
36
38
|
starting: null,
|
|
39
|
+
subagents: [],
|
|
37
40
|
link: null,
|
|
38
41
|
deliveryUnknown: [],
|
|
39
42
|
chatDraft: null,
|
|
@@ -256,13 +259,19 @@ export function createConversationStore(deps) {
|
|
|
256
259
|
const unsent = new Map();
|
|
257
260
|
const views = new Map();
|
|
258
261
|
const listing = new Map();
|
|
262
|
+
let relisting = null;
|
|
263
|
+
let listCursor = null;
|
|
259
264
|
const creations = new Set();
|
|
260
265
|
const listWatchers = new Set();
|
|
266
|
+
const unlisted = new Set();
|
|
261
267
|
let listKnown = false;
|
|
268
|
+
let listHeld = false;
|
|
269
|
+
let listKept = false;
|
|
262
270
|
const agentWatchers = new Set();
|
|
263
|
-
|
|
264
|
-
let
|
|
265
|
-
let
|
|
271
|
+
const unnamed = new Set();
|
|
272
|
+
let agentsShown = null;
|
|
273
|
+
let listedAgents = null;
|
|
274
|
+
let agentsReading = false;
|
|
266
275
|
let replicated = new Set();
|
|
267
276
|
let handedReplicated;
|
|
268
277
|
function liveOf(conversation) {
|
|
@@ -286,6 +295,7 @@ export function createConversationStore(deps) {
|
|
|
286
295
|
commands: structuredClone(facts.commands),
|
|
287
296
|
options: structuredClone(facts.options),
|
|
288
297
|
starting: facts.starting,
|
|
298
|
+
subagents: structuredClone(facts.subagents),
|
|
289
299
|
link: facts.link === null ? null : { ...facts.link },
|
|
290
300
|
deliveryUnknown: [...facts.deliveryUnknown],
|
|
291
301
|
chatDraft: draft === undefined || unwritten(draft)
|
|
@@ -341,7 +351,7 @@ export function createConversationStore(deps) {
|
|
|
341
351
|
function entries() {
|
|
342
352
|
return [...listing.values()].map((entry) => ({
|
|
343
353
|
conversation: entry.conversation,
|
|
344
|
-
agent: { identity: entry.agent, name:
|
|
354
|
+
agent: { identity: entry.agent, name: entry.agentName },
|
|
345
355
|
name: entry.name,
|
|
346
356
|
created: entry.created,
|
|
347
357
|
finished: entry.finished,
|
|
@@ -351,25 +361,100 @@ export function createConversationStore(deps) {
|
|
|
351
361
|
started: lives.get(entry.conversation)?.turn?.started ?? null,
|
|
352
362
|
}));
|
|
353
363
|
}
|
|
364
|
+
function keepList() {
|
|
365
|
+
if (!listKnown || listKept)
|
|
366
|
+
return;
|
|
367
|
+
listKept = true;
|
|
368
|
+
queueMicrotask(() => {
|
|
369
|
+
listKept = false;
|
|
370
|
+
if (deps.closed())
|
|
371
|
+
return;
|
|
372
|
+
const entries = [...listing.values()];
|
|
373
|
+
const cursor = listCursor;
|
|
374
|
+
void deps
|
|
375
|
+
.durably(async (local) => {
|
|
376
|
+
await local.fact('conversationList', entries);
|
|
377
|
+
await local.fact('conversationCursor', cursor);
|
|
378
|
+
})
|
|
379
|
+
.catch(() => { });
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function listed(entry) {
|
|
383
|
+
listing.set(entry.conversation, { ...entry });
|
|
384
|
+
creations.delete(entry.conversation);
|
|
385
|
+
}
|
|
354
386
|
function emitList() {
|
|
355
|
-
if (deps.closed()
|
|
387
|
+
if (deps.closed())
|
|
356
388
|
return;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
watcher
|
|
389
|
+
if (listWatchers.size > 0) {
|
|
390
|
+
const value = entries();
|
|
391
|
+
for (const watcher of listWatchers)
|
|
392
|
+
watcher(value);
|
|
393
|
+
}
|
|
394
|
+
emitAgents();
|
|
395
|
+
learned();
|
|
396
|
+
}
|
|
397
|
+
function learned() {
|
|
398
|
+
if (deps.closed())
|
|
399
|
+
return;
|
|
400
|
+
if (!listKnown && !listHeld && deps.stream() !== undefined && deps.online())
|
|
401
|
+
return;
|
|
402
|
+
if (unlisted.size > 0) {
|
|
403
|
+
const value = entries();
|
|
404
|
+
for (const watcher of [...unlisted]) {
|
|
405
|
+
unlisted.delete(watcher);
|
|
406
|
+
listWatchers.add(watcher);
|
|
407
|
+
watcher(value);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (unnamed.size > 0) {
|
|
411
|
+
const value = agents();
|
|
412
|
+
for (const watcher of [...unnamed]) {
|
|
413
|
+
unnamed.delete(watcher);
|
|
414
|
+
agentWatchers.add(watcher);
|
|
415
|
+
watcher(value);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
360
418
|
}
|
|
361
419
|
function agents() {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
.
|
|
420
|
+
const named = new Map();
|
|
421
|
+
for (const agent of listedAgents ?? [])
|
|
422
|
+
named.set(agent.agent, agent);
|
|
423
|
+
for (const entry of listing.values()) {
|
|
424
|
+
named.set(entry.agent, { name: entry.agentName, retired: entry.agentRetired });
|
|
425
|
+
}
|
|
426
|
+
return [...named]
|
|
427
|
+
.filter(([, agent]) => !agent.retired)
|
|
428
|
+
.map(([identity, agent]) => ({ identity, name: agent.name }))
|
|
365
429
|
.sort((left, right) => left.name === right.name
|
|
366
430
|
? left.identity.localeCompare(right.identity)
|
|
367
431
|
: left.name.localeCompare(right.name));
|
|
368
432
|
}
|
|
433
|
+
function readAgents() {
|
|
434
|
+
const stream = deps.stream();
|
|
435
|
+
if (stream?.agents === undefined || !deps.online() || agentsReading)
|
|
436
|
+
return;
|
|
437
|
+
agentsReading = true;
|
|
438
|
+
void stream
|
|
439
|
+
.agents()
|
|
440
|
+
.then((read) => {
|
|
441
|
+
if (read === null)
|
|
442
|
+
return;
|
|
443
|
+
listedAgents = read;
|
|
444
|
+
emitAgents();
|
|
445
|
+
}, () => { })
|
|
446
|
+
.finally(() => {
|
|
447
|
+
agentsReading = false;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
369
450
|
function emitAgents() {
|
|
370
451
|
if (deps.closed() || agentWatchers.size === 0)
|
|
371
452
|
return;
|
|
372
453
|
const value = agents();
|
|
454
|
+
const shown = JSON.stringify(value);
|
|
455
|
+
if (shown === agentsShown)
|
|
456
|
+
return;
|
|
457
|
+
agentsShown = shown;
|
|
373
458
|
for (const watcher of agentWatchers)
|
|
374
459
|
watcher(value);
|
|
375
460
|
}
|
|
@@ -385,55 +470,11 @@ export function createConversationStore(deps) {
|
|
|
385
470
|
if (stateOf(conversation) !== before || next?.turn?.started !== began)
|
|
386
471
|
emitList();
|
|
387
472
|
}
|
|
388
|
-
async function readAgents() {
|
|
389
|
-
const declaration = deps.agents();
|
|
390
|
-
if (declaration === undefined)
|
|
391
|
-
return;
|
|
392
|
-
const names = new Map();
|
|
393
|
-
const retired = new Set();
|
|
394
|
-
let covered = null;
|
|
395
|
-
for (let after;;) {
|
|
396
|
-
const read = await deps.documents(declaration, after);
|
|
397
|
-
if ('pending' in read)
|
|
398
|
-
return;
|
|
399
|
-
const coverage = JSON.stringify(read.coverage);
|
|
400
|
-
if (covered !== null && coverage !== covered)
|
|
401
|
-
return readAgents();
|
|
402
|
-
covered = coverage;
|
|
403
|
-
for (const document of read.documents) {
|
|
404
|
-
const identity = document.fields?.[declaration.identity];
|
|
405
|
-
const name = document.fields?.[declaration.name];
|
|
406
|
-
if (typeof identity !== 'string' || typeof name !== 'string')
|
|
407
|
-
continue;
|
|
408
|
-
names.set(identity, name);
|
|
409
|
-
const ended = declaration.retired === undefined ? null : document.fields?.[declaration.retired];
|
|
410
|
-
if (ended !== undefined && ended !== null)
|
|
411
|
-
retired.add(identity);
|
|
412
|
-
}
|
|
413
|
-
if (read.next === undefined)
|
|
414
|
-
break;
|
|
415
|
-
after = read.next;
|
|
416
|
-
}
|
|
417
|
-
const named = JSON.stringify([...names]) !== JSON.stringify([...agentNames]);
|
|
418
|
-
if (!named && JSON.stringify([...retired]) === JSON.stringify([...retiredAgents]))
|
|
419
|
-
return;
|
|
420
|
-
agentNames = names;
|
|
421
|
-
retiredAgents = retired;
|
|
422
|
-
if (named)
|
|
423
|
-
emitList();
|
|
424
|
-
emitAgents();
|
|
425
|
-
const ended = [...drafts.keys()].filter(retiredChat);
|
|
426
|
-
if (ended.length > 0)
|
|
427
|
-
await remove(ended);
|
|
428
|
-
}
|
|
429
473
|
function retiredChat(conversation) {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
agentsRead = null;
|
|
435
|
-
});
|
|
436
|
-
return agentsRead;
|
|
474
|
+
if (!conversation.startsWith(NEW_CHAT))
|
|
475
|
+
return false;
|
|
476
|
+
const agent = conversation.slice(NEW_CHAT.length);
|
|
477
|
+
return [...listing.values()].some((entry) => entry.agent === agent && entry.agentRetired);
|
|
437
478
|
}
|
|
438
479
|
function live(conversation, change) {
|
|
439
480
|
const owed = unsent.get(conversation);
|
|
@@ -456,6 +497,7 @@ export function createConversationStore(deps) {
|
|
|
456
497
|
commands: facts.has('commands') ? QUIET.commands : held.commands,
|
|
457
498
|
options: facts.has('options') ? QUIET.options : held.options,
|
|
458
499
|
starting: facts.has('starting') ? QUIET.starting : held.starting,
|
|
500
|
+
subagents: facts.has('subagents') ? QUIET.subagents : held.subagents,
|
|
459
501
|
link: facts.has('link') ? QUIET.link : held.link,
|
|
460
502
|
deliveryUnknown: facts.has('deliveryUnknown')
|
|
461
503
|
? QUIET.deliveryUnknown
|
|
@@ -509,6 +551,20 @@ export function createConversationStore(deps) {
|
|
|
509
551
|
deps.publish(conversationChangeSet(changed));
|
|
510
552
|
});
|
|
511
553
|
}
|
|
554
|
+
function missed(conversation) {
|
|
555
|
+
const read = reads.get(conversation);
|
|
556
|
+
const newest = listing.get(conversation)?.newest;
|
|
557
|
+
return (read === undefined ||
|
|
558
|
+
newest === undefined ||
|
|
559
|
+
partials.has(conversation) ||
|
|
560
|
+
(newest !== null && (read === null || newest > read)));
|
|
561
|
+
}
|
|
562
|
+
function noted(conversation, message) {
|
|
563
|
+
const entry = listing.get(conversation);
|
|
564
|
+
if (entry === undefined || (entry.newest !== null && entry.newest >= message.position))
|
|
565
|
+
return;
|
|
566
|
+
listing.set(conversation, { ...entry, newest: message.position });
|
|
567
|
+
}
|
|
512
568
|
function gap(conversation) {
|
|
513
569
|
gaps.set(conversation, (gaps.get(conversation) ?? 0) + 1);
|
|
514
570
|
behind.add(conversation);
|
|
@@ -543,7 +599,7 @@ export function createConversationStore(deps) {
|
|
|
543
599
|
}));
|
|
544
600
|
while (waiting.length > 0) {
|
|
545
601
|
const asking = waiting.slice(0, HISTORY_CONVERSATIONS);
|
|
546
|
-
const result = await deps.
|
|
602
|
+
const result = await deps.history({
|
|
547
603
|
conversations: asking.map(({ conversation, after }) => ({
|
|
548
604
|
conversation,
|
|
549
605
|
...(after === undefined ? {} : { after }),
|
|
@@ -646,6 +702,10 @@ export function createConversationStore(deps) {
|
|
|
646
702
|
live(conversation, { starting: event.step });
|
|
647
703
|
return;
|
|
648
704
|
}
|
|
705
|
+
if (event.kind === 'subagents') {
|
|
706
|
+
live(conversation, { subagents: structuredClone(event.subagents) });
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
649
709
|
if (event.kind === 'link') {
|
|
650
710
|
live(conversation, { link: { connected: event.connected } });
|
|
651
711
|
return;
|
|
@@ -657,6 +717,7 @@ export function createConversationStore(deps) {
|
|
|
657
717
|
const arriving = acceptedMessage(event.message);
|
|
658
718
|
if (arriving === null)
|
|
659
719
|
return;
|
|
720
|
+
noted(conversation, arriving);
|
|
660
721
|
if (replicated.has(conversation)) {
|
|
661
722
|
if (deps.full()) {
|
|
662
723
|
gap(conversation);
|
|
@@ -753,9 +814,9 @@ export function createConversationStore(deps) {
|
|
|
753
814
|
const dispatch = { answered: false };
|
|
754
815
|
sending.set(submission.operation, dispatch);
|
|
755
816
|
try {
|
|
756
|
-
const result = await invoke('
|
|
757
|
-
text: submission.text,
|
|
817
|
+
const result = await invoke('conversations/send', conversation, {
|
|
758
818
|
operation_id: submission.operation,
|
|
819
|
+
text: submission.text,
|
|
759
820
|
});
|
|
760
821
|
dispatch.answered = result.kind !== 'transport-uncertainty';
|
|
761
822
|
if (result.kind === 'revoked-authorization')
|
|
@@ -764,7 +825,7 @@ export function createConversationStore(deps) {
|
|
|
764
825
|
deps.unanswered();
|
|
765
826
|
return result;
|
|
766
827
|
}
|
|
767
|
-
const turn = answered(result, '
|
|
828
|
+
const turn = answered(result, 'message_id');
|
|
768
829
|
await withDraft(conversation, async (current, local) => {
|
|
769
830
|
const held = current?.submitted?.find((one) => one.operation === submission.operation);
|
|
770
831
|
if (current === undefined || held === undefined || held.turn !== null)
|
|
@@ -784,13 +845,20 @@ export function createConversationStore(deps) {
|
|
|
784
845
|
sending.delete(submission.operation);
|
|
785
846
|
}
|
|
786
847
|
}
|
|
787
|
-
function invoke(name, conversation, extra = {}) {
|
|
788
|
-
return deps.call(name, { conversation, ...extra });
|
|
848
|
+
function invoke(name, conversation, extra = { operation_id: changeBatchIdentity() }) {
|
|
849
|
+
return deps.call(name, { conversation_id: conversation, ...extra });
|
|
789
850
|
}
|
|
790
851
|
const surface = {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
852
|
+
list() {
|
|
853
|
+
return new Promise((settle) => {
|
|
854
|
+
const answer = (listed) => {
|
|
855
|
+
unlisted.delete(answer);
|
|
856
|
+
listWatchers.delete(answer);
|
|
857
|
+
settle(listed);
|
|
858
|
+
};
|
|
859
|
+
unlisted.add(answer);
|
|
860
|
+
learned();
|
|
861
|
+
});
|
|
794
862
|
},
|
|
795
863
|
async read(conversation, options = {}) {
|
|
796
864
|
const asked = askedOf(options);
|
|
@@ -801,8 +869,8 @@ export function createConversationStore(deps) {
|
|
|
801
869
|
});
|
|
802
870
|
},
|
|
803
871
|
async create(input) {
|
|
804
|
-
const result = await deps.call('
|
|
805
|
-
const conversation = answered(result, '
|
|
872
|
+
const result = await deps.call('conversations/create', input);
|
|
873
|
+
const conversation = answered(result, 'conversation_id');
|
|
806
874
|
if (conversation === null)
|
|
807
875
|
return result;
|
|
808
876
|
if (!listing.has(conversation))
|
|
@@ -836,38 +904,20 @@ export function createConversationStore(deps) {
|
|
|
836
904
|
}
|
|
837
905
|
return OFFLINE;
|
|
838
906
|
},
|
|
839
|
-
async attach(room, file) {
|
|
840
|
-
if (!deps.online())
|
|
841
|
-
return OFFLINE;
|
|
842
|
-
return deps.call('conversation.attach', {
|
|
843
|
-
room,
|
|
844
|
-
...(await declaredFile(file)),
|
|
845
|
-
blob: file.blob,
|
|
846
|
-
});
|
|
847
|
-
},
|
|
848
907
|
answer(conversation, answer) {
|
|
849
|
-
return invoke('
|
|
908
|
+
return invoke('conversations/interaction/answer', conversation, {
|
|
909
|
+
operation_id: changeBatchIdentity(),
|
|
910
|
+
...answer,
|
|
911
|
+
});
|
|
850
912
|
},
|
|
851
913
|
interrupt(conversation) {
|
|
852
|
-
return invoke('
|
|
914
|
+
return invoke('conversations/interrupt', conversation);
|
|
853
915
|
},
|
|
854
916
|
kill(conversation) {
|
|
855
|
-
return invoke('
|
|
856
|
-
},
|
|
857
|
-
async cancel(conversation, turn) {
|
|
858
|
-
const result = await invoke('conversation.cancel', conversation, { turn });
|
|
859
|
-
if (result.kind !== 'action')
|
|
860
|
-
return result;
|
|
861
|
-
await withDraft(conversation, (current) => {
|
|
862
|
-
const held = current?.submitted?.find((one) => one.turn === turn);
|
|
863
|
-
if (current === undefined || held === undefined)
|
|
864
|
-
return undefined;
|
|
865
|
-
return returned(current, held, current.submitted.filter((one) => one !== held));
|
|
866
|
-
});
|
|
867
|
-
return result;
|
|
917
|
+
return invoke('conversations/kill', conversation);
|
|
868
918
|
},
|
|
869
919
|
delete(conversation) {
|
|
870
|
-
return invoke('
|
|
920
|
+
return invoke('conversations/delete', conversation);
|
|
871
921
|
},
|
|
872
922
|
};
|
|
873
923
|
const chatDraft = {
|
|
@@ -896,7 +946,15 @@ export function createConversationStore(deps) {
|
|
|
896
946
|
return {
|
|
897
947
|
surface,
|
|
898
948
|
chatDraft,
|
|
899
|
-
hydrate(held, kept) {
|
|
949
|
+
hydrate(held, kept, list, cursor) {
|
|
950
|
+
if (list !== null && !listKnown) {
|
|
951
|
+
listing.clear();
|
|
952
|
+
for (const entry of list)
|
|
953
|
+
listing.set(entry.conversation, { ...entry });
|
|
954
|
+
listHeld = true;
|
|
955
|
+
listCursor = cursor;
|
|
956
|
+
deps.stream()?.hold(cursor);
|
|
957
|
+
}
|
|
900
958
|
stored.clear();
|
|
901
959
|
reads.clear();
|
|
902
960
|
partials.clear();
|
|
@@ -910,6 +968,8 @@ export function createConversationStore(deps) {
|
|
|
910
968
|
drafts.clear();
|
|
911
969
|
for (const record of kept)
|
|
912
970
|
drafts.set(record.conversation, record);
|
|
971
|
+
if (listHeld)
|
|
972
|
+
learned();
|
|
913
973
|
},
|
|
914
974
|
async reconcile() {
|
|
915
975
|
if (!listKnown)
|
|
@@ -921,7 +981,7 @@ export function createConversationStore(deps) {
|
|
|
921
981
|
!creations.has(conversation) &&
|
|
922
982
|
(!conversation.startsWith(NEW_CHAT) || retiredChat(conversation)));
|
|
923
983
|
for (const conversation of named) {
|
|
924
|
-
if (!replicated.has(conversation))
|
|
984
|
+
if (!replicated.has(conversation) && missed(conversation))
|
|
925
985
|
behind.add(conversation);
|
|
926
986
|
}
|
|
927
987
|
replicated = named;
|
|
@@ -983,11 +1043,8 @@ export function createConversationStore(deps) {
|
|
|
983
1043
|
known() {
|
|
984
1044
|
return listKnown;
|
|
985
1045
|
},
|
|
986
|
-
reconnected() {
|
|
987
|
-
for (const conversation of replicated)
|
|
988
|
-
gap(conversation);
|
|
989
|
-
},
|
|
990
1046
|
reopened() {
|
|
1047
|
+
relisting = null;
|
|
991
1048
|
for (const [operation, dispatch] of sending)
|
|
992
1049
|
if (!dispatch.answered)
|
|
993
1050
|
sending.delete(operation);
|
|
@@ -1009,15 +1066,15 @@ export function createConversationStore(deps) {
|
|
|
1009
1066
|
views.set(key, view);
|
|
1010
1067
|
const watcher = { notify: deliver, ready: false };
|
|
1011
1068
|
view.watchers.add(watcher);
|
|
1012
|
-
|
|
1013
|
-
|
|
1069
|
+
const reading = new AbortController();
|
|
1070
|
+
void untilAnswered(() => deps.durably(async (local) => {
|
|
1014
1071
|
if (view.window !== null)
|
|
1015
1072
|
return;
|
|
1016
1073
|
const { messages, more } = await local.messageWindow(conversation, asked.limit, asked.before);
|
|
1017
1074
|
view.window = messages;
|
|
1018
1075
|
view.more = more;
|
|
1019
1076
|
view.total = asked.total ? await local.messageCount(conversation) : null;
|
|
1020
|
-
})
|
|
1077
|
+
}), reading.signal)
|
|
1021
1078
|
.then(() => {
|
|
1022
1079
|
if (deps.closed() || !view.watchers.has(watcher))
|
|
1023
1080
|
return;
|
|
@@ -1027,6 +1084,7 @@ export function createConversationStore(deps) {
|
|
|
1027
1084
|
})
|
|
1028
1085
|
.catch(() => { });
|
|
1029
1086
|
return () => {
|
|
1087
|
+
reading.abort();
|
|
1030
1088
|
if (!view.watchers.delete(watcher))
|
|
1031
1089
|
return;
|
|
1032
1090
|
if (view.watchers.size === 0)
|
|
@@ -1034,61 +1092,76 @@ export function createConversationStore(deps) {
|
|
|
1034
1092
|
};
|
|
1035
1093
|
},
|
|
1036
1094
|
watchList(deliver) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
if (!deps.closed() && listWatchers.has(deliver))
|
|
1040
|
-
deliver(entries());
|
|
1041
|
-
});
|
|
1095
|
+
unlisted.add(deliver);
|
|
1096
|
+
learned();
|
|
1042
1097
|
return () => {
|
|
1098
|
+
unlisted.delete(deliver);
|
|
1043
1099
|
listWatchers.delete(deliver);
|
|
1044
1100
|
};
|
|
1045
1101
|
},
|
|
1046
1102
|
watchAgents(deliver) {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
deliver(agents());
|
|
1051
|
-
});
|
|
1103
|
+
unnamed.add(deliver);
|
|
1104
|
+
learned();
|
|
1105
|
+
readAgents();
|
|
1052
1106
|
return () => {
|
|
1107
|
+
unnamed.delete(deliver);
|
|
1053
1108
|
agentWatchers.delete(deliver);
|
|
1054
1109
|
};
|
|
1055
1110
|
},
|
|
1111
|
+
learned,
|
|
1056
1112
|
changed(set) {
|
|
1057
1113
|
for (const conversation of set.conversations)
|
|
1058
1114
|
emit(conversation);
|
|
1059
|
-
const declaration = deps.agents();
|
|
1060
|
-
if (declaration !== undefined &&
|
|
1061
|
-
set.documents.some((change) => change.locator === declaration.locator)) {
|
|
1062
|
-
agentsRead = readAgents().catch(() => {
|
|
1063
|
-
agentsRead = null;
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
1115
|
},
|
|
1067
1116
|
receive(event) {
|
|
1068
1117
|
if (deps.closed())
|
|
1069
1118
|
return false;
|
|
1070
1119
|
if (event.kind === 'list' || event.kind === 'listed' || event.kind === 'unlisted') {
|
|
1071
1120
|
if (event.kind === 'list') {
|
|
1072
|
-
|
|
1121
|
+
if (event.whole)
|
|
1122
|
+
relisting ??= new Map();
|
|
1073
1123
|
for (const entry of event.entries) {
|
|
1074
|
-
|
|
1075
|
-
|
|
1124
|
+
if (relisting === null)
|
|
1125
|
+
listed(entry);
|
|
1126
|
+
else
|
|
1127
|
+
relisting.set(entry.conversation, { ...entry });
|
|
1076
1128
|
}
|
|
1129
|
+
if (event.more)
|
|
1130
|
+
return false;
|
|
1131
|
+
if (relisting !== null) {
|
|
1132
|
+
listing.clear();
|
|
1133
|
+
for (const entry of relisting.values())
|
|
1134
|
+
listed(entry);
|
|
1135
|
+
relisting = null;
|
|
1136
|
+
}
|
|
1137
|
+
listCursor = event.cursor;
|
|
1138
|
+
deps.stream()?.hold(event.cursor);
|
|
1077
1139
|
listKnown = true;
|
|
1140
|
+
for (const conversation of replicated) {
|
|
1141
|
+
if (!listing.has(conversation))
|
|
1142
|
+
continue;
|
|
1143
|
+
if (!missed(conversation))
|
|
1144
|
+
behind.delete(conversation);
|
|
1145
|
+
else if (!behind.has(conversation))
|
|
1146
|
+
gap(conversation);
|
|
1147
|
+
}
|
|
1078
1148
|
openingEnded();
|
|
1079
1149
|
}
|
|
1080
1150
|
else if (event.kind === 'listed') {
|
|
1081
|
-
|
|
1082
|
-
|
|
1151
|
+
listed(event.entry);
|
|
1152
|
+
relisting?.set(event.entry.conversation, { ...event.entry });
|
|
1083
1153
|
}
|
|
1084
1154
|
else {
|
|
1085
1155
|
listing.delete(event.conversation);
|
|
1156
|
+
relisting?.delete(event.conversation);
|
|
1086
1157
|
}
|
|
1158
|
+
keepList();
|
|
1087
1159
|
emitList();
|
|
1088
|
-
return (event.kind !== 'list' &&
|
|
1160
|
+
return ((event.kind !== 'list' &&
|
|
1089
1161
|
listKnown &&
|
|
1090
1162
|
(listing.size !== replicated.size ||
|
|
1091
|
-
[...listing.keys()].some((conversation) => !replicated.has(conversation))))
|
|
1163
|
+
[...listing.keys()].some((conversation) => !replicated.has(conversation)))) ||
|
|
1164
|
+
(listKnown && [...drafts.keys()].some(retiredChat)));
|
|
1092
1165
|
}
|
|
1093
1166
|
heard(event);
|
|
1094
1167
|
return false;
|
|
@@ -1104,7 +1177,9 @@ export function createConversationStore(deps) {
|
|
|
1104
1177
|
lives.clear();
|
|
1105
1178
|
unsent.clear();
|
|
1106
1179
|
listWatchers.clear();
|
|
1180
|
+
unlisted.clear();
|
|
1107
1181
|
agentWatchers.clear();
|
|
1182
|
+
unnamed.clear();
|
|
1108
1183
|
},
|
|
1109
1184
|
};
|
|
1110
1185
|
}
|