@agentshouse/mdruntime 0.1.0-cf04ede9fb796 → 0.1.0-cf0c43fc48aad

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 (220) hide show
  1. package/README.md +12 -12
  2. package/dist/acceptance.d.ts +0 -3
  3. package/dist/acceptance.d.ts.map +1 -1
  4. package/dist/acceptance.js +74 -164
  5. package/dist/act-lanes.d.ts +30 -0
  6. package/dist/act-lanes.d.ts.map +1 -0
  7. package/dist/act-lanes.js +225 -0
  8. package/dist/actions.d.ts +8 -2
  9. package/dist/actions.d.ts.map +1 -1
  10. package/dist/actions.js +118 -67
  11. package/dist/adapter.d.ts +27 -48
  12. package/dist/adapter.d.ts.map +1 -1
  13. package/dist/bootstrap.d.ts +1 -1
  14. package/dist/bootstrap.d.ts.map +1 -1
  15. package/dist/bootstrap.js +6 -19
  16. package/dist/change-set.d.ts +4 -0
  17. package/dist/change-set.d.ts.map +1 -1
  18. package/dist/change-set.js +6 -0
  19. package/dist/change.d.ts.map +1 -1
  20. package/dist/change.js +4 -2
  21. package/dist/client.d.ts +9 -18
  22. package/dist/client.d.ts.map +1 -1
  23. package/dist/client.js +32 -15
  24. package/dist/collection.d.ts +22 -4
  25. package/dist/collection.d.ts.map +1 -1
  26. package/dist/collection.js +12 -2
  27. package/dist/compile.d.ts +2 -0
  28. package/dist/compile.d.ts.map +1 -1
  29. package/dist/compile.js +31 -24
  30. package/dist/connection.d.ts.map +1 -1
  31. package/dist/connection.js +26 -21
  32. package/dist/conversation-live.d.ts +10 -6
  33. package/dist/conversation-live.d.ts.map +1 -1
  34. package/dist/conversation-live.js +8 -6
  35. package/dist/conversation.d.ts +28 -10
  36. package/dist/conversation.d.ts.map +1 -1
  37. package/dist/conversation.js +194 -141
  38. package/dist/declaration.d.ts +10 -0
  39. package/dist/declaration.d.ts.map +1 -0
  40. package/dist/declaration.js +24 -0
  41. package/dist/discovery.d.ts.map +1 -1
  42. package/dist/discovery.js +19 -44
  43. package/dist/durability.d.ts +3 -0
  44. package/dist/durability.d.ts.map +1 -1
  45. package/dist/entry.js +1 -1
  46. package/dist/expectation.d.ts +26 -13
  47. package/dist/expectation.d.ts.map +1 -1
  48. package/dist/expectation.js +72 -19
  49. package/dist/failure.d.ts +3 -0
  50. package/dist/failure.d.ts.map +1 -1
  51. package/dist/failure.js +6 -0
  52. package/dist/host.d.ts +17 -2
  53. package/dist/host.d.ts.map +1 -1
  54. package/dist/host.js +45 -11
  55. package/dist/index.d.ts +12 -8
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +10 -6
  58. package/dist/install.d.ts +2 -4
  59. package/dist/install.d.ts.map +1 -1
  60. package/dist/install.js +52 -78
  61. package/dist/lifecycle.d.ts +1 -1
  62. package/dist/lifecycle.d.ts.map +1 -1
  63. package/dist/lifecycle.js +40 -31
  64. package/dist/listing.d.ts +6 -11
  65. package/dist/listing.d.ts.map +1 -1
  66. package/dist/listing.js +25 -62
  67. package/dist/live.d.ts.map +1 -1
  68. package/dist/live.js +3 -3
  69. package/dist/locks.d.ts +2 -4
  70. package/dist/locks.d.ts.map +1 -1
  71. package/dist/locks.js +10 -39
  72. package/dist/lost.d.ts.map +1 -1
  73. package/dist/lost.js +10 -22
  74. package/dist/media.d.ts +1 -1
  75. package/dist/media.d.ts.map +1 -1
  76. package/dist/media.js +4 -4
  77. package/dist/memory.d.ts +4 -2
  78. package/dist/memory.d.ts.map +1 -1
  79. package/dist/memory.js +44 -23
  80. package/dist/messages.d.ts +9 -5
  81. package/dist/messages.d.ts.map +1 -1
  82. package/dist/messages.js +25 -35
  83. package/dist/model.d.ts +0 -1
  84. package/dist/model.d.ts.map +1 -1
  85. package/dist/model.js +0 -5
  86. package/dist/models.d.ts +4 -8
  87. package/dist/models.d.ts.map +1 -1
  88. package/dist/models.js +95 -137
  89. package/dist/observation.d.ts.map +1 -1
  90. package/dist/observation.js +12 -17
  91. package/dist/opened.d.ts +1 -1
  92. package/dist/opened.d.ts.map +1 -1
  93. package/dist/opened.js +5 -5
  94. package/dist/opening.d.ts.map +1 -1
  95. package/dist/opening.js +5 -9
  96. package/dist/outcome.d.ts +3 -0
  97. package/dist/outcome.d.ts.map +1 -1
  98. package/dist/outcome.js +15 -0
  99. package/dist/overlay.d.ts +5 -1
  100. package/dist/overlay.d.ts.map +1 -1
  101. package/dist/overlay.js +36 -21
  102. package/dist/page-metadata.d.ts +8 -0
  103. package/dist/page-metadata.d.ts.map +1 -0
  104. package/dist/page-metadata.js +19 -0
  105. package/dist/parts.d.ts +3 -59
  106. package/dist/parts.d.ts.map +1 -1
  107. package/dist/parts.js +10 -123
  108. package/dist/preparation.d.ts.map +1 -1
  109. package/dist/preparation.js +25 -24
  110. package/dist/presence.d.ts +52 -0
  111. package/dist/presence.d.ts.map +1 -0
  112. package/dist/presence.js +220 -0
  113. package/dist/queries.d.ts +1 -1
  114. package/dist/queries.d.ts.map +1 -1
  115. package/dist/queries.js +24 -14
  116. package/dist/query.d.ts +0 -1
  117. package/dist/query.d.ts.map +1 -1
  118. package/dist/questions.d.ts +0 -5
  119. package/dist/questions.d.ts.map +1 -1
  120. package/dist/questions.js +0 -7
  121. package/dist/queue.d.ts +40 -0
  122. package/dist/queue.d.ts.map +1 -0
  123. package/dist/queue.js +450 -0
  124. package/dist/reach.d.ts.map +1 -1
  125. package/dist/reach.js +67 -22
  126. package/dist/react.d.ts +5 -0
  127. package/dist/react.d.ts.map +1 -1
  128. package/dist/react.js +33 -1
  129. package/dist/reads.d.ts +3 -1
  130. package/dist/reads.d.ts.map +1 -1
  131. package/dist/reads.js +9 -2
  132. package/dist/recovery.d.ts +3 -1
  133. package/dist/recovery.d.ts.map +1 -1
  134. package/dist/recovery.js +29 -7
  135. package/dist/refresh.js +2 -2
  136. package/dist/refusal.d.ts.map +1 -1
  137. package/dist/refusal.js +5 -6
  138. package/dist/replica.d.ts +5 -11
  139. package/dist/replica.d.ts.map +1 -1
  140. package/dist/replica.js +13 -15
  141. package/dist/retried.d.ts +30 -0
  142. package/dist/retried.d.ts.map +1 -0
  143. package/dist/retried.js +72 -0
  144. package/dist/room-draft.d.ts +4 -6
  145. package/dist/room-draft.d.ts.map +1 -1
  146. package/dist/room-draft.js +46 -57
  147. package/dist/room-drafts.d.ts.map +1 -1
  148. package/dist/room-drafts.js +17 -16
  149. package/dist/rows.d.ts.map +1 -1
  150. package/dist/rows.js +3 -4
  151. package/dist/runtime.d.ts +9 -18
  152. package/dist/runtime.d.ts.map +1 -1
  153. package/dist/save.d.ts +42 -90
  154. package/dist/save.d.ts.map +1 -1
  155. package/dist/save.js +334 -167
  156. package/dist/saves.d.ts +2 -40
  157. package/dist/saves.d.ts.map +1 -1
  158. package/dist/saves.js +107 -705
  159. package/dist/seed.d.ts.map +1 -1
  160. package/dist/seed.js +2 -3
  161. package/dist/shared.d.ts +0 -5
  162. package/dist/shared.d.ts.map +1 -1
  163. package/dist/shared.js +4 -90
  164. package/dist/shown.d.ts +4 -3
  165. package/dist/shown.d.ts.map +1 -1
  166. package/dist/shown.js +26 -31
  167. package/dist/socket/lanes.d.ts +12 -4
  168. package/dist/socket/lanes.d.ts.map +1 -1
  169. package/dist/socket/lanes.js +34 -8
  170. package/dist/socket/session.d.ts +0 -1
  171. package/dist/socket/session.d.ts.map +1 -1
  172. package/dist/socket.d.ts +3 -6
  173. package/dist/socket.d.ts.map +1 -1
  174. package/dist/socket.js +5 -16
  175. package/dist/source.d.ts +0 -7
  176. package/dist/source.d.ts.map +1 -1
  177. package/dist/source.js +5 -4
  178. package/dist/store/records.d.ts +8 -6
  179. package/dist/store/records.d.ts.map +1 -1
  180. package/dist/store/records.js +13 -6
  181. package/dist/store/space.d.ts +1 -1
  182. package/dist/store/space.d.ts.map +1 -1
  183. package/dist/store/space.js +0 -2
  184. package/dist/store/watchers.js +1 -2
  185. package/dist/store.d.ts +11 -6
  186. package/dist/store.d.ts.map +1 -1
  187. package/dist/store.js +38 -13
  188. package/dist/stored.d.ts +2 -1
  189. package/dist/stored.d.ts.map +1 -1
  190. package/dist/stored.js +11 -11
  191. package/dist/surface.d.ts +1 -1
  192. package/dist/surface.d.ts.map +1 -1
  193. package/dist/surface.js +13 -16
  194. package/dist/sync.d.ts.map +1 -1
  195. package/dist/sync.js +88 -85
  196. package/dist/tables.d.ts +6 -8
  197. package/dist/tables.d.ts.map +1 -1
  198. package/dist/tables.js +41 -20
  199. package/dist/tallies.js +5 -5
  200. package/dist/validation.d.ts.map +1 -1
  201. package/dist/validation.js +2 -2
  202. package/dist/wire.d.ts +51 -7
  203. package/dist/wire.d.ts.map +1 -1
  204. package/dist/wire.js +15 -4
  205. package/package.json +3 -2
  206. package/dist/attempt.d.ts +0 -16
  207. package/dist/attempt.d.ts.map +0 -1
  208. package/dist/attempt.js +0 -70
  209. package/dist/job.d.ts +0 -33
  210. package/dist/job.d.ts.map +0 -1
  211. package/dist/job.js +0 -54
  212. package/dist/log.d.ts +0 -6
  213. package/dist/log.d.ts.map +0 -1
  214. package/dist/log.js +0 -14
  215. package/dist/socket/rooms.d.ts +0 -44
  216. package/dist/socket/rooms.d.ts.map +0 -1
  217. package/dist/socket/rooms.js +0 -90
  218. package/dist/store/fences.d.ts +0 -16
  219. package/dist/store/fences.d.ts.map +0 -1
  220. package/dist/store/fences.js +0 -26
package/dist/listing.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import type { HeldRooms } from '@agentshouse/mdmodel';
2
- import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission } from './adapter.js';
2
+ import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission, RoomDeclaration } from './adapter.js';
3
3
  import type { Composition } from './collection.js';
4
4
  import { type ModelState, type TypesResult } from './model.js';
5
5
  import { type PortReach } from './reach.js';
6
6
  import type { ReplicaRecord } from './replica.js';
7
7
  import type { Runtime } from './runtime.js';
8
- import type { RoomDeclaration } from './socket.js';
9
8
  import type { Stored } from './store.js';
10
9
  export type AppTypedSelection = {
11
10
  roots: readonly string[];
@@ -20,6 +19,7 @@ export type AppRoom = {
20
19
  model: TypesResult;
21
20
  typedSelection: AppTypedSelection | null;
22
21
  providerOwnedPaths: readonly string[];
22
+ authoredPaths: readonly string[];
23
23
  roomVersion: string | null;
24
24
  documents: number;
25
25
  synchronizationAvailable: boolean;
@@ -31,22 +31,17 @@ type ListedEntry = ListedRoom & {
31
31
  readonly documents: number;
32
32
  };
33
33
  export type Listing = ReadonlyMap<string, ListedEntry>;
34
- export declare function modelIn({ socket }: Runtime, locator: string, stored: Stored | undefined): ModelState;
34
+ export declare function modelIn({ socket, presence }: Runtime, locator: string, stored: Stored | undefined): ModelState;
35
35
  export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
36
- export declare function declarationOf({ socket }: Runtime, locator: string, stored: Stored | undefined): {
36
+ export declare function declarationOf({ presence }: Runtime, locator: string, stored: Stored | undefined): {
37
37
  readonly room: RoomDeclaration;
38
38
  readonly available: boolean;
39
39
  } | undefined;
40
- export declare function listedLocators({ store, socket }: Runtime, held: ReadonlyMap<string, unknown>): string[];
40
+ export declare function listedLocators({ presence }: Runtime, held: ReadonlyMap<string, unknown>): string[];
41
41
  export declare function patchedListing(runtime: Runtime, changed: ReadonlySet<string>): Promise<Listing | null>;
42
42
  export declare function listingNow(runtime: Runtime): Promise<Listing>;
43
- export declare function shownRooms(runtime: Runtime, listing: Listing): readonly AppRoom[];
43
+ export declare function shownRooms({ presence }: Runtime, listing: Listing): readonly AppRoom[];
44
44
  export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
45
- export declare function list({ store, socket }: Runtime, room: RoomDeclaration, synchronizationAvailable: boolean): void;
46
- export declare function listHeld({ store, socket }: Runtime, locator: string): void;
47
- export declare function admitted({ socket }: Runtime, room: RoomDeclaration): boolean;
48
- export declare function readable(runtime: Runtime, room: DiscoveredRoom): void;
49
- export declare function usable(runtime: Runtime, room: DiscoveredRoom): void;
50
45
  export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
51
46
  export declare function name(runtime: Runtime, locator: string): Promise<void>;
52
47
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../src/listing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,eAAe,EACf,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAwB,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,WAAW,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC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Types, NO_MODEL } from './model.js';
2
3
  import { governs, holds } from './reach.js';
3
- export function modelIn({ socket }, locator, stored) {
4
+ export function modelIn({ socket, presence }, locator, stored) {
4
5
  if (socket.session.now().refusal?.code === 'revoked-authorization')
5
6
  return { status: 'unavailable', reason: 'revoked' };
6
- return stored?.record.model ?? socket.rooms.standing(locator).unheldModel ?? NO_MODEL;
7
+ return stored?.record.model ?? presence.unheldModel(locator) ?? NO_MODEL;
7
8
  }
8
9
  export function compositionFor(runtime, record) {
9
10
  return runtime.store.composed({
@@ -11,17 +12,19 @@ export function compositionFor(runtime, record) {
11
12
  model: modelIn(runtime, record.locator, { record, indexed: true, documents: 0 }),
12
13
  });
13
14
  }
14
- export function declarationOf({ socket }, locator, stored) {
15
- const held = socket.rooms.declared(locator);
16
- const room = stored?.record ?? held?.room ?? socket.rooms.discovered(locator);
17
- return room === undefined ? undefined : { room, available: held?.available ?? true };
15
+ export function declarationOf({ presence }, locator, stored) {
16
+ const listed = presence.room(locator);
17
+ const room = stored?.record.declaration ?? (listed === undefined ? undefined : declared(listed));
18
+ if (room === undefined)
19
+ return undefined;
20
+ return {
21
+ room,
22
+ available: presence.available(locator, stored?.record.declaration.replica.selection),
23
+ };
18
24
  }
19
- export function listedLocators({ store, socket }, held) {
20
- const declared = socket.rooms.declarations();
21
- return [
22
- ...declared.keys(),
23
- ...[...held.keys()].filter((locator) => !declared.has(locator)),
24
- ].filter((locator) => !store.fences.has(locator));
25
+ export function listedLocators({ presence }, held) {
26
+ const listed = presence.rooms().map(({ locator }) => locator);
27
+ return [...new Set([...listed, ...held.keys()])];
25
28
  }
26
29
  function selectionModel({ socket, builtIn }) {
27
30
  return socket.session.now().refusal?.code === 'revoked-authorization'
@@ -33,7 +36,7 @@ function listedRoom(runtime, locator, stored) {
33
36
  if (declaration === undefined)
34
37
  return undefined;
35
38
  const { room, available } = declaration;
36
- const selection = room.typedSelection ?? null;
39
+ const selection = room.typedSelection;
37
40
  return {
38
41
  name: room.name,
39
42
  locator,
@@ -45,9 +48,10 @@ function listedRoom(runtime, locator, stored) {
45
48
  ? null
46
49
  : { roots: selection.roots, model: modelTypes(selectionModel(runtime)) },
47
50
  providerOwnedPaths: room.providerOwnedPaths,
51
+ authoredPaths: room.authoredPaths,
48
52
  roomVersion: stored?.record.roomVersion ?? null,
49
53
  synchronizationAvailable: available,
50
- refusal: runtime.socket.rooms.standing(locator).refusal,
54
+ refusal: runtime.presence.refusal(locator),
51
55
  documents: stored?.documents ?? 0,
52
56
  };
53
57
  }
@@ -68,9 +72,7 @@ export async function patchedListing(runtime, changed) {
68
72
  const held = await store.rooms([...changed]);
69
73
  const listing = new Map(roomsShown);
70
74
  for (const locator of changed) {
71
- const room = store.fences.has(locator)
72
- ? undefined
73
- : listedRoom(runtime, locator, held.get(locator));
75
+ const room = listedRoom(runtime, locator, held.get(locator));
74
76
  if (room === undefined || !listing.has(locator))
75
77
  return null;
76
78
  listing.set(locator, room);
@@ -80,11 +82,9 @@ export async function patchedListing(runtime, changed) {
80
82
  export async function listingNow(runtime) {
81
83
  return listingOf(runtime, await runtime.store.rooms());
82
84
  }
83
- function lockedIn({ socket }, listing, locator) {
84
- return (listing.get(locator)?.replica.offline === 'locked' && !socket.rooms.standing(locator).confirmed);
85
- }
86
- export function shownRooms(runtime, listing) {
87
- return structuredClone([...listing.values()].map(({ documents, ...room }) => lockedIn(runtime, listing, room.locator)
85
+ export function shownRooms({ presence }, listing) {
86
+ const locked = new Set(presence.lockedAmong(new Map([...listing].map(([locator, room]) => [locator, room.replica.offline]))));
87
+ return structuredClone([...listing.values()].map(({ documents, ...room }) => locked.has(room.locator)
88
88
  ? {
89
89
  ...room,
90
90
  model: modelTypes(NO_MODEL),
@@ -113,43 +113,6 @@ export async function roomFacts(runtime, reach = null) {
113
113
  });
114
114
  return { listed: socket.session.now().roomsListed, rooms };
115
115
  }
116
- export function list({ store, socket }, room, synchronizationAvailable) {
117
- if (store.fences.has(room.locator))
118
- return;
119
- socket.rooms.declare(room.locator, {
120
- room: {
121
- name: room.name,
122
- locator: room.locator,
123
- handle: room.handle,
124
- operations: room.operations,
125
- replica: room.replica,
126
- typedSelection: room.typedSelection ?? null,
127
- providerOwnedPaths: room.providerOwnedPaths,
128
- authoredPaths: room.authoredPaths,
129
- },
130
- available: synchronizationAvailable,
131
- });
132
- }
133
- export function listHeld({ store, socket }, locator) {
134
- if (store.fences.has(locator))
135
- return;
136
- socket.rooms.declare(locator, { room: null, available: false });
137
- }
138
- export function admitted({ socket }, room) {
139
- return room.replica.admission === 'admitted' && !socket.rooms.standing(room.locator).unreadable;
140
- }
141
- export function readable(runtime, room) {
142
- runtime.socket.rooms.stand(room.locator, { unreadable: false });
143
- list(runtime, room, true);
144
- }
145
- export function usable(runtime, room) {
146
- const { rooms } = runtime.socket;
147
- rooms.stand(room.locator, { stale: false, unpreparable: false });
148
- if (rooms.standing(room.locator).unreadable) {
149
- rooms.stand(room.locator, { unreadable: false, refusal: null });
150
- }
151
- list(runtime, room, true);
152
- }
153
116
  export async function heldRooms({ store }, listed) {
154
117
  const stored = await store.rooms(listed.map((room) => room.locator));
155
118
  return listed.flatMap((room) => {
@@ -159,14 +122,14 @@ export async function heldRooms({ store }, listed) {
159
122
  ? [{ locator: room.locator, roomVersion: null }]
160
123
  : [];
161
124
  }
162
- if (record.replica.selection !== room.replica.selection)
125
+ if (record.declaration.replica.selection !== room.replica.selection)
163
126
  return [];
164
127
  return [{ locator: room.locator, roomVersion: record.roomVersion }];
165
128
  });
166
129
  }
167
130
  export async function name(runtime, locator) {
168
- const { socket } = runtime;
169
- const room = socket.rooms.discovered(locator);
131
+ const { socket, presence } = runtime;
132
+ const room = presence.room(locator);
170
133
  if (!socket.streamed || room === undefined || !socket.isOpen() || !socket.isHanded())
171
134
  return;
172
135
  const [held] = await heldRooms(runtime, [room]);
@@ -1 +1 @@
1
- {"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,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AAE,GAAG,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CA2HxF"}
package/dist/live.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { changeOf, digestOf, } from './observation.js';
2
+ import { uncaught } from './failure.js';
2
3
  import { roomOfKey } from './rows.js';
3
4
  function narrowed(plan) {
4
5
  return (plan.paths !== null &&
@@ -76,7 +77,6 @@ export function createLiveQueries(run, holding) {
76
77
  }
77
78
  }
78
79
  catch (error) {
79
- entry.dirty = false;
80
80
  const unanswered = [...entry.fresh.values()];
81
81
  entry.fresh.clear();
82
82
  for (const failed of unanswered)
@@ -113,8 +113,8 @@ export function createLiveQueries(run, holding) {
113
113
  }
114
114
  } while (recoverAgain && !closed);
115
115
  }
116
- catch {
117
- recoverAgain = false;
116
+ catch (error) {
117
+ uncaught(error);
118
118
  }
119
119
  finally {
120
120
  recovering = false;
package/dist/locks.d.ts CHANGED
@@ -1,9 +1,7 @@
1
- import type { DiscoveredRoom } from './adapter.js';
2
1
  import type { Runtime } from './runtime.js';
3
- export declare function locked({ store, socket }: Runtime, locator: string): Promise<boolean>;
4
- export declare function lockedRooms(runtime: Runtime): Promise<readonly string[]>;
2
+ export declare function locked({ store, presence }: Runtime, locator: string): Promise<boolean>;
3
+ export declare function lockedRooms({ store, presence }: Runtime): Promise<readonly string[]>;
5
4
  export declare function relocked(runtime: Runtime, before: readonly string[]): Promise<void>;
6
- export declare function confirmLocks({ socket }: Runtime, listed: readonly DiscoveredRoom[]): void;
7
5
  export declare function connectionLost(runtime: Runtime): void;
8
6
  export declare function watchLocks({ store }: Runtime, notify: () => void): () => void;
9
7
  //# sourceMappingURL=locks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"locks.d.ts","sourceRoot":"","sources":["../src/locks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,E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CHANGED
@@ -1,59 +1,30 @@
1
+ import { uncaught } from './failure.js';
1
2
  import { emitRooms, LOCKS_TOPIC } from './shown.js';
2
- async function offlineModes({ store, socket }) {
3
- const modes = new Map();
4
- for (const [locator, { room }] of socket.rooms.declarations()) {
5
- const declaration = room ?? socket.rooms.discovered(locator);
6
- if (declaration !== undefined)
7
- modes.set(locator, declaration.replica.offline);
8
- }
9
- for (const [locator, { offline }] of (await store.covering()).rooms)
10
- modes.set(locator, offline);
11
- return modes;
3
+ export async function locked({ store, presence }, locator) {
4
+ return presence.locked(locator, async () => (await store.open()).offline(locator));
12
5
  }
13
- export async function locked({ store, socket }, locator) {
14
- if (store.fences.has(locator) || socket.rooms.standing(locator).confirmed)
15
- return false;
16
- const held = socket.rooms.declared(locator)?.room ?? socket.rooms.discovered(locator);
17
- const mode = (await (await store.open()).offline(locator)) ?? held?.replica.offline;
18
- return mode === 'locked';
19
- }
20
- export async function lockedRooms(runtime) {
21
- const { store, socket } = runtime;
22
- return [...(await offlineModes(runtime))]
23
- .filter(([locator, mode]) => mode === 'locked' &&
24
- !socket.rooms.standing(locator).confirmed &&
25
- !store.fences.has(locator))
26
- .map(([locator]) => locator)
27
- .sort();
6
+ export async function lockedRooms({ store, presence }) {
7
+ const held = (await store.covering()).rooms;
8
+ return presence.lockedAmong(new Map([...held].map(([locator, { offline }]) => [locator, offline])));
28
9
  }
29
10
  export async function relocked(runtime, before) {
30
11
  const after = await lockedRooms(runtime);
31
12
  if (JSON.stringify(after) === JSON.stringify(before))
32
13
  return;
33
- runtime.journal.record(`locked ${after.length}`);
34
14
  emitRooms(runtime);
35
15
  runtime.store.tell(LOCKS_TOPIC, undefined);
36
16
  }
37
- export function confirmLocks({ socket }, listed) {
38
- if (!socket.isOpen())
39
- return;
40
- for (const room of listed) {
41
- if (room.replica.admission === 'admitted') {
42
- socket.rooms.stand(room.locator, { confirmed: true });
43
- }
44
- }
45
- }
46
17
  export function connectionLost(runtime) {
47
- const { socket } = runtime;
18
+ const { socket, presence } = runtime;
48
19
  if (socket.closed())
49
20
  return;
50
- socket.rooms.connectionLost(() => {
21
+ presence.connectionLost(() => {
51
22
  if (socket.isOpen() || socket.closed())
52
23
  return;
53
24
  void lockedRooms(runtime).then((before) => {
54
- socket.rooms.standAll({ confirmed: false });
25
+ presence.lapse();
55
26
  return relocked(runtime, before);
56
- }, () => { });
27
+ }, uncaught);
57
28
  });
58
29
  }
59
30
  export function watchLocks({ store }, notify) {
@@ -1 +1 @@
1
- {"version":3,"file":"lost.d.ts","sourceRoot":"","sources":["../src/lost.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAU5C,wBAAsB,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,iBAIhF;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,QAOtE;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,iBAqC5E"}
1
+ {"version":3,"file":"lost.d.ts","sourceRoot":"","sources":["../src/lost.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,wBAAsB,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,iBAIhF;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,QAMtE;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,iBA+B5E"}
package/dist/lost.js CHANGED
@@ -1,12 +1,8 @@
1
1
  import { changeSet, mergeChangeSets } from './change-set.js';
2
- import { ERASE_BATCH, forgetInstall } from './install.js';
3
- import { recoverReads, statusShown } from './shown.js';
2
+ import { ERASE_BATCH } from './install.js';
3
+ import { unpair } from './queue.js';
4
+ import { recoverReads } from './shown.js';
4
5
  import { yielded } from './turn.js';
5
- function forget({ store, socket }, locator) {
6
- forgetInstall(store, locator);
7
- socket.rooms.forget(locator);
8
- store.forget(locator);
9
- }
10
6
  export async function eraseFenced({ store }, locators) {
11
7
  for (const locator of locators) {
12
8
  while (await store.durably((local) => local.erase(locator, ERASE_BATCH)))
@@ -14,24 +10,17 @@ export async function eraseFenced({ store }, locators) {
14
10
  }
15
11
  }
16
12
  export function fenceLive(runtime, locators) {
17
- const { store, socket, journal } = runtime;
13
+ const { store, socket, presence } = runtime;
18
14
  for (const locator of new Set(locators)) {
19
- if (!store.fences.raise(locator, socket.session.now().discoveries))
15
+ if (!presence.lose(locator, socket.session.now().discoveries))
20
16
  continue;
21
- forget(runtime, locator);
22
- journal.record(`room lost ${locator}`);
17
+ store.forget(locator);
23
18
  }
24
19
  }
25
20
  export async function loseRooms(runtime, locators) {
26
- const { store } = runtime;
21
+ const { store, presence } = runtime;
27
22
  fenceLive(runtime, locators);
28
- const fresh = [...new Set(locators)].filter((locator) => {
29
- const fence = store.fences.of(locator);
30
- if (fence === undefined || fence.written)
31
- return false;
32
- store.fences.mark(locator, true);
33
- return true;
34
- });
23
+ const fresh = [...new Set(locators)].filter((locator) => presence.writing(locator));
35
24
  if (fresh.length === 0)
36
25
  return;
37
26
  let held = [];
@@ -43,7 +32,7 @@ export async function loseRooms(runtime, locators) {
43
32
  }
44
33
  catch (error) {
45
34
  for (const locator of fresh)
46
- store.fences.mark(locator, false);
35
+ presence.unwritten(locator);
47
36
  throw error;
48
37
  }
49
38
  finally {
@@ -54,8 +43,7 @@ export async function loseRooms(runtime, locators) {
54
43
  drafts: held.filter((draft) => draft.locator === locator).map(({ path }) => path),
55
44
  }))));
56
45
  recoverReads(runtime);
57
- statusShown(runtime);
58
46
  }
59
- await store.durably((local) => runtime.unpair(local));
47
+ await unpair(runtime);
60
48
  await eraseFenced(runtime, fresh);
61
49
  }
package/dist/media.d.ts CHANGED
@@ -3,6 +3,6 @@ import { type ShownAnswer } from './outcome.js';
3
3
  export declare const ROOM_MEDIA = "room-media";
4
4
  type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
5
5
  export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
6
- export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
6
+ export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient): void;
7
7
  export {};
8
8
  //# sourceMappingURL=media.d.ts.map
@@ -1 +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"}
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,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,GAAG,IAAI,CA0LxF"}
package/dist/media.js CHANGED
@@ -37,8 +37,8 @@ function drawnFor(mediaType) {
37
37
  return 'audio';
38
38
  return null;
39
39
  }
40
- export function defineRoomMedia(client, registry = customElements) {
41
- if (registry.get(ROOM_MEDIA) !== undefined)
40
+ export function defineRoomMedia(client) {
41
+ if (customElements.get(ROOM_MEDIA) !== undefined)
42
42
  return;
43
43
  const connected = Promise.resolve(client);
44
44
  class RoomMedia extends HTMLElement {
@@ -179,7 +179,7 @@ export function defineRoomMedia(client, registry = customElements) {
179
179
  if (drawn instanceof HTMLMediaElement) {
180
180
  drawn.controls = true;
181
181
  drawn.preload = 'metadata';
182
- if (drawn instanceof HTMLVideoElement)
182
+ if (drawn instanceof HTMLVideoElement && 'playsInline' in drawn)
183
183
  drawn.playsInline = true;
184
184
  }
185
185
  drawn.addEventListener(drawn instanceof HTMLImageElement ? 'load' : 'loadedmetadata', () => {
@@ -214,5 +214,5 @@ export function defineRoomMedia(client, registry = customElements) {
214
214
  void this.#load();
215
215
  }
216
216
  }
217
- registry.define(ROOM_MEDIA, RoomMedia);
217
+ customElements.define(ROOM_MEDIA, RoomMedia);
218
218
  }
package/dist/memory.d.ts CHANGED
@@ -1,6 +1,8 @@
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 DiscoveredRoom, type SavedFacts, type HeadChange, type ListedAgent, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode, type TypedPath } from './adapter.js';
3
- export type MemoryRoom = DiscoveredRoom & {
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, type TypedSelection } from './adapter.js';
3
+ export type MemoryRoom = Omit<DiscoveredRoom, 'typedSelection' | 'authoredPaths'> & {
4
+ typedSelection?: TypedSelection | null;
5
+ authoredPaths?: readonly string[];
4
6
  model?: ModelResult;
5
7
  documents?: Readonly<Record<string, string>>;
6
8
  facts?: Readonly<Record<string, SavedFacts>>;
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAIZ,KAAK,UAAU,EAMf,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAKtB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,EAGf,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAGX,KAAK,aAAa,EAIlB,KAAK,SAAS,EAGd,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAuBtB,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,OAAO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_ROOM_TYPES, schemaTypes } from './attached-model.js';
1
+ import { definitionAt, documentFacts, parse } from '@agentshouse/mdmodel';
2
+ import { roomTypesOf, schemaTypes } from './attached-model.js';
3
+ import { selected } from './collection.js';
3
4
  import { sameChange } from './overlay.js';
4
5
  const ATTACHMENTS = 'attachments';
5
6
  function lastName(path) {
@@ -53,7 +54,7 @@ export function createMemoryAdapter(options = {}) {
53
54
  const listeners = new Set();
54
55
  const modeObservers = new Set();
55
56
  const scripted = new Map();
56
- const sentTurns = new Map();
57
+ const repeats = new Map();
57
58
  const historyPageSize = options.historyPageSize;
58
59
  const attached = new Map();
59
60
  const linked = new WeakMap();
@@ -104,8 +105,11 @@ export function createMemoryAdapter(options = {}) {
104
105
  }
105
106
  }
106
107
  const saved = new WeakMap();
108
+ const roomTypes = roomTypesOf(options.roomTypes);
107
109
  function factsAt(room, path, content) {
108
- const types = schemaTypes(room.model?.kind === 'model' ? room.model.snapshot.schema : null, NO_ROOM_TYPES);
110
+ const types = selected({ selection: room.typedSelection ?? null }, path)
111
+ ? roomTypes.types
112
+ : schemaTypes(room.model?.kind === 'model' ? room.model.snapshot.schema : null, roomTypes);
109
113
  let held = saved.get(types);
110
114
  if (held === undefined) {
111
115
  held = new Map();
@@ -113,7 +117,9 @@ export function createMemoryAdapter(options = {}) {
113
117
  }
114
118
  const key = `${path}\u0000${content}`;
115
119
  if (!held.has(key)) {
116
- const facts = documentFacts(path, parse(content, path), { types });
120
+ const facts = documentFacts(path, parse(content, path, definitionAt({ types }, path, options.typedPaths)), {
121
+ types,
122
+ });
117
123
  held.set(key, facts === null ? null : JSON.parse(JSON.stringify(facts)));
118
124
  }
119
125
  return held.get(key);
@@ -147,9 +153,9 @@ export function createMemoryAdapter(options = {}) {
147
153
  roomVersion: room.roomVersion,
148
154
  operations: room.operations,
149
155
  replica: room.replica,
150
- ...(room.typedSelection === undefined ? {} : { typedSelection: room.typedSelection }),
156
+ typedSelection: room.typedSelection ?? null,
151
157
  providerOwnedPaths: room.providerOwnedPaths,
152
- authoredPaths: room.authoredPaths,
158
+ authoredPaths: room.authoredPaths ?? ['**'],
153
159
  };
154
160
  }
155
161
  function page(room, after) {
@@ -259,16 +265,14 @@ export function createMemoryAdapter(options = {}) {
259
265
  }
260
266
  function pageOf(conversation, after) {
261
267
  const messages = conversation.messages ?? [];
262
- const first = typeof after === 'string' ? messages.findIndex((message) => message.position > after) : 0;
268
+ const first = typeof after === 'string' ? messages.findIndex((message) => message.change > after) : 0;
263
269
  const from = first === -1 ? messages.length : first;
264
270
  const page = messages.slice(from, from + (historyPageSize ?? messages.length));
265
271
  const last = page.at(-1);
266
272
  return {
267
273
  conversation: conversation.conversation,
268
274
  messages: page,
269
- ...(last !== undefined && from + page.length < messages.length
270
- ? { next: last.position }
271
- : {}),
275
+ ...(last !== undefined && from + page.length < messages.length ? { next: last.change } : {}),
272
276
  };
273
277
  }
274
278
  function historiesOf(request) {
@@ -288,11 +292,20 @@ export function createMemoryAdapter(options = {}) {
288
292
  function conversationAction(request) {
289
293
  const name = request.name;
290
294
  const input = (request.input ?? {});
295
+ const operation = typeof input.operation_id === 'string' ? `${name}\u0000${input.operation_id}` : null;
296
+ const first = (answer) => {
297
+ if (operation !== null)
298
+ repeats.set(operation, answer);
299
+ return answer;
300
+ };
301
+ const repeated = operation === null ? undefined : repeats.get(operation);
291
302
  if (name === 'conversations/create') {
303
+ if (repeated !== undefined)
304
+ return repeated;
292
305
  issued += 1;
293
306
  const conversation = `conversation-${issued}`;
294
307
  scripted.set(conversation, { conversation });
295
- return { kind: 'action', result: { conversation_id: conversation } };
308
+ return first({ kind: 'action', result: { conversation_id: conversation } });
296
309
  }
297
310
  const named = typeof input.conversation_id === 'string' ? input.conversation_id : '';
298
311
  const conversation = scripted.get(named);
@@ -308,24 +321,30 @@ export function createMemoryAdapter(options = {}) {
308
321
  if (outcome !== undefined)
309
322
  return outcome;
310
323
  if (name === 'conversations/send') {
311
- const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
312
- const answered = operation === null ? undefined : sentTurns.get(operation);
313
- if (answered !== undefined)
314
- return { kind: 'action', result: { message_id: answered } };
324
+ if (repeated !== undefined)
325
+ return repeated;
315
326
  issued += 1;
316
- const turn = `turn-${issued}`;
317
- if (operation !== null)
318
- sentTurns.set(operation, turn);
319
- return { kind: 'action', result: { message_id: turn } };
327
+ return first({ kind: 'action', result: { message_id: `turn-${issued}` } });
320
328
  }
321
329
  if (name === 'conversations/delete')
322
330
  scripted.delete(named);
323
331
  return { kind: 'action', result: { conversation_id: named } };
324
332
  }
333
+ function decided(request) {
334
+ const { request: asked, message, decision, } = (request.input ?? {});
335
+ return {
336
+ kind: 'action',
337
+ result: {
338
+ request: asked,
339
+ ...(message === undefined ? {} : { message }),
340
+ state: decision === 'approve' ? 'started' : 'declined',
341
+ },
342
+ };
343
+ }
325
344
  function announceList() {
326
345
  const entries = [...scripted.values()].flatMap(({ conversation, listed, messages = [] }) => listed === undefined
327
346
  ? []
328
- : [{ conversation, ...listed, newest: messages.at(-1)?.position ?? null }]);
347
+ : [{ conversation, ...listed, newest: messages.at(-1)?.change ?? null }]);
329
348
  for (const listener of listeners) {
330
349
  listener({ kind: 'list', entries, whole: true, more: false, cursor: null });
331
350
  }
@@ -599,7 +618,7 @@ export function createMemoryAdapter(options = {}) {
599
618
  return { kind: 'room-not-readable', locator: request.locator };
600
619
  const blob = heldBlob(room, request.path);
601
620
  return blob === undefined
602
- ? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
621
+ ? { kind: 'rejected', code: 'not_found', fields: {}, retryable: false }
603
622
  : { kind: 'binary', body: blob.stream(), mediaType: blob.type };
604
623
  }, request);
605
624
  },
@@ -610,7 +629,7 @@ export function createMemoryAdapter(options = {}) {
610
629
  return { kind: 'room-not-readable', locator: request.locator };
611
630
  const blob = heldBlob(room, request.path);
612
631
  if (blob === undefined) {
613
- return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
632
+ return { kind: 'rejected', code: 'not_found', fields: {}, retryable: false };
614
633
  }
615
634
  const url = linked.get(blob) ?? URL.createObjectURL(blob);
616
635
  linked.set(blob, url);
@@ -631,6 +650,8 @@ export function createMemoryAdapter(options = {}) {
631
650
  return resolveScript(scripts.action, () => {
632
651
  if (request.name.startsWith('conversations/'))
633
652
  return conversationAction(request);
653
+ if (request.name === 'agent-functions/decide')
654
+ return decided(request);
634
655
  return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
635
656
  }, request).then((answer) => {
636
657
  if (answer.kind === 'action' && answer.at !== undefined)