@agentshouse/mdruntime-adapter 0.1.0-c26cd225263b7 → 0.1.0-c271876d9f81d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -10,13 +10,14 @@ App code reaches the MD Runtime through the remote client. The surfaces are
10
10
  Rooms, Query, Search, Observe, Types, Room Draft, Save, History, Call, Reached, Log,
11
11
  the reported persistence answer, reauthorization, conversation, the chat draft,
12
12
  and Presentation State. Sync Status, the Service Mode, the storage-loss
13
- statement and the deployment facts are observations only.
13
+ statement, the deployment facts and the signed-in member are observations only.
14
14
 
15
15
  The host attaches each port with its reach, and every member and observation
16
- answers within it: a Room outside it answers as one the replica does not hold, a
17
- Room reached for single Documents shows only those Documents, the Types of the
18
- models that govern them and no attachments, and without conversations the
19
- conversation members, the chat draft and the conversation observation hold none.
16
+ answers within it: a Room outside it answers as one the replica does not hold,
17
+ Rooms lists only the Rooms reached whole, a Room reached for single Documents
18
+ shows only those Documents and the Types of the models that govern them, and
19
+ without conversations the conversation members, the chat draft and the
20
+ conversation observation hold none.
20
21
  A change of the reach reaches every open observation as its new value, a query
21
22
  keeping every unchanged Document the same object.
22
23
 
@@ -26,7 +27,11 @@ value whole and returns its unsubscribe, and `close()` ends the observation.
26
27
  Closing the port ends every handle and rejects every pending call and
27
28
  observation; a client that reconnects observes again.
28
29
 
29
- Each conversation a Provider card names is held complete in the browser.
30
+ Each conversation the Provider's conversation list names is held complete in the
31
+ browser. `conversation.list()` and `observe('conversations')` answer each with its
32
+ Agent's identity and name, its name, created and finished times, last outcome and live
33
+ `state`: `asking` while a question waits, `working` while a turn runs, else `idle`,
34
+ and `started`, when the running turn began, or `null`.
30
35
  Observe one with `observe('conversation', id, { limit })`: the view
31
36
  holds its latest `limit` messages, or all of them, oldest first, its chat
32
37
  draft, and what the Provider streams for it whether or not anything views it:
@@ -52,7 +57,10 @@ effect the Provider places in a Room carries `at`, that Room and Room Version;
52
57
  reached it, and the MD Runtime keeps refreshing that Room until it has;
53
58
  `reached(room, roomVersion, path)` answers whether the held confirmed copy of
54
59
  that document was written at a later Room Version. Each History revision
55
- names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`. Every
60
+ names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`.
61
+ History of a Path no current document holds answers the removed document's
62
+ revisions with `deleted: true`, newest first; that revision is what a link to
63
+ the Path opens. Every
56
64
  member of the
57
65
  client is asynchronous. Results are detached snapshots. Nothing in this
58
66
  surface returns the authorization, performs a request the App's code
@@ -61,6 +69,15 @@ composes, or exposes the browser store.
61
69
  Read the deployment facts with `observe('deployment-facts')`. Interpret the
62
70
  opaque value using the host's contract.
63
71
 
72
+ `observe('member')` answers who uses the App: the User the Provider signed in,
73
+ `{ kind: 'user', id, name }` in the shape of a change's `author`, so a Document
74
+ whose `change.author.id` equals its `id` is that User's own. It is `null` until
75
+ the Provider first names one, and where it names none, such as a Site. The
76
+ MD Runtime keeps it with the Local Replicas, so it answers offline once known,
77
+ and every port hears the next member the Provider names; signing out answers
78
+ `null`, then ends the observation with the authorization. It is the only way App code learns who
79
+ uses it.
80
+
64
81
  The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
65
82
  ships in no bundle.
66
83
 
@@ -74,22 +91,28 @@ data:
74
91
  - **Filter.** `rooms` names Room locators and defaults to every Room. `types`
75
92
  names MD Types, and `any` names untyped Markdown Documents. `pathPrefix` is a
76
93
  directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
77
- - **Fields.** `where` names frontmatter fields, ANDs them, and nests `$and` and
78
- `$or`. A bare value is equality; the operators are `$eq`, `$ne`, `$in`, `$nin`,
79
- `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and `$exists`. Equality on a list
80
- asks whether it contains the value. Missing, null and empty differ:
94
+ - **Fields.** Every frontmatter value is named by JSON Pointer: `/status`,
95
+ `/shipping/city`, `~1` for a `/` and `~0` for a `~` in a key. A segment that
96
+ meets a list applies to every item and a number names one item. `where` names
97
+ pointers, ANDs them, and nests `$and` and `$or`; a pointer through a list holds
98
+ when any item satisfies it. A bare value is equality; the operators are `$eq`,
99
+ `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and
100
+ `$exists`. Equality on a list asks whether it contains the value. Missing, null and empty differ:
81
101
  `$exists: false` keeps a missing field, `null` an explicit null, `''` empty
82
102
  text and `$size: 0` an empty list. A date compares in calendar order and never
83
103
  with a date-time. A reference compares by the Room Path it resolves to.
84
- Untyped frontmatter is plain values. There is no text containment or regular
104
+ Untyped frontmatter, and a value under `oneOf` or a conditional, is plain
105
+ values. There is no text containment or regular
85
106
  expression.
86
107
  - **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
87
- reference `field` points to a matching Document of the same Room.
88
- `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
108
+ reference at pointer `field`, at any depth, points to a matching Document of the
109
+ same Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
89
110
  matching Document of the same Room references. Each keeps a Document once.
90
111
  - **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
91
- `preamble`, `markdown`, `backlinks` and `change`, where `fields` and `sections`
92
- are `'all'` or a list of names. Room and Path always return; a Markdown
112
+ `preamble`, `markdown`, `backlinks` and `change`, where `fields` is `'all'` or a
113
+ list of pointers and `sections` `'all'` or a list of names. Selected pointers
114
+ return the frontmatter holding only them, nested as written. A backlink names
115
+ the referring Path, MD Type and the pointer it came from as `field`. Room and Path always return; a Markdown
93
116
  Document also returns its MD Type. A non-Markdown Document or binary link
94
117
  target returns only Room and Path. An unselected part is absent. Select only
95
118
  what a screen shows: a list that selects the Markdown hears every edit of it.
@@ -98,13 +121,13 @@ data:
98
121
  or `null` for a write the Provider made itself, and `time` is the Provider's
99
122
  ISO 8601 change time. It is `null` where the Provider delivered no time, as at
100
123
  a Site. An unsent edit or move keeps it, an unsent creation has none, and a
101
- saved write takes the Provider's own once it is Accepted and refreshed. A
124
+ saved write takes the Provider's own once it is Accepted. A
102
125
  Room's last change is its Document with the latest `time`.
103
126
  - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
104
127
  with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
105
128
  `room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
106
- over every match and ordered by `count` or a key. `limit` bounds the Documents
107
- or the groups.
129
+ over every match and ordered by `count` or a key. A sort or group takes only a
130
+ pointer that holds one value. `limit` bounds the Documents or the groups.
108
131
  - **Results and errors.** A result carries no Room Version: read freshness from
109
132
  Rooms and Sync Status. An invalid query fails with `invalid-query`,
110
133
  `unknown-type`, `unknown-field` or `wrong-kind`, naming where, and never
@@ -201,13 +224,28 @@ an App's override respected. What an App Creator's agent adds carries none
201
224
  of these promises by itself. Reading, querying and searching never wait for
202
225
  the network. Data lives only in the App Creator's browser and with the Provider.
203
226
 
204
- ## App code imports only the client entry and never constructs a Runtime
205
-
206
- App code imports only `@agentshouse/mdruntime/client` and calls
207
- `connectMdRuntime` on the port the host hands it. It never constructs a
208
- Runtime. It does not import the package main, the host entry, or the Adapter
209
- package, and it does not call `serveMdRuntime`. Hosts
210
- and tests use those entries; the served App does not.
227
+ ## App code takes the client its host hands it and never constructs a Runtime
228
+
229
+ App code takes the client its host hands it: in House,
230
+ `connectHouseBridge().runtime` from `@agentshouse/app-bridge` resolves to the
231
+ client House built into the page. It never constructs a Runtime or a client.
232
+ It imports only types from `@agentshouse/mdruntime/client`, does not call
233
+ `connectMdRuntime` or `serveMdRuntime`, and does not import the package main,
234
+ the host entry, or the Adapter package. Hosts and tests use those entries; the
235
+ served App does not.
236
+
237
+ A React App may observe and save through `@agentshouse/mdruntime/react`, which
238
+ names React as a peer dependency. `useObserve(client, topic, ...input)` takes
239
+ the arguments of `observe` and returns `{ state: 'loading' }` until the topic's
240
+ first value arrives, then `{ state: 'ready', value }`, re-rendering on each
241
+ change; a `null` client observes nothing and stays loading. `useSave(client)` returns `busy`, the last `outcome` or `failure`, and
242
+ `save(room, roomDrafts)`, which writes each Path's parts onto the Room Draft
243
+ already there, keeping the bases its parts have, or onto a new one, and saves
244
+ them together. A refused Save leaves the Room Drafts for the App to save again
245
+ or discard; a failure is recorded and rejects. `saveRoomDrafts(client, room,
246
+ roomDrafts)` is that save outside a component. A react-admin or Refine App
247
+ reads and writes its Rooms through the data providers of
248
+ `@agentshouse/mdruntime-families`.
211
249
 
212
250
  ## What an agent must never do
213
251
 
package/README.md CHANGED
@@ -19,12 +19,12 @@ import { serveMdRuntime } from '@agentshouse/mdruntime/host';
19
19
  import { createAgentsHouseAdapter } from '@agentshouse/mdruntime-adapter';
20
20
 
21
21
  const adapter = createAgentsHouseAdapter({ transport, authorize });
22
- const host = serveMdRuntime({ adapter, shell, requiredGuarantees: [] });
22
+ const host = serveMdRuntime({ adapter, shell });
23
23
  host.attach(port, 'my-app');
24
24
  ```
25
25
 
26
- App code never imports this package; it reaches the Runtime only through
27
- `@agentshouse/mdruntime/client`. The rules an App's agent follows are in the
26
+ App code never imports this package; it reaches the Runtime only through the
27
+ client its host hands it. The rules an App's agent follows are in the
28
28
  package's `AGENTS.md`.
29
29
 
30
30
  ## License
package/dist/actions.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationCards } from '@agentshouse/mdruntime';
1
+ import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents } from '@agentshouse/mdruntime';
2
2
  import type { HouseDoorAnswer, HouseTransport } from './transport.js';
3
- export declare const HOUSE_CONVERSATION_CARDS: ConversationCards;
3
+ export declare function houseConversationAgents(locator: string): ConversationAgents;
4
4
  export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
5
5
  export declare function houseAction(transport: HouseTransport, request: ActionRequest): Promise<ActionResult>;
6
6
  export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAGvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAkBtE,eAAO,MAAM,wBAAwB,EAAE,iBAKtC,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CASvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAQvB;AA4DD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAWjF;AAuLD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAGxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAkBtE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAE3E;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CASvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAQvB;AA4DD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAWjF;AAuLD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE"}
package/dist/actions.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { changeBatchIdentity, } from '@agentshouse/mdruntime';
2
2
  import { doorRefusal } from './refusal.js';
3
- import { PRIVATE_LOCATOR } from './transport.js';
4
3
  const HISTORY_PAGE = 100;
5
4
  const HISTORY_CONVERSATIONS = 64;
6
5
  const OCTET_STREAM = 'application/octet-stream';
@@ -13,12 +12,9 @@ const CONVERSATION_ROUTES = new Map([
13
12
  ['conversation.delete', '/door/conversations/delete'],
14
13
  ['conversation.history', '/door/conversations/history'],
15
14
  ]);
16
- export const HOUSE_CONVERSATION_CARDS = {
17
- locator: PRIVATE_LOCATOR,
18
- type: 'house-conversation',
19
- identity: 'conversation',
20
- agent: 'agent',
21
- };
15
+ export function houseConversationAgents(locator) {
16
+ return { locator, type: 'house-agent', identity: 'agent', name: 'name' };
17
+ }
22
18
  export function declaredActions(routes) {
23
19
  const mapped = new Map([...CONVERSATION_ROUTES].map(([name, route]) => [route.slice('/door/'.length), name]));
24
20
  return routes.map((route) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,EAWd,MAAM,wBAAwB,CAAC;AAqChC,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAyBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAsBjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA0WpF"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,EAWd,MAAM,wBAAwB,CAAC;AAqChC,OAAO,EAOL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAyBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAsBjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA0WpF"}
package/dist/adapter.js CHANGED
@@ -5,9 +5,9 @@ import { createSiteAdapter } from './site.js';
5
5
  import { bootstrapOf, contentPrefixes, matchesScope, parseEnumeration, parseEnvelope, parseGrant, refreshFrom, viewOf, } from './read.js';
6
6
  import { acceptedLinks, enumeratedLinks, heldLinks, scopeLinks, streamedLinks, } from './links.js';
7
7
  import { houseAction } from './actions.js';
8
- import { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';
8
+ import { classifyDoor, classifyRead, discoveryFailure, doorRefusal } from './refusal.js';
9
9
  import { houseNotifications } from './stream.js';
10
- import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_REVISIONS, PRIVATE_LOCATOR, } from './transport.js';
10
+ import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_REVISIONS, } from './transport.js';
11
11
  import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
12
12
  import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
13
13
  const UNCERTAIN = { kind: 'transport-uncertainty' };
@@ -104,9 +104,7 @@ export function createAgentsHouseAdapter(options) {
104
104
  const { authority, position, log_epoch: logEpoch } = body;
105
105
  if (typeof position !== 'string' || typeof logEpoch !== 'string')
106
106
  return result;
107
- const locator = authority === undefined
108
- ? PRIVATE_LOCATOR
109
- : [...tracked.values()].find((entry) => entry.authority === authority)?.locator;
107
+ const locator = [...tracked.values()].find((entry) => entry.authority === authority)?.locator;
110
108
  if (locator === undefined)
111
109
  return result;
112
110
  return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };
@@ -142,7 +140,7 @@ export function createAgentsHouseAdapter(options) {
142
140
  answers.push(envelope === null ? UNCERTAIN_READ : await bootstrappedRoom(envelope, entry));
143
141
  continue;
144
142
  }
145
- answers.push(failure.kind === 'beyond-horizon' ? UNCERTAIN_READ : failure);
143
+ answers.push(failure);
146
144
  }
147
145
  }
148
146
  return answers;
@@ -167,7 +165,7 @@ export function createAgentsHouseAdapter(options) {
167
165
  prefixes: open.flatMap((ask) => contentPrefixes(ask.entry)),
168
166
  positions: open.map((ask) => presented(ask.entry.authority, ask.from)),
169
167
  });
170
- const classified = open.map((ask) => classifyDoor(answer.status, answer.body, ask.entry.locator));
168
+ const classified = open.map((ask) => classifyRead(answer.status, answer.body, ask.entry.locator));
171
169
  if (classified[0]?.kind === 'beyond-horizon') {
172
170
  const named = doorRefusal(answer.body)?.fields.authority;
173
171
  const expired = open.filter((ask) => ask.entry.authority === named);
@@ -198,7 +196,7 @@ export function createAgentsHouseAdapter(options) {
198
196
  const paths = batchPaths(changes);
199
197
  const sha256 = await deltaDigest(delta);
200
198
  if (handed !== undefined && handed.sha256 === sha256) {
201
- return { body: { ...head, paths, upload: handed } };
199
+ return { body: { ...head, paths, upload: handed, runtime: notifications.runtime } };
202
200
  }
203
201
  const minted = await transport.door(DOOR_BATCH_UPLOAD, { ...head, paths, bytes, sha256 });
204
202
  if (minted.status !== 200) {
@@ -221,10 +219,10 @@ export function createAgentsHouseAdapter(options) {
221
219
  return { outcome: UNCERTAIN };
222
220
  const upload = { url: holding.url, operation: holding.operation, bytes, sha256 };
223
221
  await keep(upload);
224
- return { body: { ...head, paths, upload } };
222
+ return { body: { ...head, paths, upload, runtime: notifications.runtime } };
225
223
  }
226
224
  async function submit(head, changes, delta, bytes, entry, handed, keep) {
227
- const inline = { ...head, changes };
225
+ const inline = { ...head, changes, runtime: notifications.runtime };
228
226
  const prepared = uploadable(inline, bytes, declared())
229
227
  ? await uploaded(head, changes, delta, bytes, entry, handed, keep)
230
228
  : { body: inline };
@@ -239,9 +237,9 @@ export function createAgentsHouseAdapter(options) {
239
237
  },
240
238
  async discover(_authorization) {
241
239
  const answer = await transport.door(DOOR_DISCOVER, { prefixes: [...DISCOVER_PREFIXES] });
242
- const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);
243
- if (classified !== null)
244
- return discoveryFailure(classified);
240
+ const failed = discoveryFailure(answer.status, answer.body);
241
+ if (failed !== null)
242
+ return failed;
245
243
  const document = parseDiscovery(answer.body);
246
244
  if (document === null)
247
245
  return { kind: 'transport-uncertainty' };
@@ -254,7 +252,10 @@ export function createAgentsHouseAdapter(options) {
254
252
  if (!tracked.has(locator))
255
253
  handed.delete(locator);
256
254
  notifications.track(entries);
257
- return mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document.actions));
255
+ return {
256
+ ...mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document)),
257
+ member: document.member,
258
+ };
258
259
  },
259
260
  async bootstrap(_authorization, request) {
260
261
  const entry = authorityFor(request.locator);
@@ -318,7 +319,7 @@ export function createAgentsHouseAdapter(options) {
318
319
  async action(_authorization, request) {
319
320
  return withAt(await houseAction(transport, request));
320
321
  },
321
- roomStream: { hold: held, observe: notifications.observe },
322
+ roomStream: { hold: held, reopen: notifications.reopen, observe: notifications.observe },
322
323
  conversations: notifications.conversations,
323
324
  serviceMode: notifications.serviceMode,
324
325
  };
@@ -1,12 +1,7 @@
1
- import type { Capability, DiscoveredRoom, Discovery, ProviderLimit, Retention } from '@agentshouse/mdruntime';
1
+ import type { Capability, DiscoveredRoom, Discovery, Member, ProviderLimit, Retention } from '@agentshouse/mdruntime';
2
2
  import { type LogPosition } from './version.js';
3
- export declare const ROOM_CONTRACT_VERSION = 1;
4
- export declare const MD_MODEL_IDENTITY = "@agentshouse/mdmodel";
5
- export declare const ROOM_VERSION_NOTIFICATIONS = "room-version-notifications";
6
3
  export declare const PROVIDER_ACTIONS = "provider-actions";
7
- export declare const MOVE_REFERENCE_REWRITES = "move-reference-rewrites";
8
4
  export declare const DISCOVER_PREFIXES: readonly string[];
9
- export declare const PRIVATE_HANDLE = "private";
10
5
  export type HouseBounds = {
11
6
  max_authored_file_bytes: number;
12
7
  max_batch_operations: number;
@@ -42,8 +37,8 @@ export type HouseAuthority = LogPosition & {
42
37
  operations: HouseOperations;
43
38
  };
44
39
  export type HouseDiscoveryDocument = {
40
+ member: Member;
45
41
  bounds: HouseBounds;
46
- mdModelVersion: string;
47
42
  authorities: readonly HouseAuthority[];
48
43
  actions: readonly string[];
49
44
  };
@@ -62,18 +57,16 @@ export type HouseSiteAuthority = LogPosition & {
62
57
  };
63
58
  export type HouseSiteDiscovery = {
64
59
  bounds: HouseBounds;
65
- mdModelVersion: string;
66
60
  authorities: readonly HouseSiteAuthority[];
67
61
  };
68
62
  export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
69
63
  export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
70
64
  export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthority[];
71
- export declare function locatorOf(authority: HouseAuthority): string;
72
65
  export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
73
66
  export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
74
67
  export declare function declaredRetention(bounds: HouseBounds): Retention;
75
- export declare function capabilities(actions: readonly string[]): readonly Capability[];
68
+ export declare function capabilities(document: HouseDiscoveryDocument): readonly Capability[];
76
69
  export declare function siteCapabilities(): readonly Capability[];
77
70
  export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
78
- export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds' | 'mdModelVersion'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
71
+ export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
79
72
  //# sourceMappingURL=discovery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AAExD,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;AAE1D,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAA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;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAMhE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,UAAU,EAAE,CAWpF;AAED,wBAAgB,gBAAgB,IAAI,SAAS,UAAU,EAAE,CAIxD;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,cAAc,GAAG,cAAc,CAmBxE;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,EAChD,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,SAAS,CAQX"}
package/dist/discovery.js CHANGED
@@ -1,13 +1,7 @@
1
- import { declaredActions, HOUSE_CONVERSATION_CARDS } from './actions.js';
2
- import { PRIVATE_LOCATOR } from './transport.js';
1
+ import { declaredActions, houseConversationAgents } from './actions.js';
3
2
  import { readPosition, roomVersion } from './version.js';
4
- export const ROOM_CONTRACT_VERSION = 1;
5
- export const MD_MODEL_IDENTITY = '@agentshouse/mdmodel';
6
- export const ROOM_VERSION_NOTIFICATIONS = 'room-version-notifications';
7
3
  export const PROVIDER_ACTIONS = 'provider-actions';
8
- export const MOVE_REFERENCE_REWRITES = 'move-reference-rewrites';
9
4
  export const DISCOVER_PREFIXES = ['/'];
10
- export const PRIVATE_HANDLE = 'private';
11
5
  const BOUND_KEYS = [
12
6
  'max_authored_file_bytes',
13
7
  'max_batch_operations',
@@ -52,6 +46,14 @@ function parseHouseModel(value) {
52
46
  return undefined;
53
47
  return { root: held.root, paths };
54
48
  }
49
+ function parseMember(value) {
50
+ if (typeof value !== 'object' || value === null)
51
+ return null;
52
+ const { user, name } = value;
53
+ if (typeof user !== 'string' || typeof name !== 'string')
54
+ return null;
55
+ return { kind: 'user', id: user, name };
56
+ }
55
57
  function parseOperations(value) {
56
58
  if (typeof value !== 'object' || value === null)
57
59
  return null;
@@ -104,11 +106,12 @@ export function parseDiscovery(body) {
104
106
  if (typeof body !== 'object' || body === null)
105
107
  return null;
106
108
  const held = body;
109
+ const member = parseMember(held.member);
110
+ if (member === null)
111
+ return null;
107
112
  const bounds = parseBounds(held.bounds);
108
113
  if (bounds === null)
109
114
  return null;
110
- if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0)
111
- return null;
112
115
  const actions = stringList(held.actions);
113
116
  if (actions === null ||
114
117
  new Set(actions).size !== actions.length ||
@@ -123,7 +126,7 @@ export function parseDiscovery(body) {
123
126
  return null;
124
127
  authorities.push(authority);
125
128
  }
126
- return { bounds, mdModelVersion: held.md_model_version, authorities, actions };
129
+ return { member, bounds, authorities, actions };
127
130
  }
128
131
  function parseSiteAuthority(value) {
129
132
  if (typeof value !== 'object' || value === null)
@@ -154,8 +157,6 @@ export function parseSiteDiscovery(body) {
154
157
  const bounds = parseBounds(held.bounds);
155
158
  if (bounds === null)
156
159
  return null;
157
- if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0)
158
- return null;
159
160
  if (!Array.isArray(held.authorities))
160
161
  return null;
161
162
  const authorities = [];
@@ -165,7 +166,7 @@ export function parseSiteDiscovery(body) {
165
166
  return null;
166
167
  authorities.push(authority);
167
168
  }
168
- return { bounds, mdModelVersion: held.md_model_version, authorities };
169
+ return { bounds, authorities };
169
170
  }
170
171
  export function siteTracked(document) {
171
172
  return document.authorities.map((authority) => ({
@@ -179,9 +180,6 @@ export function siteTracked(document) {
179
180
  logEpoch: authority.logEpoch,
180
181
  }));
181
182
  }
182
- export function locatorOf(authority) {
183
- return authority.roomHandle === PRIVATE_HANDLE ? PRIVATE_LOCATOR : authority.roomRef;
184
- }
185
183
  function schemasOf(authority) {
186
184
  return authority.houseModel === null
187
185
  ? [authority.schema]
@@ -189,7 +187,7 @@ function schemasOf(authority) {
189
187
  }
190
188
  export function trackedFrom(document) {
191
189
  return document.authorities.map((authority) => ({
192
- locator: locatorOf(authority),
190
+ locator: authority.roomRef,
193
191
  authority: authority.roomRef,
194
192
  handle: authority.roomHandle,
195
193
  schema: authority.schema,
@@ -217,28 +215,29 @@ export function declaredRetention(bounds) {
217
215
  refreshHorizon: bounds.change_retention_seconds,
218
216
  };
219
217
  }
220
- export function capabilities(actions) {
218
+ export function capabilities(document) {
219
+ const house = document.authorities.find((authority) => authority.houseModel !== null);
221
220
  return [
222
- { name: ROOM_VERSION_NOTIFICATIONS },
223
221
  {
224
222
  name: PROVIDER_ACTIONS,
225
- actions: declaredActions(actions),
226
- conversationCards: HOUSE_CONVERSATION_CARDS,
223
+ actions: declaredActions(document.actions),
224
+ ...(house === undefined
225
+ ? {}
226
+ : { conversationAgents: houseConversationAgents(house.roomRef) }),
227
227
  },
228
- { name: MOVE_REFERENCE_REWRITES },
229
228
  ];
230
229
  }
231
230
  export function siteCapabilities() {
232
231
  return [
233
- { name: ROOM_VERSION_NOTIFICATIONS },
234
232
  { name: PROVIDER_ACTIONS, actions: [{ name: 'submit', inputShape: {}, resultKind: 'house' }] },
235
233
  ];
236
234
  }
237
235
  export function discoveredRoom(authority) {
238
- const locator = locatorOf(authority);
236
+ const locator = authority.roomRef;
239
237
  return {
240
238
  name: authority.name,
241
239
  locator,
240
+ handle: authority.roomHandle,
242
241
  roomVersion: roomVersion(authority),
243
242
  operations: {
244
243
  read: [...authority.operations.read],
@@ -256,8 +255,6 @@ export function discoveredRoom(authority) {
256
255
  export function mapDiscovery(document, rooms, declared) {
257
256
  return {
258
257
  kind: 'discovery',
259
- supportedVersions: [ROOM_CONTRACT_VERSION],
260
- mdModel: { identity: MD_MODEL_IDENTITY, version: document.mdModelVersion },
261
258
  rooms,
262
259
  capabilities: declared,
263
260
  providerLimits: providerLimits(document.bounds),
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
2
- export { PRIVATE_LOCATOR } from './transport.js';
3
2
  export type { HouseByteAct, HouseByteAnswer, HouseByteTransfer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,YAAY,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { createAgentsHouseAdapter } from './adapter.js';
2
- export { PRIVATE_LOCATOR } from './transport.js';
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA0C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAiClE,wBAAgB,WAAW,CACzB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAEjC;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAQjC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC9C,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CASjC"}
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA0C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAoClE,wBAAgB,WAAW,CACzB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAEjC;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAcjC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC9C,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAWjC"}
package/dist/model.js CHANGED
@@ -1,12 +1,15 @@
1
1
  import { sha256Hex } from './digest.js';
2
2
  import { schemaOf, schemaPath } from './read.js';
3
3
  const MODEL_ABSENT = { kind: 'model-unavailable', reason: 'not-readable' };
4
- const ABSENT_SCHEMA = { schema: null, version: null };
4
+ const ABSENT_SCHEMA = { schema: null, version: null, revision: null };
5
5
  async function heldModel(read, identity) {
6
6
  if (read === null)
7
7
  return MODEL_ABSENT;
8
8
  const version = await sha256Hex(JSON.stringify(read.version));
9
- return { kind: 'model', snapshot: { identity, version, schema: read.schema } };
9
+ return {
10
+ kind: 'model',
11
+ snapshot: { identity, version, schema: read.schema, revision: read.revision },
12
+ };
10
13
  }
11
14
  async function modelsOf(tracked, read) {
12
15
  const models = {};
@@ -33,8 +36,13 @@ export function viewModels(view, tracked) {
33
36
  return undefined;
34
37
  if ('removed' in change)
35
38
  return ABSENT_SCHEMA;
36
- if ('content' in change)
37
- return { schema: change.content, version: change.version };
39
+ if ('content' in change) {
40
+ return {
41
+ schema: change.content,
42
+ version: change.version,
43
+ revision: change.revision ?? null,
44
+ };
45
+ }
38
46
  return null;
39
47
  });
40
48
  }
@@ -48,6 +56,8 @@ export function streamedModels(schemas, tracked, mode) {
48
56
  if (entry.text === undefined)
49
57
  return null;
50
58
  const version = mode === 'site' ? entry.sha256 : entry.revision;
51
- return version === undefined ? null : { schema: entry.text, version };
59
+ return version === undefined
60
+ ? null
61
+ : { schema: entry.text, version, revision: mode === 'site' ? null : version };
52
62
  });
53
63
  }
package/dist/read.d.ts CHANGED
@@ -71,6 +71,7 @@ export declare function bootstrapOf(scope: HouseScope): BootstrapPage;
71
71
  export type HouseSchema = {
72
72
  schema: string | null;
73
73
  version: string | null;
74
+ revision: string | null;
74
75
  };
75
76
  export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
76
77
  export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV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AAG,aAAa,CAsB5D;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAO9E;AAED,wBAAgB,MAAM,CACpB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,SAAS,GAAG,SAAS,CAEvB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,aAAa,CA+BnF"}
package/dist/read.js CHANGED
@@ -288,9 +288,11 @@ export function bootstrapOf(scope) {
288
288
  export function schemaOf(scope, schema) {
289
289
  const file = scope.files.find((entry) => entry.path === schema);
290
290
  if (file === undefined)
291
- return { schema: null, version: null };
291
+ return { schema: null, version: null, revision: null };
292
292
  const content = scope.contents.find((entry) => entry.path === schema);
293
- return content === undefined ? null : { schema: content.content, version: file.version };
293
+ return content === undefined
294
+ ? null
295
+ : { schema: content.content, version: file.version, revision: file.revision ?? null };
294
296
  }
295
297
  export function viewOf(enumeration, tracked) {
296
298
  return enumeration.authorities.find((entry) => entry.authority === tracked.authority);
package/dist/refusal.d.ts CHANGED
@@ -4,10 +4,9 @@ export type DoorRefusal = ProviderRefusal & {
4
4
  };
5
5
  export declare function doorRefusal(body: unknown): DoorRefusal | null;
6
6
  export declare function scopedRefusal(locator: string, scope: ScopedRefusal['scope'], refusal: DoorRefusal): ScopedRefusal;
7
- export declare function classifyDoor(status: number, body: unknown, locator: string): AdapterFailure | {
7
+ export declare function classifyDoor(status: number, body: unknown, locator: string): AdapterFailure | null;
8
+ export declare function classifyRead(status: number, body: unknown, locator: string): AdapterFailure | {
8
9
  kind: 'beyond-horizon';
9
10
  } | null;
10
- export declare function discoveryFailure(classified: AdapterFailure | {
11
- kind: 'beyond-horizon';
12
- }): DiscoverResult;
11
+ export declare function discoveryFailure(status: number, body: unknown): DiscoverResult | null;
13
12
  //# sourceMappingURL=refusal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnE,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAO7D;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,aAAa,CAEf;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,CAapD;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GACtD,cAAc,CAMhB"}
1
+ {"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnE,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAO7D;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,aAAa,CAEf;AAmBD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG,IAAI,CAMvB;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,CAGpD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAYrF"}
package/dist/refusal.js CHANGED
@@ -12,7 +12,7 @@ export function doorRefusal(body) {
12
12
  export function scopedRefusal(locator, scope, refusal) {
13
13
  return { kind: 'scoped-refusal', locator, scope, code: refusal.code, fields: refusal.fields };
14
14
  }
15
- export function classifyDoor(status, body, locator) {
15
+ function doorFailure(status, body) {
16
16
  if (status === 0)
17
17
  return { kind: 'transport-uncertainty' };
18
18
  const refusal = doorRefusal(body);
@@ -20,24 +20,41 @@ export function classifyDoor(status, body, locator) {
20
20
  return { kind: 'revoked-authorization' };
21
21
  if (refusal?.retryable === true)
22
22
  return { kind: 'transport-uncertainty' };
23
- if (refusal !== null && refusal.code === 'position_expired')
24
- return { kind: 'beyond-horizon' };
25
- if (status === 404 || refusal?.code === 'room_not_found') {
26
- return { kind: 'room-not-readable', locator };
27
- }
23
+ if (status === 404 || refusal?.code === 'room_not_found')
24
+ return { kind: 'room-not-readable' };
28
25
  if (status < 400)
29
26
  return null;
30
27
  if (refusal === null)
31
28
  return { kind: 'transport-uncertainty' };
32
- if (status === 403)
33
- return scopedRefusal(locator, 'operation', refusal);
34
- return scopedRefusal(locator, 'undisclosed', refusal);
29
+ return { kind: 'refused', scope: status === 403 ? 'operation' : 'undisclosed', refusal };
35
30
  }
36
- export function discoveryFailure(classified) {
37
- if (classified.kind === 'revoked-authorization')
38
- return classified;
39
- if (classified.kind === 'scoped-refusal') {
40
- return { kind: 'contract-unavailable', code: classified.code, fields: classified.fields };
31
+ export function classifyDoor(status, body, locator) {
32
+ const failure = doorFailure(status, body);
33
+ if (failure === null)
34
+ return null;
35
+ if (failure.kind === 'room-not-readable')
36
+ return { kind: 'room-not-readable', locator };
37
+ if (failure.kind === 'refused')
38
+ return scopedRefusal(locator, failure.scope, failure.refusal);
39
+ return failure;
40
+ }
41
+ export function classifyRead(status, body, locator) {
42
+ if (doorRefusal(body)?.code === 'expired')
43
+ return { kind: 'beyond-horizon' };
44
+ return classifyDoor(status, body, locator);
45
+ }
46
+ export function discoveryFailure(status, body) {
47
+ const failure = doorFailure(status, body);
48
+ if (failure === null)
49
+ return null;
50
+ if (failure.kind === 'revoked-authorization')
51
+ return failure;
52
+ if (failure.kind === 'refused') {
53
+ return {
54
+ kind: 'contract-unavailable',
55
+ code: failure.refusal.code,
56
+ fields: failure.refusal.fields,
57
+ };
41
58
  }
42
59
  return { kind: 'transport-uncertainty' };
43
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAMR,MAAM,wBAAwB,CAAC;AAsBhC,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AA+BxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAiIxE"}
1
+ {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAMR,MAAM,wBAAwB,CAAC;AAsBhC,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAgCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAkIxE"}
package/dist/site.js CHANGED
@@ -2,15 +2,16 @@ import { actionOutcome } from './actions.js';
2
2
  import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
3
3
  import { scopeModels, streamedModels, viewModels } from './model.js';
4
4
  import { advancedScope, bootstrapOf, parseEnumeration, parseSiteBootstrap, refreshFrom, viewOf, } from './read.js';
5
- import { classifyDoor, discoveryFailure } from './refusal.js';
5
+ import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
6
6
  import { houseNotifications } from './stream.js';
7
- import { PRIVATE_LOCATOR, SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, } from './transport.js';
7
+ import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, } from './transport.js';
8
8
  import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
9
9
  const UNCERTAIN = { kind: 'transport-uncertainty' };
10
10
  function siteRoom(tracked) {
11
11
  return {
12
12
  name: tracked.handle,
13
13
  locator: tracked.locator,
14
+ handle: tracked.handle,
14
15
  roomVersion: roomVersion(tracked),
15
16
  operations: { read: [''], sync: [''], write: [], delete: [] },
16
17
  replica: { selection: tracked.locator, admission: 'admitted' },
@@ -27,7 +28,7 @@ export function createSiteAdapter(transport) {
27
28
  const answer = await transport.door(SITE_DOOR_ENUMERATE, {
28
29
  positions: [presented(entry.authority, from)],
29
30
  });
30
- const classified = classifyDoor(answer.status, answer.body, entry.locator);
31
+ const classified = classifyRead(answer.status, answer.body, entry.locator);
31
32
  if (classified !== null)
32
33
  return classified;
33
34
  return parseEnumeration(answer.body, 'site') ?? UNCERTAIN;
@@ -36,7 +37,7 @@ export function createSiteAdapter(transport) {
36
37
  const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}`);
37
38
  const classified = classifyDoor(answer.status, answer.body, entry.locator);
38
39
  if (classified !== null)
39
- return { failure: settled(classified) };
40
+ return { failure: classified };
40
41
  const scope = parseSiteBootstrap(answer.body);
41
42
  if (scope === null)
42
43
  return { failure: UNCERTAIN };
@@ -78,9 +79,9 @@ export function createSiteAdapter(transport) {
78
79
  },
79
80
  async discover() {
80
81
  const answer = await transport.read(SITE_DOOR_DISCOVER);
81
- const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);
82
- if (classified !== null)
83
- return discoveryFailure(classified);
82
+ const failed = discoveryFailure(answer.status, answer.body);
83
+ if (failed !== null)
84
+ return failed;
84
85
  const document = parseSiteDiscovery(answer.body);
85
86
  if (document === null)
86
87
  return UNCERTAIN;
@@ -143,6 +144,7 @@ export function createSiteAdapter(transport) {
143
144
  return [presented(entry.authority, at)];
144
145
  }));
145
146
  },
147
+ reopen: notifications.reopen,
146
148
  observe: notifications.observe,
147
149
  },
148
150
  serviceMode: notifications.serviceMode,
package/dist/stream.d.ts CHANGED
@@ -9,8 +9,10 @@ export type StreamedAdvancement = {
9
9
  schemas: ReadonlyMap<string, HouseStreamEntry>;
10
10
  };
11
11
  export type HouseNotifications = {
12
+ runtime: string;
12
13
  observe(notify: (event: RoomStreamEvent) => void): () => void;
13
14
  send(rooms: readonly HouseHeldRoom[]): void;
15
+ reopen(): void;
14
16
  track(authorities: readonly TrackedAuthority[]): void;
15
17
  reach(authority: string, at: LogPosition): void;
16
18
  advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): StreamedAdvancement | null;
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EACX,eAAe,EAEf,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,SAAS,EAET,gBAAgB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vD,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,SAAS,EAET,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAgB7D,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAEvE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACrC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC9D,IAAI,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;IAC5C,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,OAAO,CACL,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,EACjB,KAAK,CAAC,EAAE,YAAY,GACnB,mBAAmB,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAuBF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CAyS5F"}
package/dist/stream.js CHANGED
@@ -6,6 +6,16 @@ function turnOperation(frame) {
6
6
  const { type: _type, conversation_id: _conversation, turn_id: _turn, ...operation } = frame;
7
7
  return structuredClone(operation);
8
8
  }
9
+ function listedConversation(listed) {
10
+ return {
11
+ conversation: listed.conversation_id,
12
+ agent: listed.agent_id,
13
+ name: listed.name,
14
+ created: listed.created_at,
15
+ finished: listed.finished_at,
16
+ outcome: listed.outcome,
17
+ };
18
+ }
9
19
  function position(value) {
10
20
  if (!/^(?:0|[1-9][0-9]*)$/.test(value))
11
21
  return null;
@@ -21,13 +31,19 @@ export function houseNotifications(transport, mode) {
21
31
  let replicated = [];
22
32
  const live = new Set();
23
33
  let opening = null;
34
+ const runtime = crypto.randomUUID();
24
35
  function emit(event) {
25
36
  for (const observer of observers)
26
37
  observer(event);
27
38
  }
28
39
  function emitConversation(event) {
29
- if (event.kind !== 'gap' && event.kind !== 'accepted-message')
40
+ if (event.kind === 'turn' ||
41
+ event.kind === 'questions' ||
42
+ event.kind === 'process' ||
43
+ event.kind === 'commands' ||
44
+ event.kind === 'options') {
30
45
  live.add(event.conversation);
46
+ }
31
47
  for (const observer of conversationObservers)
32
48
  observer(event);
33
49
  }
@@ -110,6 +126,18 @@ export function houseNotifications(transport, mode) {
110
126
  });
111
127
  return;
112
128
  }
129
+ if (frame.type === 'conversations') {
130
+ emitConversation({ kind: 'list', entries: frame.conversations.map(listedConversation) });
131
+ return;
132
+ }
133
+ if (frame.type === 'conversation') {
134
+ emitConversation({ kind: 'listed', entry: listedConversation(frame.conversation) });
135
+ return;
136
+ }
137
+ if (frame.type === 'conversation_deleted') {
138
+ emitConversation({ kind: 'unlisted', conversation: frame.conversation_id });
139
+ return;
140
+ }
113
141
  if (frame.type === 'turn' ||
114
142
  frame.type === 'process' ||
115
143
  frame.type === 'commands' ||
@@ -150,6 +178,7 @@ export function houseNotifications(transport, mode) {
150
178
  emit({ kind: 'closed', revoked });
151
179
  });
152
180
  return {
181
+ runtime,
153
182
  serviceMode: {
154
183
  observe(notify) {
155
184
  modeObservers.add(notify);
@@ -191,7 +220,12 @@ export function houseNotifications(transport, mode) {
191
220
  }
192
221
  const current = opening;
193
222
  opening = null;
194
- current?.hold(rooms);
223
+ current?.hold(rooms, runtime);
224
+ },
225
+ reopen() {
226
+ const current = opening;
227
+ opening = null;
228
+ current?.close();
195
229
  },
196
230
  track(entries) {
197
231
  locators.clear();
@@ -9,7 +9,6 @@ export declare const SITE_DOOR_DISCOVER = "/_house/door/discover";
9
9
  export declare const SITE_DOOR_BOOTSTRAP = "/_house/door/bootstrap/";
10
10
  export declare const SITE_DOOR_ENUMERATE = "/_house/door/enumerate";
11
11
  export declare const SITE_DOOR_SUBMIT = "/_house/door/submit";
12
- export declare const PRIVATE_LOCATOR = "private";
13
12
  export type HouseMode = 'credential' | 'site';
14
13
  export type HouseDoorAnswer = {
15
14
  status: number;
@@ -44,6 +43,14 @@ export type HouseStreamEntry = {
44
43
  type LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, {
45
44
  kind: K;
46
45
  }>;
46
+ export type HouseListedConversation = {
47
+ conversation_id: string;
48
+ agent_id: string;
49
+ name: string;
50
+ created_at: string;
51
+ finished_at: string | null;
52
+ outcome: string | null;
53
+ };
47
54
  export type HouseStreamFrame = {
48
55
  type: 'entries';
49
56
  authority: string;
@@ -78,6 +85,15 @@ export type HouseStreamFrame = {
78
85
  type: 'options';
79
86
  conversation_id: string;
80
87
  options: LiveFact<'options'>['options'];
88
+ } | {
89
+ type: 'conversations';
90
+ conversations: readonly HouseListedConversation[];
91
+ } | {
92
+ type: 'conversation';
93
+ conversation: HouseListedConversation;
94
+ } | {
95
+ type: 'conversation_deleted';
96
+ conversation_id: string;
81
97
  } | {
82
98
  type: 'signal';
83
99
  service_mode: string;
@@ -88,7 +104,8 @@ export type HouseHeldRoom = {
88
104
  log_epoch: string;
89
105
  };
90
106
  export type HouseOpening = {
91
- hold(rooms: readonly HouseHeldRoom[]): void;
107
+ hold(rooms: readonly HouseHeldRoom[], runtime: string): void;
108
+ close(): void;
92
109
  };
93
110
  export type HouseStream = {
94
111
  observe(receive: (frame: HouseStreamFrame) => void): () => void;
@@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ClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7D,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5D,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG;IACvC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/C,CAAC"}
package/dist/transport.js CHANGED
@@ -8,4 +8,3 @@ export const SITE_DOOR_DISCOVER = '/_house/door/discover';
8
8
  export const SITE_DOOR_BOOTSTRAP = '/_house/door/bootstrap/';
9
9
  export const SITE_DOOR_ENUMERATE = '/_house/door/enumerate';
10
10
  export const SITE_DOOR_SUBMIT = '/_house/door/submit';
11
- export const PRIVAT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AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE1D;AA6CD,MAAM,MAAM,gBAAgB,GACxB,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GAC7C,CAAC,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GAAG;IAAE,SAAS,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,CAAC,CAAC;AAE/F,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,gBAAgB,CA4DlB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;IAEjF,IAAI,EAAE,UAAU;IAChB,QAAQ;IACR,IAAI;IACJ,MAAM;QAAI,IAAI;;EAEjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1B;AAeD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,aAAa,CAgDf"}
package/dist/write.js CHANGED
@@ -1,4 +1,4 @@
1
- import { parseOriginals } from './read.js';
1
+ import { headChange, parseOriginals } from './read.js';
2
2
  import { sha256Hex, textBytes } from './digest.js';
3
3
  import { nativePath, roomLocalPath } from './map.js';
4
4
  import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
@@ -138,6 +138,9 @@ function material(value, handle) {
138
138
  return null;
139
139
  if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')
140
140
  return null;
141
+ const head = headChange(file);
142
+ if (head === null)
143
+ return null;
141
144
  let path;
142
145
  try {
143
146
  path = roomLocalPath(file.path, handle);
@@ -149,6 +152,7 @@ function material(value, handle) {
149
152
  path,
150
153
  content: file.content,
151
154
  revision: typeof file.revision === 'string' ? file.revision : null,
155
+ ...(head === undefined ? {} : { head }),
152
156
  });
153
157
  }
154
158
  return held;
@@ -166,7 +170,7 @@ export function mutationOutcome(status, body, locator, handle) {
166
170
  if (refusal !== null && refusal.code === 'service_mode_write_halted') {
167
171
  return { kind: 'write-halted' };
168
172
  }
169
- if (refusal !== null && refusal.code === 'operation_expired')
173
+ if (refusal !== null && refusal.code === 'expired')
170
174
  return { kind: 'expired' };
171
175
  if (refusal !== null && refusal.code === 'edit_conflict') {
172
176
  const { current, ...fields } = refusal.fields;
@@ -183,9 +187,8 @@ export function mutationOutcome(status, body, locator, handle) {
183
187
  classified?.kind === 'transport-uncertainty') {
184
188
  return { kind: 'retryable-refusal', code: refusal.code, fields: refusal.fields, reset };
185
189
  }
186
- if (classified !== null && classified.kind !== 'scoped-refusal') {
187
- return classified.kind === 'beyond-horizon' ? { kind: 'expired' } : classified;
188
- }
190
+ if (classified !== null && classified.kind !== 'scoped-refusal')
191
+ return classified;
189
192
  if (classified !== null && status === 403)
190
193
  return classified;
191
194
  if (refusal !== null && status >= 400) {
@@ -206,6 +209,7 @@ export function mutationOutcome(status, body, locator, handle) {
206
209
  return { kind: 'transport-uncertainty' };
207
210
  const documents = {};
208
211
  const revisions = {};
212
+ const changes = {};
209
213
  const removals = [];
210
214
  for (const entry of contents) {
211
215
  if (entry.content === null || entry.revision === null) {
@@ -214,12 +218,15 @@ export function mutationOutcome(status, body, locator, handle) {
214
218
  }
215
219
  documents[entry.path] = entry.content;
216
220
  revisions[entry.path] = entry.revision;
221
+ if (entry.head !== undefined)
222
+ changes[entry.path] = entry.head;
217
223
  }
218
224
  return {
219
225
  kind: 'accepted',
220
226
  roomVersion: roomVersion(at),
221
227
  documents,
222
228
  revisions,
229
+ changes,
223
230
  removals: removals.sort(),
224
231
  originals,
225
232
  };
@@ -253,9 +260,8 @@ function revisionAuthor(entry) {
253
260
  }
254
261
  export function historyOutcome(status, body, locator, request) {
255
262
  const classified = classifyDoor(status, body, locator);
256
- if (classified !== null) {
257
- return classified.kind === 'beyond-horizon' ? { kind: 'transport-uncertainty' } : classified;
258
- }
263
+ if (classified !== null)
264
+ return classified;
259
265
  if (status !== 200 || typeof body !== 'object' || body === null) {
260
266
  return { kind: 'transport-uncertainty' };
261
267
  }
@@ -302,5 +308,6 @@ export function historyOutcome(status, body, locator, request) {
302
308
  kind: 'history',
303
309
  revisions,
304
310
  ...(typeof next === 'number' ? { pageToken: String(next) } : {}),
311
+ ...(held.deleted === true ? { deleted: true } : {}),
305
312
  };
306
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-c26cd225263b7",
3
+ "version": "0.1.0-c271876d9f81d",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "LICENSE"
26
26
  ],
27
27
  "dependencies": {
28
- "@agentshouse/mdmodel": "0.1.0-c6b0c6dc1a195",
29
- "@agentshouse/mdruntime": "0.1.0-ca7c26c6bc27e"
28
+ "@agentshouse/mdmodel": "0.1.0-c0d316445d94f",
29
+ "@agentshouse/mdruntime": "0.1.0-c7274d650bd05"
30
30
  }
31
31
  }