@agentshouse/mdruntime-adapter 0.1.0-cefdbbefd37e5 → 0.1.0-cf151c882c69c

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 (75) hide show
  1. package/README.md +1 -1
  2. package/dist/actions.d.ts +4 -0
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +55 -9
  5. package/dist/adapter.d.ts.map +1 -1
  6. package/dist/adapter.js +129 -117
  7. package/dist/authored-path.d.ts +54 -3
  8. package/dist/authored-path.d.ts.map +1 -1
  9. package/dist/authored-path.js +142 -11
  10. package/dist/chunks.d.ts +2 -3
  11. package/dist/chunks.d.ts.map +1 -1
  12. package/dist/chunks.js +72 -38
  13. package/dist/discovery.d.ts +25 -5
  14. package/dist/discovery.d.ts.map +1 -1
  15. package/dist/discovery.js +169 -21
  16. package/dist/history.d.ts.map +1 -1
  17. package/dist/history.js +3 -2
  18. package/dist/index.d.ts +6 -8
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +6 -8
  21. package/dist/model.d.ts +5 -5
  22. package/dist/model.d.ts.map +1 -1
  23. package/dist/model.js +17 -27
  24. package/dist/read.d.ts +11 -24
  25. package/dist/read.d.ts.map +1 -1
  26. package/dist/read.js +71 -44
  27. package/dist/refusal.d.ts +5 -1
  28. package/dist/refusal.d.ts.map +1 -1
  29. package/dist/refusal.js +23 -6
  30. package/dist/renamed.d.ts +10 -0
  31. package/dist/renamed.d.ts.map +1 -0
  32. package/dist/renamed.js +29 -0
  33. package/dist/room-query.d.ts +4 -0
  34. package/dist/room-query.d.ts.map +1 -0
  35. package/dist/room-query.js +63 -0
  36. package/dist/search.d.ts.map +1 -1
  37. package/dist/search.js +4 -4
  38. package/dist/session-content/check.d.ts +0 -1
  39. package/dist/session-content/index.d.ts +2 -3
  40. package/dist/session-content/parts.d.ts +12 -84
  41. package/dist/session-content/state.d.ts +4 -6
  42. package/dist/session-content/turn.d.ts +28 -219
  43. package/dist/site.d.ts.map +1 -1
  44. package/dist/site.js +56 -22
  45. package/dist/space-schema.d.ts.map +1 -1
  46. package/dist/space-schema.js +1 -8
  47. package/dist/stream.d.ts +2 -3
  48. package/dist/stream.d.ts.map +1 -1
  49. package/dist/stream.js +74 -76
  50. package/dist/transport.d.ts +44 -13
  51. package/dist/transport.d.ts.map +1 -1
  52. package/dist/transport.js +47 -7
  53. package/dist/uncertain.d.ts +5 -0
  54. package/dist/uncertain.d.ts.map +1 -0
  55. package/dist/uncertain.js +11 -0
  56. package/dist/upload.d.ts +7 -1
  57. package/dist/upload.d.ts.map +1 -1
  58. package/dist/upload.js +49 -6
  59. package/dist/write.d.ts +1 -2
  60. package/dist/write.d.ts.map +1 -1
  61. package/dist/write.js +30 -30
  62. package/package.json +4 -3
  63. package/dist/app-reference.d.ts +0 -1
  64. package/dist/app-reference.d.ts.map +0 -1
  65. package/dist/app-reference.js +0 -2
  66. package/dist/crockford.d.ts +0 -3
  67. package/dist/crockford.d.ts.map +0 -1
  68. package/dist/crockford.js +0 -3
  69. package/dist/house-model.d.ts +0 -830
  70. package/dist/house-model.d.ts.map +0 -1
  71. package/dist/house-model.js +0 -465
  72. package/dist/room-types.d.ts +0 -4
  73. package/dist/room-types.d.ts.map +0 -1
  74. package/dist/room-types.js +0 -135
  75. package/dist/session-content/bounds.d.ts +0 -7
package/dist/upload.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { sha256 } from '@agentshouse/mdruntime/digest';
2
+ import { answeredFailure, doorRefusal } from './refusal.js';
2
3
  import { houseDoorRoute } from './transport.js';
4
+ import { unusable } from './uncertain.js';
3
5
  const FINISHING_ROUNDS = 24;
4
6
  function record(value) {
5
7
  return value !== null && typeof value === 'object' ? value : {};
@@ -37,17 +39,19 @@ async function sent(transport, upload, blob, digests) {
37
39
  for (const { part: number, url } of upload.parts) {
38
40
  const start = (number - 1) * upload.partBytes;
39
41
  const slice = blob.slice(start, start + upload.partBytes);
40
- if ((await transport.put(url, slice, checksum(digests[number - 1]))) !== 200)
41
- return false;
42
+ const stored = await transport.put(url, slice, checksum(digests[number - 1]));
43
+ if (stored !== 200)
44
+ return stored;
42
45
  }
43
- return true;
46
+ return 200;
44
47
  }
45
48
  export async function finishedUpload(transport, first, blob) {
46
49
  const digests = await partSha256(blob, first.partBytes);
47
50
  let upload = first;
48
51
  for (let round = 0; round < FINISHING_ROUNDS; round += 1) {
49
- if (!(await sent(transport, upload, blob, digests)))
50
- return null;
52
+ const stored = await sent(transport, upload, blob, digests);
53
+ if (stored !== 200)
54
+ return { unfinished: stored };
51
55
  const answer = await transport.door(houseDoorRoute('files/finish'), {
52
56
  upload: upload.id,
53
57
  part_sha256: digests,
@@ -59,5 +63,44 @@ export async function finishedUpload(transport, first, blob) {
59
63
  return answer;
60
64
  upload = missing;
61
65
  }
62
- return null;
66
+ return { unfinished: 200 };
67
+ }
68
+ function unstagedRefusal(answer) {
69
+ const refusal = doorRefusal(answer.body);
70
+ return refusal?.code === 'files_unstaged' ? refusal : null;
71
+ }
72
+ async function staged(transport, named, file) {
73
+ const upload = houseUpload(named);
74
+ if (upload === null)
75
+ return unusable();
76
+ const blob = file(record(named).sha256);
77
+ if (blob === null)
78
+ return unusable();
79
+ const sent = await finishedUpload(transport, upload, await blob);
80
+ if ('unfinished' in sent)
81
+ return answeredFailure(sent.unfinished, null);
82
+ if (sent.status !== 200)
83
+ return answeredFailure(sent.status, sent.body);
84
+ return record(sent.body).staged === true ? null : unusable();
85
+ }
86
+ export async function stagedBatch(transport, body, file) {
87
+ let answer = await transport.door(houseDoorRoute('update'), body);
88
+ const finished = new Set();
89
+ for (let unstaged = unstagedRefusal(answer); unstaged !== null; unstaged = unstagedRefusal(answer)) {
90
+ const named = unstaged.fields.upload;
91
+ if (!Array.isArray(named))
92
+ return unusable();
93
+ const fresh = named.filter((upload) => !finished.has(record(upload).id));
94
+ if (fresh.length === 0)
95
+ return answeredFailure(answer.status, answer.body);
96
+ for (const upload of fresh) {
97
+ const staging = await staged(transport, upload, file);
98
+ if (staging !== null)
99
+ return staging;
100
+ }
101
+ for (const upload of fresh)
102
+ finished.add(record(upload).id);
103
+ answer = await transport.door(houseDoorRoute('update'), body);
104
+ }
105
+ return answer;
63
106
  }
package/dist/write.d.ts CHANGED
@@ -17,11 +17,10 @@ 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;
21
20
  readonly app_ref?: string;
22
21
  readonly release?: string;
23
22
  };
24
- export declare function operationHead(batch: ChangeBatch, room: string): OperationHead;
23
+ export declare function operationHead(batch: ChangeBatch): OperationHead;
25
24
  export declare function batchPaths(changes: readonly HouseOperation[]): readonly string[];
26
25
  export declare function deltaBody(changes: readonly HouseOperation[]): string;
27
26
  export declare function deltaBytes(delta: string): number;
@@ -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,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAwHrD,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAQ9E;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS;IAAE,QAAQ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AA;CAAE,GAC7B,aAAa,CA8Cf"}
package/dist/write.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { departure, partsChanges, ROW_WEIGHT, } from '@agentshouse/mdruntime';
2
- import { answered, answering, binaryFileOf, headChange, revised } from './read.js';
2
+ import { answered, answering, attachmentOf, 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, resetOf, 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,9 +142,9 @@ export function houseMove(batch, source, destination) {
141
142
  }
142
143
  return { kind: 'changes', changes };
143
144
  }
144
- export function operationHead(batch, room) {
145
+ export function operationHead(batch) {
145
146
  const writer = batch.writtenBy;
146
- const head = { operation_id: batch.id, room_ref: room };
147
+ const head = { operation_id: batch.id };
147
148
  return writer === undefined ? head : { ...head, app_ref: writer.app, release: writer.release };
148
149
  }
149
150
  export function batchPaths(changes) {
@@ -181,7 +182,7 @@ function* material(value, handle, within = () => true) {
181
182
  return null;
182
183
  if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')
183
184
  return null;
184
- const binary = binaryFileOf(file);
185
+ const binary = attachmentOf(file);
185
186
  if (binary === null)
186
187
  return null;
187
188
  const head = headChange(file);
@@ -224,14 +225,14 @@ function* acceptedOf(at, contents) {
224
225
  if (entry.content !== null)
225
226
  answer.documents.set(entry.path, entry.content);
226
227
  if (entry.binary !== undefined)
227
- answer.binaryFiles.set(entry.path, entry.binary);
228
+ answer.attachments.set(entry.path, entry.binary);
228
229
  revised(answer, entry.path, entry.revision);
229
230
  if (entry.head !== undefined)
230
231
  answer.changes.set(entry.path, entry.head);
231
232
  }
232
- const unbinaried = answer.binaryFiles.size === 0;
233
- const { binaryFiles, facts: _facts, ...room } = yield* answered(answer);
234
- return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : { binaryFiles }) };
233
+ const unbinaried = answer.attachments.size === 0;
234
+ const { attachments, facts: _facts, ...room } = yield* answered(answer);
235
+ return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : { attachments }) };
235
236
  }
236
237
  function* movedOutcome(held, move) {
237
238
  const authorities = Array.isArray(held.authorities) ? held.authorities : [];
@@ -244,12 +245,12 @@ function* movedOutcome(held, move) {
244
245
  const left = at(move.source.authority);
245
246
  const arrived = at(move.destination.authority);
246
247
  if (left === null || arrived === null)
247
- return { kind: 'transport-uncertainty' };
248
+ return unusable();
248
249
  const under = (handle) => (path) => path.startsWith(`/rooms/${handle}/`);
249
250
  const leaving = yield* material(held.contents, move.source.handle, under(move.source.handle));
250
251
  const arriving = yield* material(held.contents, move.destination.handle, under(move.destination.handle));
251
252
  if (leaving === null || arriving === null)
252
- return { kind: 'transport-uncertainty' };
253
+ return unusable();
253
254
  return {
254
255
  kind: 'accepted',
255
256
  ...(yield* acceptedOf(left, leaving)),
@@ -300,18 +301,19 @@ export function* mutationOutcome(status, body, locator, handle, move) {
300
301
  retryable: refusal.retryable,
301
302
  };
302
303
  }
303
- if (status !== 200 || typeof body !== 'object' || body === null) {
304
- return { kind: 'transport-uncertainty' };
305
- }
304
+ if (status !== 200)
305
+ return answeredFailure(status, body);
306
+ if (typeof body !== 'object' || body === null)
307
+ return unusable();
306
308
  const held = body;
307
309
  if (move !== undefined)
308
310
  return yield* movedOutcome(held, move);
309
311
  const at = readPosition(held);
310
312
  if (at === null)
311
- return { kind: 'transport-uncertainty' };
313
+ return unusable();
312
314
  const contents = yield* material(held.contents, handle);
313
315
  if (contents === null)
314
- return { kind: 'transport-uncertainty' };
316
+ return unusable();
315
317
  return { kind: 'accepted', ...(yield* acceptedOf(at, contents)) };
316
318
  }
317
319
  export function rejectedMapping(mapping) {
@@ -360,25 +362,23 @@ export function historyOutcome(status, body, locator, request) {
360
362
  if (classified !== null)
361
363
  return classified;
362
364
  if (status !== 200 || typeof body !== 'object' || body === null) {
363
- return { kind: 'transport-uncertainty' };
365
+ return unusable();
364
366
  }
365
367
  const held = body;
366
368
  if (!Array.isArray(held.revisions))
367
- return { kind: 'transport-uncertainty' };
369
+ return unusable();
368
370
  const entries = [];
369
371
  for (const entry of held.revisions) {
370
372
  if (typeof entry !== 'object' || entry === null)
371
- return { kind: 'transport-uncertainty' };
373
+ return unusable();
372
374
  entries.push(entry);
373
375
  }
374
- if (request.revision !== undefined) {
375
- const named = entries[0];
376
+ const named = entries[0];
377
+ if (request.revision !== undefined && typeof named?.media_type !== 'string') {
376
378
  if (named === undefined)
377
379
  return { kind: 'no-history' };
378
- if (typeof named.media_type === 'string')
379
- return { kind: 'no-history' };
380
380
  if (typeof named.content !== 'string')
381
- return { kind: 'transport-uncertainty' };
381
+ return unusable();
382
382
  return { kind: 'revision', content: named.content };
383
383
  }
384
384
  if (entries.length === 0)
@@ -389,16 +389,16 @@ export function historyOutcome(status, body, locator, request) {
389
389
  if (typeof entry.revision !== 'string' ||
390
390
  author === null ||
391
391
  typeof entry.created_at !== 'string') {
392
- return { kind: 'transport-uncertainty' };
392
+ return unusable();
393
393
  }
394
- const binaryFile = binaryFileOf(entry);
395
- if (binaryFile === null)
396
- return { kind: 'transport-uncertainty' };
394
+ const attachment = attachmentOf(entry);
395
+ if (attachment === null)
396
+ return unusable();
397
397
  revisions.push({
398
398
  revision: entry.revision,
399
399
  author,
400
400
  time: entry.created_at,
401
- ...(binaryFile === undefined ? {} : { binaryFile }),
401
+ ...(attachment === undefined ? {} : { attachment }),
402
402
  });
403
403
  }
404
404
  const next = held.next_before;
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-cefdbbefd37e5",
4
3
  "description": "Agents House Adapter for the MD Runtime",
5
4
  "license": "MIT",
6
5
  "type": "module",
@@ -24,11 +23,13 @@
24
23
  "LICENSE"
25
24
  ],
26
25
  "dependencies": {
27
- "@agentshouse/mdruntime": "0.1.0-c7921ed1eb9d6"
26
+ "@agentshouse/mdmodel": "0.1.0-cffab849d904b",
27
+ "@agentshouse/mdruntime": "0.1.0-c697ef79d87a3"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",
31
31
  "url": "git+https://github.com/agentshouse/core.git",
32
32
  "directory": "mdruntime/packages/mdruntime-adapter"
33
- }
33
+ },
34
+ "version": "0.1.0-cf151c882c69c"
34
35
  }
@@ -1 +0,0 @@
1
- export declare const APP_REFERENCE_PATTERN: RegExp;
@@ -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,3 +0,0 @@
1
- export declare const CROCKFORD_ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz";
2
- export declare const CROCKFORD_CHARACTER = "[0123456789abcdefghjkmnpqrstvwxyz]";
3
- export declare const CROCKFORD_LEADING_CHARACTER: string;
@@ -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)}]`;