@agentshouse/mdruntime 0.1.0-c069136dcb4e8 → 0.1.0-c09bf842921ff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/adapter.d.ts +51 -22
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -56
- package/dist/bootstrap.d.ts +2 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +9 -8
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/client.d.ts +9 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -1
- package/dist/collection.d.ts +2 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/compile.d.ts +1 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +90 -277
- package/dist/connection.d.ts +8 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +362 -313
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation.d.ts +14 -8
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +85 -67
- package/dist/durability.d.ts +6 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +16 -7
- package/dist/host.d.ts +3 -6
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +16 -23
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/job.d.ts +14 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +28 -0
- package/dist/live.d.ts +2 -1
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +10 -7
- package/dist/memory.d.ts +8 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +116 -66
- package/dist/messages.d.ts +2 -2
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +15 -16
- package/dist/model.d.ts +2 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -3
- package/dist/observation.d.ts +2 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +7 -2
- package/dist/query.d.ts +4 -209
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/reach.d.ts +7 -7
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +33 -44
- package/dist/react.d.ts +3 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +0 -2
- package/dist/readiness.d.ts.map +1 -1
- package/dist/refresh.d.ts +2 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +25 -1
- package/dist/replica.d.ts +8 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +27 -9
- package/dist/room-draft.d.ts +4 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +65 -52
- package/dist/rows.d.ts +14 -21
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +48 -184
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +1 -1
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/store.d.ts +5 -7
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +11 -15
- package/dist/stored.d.ts +3 -4
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +90 -126
- package/dist/tables.d.ts +8 -6
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +22 -13
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +7 -4
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +9 -4
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +3 -1
- package/package.json +2 -2
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -370
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIpD"}
|
package/dist/context.js
ADDED
package/dist/conversation.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConversationAction, ConversationEvent, ConversationMessage, ConversationStream, ListedConversation, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
|
|
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
3
|
import type { Open } from './open.js';
|
|
4
4
|
import { type CallResult, type Offline } from './outcome.js';
|
|
@@ -37,6 +37,9 @@ export type ConversationOptions = {
|
|
|
37
37
|
after?: string;
|
|
38
38
|
total?: true;
|
|
39
39
|
};
|
|
40
|
+
export type ConversationRead = ConversationOptions & {
|
|
41
|
+
text?: string;
|
|
42
|
+
};
|
|
40
43
|
export type ConversationView = {
|
|
41
44
|
conversation: string;
|
|
42
45
|
messages: readonly ConversationMessage[];
|
|
@@ -47,9 +50,11 @@ export type ConversationView = {
|
|
|
47
50
|
process: {
|
|
48
51
|
running: boolean;
|
|
49
52
|
} | null;
|
|
53
|
+
processEnded: string | null;
|
|
50
54
|
commands: readonly ProcessCommand[];
|
|
51
55
|
options: readonly SessionOption[];
|
|
52
56
|
starting: string | null;
|
|
57
|
+
subagents: readonly RunningSubagent[];
|
|
53
58
|
link: {
|
|
54
59
|
connected: boolean;
|
|
55
60
|
} | null;
|
|
@@ -60,15 +65,18 @@ export type ConversationView = {
|
|
|
60
65
|
};
|
|
61
66
|
export type ConversationSurface = {
|
|
62
67
|
list(): Promise<readonly ConversationEntry[]>;
|
|
63
|
-
read(conversation: string, options?:
|
|
68
|
+
read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
|
|
64
69
|
create(input: unknown): Promise<CallResult>;
|
|
65
70
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
66
|
-
answer(conversation: string, answer:
|
|
71
|
+
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
67
72
|
interrupt(conversation: string): Promise<CallResult>;
|
|
68
73
|
kill(conversation: string): Promise<CallResult>;
|
|
69
|
-
cancel(conversation: string, turn: string): Promise<CallResult>;
|
|
70
74
|
delete(conversation: string): Promise<CallResult>;
|
|
71
75
|
};
|
|
76
|
+
export type ConversationAnswer = {
|
|
77
|
+
interaction_id: string;
|
|
78
|
+
response: unknown;
|
|
79
|
+
};
|
|
72
80
|
export type ChatDraftSurface = {
|
|
73
81
|
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
74
82
|
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
@@ -76,6 +84,7 @@ export type ChatDraftSurface = {
|
|
|
76
84
|
};
|
|
77
85
|
export type ConversationDependencies = {
|
|
78
86
|
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
87
|
+
history(request: ConversationHistoryRequest): Promise<CallResult>;
|
|
79
88
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
80
89
|
stream(): ConversationStream | undefined;
|
|
81
90
|
publish(set: ChangeSet): void;
|
|
@@ -83,12 +92,11 @@ export type ConversationDependencies = {
|
|
|
83
92
|
full(): boolean;
|
|
84
93
|
closed(): boolean;
|
|
85
94
|
unanswered(): void;
|
|
86
|
-
expired(operation: string): boolean;
|
|
87
95
|
};
|
|
88
96
|
export type ConversationStore = {
|
|
89
97
|
surface: ConversationSurface;
|
|
90
98
|
chatDraft: ChatDraftSurface;
|
|
91
|
-
hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null): void;
|
|
99
|
+
hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null, cursor: string | null): void;
|
|
92
100
|
reconcile(): Promise<void>;
|
|
93
101
|
catchUp(progress: CycleProgress): Promise<void>;
|
|
94
102
|
resend(progress: CycleProgress): Promise<void>;
|
|
@@ -102,8 +110,6 @@ export type ConversationStore = {
|
|
|
102
110
|
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
103
111
|
changed(set: ChangeSet): void;
|
|
104
112
|
receive(event: ConversationEvent): boolean;
|
|
105
|
-
searchable(): readonly string[];
|
|
106
|
-
acquired(conversation: string): boolean;
|
|
107
113
|
close(): void;
|
|
108
114
|
};
|
|
109
115
|
export declare function unheldView(conversation: string): ConversationView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AACA,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,EAAk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AAM,GAAG,gBAAgB,CAgBjE;AAED,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAIjD,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAmQD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CAw7BzF"}
|
package/dist/conversation.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { cursorOf, decodedCursor } from '@agentshouse/mdmodel';
|
|
1
2
|
import { conversationChangeSet } from './change-set.js';
|
|
2
3
|
import { runtimeError } from './failure.js';
|
|
3
4
|
import { refusedForSpace } from './durability.js';
|
|
4
5
|
import { changeBatchIdentity, chatDraftRevision } from './identity.js';
|
|
5
6
|
import { OFFLINE } from './outcome.js';
|
|
6
7
|
import { untilAnswered } from './recovery.js';
|
|
7
|
-
import { capped,
|
|
8
|
+
import { capped, FROM_START, messageOrder, precedes } from './windows.js';
|
|
8
9
|
const QUIET = {
|
|
9
10
|
turn: null,
|
|
10
11
|
questions: [],
|
|
@@ -12,6 +13,7 @@ const QUIET = {
|
|
|
12
13
|
commands: [],
|
|
13
14
|
options: [],
|
|
14
15
|
starting: null,
|
|
16
|
+
subagents: [],
|
|
15
17
|
link: null,
|
|
16
18
|
deliveryUnknown: [],
|
|
17
19
|
};
|
|
@@ -21,6 +23,7 @@ const FACTS = [
|
|
|
21
23
|
'commands',
|
|
22
24
|
'options',
|
|
23
25
|
'starting',
|
|
26
|
+
'subagents',
|
|
24
27
|
'link',
|
|
25
28
|
'deliveryUnknown',
|
|
26
29
|
];
|
|
@@ -31,9 +34,11 @@ export function unheldView(conversation) {
|
|
|
31
34
|
turn: null,
|
|
32
35
|
questions: [],
|
|
33
36
|
process: null,
|
|
37
|
+
processEnded: null,
|
|
34
38
|
commands: [],
|
|
35
39
|
options: [],
|
|
36
40
|
starting: null,
|
|
41
|
+
subagents: [],
|
|
37
42
|
link: null,
|
|
38
43
|
deliveryUnknown: [],
|
|
39
44
|
chatDraft: null,
|
|
@@ -48,10 +53,8 @@ export function newChat(agent) {
|
|
|
48
53
|
function creationOf(input) {
|
|
49
54
|
if (typeof input !== 'object' || input === null)
|
|
50
55
|
return null;
|
|
51
|
-
const { agent_id: agent, operation_id: operation
|
|
52
|
-
return typeof agent === 'string' && typeof operation === 'string'
|
|
53
|
-
? { agent, operation }
|
|
54
|
-
: null;
|
|
56
|
+
const { agent_id: agent, operation_id: operation } = input;
|
|
57
|
+
return typeof agent === 'string' && typeof operation === 'string' ? { agent, operation } : null;
|
|
55
58
|
}
|
|
56
59
|
function startedTurn(turn, operation) {
|
|
57
60
|
if (operation.op === 'begin')
|
|
@@ -210,7 +213,14 @@ function askedOf(options) {
|
|
|
210
213
|
}
|
|
211
214
|
return { limit: capped(limit), after, before: beforeOf(after), total: total === true };
|
|
212
215
|
}
|
|
213
|
-
|
|
216
|
+
function phraseOf(text) {
|
|
217
|
+
if (text === undefined)
|
|
218
|
+
return null;
|
|
219
|
+
if (typeof text !== 'string' || text === '') {
|
|
220
|
+
throw runtimeError('invalid-text', 'a conversation is found by a phrase');
|
|
221
|
+
}
|
|
222
|
+
return text;
|
|
223
|
+
}
|
|
214
224
|
const DURABLE_WRITE = {
|
|
215
225
|
kind: 'rejected',
|
|
216
226
|
code: 'durable-write',
|
|
@@ -256,6 +266,8 @@ export function createConversationStore(deps) {
|
|
|
256
266
|
const unsent = new Map();
|
|
257
267
|
const views = new Map();
|
|
258
268
|
const listing = new Map();
|
|
269
|
+
let relisting = null;
|
|
270
|
+
let listCursor = null;
|
|
259
271
|
const creations = new Set();
|
|
260
272
|
const listWatchers = new Set();
|
|
261
273
|
const unlisted = new Set();
|
|
@@ -287,9 +299,11 @@ export function createConversationStore(deps) {
|
|
|
287
299
|
turn: structuredClone(facts.turn),
|
|
288
300
|
questions: structuredClone(facts.questions),
|
|
289
301
|
process: facts.process === null ? null : { ...facts.process },
|
|
302
|
+
processEnded: listing.get(conversation)?.processEnded ?? null,
|
|
290
303
|
commands: structuredClone(facts.commands),
|
|
291
304
|
options: structuredClone(facts.options),
|
|
292
305
|
starting: facts.starting,
|
|
306
|
+
subagents: structuredClone(facts.subagents),
|
|
293
307
|
link: facts.link === null ? null : { ...facts.link },
|
|
294
308
|
deliveryUnknown: [...facts.deliveryUnknown],
|
|
295
309
|
chatDraft: draft === undefined || unwritten(draft)
|
|
@@ -364,9 +378,22 @@ export function createConversationStore(deps) {
|
|
|
364
378
|
if (deps.closed())
|
|
365
379
|
return;
|
|
366
380
|
const entries = [...listing.values()];
|
|
367
|
-
|
|
381
|
+
const cursor = listCursor;
|
|
382
|
+
void deps
|
|
383
|
+
.durably(async (local) => {
|
|
384
|
+
await local.fact('conversationList', entries);
|
|
385
|
+
await local.fact('conversationCursor', cursor);
|
|
386
|
+
})
|
|
387
|
+
.catch(() => { });
|
|
368
388
|
});
|
|
369
389
|
}
|
|
390
|
+
function listed(entry) {
|
|
391
|
+
const ended = listing.get(entry.conversation)?.processEnded ?? null;
|
|
392
|
+
listing.set(entry.conversation, { ...entry });
|
|
393
|
+
creations.delete(entry.conversation);
|
|
394
|
+
if (entry.processEnded !== ended)
|
|
395
|
+
emit(entry.conversation);
|
|
396
|
+
}
|
|
370
397
|
function emitList() {
|
|
371
398
|
if (deps.closed())
|
|
372
399
|
return;
|
|
@@ -481,6 +508,7 @@ export function createConversationStore(deps) {
|
|
|
481
508
|
commands: facts.has('commands') ? QUIET.commands : held.commands,
|
|
482
509
|
options: facts.has('options') ? QUIET.options : held.options,
|
|
483
510
|
starting: facts.has('starting') ? QUIET.starting : held.starting,
|
|
511
|
+
subagents: facts.has('subagents') ? QUIET.subagents : held.subagents,
|
|
484
512
|
link: facts.has('link') ? QUIET.link : held.link,
|
|
485
513
|
deliveryUnknown: facts.has('deliveryUnknown')
|
|
486
514
|
? QUIET.deliveryUnknown
|
|
@@ -582,7 +610,7 @@ export function createConversationStore(deps) {
|
|
|
582
610
|
}));
|
|
583
611
|
while (waiting.length > 0) {
|
|
584
612
|
const asking = waiting.slice(0, HISTORY_CONVERSATIONS);
|
|
585
|
-
const result = await deps.
|
|
613
|
+
const result = await deps.history({
|
|
586
614
|
conversations: asking.map(({ conversation, after }) => ({
|
|
587
615
|
conversation,
|
|
588
616
|
...(after === undefined ? {} : { after }),
|
|
@@ -685,6 +713,10 @@ export function createConversationStore(deps) {
|
|
|
685
713
|
live(conversation, { starting: event.step });
|
|
686
714
|
return;
|
|
687
715
|
}
|
|
716
|
+
if (event.kind === 'subagents') {
|
|
717
|
+
live(conversation, { subagents: structuredClone(event.subagents) });
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
688
720
|
if (event.kind === 'link') {
|
|
689
721
|
live(conversation, { link: { connected: event.connected } });
|
|
690
722
|
return;
|
|
@@ -734,7 +766,7 @@ export function createConversationStore(deps) {
|
|
|
734
766
|
const from = newChat(agent);
|
|
735
767
|
return deps.durably(async (local) => {
|
|
736
768
|
const held = drafts.get(from);
|
|
737
|
-
const earlier =
|
|
769
|
+
const earlier = held?.moves ?? [];
|
|
738
770
|
if (earlier.includes(operation))
|
|
739
771
|
return;
|
|
740
772
|
const blank = {
|
|
@@ -763,10 +795,8 @@ export function createConversationStore(deps) {
|
|
|
763
795
|
}
|
|
764
796
|
async function submitted(conversation, operation, draft) {
|
|
765
797
|
let submission;
|
|
766
|
-
let earlier = false;
|
|
767
798
|
await withDraft(conversation, (current) => {
|
|
768
799
|
submission = current?.submitted?.find((one) => one.operation === operation);
|
|
769
|
-
earlier = submission !== undefined;
|
|
770
800
|
if (submission !== undefined)
|
|
771
801
|
return undefined;
|
|
772
802
|
const said = draft ?? current;
|
|
@@ -779,23 +809,15 @@ export function createConversationStore(deps) {
|
|
|
779
809
|
submitted: [...(current?.submitted ?? []), submission],
|
|
780
810
|
};
|
|
781
811
|
});
|
|
782
|
-
return
|
|
783
|
-
}
|
|
784
|
-
function forgotten(conversation, submission) {
|
|
785
|
-
return withDraft(conversation, (current) => {
|
|
786
|
-
const held = current?.submitted ?? [];
|
|
787
|
-
if (current === undefined || !held.includes(submission))
|
|
788
|
-
return undefined;
|
|
789
|
-
return withSubmitted(current, held.filter((one) => one !== submission));
|
|
790
|
-
});
|
|
812
|
+
return submission;
|
|
791
813
|
}
|
|
792
814
|
async function dispatched(conversation, submission) {
|
|
793
815
|
const dispatch = { answered: false };
|
|
794
816
|
sending.set(submission.operation, dispatch);
|
|
795
817
|
try {
|
|
796
|
-
const result = await invoke('
|
|
797
|
-
text: submission.text,
|
|
818
|
+
const result = await invoke('conversations/send', conversation, {
|
|
798
819
|
operation_id: submission.operation,
|
|
820
|
+
text: submission.text,
|
|
799
821
|
});
|
|
800
822
|
dispatch.answered = result.kind !== 'transport-uncertainty';
|
|
801
823
|
if (result.kind === 'revoked-authorization')
|
|
@@ -804,7 +826,7 @@ export function createConversationStore(deps) {
|
|
|
804
826
|
deps.unanswered();
|
|
805
827
|
return result;
|
|
806
828
|
}
|
|
807
|
-
const turn = answered(result, '
|
|
829
|
+
const turn = answered(result, 'message_id');
|
|
808
830
|
await withDraft(conversation, async (current, local) => {
|
|
809
831
|
const held = current?.submitted?.find((one) => one.operation === submission.operation);
|
|
810
832
|
if (current === undefined || held === undefined || held.turn !== null)
|
|
@@ -824,8 +846,8 @@ export function createConversationStore(deps) {
|
|
|
824
846
|
sending.delete(submission.operation);
|
|
825
847
|
}
|
|
826
848
|
}
|
|
827
|
-
function invoke(name, conversation, extra = {}) {
|
|
828
|
-
return deps.call(name, { conversation, ...extra });
|
|
849
|
+
function invoke(name, conversation, extra = { operation_id: changeBatchIdentity() }) {
|
|
850
|
+
return deps.call(name, { conversation_id: conversation, ...extra });
|
|
829
851
|
}
|
|
830
852
|
const surface = {
|
|
831
853
|
list() {
|
|
@@ -840,16 +862,18 @@ export function createConversationStore(deps) {
|
|
|
840
862
|
});
|
|
841
863
|
},
|
|
842
864
|
async read(conversation, options = {}) {
|
|
843
|
-
const
|
|
865
|
+
const { text, ...windowed } = options;
|
|
866
|
+
const asked = askedOf(windowed);
|
|
867
|
+
const phrase = phraseOf(text);
|
|
844
868
|
return deps.durably(async (local) => {
|
|
845
|
-
const { messages, more } = await local.messageWindow(conversation, asked.limit, asked.before);
|
|
846
|
-
const total = asked.total ? await local.messageCount(conversation) : null;
|
|
869
|
+
const { messages, more } = await local.messageWindow(conversation, asked.limit, asked.before, phrase);
|
|
870
|
+
const total = asked.total ? await local.messageCount(conversation, phrase) : null;
|
|
847
871
|
return structuredClone(viewOf(conversation, messages, frameOf(asked, messages, more, total)));
|
|
848
872
|
});
|
|
849
873
|
},
|
|
850
874
|
async create(input) {
|
|
851
|
-
const result = await deps.call('
|
|
852
|
-
const conversation = answered(result, '
|
|
875
|
+
const result = await deps.call('conversations/create', input);
|
|
876
|
+
const conversation = answered(result, 'conversation_id');
|
|
853
877
|
if (conversation === null)
|
|
854
878
|
return result;
|
|
855
879
|
if (!listing.has(conversation))
|
|
@@ -870,11 +894,7 @@ export function createConversationStore(deps) {
|
|
|
870
894
|
});
|
|
871
895
|
if (held === null)
|
|
872
896
|
return DURABLE_WRITE;
|
|
873
|
-
|
|
874
|
-
if (!earlier || !deps.expired(operation))
|
|
875
|
-
return dispatched(conversation, submission);
|
|
876
|
-
await forgotten(conversation, submission);
|
|
877
|
-
return EXPIRED;
|
|
897
|
+
return dispatched(conversation, held);
|
|
878
898
|
}
|
|
879
899
|
if (draft !== undefined) {
|
|
880
900
|
await withDraft(conversation, (current) => current?.submitted?.some((one) => one.operation === operation) === true
|
|
@@ -884,28 +904,19 @@ export function createConversationStore(deps) {
|
|
|
884
904
|
return OFFLINE;
|
|
885
905
|
},
|
|
886
906
|
answer(conversation, answer) {
|
|
887
|
-
return invoke('
|
|
907
|
+
return invoke('conversations/interaction/answer', conversation, {
|
|
908
|
+
operation_id: changeBatchIdentity(),
|
|
909
|
+
...answer,
|
|
910
|
+
});
|
|
888
911
|
},
|
|
889
912
|
interrupt(conversation) {
|
|
890
|
-
return invoke('
|
|
913
|
+
return invoke('conversations/interrupt', conversation);
|
|
891
914
|
},
|
|
892
915
|
kill(conversation) {
|
|
893
|
-
return invoke('
|
|
894
|
-
},
|
|
895
|
-
async cancel(conversation, turn) {
|
|
896
|
-
const result = await invoke('conversation.cancel', conversation, { turn });
|
|
897
|
-
if (result.kind !== 'action')
|
|
898
|
-
return result;
|
|
899
|
-
await withDraft(conversation, (current) => {
|
|
900
|
-
const held = current?.submitted?.find((one) => one.turn === turn);
|
|
901
|
-
if (current === undefined || held === undefined)
|
|
902
|
-
return undefined;
|
|
903
|
-
return returned(current, held, current.submitted.filter((one) => one !== held));
|
|
904
|
-
});
|
|
905
|
-
return result;
|
|
916
|
+
return invoke('conversations/kill', conversation);
|
|
906
917
|
},
|
|
907
918
|
delete(conversation) {
|
|
908
|
-
return invoke('
|
|
919
|
+
return invoke('conversations/delete', conversation);
|
|
909
920
|
},
|
|
910
921
|
};
|
|
911
922
|
const chatDraft = {
|
|
@@ -934,12 +945,14 @@ export function createConversationStore(deps) {
|
|
|
934
945
|
return {
|
|
935
946
|
surface,
|
|
936
947
|
chatDraft,
|
|
937
|
-
hydrate(held, kept, list) {
|
|
948
|
+
hydrate(held, kept, list, cursor) {
|
|
938
949
|
if (list !== null && !listKnown) {
|
|
939
950
|
listing.clear();
|
|
940
951
|
for (const entry of list)
|
|
941
952
|
listing.set(entry.conversation, { ...entry });
|
|
942
953
|
listHeld = true;
|
|
954
|
+
listCursor = cursor;
|
|
955
|
+
deps.stream()?.hold(cursor);
|
|
943
956
|
}
|
|
944
957
|
stored.clear();
|
|
945
958
|
reads.clear();
|
|
@@ -1005,10 +1018,6 @@ export function createConversationStore(deps) {
|
|
|
1005
1018
|
continue;
|
|
1006
1019
|
if (deps.closed())
|
|
1007
1020
|
return;
|
|
1008
|
-
if (deps.expired(submission.operation)) {
|
|
1009
|
-
await forgotten(conversation, submission);
|
|
1010
|
-
continue;
|
|
1011
|
-
}
|
|
1012
1021
|
const result = await dispatched(conversation, submission);
|
|
1013
1022
|
if (result.kind === 'revoked-authorization')
|
|
1014
1023
|
return;
|
|
@@ -1030,6 +1039,7 @@ export function createConversationStore(deps) {
|
|
|
1030
1039
|
return listKnown;
|
|
1031
1040
|
},
|
|
1032
1041
|
reopened() {
|
|
1042
|
+
relisting = null;
|
|
1033
1043
|
for (const [operation, dispatch] of sending)
|
|
1034
1044
|
if (!dispatch.answered)
|
|
1035
1045
|
sending.delete(operation);
|
|
@@ -1103,11 +1113,24 @@ export function createConversationStore(deps) {
|
|
|
1103
1113
|
return false;
|
|
1104
1114
|
if (event.kind === 'list' || event.kind === 'listed' || event.kind === 'unlisted') {
|
|
1105
1115
|
if (event.kind === 'list') {
|
|
1106
|
-
|
|
1116
|
+
if (event.whole)
|
|
1117
|
+
relisting ??= new Map();
|
|
1107
1118
|
for (const entry of event.entries) {
|
|
1108
|
-
|
|
1109
|
-
|
|
1119
|
+
if (relisting === null)
|
|
1120
|
+
listed(entry);
|
|
1121
|
+
else
|
|
1122
|
+
relisting.set(entry.conversation, { ...entry });
|
|
1110
1123
|
}
|
|
1124
|
+
if (event.more)
|
|
1125
|
+
return false;
|
|
1126
|
+
if (relisting !== null) {
|
|
1127
|
+
listing.clear();
|
|
1128
|
+
for (const entry of relisting.values())
|
|
1129
|
+
listed(entry);
|
|
1130
|
+
relisting = null;
|
|
1131
|
+
}
|
|
1132
|
+
listCursor = event.cursor;
|
|
1133
|
+
deps.stream()?.hold(event.cursor);
|
|
1111
1134
|
listKnown = true;
|
|
1112
1135
|
for (const conversation of replicated) {
|
|
1113
1136
|
if (!listing.has(conversation))
|
|
@@ -1120,11 +1143,12 @@ export function createConversationStore(deps) {
|
|
|
1120
1143
|
openingEnded();
|
|
1121
1144
|
}
|
|
1122
1145
|
else if (event.kind === 'listed') {
|
|
1123
|
-
|
|
1124
|
-
|
|
1146
|
+
listed(event.entry);
|
|
1147
|
+
relisting?.set(event.entry.conversation, { ...event.entry });
|
|
1125
1148
|
}
|
|
1126
1149
|
else {
|
|
1127
1150
|
listing.delete(event.conversation);
|
|
1151
|
+
relisting?.delete(event.conversation);
|
|
1128
1152
|
}
|
|
1129
1153
|
keepList();
|
|
1130
1154
|
emitList();
|
|
@@ -1137,12 +1161,6 @@ export function createConversationStore(deps) {
|
|
|
1137
1161
|
heard(event);
|
|
1138
1162
|
return false;
|
|
1139
1163
|
},
|
|
1140
|
-
searchable() {
|
|
1141
|
-
return [...(listKnown ? listing.keys() : stored)].sort();
|
|
1142
|
-
},
|
|
1143
|
-
acquired(conversation) {
|
|
1144
|
-
return reads.has(conversation) && !partials.has(conversation);
|
|
1145
|
-
},
|
|
1146
1164
|
close() {
|
|
1147
1165
|
views.clear();
|
|
1148
1166
|
lives.clear();
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
+
export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
|
|
3
|
+
export type UnsentWork = {
|
|
4
|
+
readonly kind: UnsentKind;
|
|
5
|
+
readonly count: number;
|
|
6
|
+
};
|
|
2
7
|
export type RuntimeShell = {
|
|
3
8
|
persistence: Persistence;
|
|
4
9
|
generation: string | null;
|
|
5
10
|
keepGeneration(value: string): void | Promise<void>;
|
|
6
11
|
dropGeneration(): void | Promise<void>;
|
|
7
12
|
cleanUp?(): Promise<number>;
|
|
13
|
+
reset(): Promise<void>;
|
|
8
14
|
};
|
|
9
15
|
export declare function refusedForSpace(error: unknown): boolean;
|
|
10
16
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
package/dist/durability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,YAAY,GAAG;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EA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AGrF"}
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
2
|
import { type QueryRows } from './query.js';
|
|
3
3
|
import type { Connection } from './tables.js';
|
|
4
|
-
export { QueryError } from '
|
|
4
|
+
export { QueryError } from '@agentshouse/mdmodel';
|
|
5
5
|
export type EntryRoom = {
|
|
6
6
|
locator: string;
|
|
7
7
|
schema: string | null;
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,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;IAC5C,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC9C,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;AAyCD,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,CACxB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU,GACrB,UAAU,CAmDZ"}
|
package/dist/entry.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { invalid, plain, QueryError, } from '@agentshouse/mdmodel';
|
|
1
2
|
import { attachedModel } from './attached-model.js';
|
|
2
3
|
import { answerQuery } from './compile.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { planWithin } from './query.js';
|
|
5
|
+
import { writtenFacts } from './rows.js';
|
|
5
6
|
import { entered, REPLICA_TABLES } from './stored.js';
|
|
6
|
-
export { QueryError } from '
|
|
7
|
+
export { QueryError } from '@agentshouse/mdmodel';
|
|
7
8
|
const PARAMETER = '$param';
|
|
8
9
|
const KIND = 'as';
|
|
9
10
|
const INTEGER = /^-?(?:0|[1-9][0-9]*)$/u;
|
|
@@ -83,6 +84,7 @@ const SAMPLED = {
|
|
|
83
84
|
$all: 'entry',
|
|
84
85
|
$size: 0,
|
|
85
86
|
$exists: true,
|
|
87
|
+
$prefix: 'entry',
|
|
86
88
|
$gt: 0,
|
|
87
89
|
$gte: 0,
|
|
88
90
|
$lt: 0,
|
|
@@ -98,9 +100,15 @@ function sampled(template, key) {
|
|
|
98
100
|
}
|
|
99
101
|
return template;
|
|
100
102
|
}
|
|
103
|
+
function entryPlan(query, facts) {
|
|
104
|
+
const plan = planWithin(query, facts);
|
|
105
|
+
if (plan.fileIds !== null)
|
|
106
|
+
invalid('fileIds', 'an entry Room holds no file IDs');
|
|
107
|
+
return plan;
|
|
108
|
+
}
|
|
101
109
|
export function entryRefusal(template) {
|
|
102
110
|
try {
|
|
103
|
-
|
|
111
|
+
entryPlan(sampled(template, ''), { listed: false, rooms: [] });
|
|
104
112
|
return null;
|
|
105
113
|
}
|
|
106
114
|
catch (error) {
|
|
@@ -117,18 +125,19 @@ export function entryScope(rooms, roomTypes, connection) {
|
|
|
117
125
|
const model = attachedModel({
|
|
118
126
|
kind: 'model',
|
|
119
127
|
snapshot: { identity: room.locator, version: '', schema: room.schema, revision: null },
|
|
120
|
-
},
|
|
128
|
+
}, roomTypes);
|
|
121
129
|
held.push({
|
|
122
130
|
locator: room.locator,
|
|
123
131
|
available: model.status !== 'unavailable',
|
|
124
132
|
types: model.status === 'unavailable' ? [] : Object.values(model.types),
|
|
125
133
|
});
|
|
126
|
-
const composition = { model, selection: null };
|
|
134
|
+
const composition = { model, selection: null, typedPaths: [] };
|
|
127
135
|
const key = entered(connection, room.locator, composition, Object.keys(room.documents)
|
|
128
136
|
.sort()
|
|
129
137
|
.map((path) => ({
|
|
130
138
|
path,
|
|
131
139
|
content: room.documents[path],
|
|
140
|
+
facts: writtenFacts(path, room.documents[path], composition),
|
|
132
141
|
binary: null,
|
|
133
142
|
revision: room.revisions?.[path] ?? null,
|
|
134
143
|
fileId: null,
|
|
@@ -142,7 +151,7 @@ export function entryScope(rooms, roomTypes, connection) {
|
|
|
142
151
|
async results(queries) {
|
|
143
152
|
const results = {};
|
|
144
153
|
for (const [name, query] of Object.entries(queries)) {
|
|
145
|
-
const plan =
|
|
154
|
+
const plan = entryPlan(query, planned);
|
|
146
155
|
results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)));
|
|
147
156
|
}
|
|
148
157
|
return results;
|
package/dist/host.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MdRuntimeOptions } from './connection.js';
|
|
2
2
|
import type { PortReach } from './reach.js';
|
|
3
|
-
import type { CodeAvailability, Persistence, Readiness
|
|
3
|
+
import type { CodeAvailability, Persistence, Readiness } from './readiness.js';
|
|
4
4
|
import type { EntrySeed } from './seed.js';
|
|
5
5
|
import { type RuntimePort } from './wire.js';
|
|
6
6
|
export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
@@ -11,21 +11,18 @@ export type AttachedPort = {
|
|
|
11
11
|
narrow(reach: PortReach): void;
|
|
12
12
|
readiness(deliver: (readiness: Readiness) => void): () => void;
|
|
13
13
|
answered(queries: readonly unknown[], done: () => void): void;
|
|
14
|
-
code(code: CodeAvailability, space: Space | null): void;
|
|
15
|
-
search(search: SearchObligation): void;
|
|
16
14
|
};
|
|
17
15
|
export type MdRuntimeHost = {
|
|
18
|
-
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability
|
|
16
|
+
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability): AttachedPort;
|
|
19
17
|
seed(entry: EntrySeed): void;
|
|
20
18
|
persisted(answer: Persistence): void;
|
|
21
19
|
endAuthorization(holder?: string): Promise<void>;
|
|
22
|
-
lose(locators: readonly string[]): Promise<void>;
|
|
23
20
|
stop(): Promise<void>;
|
|
24
21
|
};
|
|
25
22
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
26
23
|
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
27
24
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
28
|
-
export type { CodeAvailability, Persistence,
|
|
25
|
+
export type { CodeAvailability, Persistence, Space } from './readiness.js';
|
|
29
26
|
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
30
27
|
export type { RuntimePort } from './wire.js';
|
|
31
28
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAGL,KAAK,WAAW,EAOjB,MAAM,WAAW,CAAC;AAInB,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,IAAI,IAAI,CAAC;IACf,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CACJ,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,SAAS,EACjB,IAAI,CAAC,EAAE,gBAAgB,GACtB,YAAY,CAAC;IAChB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG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