@agentshouse/mdruntime-adapter 0.1.0-cdfc733e397ee → 0.1.0-ce1f911b3b195

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
@@ -5,295 +5,299 @@ Repository, change it, build, and push. They are documentation, not enforcement.
5
5
 
6
6
  ## The MD Runtime API
7
7
 
8
- App code reaches the MD Runtime through the remote client. The surfaces are
9
- Rooms, Query, Search, Observe, Types, Room Draft, Save, History, the binary file
10
- reads, Call, Reached, Log, the reported persistence answer, reauthorization,
11
- conversation, the chat draft, and Presentation State. Sync Status, the Service
12
- Mode, the storage-loss statement, the deployment facts and the signed-in member
13
- are observations only.
14
-
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,
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. A change of the reach reaches every open
21
- observation as its new value, a query keeping unchanged Documents the same objects.
22
-
23
- Every `observe` resolves, once its first value has arrived, to a handle:
24
- `current()` is the latest complete value, `subscribe(listener)` hears each later
25
- value whole and returns its unsubscribe, and `close()` ends the observation.
26
- Closing the port ends every handle and rejects every pending call and
27
- observation; a client that reconnects observes again.
28
-
29
- `observe('agents')` answers every Agent a new conversation can go to, each
30
- `{ identity, name }`, whether or not it has a conversation yet. Each conversation
31
- the Provider's conversation list names is held complete in the browser.
32
- `conversation.list()` and `observe('conversations')` answer each with its Agent's
33
- identity and name, its name, created and finished times, last outcome and live
34
- `state`: `asking` while a question waits, `working` while a turn runs, else
35
- `idle`, and `started`, when the running turn began, or `null`. Observe one with
36
- `observe('conversation', id, { limit })`: the view holds its latest `limit`
37
- messages, or all of them, oldest first, its chat draft, and what the Provider
38
- streams for it whether or not anything views it: the running `turn` with its
39
- message parts and its context in use and window, the open questions, the process
40
- state, and the CLI's commands and options. These live only in memory: the
41
- message accepted under the turn's id replaces the running turn, and none of them
42
- is stored or searchable. `chatDraft.write` and `chatDraft.discard` keep what the
43
- App Creator composes; sending it is a Provider Action that needs the Provider
44
- reachable and is never queued.
45
-
46
- A binary file at a Path is a binary Path entry. Query lists it by `path`, and
47
- History each of its revisions, with its `binaryFile` record and never its bytes:
48
- `{ state: 'accepted', revision, path, fileRef, byteLength, mediaType, sha256 }`,
49
- or, from a Save until the Provider accepts it, `{ state: 'pending', localId,
50
- path, byteLength, mediaType, sha256 }`. Write one with a Room Draft whose only
51
- part is `file: { blob }`, the `Blob`'s `type` its media type: Save keeps the
52
- bytes in its Pending Change, offline too, and acceptance gives the record the
53
- Provider's revision. Move or remove one as a Document, a pending one before or
54
- after Save too, its bytes following; once its Pending Change has gone to the
55
- Provider, Save refuses that as `unknown-revision` until it is accepted.
56
- `binaryFile.read(room, path, revision?)` answers a pending record's saved bytes,
57
- or asks the Provider again on every read of an accepted one or of a History
58
- revision, a removed file's last included, keeping nothing. Text, a Record
59
- attachment or a conversation message may name a file by its `fileRef`; read it
60
- with `binaryFile.readReference({ fileRef, referrer })`, the referrer being the
61
- `referrer` the Provider gave beside it, or `{ room, path }` of the document whose
62
- text names it. Both answer `{ kind: 'binary', blob }` or a refusal or failure.
63
-
64
- Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never
65
- touch the network. History, the binary file reads and Call go to the Provider
66
- through the Adapter. Call takes the Action names the Adapter declares; any other
67
- name answers `undeclared` without reaching the Provider. A Call result whose
68
- effect the Provider places in a Room carries `at`, that Room and Room Version;
69
- `reached(room, roomVersion)` answers whether the Room's confirmed state has
70
- reached it, and the MD Runtime keeps refreshing that Room until it has;
71
- `reached(room, roomVersion, path)` answers whether the held confirmed copy of
72
- that document was written at a later Room Version. Each History revision
73
- names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`.
74
- History of a Path no current document holds answers the removed document's
75
- revisions with `deleted: true`, newest first; that revision is what a link to
76
- the Path opens. Every member of the client is asynchronous. Results are
77
- detached snapshots. Nothing in this surface returns the authorization, performs
78
- a request the App's code composes, or exposes the browser store.
79
-
80
- Every refusal and failure carries `code` and `retryable`: each Call and History
81
- answer other than its result, a refused Save or Room Draft write, a returned Room
82
- Draft's reason, a Room's refusal and the Connection Refusal, and every error a
83
- member rejects with, beside its message. A Provider refusal carries the
84
- Provider's own `retryable`. Every code and every value the API answers is open:
85
- handle one you do not know by its `code` and `retryable`.
86
-
87
- Read the deployment facts with `observe('deployment-facts')`, an opaque value
88
- the host's contract interprets. `observe('member')` answers who uses the App:
89
- the User the Provider signed in, `{ kind: 'user', id, name }` in the shape of a
90
- change's `author`, so a Document whose `change.author.id` equals its `id` is that
91
- User's own. It is `null` until the Provider first names one, and where it names
92
- none, such as a Site. The MD Runtime keeps it with the Local Replicas, so it
93
- answers offline once known, and every port hears the next member the Provider
94
- names; signing out answers `null`, then ends the observation with the
95
- authorization. It is the only way App code learns who uses it.
8
+ App code reaches the MD Runtime through the remote client. The surfaces are Rooms,
9
+ Query, Search, Observe, Types, Room Draft, Save, History, the binary file reads, Call,
10
+ Reached, Log, the reported persistence answer, reauthorization, conversation, the chat
11
+ draft, and Presentation State. Sync Status, readiness, the Service Mode, the storage-loss
12
+ statement, the deployment facts and the signed-in member are observations only.
13
+
14
+ The host attaches each port with its reach, and every member and observation answers
15
+ within it: a Room outside it answers as one the replica does not hold, Rooms lists only
16
+ the Rooms reached whole, a Room reached for single Documents shows only those Documents
17
+ and the Types of the models that govern them, and without conversations the conversation
18
+ members, the chat draft and the conversation observation hold none. A change of the
19
+ reach reaches every open observation as its new value, a query keeping unchanged
20
+ Documents the same objects.
21
+
22
+ Every `observe` resolves, once its first value has arrived, to a handle: `current()` is
23
+ the latest complete value, `subscribe(listener)` hears each later value whole and returns
24
+ its unsubscribe, and `close()` ends the observation. Closing the port ends every handle
25
+ and rejects every pending call and observation; a client that reconnects observes again.
26
+
27
+ `observe('agents')` answers every Agent a new conversation can go to, each `{ identity,
28
+ name }`, whether or not it has a conversation yet. Each conversation the Provider's
29
+ conversation list names is held complete in the browser. `conversation.list()` and
30
+ `observe('conversations')` answer each with its Agent's identity and name, its name,
31
+ created and finished times, last outcome and live `state`: `asking` while a question
32
+ waits, `working` while a turn runs, else `idle`, and `started`, when the running turn
33
+ began, or `null`. Observe one with `observe('conversation', id, { limit })`: the view
34
+ holds a window of its latest `limit` messages, or all of them, oldest first, its chat
35
+ draft, and what the Provider streams for it whether or not anything views it: the
36
+ running `turn` with its message parts and its context in use and window, the open
37
+ questions, the process state, and the CLI's commands and options. These live only in
38
+ memory: the message accepted under the turn's id replaces the running turn, and none of
39
+ them is stored or searchable. `chatDraft.write` and `chatDraft.discard` keep what the
40
+ App Creator composes; sending it is a Provider Action that needs the Provider reachable
41
+ and is never queued. A new conversation's chat draft is the one keyed `new:<Agent
42
+ identity>`: no conversation list removes it, a retired Agent's goes, and the first answer
43
+ to `conversation.create({ agent_id, operation_id })` moves it to the created conversation,
44
+ where `conversation.send(conversation)` sends it; a replay of that create moves nothing.
45
+
46
+ A binary file at a Path is a binary Path entry. Query lists it by `path`, and History
47
+ each of its revisions, with its `binaryFile` record and never its bytes: `{ state:
48
+ 'accepted', revision, path, fileRef, byteLength, mediaType, sha256 }`, or, from a Save
49
+ until the Provider accepts it, `{ state: 'pending', localId, path, byteLength,
50
+ mediaType, sha256 }`. Write one with a Room Draft whose only part is `file: { blob }`,
51
+ the `Blob`'s `type` its media type: Save keeps the bytes in its Pending Change, offline
52
+ too, and acceptance gives the record the Provider's revision. Move or remove one as a
53
+ Document, a pending one before or after Save too, its bytes following; once its Pending
54
+ Change has gone to the Provider, Save refuses that as `unknown-revision` until it is
55
+ accepted. `binaryFile.read(room, path, revision?)` answers a pending record's saved
56
+ bytes, or asks the Provider again on every read of an accepted one or of a History
57
+ revision, a removed file's last included, keeping nothing. Text, a Record attachment or
58
+ a conversation message may name a file by its `fileRef`; read it with
59
+ `binaryFile.readReference({ fileRef, referrer })`, the referrer being the `referrer` the
60
+ Provider gave beside it, or `{ room, path }` of the document whose text names it. Both
61
+ answer `{ kind: 'binary', blob }` or a refusal or failure.
62
+
63
+ Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never touch the
64
+ network. History, the binary file reads and Call go to the Provider through the Adapter.
65
+ Call takes the Action names the Adapter declares; any other name answers `undeclared`
66
+ without reaching the Provider. A Call result whose effect the Provider places in a Room
67
+ carries `at`, that Room and Room Version; `reached(room, roomVersion)` answers whether
68
+ the Room's confirmed state has reached it, and the MD Runtime keeps refreshing that Room
69
+ until it has; `reached(room, roomVersion, path)` answers whether the held confirmed copy
70
+ of that document was written at a later Room Version. Each History revision names its
71
+ author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`. History of a Path no
72
+ current document holds answers the removed document's revisions with `deleted: true`,
73
+ newest first; that revision is what a link to the Path opens. Every member of the client
74
+ is asynchronous. Results are detached snapshots. Nothing in this surface returns the
75
+ authorization, performs a request the App's code composes, or exposes the browser store.
76
+
77
+ Every refusal and failure carries `code` and `retryable`: each Call and History answer
78
+ other than its result, a refused Save or Room Draft write, a returned Room Draft's
79
+ reason, a Room's refusal and the Connection Refusal, and every error a member rejects
80
+ with, beside its message. A Provider refusal carries the Provider's own `retryable`.
81
+ Every code and every value the API answers is open: handle one you do not know by its
82
+ `code` and `retryable`. Only a tag telling which fields a value carries, such as an
83
+ answer's `kind`, is closed so it narrows: keep a branch for a tag you do not know. A
84
+ model with no usable types answers `types: null`, whatever its `status`.
85
+
86
+ Read the deployment facts with `observe('deployment-facts')`, an opaque value the host's
87
+ contract interprets. `observe('member')` answers who uses the App: the User the Provider
88
+ signed in, `{ kind: 'user', id, name }` in the shape of a change's `author`, so a
89
+ Document whose `change.author.id` equals its `id` is that User's own. It is `null` until
90
+ the Provider first names one, and where it names none, such as a Site. The MD Runtime
91
+ keeps it with the Local Replicas, so it answers offline once known, and every port hears
92
+ the next member the Provider names; signing out answers `null`, then ends the
93
+ observation with the authorization. It is the only way App code learns who uses it.
96
94
 
97
95
  ## Local Query rules
98
96
 
99
- `query(q)` answers once from local state; `observe('query', q)` holds the whole
100
- result and hears it again only when it changes, keeping every unchanged Document
101
- the same object, so a component can tell what changed by identity. A query is
102
- data:
103
-
104
- - **Filter.** `rooms` names Room locators and defaults to every Room. `types`
105
- names MD Types, and `any` names untyped Markdown Documents. `pathPrefix` is a
106
- directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
97
+ `query(q)` answers once from local state; `observe('query', q)` holds the whole result
98
+ and hears it again only when it changes, keeping every unchanged Document the same
99
+ object, so a component can tell what changed by identity. An answer is complete or
100
+ pending: `{ documents, coverage }` or `{ groups, coverage }` is complete for the Rooms
101
+ its `coverage` names, and `{ pending }` names each Room not yet acquired or prepared,
102
+ `[{ room, awaits }]`. Never read a pending answer as empty: draw it as loading, and
103
+ observe the query to hear the complete one. A query is data:
104
+
105
+ - **Filter.** `rooms` names Room locators and defaults to every Room. `types` names MD
106
+ Types, and `any` names untyped Markdown Documents. `pathPrefix` is a directory:
107
+ `notes` keeps `notes/a.md` and not `notes2/a.md`.
107
108
  - **Fields.** Every frontmatter value is named by JSON Pointer: `/status`,
108
- `/shipping/city`, `~1` for a `/` and `~0` for a `~` in a key. A segment that
109
- meets a list applies to every item and a number names one item. `where` names
110
- pointers, ANDs them, and nests `$and` and `$or`; a pointer through a list holds
111
- when any item satisfies it. A bare value is equality; the operators are `$eq`,
112
- `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and
113
- `$exists`. Equality on a list asks whether it contains the value. Missing,
114
- null and empty differ: `$exists: false` keeps a missing field, `null` an
115
- explicit null, `''` empty text and `$size: 0` an empty list. A date compares
116
- in calendar order and never with a date-time. A reference compares by the Room
117
- Path it resolves to. Untyped frontmatter, and a value under `oneOf` or a
109
+ `/shipping/city`, `~1` for a `/` and `~0` for a `~` in a key. A segment that meets a
110
+ list applies to every item and a number names one item. `where` names pointers, ANDs
111
+ them, and nests `$and` and `$or`; a pointer through a list holds if any item satisfies
112
+ it. A bare value is equality; the operators are `$eq`, `$ne`, `$in`, `$nin`, `$gt`,
113
+ `$gte`, `$lt`, `$lte`, `$all`, `$size` and `$exists`. Equality on a list asks if it
114
+ contains the value. Missing, null and empty differ: `$exists: false` keeps a missing
115
+ field, `null` an explicit null, `''` empty text and `$size: 0` an empty list. A date
116
+ compares in calendar order and never with a date-time. A reference compares by the
117
+ Room Path it resolves to. Untyped frontmatter, and a value under `oneOf` or a
118
118
  conditional, is plain values. There is no text containment or regular expression.
119
119
  - **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
120
- reference at pointer `field`, at any depth, points to a matching Document of the
121
- same Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
122
- matching Document of the same Room references. Each keeps a Document once.
120
+ reference at pointer `field`, at any depth, points to a matching Document of the same
121
+ Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a matching
122
+ Document of the same Room references. Each keeps a Document once.
123
123
  - **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
124
- `preamble`, `markdown`, `backlinks` and `change`, where `fields` is `'all'` or a
125
- list of pointers and `sections` `'all'` or a list of names. Selected pointers
126
- return the frontmatter holding only them, nested as written. A backlink names
127
- the referring Path, MD Type and the pointer it came from as `field`. Room and Path always return; a Markdown
128
- Document also returns its MD Type. A non-Markdown Document returns only Room
129
- and Path, and a binary Path entry Room, Path and its `binaryFile` record,
130
- whatever is selected. An unselected part is absent. Select only
131
- what a screen shows: a list that selects the Markdown hears every edit of it.
132
- - **Change.** `change` is `{ author, time }` of the Document's head revision as
133
- the Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }`
134
- or `null` for a write the Provider made itself, and `time` is the Provider's
135
- ISO 8601 change time. It is `null` where the Provider delivered no time, as at
136
- a Site. An unsent edit or move keeps it, an unsent creation has none, and a
137
- saved write takes the Provider's own once it is Accepted. A
138
- Room's last change is its Document with the latest `time`.
139
- - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
140
- with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
141
- `room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
142
- over every match and ordered by `count` or a key. A sort or group takes only a
143
- pointer that holds one value. `limit` bounds the Documents or the groups.
144
- - **Results and errors.** A result carries no Room Version: read freshness from
145
- Rooms and Sync Status. An invalid query fails with the `code`
146
- `invalid-query`, `unknown-type`, `unknown-field` or `wrong-kind`, naming where,
147
- and never answers an empty result in its place.
124
+ `preamble`, `markdown`, `backlinks` and `change`, where `fields` is `'all'` or a list
125
+ of pointers and `sections` `'all'` or a list of names. Selected pointers return the
126
+ frontmatter holding only them, nested as written. A backlink names the referring Path,
127
+ MD Type and the pointer it came from as `field`. Room and Path always return; a
128
+ Markdown Document also returns its MD Type. A non-Markdown Document returns only Room
129
+ and Path, and a binary Path entry Room, Path and its `binaryFile` record, whatever is
130
+ selected. An unselected part is absent. Select only what a screen shows: a list that
131
+ selects the Markdown hears every edit of it.
132
+ - **Change.** `change` is `{ author, time }` of the Document's head revision as the
133
+ Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }` or `null`
134
+ for a write the Provider made itself, and `time` is the Provider's ISO 8601 change
135
+ time. It is `null` where the Provider delivered no time, as at a Site. An unsent edit
136
+ or move keeps it, an unsent creation has none, and a saved write takes the Provider's
137
+ own once it is Accepted. A Room's last change is its Document with the latest `time`.
138
+ - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }` with
139
+ TanStack DB's own options, and ties end with Room, then Path. `groupBy` by `room`,
140
+ `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted over every match
141
+ and ordered by `count` or a key. A sort or group takes only a pointer that holds one
142
+ value. `limit` bounds the Documents or the groups.
143
+ - **Results and errors.** A result carries no Room Version: read freshness from Rooms
144
+ and Sync Status. `coverage` names each Room read as `{ room, generation, current }`,
145
+ `current` false while a newer copy of that Room is being fetched, and the queued
146
+ changes it includes as `overlay`; a Save in a Room changes the `overlay` of every
147
+ query over it. An invalid query fails with the `code` `invalid-query`, `unknown-type`,
148
+ `unknown-field` or `wrong-kind`, naming where, and never answers empty in its place.
148
149
 
149
150
  ## Local Search rules
150
151
 
151
- `search({ text, documents, conversations, limit })` answers once, by words, from
152
- local state, with MiniSearch's defaults. There is no observed search.
152
+ `search({ text, documents, conversations, limit })` answers once, by words, from local
153
+ state, with MiniSearch's defaults. There is no observed search.
153
154
 
154
- - **What is found.** A Document by its field values, its sections' headings and
155
- text, its preamble and its Path; a message by its text. Frontmatter keys, Room
156
- Drafts, chat drafts and a running turn's parts are never found. There are no phrases,
157
- word forms, typo tolerance or prefix matching.
155
+ - **Declaration.** Only an App whose release declares Local Search searches, and its
156
+ first readiness waits for its index. Any other App's `search` answers the `undeclared`
157
+ refusal `search-undeclared`, its `fields` naming `local_search` and never retryable.
158
+ - **What is found.** A Document by its field values, its sections' headings and text,
159
+ its preamble and its Path; a message by its text. Frontmatter keys, Room Drafts, chat
160
+ drafts and a running turn's parts are never found. There are no phrases, word forms,
161
+ typo tolerance or prefix matching.
158
162
  - **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
159
- `pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both
160
- apply before `limit`, which bounds each list; without it every hit returns.
161
- - **Results.** `{ documents, messages }`, each ranked by `score`, which compares
162
- hits of one list of one search. A Document hit names its `room`, `path` and
163
- `type`, a message hit its `conversation` and `identity`, and `matches` maps each
164
- matched word to the parts it matched in: `fields`, `sections`, `preamble` or
165
- `path`, or `text`. A hit carries no position; mark the words in the text you
166
- show. An invalid filter fails with its Local Query error.
163
+ `pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both apply
164
+ before `limit`, which bounds each list; without it every hit returns.
165
+ - **Results.** `{ documents, messages, coverage }`, or the same with `pending` naming
166
+ each Room or conversation the search waits for while its index is prepared: show its
167
+ hits, ask again, and never read pending as no hits. `coverage` names the Rooms and
168
+ conversations searched. Each
169
+ list is ranked by `score`, which compares hits of one list of one search. A Document
170
+ hit names its `room`, `path` and `type`, a message hit its `conversation` and
171
+ `identity`, and `matches` maps each matched word to the parts it matched in: `fields`,
172
+ `sections`, `preamble` or `path`, or `text`. A hit carries no position; mark the words
173
+ in the text you show. An invalid filter fails with its Local Query error.
167
174
 
168
175
  ## Room Draft, Save, and outcome rules
169
176
 
170
- The MD Runtime owns one Room Draft per Room and Path, shared by every App and tab.
171
- It is durable: it survives reload and navigation. A Room that Discovery stops
172
- listing takes its Room Drafts and its queue with it. Write a Room Draft with
173
- `roomDraft.write(room, path, revision, parts)`, naming the revision you read, or
174
- `null` when there was none, and every part it should now change: fields, sections
175
- and the preamble, or the whole Markdown, a creation, a move, or a removal. A part
176
- new to the Room Draft names its base, the value you showed when it was opened; the
177
- MD Runtime keeps a part's first base; a binary Path entry's move or removal takes
178
- `null` as its base. A write or a discard from an older revision is refused as
179
- `stale` with the current Room Draft; read it and write again.
180
-
181
- Save takes one Room and the Room Drafts of it to save, each with its revision,
182
- validates locally, and on success appends one Change Batch to that Room's
183
- queue and removes those Room Drafts. It is refused with the `code` `stale`,
184
- `changed-underneath` naming each part whose base no longer matches the visible
185
- state, or a local validation rule, and then creates nothing and leaves every
186
- Room Draft in place. A directory move or removal is a move or removal part on
187
- each Document and binary Path entry beneath it, saved together.
188
-
189
- Outcomes follow the Provider's answer. An Accepted Change Batch stays in the
190
- queue, drawn over the confirmed layer, until the confirmed layer reaches the
191
- Room Version it was accepted at, and then leaves it. Conflicted and Rejected, an expired operation, and a change that no
192
- longer applies over the Room each leave the queue and return as Room Drafts on
193
- the Documents they changed, marked with why: the Provider's structured refusal
194
- code and fields as returned, not known to have applied, or withdrawn locally.
195
- The rest of the queue keeps synchronizing, and Sync Status requires attention
196
- until each returned Room Draft is saved again or discarded. A Change Batch
197
- keeps no outcome once it leaves the queue; `observe('queue', room)` shows each
198
- Pending one, and a returned Room Draft says why it returned. Transport
199
- failure and Provider unavailability keep work Pending and do not infer a
200
- rejection. A refusal the Provider marks retryable stays Pending until the reset
201
- it names; the MD Runtime retries the same Change Batch identity and payload and
202
- never infers an outcome from transport uncertainty. The MD Runtime never
203
- combines, reorders, or rebases.
204
-
205
- On a Site, every Save stays in the visitor's browser. Write grants and revisions
206
- do not refuse it, and its Pending Change shows in every query and across reloads
207
- until the browser's storage is cleared. It is never sent: `observe('queue', room)`
208
- shows it `local`, and Sync Status never waits on it. Once the Room changes so that
209
- it no longer applies, it leaves the queue and returns no Room Draft.
210
-
211
- `observe('service-mode')` answers the Provider's Service Mode, `open` or
212
- `write-halted`. While writes are halted, Save still succeeds, its Change Batch
213
- waits unsent, and the queue is submitted in order once the Provider reopens
214
- writes. An Action is never held: a write the Provider refuses for the halt returns
215
- that refusal to its caller. Show the Provider as read-only instead of retrying.
177
+ The MD Runtime owns one Room Draft per Room and Path, shared by every App and tab. It is
178
+ durable: it survives reload and navigation. A Room that Discovery stops listing takes its
179
+ Room Drafts and its queue with it. Write a Room Draft with `roomDraft.write(room, path,
180
+ revision, parts)`, naming the revision you read, or `null` when there was none, and every
181
+ part it should now change: fields, sections and the preamble, or the whole Markdown, a
182
+ creation, a move, or a removal. A part new to the Room Draft names its base, the value
183
+ you showed when it was opened; the MD Runtime keeps a part's first base; a binary Path
184
+ entry's move or removal takes `null` as its base. A write or a discard from an older
185
+ revision is refused as `stale` with the current Room Draft; read it and write again.
186
+
187
+ Save takes one Room and the Room Drafts of it to save, each with its revision, validates
188
+ locally, and on success appends one Change Batch to that Room's queue and removes those
189
+ Room Drafts. It is refused with the `code` `stale`, `changed-underneath` naming each
190
+ part whose base no longer matches the visible state, or a local validation rule, and
191
+ then creates nothing and leaves every Room Draft in place. A directory move or removal
192
+ is that part on each Document and binary Path entry beneath it, saved together.
193
+
194
+ Outcomes follow the Provider's answer. An Accepted Change Batch stays in the queue,
195
+ drawn over the confirmed layer, until the confirmed layer reaches the Room Version it
196
+ was accepted at, and then leaves it. Conflicted and Rejected, an expired operation, and
197
+ a change that no longer applies over the Room each leave the queue and return as Room
198
+ Drafts on the Documents they changed, marked with why: the Provider's structured refusal
199
+ code and fields as returned, not known to have applied, or withdrawn locally. The rest
200
+ of the queue keeps synchronizing, and Sync Status requires attention until each returned
201
+ Room Draft is saved again or discarded. A Change Batch keeps no outcome once it leaves
202
+ the queue; `observe('queue', room)` shows each Pending one, and a returned Room Draft
203
+ says why it returned. Transport failure and Provider unavailability keep work Pending
204
+ and do not infer a rejection. A refusal the Provider marks retryable stays Pending until
205
+ the reset it names; the MD Runtime retries the same Change Batch identity and payload
206
+ and never infers an outcome from transport uncertainty. The MD Runtime never combines,
207
+ reorders, or rebases.
208
+
209
+ On a Site, every Save stays in the visitor's browser. Write grants and revisions do not
210
+ refuse it, and its Pending Change shows in every query and across reloads until the
211
+ browser's storage is cleared. It is never sent: `observe('queue', room)` shows it
212
+ `local`, and Sync Status never waits on it. Once the Room changes so that it no longer
213
+ applies, it leaves the queue and returns no Room Draft.
214
+
215
+ `observe('service-mode')` answers the Provider's Service Mode, `open` or `write-halted`.
216
+ While writes are halted, Save still succeeds, its Change Batch waits unsent, and the
217
+ queue is submitted in order once the Provider reopens writes. An Action is never held: a
218
+ write the Provider refuses for the halt returns that refusal to its caller. Show the
219
+ Provider as read-only instead of retrying.
220
+
221
+ `observe('readiness')` tells whether the App's code and bound Rooms are held locally
222
+ (`ready`), each Room's state, each refused Room's file and rule, the persistence answer
223
+ and a paused preparation's `capacity` cause; `retry()` resumes a paused preparation.
216
224
 
217
225
  ## The neutrality rule
218
226
 
219
- No module outside an Adapter package imports, names, or special-cases a
220
- Provider. MD UI and every App reach data only through the client entry.
227
+ No module outside an Adapter package imports, names, or special-cases a Provider. MD UI
228
+ and every App reach data only through the client entry.
221
229
 
222
230
  ## Content-safety rules
223
231
 
224
- The Provider authorization belongs to the Runtime host and is never readable
225
- by the App's code. The App's code reaches the network only at the external
226
- origins its manifest declares, empty by default, and the Provider enforces
227
- that set. Every request to the Provider itself goes through the MD Runtime.
228
- Rendered Markdown never executes scripts, renders raw HTML only for the
229
- details and summary elements, and loads images and other resources only from
230
- origins the Provider's policy allows.
232
+ The Provider authorization belongs to the Runtime host and is never readable by the
233
+ App's code. The App's code reaches the network only at the external origins its manifest
234
+ declares, empty by default, and the Provider enforces that set. Every request to the
235
+ Provider itself goes through the MD Runtime. Rendered Markdown never executes scripts,
236
+ renders raw HTML only for the details and summary elements, and loads images and other
237
+ resources only from origins the Provider's policy allows.
231
238
 
232
239
  ## Launch promises MD UI keeps
233
240
 
234
- MD UI uses semantic HTML, is fully operable from a keyboard with visible
235
- focus and labelled controls, and lays out from a 360 pixel wide viewport to
236
- a desktop. Its strings are English only, dates and numbers follow the
237
- browser locale, and content is never translated. Light and dark themes come
238
- from CSS custom properties with the browser's preference as the default and
239
- an App's override respected. What an App Creator's agent adds carries none
240
- of these promises by itself. Reading, querying and searching never wait for
241
- the network. Data lives only in the App Creator's browser and with the Provider.
241
+ MD UI uses semantic HTML, is fully operable from a keyboard with visible focus and
242
+ labelled controls, and lays out from a 360 pixel wide viewport to a desktop. Its strings
243
+ are English only, dates and numbers follow the browser locale, and content is never
244
+ translated. Light and dark themes come from CSS custom properties with the browser's
245
+ preference as the default and an App's override respected. What an App Creator's agent
246
+ adds carries none of these promises by itself. Reading, querying and searching never
247
+ wait for the network. Data lives only in the App Creator's browser and with the
248
+ Provider.
242
249
 
243
250
  ## App code takes the client its host hands it and never constructs a Runtime
244
251
 
245
- App code takes the client its host hands it: in House, `houseBridge().runtime`
246
- from `@agentshouse/app-bridge` resolves to the client House built into the page.
247
- It imports only types from `@agentshouse/mdruntime/client`, never calls
248
- `connectMdRuntime` or `serveMdRuntime`, and never imports the package main, the
249
- host entry or the Adapter package, which hosts and tests use. The in-memory
250
- Adapter at `@agentshouse/mdruntime/memory` is for tests and ships in no bundle.
251
- A Site's page fills its Entry Data Contract's `{"$param": name}` arguments with
252
- `boundQuery` from `@agentshouse/mdruntime/entry`, as House did for its HTML.
253
-
254
- A React App may observe and save through `@agentshouse/mdruntime/react`, which
255
- names React as a peer dependency. `useObserve(client, topic, ...input)` takes
256
- the arguments of `observe` and returns `{ state: 'loading' }` until the topic's
257
- first value arrives, then `{ state: 'ready', value }`, re-rendering on each
258
- change; a `null` client observes nothing and stays loading. `useSave(client)`
259
- returns `busy`, the last `outcome` or `failure`, and `save(room, roomDrafts)`,
260
- which writes each Path's parts onto the Room Draft already there, keeping the
261
- bases its parts have, or onto a new one, and saves them together. A refused
262
- Save leaves the Room Drafts for the App to save again or discard; a failure is
263
- recorded and rejects. `saveRoomDrafts(client, room, roomDrafts)` is that save
264
- outside a component. A react-admin or Refine App reads and writes its Rooms
265
- through the data providers of `@agentshouse/mdruntime-families`.
252
+ App code takes the client its host hands it: in House, `houseBridge().runtime` from
253
+ `@agentshouse/app-bridge` resolves to the client House built into the page. It imports
254
+ only types from `@agentshouse/mdruntime/client`, never calls `connectMdRuntime` or
255
+ `serveMdRuntime`, and never imports the package main, the host entry or the Adapter
256
+ package, which hosts and tests use. The in-memory Adapter at
257
+ `@agentshouse/mdruntime/memory` is for tests and ships in no bundle. A Site's page fills
258
+ its Entry Data Contract's `{"$param": name}` arguments with `boundQuery` from
259
+ `@agentshouse/mdruntime/entry`, as House did for its HTML.
260
+
261
+ A React App may observe and save through `@agentshouse/mdruntime/react`, which names
262
+ React as a peer dependency. `useObserve(client, topic, ...input)` takes the arguments of
263
+ `observe` and returns `{ state: 'loading' }` until the topic's first value arrives, then
264
+ `{ state: 'ready', value }`, re-rendering on each change; a `null` client observes
265
+ nothing and stays loading. `useSave(client)` returns `busy`, the last `outcome` or
266
+ `failure`, and `save(room, roomDrafts)`, which writes each Path's parts onto the Room
267
+ Draft already there, keeping the bases its parts have, or onto a new one, and saves them
268
+ together. A refused Save leaves the Room Drafts for the App to save again or discard; a
269
+ failure is recorded and rejects. `saveRoomDrafts(client, room, roomDrafts)` is that save
270
+ outside a component. A react-admin or Refine App reads and writes its Rooms through the
271
+ data providers of `@agentshouse/mdruntime-families`.
266
272
 
267
273
  ## The Chat
268
274
 
269
- `@agentshouse/mdruntime/chat` holds the Chat, one data layer for every App; add
270
- React as a dependency in any App, with React DOM and `@assistant-ui/react`.
271
-
272
- Place the ready chat with `<Chat client={runtime} conversation={id}
273
- agent={agent} width="1/3" showChats />`: `conversation` opens one, `null` for a
274
- new chat, `agent` is the Agent a new chat goes to, `onOpen` hears each one it
275
- opens, and `width` is `full` (the place you give it), or `3/4`, `1/2` or `1/3`
276
- of the window docked at its right edge, whole on a narrow window. `showChats`
277
- adds its conversation list; or draw your own inside a `ChatProvider` around a
278
- `<Chat />` with no `client`. It carries its own styles; theme it with CSS custom
279
- properties on it or an ancestor: `--chat-background`, `--chat-surface`,
280
- `--chat-text`, `--chat-text-muted`, `--chat-accent`, `--chat-line`,
275
+ `@agentshouse/mdruntime/chat` holds the Chat, one data layer for every App; add React as
276
+ a dependency in any App, with React DOM and `@assistant-ui/react`.
277
+
278
+ Place the ready chat with `<Chat client={runtime} conversation={id} agent={agent}
279
+ width="1/3" showChats />`: `conversation` opens one, `null` for a new chat, `agent` is
280
+ the Agent a new chat goes to, `onOpen` hears each one it opens, and `width` is `full`
281
+ (the place you give it), or `3/4`, `1/2` or `1/3` of the window docked at its right
282
+ edge, whole on a narrow window. `showChats` adds its conversation list; or draw your own
283
+ inside a `ChatProvider` around a `<Chat />` with no `client`. It carries its own styles;
284
+ theme it with CSS custom properties on it or an ancestor: `--chat-background`,
285
+ `--chat-surface`, `--chat-text`, `--chat-text-muted`, `--chat-accent`, `--chat-line`,
281
286
  `--chat-attention`, `--chat-danger`, `--chat-font`, `--chat-font-mono`,
282
- `--chat-font-size`, `--chat-radius` and `--chat-density` (a factor for spacing);
283
- an unset one keeps House's light or dark look. `mountChat(element, { client })`
284
- places it outside React and returns `update(props)` and `unmount()`.
285
-
286
- Mix `ChatMessageList` (`components` takes your `UserMessage` and
287
- `AssistantMessage`), `ChatInput` and `ChatQuestionCard` with your own design
288
- inside a `ChatProvider`, or compose assistant-ui's primitives there; `useChat()`
289
- gives `send`, the conversations, the Agents, questions to `answer`, `options`
290
- to `choose`, `commands`, the queue to `edit` or `unqueue`, `stop`, `kill` and
291
- outcomes; never replace its messages, sending or store. A secret question is
292
- never answered here; typed answers live in Presentation State's `typed` key:
293
- keep it, and change Presentation State only inside `inTurn(client, work)` from
294
- `@agentshouse/mdruntime/client`. `Markdown` draws Markdown safely.
287
+ `--chat-font-size`, `--chat-radius` and `--chat-density` (a factor for spacing); an
288
+ unset one keeps House's light or dark look. `mountChat(element, { client })` places it
289
+ outside React and returns `update(props)` and `unmount()`.
290
+
291
+ Mix `ChatMessageList` (`components` takes your `UserMessage` and `AssistantMessage`),
292
+ `ChatInput` and `ChatQuestionCard` with your own design inside a `ChatProvider`, or
293
+ compose assistant-ui's primitives there; `useChat()` gives `send`, the conversations,
294
+ the Agents, questions to `answer`, `options` to `choose`, `commands`, the queue to
295
+ `edit` or `unqueue`, `stop`, `kill` and outcomes; never replace its messages, sending or
296
+ store. A secret question is never answered here; typed answers live in Presentation
297
+ State's `typed` key: keep it, and change Presentation State only inside `inTurn(client,
298
+ work)` from `@agentshouse/mdruntime/client`. `Markdown` draws Markdown safely.
295
299
 
296
300
  ## What an agent must never do
297
301
 
298
- An agent must never read the authorization, load code from a Room, call the
299
- Provider directly, or rebase a refused Change Batch.
302
+ An agent must never read the authorization, load code from a Room, call the Provider
303
+ directly, or rebase a refused Change Batch.
package/dist/adapter.d.ts CHANGED
@@ -5,6 +5,7 @@ export type AgentsHouseAdapterOptions = {
5
5
  authorize(): Promise<Authorization>;
6
6
  } | {
7
7
  site: HouseSiteTransport;
8
+ snapshot?: boolean;
8
9
  };
9
10
  export declare function createAgentsHouseAdapter(options: AgentsHouseAdapterOptions): Adapter;
10
11
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EACP,aAAa,EAiBd,MAAM,wBAAwB,CAAC;AA4ChC,OAAO,EASL,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;AAoEjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA+gBpF"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKV,OAAO,EACP,aAAa,EAiBd,MAAM,wBAAwB,CAAC;AA4ChC,OAAO,EASL,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,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAsErD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA0hBpF"}
package/dist/adapter.js CHANGED
@@ -46,7 +46,7 @@ async function reused(scope, held) {
46
46
  }
47
47
  export function createAgentsHouseAdapter(options) {
48
48
  if ('site' in options)
49
- return createSiteAdapter(options.site);
49
+ return createSiteAdapter(options.site, options.snapshot === true);
50
50
  const transport = options.transport;
51
51
  const notifications = houseNotifications(transport, 'credential');
52
52
  const tracked = new Map();
@@ -134,7 +134,7 @@ export function createAgentsHouseAdapter(options) {
134
134
  const models = await streamedModels(advanced.schemas, entry, 'credential');
135
135
  return models === undefined ? advanced.page : { ...advanced.page, models };
136
136
  }
137
- function held(rooms) {
137
+ function held(rooms, demand) {
138
138
  const kept = rooms.flatMap((room) => {
139
139
  const entry = tracked.get(room.locator);
140
140
  const at = logPosition(room.roomVersion);
@@ -144,7 +144,15 @@ export function createAgentsHouseAdapter(options) {
144
144
  notifications.reach(entry.authority, at);
145
145
  return [presented(entry.authority, at)];
146
146
  });
147
- notifications.send(kept);
147
+ notifications.send(kept, demand === null
148
+ ? null
149
+ : {
150
+ rooms: demand.rooms.flatMap((locator) => {
151
+ const entry = tracked.get(locator);
152
+ return entry === undefined ? [] : [entry.authority];
153
+ }),
154
+ conversations: demand.conversations,
155
+ });
148
156
  }
149
157
  function adopted(entry, outcome) {
150
158
  if (outcome.kind !== 'accepted')
@@ -242,46 +250,47 @@ export function createAgentsHouseAdapter(options) {
242
250
  const depths = new Map();
243
251
  const layers = [];
244
252
  for (const ask of asks) {
245
- const depth = depths.get(ask.entry.authority) ?? 0;
246
- depths.set(ask.entry.authority, depth + 1);
253
+ const depth = depths.get(ask.ask.entry.authority) ?? 0;
254
+ depths.set(ask.ask.entry.authority, depth + 1);
247
255
  (layers[depth] ??= []).push(ask);
248
256
  }
249
257
  return layers;
250
258
  }
251
259
  async function enumerated(asks) {
252
- const answers = new Map();
253
- const parts = layered(asks).flatMap((layer) => selections(layer, (ask) => weight(ask.entry), declared().max_prefixes));
260
+ const answers = [];
261
+ const parts = layered(asks.map((ask, index) => ({ ask, index }))).flatMap((layer) => selections(layer, ({ ask }) => weight(ask.entry), declared().max_prefixes));
254
262
  for (const part of parts) {
255
263
  let open = [...part];
256
264
  while (open.length > 0) {
257
265
  const answer = await transport.door(DOOR_ENUMERATE, {
258
- prefixes: open.flatMap((ask) => contentPrefixes(ask.entry)),
259
- positions: open.map((ask) => presented(ask.entry.authority, ask.from)),
266
+ prefixes: open.flatMap(({ ask }) => contentPrefixes(ask.entry)),
267
+ positions: open.map(({ ask }) => presented(ask.entry.authority, ask.from)),
260
268
  });
261
- const classified = open.map((ask) => classifyRead(answer.status, answer.body, ask.entry.locator));
269
+ const classified = open.map(({ ask }) => classifyRead(answer.status, answer.body, ask.entry.locator));
262
270
  if (classified[0]?.kind === 'beyond-horizon') {
263
271
  const named = doorRefusal(answer.body)?.fields.authority;
264
- const expired = open.filter((ask) => ask.entry.authority === named);
272
+ const expired = open.filter(({ ask }) => ask.entry.authority === named);
265
273
  const answered = expired.length === 0 ? UNCERTAIN_READ : { kind: 'beyond-horizon' };
266
274
  const gone = expired.length === 0 ? open : expired;
267
275
  for (const ask of gone)
268
- answers.set(ask, answered);
276
+ answers[ask.index] = answered;
269
277
  open = open.filter((ask) => !gone.includes(ask));
270
278
  continue;
271
279
  }
272
280
  const enumeration = classified[0] === null ? parseEnumeration(answer.body, 'credential') : null;
273
- for (const [index, ask] of open.entries()) {
274
- const failure = classified[index];
281
+ for (const [answerIndex, { ask, index }] of open.entries()) {
282
+ const failure = classified[answerIndex];
275
283
  if (failure !== null && failure !== undefined) {
276
- answers.set(ask, failure);
284
+ answers[index] = failure;
277
285
  continue;
278
286
  }
279
- answers.set(ask, enumeration === null ? UNCERTAIN_READ : await enumeratedRoom(enumeration, ask));
287
+ answers[index] =
288
+ enumeration === null ? UNCERTAIN_READ : await enumeratedRoom(enumeration, ask);
280
289
  }
281
290
  open = [];
282
291
  }
283
292
  }
284
- return asks.map((ask) => answers.get(ask) ?? UNCERTAIN_READ);
293
+ return answers;
285
294
  }
286
295
  const bootstrapTogether = gatheredEach(bootstrapped);
287
296
  const enumerateTogether = gathered(enumerated);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
2
2
  export { HOUSE_APP_ACTS, HOUSE_APP_BATCHES, HOUSE_SITE_ACTS } from './actions.js';
3
- export type { HouseByteAct, HouseByteTransfer, HouseBytesAnswer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
3
+ export type { HouseByteAct, HouseByteTransfer, HouseBytesAnswer, HouseDemand, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
4
4
  //# 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,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAClF,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,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,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAClF,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
package/dist/site.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import type { Adapter } from '@agentshouse/mdruntime';
2
2
  import { type HouseSiteTransport } from './transport.js';
3
- export declare function createSiteAdapter(transport: HouseSiteTransport): Adapter;
3
+ export declare function createSiteAdapter(transport: HouseSiteTransport, snapshot?: boolean): Adapter;
4
4
  //# sourceMappingURL=site.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAOR,MAAM,wBAAwB,CAAC;AA2BhC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAmCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAuQxE"}
1
+ {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAOR,MAAM,wBAAwB,CAAC;AA2BhC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAmCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CA+Q1F"}
package/dist/site.js CHANGED
@@ -23,7 +23,7 @@ function siteRoom(tracked) {
23
23
  function settled(refused) {
24
24
  return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;
25
25
  }
26
- export function createSiteAdapter(transport) {
26
+ export function createSiteAdapter(transport, snapshot = false) {
27
27
  const notifications = houseNotifications(transport, 'site');
28
28
  const tracked = new Map();
29
29
  function published(referrer) {
@@ -184,6 +184,11 @@ export function createSiteAdapter(transport) {
184
184
  return { kind: 'room-not-readable', locator: request.locator };
185
185
  if (request.pageToken !== undefined)
186
186
  return UNCERTAIN;
187
+ if (snapshot) {
188
+ return request.fromRoomVersion === roomVersion(entry)
189
+ ? { kind: 'still-current' }
190
+ : { kind: 'beyond-horizon' };
191
+ }
187
192
  return refreshed(entry, request.fromRoomVersion);
188
193
  },
189
194
  async mutate() {
@@ -237,25 +242,27 @@ export function createSiteAdapter(transport) {
237
242
  return UNCERTAIN;
238
243
  return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), SITE_SUBMIT);
239
244
  },
240
- roomStream: {
241
- hold(rooms) {
242
- notifications.send(rooms.flatMap((room) => {
243
- const entry = tracked.get(room.locator);
244
- const at = logPosition(room.roomVersion);
245
- if (entry === undefined || at === null)
246
- return [];
247
- notifications.reach(entry.authority, at);
248
- return [presented(entry.authority, at)];
249
- }));
250
- },
251
- reopen: notifications.reopen,
252
- observe: notifications.observe,
253
- published(locator, roomVersion) {
254
- const at = logPosition(roomVersion);
255
- if (at !== null)
256
- notifications.published(locator, at);
245
+ roomStream: snapshot
246
+ ? undefined
247
+ : {
248
+ hold(rooms) {
249
+ notifications.send(rooms.flatMap((room) => {
250
+ const entry = tracked.get(room.locator);
251
+ const at = logPosition(room.roomVersion);
252
+ if (entry === undefined || at === null)
253
+ return [];
254
+ notifications.reach(entry.authority, at);
255
+ return [presented(entry.authority, at)];
256
+ }), null);
257
+ },
258
+ reopen: notifications.reopen,
259
+ observe: notifications.observe,
260
+ published(locator, roomVersion) {
261
+ const at = logPosition(roomVersion);
262
+ if (at !== null)
263
+ notifications.published(locator, at);
264
+ },
257
265
  },
258
- },
259
266
  serviceMode: notifications.serviceMode,
260
267
  };
261
268
  }
package/dist/stream.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ConversationStream, RefreshPage, RoomStreamEvent, ServiceModeSignal, StreamReceipts } from '@agentshouse/mdruntime';
2
2
  import type { TrackedAuthority } from './discovery.js';
3
- import type { HouseDoor, HouseHeldRoom, HouseMode, HouseStreamEntry } from './transport.js';
3
+ import type { HouseDemand, HouseDoor, HouseHeldRoom, HouseMode, HouseStreamEntry } from './transport.js';
4
4
  import { type LogPosition } from './version.js';
5
5
  export type HeldRevision = (path: string, revision: string) => boolean;
6
6
  export type StreamedAdvancement = {
@@ -11,7 +11,7 @@ export type StreamedAdvancement = {
11
11
  export type HouseNotifications = {
12
12
  runtime: string;
13
13
  observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
14
- send(rooms: readonly HouseHeldRoom[]): void;
14
+ send(rooms: readonly HouseHeldRoom[], demand: HouseDemand | null): void;
15
15
  published(locator: string, at: LogPosition): void;
16
16
  reopen(): void;
17
17
  track(authorities: readonly TrackedAuthority[]): void;
@@ -1 +1 @@
1
- {"version":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,EAAE,WAAW,GAAG,IAAI,CAAC;IAClD,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;AAkFF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CAmhB5F"}
package/dist/stream.js CHANGED
@@ -463,7 +463,7 @@ export function houseNotifications(transport, mode) {
463
463
  observers.delete(notify);
464
464
  };
465
465
  },
466
- send(rooms) {
466
+ send(rooms, demand) {
467
467
  for (const room of rooms) {
468
468
  const line = lines.get(room.authority);
469
469
  const held = position(room.position);
@@ -478,7 +478,7 @@ export function houseNotifications(transport, mode) {
478
478
  void loaded
479
479
  .then(() => Promise.all(rooms.map(restored)))
480
480
  .then((presented) => {
481
- current.hold(presented, runtime);
481
+ current.hold(presented, runtime, demand);
482
482
  for (const [index, room] of presented.entries()) {
483
483
  if (room.position === rooms[index].position)
484
484
  continue;
@@ -134,8 +134,12 @@ export type HouseHeldRoom = {
134
134
  log_epoch: string;
135
135
  carry?: HouseHeldCarry;
136
136
  };
137
+ export type HouseDemand = {
138
+ rooms: readonly string[];
139
+ conversations: boolean;
140
+ };
137
141
  export type HouseOpening = {
138
- hold(rooms: readonly HouseHeldRoom[], runtime: string): void;
142
+ hold(rooms: readonly HouseHeldRoom[], runtime: string, demand: HouseDemand | null): void;
139
143
  received(authority: string, carry: string, index: number): void;
140
144
  close(): void;
141
145
  };
@@ -1 +1 @@
1
- {"version":3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CAAC,CAE1D;AAiDD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,cAAc,CAkFhB;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;;IACd,SAAS;EAEZ;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;AA4BD,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,CAyDf"}
package/dist/write.js CHANGED
@@ -194,8 +194,11 @@ export function mutationOutcome(status, body, locator, handle) {
194
194
  if (refusal !== null && refusal.code === 'service_mode_write_halted') {
195
195
  return { kind: 'write-halted' };
196
196
  }
197
- if (refusal !== null && refusal.code === 'expired')
198
- return { kind: 'expired' };
197
+ if (refusal !== null && refusal.code === 'expired') {
198
+ return refusal.fields.restored === true
199
+ ? { kind: 'expired', restored: true }
200
+ : { kind: 'expired' };
201
+ }
199
202
  if (refusal !== null && refusal.code === 'edit_conflict') {
200
203
  const { current, ...fields } = refusal.fields;
201
204
  const held = material(current, handle) ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-cdfc733e397ee",
3
+ "version": "0.1.0-ce1f911b3b195",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,6 +25,6 @@
25
25
  "LICENSE"
26
26
  ],
27
27
  "dependencies": {
28
- "@agentshouse/mdruntime": "0.1.0-ca14c49c06d90"
28
+ "@agentshouse/mdruntime": "0.1.0-c766beb2a980a"
29
29
  }
30
30
  }