@agentshouse/mdruntime 0.1.0-ca6edc1abd618 → 0.1.0-ca92b54804c33

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 (149) hide show
  1. package/README.md +2 -2
  2. package/dist/adapter.d.ts +101 -70
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/attached-model.d.ts +3 -10
  5. package/dist/attached-model.d.ts.map +1 -1
  6. package/dist/attached-model.js +29 -47
  7. package/dist/bootstrap.d.ts +16 -14
  8. package/dist/bootstrap.d.ts.map +1 -1
  9. package/dist/bootstrap.js +272 -129
  10. package/dist/chain.d.ts +2 -1
  11. package/dist/chain.d.ts.map +1 -1
  12. package/dist/change.d.ts +1 -0
  13. package/dist/change.d.ts.map +1 -1
  14. package/dist/client.d.ts +13 -9
  15. package/dist/client.d.ts.map +1 -1
  16. package/dist/client.js +54 -6
  17. package/dist/collection.d.ts +7 -4
  18. package/dist/collection.d.ts.map +1 -1
  19. package/dist/collection.js +23 -17
  20. package/dist/compile.d.ts +1 -6
  21. package/dist/compile.d.ts.map +1 -1
  22. package/dist/compile.js +108 -243
  23. package/dist/connection.d.ts +14 -11
  24. package/dist/connection.d.ts.map +1 -1
  25. package/dist/connection.js +2264 -1933
  26. package/dist/context.d.ts +2 -0
  27. package/dist/context.d.ts.map +1 -0
  28. package/dist/context.js +7 -0
  29. package/dist/conversation.d.ts +21 -17
  30. package/dist/conversation.d.ts.map +1 -1
  31. package/dist/conversation.js +405 -253
  32. package/dist/durability.d.ts +6 -1
  33. package/dist/durability.d.ts.map +1 -1
  34. package/dist/entry.d.ts +3 -2
  35. package/dist/entry.d.ts.map +1 -1
  36. package/dist/entry.js +18 -8
  37. package/dist/file.d.ts +2 -11
  38. package/dist/file.d.ts.map +1 -1
  39. package/dist/file.js +6 -4
  40. package/dist/host.d.ts +3 -7
  41. package/dist/host.d.ts.map +1 -1
  42. package/dist/host.js +26 -29
  43. package/dist/identity.d.ts +0 -1
  44. package/dist/identity.d.ts.map +1 -1
  45. package/dist/identity.js +0 -3
  46. package/dist/index.d.ts +12 -9
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +4 -1
  49. package/dist/job.d.ts +14 -0
  50. package/dist/job.d.ts.map +1 -0
  51. package/dist/job.js +28 -0
  52. package/dist/live.d.ts +5 -4
  53. package/dist/live.d.ts.map +1 -1
  54. package/dist/live.js +62 -20
  55. package/dist/media.d.ts +8 -0
  56. package/dist/media.d.ts.map +1 -0
  57. package/dist/media.js +218 -0
  58. package/dist/memory.d.ts +12 -5
  59. package/dist/memory.d.ts.map +1 -1
  60. package/dist/memory.js +216 -85
  61. package/dist/messages.d.ts +3 -3
  62. package/dist/messages.d.ts.map +1 -1
  63. package/dist/messages.js +20 -19
  64. package/dist/model.d.ts +8 -10
  65. package/dist/model.d.ts.map +1 -1
  66. package/dist/model.js +5 -17
  67. package/dist/observation.d.ts +3 -2
  68. package/dist/observation.d.ts.map +1 -1
  69. package/dist/observation.js +8 -3
  70. package/dist/outcome.d.ts +13 -5
  71. package/dist/outcome.d.ts.map +1 -1
  72. package/dist/outcome.js +16 -2
  73. package/dist/overlay.d.ts +1 -0
  74. package/dist/overlay.d.ts.map +1 -1
  75. package/dist/overlay.js +11 -0
  76. package/dist/paths.d.ts +1 -0
  77. package/dist/paths.d.ts.map +1 -1
  78. package/dist/paths.js +4 -0
  79. package/dist/query.d.ts +8 -207
  80. package/dist/query.d.ts.map +1 -1
  81. package/dist/query.js +3 -505
  82. package/dist/reach.d.ts +18 -11
  83. package/dist/reach.d.ts.map +1 -1
  84. package/dist/reach.js +195 -126
  85. package/dist/react.d.ts +3 -1
  86. package/dist/react.d.ts.map +1 -1
  87. package/dist/readiness.d.ts +3 -17
  88. package/dist/readiness.d.ts.map +1 -1
  89. package/dist/readiness.js +4 -10
  90. package/dist/recovery.d.ts +1 -0
  91. package/dist/recovery.d.ts.map +1 -1
  92. package/dist/recovery.js +35 -1
  93. package/dist/refresh.d.ts +7 -5
  94. package/dist/refresh.d.ts.map +1 -1
  95. package/dist/refresh.js +33 -5
  96. package/dist/replica.d.ts +10 -8
  97. package/dist/replica.d.ts.map +1 -1
  98. package/dist/replica.js +52 -20
  99. package/dist/room-draft.d.ts +21 -5
  100. package/dist/room-draft.d.ts.map +1 -1
  101. package/dist/room-draft.js +98 -51
  102. package/dist/rows.d.ts +18 -16
  103. package/dist/rows.d.ts.map +1 -1
  104. package/dist/rows.js +45 -153
  105. package/dist/save.d.ts +2 -0
  106. package/dist/save.d.ts.map +1 -1
  107. package/dist/save.js +22 -13
  108. package/dist/search.d.ts +12 -63
  109. package/dist/search.d.ts.map +1 -1
  110. package/dist/search.js +9 -52
  111. package/dist/shared.d.ts +0 -1
  112. package/dist/shared.d.ts.map +1 -1
  113. package/dist/shared.js +0 -10
  114. package/dist/status.d.ts +4 -5
  115. package/dist/status.d.ts.map +1 -1
  116. package/dist/status.js +3 -7
  117. package/dist/store.d.ts +101 -61
  118. package/dist/store.d.ts.map +1 -1
  119. package/dist/store.js +153 -161
  120. package/dist/stored.d.ts +66 -55
  121. package/dist/stored.d.ts.map +1 -1
  122. package/dist/stored.js +341 -273
  123. package/dist/tables.d.ts +90 -63
  124. package/dist/tables.d.ts.map +1 -1
  125. package/dist/tables.js +174 -98
  126. package/dist/transfer.d.ts +0 -5
  127. package/dist/transfer.d.ts.map +1 -1
  128. package/dist/validation.d.ts +3 -4
  129. package/dist/validation.d.ts.map +1 -1
  130. package/dist/validation.js +42 -100
  131. package/dist/windows.d.ts +1 -12
  132. package/dist/windows.d.ts.map +1 -1
  133. package/dist/windows.js +2 -75
  134. package/dist/wire.d.ts +17 -8
  135. package/dist/wire.d.ts.map +1 -1
  136. package/dist/wire.js +5 -2
  137. package/package.json +2 -2
  138. package/dist/fence.d.ts +0 -6
  139. package/dist/fence.d.ts.map +0 -1
  140. package/dist/fence.js +0 -10
  141. package/dist/fulltext.d.ts +0 -27
  142. package/dist/fulltext.d.ts.map +0 -1
  143. package/dist/fulltext.js +0 -368
  144. package/dist/reads.d.ts +0 -11
  145. package/dist/reads.d.ts.map +0 -1
  146. package/dist/reads.js +0 -100
  147. package/dist/words.d.ts +0 -19
  148. package/dist/words.d.ts.map +0 -1
  149. package/dist/words.js +0 -150
package/dist/live.js CHANGED
@@ -22,13 +22,15 @@ function affected(plan, set) {
22
22
  const paths = narrowed(plan) ? new Set(plan.paths) : null;
23
23
  return set.documents.some(({ locator, path }) => reads(plan, locator) && (paths === null || path === null || paths.has(path)));
24
24
  }
25
- function shown(entry) {
26
- const cover = entry.cover();
25
+ function shown(entry, held) {
26
+ const cover = entry.cover(held);
27
27
  return JSON.stringify('pending' in cover ? cover : cover.coverage);
28
28
  }
29
- export function createLiveQueries(run) {
29
+ export function createLiveQueries(run, holding) {
30
30
  const entries = new Map();
31
31
  let closed = false;
32
+ let recovering = false;
33
+ let recoverAgain = false;
32
34
  function deliver(entry, next) {
33
35
  const previous = entry.digest;
34
36
  entry.digest = digestOf(next);
@@ -38,12 +40,19 @@ export function createLiveQueries(run) {
38
40
  for (const listener of entry.ready)
39
41
  listener(change);
40
42
  }
41
- for (const listener of entry.fresh) {
43
+ for (const listener of entry.fresh.keys()) {
42
44
  entry.ready.add(listener);
43
45
  listener(next);
44
46
  }
45
47
  entry.fresh.clear();
46
48
  }
49
+ async function delivered(entry) {
50
+ const { current, ...next } = await run(entry.plan, async () => entry.cover(await holding()));
51
+ if (closed || entry.listeners.size === 0)
52
+ return null;
53
+ deliver(entry, next);
54
+ return current;
55
+ }
47
56
  function schedule(entry) {
48
57
  if (closed || entry.listeners.size === 0)
49
58
  return;
@@ -56,22 +65,62 @@ export function createLiveQueries(run) {
56
65
  try {
57
66
  for (;;) {
58
67
  entry.dirty = false;
59
- const { current, ...next } = await run(entry.plan, entry.cover);
60
- if (closed || entry.listeners.size === 0)
68
+ const current = await delivered(entry);
69
+ if (current === null)
61
70
  return;
62
- deliver(entry, next);
63
- if (!(entry.dirty && !current()) && shown(entry) === entry.covered)
71
+ const held = await holding();
72
+ if (entry.fresh.size > 0 || (entry.dirty && !current()))
73
+ continue;
74
+ if (shown(entry, held) === entry.covered)
64
75
  break;
65
76
  }
66
77
  }
67
- catch {
78
+ catch (error) {
68
79
  entry.dirty = false;
80
+ const unanswered = [...entry.fresh.values()];
81
+ entry.fresh.clear();
82
+ for (const failed of unanswered)
83
+ failed(error);
69
84
  }
70
85
  finally {
71
86
  entry.running = false;
72
87
  }
73
88
  })();
74
89
  }
90
+ function recovered() {
91
+ if (recovering) {
92
+ recoverAgain = true;
93
+ return;
94
+ }
95
+ recovering = true;
96
+ void (async () => {
97
+ try {
98
+ do {
99
+ recoverAgain = false;
100
+ for (const entry of entries.values()) {
101
+ if (entry.running)
102
+ entry.dirty = true;
103
+ }
104
+ const waiting = [...entries.values()].filter((entry) => !entry.running);
105
+ if (waiting.length === 0 || closed)
106
+ continue;
107
+ const held = await holding();
108
+ for (const entry of waiting) {
109
+ if (entry.running)
110
+ continue;
111
+ if (entry.digest === undefined || shown(entry, held) !== entry.covered)
112
+ schedule(entry);
113
+ }
114
+ } while (recoverAgain && !closed);
115
+ }
116
+ catch {
117
+ recoverAgain = false;
118
+ }
119
+ finally {
120
+ recovering = false;
121
+ }
122
+ })();
123
+ }
75
124
  return {
76
125
  touched(set) {
77
126
  for (const entry of entries.values()) {
@@ -79,22 +128,15 @@ export function createLiveQueries(run) {
79
128
  schedule(entry);
80
129
  }
81
130
  },
82
- recover() {
83
- for (const entry of entries.values()) {
84
- if (entry.running)
85
- continue;
86
- if (entry.digest === undefined || shown(entry) !== entry.covered)
87
- schedule(entry);
88
- }
89
- },
90
- watch(plan, identity, cover, listener) {
131
+ recover: recovered,
132
+ watch(plan, identity, cover, listener, failed) {
91
133
  let entry = entries.get(identity);
92
134
  if (entry === undefined) {
93
135
  entry = {
94
136
  plan,
95
137
  cover,
96
138
  listeners: new Set(),
97
- fresh: new Set(),
139
+ fresh: new Map(),
98
140
  ready: new Set(),
99
141
  digest: undefined,
100
142
  covered: '',
@@ -105,7 +147,7 @@ export function createLiveQueries(run) {
105
147
  }
106
148
  const held = entry;
107
149
  held.listeners.add(listener);
108
- held.fresh.add(listener);
150
+ held.fresh.set(listener, failed);
109
151
  schedule(held);
110
152
  return () => {
111
153
  held.listeners.delete(listener);
@@ -0,0 +1,8 @@
1
+ import type { MdRuntimeClient } from './client.js';
2
+ import { type ShownAnswer } from './outcome.js';
3
+ export declare const ROOM_MEDIA = "room-media";
4
+ type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
5
+ export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
6
+ export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
7
+ export {};
8
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3D,eAAO,MAAM,UAAU,eAAe,CAAC;AAwBvC,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAIpF,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,GAAG,eAAe,CAG5E;AAsBD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,EAClD,QAAQ,GAAE,qBAAsC,GAC/C,IAAI,CA0LN"}
package/dist/media.js ADDED
@@ -0,0 +1,218 @@
1
+ import { UNCERTAIN } from './outcome.js';
2
+ export const ROOM_MEDIA = 'room-media';
3
+ const ATTRIBUTES = ['room', 'path', 'revision', 'width', 'height', 'alt'];
4
+ const LOADING = new Set(['room', 'path', 'revision']);
5
+ const NEARING = '600px 0px';
6
+ const RELINKS = 2;
7
+ // The Room's stream brings a file seconds after the text that links it, minutes after on a first open, and a page's reach of its Rooms settles seconds after it opens, so a file not shown yet is asked for again every three seconds.
8
+ const UNSHOWN_MS = 3_000;
9
+ const SHAPE = '16 / 9';
10
+ const STYLE = `:host{display:block}
11
+ [part=box]{position:relative;overflow:hidden}
12
+ [part=box]>img,[part=box]>video,[part=box]>audio{display:block;width:100%;height:100%;object-fit:contain}
13
+ [part=box]>slot{display:flex;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}`;
14
+ const shows = new WeakMap();
15
+ export function shownBy(show, client) {
16
+ shows.set(client, show);
17
+ return client;
18
+ }
19
+ function ratioOf(width, height) {
20
+ const across = Number(width);
21
+ const down = Number(height);
22
+ return Number.isFinite(across) && Number.isFinite(down) && across > 0 && down > 0
23
+ ? `${across} / ${down}`
24
+ : SHAPE;
25
+ }
26
+ function refusedForGood(shown) {
27
+ if (shown.kind === 'revoked-authorization')
28
+ return true;
29
+ return (shown.kind === 'rejected' || shown.kind === 'scoped-refusal') && !shown.retryable;
30
+ }
31
+ function drawnFor(mediaType) {
32
+ if (mediaType.startsWith('image/'))
33
+ return 'img';
34
+ if (mediaType.startsWith('video/'))
35
+ return 'video';
36
+ if (mediaType.startsWith('audio/'))
37
+ return 'audio';
38
+ return null;
39
+ }
40
+ export function defineRoomMedia(client, registry = customElements) {
41
+ if (registry.get(ROOM_MEDIA) !== undefined)
42
+ return;
43
+ const connected = Promise.resolve(client);
44
+ class RoomMedia extends HTMLElement {
45
+ static observedAttributes = ATTRIBUTES;
46
+ #root = this.attachShadow({ mode: 'open' });
47
+ #box = document.createElement('div');
48
+ #fallback = document.createElement('slot');
49
+ #watching = null;
50
+ #near = false;
51
+ #asked = 0;
52
+ #shown = null;
53
+ #drawn = null;
54
+ #loaded = false;
55
+ #relinked = 0;
56
+ constructor() {
57
+ super();
58
+ this.#box.setAttribute('part', 'box');
59
+ this.#root.append(Object.assign(document.createElement('style'), { textContent: STYLE }), this.#box);
60
+ this.#shape();
61
+ }
62
+ connectedCallback() {
63
+ this.#label();
64
+ this.#watching ??= new IntersectionObserver((seen) => {
65
+ if (!seen.some((entry) => entry.isIntersecting) || this.#near)
66
+ return;
67
+ this.#near = true;
68
+ void this.#load();
69
+ }, { rootMargin: NEARING });
70
+ this.#watching.observe(this);
71
+ }
72
+ disconnectedCallback() {
73
+ this.#watching?.disconnect();
74
+ this.#watching = null;
75
+ this.#near = false;
76
+ this.#asked += 1;
77
+ this.#show(null);
78
+ }
79
+ attributeChangedCallback(name, before, after) {
80
+ if (before === after)
81
+ return;
82
+ this.#shape();
83
+ if (this.isConnected)
84
+ this.#label();
85
+ if (!LOADING.has(name) || !this.#near)
86
+ return;
87
+ this.#relinked = 0;
88
+ void this.#load();
89
+ }
90
+ #shape() {
91
+ this.#box.style.aspectRatio = ratioOf(this.getAttribute('width'), this.getAttribute('height'));
92
+ }
93
+ #label() {
94
+ const alt = this.getAttribute('alt') ?? '';
95
+ const drawn = this.#drawn;
96
+ if (drawn instanceof HTMLMediaElement) {
97
+ this.removeAttribute('role');
98
+ this.removeAttribute('aria-label');
99
+ drawn.setAttribute('aria-label', alt);
100
+ return;
101
+ }
102
+ this.setAttribute('role', 'img');
103
+ this.setAttribute('aria-label', alt);
104
+ if (drawn !== null)
105
+ drawn.alt = '';
106
+ }
107
+ async #load() {
108
+ const asked = (this.#asked += 1);
109
+ this.#loaded = false;
110
+ const room = this.getAttribute('room');
111
+ const path = this.getAttribute('path');
112
+ const revision = this.getAttribute('revision') ?? undefined;
113
+ if (room === null || path === null) {
114
+ this.#unreadable();
115
+ return;
116
+ }
117
+ const show = shows.get(await connected);
118
+ const shown = show === undefined ? null : await show(room, path, revision).catch(() => UNCERTAIN);
119
+ if (asked !== this.#asked)
120
+ return;
121
+ if (shown?.kind === 'link') {
122
+ this.#draw({ url: shown.url, copy: false }, shown.mediaType);
123
+ return;
124
+ }
125
+ if (shown?.kind !== 'binary') {
126
+ if (shown === null || refusedForGood(shown))
127
+ this.#unreadable();
128
+ else
129
+ this.#unshown(asked);
130
+ return;
131
+ }
132
+ const copy = await new Response(shown.stream, {
133
+ headers: { 'content-type': shown.mediaType },
134
+ })
135
+ .blob()
136
+ .catch(() => null);
137
+ if (asked !== this.#asked)
138
+ return;
139
+ if (copy === null)
140
+ this.#unshown(asked);
141
+ else
142
+ this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType);
143
+ }
144
+ #unshown(asked) {
145
+ this.#unreadable();
146
+ setTimeout(() => {
147
+ if (asked === this.#asked && this.#near)
148
+ void this.#load();
149
+ }, UNSHOWN_MS);
150
+ }
151
+ #show(shown, content = null) {
152
+ if (this.#shown?.copy === true)
153
+ URL.revokeObjectURL(this.#shown.url);
154
+ this.#shown = shown;
155
+ if (content !== this.#drawn)
156
+ this.#drawn = null;
157
+ if (content === null)
158
+ this.#box.replaceChildren();
159
+ else if (content.parentNode !== this.#box)
160
+ this.#box.replaceChildren(content);
161
+ this.#label();
162
+ }
163
+ #unreadable() {
164
+ this.#show(null, this.#fallback);
165
+ }
166
+ #draw(shown, mediaType) {
167
+ const tag = drawnFor(mediaType);
168
+ if (tag === null) {
169
+ if (shown.copy)
170
+ URL.revokeObjectURL(shown.url);
171
+ this.#unreadable();
172
+ return;
173
+ }
174
+ const kept = this.#drawn?.localName === tag ? this.#drawn : null;
175
+ const drawn = kept ?? document.createElement(tag);
176
+ if (kept === null) {
177
+ if (drawn instanceof HTMLImageElement)
178
+ drawn.decoding = 'async';
179
+ if (drawn instanceof HTMLMediaElement) {
180
+ drawn.controls = true;
181
+ drawn.preload = 'metadata';
182
+ if (drawn instanceof HTMLVideoElement)
183
+ drawn.playsInline = true;
184
+ }
185
+ drawn.addEventListener(drawn instanceof HTMLImageElement ? 'load' : 'loadedmetadata', () => {
186
+ if (drawn !== this.#drawn)
187
+ return;
188
+ this.#loaded = true;
189
+ this.#relinked = 0;
190
+ });
191
+ drawn.addEventListener('error', () => this.#failed(drawn));
192
+ }
193
+ this.#drawn = drawn;
194
+ this.#show(shown, drawn);
195
+ drawn.src = shown.url;
196
+ }
197
+ #failed(drawn) {
198
+ if (drawn !== this.#drawn)
199
+ return;
200
+ if (this.#shown?.copy !== false || !this.#loaded || this.#relinked >= RELINKS) {
201
+ this.#unreadable();
202
+ return;
203
+ }
204
+ this.#relinked += 1;
205
+ if (drawn instanceof HTMLMediaElement) {
206
+ const at = drawn.currentTime;
207
+ const playing = !drawn.paused;
208
+ drawn.addEventListener('loadedmetadata', () => {
209
+ drawn.currentTime = at;
210
+ if (playing)
211
+ void drawn.play().catch(() => undefined);
212
+ }, { once: true });
213
+ }
214
+ void this.#load();
215
+ }
216
+ }
217
+ registry.define(ROOM_MEDIA, RoomMedia);
218
+ }
package/dist/memory.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import type { ModelResult } from './model.js';
2
- import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveryScope, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode } from './adapter.js';
2
+ import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type SavedFacts, type HeadChange, type ListedAgent, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode, type TypedPath } from './adapter.js';
3
3
  export type MemoryRoom = DiscoveredRoom & {
4
4
  model?: ModelResult;
5
5
  documents?: Readonly<Record<string, string>>;
6
+ facts?: Readonly<Record<string, SavedFacts>>;
6
7
  revisions?: Readonly<Record<string, string>>;
7
8
  fileIds?: Readonly<Record<string, string>>;
9
+ created?: Readonly<Record<string, string>>;
8
10
  changes?: Readonly<Record<string, HeadChange>>;
9
11
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
10
12
  folders?: readonly string[];
@@ -12,13 +14,14 @@ export type MemoryRoom = DiscoveredRoom & {
12
14
  };
13
15
  export type MemoryConversation = {
14
16
  conversation: string;
15
- listed?: Omit<ListedConversation, 'conversation'>;
17
+ listed?: Omit<ListedConversation, 'conversation' | 'newest'>;
16
18
  messages?: readonly AcceptedMessage[];
17
- outcomes?: Partial<Record<ConversationAction, ActionResult>>;
19
+ outcomes?: Partial<Record<ConversationAction | 'history', ActionResult>>;
18
20
  };
19
21
  export type MemoryAdapterOptions = {
20
22
  rooms?: readonly MemoryRoom[];
21
23
  conversations?: readonly MemoryConversation[];
24
+ agents?: readonly ListedAgent[];
22
25
  historyPageSize?: number;
23
26
  pageSize?: number;
24
27
  capabilities?: readonly Capability[];
@@ -26,10 +29,12 @@ export type MemoryAdapterOptions = {
26
29
  retention?: Retention;
27
30
  member?: Member;
28
31
  unopened?: boolean;
29
- exhaustiveDiscovery?: true;
30
32
  roomTypes?: string;
33
+ typedPaths?: readonly TypedPath[];
31
34
  };
32
35
  export type MemoryAdapter = Adapter & {
36
+ discover: NonNullable<Adapter['discover']>;
37
+ refresh: NonNullable<Adapter['refresh']>;
33
38
  setRooms(rooms: readonly MemoryRoom[]): void;
34
39
  setConversations(conversations: readonly MemoryConversation[]): void;
35
40
  script(operation: keyof Adapter, answer: unknown): void;
@@ -37,17 +42,19 @@ export type MemoryAdapter = Adapter & {
37
42
  close(closing?: {
38
43
  revoked?: boolean;
39
44
  lost?: boolean;
45
+ authorityChanged?: boolean;
40
46
  }): void;
41
47
  expire(locators: readonly string[]): void;
42
48
  notifyRoomVersion(notification: {
43
49
  locator: string;
44
50
  roomVersion: string;
45
51
  }): void;
46
- notifyAuthorityChanged(scope?: DiscoveryScope): void;
52
+ notifyAuthorityChanged(locators?: readonly string[]): void;
47
53
  notifyConversation(event: ConversationEvent): void;
48
54
  notifyServiceMode(mode: ServiceMode): void;
49
55
  heldRooms(): readonly string[];
50
56
  replicatedConversations(): readonly string[];
57
+ heldConversationCursor(): string | null;
51
58
  };
52
59
  export declare function createMemoryAdapter(options?: MemoryAdapter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