@agentshouse/mdruntime-adapter 0.1.0-cacce09fc82c6 → 0.1.0-cb89e0425af50

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
@@ -51,7 +51,9 @@ open one through the Provider Action that serves it.
51
51
 
52
52
  Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never
53
53
  touch the network.
54
- History and Call go to the Provider through the Adapter. A Call result whose
54
+ History and Call go to the Provider through the Adapter. Call takes the Action names
55
+ the Adapter declares; any other name answers `undeclared` without reaching the
56
+ Provider. A Call result whose
55
57
  effect the Provider places in a Room carries `at`, that Room and Room Version;
56
58
  `reached(room, roomVersion)` answers whether the Room's confirmed state has
57
59
  reached it, and the MD Runtime keeps refreshing that Room until it has;
@@ -66,6 +68,13 @@ client is asynchronous. Results are detached snapshots. Nothing in this
66
68
  surface returns the authorization, performs a request the App's code
67
69
  composes, or exposes the browser store.
68
70
 
71
+ Every refusal and failure carries `code` and `retryable`: each Call and History answer
72
+ other than its result, a refused Save or Room Draft write, a returned Room Draft's
73
+ reason, a Room's refusal and the Connection Refusal, and every error a member rejects
74
+ with, beside its message. A Provider refusal carries the Provider's own `retryable`.
75
+ Every code and every value the API answers is open: handle one you do not know by its
76
+ `code` and `retryable`.
77
+
69
78
  Read the deployment facts with `observe('deployment-facts')`. Interpret the
70
79
  opaque value using the host's contract.
71
80
 
@@ -129,9 +138,9 @@ data:
129
138
  over every match and ordered by `count` or a key. A sort or group takes only a
130
139
  pointer that holds one value. `limit` bounds the Documents or the groups.
131
140
  - **Results and errors.** A result carries no Room Version: read freshness from
132
- Rooms and Sync Status. An invalid query fails with `invalid-query`,
133
- `unknown-type`, `unknown-field` or `wrong-kind`, naming where, and never
134
- answers an empty result in its place.
141
+ Rooms and Sync Status. An invalid query fails with the `code`
142
+ `invalid-query`, `unknown-type`, `unknown-field` or `wrong-kind`, naming where,
143
+ and never answers an empty result in its place.
135
144
 
136
145
  ## Local Search rules
137
146
 
@@ -169,9 +178,9 @@ the current Room Draft; read it and write again.
169
178
 
170
179
  Save takes one Room and the Room Drafts of it to save, each with its revision,
171
180
  validates locally, and on success appends one Change Batch to that Room's
172
- queue and removes those Room Drafts. It is refused as `stale`, as
181
+ queue and removes those Room Drafts. It is refused with the `code` `stale`,
173
182
  `changed-underneath` naming each part whose base no longer matches the visible
174
- state, or by a local validation rule, and then creates nothing and leaves every
183
+ state, or a local validation rule, and then creates nothing and leaves every
175
184
  Room Draft in place. A directory move or removal is a move or removal part on
176
185
  each Document and binary link target beneath it, saved together.
177
186
 
@@ -191,6 +200,13 @@ it names; the MD Runtime retries the same Change Batch identity and payload and
191
200
  never infers an outcome from transport uncertainty. The MD Runtime never
192
201
  combines, reorders, or rebases.
193
202
 
203
+ On a Site, every Save stays in the visitor's browser. Write grants and
204
+ revisions do not refuse it, and its Pending Change shows in every query and
205
+ across reloads until the browser's storage is cleared. It is never sent:
206
+ `observe('queue', room)` shows it `local`, and Sync Status never waits on it.
207
+ Once the Room changes so that it no longer applies, it leaves the queue and
208
+ returns no Room Draft.
209
+
194
210
  `observe('service-mode')` answers the Provider's Service
195
211
  Mode, `open` or `write-halted`. While writes are halted, Save still succeeds,
196
212
  its Change Batch waits unsent, and the queue is submitted in order once the
@@ -227,7 +243,7 @@ the network. Data lives only in the App Creator's browser and with the Provider.
227
243
  ## App code takes the client its host hands it and never constructs a Runtime
228
244
 
229
245
  App code takes the client its host hands it: in House,
230
- `connectHouseBridge().runtime` from `@agentshouse/app-bridge` resolves to the
246
+ `houseBridge().runtime` from `@agentshouse/app-bridge` resolves to the
231
247
  client House built into the page. It never constructs a Runtime or a client.
232
248
  It imports only types from `@agentshouse/mdruntime/client`, does not call
233
249
  `connectMdRuntime` or `serveMdRuntime`, and does not import the package main,
package/dist/actions.d.ts CHANGED
@@ -1,5 +1,6 @@
1
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_APP_ACTS: Readonly<Record<string, string>>;
3
4
  export declare function houseConversationAgents(locator: string): ConversationAgents;
4
5
  export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
5
6
  export declare function houseAction(transport: HouseTransport, request: ActionRequest): Promise<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,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"}
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;AAmEtE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE3D,CAAC;AAMF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAE3E;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAMvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAQvB;AAyDD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAOjF;AAwMD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE"}
package/dist/actions.js CHANGED
@@ -3,44 +3,74 @@ import { doorRefusal } from './refusal.js';
3
3
  const HISTORY_PAGE = 100;
4
4
  const HISTORY_CONVERSATIONS = 64;
5
5
  const OCTET_STREAM = 'application/octet-stream';
6
- const CONVERSATION_ROUTES = new Map([
7
- ['conversation.create', '/door/conversations/create'],
8
- ['conversation.send', '/door/conversations/send'],
9
- ['conversation.answer', '/door/conversations/interaction/answer'],
10
- ['conversation.interrupt', '/door/conversations/interrupt'],
11
- ['conversation.kill', '/door/conversations/kill'],
12
- ['conversation.delete', '/door/conversations/delete'],
13
- ['conversation.history', '/door/conversations/history'],
14
- ]);
6
+ function mapped(door, input = (given) => given) {
7
+ return {
8
+ door,
9
+ async carry(transport, given, name) {
10
+ return actionOutcome(await transport.door(`/door/${door}`, input(given)), name);
11
+ },
12
+ };
13
+ }
14
+ function carried(door, carry) {
15
+ return {
16
+ door,
17
+ carry: (transport, input, name) => carry(transport, `/door/${door}`, input, name),
18
+ };
19
+ }
20
+ const APP_ACTS = {
21
+ 'access.read': mapped('rooms/access/read'),
22
+ 'attachment.read': carried('attachments/get', openAction),
23
+ 'attachment.upload': carried('attachments/upload', attachAction),
24
+ 'conversation.answer': mapped('conversations/interaction/answer', answerBody),
25
+ 'conversation.create': mapped('conversations/create', createBody),
26
+ 'conversation.delete': mapped('conversations/delete', controlBody),
27
+ 'conversation.history': carried('conversations/history', historyAction),
28
+ 'conversation.interrupt': mapped('conversations/interrupt', controlBody),
29
+ 'conversation.kill': mapped('conversations/kill', controlBody),
30
+ 'conversation.markDone': mapped('conversations/done'),
31
+ 'conversation.rename': mapped('conversations/rename'),
32
+ 'conversation.send': carried('conversations/send', sendAction),
33
+ 'conversation.setOption': mapped('conversations/option'),
34
+ 'feature.list': mapped('apps/features/read'),
35
+ 'holder.list': mapped('apps/holders'),
36
+ 'holder.ring': mapped('apps/ring'),
37
+ 'member.list': mapped('rooms/members'),
38
+ 'message.send': mapped('apps/messages/send'),
39
+ 'processing.read': mapped('rooms/settings/processing/read'),
40
+ 'record.list': mapped('records/read'),
41
+ 'relay.read': mapped('apps/relay'),
42
+ 'routine.list': mapped('routines/access'),
43
+ 'routineAccess.list': mapped('routines/granted'),
44
+ 'routineAllowance.list': mapped('routines/allowance'),
45
+ 'routineRequest.list': mapped('routines/requests'),
46
+ 'storage.read': mapped('storage/inventory'),
47
+ 'trigger.list': mapped('triggers/read'),
48
+ 'triggerOccurrence.list': mapped('triggers/fired'),
49
+ };
50
+ export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
51
+ const APP_NAMES = new Map(Object.entries(APP_ACTS).map(([name, act]) => [act.door, name]));
15
52
  export function houseConversationAgents(locator) {
16
53
  return { locator, type: 'house-agent', identity: 'agent', name: 'name' };
17
54
  }
18
55
  export function declaredActions(routes) {
19
- const mapped = new Map([...CONVERSATION_ROUTES].map(([name, route]) => [route.slice('/door/'.length), name]));
20
56
  return routes.map((route) => ({
21
- name: mapped.get(route) ?? route,
57
+ name: APP_NAMES.get(route) ?? route,
22
58
  inputShape: {},
23
59
  resultKind: 'house',
24
60
  }));
25
61
  }
26
62
  export function houseAction(transport, request) {
27
- if (request.name === 'conversation.send')
28
- return sendAction(transport, request.input);
29
- if (request.name === 'conversation.history')
30
- return historyAction(transport, request.input);
31
- if (request.name === 'attachments/upload')
32
- return attachAction(transport, request.input);
33
- if (request.name === 'attachments/get')
34
- return openAction(transport, request.input);
63
+ if (Object.hasOwn(APP_ACTS, request.name)) {
64
+ return APP_ACTS[request.name].carry(transport, request.input, request.name);
65
+ }
66
+ if (APP_NAMES.has(request.name))
67
+ return Promise.resolve(unimplemented(request.name));
35
68
  const route = routeOf(request.name);
36
69
  if (route === null)
37
70
  return Promise.resolve(malformed());
38
71
  return carry(transport, route, request.name, request.input);
39
72
  }
40
73
  function routeOf(name) {
41
- const mapped = CONVERSATION_ROUTES.get(name);
42
- if (mapped !== undefined)
43
- return mapped;
44
74
  const parts = name.split('/');
45
75
  if (parts.some((part) => part === '.' || part === '..'))
46
76
  return null;
@@ -62,27 +92,25 @@ function operationId(input) {
62
92
  return text(input, 'operation_id') ?? changeBatchIdentity();
63
93
  }
64
94
  function malformed() {
65
- return { kind: 'rejected', code: 'invalid_request', fields: {} };
95
+ return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
66
96
  }
67
- function bodyOf(name, input) {
68
- if (name === 'conversation.create') {
69
- return { agent_id: text(input, 'agent_id'), operation_id: operationId(input) };
70
- }
71
- if (name === 'conversation.interrupt' ||
72
- name === 'conversation.kill' ||
73
- name === 'conversation.delete') {
74
- return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };
75
- }
76
- if (name === 'conversation.answer') {
77
- const nested = record(record(input).answer);
78
- return {
79
- conversation_id: text(input, 'conversation'),
80
- operation_id: operationId(input),
81
- interaction_id: text(nested, 'interaction_id'),
82
- response: nested.response,
83
- };
84
- }
85
- return input;
97
+ function unimplemented(name) {
98
+ return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
99
+ }
100
+ function createBody(input) {
101
+ return { agent_id: text(input, 'agent_id'), operation_id: operationId(input) };
102
+ }
103
+ function controlBody(input) {
104
+ return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };
105
+ }
106
+ function answerBody(input) {
107
+ const nested = record(record(input).answer);
108
+ return {
109
+ conversation_id: text(input, 'conversation'),
110
+ operation_id: operationId(input),
111
+ interaction_id: text(nested, 'interaction_id'),
112
+ response: nested.response,
113
+ };
86
114
  }
87
115
  function withTurn(body) {
88
116
  const held = record(body);
@@ -93,20 +121,16 @@ export function actionOutcome(answer, name) {
93
121
  if (answer.status === 401)
94
122
  return { kind: 'revoked-authorization' };
95
123
  const refusal = doorRefusal(answer.body);
96
- if (refusal !== null) {
97
- return { kind: 'rejected', code: refusal.code, fields: refusal.fields };
98
- }
124
+ if (refusal !== null)
125
+ return { kind: 'rejected', ...refusal };
99
126
  if (answer.status === 404)
100
- return { kind: 'rejected', code: 'action-unimplemented', fields: { name } };
127
+ return unimplemented(name);
101
128
  if (answer.status === 0 || answer.status >= 400)
102
129
  return { kind: 'transport-uncertainty' };
103
- if (name === 'conversation.send')
104
- return { kind: 'action', result: withTurn(answer.body) };
105
130
  return { kind: 'action', result: answer.body };
106
131
  }
107
132
  async function carry(transport, route, name, input) {
108
- const answer = await transport.door(route, bodyOf(name, input));
109
- return actionOutcome(answer, name);
133
+ return actionOutcome(await transport.door(route, input), name);
110
134
  }
111
135
  function sendFile(entry) {
112
136
  const file = record(entry);
@@ -176,7 +200,7 @@ function uploadGrant(entry) {
176
200
  return null;
177
201
  return { method: 'POST', operation: upload.operation, url: upload.url };
178
202
  }
179
- async function uploadOriginals(transport, input, result) {
203
+ async function uploadOriginals(transport, input, result, name) {
180
204
  const originals = record(result).originals;
181
205
  if (!Array.isArray(originals) || originals.length === 0)
182
206
  return null;
@@ -189,7 +213,12 @@ async function uploadOriginals(transport, input, result) {
189
213
  return malformed();
190
214
  const bytes = index < files.length ? await fileBytes(files[index]) : null;
191
215
  if (bytes === null) {
192
- return { kind: 'rejected', code: 'conversation_original_descriptor_required', fields: {} };
216
+ return {
217
+ kind: 'rejected',
218
+ code: 'conversation_original_descriptor_required',
219
+ fields: {},
220
+ retryable: false,
221
+ };
193
222
  }
194
223
  const failed = delivered(await transport.transfer({
195
224
  act: 'conversation_original_upload',
@@ -198,19 +227,18 @@ async function uploadOriginals(transport, input, result) {
198
227
  answer: 'json',
199
228
  body: bytes,
200
229
  operation: grant.operation,
201
- }), 'conversation.send');
230
+ }), name);
202
231
  if (failed !== null)
203
232
  return failed;
204
233
  }
205
234
  return null;
206
235
  }
207
- async function attachAction(transport, input) {
236
+ async function attachAction(transport, route, input, name) {
208
237
  const { blob, ...descriptor } = record(input);
209
238
  const bytes = await fileBytes({ blob });
210
239
  if (bytes === null)
211
240
  return malformed();
212
- const answer = await transport.door('/door/attachments/upload', descriptor);
213
- const outcome = actionOutcome(answer, 'attachments/upload');
241
+ const outcome = actionOutcome(await transport.door(route, descriptor), name);
214
242
  if (outcome.kind !== 'action')
215
243
  return outcome;
216
244
  const grant = uploadGrant(outcome.result);
@@ -226,11 +254,10 @@ async function attachAction(transport, input) {
226
254
  body: bytes,
227
255
  operation: grant.operation,
228
256
  });
229
- return delivered(stored, 'attachments/upload') ?? { kind: 'action', result: stored.body };
257
+ return delivered(stored, name) ?? { kind: 'action', result: stored.body };
230
258
  }
231
- async function openAction(transport, input) {
232
- const answer = await transport.door('/door/attachments/get', input);
233
- const outcome = actionOutcome(answer, 'attachments/get');
259
+ async function openAction(transport, route, input, name) {
260
+ const outcome = actionOutcome(await transport.door(route, input), name);
234
261
  if (outcome.kind !== 'action')
235
262
  return outcome;
236
263
  const { download, ...opened } = record(outcome.result);
@@ -245,25 +272,24 @@ async function openAction(transport, input) {
245
272
  url: grant.url,
246
273
  answer: 'bytes',
247
274
  });
248
- const failed = delivered(read, 'attachments/get');
275
+ const failed = delivered(read, name);
249
276
  if (failed !== null)
250
277
  return failed;
251
278
  if (!(read.body instanceof Blob))
252
279
  return { kind: 'transport-uncertainty' };
253
280
  return { kind: 'action', result: { ...opened, blob: read.body } };
254
281
  }
255
- async function sendAction(transport, input) {
282
+ async function sendAction(transport, route, input, name) {
256
283
  const body = sendBody(input);
257
284
  if (body === null)
258
285
  return malformed();
259
- const answer = await transport.door('/door/conversations/send', body);
260
- const outcome = actionOutcome(answer, 'conversation.send');
286
+ const outcome = actionOutcome(await transport.door(route, body), name);
261
287
  if (outcome.kind !== 'action')
262
288
  return outcome;
263
- const uploaded = await uploadOriginals(transport, input, outcome.result);
289
+ const uploaded = await uploadOriginals(transport, input, outcome.result, name);
264
290
  if (uploaded !== null)
265
291
  return uploaded;
266
- return outcome;
292
+ return { ...outcome, result: withTurn(outcome.result) };
267
293
  }
268
294
  function historyCursor(value) {
269
295
  const acceptedAt = text(value, 'accepted_at');
@@ -329,17 +355,17 @@ function historyAsks(input) {
329
355
  }
330
356
  return asks;
331
357
  }
332
- async function historyAction(transport, input) {
358
+ async function historyAction(transport, route, input, name) {
333
359
  const asks = historyAsks(input);
334
360
  if (asks === null)
335
361
  return malformed();
336
362
  const histories = [];
337
363
  for (let at = 0; at < asks.length; at += HISTORY_CONVERSATIONS) {
338
- const answer = await transport.door('/door/conversations/history', {
364
+ const answer = await transport.door(route, {
339
365
  conversations: asks.slice(at, at + HISTORY_CONVERSATIONS),
340
366
  limit: HISTORY_PAGE,
341
367
  });
342
- const outcome = actionOutcome(answer, 'conversation.history');
368
+ const outcome = actionOutcome(answer, name);
343
369
  if (outcome.kind !== 'action')
344
370
  return outcome;
345
371
  const answered = record(outcome.result).histories;
@@ -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,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"}
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;AAuChC,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;AAwBjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAyYpF"}
package/dist/adapter.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DISCOVER_PREFIXES, capabilities, discoveredRoom, mapDiscovery, parseDiscovery, trackedFrom, } from './discovery.js';
2
- import { scopeModels, streamedModels, viewModels } from './model.js';
3
- import { gathered, selections } from './gather.js';
2
+ import { partModels, streamedModels, viewModels } from './model.js';
3
+ import { gathered, gatheredEach, selections } from './gather.js';
4
4
  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';
@@ -28,14 +28,26 @@ export function createAgentsHouseAdapter(options) {
28
28
  throw new Error('no Discovery declared the bounds');
29
29
  return bounds;
30
30
  }
31
- async function bootstrappedRoom(envelope, entry) {
32
- const scope = envelope.scopes.find((candidate) => matchesScope(candidate, entry));
31
+ async function bootstrappedRoom(envelope, scope, entry, continued) {
33
32
  if (scope === undefined)
34
33
  return { kind: 'room-not-readable', locator: entry.locator };
35
- handed.set(entry.locator, scopeLinks(scope));
34
+ const next = envelope.next?.room === entry.authority ? envelope.next.path : null;
35
+ if (continued === null && next === null)
36
+ handed.set(entry.locator, scopeLinks(scope));
37
+ else
38
+ handed.delete(entry.locator);
36
39
  notifications.reach(entry.authority, scope);
37
- const models = await scopeModels(scope, entry);
38
- return { ...bootstrapOf(scope), ...(models === undefined ? {} : { models }) };
40
+ const seen = [
41
+ ...(continued?.seen ?? []),
42
+ ...entry.schemas.filter((schema) => scope.files.some((file) => file.path === schema)),
43
+ ];
44
+ const models = await partModels(scope, entry, new Set(seen), next === null);
45
+ const continuation = next === null ? null : { after: next, seen };
46
+ return {
47
+ ...bootstrapOf(scope),
48
+ ...(models === undefined ? {} : { models }),
49
+ ...(continuation === null ? {} : { pageToken: JSON.stringify(continuation) }),
50
+ };
39
51
  }
40
52
  async function enumeratedRoom(enumeration, ask) {
41
53
  const view = viewOf(enumeration, ask.entry);
@@ -109,41 +121,54 @@ export function createAgentsHouseAdapter(options) {
109
121
  return result;
110
122
  return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };
111
123
  }
112
- async function bundled(body) {
113
- const grant = parseGrant(body);
114
- if (grant === null)
115
- return body;
116
- if (grant.method !== 'GET')
117
- return null;
118
- const answer = await transport.transfer({
119
- act: 'local_copy_bundle',
120
- method: 'GET',
121
- url: grant.url,
122
- answer: 'json',
123
- });
124
- return answer.status === 200 ? answer.body : null;
125
- }
126
124
  function weight(entry) {
127
125
  return contentPrefixes(entry).length;
128
126
  }
129
- async function bootstrapped(entries) {
130
- const answers = [];
131
- for (const part of selections(entries, weight, declared().max_prefixes)) {
132
- const answer = await transport.door(DOOR_BOOTSTRAP, {
133
- prefixes: part.flatMap((entry) => contentPrefixes(entry)),
134
- });
135
- const classified = part.map((entry) => classifyDoor(answer.status, answer.body, entry.locator));
136
- const envelope = classified[0] === null ? parseEnvelope(await bundled(answer.body)) : null;
137
- for (const [index, entry] of part.entries()) {
138
- const failure = classified[index];
139
- if (failure === null || failure === undefined) {
140
- answers.push(envelope === null ? UNCERTAIN_READ : await bootstrappedRoom(envelope, entry));
141
- continue;
127
+ async function bootstrapped(entries, answer) {
128
+ let open = entries.map((entry, ask) => ({ entry, ask }));
129
+ while (open.length > 0) {
130
+ const unreached = [];
131
+ for (const part of selections(open, ({ entry }) => weight(entry), declared().max_prefixes)) {
132
+ const answered = await transport.door(DOOR_BOOTSTRAP, {
133
+ prefixes: part.flatMap(({ entry }) => contentPrefixes(entry)),
134
+ });
135
+ const classified = part.map(({ entry }) => classifyDoor(answered.status, answered.body, entry.locator));
136
+ const envelope = classified[0] === null ? parseEnvelope(answered.body) : null;
137
+ for (const [index, asked] of part.entries()) {
138
+ const failure = classified[index];
139
+ if (failure !== null && failure !== undefined) {
140
+ answer(asked.ask, failure);
141
+ continue;
142
+ }
143
+ if (envelope === null) {
144
+ answer(asked.ask, UNCERTAIN_READ);
145
+ continue;
146
+ }
147
+ const scope = envelope.scopes.find((candidate) => matchesScope(candidate, asked.entry));
148
+ if (scope === undefined && envelope.next !== undefined) {
149
+ unreached.push(asked);
150
+ continue;
151
+ }
152
+ answer(asked.ask, await bootstrappedRoom(envelope, scope, asked.entry, null));
142
153
  }
143
- answers.push(failure);
144
154
  }
155
+ open = unreached;
145
156
  }
146
- return answers;
157
+ }
158
+ async function continuedBootstrap(entry, continued) {
159
+ const after = { room: entry.authority, path: continued.after };
160
+ const answered = await transport.door(DOOR_BOOTSTRAP, {
161
+ prefixes: contentPrefixes(entry),
162
+ after,
163
+ });
164
+ const failure = classifyDoor(answered.status, answered.body, entry.locator);
165
+ if (failure !== null)
166
+ return failure;
167
+ const envelope = parseEnvelope(answered.body);
168
+ if (envelope === null)
169
+ return UNCERTAIN_READ;
170
+ const scope = envelope.scopes.find((candidate) => matchesScope(candidate, entry));
171
+ return bootstrappedRoom(envelope, scope, entry, continued);
147
172
  }
148
173
  function layered(asks) {
149
174
  const depths = new Map();
@@ -190,7 +215,7 @@ export function createAgentsHouseAdapter(options) {
190
215
  }
191
216
  return asks.map((ask) => answers.get(ask) ?? UNCERTAIN_READ);
192
217
  }
193
- const bootstrapTogether = gathered(bootstrapped);
218
+ const bootstrapTogether = gatheredEach(bootstrapped);
194
219
  const enumerateTogether = gathered(enumerated);
195
220
  async function uploaded(head, changes, delta, bytes, entry, handed, keep) {
196
221
  const paths = batchPaths(changes);
@@ -261,8 +286,9 @@ export function createAgentsHouseAdapter(options) {
261
286
  const entry = authorityFor(request.locator);
262
287
  if (entry === undefined)
263
288
  return { kind: 'room-not-readable', locator: request.locator };
264
- if (request.pageToken !== undefined)
265
- return { kind: 'transport-uncertainty' };
289
+ if (request.pageToken !== undefined) {
290
+ return continuedBootstrap(entry, JSON.parse(request.pageToken));
291
+ }
266
292
  return bootstrapTogether(entry);
267
293
  },
268
294
  async refresh(_authorization, request) {
package/dist/gather.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare function gatheredEach<A, R>(send: (asks: readonly A[], answer: (ask: number, result: R) => void) => Promise<void>): (ask: A) => Promise<R>;
1
2
  export declare function gathered<A, R>(send: (asks: readonly A[]) => Promise<readonly R[]>): (ask: A) => Promise<R>;
2
3
  export declare function selections<T>(items: readonly T[], weight: (item: T) => number, limit: number): readonly (readonly T[])[];
3
4
  //# sourceMappingURL=gather.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAMA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAClD,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CA0BxB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAC3B,KAAK,EAAE,MAAM,GACZ,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAgB3B"}
1
+ {"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAC/B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,GACpF,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAwBxB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAClD,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAMxB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAC3B,KAAK,EAAE,MAAM,GACZ,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAgB3B"}
package/dist/gather.js CHANGED
@@ -1,13 +1,11 @@
1
- export function gathered(send) {
1
+ export function gatheredEach(send) {
2
2
  let held = [];
3
3
  function flush() {
4
4
  const taken = held;
5
5
  held = [];
6
- send(taken.map((entry) => entry.ask)).then((answers) => {
7
- taken.forEach((entry, index) => {
8
- entry.resolve(answers[index]);
9
- });
10
- }, (reason) => {
6
+ send(taken.map((entry) => entry.ask), (ask, result) => {
7
+ taken[ask]?.resolve(result);
8
+ }).catch((reason) => {
11
9
  for (const entry of taken)
12
10
  entry.reject(reason);
13
11
  });
@@ -20,6 +18,13 @@ export function gathered(send) {
20
18
  held.push({ ask, resolve, reject });
21
19
  });
22
20
  }
21
+ export function gathered(send) {
22
+ return gatheredEach(async (asks, answer) => {
23
+ (await send(asks)).forEach((result, ask) => {
24
+ answer(ask, result);
25
+ });
26
+ });
27
+ }
23
28
  export function selections(items, weight, limit) {
24
29
  const parts = [];
25
30
  let part = [];
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
2
+ export { HOUSE_APP_ACTS } from './actions.js';
2
3
  export type { HouseByteAct, HouseByteAnswer, HouseByteTransfer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
3
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,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,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,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 +1,2 @@
1
1
  export { createAgentsHouseAdapter } from './adapter.js';
2
+ export { HOUSE_APP_ACTS } from './actions.js';
package/dist/model.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { RoomModels } from '@agentshouse/mdruntime';
2
2
  import type { TrackedAuthority } from './discovery.js';
3
3
  import { type HouseScope, type HouseView } from './read.js';
4
4
  import type { HouseMode, HouseStreamEntry } from './transport.js';
5
+ export declare function partModels(scope: HouseScope, tracked: TrackedAuthority, seen: ReadonlySet<string>, final: boolean): Promise<RoomModels | undefined>;
5
6
  export declare function scopeModels(scope: HouseScope, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
6
7
  export declare function viewModels(view: HouseView, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
7
8
  export declare function streamedModels(schemas: ReadonlyMap<string, HouseStreamEntry>, tracked: TrackedAuthority, mode: HouseMode): Promise<RoomModels | undefined>;
@@ -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;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"}
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,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EACzB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAKjC;AAED,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
@@ -26,8 +26,15 @@ async function modelsOf(tracked, read) {
26
26
  }
27
27
  return models.collection === undefined && models.selection === undefined ? undefined : models;
28
28
  }
29
+ export function partModels(scope, tracked, seen, final) {
30
+ return modelsOf(tracked, (schema) => {
31
+ if (scope.files.some((file) => file.path === schema))
32
+ return schemaOf(scope, schema);
33
+ return final && !seen.has(schema) ? ABSENT_SCHEMA : undefined;
34
+ });
35
+ }
29
36
  export function scopeModels(scope, tracked) {
30
- return modelsOf(tracked, (schema) => schemaOf(scope, schema));
37
+ return partModels(scope, tracked, new Set(), true);
31
38
  }
32
39
  export function viewModels(view, tracked) {
33
40
  return modelsOf(tracked, (schema) => {
package/dist/read.d.ts CHANGED
@@ -19,8 +19,13 @@ export type HouseScope = LogPosition & {
19
19
  contents: readonly HouseContent[];
20
20
  attachments?: readonly RoomAttachment[];
21
21
  };
22
+ export type HouseCursor = {
23
+ room: string;
24
+ path: string | null;
25
+ };
22
26
  export type HouseEnvelope = {
23
27
  scopes: readonly HouseScope[];
28
+ next?: HouseCursor;
24
29
  };
25
30
  export type HouseGrant = {
26
31
  method: 'GET';
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACb,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,W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,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,aAAa,CA+BnF"}
package/dist/read.js CHANGED
@@ -137,6 +137,14 @@ function parseScope(value, mode) {
137
137
  return null;
138
138
  return { anchor: manifest.anchor, ...at, files, contents, attachments };
139
139
  }
140
+ function parseCursor(value) {
141
+ if (typeof value !== 'object' || value === null)
142
+ return null;
143
+ const { room, path } = value;
144
+ if (typeof room !== 'string' || (path !== null && typeof path !== 'string'))
145
+ return null;
146
+ return { room, path };
147
+ }
140
148
  export function parseEnvelope(body) {
141
149
  if (typeof body !== 'object' || body === null)
142
150
  return null;
@@ -149,7 +157,10 @@ export function parseEnvelope(body) {
149
157
  return null;
150
158
  scopes.push(scope);
151
159
  }
152
- return { scopes };
160
+ if (!('next' in body) || body.next === undefined)
161
+ return { scopes };
162
+ const next = parseCursor(body.next);
163
+ return next === null ? null : { scopes, next };
153
164
  }
154
165
  export function parseSiteBootstrap(body) {
155
166
  return parseScope(body, 'site');
package/dist/refusal.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import type { AdapterFailure, DiscoverResult, ProviderRefusal, ScopedRefusal } from '@agentshouse/mdruntime';
2
- export type DoorRefusal = ProviderRefusal & {
3
- retryable: boolean;
4
- };
5
- export declare function doorRefusal(body: unknown): DoorRefusal | null;
6
- export declare function scopedRefusal(locator: string, scope: ScopedRefusal['scope'], refusal: DoorRefusal): ScopedRefusal;
2
+ export declare function doorRefusal(body: unknown): ProviderRefusal | null;
3
+ export declare function scopedRefusal(locator: string, scope: ScopedRefusal['scope'], refusal: ProviderRefusal): ScopedRefusal;
7
4
  export declare function classifyDoor(status: number, body: unknown, locator: string): AdapterFailure | null;
8
5
  export declare function classifyRead(status: number, body: unknown, locator: string): AdapterFailure | {
9
6
  kind: 'beyond-horizon';
@@ -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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AAM,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,CAQrF"}
package/dist/refusal.js CHANGED
@@ -6,11 +6,11 @@ export function doorRefusal(body) {
6
6
  const error = body.error;
7
7
  if (typeof error.code !== 'string')
8
8
  return null;
9
- const { code, ...fields } = error;
10
- return { code, fields, retryable: error.retryable === true };
9
+ const { code, retryable, ...fields } = error;
10
+ return { code, fields, retryable: retryable === true };
11
11
  }
12
12
  export function scopedRefusal(locator, scope, refusal) {
13
- return { kind: 'scoped-refusal', locator, scope, code: refusal.code, fields: refusal.fields };
13
+ return { kind: 'scoped-refusal', locator, scope, ...refusal };
14
14
  }
15
15
  function doorFailure(status, body) {
16
16
  if (status === 0)
@@ -50,11 +50,7 @@ export function discoveryFailure(status, body) {
50
50
  if (failure.kind === 'revoked-authorization')
51
51
  return failure;
52
52
  if (failure.kind === 'refused') {
53
- return {
54
- kind: 'contract-unavailable',
55
- code: failure.refusal.code,
56
- fields: failure.refusal.fields,
57
- };
53
+ return { kind: 'contract-unavailable', ...failure.refusal };
58
54
  }
59
55
  return { kind: 'transport-uncertainty' };
60
56
  }
@@ -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,EAKL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAgCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAkIxE"}
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,CAwIxE"}
package/dist/site.js CHANGED
@@ -74,6 +74,7 @@ export function createSiteAdapter(transport) {
74
74
  return models === undefined ? answer : { ...answer, models };
75
75
  }
76
76
  return {
77
+ localSaves: true,
77
78
  async authorize() {
78
79
  return {};
79
80
  },
@@ -114,7 +115,7 @@ export function createSiteAdapter(transport) {
114
115
  return refreshed(entry, request.fromRoomVersion);
115
116
  },
116
117
  async mutate() {
117
- return { kind: 'rejected', affected: {}, code: 'write-grant', fields: {} };
118
+ return { kind: 'rejected', affected: {}, code: 'write-grant', fields: {}, retryable: false };
118
119
  },
119
120
  async history() {
120
121
  return { kind: 'no-history' };
@@ -127,7 +128,12 @@ export function createSiteAdapter(transport) {
127
128
  },
128
129
  async action(_authorization, request) {
129
130
  if (request.name !== 'submit') {
130
- return { kind: 'rejected', code: 'action-unimplemented', fields: { name: request.name } };
131
+ return {
132
+ kind: 'rejected',
133
+ code: 'action-unimplemented',
134
+ fields: { name: request.name },
135
+ retryable: false,
136
+ };
131
137
  }
132
138
  if (!transport.online())
133
139
  return UNCERTAIN;
@@ -14,7 +14,7 @@ export type HouseDoorAnswer = {
14
14
  status: number;
15
15
  body: unknown;
16
16
  };
17
- export type HouseByteAct = 'local_copy_bundle' | 'authored_batch_upload' | 'conversation_original_upload' | 'original_upload' | 'original_download';
17
+ export type HouseByteAct = 'authored_batch_upload' | 'conversation_original_upload' | 'original_upload' | 'original_download';
18
18
  export type HouseByteBody = string | ArrayBuffer | Uint8Array;
19
19
  export type HouseByteAnswer = 'json' | 'bytes';
20
20
  export type HouseByteTransfer = {
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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AAC;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/write.d.ts CHANGED
@@ -38,6 +38,7 @@ export declare function rejectedMapping(mapping: Extract<ChangeMapping, {
38
38
  fields: {
39
39
  path: string;
40
40
  };
41
+ retryable: boolean;
41
42
  };
42
43
  export declare function revisionBody(input: {
43
44
  path: string;
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EAEX,aAAa,EAEb,cAAc,EAEd,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAOlD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE/D,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAuGrD,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAQ9E;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CAK/D;AAED,wBAAgB,UAA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AM,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,CAiDf"}
package/dist/write.js CHANGED
@@ -175,7 +175,13 @@ export function mutationOutcome(status, body, locator, handle) {
175
175
  if (refusal !== null && refusal.code === 'edit_conflict') {
176
176
  const { current, ...fields } = refusal.fields;
177
177
  const held = material(current, handle) ?? [];
178
- return { kind: 'conflicted', affected: affectedOf(held), code: refusal.code, fields };
178
+ return {
179
+ kind: 'conflicted',
180
+ affected: affectedOf(held),
181
+ code: refusal.code,
182
+ fields,
183
+ retryable: refusal.retryable,
184
+ };
179
185
  }
180
186
  if (refusal !== null && status === 404) {
181
187
  return scopedRefusal(locator, 'undisclosed', refusal);
@@ -185,14 +191,26 @@ export function mutationOutcome(status, body, locator, handle) {
185
191
  if (refusal?.retryable === true &&
186
192
  typeof reset === 'string' &&
187
193
  classified?.kind === 'transport-uncertainty') {
188
- return { kind: 'retryable-refusal', code: refusal.code, fields: refusal.fields, reset };
194
+ return {
195
+ kind: 'retryable-refusal',
196
+ code: refusal.code,
197
+ fields: refusal.fields,
198
+ retryable: true,
199
+ reset,
200
+ };
189
201
  }
190
202
  if (classified !== null && classified.kind !== 'scoped-refusal')
191
203
  return classified;
192
204
  if (classified !== null && status === 403)
193
205
  return classified;
194
206
  if (refusal !== null && status >= 400) {
195
- return { kind: 'rejected', affected: {}, code: refusal.code, fields: refusal.fields };
207
+ return {
208
+ kind: 'rejected',
209
+ affected: {},
210
+ code: refusal.code,
211
+ fields: refusal.fields,
212
+ retryable: refusal.retryable,
213
+ };
196
214
  }
197
215
  if (status !== 200 || typeof body !== 'object' || body === null) {
198
216
  return { kind: 'transport-uncertainty' };
@@ -237,6 +255,7 @@ export function rejectedMapping(mapping) {
237
255
  affected: {},
238
256
  code: mapping.rule,
239
257
  fields: { path: mapping.path },
258
+ retryable: false,
240
259
  };
241
260
  }
242
261
  export function revisionBody(input) {
@@ -285,6 +304,7 @@ export function historyOutcome(status, body, locator, request) {
285
304
  scope: 'content',
286
305
  code: 'retained_history_unavailable',
287
306
  fields: { path: request.path, revision: request.revision },
307
+ retryable: false,
288
308
  };
289
309
  }
290
310
  if (typeof named.content !== 'string')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-cacce09fc82c6",
3
+ "version": "0.1.0-cb89e0425af50",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "exports": {
15
15
  ".": {
16
16
  "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
17
+ "default": "./dist/index.js"
18
18
  },
19
19
  "./package.json": "./package.json"
20
20
  },
@@ -25,7 +25,7 @@
25
25
  "LICENSE"
26
26
  ],
27
27
  "dependencies": {
28
- "@agentshouse/mdmodel": "0.1.0-c896b3d9398b1",
29
- "@agentshouse/mdruntime": "0.1.0-c389df724fd2f"
28
+ "@agentshouse/mdmodel": "0.1.0-c4fe1bc82bc55",
29
+ "@agentshouse/mdruntime": "0.1.0-c99e5271060cd"
30
30
  }
31
31
  }