@agentshouse/mdruntime-adapter 0.1.0-c42c5814296fe → 0.1.0-c43ed8a091d4d

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.
Files changed (85) hide show
  1. package/README.md +2 -2
  2. package/dist/actions.d.ts +3 -2
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +26 -9
  5. package/dist/adapter.d.ts +0 -1
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +175 -154
  8. package/dist/authored-path.d.ts +9 -0
  9. package/dist/authored-path.d.ts.map +1 -0
  10. package/dist/authored-path.js +34 -0
  11. package/dist/chunks.d.ts +36 -0
  12. package/dist/chunks.d.ts.map +1 -0
  13. package/dist/chunks.js +281 -0
  14. package/dist/digest.d.ts +0 -1
  15. package/dist/discovery.d.ts +32 -7
  16. package/dist/discovery.d.ts.map +1 -1
  17. package/dist/discovery.js +203 -29
  18. package/dist/history.d.ts +1 -7
  19. package/dist/history.d.ts.map +1 -1
  20. package/dist/history.js +24 -30
  21. package/dist/index.d.ts +6 -7
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +5 -5
  24. package/dist/map.d.ts +0 -1
  25. package/dist/model.d.ts +6 -9
  26. package/dist/model.d.ts.map +1 -1
  27. package/dist/model.js +28 -26
  28. package/dist/read.d.ts +15 -20
  29. package/dist/read.d.ts.map +1 -1
  30. package/dist/read.js +66 -164
  31. package/dist/refusal.d.ts +6 -2
  32. package/dist/refusal.d.ts.map +1 -1
  33. package/dist/refusal.js +28 -7
  34. package/dist/room-query.d.ts +4 -0
  35. package/dist/room-query.d.ts.map +1 -0
  36. package/dist/room-query.js +48 -0
  37. package/dist/search.d.ts +4 -0
  38. package/dist/search.d.ts.map +1 -0
  39. package/dist/search.js +47 -0
  40. package/dist/session-content/check.d.ts +17 -0
  41. package/dist/session-content/index.d.ts +6 -0
  42. package/dist/session-content/parts.d.ts +30 -0
  43. package/dist/session-content/state.d.ts +59 -0
  44. package/dist/session-content/turn.d.ts +137 -0
  45. package/dist/site.d.ts +0 -1
  46. package/dist/site.d.ts.map +1 -1
  47. package/dist/site.js +59 -51
  48. package/dist/space-schema.d.ts +6 -0
  49. package/dist/space-schema.d.ts.map +1 -0
  50. package/dist/space-schema.js +11 -0
  51. package/dist/stream.d.ts +4 -4
  52. package/dist/stream.d.ts.map +1 -1
  53. package/dist/stream.js +162 -62
  54. package/dist/transport.d.ts +63 -25
  55. package/dist/transport.d.ts.map +1 -1
  56. package/dist/transport.js +48 -11
  57. package/dist/uncertain.d.ts +5 -0
  58. package/dist/uncertain.d.ts.map +1 -0
  59. package/dist/uncertain.js +11 -0
  60. package/dist/upload.d.ts +3 -2
  61. package/dist/upload.d.ts.map +1 -1
  62. package/dist/upload.js +8 -6
  63. package/dist/version.d.ts +0 -1
  64. package/dist/write.d.ts +2 -3
  65. package/dist/write.d.ts.map +1 -1
  66. package/dist/write.js +29 -46
  67. package/package.json +3 -2
  68. package/dist/app-reference.d.ts +0 -2
  69. package/dist/app-reference.d.ts.map +0 -1
  70. package/dist/app-reference.js +0 -2
  71. package/dist/crockford.d.ts +0 -4
  72. package/dist/crockford.d.ts.map +0 -1
  73. package/dist/crockford.js +0 -3
  74. package/dist/house-model.d.ts +0 -2983
  75. package/dist/house-model.d.ts.map +0 -1
  76. package/dist/house-model.js +0 -1642
  77. package/dist/part.d.ts +0 -14
  78. package/dist/part.d.ts.map +0 -1
  79. package/dist/part.js +0 -90
  80. package/dist/room-stream.d.ts +0 -19
  81. package/dist/room-stream.d.ts.map +0 -1
  82. package/dist/room-stream.js +0 -57
  83. package/dist/room-types.d.ts +0 -7
  84. package/dist/room-types.d.ts.map +0 -1
  85. package/dist/room-types.js +0 -126
package/dist/transport.js CHANGED
@@ -1,23 +1,28 @@
1
+ import { plain, queryKey } from '@agentshouse/mdmodel';
1
2
  export const HOUSE_RUNTIME_READS = {
2
3
  acts: [
3
- 'account/push',
4
- 'agents/read',
4
+ 'account/push/set',
5
+ 'account/time-zone/set',
5
6
  'apps/features/set',
6
7
  'apps/source/download',
7
- 'apps/source/top',
8
- 'batch',
9
- 'batch-upload',
10
- 'bootstrap',
11
- 'conversations/history',
12
- 'discover',
8
+ 'apps/source/top/read',
9
+ 'conversations/history/list',
13
10
  'files/attach',
11
+ 'files/batch',
12
+ 'files/batch-upload',
14
13
  'files/finish',
15
- 'files/get',
16
- 'revisions',
14
+ 'files/read',
15
+ 'files/revisions/list',
16
+ 'room-chunks/list',
17
+ 'rooms/discover',
18
+ 'rooms/query',
19
+ 'rooms/search',
17
20
  'sites/screenshot/read',
18
21
  ],
19
22
  frames: [
23
+ 'agent',
20
24
  'app-message',
25
+ 'app-rooms',
21
26
  'authority_changed',
22
27
  'carried',
23
28
  'caught_up',
@@ -36,9 +41,11 @@ export const HOUSE_RUNTIME_READS = {
36
41
  'part',
37
42
  'process',
38
43
  'received',
44
+ 'report',
39
45
  'signal',
40
46
  'site',
41
47
  'starting',
48
+ 'state',
42
49
  'tab-icon',
43
50
  'turn',
44
51
  ],
@@ -49,6 +56,36 @@ export function houseDoorRoute(act) {
49
56
  export function houseSiteRoute(act) {
50
57
  return `/_house/door/${act}`;
51
58
  }
52
- export const SITE_SUBMISSION = 'site/submission';
59
+ export const SITE_QUERY = 'query';
60
+ export const SITE_QUERY_ROUTE_CHARACTERS = 12_000;
61
+ function addressed(text) {
62
+ let binary = '';
63
+ for (const byte of new TextEncoder().encode(text))
64
+ binary += String.fromCharCode(byte);
65
+ return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/u, '');
66
+ }
67
+ export function siteQueryRoute(room, query) {
68
+ const canonical = queryKey(JSON.parse(JSON.stringify(query)));
69
+ return `${houseSiteRoute('query')}/${room}?${SITE_QUERY}=${addressed(canonical)}`;
70
+ }
71
+ export function siteQueryAsked(address) {
72
+ let asked;
73
+ try {
74
+ const binary = atob(address.replaceAll('-', '+').replaceAll('_', '/'));
75
+ const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
76
+ asked = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ return plain(asked) && addressed(queryKey(asked)) === address ? asked : null;
82
+ }
83
+ export const SITES_SUBMISSIONS_CREATE = 'sites/submissions/create';
53
84
  export const SITE_DOOR_SUBMIT = '/_house/door/submit';
85
+ export const SITES_FUNCTIONS_CALL = 'sites/functions/call';
86
+ export const SITE_DOOR_FUNCTION = '/_house/door/function';
87
+ export const SITE_DOOR_ACTS = {
88
+ [SITES_SUBMISSIONS_CREATE]: SITE_DOOR_SUBMIT,
89
+ [SITES_FUNCTIONS_CALL]: SITE_DOOR_FUNCTION,
90
+ };
54
91
  export const SITE_FILES = '/_house/files/';
@@ -0,0 +1,5 @@
1
+ import { type ProviderRefusal, type TransportUncertainty } from '@agentshouse/mdruntime';
2
+ export declare const UNANSWERED: TransportUncertainty;
3
+ export declare function failedOn(failure: unknown): TransportUncertainty;
4
+ export declare function unusable(): TransportUncertainty;
5
+ export declare function refusedFor(refusal: ProviderRefusal): TransportUncertainty;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uncertain.d.ts","sourceRoot":"","sources":["../src/uncertain.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,UAAU,EAAE,oBAAwD,CAAC;AAElF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAE/D;AAED,wBAAgB,QAAQ,IAAI,oBAAoB,CAE/C;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,oBAAoB,CAEzE"}
@@ -0,0 +1,11 @@
1
+ import { refusalError, } from '@agentshouse/mdruntime';
2
+ export const UNANSWERED = { kind: 'transport-uncertainty' };
3
+ export function failedOn(failure) {
4
+ return { kind: 'transport-uncertainty', failure };
5
+ }
6
+ export function unusable() {
7
+ return failedOn(new Error());
8
+ }
9
+ export function refusedFor(refusal) {
10
+ return failedOn(refusalError(refusal));
11
+ }
package/dist/upload.d.ts CHANGED
@@ -8,5 +8,6 @@ export type HouseUpload = {
8
8
  }[];
9
9
  };
10
10
  export declare function houseUpload(value: unknown): HouseUpload | null;
11
- export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer | null>;
12
- //# sourceMappingURL=upload.d.ts.map
11
+ export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer | {
12
+ readonly unfinished: number;
13
+ }>;
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE3F,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5E,CAAC;AAeF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAQ9D;AA8BD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAejC"}
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE3F,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5E,CAAC;AAeF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAQ9D;AA+BD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB5D"}
package/dist/upload.js CHANGED
@@ -37,17 +37,19 @@ async function sent(transport, upload, blob, digests) {
37
37
  for (const { part: number, url } of upload.parts) {
38
38
  const start = (number - 1) * upload.partBytes;
39
39
  const slice = blob.slice(start, start + upload.partBytes);
40
- if ((await transport.put(url, slice, checksum(digests[number - 1]))) !== 200)
41
- return false;
40
+ const stored = await transport.put(url, slice, checksum(digests[number - 1]));
41
+ if (stored !== 200)
42
+ return stored;
42
43
  }
43
- return true;
44
+ return 200;
44
45
  }
45
46
  export async function finishedUpload(transport, first, blob) {
46
47
  const digests = await partSha256(blob, first.partBytes);
47
48
  let upload = first;
48
49
  for (let round = 0; round < FINISHING_ROUNDS; round += 1) {
49
- if (!(await sent(transport, upload, blob, digests)))
50
- return null;
50
+ const stored = await sent(transport, upload, blob, digests);
51
+ if (stored !== 200)
52
+ return { unfinished: stored };
51
53
  const answer = await transport.door(houseDoorRoute('files/finish'), {
52
54
  upload: upload.id,
53
55
  part_sha256: digests,
@@ -59,5 +61,5 @@ export async function finishedUpload(transport, first, blob) {
59
61
  return answer;
60
62
  upload = missing;
61
63
  }
62
- return null;
64
+ return { unfinished: 200 };
63
65
  }
package/dist/version.d.ts CHANGED
@@ -14,4 +14,3 @@ export declare function presented(authority: string, at: LogPosition): Presented
14
14
  export declare const DECIMAL: RegExp;
15
15
  export declare function reachedVersion(roomVersion: string, target: string, currentEpoch: string | undefined): boolean;
16
16
  export declare function followsVersion(roomVersion: string, next: string): boolean;
17
- //# sourceMappingURL=version.d.ts.map
package/dist/write.d.ts CHANGED
@@ -17,10 +17,11 @@ export declare function houseParts(saved: readonly {
17
17
  export declare function houseMove(batch: ChangeBatch, source: string, destination: string): ChangeMapping;
18
18
  export type OperationHead = {
19
19
  readonly operation_id: string;
20
+ readonly room_ref: string;
20
21
  readonly app_ref?: string;
21
22
  readonly release?: string;
22
23
  };
23
- export declare function operationHead(batch: ChangeBatch): OperationHead;
24
+ export declare function operationHead(batch: ChangeBatch, room: string): OperationHead;
24
25
  export declare function batchPaths(changes: readonly HouseOperation[]): readonly string[];
25
26
  export declare function deltaBody(changes: readonly HouseOperation[]): string;
26
27
  export declare function deltaBytes(delta: string): number;
@@ -55,7 +56,5 @@ export declare function revisionBody(input: {
55
56
  pageToken?: string;
56
57
  }): Record<string, unknown>;
57
58
  export declare function historyOutcome(status: number, body: unknown, locator: string, request: {
58
- path: string;
59
59
  revision?: string;
60
60
  }): HistoryResult;
61
- //# sourceMappingURL=write.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAElB,KAAK,cAAc,EAEpB,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,IAA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f,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1B;AA6BD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,aAAa,CA8Cf"}
package/dist/write.js CHANGED
@@ -2,8 +2,9 @@ import { departure, partsChanges, ROW_WEIGHT, } from '@agentshouse/mdruntime';
2
2
  import { answered, answering, binaryFileOf, headChange, revised } from './read.js';
3
3
  import { sha256Hex, textBytes } from './digest.js';
4
4
  import { nativePath, roomLocalPath } from './map.js';
5
- import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
5
+ import { answeredFailure, classifyDoor, doorRefusal, resetOf, scopedRefusal } from './refusal.js';
6
6
  import { readPosition, roomVersion } from './version.js';
7
+ import { unusable } from './uncertain.js';
7
8
  function priorField(batch, path, name) {
8
9
  return batch.preconditions.find((precondition) => precondition.kind === 'field' && precondition.path === path && precondition.name === name);
9
10
  }
@@ -28,7 +29,7 @@ function created(change, path) {
28
29
  const { type, ...fields } = change.fields;
29
30
  if (typeof type !== 'string' || type.length === 0)
30
31
  return null;
31
- return { op: 'create_typed', path, type, fields, sections: change.sections };
32
+ return { op: 'create_typed', path, type, fields };
32
33
  }
33
34
  function operationOf(batch, change, handle) {
34
35
  const path = nativePath(change.path, handle);
@@ -141,11 +142,10 @@ export function houseMove(batch, source, destination) {
141
142
  }
142
143
  return { kind: 'changes', changes };
143
144
  }
144
- export function operationHead(batch) {
145
+ export function operationHead(batch, room) {
145
146
  const writer = batch.writtenBy;
146
- return writer === undefined
147
- ? { operation_id: batch.id }
148
- : { operation_id: batch.id, app_ref: writer.app, release: writer.release };
147
+ const head = { operation_id: batch.id, room_ref: room };
148
+ return writer === undefined ? head : { ...head, app_ref: writer.app, release: writer.release };
149
149
  }
150
150
  export function batchPaths(changes) {
151
151
  return [
@@ -231,7 +231,7 @@ function* acceptedOf(at, contents) {
231
231
  answer.changes.set(entry.path, entry.head);
232
232
  }
233
233
  const unbinaried = answer.binaryFiles.size === 0;
234
- const { binaryFiles, ...room } = yield* answered(answer);
234
+ const { binaryFiles, facts: _facts, ...room } = yield* answered(answer);
235
235
  return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : { binaryFiles }) };
236
236
  }
237
237
  function* movedOutcome(held, move) {
@@ -245,12 +245,12 @@ function* movedOutcome(held, move) {
245
245
  const left = at(move.source.authority);
246
246
  const arrived = at(move.destination.authority);
247
247
  if (left === null || arrived === null)
248
- return { kind: 'transport-uncertainty' };
248
+ return unusable();
249
249
  const under = (handle) => (path) => path.startsWith(`/rooms/${handle}/`);
250
250
  const leaving = yield* material(held.contents, move.source.handle, under(move.source.handle));
251
251
  const arriving = yield* material(held.contents, move.destination.handle, under(move.destination.handle));
252
252
  if (leaving === null || arriving === null)
253
- return { kind: 'transport-uncertainty' };
253
+ return unusable();
254
254
  return {
255
255
  kind: 'accepted',
256
256
  ...(yield* acceptedOf(left, leaving)),
@@ -262,11 +262,6 @@ export function* mutationOutcome(status, body, locator, handle, move) {
262
262
  if (refusal !== null && refusal.code === 'service_mode_write_halted') {
263
263
  return { kind: 'write-halted' };
264
264
  }
265
- if (refusal !== null && refusal.code === 'expired') {
266
- return refusal.fields.restored === true
267
- ? { kind: 'expired', restored: true }
268
- : { kind: 'expired' };
269
- }
270
265
  if (refusal !== null && refusal.code === 'edit_conflict') {
271
266
  const { current, ...fields } = refusal.fields;
272
267
  const held = (yield* material(current, handle)) ?? [];
@@ -282,10 +277,8 @@ export function* mutationOutcome(status, body, locator, handle, move) {
282
277
  return scopedRefusal(locator, 'undisclosed', refusal);
283
278
  }
284
279
  const classified = classifyDoor(status, body, locator);
285
- const reset = refusal?.fields.retry_at;
286
- if (refusal?.retryable === true &&
287
- typeof reset === 'string' &&
288
- classified?.kind === 'transport-uncertainty') {
280
+ const reset = resetOf(refusal);
281
+ if (refusal !== null && reset !== undefined && classified?.kind === 'transport-uncertainty') {
289
282
  return {
290
283
  kind: 'retryable-refusal',
291
284
  code: refusal.code,
@@ -308,18 +301,19 @@ export function* mutationOutcome(status, body, locator, handle, move) {
308
301
  retryable: refusal.retryable,
309
302
  };
310
303
  }
311
- if (status !== 200 || typeof body !== 'object' || body === null) {
312
- return { kind: 'transport-uncertainty' };
313
- }
304
+ if (status !== 200)
305
+ return answeredFailure(status, body);
306
+ if (typeof body !== 'object' || body === null)
307
+ return unusable();
314
308
  const held = body;
315
309
  if (move !== undefined)
316
310
  return yield* movedOutcome(held, move);
317
311
  const at = readPosition(held);
318
312
  if (at === null)
319
- return { kind: 'transport-uncertainty' };
313
+ return unusable();
320
314
  const contents = yield* material(held.contents, handle);
321
315
  if (contents === null)
322
- return { kind: 'transport-uncertainty' };
316
+ return unusable();
323
317
  return { kind: 'accepted', ...(yield* acceptedOf(at, contents)) };
324
318
  }
325
319
  export function rejectedMapping(mapping) {
@@ -340,6 +334,7 @@ export function revisionBody(input) {
340
334
  }
341
335
  function revisionAuthor(entry) {
342
336
  const user = entry.author_user;
337
+ const userName = entry.author_user_name;
343
338
  const site = entry.author_site;
344
339
  const siteName = entry.author_site_name;
345
340
  const inbox = entry.author_inbox;
@@ -347,9 +342,9 @@ function revisionAuthor(entry) {
347
342
  const app = entry.author_app;
348
343
  const appName = entry.author_app_name;
349
344
  const named = [site, siteName, inbox, inboxName, app, appName].filter((held) => held !== undefined);
350
- if (typeof user === 'string' && named.length === 0)
351
- return { kind: 'user', id: user };
352
- if (user !== null || named.length !== 2)
345
+ if (typeof user === 'string' && typeof userName === 'string' && named.length === 0)
346
+ return { kind: 'user', id: user, name: userName };
347
+ if (user !== null || userName !== undefined || named.length !== 2)
353
348
  return null;
354
349
  if (typeof site === 'string' && typeof siteName === 'string') {
355
350
  return { kind: 'site', id: site, name: siteName };
@@ -367,35 +362,23 @@ export function historyOutcome(status, body, locator, request) {
367
362
  if (classified !== null)
368
363
  return classified;
369
364
  if (status !== 200 || typeof body !== 'object' || body === null) {
370
- return { kind: 'transport-uncertainty' };
365
+ return unusable();
371
366
  }
372
367
  const held = body;
373
368
  if (!Array.isArray(held.revisions))
374
- return { kind: 'transport-uncertainty' };
369
+ return unusable();
375
370
  const entries = [];
376
371
  for (const entry of held.revisions) {
377
372
  if (typeof entry !== 'object' || entry === null)
378
- return { kind: 'transport-uncertainty' };
373
+ return unusable();
379
374
  entries.push(entry);
380
375
  }
381
- if (request.revision !== undefined) {
382
- const named = entries[0];
376
+ const named = entries[0];
377
+ if (request.revision !== undefined && typeof named?.media_type !== 'string') {
383
378
  if (named === undefined)
384
379
  return { kind: 'no-history' };
385
- if (named.unavailable === true) {
386
- return {
387
- kind: 'scoped-refusal',
388
- locator,
389
- scope: 'operation',
390
- code: 'retained_history_unavailable',
391
- fields: { path: request.path, revision: request.revision },
392
- retryable: false,
393
- };
394
- }
395
- if (typeof named.media_type === 'string')
396
- return { kind: 'no-history' };
397
380
  if (typeof named.content !== 'string')
398
- return { kind: 'transport-uncertainty' };
381
+ return unusable();
399
382
  return { kind: 'revision', content: named.content };
400
383
  }
401
384
  if (entries.length === 0)
@@ -406,11 +389,11 @@ export function historyOutcome(status, body, locator, request) {
406
389
  if (typeof entry.revision !== 'string' ||
407
390
  author === null ||
408
391
  typeof entry.created_at !== 'string') {
409
- return { kind: 'transport-uncertainty' };
392
+ return unusable();
410
393
  }
411
394
  const binaryFile = binaryFileOf(entry);
412
395
  if (binaryFile === null)
413
- return { kind: 'transport-uncertainty' };
396
+ return unusable();
414
397
  revisions.push({
415
398
  revision: entry.revision,
416
399
  author,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-c42c5814296fe",
3
+ "version": "0.1.0-c43ed8a091d4d",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,7 +24,8 @@
24
24
  "LICENSE"
25
25
  ],
26
26
  "dependencies": {
27
- "@agentshouse/mdruntime": "0.1.0-cf9a84afc6def"
27
+ "@agentshouse/mdmodel": "0.1.0-cbb41ab5ebbd2",
28
+ "@agentshouse/mdruntime": "0.1.0-c1ea23b9ca7c6"
28
29
  },
29
30
  "repository": {
30
31
  "type": "git",
@@ -1,2 +0,0 @@
1
- export declare const APP_REFERENCE_PATTERN: RegExp;
2
- //# sourceMappingURL=app-reference.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-reference.d.ts","sourceRoot":"","sources":["../src/app-reference.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,QAEjC,CAAC"}
@@ -1,2 +0,0 @@
1
- import { CROCKFORD_CHARACTER } from './crockford.js';
2
- export const APP_REFERENCE_PATTERN = new RegExp(`^a_(${CROCKFORD_CHARACTER}+)\\.(${CROCKFORD_CHARACTER})$`);
@@ -1,4 +0,0 @@
1
- export declare const CROCKFORD_ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz";
2
- export declare const CROCKFORD_CHARACTER = "[0123456789abcdefghjkmnpqrstvwxyz]";
3
- export declare const CROCKFORD_LEADING_CHARACTER: string;
4
- //# sourceMappingURL=crockford.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crockford.d.ts","sourceRoot":"","sources":["../src/crockford.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAErE,eAAO,MAAM,mBAAmB,uCAA4B,CAAC;AAE7D,eAAO,MAAM,2BAA2B,QAAqC,CAAC"}
package/dist/crockford.js DELETED
@@ -1,3 +0,0 @@
1
- export const CROCKFORD_ALPHABET = '0123456789abcdefghjkmnpqrstvwxyz';
2
- export const CROCKFORD_CHARACTER = `[${CROCKFORD_ALPHABET}]`;
3
- export const CROCKFORD_LEADING_CHARACTER = `[${CROCKFORD_ALPHABET.slice(1)}]`;