@agentshouse/mdruntime 0.1.0-cebcd51f70ed1 → 0.1.0-cec6690d5712e
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 +82 -27
- package/README.md +13 -3
- package/dist/adapter.d.ts +13 -3
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +15 -2
- package/dist/attempt.d.ts +16 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +57 -0
- package/dist/bootstrap.d.ts +17 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +88 -35
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +13 -7
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/chat/acts.d.ts +34 -0
- package/dist/chat/acts.d.ts.map +1 -0
- package/dist/chat/acts.js +36 -0
- package/dist/chat/context.d.ts +3 -0
- package/dist/chat/context.d.ts.map +1 -0
- package/dist/chat/context.js +10 -0
- package/dist/chat/input.d.ts +9 -0
- package/dist/chat/input.d.ts.map +1 -0
- package/dist/chat/input.js +99 -0
- package/dist/chat/kit.d.ts +60 -0
- package/dist/chat/kit.d.ts.map +1 -0
- package/dist/chat/kit.js +123 -0
- package/dist/chat/lasting.d.ts +6 -0
- package/dist/chat/lasting.d.ts.map +1 -0
- package/dist/chat/lasting.js +19 -0
- package/dist/chat/list.d.ts +20 -0
- package/dist/chat/list.d.ts.map +1 -0
- package/dist/chat/list.js +59 -0
- package/dist/chat/markdown.d.ts +19 -0
- package/dist/chat/markdown.d.ts.map +1 -0
- package/dist/chat/markdown.js +187 -0
- package/dist/chat/message.d.ts +6 -0
- package/dist/chat/message.d.ts.map +1 -0
- package/dist/chat/message.js +192 -0
- package/dist/chat/messages.d.ts +21 -0
- package/dist/chat/messages.d.ts.map +1 -0
- package/dist/chat/messages.js +151 -0
- package/dist/chat/name.d.ts +6 -0
- package/dist/chat/name.d.ts.map +1 -0
- package/dist/chat/name.js +37 -0
- package/dist/chat/opened.d.ts +11 -0
- package/dist/chat/opened.d.ts.map +1 -0
- package/dist/chat/opened.js +17 -0
- package/dist/chat/overlay.d.ts +31 -0
- package/dist/chat/overlay.d.ts.map +1 -0
- package/dist/chat/overlay.js +97 -0
- package/dist/chat/parts.d.ts +57 -0
- package/dist/chat/parts.d.ts.map +1 -0
- package/dist/chat/parts.js +119 -0
- package/dist/chat/process.d.ts +20 -0
- package/dist/chat/process.d.ts.map +1 -0
- package/dist/chat/process.js +32 -0
- package/dist/chat/provider.d.ts +63 -0
- package/dist/chat/provider.d.ts.map +1 -0
- package/dist/chat/provider.js +645 -0
- package/dist/chat/question.d.ts +9 -0
- package/dist/chat/question.d.ts.map +1 -0
- package/dist/chat/question.js +80 -0
- package/dist/chat/questions.d.ts +31 -0
- package/dist/chat/questions.d.ts.map +1 -0
- package/dist/chat/questions.js +111 -0
- package/dist/chat/read.d.ts +5 -0
- package/dist/chat/read.d.ts.map +1 -0
- package/dist/chat/read.js +13 -0
- package/dist/chat/ready.d.ts +33 -0
- package/dist/chat/ready.d.ts.map +1 -0
- package/dist/chat/ready.js +91 -0
- package/dist/chat/style.d.ts +4 -0
- package/dist/chat/style.d.ts.map +1 -0
- package/dist/chat/style.js +302 -0
- package/dist/chat.d.ts +14 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +8 -0
- package/dist/client.d.ts +9 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +61 -15
- package/dist/collection.d.ts +6 -11
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +56 -19
- package/dist/connection.d.ts +14 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +239 -102
- package/dist/conversation.d.ts +11 -3
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +47 -7
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/host.d.ts +1 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +5 -8
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +10 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/memory.d.ts +2 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +31 -11
- package/dist/model.d.ts +10 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +2 -0
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/outcome.d.ts +22 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +35 -1
- package/dist/overlay.d.ts +1 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +19 -15
- package/dist/query.d.ts +2 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +5 -31
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +21 -19
- package/dist/react.d.ts +25 -16
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +8 -6
- package/dist/refresh.d.ts +10 -0
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +33 -24
- package/dist/replica.d.ts +5 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +44 -29
- package/dist/room-draft.d.ts +8 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +13 -22
- package/dist/rows.d.ts +2 -0
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +7 -1
- package/dist/save.d.ts +3 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +38 -21
- package/dist/search.d.ts +3 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/status.d.ts +2 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -8
- package/dist/store.d.ts +25 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +206 -90
- package/dist/wire.d.ts +5 -3
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +13 -2
- package/package.json +17 -9
package/dist/conversation.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
|
|
2
2
|
import { type ChangeSet } from './change-set.js';
|
|
3
3
|
import { type ChatDraftFile } from './file.js';
|
|
4
|
+
import type { Open } from './open.js';
|
|
4
5
|
import type { CallResult } from './outcome.js';
|
|
5
6
|
import type { DocumentResult } from './query.js';
|
|
6
7
|
import type { SearchedMessage } from './search.js';
|
|
7
8
|
import type { CycleProgress } from './status.js';
|
|
8
9
|
import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
|
|
9
|
-
export type ConversationState = 'working' | 'asking' | 'idle'
|
|
10
|
+
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
10
11
|
export type ConversationEntry = {
|
|
11
12
|
conversation: string;
|
|
12
13
|
agent: {
|
|
@@ -20,6 +21,10 @@ export type ConversationEntry = {
|
|
|
20
21
|
state: ConversationState;
|
|
21
22
|
started: string | null;
|
|
22
23
|
};
|
|
24
|
+
export type ConversationAgent = {
|
|
25
|
+
identity: string;
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
23
28
|
export type RunningTurn = {
|
|
24
29
|
turn: string;
|
|
25
30
|
started: string | null;
|
|
@@ -43,7 +48,9 @@ export type ConversationView = {
|
|
|
43
48
|
} | null;
|
|
44
49
|
commands: readonly ProcessCommand[];
|
|
45
50
|
options: readonly SessionOption[];
|
|
46
|
-
chatDraft: ChatDraft
|
|
51
|
+
chatDraft: (ChatDraft & {
|
|
52
|
+
readonly revision: string;
|
|
53
|
+
}) | null;
|
|
47
54
|
};
|
|
48
55
|
export type ConversationSurface = {
|
|
49
56
|
list(): Promise<readonly ConversationEntry[]>;
|
|
@@ -57,7 +64,7 @@ export type ConversationSurface = {
|
|
|
57
64
|
delete(conversation: string): Promise<CallResult>;
|
|
58
65
|
};
|
|
59
66
|
export type ChatDraftSurface = {
|
|
60
|
-
write(conversation: string, draft: ChatDraft): Promise<void>;
|
|
67
|
+
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
61
68
|
discard(conversation: string): Promise<void>;
|
|
62
69
|
};
|
|
63
70
|
export type ConversationDependencies = {
|
|
@@ -79,6 +86,7 @@ export type ConversationStore = {
|
|
|
79
86
|
reconnected(): void;
|
|
80
87
|
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
81
88
|
watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
|
|
89
|
+
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
82
90
|
changed(set: ChangeSet): void;
|
|
83
91
|
receive(event: ConversationEvent): boolean;
|
|
84
92
|
messages(): readonly SearchedMessage[];
|
|
@@ -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;
|
|
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,CA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,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,IAAI,OAAO,CAAC;IACnB,WAAW,IAAI,IAAI,CAAC;IACpB,KAAK,CACH,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GACxC,MAAM,IAAI,CAAC;IACd,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChF,WAAW,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACjF,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC3C,QAAQ,IAAI,SAAS,eAAe,EAAE,CAAC;IACvC,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;IACxE,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAyBF,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAWjE;AAmJD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CAklBzF"}
|
package/dist/conversation.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { conversationChangeSet } from './change-set.js';
|
|
2
|
+
import { runtimeError } from './failure.js';
|
|
2
3
|
import { declaredFile } from './file.js';
|
|
4
|
+
import { chatDraftRevision } from './identity.js';
|
|
3
5
|
const QUIET = {
|
|
4
6
|
turn: null,
|
|
5
7
|
questions: [],
|
|
@@ -152,7 +154,7 @@ function limitOf(options) {
|
|
|
152
154
|
if (limit === undefined)
|
|
153
155
|
return undefined;
|
|
154
156
|
if (!Number.isInteger(limit) || limit < 0) {
|
|
155
|
-
throw
|
|
157
|
+
throw runtimeError('invalid-limit', `conversation limit must be a non-negative integer, got ${String(limit)}`);
|
|
156
158
|
}
|
|
157
159
|
return limit;
|
|
158
160
|
}
|
|
@@ -168,7 +170,9 @@ export function createConversationStore(deps) {
|
|
|
168
170
|
const listing = new Map();
|
|
169
171
|
const listWatchers = new Set();
|
|
170
172
|
let listKnown = false;
|
|
173
|
+
const agentWatchers = new Set();
|
|
171
174
|
let agentNames = new Map();
|
|
175
|
+
let retiredAgents = new Set();
|
|
172
176
|
let agentsRead = null;
|
|
173
177
|
let replicated = new Set();
|
|
174
178
|
let handedReplicated;
|
|
@@ -198,7 +202,7 @@ export function createConversationStore(deps) {
|
|
|
198
202
|
options: structuredClone(facts.options),
|
|
199
203
|
chatDraft: draft === undefined || draft.turn !== null || sending.get(conversation)?.draft === draft
|
|
200
204
|
? null
|
|
201
|
-
: { text: draft.text, files: [...draft.files] },
|
|
205
|
+
: { text: draft.text, files: [...draft.files], revision: draft.revision },
|
|
202
206
|
};
|
|
203
207
|
}
|
|
204
208
|
function emit(conversation, messagesChanged = true) {
|
|
@@ -243,6 +247,21 @@ export function createConversationStore(deps) {
|
|
|
243
247
|
for (const watcher of listWatchers)
|
|
244
248
|
watcher(value);
|
|
245
249
|
}
|
|
250
|
+
function agents() {
|
|
251
|
+
return [...agentNames]
|
|
252
|
+
.filter(([identity]) => !retiredAgents.has(identity))
|
|
253
|
+
.map(([identity, name]) => ({ identity, name }))
|
|
254
|
+
.sort((left, right) => left.name === right.name
|
|
255
|
+
? left.identity.localeCompare(right.identity)
|
|
256
|
+
: left.name.localeCompare(right.name));
|
|
257
|
+
}
|
|
258
|
+
function emitAgents() {
|
|
259
|
+
if (deps.closed() || agentWatchers.size === 0)
|
|
260
|
+
return;
|
|
261
|
+
const value = agents();
|
|
262
|
+
for (const watcher of agentWatchers)
|
|
263
|
+
watcher(value);
|
|
264
|
+
}
|
|
246
265
|
function setLive(conversation, next) {
|
|
247
266
|
const before = stateOf(conversation);
|
|
248
267
|
const began = lives.get(conversation)?.turn?.started;
|
|
@@ -261,18 +280,27 @@ export function createConversationStore(deps) {
|
|
|
261
280
|
return;
|
|
262
281
|
const { documents } = await deps.documents(declaration.locator);
|
|
263
282
|
const names = new Map();
|
|
283
|
+
const retired = new Set();
|
|
264
284
|
for (const document of documents) {
|
|
265
285
|
if (document.type !== declaration.type)
|
|
266
286
|
continue;
|
|
267
287
|
const identity = document.fields?.[declaration.identity];
|
|
268
288
|
const name = document.fields?.[declaration.name];
|
|
269
|
-
if (typeof identity
|
|
270
|
-
|
|
289
|
+
if (typeof identity !== 'string' || typeof name !== 'string')
|
|
290
|
+
continue;
|
|
291
|
+
names.set(identity, name);
|
|
292
|
+
const ended = declaration.retired === undefined ? null : document.fields?.[declaration.retired];
|
|
293
|
+
if (ended !== undefined && ended !== null)
|
|
294
|
+
retired.add(identity);
|
|
271
295
|
}
|
|
272
|
-
|
|
296
|
+
const named = JSON.stringify([...names]) !== JSON.stringify([...agentNames]);
|
|
297
|
+
if (!named && JSON.stringify([...retired]) === JSON.stringify([...retiredAgents]))
|
|
273
298
|
return;
|
|
274
299
|
agentNames = names;
|
|
275
|
-
|
|
300
|
+
retiredAgents = retired;
|
|
301
|
+
if (named)
|
|
302
|
+
emitList();
|
|
303
|
+
emitAgents();
|
|
276
304
|
}
|
|
277
305
|
function agentsReady() {
|
|
278
306
|
agentsRead ??= readAgents().catch(() => {
|
|
@@ -550,12 +578,13 @@ export function createConversationStore(deps) {
|
|
|
550
578
|
},
|
|
551
579
|
};
|
|
552
580
|
const chatDraft = {
|
|
553
|
-
write(conversation, draft) {
|
|
581
|
+
write(conversation, draft, revision = chatDraftRevision()) {
|
|
554
582
|
return withDraft(conversation, () => ({
|
|
555
583
|
conversation,
|
|
556
584
|
text: draft.text,
|
|
557
585
|
files: [...draft.files],
|
|
558
586
|
turn: null,
|
|
587
|
+
revision,
|
|
559
588
|
}));
|
|
560
589
|
},
|
|
561
590
|
discard(conversation) {
|
|
@@ -650,6 +679,16 @@ export function createConversationStore(deps) {
|
|
|
650
679
|
listWatchers.delete(deliver);
|
|
651
680
|
};
|
|
652
681
|
},
|
|
682
|
+
watchAgents(deliver) {
|
|
683
|
+
agentWatchers.add(deliver);
|
|
684
|
+
void agentsReady().then(() => {
|
|
685
|
+
if (!deps.closed() && agentWatchers.has(deliver))
|
|
686
|
+
deliver(agents());
|
|
687
|
+
});
|
|
688
|
+
return () => {
|
|
689
|
+
agentWatchers.delete(deliver);
|
|
690
|
+
};
|
|
691
|
+
},
|
|
653
692
|
changed(set) {
|
|
654
693
|
for (const conversation of set.conversations)
|
|
655
694
|
emit(conversation);
|
|
@@ -697,6 +736,7 @@ export function createConversationStore(deps) {
|
|
|
697
736
|
views.clear();
|
|
698
737
|
lives.clear();
|
|
699
738
|
listWatchers.clear();
|
|
739
|
+
agentWatchers.clear();
|
|
700
740
|
},
|
|
701
741
|
};
|
|
702
742
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ExpectedOf<E extends {
|
|
2
|
+
readonly key: string;
|
|
3
|
+
}> = E | readonly E[] | null;
|
|
4
|
+
export type Expecting<E extends {
|
|
5
|
+
readonly key: string;
|
|
6
|
+
}> = {
|
|
7
|
+
subscribe(listener: () => void): () => void;
|
|
8
|
+
version(): number;
|
|
9
|
+
begin(): number;
|
|
10
|
+
expect(act: number, expected: ExpectedOf<E>, settled?: (one: E) => boolean): void;
|
|
11
|
+
drop(act: number): void;
|
|
12
|
+
heard(shown: (one: E) => boolean): void;
|
|
13
|
+
drawn(): readonly E[];
|
|
14
|
+
};
|
|
15
|
+
export declare function expectedList<E extends {
|
|
16
|
+
readonly key: string;
|
|
17
|
+
}>(expected: ExpectedOf<E>): readonly E[];
|
|
18
|
+
export declare function expecting<E extends {
|
|
19
|
+
readonly key: string;
|
|
20
|
+
}>(): Expecting<E>;
|
|
21
|
+
//# sourceMappingURL=expectation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expectation.d.ts","sourceRoot":"","sources":["../src/expectation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC;AAErF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,IAAI;IAC1D,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5C,OAAO,IAAI,MAAM,CAAC;IAClB,KAAK,IAAI,MAAM,CAAC;IAChB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC;IAClF,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC;IACxC,KAAK,IAAI,SAAS,CAAC,EAAE,CAAC;CACvB,CAAC;AAIF,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAC7D,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GACtB,SAAS,CAAC,EAAE,CAGd;AAwBD,wBAAgB,SAAS,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,KAAK,SAAS,CAAC,CAAC,CAAC,CA4C5E"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function expectedList(expected) {
|
|
2
|
+
if (expected === null)
|
|
3
|
+
return [];
|
|
4
|
+
return 'key' in expected ? [expected] : expected;
|
|
5
|
+
}
|
|
6
|
+
function superseded(entries, at) {
|
|
7
|
+
const key = entries[at]?.expectation.key;
|
|
8
|
+
return entries.slice(at + 1).some((later) => later.expectation.key === key);
|
|
9
|
+
}
|
|
10
|
+
function unended(entries, ends) {
|
|
11
|
+
const ended = new Set();
|
|
12
|
+
const kept = [];
|
|
13
|
+
for (const one of [...entries].reverse()) {
|
|
14
|
+
if (ended.has(one.expectation.key))
|
|
15
|
+
continue;
|
|
16
|
+
if (ends(one.expectation))
|
|
17
|
+
ended.add(one.expectation.key);
|
|
18
|
+
else
|
|
19
|
+
kept.unshift(one);
|
|
20
|
+
}
|
|
21
|
+
return kept;
|
|
22
|
+
}
|
|
23
|
+
export function expecting() {
|
|
24
|
+
let entries = [];
|
|
25
|
+
let version = 0;
|
|
26
|
+
let acts = 0;
|
|
27
|
+
const listeners = new Set();
|
|
28
|
+
const set = (next) => {
|
|
29
|
+
if (next.length === entries.length && next.every((one, at) => one === entries[at]))
|
|
30
|
+
return;
|
|
31
|
+
entries = next;
|
|
32
|
+
version += 1;
|
|
33
|
+
for (const listener of listeners)
|
|
34
|
+
listener();
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
subscribe(listener) {
|
|
38
|
+
listeners.add(listener);
|
|
39
|
+
return () => {
|
|
40
|
+
listeners.delete(listener);
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
version: () => version,
|
|
44
|
+
begin() {
|
|
45
|
+
acts += 1;
|
|
46
|
+
return acts;
|
|
47
|
+
},
|
|
48
|
+
expect(act, expected, settled = () => false) {
|
|
49
|
+
const fresh = expectedList(expected);
|
|
50
|
+
if (fresh.length === 0)
|
|
51
|
+
return;
|
|
52
|
+
const keys = new Set(fresh.map((one) => one.key));
|
|
53
|
+
const kept = entries.filter((one) => one.act !== act || !keys.has(one.expectation.key));
|
|
54
|
+
const over = new Set(kept.map((one) => one.expectation.key));
|
|
55
|
+
set([
|
|
56
|
+
...kept,
|
|
57
|
+
...fresh
|
|
58
|
+
.filter((one) => over.has(one.key) || !settled(one))
|
|
59
|
+
.map((expectation) => ({ act, expectation })),
|
|
60
|
+
]);
|
|
61
|
+
},
|
|
62
|
+
drop(act) {
|
|
63
|
+
set(entries.filter((one) => one.act !== act));
|
|
64
|
+
},
|
|
65
|
+
heard(shown) {
|
|
66
|
+
set(unended(entries, shown));
|
|
67
|
+
},
|
|
68
|
+
drawn: () => entries.flatMap((one, at) => (superseded(entries, at) ? [] : [one.expectation])),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type RuntimeError = Error & {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly retryable: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type Described = {
|
|
6
|
+
message: string;
|
|
7
|
+
code: string;
|
|
8
|
+
retryable: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function runtimeError(code: string, message?: string, retryable?: boolean): RuntimeError;
|
|
11
|
+
export declare function failed(error: unknown): RuntimeError;
|
|
12
|
+
export declare function described(error: unknown): Described;
|
|
13
|
+
//# sourceMappingURL=failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1F,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9E,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAa,EACtB,SAAS,UAAQ,GAChB,YAAY,CAEd;AAYD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAGnD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAGnD"}
|
package/dist/failure.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function runtimeError(code, message = code, retryable = false) {
|
|
2
|
+
return Object.assign(new Error(message), { code, retryable });
|
|
3
|
+
}
|
|
4
|
+
function coded(error) {
|
|
5
|
+
return (error instanceof Error &&
|
|
6
|
+
'code' in error &&
|
|
7
|
+
typeof error.code === 'string' &&
|
|
8
|
+
'retryable' in error &&
|
|
9
|
+
typeof error.retryable === 'boolean');
|
|
10
|
+
}
|
|
11
|
+
export function failed(error) {
|
|
12
|
+
if (coded(error))
|
|
13
|
+
return error;
|
|
14
|
+
return runtimeError('runtime-failure', error instanceof Error ? error.message : String(error));
|
|
15
|
+
}
|
|
16
|
+
export function described(error) {
|
|
17
|
+
const { message, code, retryable } = failed(error);
|
|
18
|
+
return { message, code, retryable };
|
|
19
|
+
}
|
package/dist/host.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export type MdRuntimeHost = {
|
|
|
15
15
|
};
|
|
16
16
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
17
17
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
18
|
+
export { STORE_SCHEMA } from './store.js';
|
|
18
19
|
export type { RuntimePort } from './wire.js';
|
|
19
20
|
//# 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":"AACA,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C,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;CAChC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IAC1F,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AA8EF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAkH3E;AAED,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { composeRuntime, } from './connection.js';
|
|
2
|
+
import { described } from './failure.js';
|
|
2
3
|
import { removeRuntimeStore } from './store.js';
|
|
3
4
|
import { AUTHORIZATION_ENDED, request, WIRE_REACH, } from './wire.js';
|
|
4
5
|
const NARROWED = new Set(['within', 'whole']);
|
|
@@ -57,7 +58,7 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
57
58
|
case 'conversation.delete':
|
|
58
59
|
return md.conversation.delete(input[0]);
|
|
59
60
|
case 'chatDraft.write':
|
|
60
|
-
return md.chatDraft.write(input[0], input[1]);
|
|
61
|
+
return md.chatDraft.write(input[0], input[1], input[2]);
|
|
61
62
|
case 'chatDraft.discard':
|
|
62
63
|
return md.chatDraft.discard(input[0]);
|
|
63
64
|
}
|
|
@@ -131,13 +132,8 @@ export function serveMdRuntime(options) {
|
|
|
131
132
|
send({ kind: 'result', id: message.id, value });
|
|
132
133
|
}
|
|
133
134
|
catch (error) {
|
|
134
|
-
if (serving)
|
|
135
|
-
send({
|
|
136
|
-
kind: 'failure',
|
|
137
|
-
id: message.id,
|
|
138
|
-
message: error instanceof Error ? error.message : String(error),
|
|
139
|
-
});
|
|
140
|
-
}
|
|
135
|
+
if (serving)
|
|
136
|
+
send({ kind: 'failure', id: message.id, ...described(error) });
|
|
141
137
|
}
|
|
142
138
|
};
|
|
143
139
|
port.addEventListener('message', (event) => {
|
|
@@ -176,3 +172,4 @@ export function serveMdRuntime(options) {
|
|
|
176
172
|
},
|
|
177
173
|
};
|
|
178
174
|
}
|
|
175
|
+
export { STORE_SCHEMA } from './store.js';
|
package/dist/identity.d.ts
CHANGED
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC"}
|
package/dist/identity.js
CHANGED
|
@@ -10,8 +10,17 @@ export function changeBatchIdentity(at = Date.now()) {
|
|
|
10
10
|
const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
11
11
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
function randomIdentity() {
|
|
14
14
|
const bytes = new Uint8Array(16);
|
|
15
15
|
crypto.getRandomValues(bytes);
|
|
16
16
|
return [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
17
17
|
}
|
|
18
|
+
export function roomDraftRevision() {
|
|
19
|
+
return randomIdentity();
|
|
20
|
+
}
|
|
21
|
+
export function chatDraftRevision() {
|
|
22
|
+
return randomIdentity();
|
|
23
|
+
}
|
|
24
|
+
export function transferIdentity() {
|
|
25
|
+
return randomIdentity();
|
|
26
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldRoom, ListedConversation, MdModelIdentity, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomAttachment, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
1
|
+
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldRoom, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomAttachment, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
2
2
|
export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
|
|
3
|
-
export type { ChatDraft, ChatDraftSurface, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
3
|
+
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
4
|
export type { ChatDraftFile, FileDeclaration } from './file.js';
|
|
5
|
-
export type { AppRoom, AppTypedSelection, ConnectionRefusal,
|
|
5
|
+
export type { AppRoom, AppTypedSelection, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
6
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type { CallResult, QueueEntry, Submission } from './outcome.js';
|
|
7
|
+
export type { CallResult, Failure, HistoryAnswer, QueueEntry, Submission } from './outcome.js';
|
|
8
|
+
export type { RuntimeError } from './failure.js';
|
|
8
9
|
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, } from './room-draft.js';
|
|
9
10
|
export type { SaveRefusal } from './save.js';
|
|
10
11
|
export type { DocumentHit, DocumentPart, MessageHit, SearchRequest, SearchResult, } from './search.js';
|
|
11
12
|
export { changeBatchIdentity } from './identity.js';
|
|
13
|
+
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
14
|
+
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
|
|
12
15
|
export type { RuntimeShell } from './durability.js';
|
|
13
16
|
export type { AttentionEntry, SyncStatus } from './status.js';
|
|
14
17
|
export type { Backlink, Direction, DocumentQuery, DocumentResult, Filter, GroupQuery, GroupResult, Key, LocalQuery, OrderOptions, Predicate, QueryDocument, QueryGroup, QueryResult, Related, Select, Value, Where, } from './query.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChF,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAChE,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM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Y,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,EACd,MAAM,EACN,UAAU,EACV,WAAW,EACX,GAAG,EACH,UAAU,EACV,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/memory.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelResult } from './model.js';
|
|
2
|
-
import { type AcceptedMessage, type ActionResult, type Adapter, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type ListedConversation, type ProviderLimit, type Retention, type RoomAttachment, type ServiceMode } from './adapter.js';
|
|
2
|
+
import { type AcceptedMessage, type ActionResult, type Adapter, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type RoomAttachment, type ServiceMode } from './adapter.js';
|
|
3
3
|
export type MemoryRoom = DiscoveredRoom & {
|
|
4
4
|
model?: ModelResult;
|
|
5
5
|
selectionModel?: ModelResult;
|
|
@@ -23,6 +23,7 @@ export type MemoryAdapterOptions = {
|
|
|
23
23
|
capabilities?: readonly Capability[];
|
|
24
24
|
providerLimits?: readonly ProviderLimit[];
|
|
25
25
|
retention?: Retention;
|
|
26
|
+
member?: Member;
|
|
26
27
|
unopened?: boolean;
|
|
27
28
|
};
|
|
28
29
|
export type MemoryAdapter = Adapter & {
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAIZ,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAIZ,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAGX,KAAK,aAAa,EAGlB,KAAK,SAAS,EACd,KAAK,cAAc,EAGnB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAkBtB,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC/C,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,WAAW,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CACzC,CA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AE,GAAG,IAAI,CAAC;IAChF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnD,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C,SAAS,IAAI,SAAS,MAAM,EAAE,CAAC;IAC/B,uBAAuB,IAAI,SAAS,MAAM,EAAE,CAAC;CAC9C,CAAC;AA+CF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAucrF"}
|
package/dist/memory.js
CHANGED
|
@@ -107,22 +107,24 @@ export function createMemoryAdapter(options = {}) {
|
|
|
107
107
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
function page(room,
|
|
110
|
+
function page(room, after) {
|
|
111
111
|
const paths = Object.keys(room.documents ?? {}).sort();
|
|
112
|
+
const opening = after === undefined;
|
|
113
|
+
const from = opening ? 0 : paths.filter((path) => path <= after).length;
|
|
112
114
|
const size = pageSize ?? paths.length;
|
|
113
115
|
const taken = paths.slice(from, from + size);
|
|
114
116
|
const next = from + taken.length;
|
|
115
|
-
const targets =
|
|
117
|
+
const targets = opening ? (room.binaryTargets ?? []) : [];
|
|
116
118
|
return {
|
|
117
119
|
kind: 'bootstrap',
|
|
118
120
|
roomVersion: room.roomVersion,
|
|
119
|
-
...(
|
|
121
|
+
...(opening ? { models: modelsOf(room) } : {}),
|
|
120
122
|
documents: named(room.documents ?? {}, taken),
|
|
121
123
|
revisions: named(room.revisions ?? {}, taken),
|
|
122
124
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
123
125
|
binaryTargets: targets,
|
|
124
|
-
...(
|
|
125
|
-
...(next < paths.length ? { pageToken:
|
|
126
|
+
...(opening && room.attachments !== undefined ? { attachments: room.attachments } : {}),
|
|
127
|
+
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
126
128
|
};
|
|
127
129
|
}
|
|
128
130
|
function advancement(room, from, at) {
|
|
@@ -183,7 +185,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
183
185
|
function historiesOf(input) {
|
|
184
186
|
const asked = input?.conversations;
|
|
185
187
|
if (!Array.isArray(asked))
|
|
186
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {} };
|
|
188
|
+
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
187
189
|
const histories = [];
|
|
188
190
|
for (const entry of asked) {
|
|
189
191
|
const conversation = typeof entry.conversation === 'string' ? scripted.get(entry.conversation) : undefined;
|
|
@@ -211,7 +213,12 @@ export function createMemoryAdapter(options = {}) {
|
|
|
211
213
|
const named = typeof input.conversation === 'string' ? input.conversation : '';
|
|
212
214
|
const conversation = scripted.get(named);
|
|
213
215
|
if (conversation === undefined) {
|
|
214
|
-
return {
|
|
216
|
+
return {
|
|
217
|
+
kind: 'rejected',
|
|
218
|
+
code: 'unknown-conversation',
|
|
219
|
+
fields: { conversation: named },
|
|
220
|
+
retryable: false,
|
|
221
|
+
};
|
|
215
222
|
}
|
|
216
223
|
const outcome = conversation.outcomes?.[name];
|
|
217
224
|
if (outcome !== undefined)
|
|
@@ -225,7 +232,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
225
232
|
if (name === 'conversation.cancel') {
|
|
226
233
|
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
227
234
|
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
228
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn } };
|
|
235
|
+
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
229
236
|
}
|
|
230
237
|
unsealed.delete(turn);
|
|
231
238
|
return { kind: 'action', result: { turn, cancelled: true } };
|
|
@@ -246,6 +253,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
246
253
|
capabilities,
|
|
247
254
|
providerLimits,
|
|
248
255
|
retention,
|
|
256
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
249
257
|
};
|
|
250
258
|
}
|
|
251
259
|
return {
|
|
@@ -330,6 +338,12 @@ export function createMemoryAdapter(options = {}) {
|
|
|
330
338
|
}
|
|
331
339
|
});
|
|
332
340
|
},
|
|
341
|
+
reopen() {
|
|
342
|
+
queueMicrotask(() => {
|
|
343
|
+
for (const observer of observers)
|
|
344
|
+
observer({ kind: 'closed', revoked: false });
|
|
345
|
+
});
|
|
346
|
+
},
|
|
333
347
|
observe(notify) {
|
|
334
348
|
observers.add(notify);
|
|
335
349
|
queueMicrotask(() => {
|
|
@@ -379,7 +393,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
379
393
|
if (room === undefined) {
|
|
380
394
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
381
395
|
}
|
|
382
|
-
return page(room, request.pageToken
|
|
396
|
+
return page(room, request.pageToken);
|
|
383
397
|
}, request).then((answer) => note(request.locator, answer));
|
|
384
398
|
},
|
|
385
399
|
async refresh(_authorization, request) {
|
|
@@ -412,7 +426,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
412
426
|
if (room === undefined) {
|
|
413
427
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
414
428
|
}
|
|
415
|
-
return {
|
|
429
|
+
return {
|
|
430
|
+
kind: 'rejected',
|
|
431
|
+
code: 'unscripted-mutation',
|
|
432
|
+
fields: {},
|
|
433
|
+
retryable: false,
|
|
434
|
+
affected: {},
|
|
435
|
+
};
|
|
416
436
|
}, request).then((answer) => note(request.locator, answer));
|
|
417
437
|
},
|
|
418
438
|
async history(_authorization, request) {
|
|
@@ -431,7 +451,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
431
451
|
return resolveScript(scripts.action, () => {
|
|
432
452
|
if (request.name.startsWith('conversation.'))
|
|
433
453
|
return conversationAction(request);
|
|
434
|
-
return { kind: 'rejected', code: 'unscripted-action', fields: {} };
|
|
454
|
+
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
435
455
|
}, request).then((answer) => {
|
|
436
456
|
if (answer.kind === 'action' && answer.at !== undefined)
|
|
437
457
|
note(answer.at.locator, answer.at);
|