@agentshouse/mdruntime 0.1.0-ce531b51ff088 → 0.1.0-cff8ba8fa2542

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.
Files changed (66) hide show
  1. package/AGENTS.md +32 -8
  2. package/README.md +10 -10
  3. package/dist/adapter.d.ts +50 -25
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/adapter.js +1 -9
  6. package/dist/attached-model.d.ts +11 -0
  7. package/dist/attached-model.d.ts.map +1 -0
  8. package/dist/attached-model.js +34 -0
  9. package/dist/bootstrap.d.ts +5 -3
  10. package/dist/bootstrap.d.ts.map +1 -1
  11. package/dist/bootstrap.js +2 -2
  12. package/dist/client.d.ts +3 -2
  13. package/dist/client.d.ts.map +1 -1
  14. package/dist/client.js +3 -10
  15. package/dist/connection.d.ts +9 -12
  16. package/dist/connection.d.ts.map +1 -1
  17. package/dist/connection.js +495 -511
  18. package/dist/conversation.d.ts +18 -6
  19. package/dist/conversation.d.ts.map +1 -1
  20. package/dist/conversation.js +179 -78
  21. package/dist/host.d.ts +7 -1
  22. package/dist/host.d.ts.map +1 -1
  23. package/dist/host.js +34 -31
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/memory.d.ts +11 -5
  27. package/dist/memory.d.ts.map +1 -1
  28. package/dist/memory.js +77 -26
  29. package/dist/model.d.ts +4 -11
  30. package/dist/model.d.ts.map +1 -1
  31. package/dist/model.js +4 -3
  32. package/dist/observation.d.ts +2 -0
  33. package/dist/observation.d.ts.map +1 -1
  34. package/dist/observation.js +24 -14
  35. package/dist/query.d.ts +7 -2
  36. package/dist/query.d.ts.map +1 -1
  37. package/dist/query.js +29 -20
  38. package/dist/reach.d.ts +40 -0
  39. package/dist/reach.d.ts.map +1 -0
  40. package/dist/reach.js +285 -0
  41. package/dist/react.d.ts +31 -0
  42. package/dist/react.d.ts.map +1 -0
  43. package/dist/react.js +62 -0
  44. package/dist/read-side.d.ts +4 -0
  45. package/dist/read-side.d.ts.map +1 -1
  46. package/dist/read-side.js +16 -10
  47. package/dist/refresh.d.ts +2 -1
  48. package/dist/refresh.d.ts.map +1 -1
  49. package/dist/refresh.js +7 -3
  50. package/dist/replica.d.ts +4 -4
  51. package/dist/replica.d.ts.map +1 -1
  52. package/dist/replica.js +12 -13
  53. package/dist/room-draft.d.ts +3 -0
  54. package/dist/room-draft.d.ts.map +1 -1
  55. package/dist/room-draft.js +6 -4
  56. package/dist/rows.d.ts.map +1 -1
  57. package/dist/rows.js +1 -4
  58. package/dist/save.d.ts +0 -2
  59. package/dist/save.d.ts.map +1 -1
  60. package/dist/save.js +3 -8
  61. package/dist/store.d.ts +0 -1
  62. package/dist/store.d.ts.map +1 -1
  63. package/dist/wire.d.ts +51 -16
  64. package/dist/wire.d.ts.map +1 -1
  65. package/dist/wire.js +50 -59
  66. package/package.json +14 -2
@@ -1,18 +1,28 @@
1
- import type { ConversationAction, ConversationCards, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
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
4
  import type { CallResult } from './outcome.js';
5
- import type { DocumentResult, QueryDocument } from './query.js';
5
+ import type { DocumentResult } from './query.js';
6
6
  import type { SearchedMessage } from './search.js';
7
7
  import type { CycleProgress } from './status.js';
8
8
  import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
9
+ export type ConversationState = 'working' | 'asking' | 'idle';
9
10
  export type ConversationEntry = {
10
11
  conversation: string;
11
- card: Required<QueryDocument>;
12
- agent: Required<QueryDocument> | null;
12
+ agent: {
13
+ identity: string;
14
+ name: string | null;
15
+ };
16
+ name: string;
17
+ created: string;
18
+ finished: string | null;
19
+ outcome: string | null;
20
+ state: ConversationState;
21
+ started: string | null;
13
22
  };
14
23
  export type RunningTurn = {
15
24
  turn: string;
25
+ started: string | null;
16
26
  parts: readonly unknown[];
17
27
  context: TurnContext | null;
18
28
  };
@@ -51,7 +61,7 @@ export type ChatDraftSurface = {
51
61
  discard(conversation: string): Promise<void>;
52
62
  };
53
63
  export type ConversationDependencies = {
54
- cards(): ConversationCards | undefined;
64
+ agents(): ConversationAgents | undefined;
55
65
  documents(locator: string): Promise<DocumentResult>;
56
66
  call(name: ConversationAction, input: unknown): Promise<CallResult>;
57
67
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
@@ -68,11 +78,13 @@ export type ConversationStore = {
68
78
  current(): boolean;
69
79
  reconnected(): void;
70
80
  watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
81
+ watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
71
82
  changed(set: ChangeSet): void;
72
- receive(event: ConversationEvent): void;
83
+ receive(event: ConversationEvent): boolean;
73
84
  messages(): readonly SearchedMessage[];
74
85
  message(conversation: string, identity: string): SearchedMessage | null;
75
86
  close(): void;
76
87
  };
88
+ export declare function unheldView(conversation: string): ConversationView;
77
89
  export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
78
90
  //# sourceMappingURL=conversation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EAEjB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,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,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,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;AAgJD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CA4iBzF"}
@@ -7,12 +7,31 @@ const QUIET = {
7
7
  commands: [],
8
8
  options: [],
9
9
  };
10
+ export function unheldView(conversation) {
11
+ return {
12
+ conversation,
13
+ messages: [],
14
+ turn: null,
15
+ questions: [],
16
+ process: null,
17
+ commands: [],
18
+ options: [],
19
+ chatDraft: null,
20
+ };
21
+ }
10
22
  function startedTurn(turn, operation) {
23
+ if (operation.op === 'begin')
24
+ return { turn, started: operation.at, parts: [], context: null };
11
25
  if (operation.op === 'context') {
12
- return { turn, parts: [], context: { used: operation.used, window: operation.window } };
26
+ return {
27
+ turn,
28
+ started: null,
29
+ parts: [],
30
+ context: { used: operation.used, window: operation.window },
31
+ };
13
32
  }
14
33
  return operation.op === 'start' && operation.index === 0
15
- ? { turn, parts: [structuredClone(operation.part)], context: null }
34
+ ? { turn, started: null, parts: [structuredClone(operation.part)], context: null }
16
35
  : null;
17
36
  }
18
37
  function changedFields(part, operation) {
@@ -27,6 +46,8 @@ function changedFields(part, operation) {
27
46
  return { entries: structuredClone(operation.entries) };
28
47
  }
29
48
  function appliedTurn(held, operation) {
49
+ if (operation.op === 'begin')
50
+ return { ...held, started: operation.at };
30
51
  if (operation.op === 'context') {
31
52
  return { ...held, context: { used: operation.used, window: operation.window } };
32
53
  }
@@ -144,6 +165,11 @@ export function createConversationStore(deps) {
144
165
  const gaps = new Map();
145
166
  const lives = new Map();
146
167
  const views = new Map();
168
+ const listing = new Map();
169
+ const listWatchers = new Set();
170
+ let listKnown = false;
171
+ let agentNames = new Map();
172
+ let agentsRead = null;
147
173
  let replicated = new Set();
148
174
  let handedReplicated;
149
175
  function liveOf(conversation) {
@@ -192,8 +218,70 @@ export function createConversationStore(deps) {
192
218
  watcher.notify(value);
193
219
  }
194
220
  }
221
+ function stateOf(conversation) {
222
+ const facts = liveOf(conversation);
223
+ if (facts.questions.length > 0)
224
+ return 'asking';
225
+ return facts.turn === null ? 'idle' : 'working';
226
+ }
227
+ function entries() {
228
+ return [...listing.values()].map((entry) => ({
229
+ conversation: entry.conversation,
230
+ agent: { identity: entry.agent, name: agentNames.get(entry.agent) ?? null },
231
+ name: entry.name,
232
+ created: entry.created,
233
+ finished: entry.finished,
234
+ outcome: entry.outcome,
235
+ state: stateOf(entry.conversation),
236
+ started: lives.get(entry.conversation)?.turn?.started ?? null,
237
+ }));
238
+ }
239
+ function emitList() {
240
+ if (deps.closed() || listWatchers.size === 0)
241
+ return;
242
+ const value = entries();
243
+ for (const watcher of listWatchers)
244
+ watcher(value);
245
+ }
246
+ function setLive(conversation, next) {
247
+ const before = stateOf(conversation);
248
+ const began = lives.get(conversation)?.turn?.started;
249
+ if (next === null)
250
+ lives.delete(conversation);
251
+ else
252
+ lives.set(conversation, next);
253
+ if (!listing.has(conversation))
254
+ return;
255
+ if (stateOf(conversation) !== before || next?.turn?.started !== began)
256
+ emitList();
257
+ }
258
+ async function readAgents() {
259
+ const declaration = deps.agents();
260
+ if (declaration === undefined)
261
+ return;
262
+ const { documents } = await deps.documents(declaration.locator);
263
+ const names = new Map();
264
+ for (const document of documents) {
265
+ if (document.type !== declaration.type)
266
+ continue;
267
+ const identity = document.fields?.[declaration.identity];
268
+ const name = document.fields?.[declaration.name];
269
+ if (typeof identity === 'string' && typeof name === 'string')
270
+ names.set(identity, name);
271
+ }
272
+ if (JSON.stringify([...names]) === JSON.stringify([...agentNames]))
273
+ return;
274
+ agentNames = names;
275
+ emitList();
276
+ }
277
+ function agentsReady() {
278
+ agentsRead ??= readAgents().catch(() => {
279
+ agentsRead = null;
280
+ });
281
+ return agentsRead;
282
+ }
195
283
  function live(conversation, change) {
196
- lives.set(conversation, { ...liveOf(conversation), ...change });
284
+ setLive(conversation, { ...liveOf(conversation), ...change });
197
285
  emit(conversation, false);
198
286
  }
199
287
  function relayed(conversation, turn, operation) {
@@ -206,7 +294,7 @@ export function createConversationStore(deps) {
206
294
  const held = lives.get(conversation);
207
295
  if (held?.turn == null || !turns.has(held.turn.turn))
208
296
  return false;
209
- lives.set(conversation, { ...held, turn: null });
297
+ setLive(conversation, { ...held, turn: null });
210
298
  return true;
211
299
  }
212
300
  function handReplicated() {
@@ -220,27 +308,6 @@ export function createConversationStore(deps) {
220
308
  handedReplicated = named;
221
309
  stream.replicate(held);
222
310
  }
223
- async function documented() {
224
- const declaration = deps.cards();
225
- if (declaration === undefined)
226
- return [];
227
- const { documents } = await deps.documents(declaration.locator);
228
- return documents.filter((document) => typeof document.type === 'string');
229
- }
230
- function carded(documents) {
231
- const declaration = deps.cards();
232
- if (declaration === undefined)
233
- return [];
234
- const cards = [];
235
- for (const card of documents) {
236
- if (card.type !== declaration.type)
237
- continue;
238
- const identity = card.fields[declaration.identity];
239
- if (typeof identity === 'string')
240
- cards.push({ conversation: identity, card });
241
- }
242
- return cards;
243
- }
244
311
  async function remove(leaving) {
245
312
  await deps.durably(async (local) => {
246
313
  await local.dropConversations(leaving);
@@ -257,7 +324,7 @@ export function createConversationStore(deps) {
257
324
  reads.delete(conversation);
258
325
  drafts.delete(conversation);
259
326
  behind.delete(conversation);
260
- lives.delete(conversation);
327
+ setLive(conversation, null);
261
328
  }
262
329
  if (changed.length > 0)
263
330
  deps.publish(conversationChangeSet(removed, changed));
@@ -353,6 +420,48 @@ export function createConversationStore(deps) {
353
420
  }
354
421
  });
355
422
  }
423
+ function heard(event) {
424
+ const { conversation } = event;
425
+ if (event.kind === 'gap') {
426
+ if (replicated.has(conversation))
427
+ gap(conversation);
428
+ const held = lives.get(conversation);
429
+ if (held === undefined)
430
+ return;
431
+ setLive(conversation, { ...QUIET, turn: held.turn });
432
+ emit(conversation, false);
433
+ return;
434
+ }
435
+ if (event.kind === 'turn') {
436
+ relayed(conversation, event.turn, event.operation);
437
+ return;
438
+ }
439
+ if (event.kind === 'questions') {
440
+ live(conversation, { questions: structuredClone(event.questions) });
441
+ return;
442
+ }
443
+ if (event.kind === 'process') {
444
+ live(conversation, { process: { running: event.running } });
445
+ return;
446
+ }
447
+ if (event.kind === 'commands') {
448
+ live(conversation, { commands: structuredClone(event.commands) });
449
+ return;
450
+ }
451
+ if (event.kind === 'options') {
452
+ live(conversation, { options: structuredClone(event.options) });
453
+ return;
454
+ }
455
+ const arriving = acceptedMessage(event.message);
456
+ if (arriving === null)
457
+ return;
458
+ if (replicated.has(conversation)) {
459
+ void keep(conversation, arriving).catch(() => { });
460
+ return;
461
+ }
462
+ if (sealTurns(conversation, new Set([arriving.turn])))
463
+ emit(conversation);
464
+ }
356
465
  function withDraft(conversation, next) {
357
466
  return deps.durably(async (local) => {
358
467
  const following = next(drafts.get(conversation));
@@ -374,17 +483,8 @@ export function createConversationStore(deps) {
374
483
  }
375
484
  const surface = {
376
485
  async list() {
377
- const declaration = deps.cards();
378
- if (declaration === undefined)
379
- return [];
380
- const documents = await documented();
381
- const entries = carded(documents).map(({ conversation, card }) => ({
382
- conversation,
383
- card,
384
- agent: documents.find((document) => document.backlinks.some((backlink) => backlink.path === card.path && backlink.field === declaration.agent)) ?? null,
385
- }));
386
- entries.sort((left, right) => (left.conversation < right.conversation ? -1 : 1));
387
- return entries;
486
+ await agentsReady();
487
+ return entries();
388
488
  },
389
489
  async read(conversation, options = {}) {
390
490
  const limit = limitOf(options);
@@ -480,7 +580,9 @@ export function createConversationStore(deps) {
480
580
  drafts.set(record.conversation, record);
481
581
  },
482
582
  async reconcile() {
483
- const named = new Set(carded(await documented()).map((entry) => entry.conversation));
583
+ if (!listKnown)
584
+ return;
585
+ const named = new Set(listing.keys());
484
586
  const leaving = [
485
587
  ...new Set([...replicated, ...messages.keys(), ...reads.keys(), ...drafts.keys()]),
486
588
  ].filter((conversation) => !named.has(conversation));
@@ -538,53 +640,51 @@ export function createConversationStore(deps) {
538
640
  views.delete(key);
539
641
  };
540
642
  },
643
+ watchList(deliver) {
644
+ listWatchers.add(deliver);
645
+ void agentsReady().then(() => {
646
+ if (!deps.closed() && listWatchers.has(deliver))
647
+ deliver(entries());
648
+ });
649
+ return () => {
650
+ listWatchers.delete(deliver);
651
+ };
652
+ },
541
653
  changed(set) {
542
654
  for (const conversation of set.conversations)
543
655
  emit(conversation);
656
+ const declaration = deps.agents();
657
+ if (declaration !== undefined &&
658
+ set.documents.some((change) => change.locator === declaration.locator)) {
659
+ agentsRead = readAgents().catch(() => {
660
+ agentsRead = null;
661
+ });
662
+ }
544
663
  },
545
664
  receive(event) {
546
665
  if (deps.closed())
547
- return;
548
- const { conversation } = event;
549
- if (event.kind === 'gap') {
550
- if (replicated.has(conversation))
551
- gap(conversation);
552
- const held = lives.get(conversation);
553
- if (held === undefined)
554
- return;
555
- lives.set(conversation, { ...QUIET, turn: held.turn });
556
- emit(conversation, false);
557
- return;
558
- }
559
- if (event.kind === 'turn') {
560
- relayed(conversation, event.turn, event.operation);
561
- return;
562
- }
563
- if (event.kind === 'questions') {
564
- live(conversation, { questions: structuredClone(event.questions) });
565
- return;
566
- }
567
- if (event.kind === 'process') {
568
- live(conversation, { process: { running: event.running } });
569
- return;
570
- }
571
- if (event.kind === 'commands') {
572
- live(conversation, { commands: structuredClone(event.commands) });
573
- return;
574
- }
575
- if (event.kind === 'options') {
576
- live(conversation, { options: structuredClone(event.options) });
577
- return;
578
- }
579
- const arriving = acceptedMessage(event.message);
580
- if (arriving === null)
581
- return;
582
- if (replicated.has(conversation)) {
583
- void keep(conversation, arriving).catch(() => { });
584
- return;
666
+ return false;
667
+ if (event.kind === 'list' || event.kind === 'listed' || event.kind === 'unlisted') {
668
+ if (event.kind === 'list') {
669
+ listing.clear();
670
+ for (const entry of event.entries)
671
+ listing.set(entry.conversation, { ...entry });
672
+ listKnown = true;
673
+ }
674
+ else if (event.kind === 'listed') {
675
+ listing.set(event.entry.conversation, { ...event.entry });
676
+ }
677
+ else {
678
+ listing.delete(event.conversation);
679
+ }
680
+ emitList();
681
+ return (event.kind !== 'list' &&
682
+ listKnown &&
683
+ (listing.size !== replicated.size ||
684
+ [...listing.keys()].some((conversation) => !replicated.has(conversation))));
585
685
  }
586
- if (sealTurns(conversation, new Set([arriving.turn])))
587
- emit(conversation);
686
+ heard(event);
687
+ return false;
588
688
  },
589
689
  messages() {
590
690
  return [...messages].flatMap(([conversation, held]) => held.map(({ identity, text }) => ({ conversation, identity, text })));
@@ -596,6 +696,7 @@ export function createConversationStore(deps) {
596
696
  close() {
597
697
  views.clear();
598
698
  lives.clear();
699
+ listWatchers.clear();
599
700
  },
600
701
  };
601
702
  }
package/dist/host.d.ts CHANGED
@@ -1,13 +1,19 @@
1
1
  import { type MdRuntimeOptions } from './connection.js';
2
+ import type { PortReach } from './reach.js';
2
3
  import { type RuntimePort } from './wire.js';
3
4
  export type MdRuntimeHostOptions = MdRuntimeOptions & {
4
5
  deploymentFacts?: unknown;
5
6
  };
7
+ export type AttachedPort = {
8
+ detach(): void;
9
+ narrow(reach: PortReach): void;
10
+ };
6
11
  export type MdRuntimeHost = {
7
- attach(port: RuntimePort, app: string, release?: string): () => void;
12
+ attach(port: RuntimePort, app: string, release?: string, reach?: PortReach): AttachedPort;
8
13
  endAuthorization(): Promise<void>;
9
14
  stop(): Promise<void>;
10
15
  };
11
16
  export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
17
+ export type { PortReach, ReachedDocument } from './reach.js';
12
18
  export type { RuntimePort } from './wire.js';
13
19
  //# sourceMappingURL=host.d.ts.map
@@ -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;AAKzB,OAAO,EAML,KAAK,WAAW,EAIjB,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;IACrE,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AA0EF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAwG3E;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,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;AAG5C,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;AA0EF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAwH3E;AAED,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
package/dist/host.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { composeRuntime, } from './connection.js';
2
2
  import { removeRuntimeStore } from './store.js';
3
- import { AUTHORIZATION_ENDED, carried, envelope, PROTOCOL_MISMATCH, request, } from './wire.js';
3
+ import { AUTHORIZATION_ENDED, request, WIRE_REACH, } from './wire.js';
4
+ const NARROWED = new Set(['within', 'whole']);
4
5
  function answered(md, app, writtenBy, member, input) {
5
6
  switch (member) {
6
7
  case 'rooms':
@@ -71,57 +72,61 @@ export function serveMdRuntime(options) {
71
72
  if (options.signal?.aborted === true)
72
73
  close();
73
74
  const runtime = composeRuntime({ ...options, signal: closing.signal });
74
- const { md, watch } = runtime;
75
+ const { md } = runtime;
75
76
  const attachments = new Map();
76
77
  let authorized = true;
77
78
  const watchFacts = (deliver) => {
78
79
  deliver(structuredClone(deploymentFacts));
79
80
  return () => { };
80
81
  };
81
- function attach(port, app, release) {
82
+ function attach(port, app, release, reach) {
82
83
  if (!authorized)
83
84
  throw new Error(AUTHORIZATION_ENDED);
84
85
  const writtenBy = release === undefined ? undefined : { app, release };
85
- const subscriptions = new Map();
86
+ const view = runtime.within(reach ?? null);
87
+ const observations = new Map();
86
88
  let serving = true;
87
89
  const send = (message) => {
88
- port.postMessage(envelope(message));
90
+ port.postMessage(message);
89
91
  };
90
92
  const detach = () => {
91
93
  if (!serving)
92
94
  return;
93
95
  serving = false;
94
- for (const end of subscriptions.values())
96
+ for (const end of observations.values())
95
97
  end();
96
- subscriptions.clear();
98
+ observations.clear();
97
99
  attachments.delete(detach);
98
100
  };
101
+ const observe = (id, topic, input) => {
102
+ let resolved = false;
103
+ const deliver = (value) => {
104
+ if (!serving)
105
+ return;
106
+ send(resolved ? { kind: 'event', id, value } : { kind: 'result', id, value });
107
+ resolved = true;
108
+ };
109
+ observations.set(id, topic === 'deployment-facts'
110
+ ? watchFacts(deliver)
111
+ : (NARROWED.has(WIRE_REACH.topics[topic]) ? view : runtime).watch(topic, topic === 'presentation' ? [app] : input, deliver));
112
+ };
99
113
  const serve = async (message) => {
100
114
  if (message.kind === 'hello')
101
115
  return;
102
116
  if (message.kind === 'stop') {
103
- subscriptions.get(message.id)?.();
104
- subscriptions.delete(message.id);
117
+ observations.get(message.id)?.();
118
+ observations.delete(message.id);
105
119
  return;
106
120
  }
107
121
  try {
108
122
  if (message.kind !== 'observe' || message.topic !== 'room-drafts')
109
123
  await md.loaded();
110
124
  if (message.kind === 'observe') {
111
- const { id, topic } = message;
112
- let resolved = false;
113
- const deliver = (value) => {
114
- if (!serving)
115
- return;
116
- send(resolved ? { kind: 'event', id, value } : { kind: 'result', id, value });
117
- resolved = true;
118
- };
119
- subscriptions.set(id, topic === 'deployment-facts'
120
- ? watchFacts(deliver)
121
- : watch(topic, topic === 'presentation' ? [app] : message.input, deliver));
125
+ if (serving)
126
+ observe(message.id, message.topic, message.input);
122
127
  return;
123
128
  }
124
- const value = await answered(md, app, writtenBy, message.member, message.input);
129
+ const value = await answered(NARROWED.has(WIRE_REACH.members[message.member]) ? view.md : md, app, writtenBy, message.member, message.input);
125
130
  if (serving)
126
131
  send({ kind: 'result', id: message.id, value });
127
132
  }
@@ -138,15 +143,7 @@ export function serveMdRuntime(options) {
138
143
  port.addEventListener('message', (event) => {
139
144
  if (!serving)
140
145
  return;
141
- const wire = carried(event.data);
142
- if (wire === null)
143
- return;
144
- if (!wire.matching) {
145
- send({ kind: 'refusal', refusal: PROTOCOL_MISMATCH });
146
- detach();
147
- return;
148
- }
149
- const message = request(wire.message);
146
+ const message = request(event.data);
150
147
  if (message === null)
151
148
  return;
152
149
  void serve(message);
@@ -154,7 +151,13 @@ export function serveMdRuntime(options) {
154
151
  port.addEventListener('close', detach);
155
152
  port.start();
156
153
  attachments.set(detach, send);
157
- return detach;
154
+ return {
155
+ detach,
156
+ narrow(next) {
157
+ if (serving)
158
+ view.narrow(next);
159
+ },
160
+ };
158
161
  }
159
162
  return {
160
163
  attach,
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationCards, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, MdModelIdentity, ModelRequest, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomAttachment, RoomNotReadable, RoomVersionAt, RoomVersionNotification, SelectedRooms, 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, 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, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
3
+ export type { ChatDraft, ChatDraftSurface, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
4
4
  export type { ChatDraftFile, FileDeclaration } from './file.js';
5
- export type { AppRoom, AppTypedSelection, ConnectionRefusal, ConnectionRefusalReason, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomTypes, SavedRoomDraft, SaveResult, } from './connection.js';
5
+ export type { AppRoom, AppTypedSelection, ConnectionRefusal, ConnectionRefusalReason, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedRoomDraft, SaveResult, } from './connection.js';
6
6
  export type { Observation } from './observation.js';
7
7
  export type { CallResult, QueueEntry, Submission } from './outcome.js';
8
8
  export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, } from './room-draft.js';
@@ -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,EAC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SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,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"}
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,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AAC;AACpD,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,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/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 MdModelIdentity, type ProviderLimit, type Retention, type RoomAttachment, type RoomVersionNotification, 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 ProviderLimit, type Retention, type RoomAttachment, type ServiceMode } from './adapter.js';
3
3
  export type MemoryRoom = DiscoveredRoom & {
4
4
  model?: ModelResult;
5
5
  selectionModel?: ModelResult;
@@ -11,6 +11,7 @@ export type MemoryRoom = DiscoveredRoom & {
11
11
  };
12
12
  export type MemoryConversation = {
13
13
  conversation: string;
14
+ listed?: Omit<ListedConversation, 'conversation'>;
14
15
  messages?: readonly AcceptedMessage[];
15
16
  outcomes?: Partial<Record<ConversationAction, ActionResult>>;
16
17
  };
@@ -19,20 +20,25 @@ export type MemoryAdapterOptions = {
19
20
  conversations?: readonly MemoryConversation[];
20
21
  historyPageSize?: number;
21
22
  pageSize?: number;
22
- mdModel?: MdModelIdentity;
23
- supportedVersions?: readonly number[];
24
23
  capabilities?: readonly Capability[];
25
24
  providerLimits?: readonly ProviderLimit[];
26
25
  retention?: Retention;
26
+ unopened?: boolean;
27
27
  };
28
28
  export type MemoryAdapter = Adapter & {
29
29
  setRooms(rooms: readonly MemoryRoom[]): void;
30
30
  setConversations(conversations: readonly MemoryConversation[]): void;
31
31
  script(operation: keyof Adapter, answer: unknown): void;
32
- notifyRoomVersion(notification: RoomVersionNotification): void;
32
+ open(): void;
33
+ close(revoked?: boolean): void;
34
+ expire(locators: readonly string[]): void;
35
+ notifyRoomVersion(notification: {
36
+ locator: string;
37
+ roomVersion: string;
38
+ }): void;
33
39
  notifyConversation(event: ConversationEvent): void;
34
40
  notifyServiceMode(mode: ServiceMode): void;
35
- selectedRooms(): readonly string[];
41
+ heldRooms(): readonly string[];
36
42
  replicatedConversations(): readonly string[];
37
43
  };
38
44
  export declare function createMemoryAdapter(options?: MemoryAdapterOptions): MemoryAdapter;