@agentshouse/mdruntime-adapter 0.1.0-c028d11613a54 → 0.1.0-c03a088da4fb8

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
@@ -3,5 +3,5 @@ import type { HouseDoorAnswer, HouseTransport } from './transport.js';
3
3
  export type HouseActDoor = Pick<HouseTransport, 'door'>;
4
4
  export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
5
5
  export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
6
- export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
6
+ export declare function actionOutcome(answer: HouseDoorAnswer, name: string, input: unknown): ActionResult;
7
7
  //# sourceMappingURL=actions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE7F,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAEvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAIvB;AAoBD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAQjF"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE7F,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAEvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAIvB;AAwBD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,YAAY,CAUjG"}
package/dist/actions.js CHANGED
@@ -25,12 +25,16 @@ function malformed() {
25
25
  function unimplemented(name) {
26
26
  return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
27
27
  }
28
- export function actionOutcome(answer, name) {
28
+ function numbered(input) {
29
+ return typeof input?.operation_id === 'string';
30
+ }
31
+ export function actionOutcome(answer, name, input) {
29
32
  if (answer.status === 401)
30
33
  return { kind: 'revoked-authorization' };
31
34
  const refusal = doorRefusal(answer.body);
32
- if (refusal?.code === 'operation_contended')
35
+ if (refusal?.code === 'operation_contended' && numbered(input)) {
33
36
  return { kind: 'transport-uncertainty' };
37
+ }
34
38
  if (refusal !== null)
35
39
  return { kind: 'rejected', ...refusal };
36
40
  if (answer.status === 404)
@@ -40,5 +44,5 @@ export function actionOutcome(answer, name) {
40
44
  return { kind: 'action', result: answer.body };
41
45
  }
42
46
  async function carry(transport, route, name, input) {
43
- return actionOutcome(await transport.door(route, input), name);
47
+ return actionOutcome(await transport.door(route, input), name, input);
44
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAcd,MAAM,wBAAwB,CAAC;AA+BhC,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,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;AA6DrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAyZpF"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAgBd,MAAM,wBAAwB,CAAC;AAgChC,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,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;AA+DrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA8apF"}
package/dist/adapter.js CHANGED
@@ -6,6 +6,7 @@ import { roomStreams } from './room-stream.js';
6
6
  import { sha256Hex } from './digest.js';
7
7
  import { finishedUpload, houseUpload } from './upload.js';
8
8
  import { houseAction } from './actions.js';
9
+ import { houseSearch } from './search.js';
9
10
  import { classifyDoor, doorRefusal } from './refusal.js';
10
11
  import { houseNotifications, } from './stream.js';
11
12
  import { houseDoorRoute, } from './transport.js';
@@ -28,7 +29,7 @@ async function heldFiles(authority, held, bound) {
28
29
  async function reused(scope, held) {
29
30
  const sent = new Set(scope.contents.map((entry) => entry.path));
30
31
  const contents = [...scope.contents];
31
- const asked = scope.files.filter((file) => file.binary === undefined && !sent.has(file.path));
32
+ const asked = scope.files.filter((file) => file.binary === undefined && file.outline === undefined && !sent.has(file.path));
32
33
  if (asked.length === 0)
33
34
  return scope;
34
35
  if (held === undefined)
@@ -108,12 +109,19 @@ export function createAgentsHouseAdapter(options) {
108
109
  bytes: part.bytes,
109
110
  };
110
111
  }
112
+ async function namedDocument(entry, path, signal) {
113
+ const answered = await transport.streamed(houseDoorRoute('bootstrap'), { room_ref: entry.authority, prefixes: [`${authorityRoot(entry.handle)}/${path}`] }, signal ?? new AbortController().signal);
114
+ if (answered.room === null)
115
+ return classifyDoor(answered.status, answered.body, entry.locator) ?? UNCERTAIN_READ;
116
+ return rooms.named(entry, answered.room, signal);
117
+ }
111
118
  async function openedRoom(entry, request) {
112
119
  const reusing = unreused.delete(entry.locator) ? undefined : request.held;
113
120
  const files = reusing === undefined
114
121
  ? null
115
122
  : await heldFiles(entry.authority, reusing, declared().max_held_files);
116
123
  const answered = await transport.streamed(houseDoorRoute('bootstrap'), {
124
+ room_ref: entry.authority,
117
125
  prefixes: [authorityRoot(entry.handle)],
118
126
  ...(files === null ? {} : { held: [files] }),
119
127
  }, request.signal ?? new AbortController().signal);
@@ -292,6 +300,8 @@ export function createAgentsHouseAdapter(options) {
292
300
  const entry = authorityFor(request.locator);
293
301
  if (entry === undefined)
294
302
  return { kind: 'room-not-readable', locator: request.locator };
303
+ if (request.path !== undefined)
304
+ return namedDocument(entry, request.path, request.signal);
295
305
  return request.pageToken === undefined
296
306
  ? openedRoom(entry, request)
297
307
  : streamedPage(entry, request.pageToken, request.held);
@@ -311,7 +321,7 @@ export function createAgentsHouseAdapter(options) {
311
321
  : houseMove(batch, entry.handle, into.handle);
312
322
  if (mapped.kind === 'unmapped')
313
323
  return rejectedMapping(mapped);
314
- const head = operationHead(batch);
324
+ const head = operationHead(batch, entry.authority);
315
325
  const delta = deltaBody(mapped.changes);
316
326
  const bytes = deltaBytes(delta);
317
327
  const handed = request.upload;
@@ -386,6 +396,9 @@ export function createAgentsHouseAdapter(options) {
386
396
  async action(_authorization, request) {
387
397
  return withAt(await houseAction(transport, request));
388
398
  },
399
+ search(_authorization, request) {
400
+ return houseSearch(transport, [...tracked.values()], request);
401
+ },
389
402
  roomStream: {
390
403
  hold: held,
391
404
  observe: notifications.observe,
@@ -1 +1 @@
1
- {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EAGZ,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhE,eAAO,MAAM,YAAY,MAAM,CAAC;AAIhC,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAkBjE,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE;AA8BD,wBAAsB,YAAY,CAChC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,YAAY,CAAC,CAmBvB"}
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EAGZ,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhE,eAAO,MAAM,YAAY,MAAM,CAAC;AAIhC,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAkBjE,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE;AA8BD,wBAAsB,YAAY,CAChC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,YAAY,CAAC,CAqBvB"}
package/dist/history.js CHANGED
@@ -73,7 +73,8 @@ export async function houseHistory(transport, request) {
73
73
  const asks = historyAsks(request);
74
74
  if (asks === null)
75
75
  return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
76
- const outcome = actionOutcome(await transport.door(houseDoorRoute(HISTORY), { conversations: asks, limit: HISTORY_PAGE }), HISTORY);
76
+ const asked = { conversations: asks, limit: HISTORY_PAGE };
77
+ const outcome = actionOutcome(await transport.door(houseDoorRoute(HISTORY), asked), HISTORY, asked);
77
78
  if (outcome.kind !== 'action')
78
79
  return outcome;
79
80
  const answered = record(outcome.result).histories;