@agentshouse/mdruntime-adapter 0.1.0-ca1c5f87272be → 0.1.0-ca218a8729667

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/dist/actions.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents, type ConversationHistories, type ConversationHistoryRequest } from '@agentshouse/mdruntime';
2
2
  import type { HouseDoorAnswer, HouseTransport } from './transport.js';
3
+ export type HouseActDoor = Pick<HouseTransport, 'door'>;
3
4
  export declare const HISTORY_PAGE = 100;
4
5
  type Operated = {
5
6
  readonly operation_id?: string;
@@ -44,8 +45,13 @@ export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
44
45
  export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
45
46
  export declare function houseConversationAgents(locator: string): ConversationAgents;
46
47
  export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
47
- export declare function houseAction(transport: HouseTransport, request: ActionRequest): Promise<ActionResult>;
48
+ export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
48
49
  export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
50
+ type HistoryCursor = {
51
+ accepted_at: string;
52
+ message_id: string;
53
+ };
54
+ export declare function cursorPosition(cursor: HistoryCursor): string;
49
55
  export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
50
56
  export {};
51
57
  //# sourceMappingURL=actions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE1B,KAAK,0BAA0B,EAChC,MAAM,wBAAwB,CAAC;AAEhC,O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Q,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD,CAAC;AA2EF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE3D,CAAC;AAEF,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE5D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAKhF,CAAC;AAMJ,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAE3E;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAKvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAQvB;AAkFD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAQjF;AA+BD,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AASjE,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE"}
package/dist/actions.js CHANGED
@@ -181,7 +181,7 @@ function historyCursor(value) {
181
181
  return null;
182
182
  return { accepted_at: acceptedAt, message_id: messageId };
183
183
  }
184
- function position(cursor) {
184
+ export function cursorPosition(cursor) {
185
185
  return JSON.stringify({ accepted_at: cursor.accepted_at, message_id: cursor.message_id });
186
186
  }
187
187
  function positionCursor(value) {
@@ -199,7 +199,7 @@ export function acceptedMessage(entry) {
199
199
  return {
200
200
  identity: cursor.message_id,
201
201
  turn: text(entry, 'turn_id') ?? cursor.message_id,
202
- position: position(cursor),
202
+ position: cursorPosition(cursor),
203
203
  text: text(entry, 'text') ?? '',
204
204
  message: structuredClone(record(entry)),
205
205
  };
@@ -219,7 +219,7 @@ function historyPage(entry) {
219
219
  const next = held.next === null || held.next === undefined ? undefined : historyCursor(held.next);
220
220
  if (next === null)
221
221
  return null;
222
- return { conversation, messages, ...(next === undefined ? {} : { next: position(next) }) };
222
+ return { conversation, messages, ...(next === undefined ? {} : { next: cursorPosition(next) }) };
223
223
  }
224
224
  function historyAsks(input) {
225
225
  const asked = record(input).conversations;
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAGP,aAAa,EAkBd,MAAM,wBAAwB,CAAC;AA0ChC,OAAO,EAUL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AA0BxB,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;AAgFrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAyqBpF"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAGP,aAAa,EAkBd,MAAM,wBAAwB,CAAC;AAoChC,OAAO,EAUL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AA0BxB,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;AAqErD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA+jBpF"}
package/dist/adapter.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { stepped } from '@agentshouse/mdruntime';
2
2
  import { DISCOVER_PREFIXES, capabilities, discoveredRoom, mapDiscovery, parseDiscovery, trackedFrom, } from './discovery.js';
3
- import { manifestedModels, partModels, streamedModels, viewModels } from './model.js';
4
- import { gathered, gatheredEach, selections } from './gather.js';
3
+ import { streamedModels, viewModels } from './model.js';
4
+ import { gathered, selections } from './gather.js';
5
5
  import { createSiteAdapter } from './site.js';
6
- import { authorityRoot, bootstrapping, emptyScope, housePart, manifested, parseEnumeration, parseFileAddress, parseGrant, parseParted, partInventory, refreshFrom, viewOf, wholeView, } from './read.js';
7
- import { PART_ATTEMPTS, partArrival, partFrame, unverifiedPart } from './part.js';
6
+ import { authorityRoot, bootstrapping, parseEnumeration, parseFileAddress, parseGrant, refreshFrom, viewOf, wholeView, } from './read.js';
7
+ import { roomStreams } from './room-stream.js';
8
8
  import { sha256Hex } from './digest.js';
9
9
  import { finishedUpload, houseUpload } from './upload.js';
10
10
  import { houseAction } from './actions.js';
@@ -54,6 +54,8 @@ export function createAgentsHouseAdapter(options) {
54
54
  const notifications = houseNotifications(transport, 'credential');
55
55
  const tracked = new Map();
56
56
  const handed = new Map();
57
+ const rooms = roomStreams('credential');
58
+ const unreused = new Set();
57
59
  let heldRevisions;
58
60
  let bounds;
59
61
  function declared() {
@@ -61,73 +63,40 @@ export function createAgentsHouseAdapter(options) {
61
63
  throw new Error('no Discovery declared the bounds');
62
64
  return bounds;
63
65
  }
64
- async function fetchedPart(entry, continued, listed, received, arriving) {
65
- if (received !== undefined) {
66
- const kept = new Uint8Array(received);
67
- const held = await housePart(continued.room, kept, listed, 'credential');
68
- if (held !== null)
69
- return 'kind' in held ? held : { scope: held, frame: kept };
70
- }
71
- for (let attempt = 0; attempt < PART_ATTEMPTS; attempt += 1) {
72
- const answered = await transport.door(DOOR_BOOTSTRAP, {
73
- prefixes: [authorityRoot(entry.handle)],
74
- part: listed.part,
75
- ...(continued.held === undefined ? {} : { held: [continued.held] }),
76
- }, partArrival(listed, arriving));
77
- const failure = classifyRead(answered.status, answered.body, entry.locator);
78
- if (failure !== null)
79
- return failure;
80
- const frame = partFrame(answered.body);
81
- if (frame === null)
82
- continue;
83
- const scope = await housePart(continued.room, frame, listed, 'credential');
84
- if (scope !== null)
85
- return 'kind' in scope ? scope : { scope, frame };
86
- }
87
- return unverifiedPart(entry.locator);
88
- }
89
- async function manifestPage(asked, continued) {
90
- const inventory = partInventory(continued.room);
91
- if (inventory.parts === 0) {
92
- const page = await partPage(asked, continued, undefined, undefined);
93
- return page.kind === 'bootstrap' ? { ...page, inventory } : page;
94
- }
95
- const { models, seen } = await manifestedModels(continued.room, asked.entry);
96
- return manifested(continued.room, inventory, JSON.stringify({ ...continued, seen }), models);
97
- }
98
- async function partPage(asked, continued, received, arriving) {
99
- const { entry } = asked;
100
- const listed = continued.room.parts[continued.next];
101
- const sent = listed === undefined
102
- ? { scope: emptyScope(continued.room), frame: null }
103
- : await fetchedPart(entry, continued, listed, received, arriving);
104
- if ('kind' in sent)
105
- return sent;
106
- const scope = await reused(sent.scope, asked.held);
66
+ async function streamedPage(entry, token, held) {
67
+ const part = await rooms.part(entry, token);
68
+ if ('kind' in part)
69
+ return part;
70
+ const scope = await reused(part.scope, held);
107
71
  if (scope === null) {
108
- return asked.held === undefined
109
- ? UNCERTAIN_READ
110
- : bootstrapTogether({ entry, held: undefined });
72
+ unreused.add(entry.locator);
73
+ return UNCERTAIN_READ;
111
74
  }
112
- const next = continued.next + 1;
113
- const more = next < continued.room.parts.length;
114
- if (continued.next === 0 && !more)
75
+ if (part.first && part.ended)
115
76
  handed.set(entry.locator, roomVersion(scope));
116
77
  else
117
78
  handed.delete(entry.locator);
118
79
  notifications.reach(entry.authority, scope);
119
- const seen = [
120
- ...continued.seen,
121
- ...(scope.files.some((file) => file.path === entry.schema) ? [entry.schema] : []),
122
- ];
123
- const models = await partModels(scope, entry, new Set(seen), !more);
124
80
  return {
125
81
  ...(await stepped(bootstrapping(scope))),
126
- ...(models === undefined ? {} : { models }),
127
- ...(more ? { pageToken: JSON.stringify({ ...continued, next, seen }) } : {}),
128
- ...(sent.frame === null ? {} : { received: sent.frame }),
82
+ ...(part.models === undefined ? {} : { models: part.models }),
83
+ ...(part.pageToken === undefined ? {} : { pageToken: part.pageToken }),
84
+ bytes: part.bytes,
129
85
  };
130
86
  }
87
+ async function openedRoom(entry, request) {
88
+ const reusing = unreused.delete(entry.locator) ? undefined : request.held;
89
+ const files = reusing === undefined
90
+ ? null
91
+ : await heldFiles(entry.authority, reusing, declared().max_held_files);
92
+ const answered = await transport.streamed(DOOR_BOOTSTRAP, {
93
+ prefixes: [authorityRoot(entry.handle)],
94
+ ...(files === null ? {} : { held: [files] }),
95
+ }, request.signal ?? new AbortController().signal);
96
+ if (answered.room === null)
97
+ return classifyDoor(answered.status, answered.body, entry.locator) ?? UNCERTAIN_READ;
98
+ return rooms.head(entry, answered.room, request.arriving, request.signal);
99
+ }
131
100
  async function enumeratedPage(ask, page) {
132
101
  const answer = await transport.door(DOOR_ENUMERATE, {
133
102
  prefixes: [authorityRoot(ask.entry.handle)],
@@ -224,61 +193,6 @@ export function createAgentsHouseAdapter(options) {
224
193
  return result;
225
194
  return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };
226
195
  }
227
- async function holding(asks) {
228
- const bound = Math.floor(declared().max_held_files / Math.max(1, asks.filter((ask) => ask.held !== undefined).length));
229
- const held = [];
230
- for (const ask of asks) {
231
- if (ask.held === undefined || bound === 0)
232
- continue;
233
- const files = await heldFiles(ask.entry.authority, ask.held, bound);
234
- if (files !== null)
235
- held.push(files);
236
- }
237
- return held;
238
- }
239
- async function bootstrapped(asks, answer) {
240
- let open = asks.map((asked, ask) => ({ entry: asked.entry, asked, ask }));
241
- while (open.length > 0) {
242
- const unreached = [];
243
- for (const part of selections(open, declared().max_prefixes)) {
244
- const held = await holding(part.map(({ asked }) => asked));
245
- const answered = await transport.door(DOOR_BOOTSTRAP, {
246
- prefixes: part.map(({ entry }) => authorityRoot(entry.handle)),
247
- ...(held.length === 0 ? {} : { held }),
248
- });
249
- const classified = part.map(({ entry }) => classifyDoor(answered.status, answered.body, entry.locator));
250
- const parted = classified[0] === null ? parseParted(answered.body) : null;
251
- for (const [index, asked] of part.entries()) {
252
- const failure = classified[index];
253
- if (failure !== null && failure !== undefined) {
254
- answer(asked.ask, failure);
255
- continue;
256
- }
257
- if (parted === null) {
258
- answer(asked.ask, UNCERTAIN_READ);
259
- continue;
260
- }
261
- const room = parted.rooms.find((candidate) => candidate.anchor === asked.entry.authority);
262
- if (room === undefined && parted.next !== undefined) {
263
- unreached.push(asked);
264
- continue;
265
- }
266
- if (room === undefined) {
267
- answer(asked.ask, { kind: 'room-not-readable', locator: asked.entry.locator });
268
- continue;
269
- }
270
- const kept = held.find((files) => files.room === asked.entry.authority);
271
- answer(asked.ask, await manifestPage(asked.asked, {
272
- room,
273
- next: 0,
274
- seen: [],
275
- ...(kept === undefined ? {} : { held: kept }),
276
- }));
277
- }
278
- }
279
- open = unreached;
280
- }
281
- }
282
196
  function layered(asks) {
283
197
  const depths = new Map();
284
198
  const layers = [];
@@ -325,7 +239,6 @@ export function createAgentsHouseAdapter(options) {
325
239
  }
326
240
  return answers;
327
241
  }
328
- const bootstrapTogether = gatheredEach(bootstrapped);
329
242
  const enumerateTogether = gathered(enumerated);
330
243
  async function uploaded(head, changes, delta, bytes, entry, handed, keep) {
331
244
  const paths = batchPaths(changes);
@@ -509,11 +422,9 @@ export function createAgentsHouseAdapter(options) {
509
422
  const entry = authorityFor(request.locator);
510
423
  if (entry === undefined)
511
424
  return { kind: 'room-not-readable', locator: request.locator };
512
- const asked = { entry, held: request.held };
513
- if (request.pageToken !== undefined) {
514
- return partPage(asked, JSON.parse(request.pageToken), request.received, request.arriving);
515
- }
516
- return bootstrapTogether(asked);
425
+ return request.pageToken === undefined
426
+ ? openedRoom(entry, request)
427
+ : streamedPage(entry, request.pageToken, request.held);
517
428
  },
518
429
  async refresh(_authorization, request) {
519
430
  const entry = authorityFor(request.locator);
@@ -22,7 +22,7 @@ export type HouseOperations = {
22
22
  write: readonly string[];
23
23
  delete: readonly string[];
24
24
  };
25
- export type HouseReadLevel = 'mcp' | 'online' | 'local';
25
+ export type HouseAccessLevel = 'search' | 'open' | 'keep';
26
26
  export type HouseAuthority = LogPosition & {
27
27
  roomRef: string;
28
28
  roomHandle: string;
@@ -31,7 +31,7 @@ export type HouseAuthority = LogPosition & {
31
31
  typedSelection: readonly string[] | null;
32
32
  managedReplication: 'admitted' | 'unavailable';
33
33
  protectedPaths: readonly string[];
34
- read: HouseReadLevel;
34
+ level: HouseAccessLevel;
35
35
  operations: HouseOperations;
36
36
  };
37
37
  export type HouseDiscoveryDocument = {
@@ -62,7 +62,7 @@ export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthor
62
62
  export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
63
63
  export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
64
64
  export declare function declaredRetention(bounds: HouseBounds): Retention;
65
- export declare function capabilities(actions: HouseDiscoveryDocument['actions'], rooms: readonly Pick<TrackedAuthority, 'authority' | 'typedSelection'>[]): readonly Capability[];
65
+ export declare function capabilities(actions: HouseDiscoveryDocument['actions'], rooms: readonly Pick<TrackedAuthority, 'authority' | 'handle'>[]): readonly Capability[];
66
66
  export declare function siteCapabilities(): readonly Capability[];
67
67
  export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
68
68
  export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,MAAM,EACN,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;AAE1D,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB,EAAE,MAAM,CAAC;IACjC,2BAA2B,EAAE,MAAM,CAAC;IACpC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf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Position, roomVersion } from './version.js';
3
3
  export const PROVIDER_ACTIONS = 'provider-actions';
4
4
  export const DISCOVER_PREFIXES = ['/'];
5
+ const PRIVATE_HANDLE = 'private';
5
6
  const BOUND_KEYS = [
6
7
  'max_authored_file_bytes',
7
8
  'max_batch_operations',
@@ -18,7 +19,7 @@ const BOUND_KEYS = [
18
19
  'operation_retention_seconds',
19
20
  ];
20
21
  const OPERATION_KEYS = ['write', 'delete'];
21
- const READ_LEVELS = ['mcp', 'online', 'local'];
22
+ const ACCESS_LEVELS = ['search', 'open', 'keep'];
22
23
  function stringList(value) {
23
24
  if (!Array.isArray(value))
24
25
  return null;
@@ -86,11 +87,11 @@ function parseAuthority(value) {
86
87
  const typedSelection = parseTypedSelection(held.typed_selection);
87
88
  const protectedPaths = stringList(held.protected_paths);
88
89
  const operations = parseOperations(held.operations);
89
- const read = READ_LEVELS.find((level) => level === held.read);
90
+ const level = ACCESS_LEVELS.find((one) => one === held.level);
90
91
  if (at === null ||
91
92
  typedSelection === undefined ||
92
93
  protectedPaths === null ||
93
- read === undefined ||
94
+ level === undefined ||
94
95
  operations === null)
95
96
  return null;
96
97
  if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
@@ -105,7 +106,7 @@ function parseAuthority(value) {
105
106
  typedSelection,
106
107
  managedReplication: held.managed_replication,
107
108
  protectedPaths,
108
- read,
109
+ level,
109
110
  operations,
110
111
  ...at,
111
112
  };
@@ -220,14 +221,12 @@ export function declaredRetention(bounds) {
220
221
  };
221
222
  }
222
223
  export function capabilities(actions, rooms) {
223
- const house = rooms.find((room) => room.typedSelection !== null);
224
+ const own = rooms.find((room) => room.handle === PRIVATE_HANDLE);
224
225
  return [
225
226
  {
226
227
  name: PROVIDER_ACTIONS,
227
228
  actions: declaredActions(actions),
228
- ...(house === undefined
229
- ? {}
230
- : { conversationAgents: houseConversationAgents(house.authority) }),
229
+ ...(own === undefined ? {} : { conversationAgents: houseConversationAgents(own.authority) }),
231
230
  },
232
231
  ];
233
232
  }
@@ -253,7 +252,7 @@ export function discoveredRoom(authority) {
253
252
  replica: {
254
253
  selection: locator,
255
254
  admission: authority.managedReplication,
256
- offline: authority.read === 'online' ? 'locked' : 'open',
255
+ offline: authority.level === 'open' ? 'locked' : 'open',
257
256
  },
258
257
  ...(authority.typedSelection === null
259
258
  ? {}
package/dist/gather.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export declare function gatheredEach<A, R>(send: (asks: readonly A[], answer: (ask: number, result: R) => void) => Promise<void>): (ask: A) => Promise<R>;
2
1
  export declare function gathered<A, R>(send: (asks: readonly A[]) => Promise<readonly R[]>): (ask: A) => Promise<R>;
3
2
  export declare function selections<T>(items: readonly T[], limit: number): readonly (readonly T[])[];
4
3
  //# sourceMappingURL=gather.d.ts.map
@@ -1 +1 @@
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,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAO3F"}
1
+ {"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAkCA,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,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAO3F"}
package/dist/gather.js CHANGED
@@ -1,4 +1,4 @@
1
- export function gatheredEach(send) {
1
+ function gatheredEach(send) {
2
2
  let held = [];
3
3
  function flush() {
4
4
  const taken = held;