@agentshouse/mdruntime-adapter 0.1.0-alpha.9 → 0.1.0-c04b3fdfb64c6

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 (66) hide show
  1. package/AGENTS.md +297 -71
  2. package/README.md +32 -0
  3. package/dist/actions.d.ts +66 -13
  4. package/dist/actions.d.ts.map +1 -1
  5. package/dist/actions.js +279 -354
  6. package/dist/adapter.d.ts +1 -0
  7. package/dist/adapter.d.ts.map +1 -1
  8. package/dist/adapter.js +480 -218
  9. package/dist/digest.js +1 -5
  10. package/dist/discovery.d.ts +24 -34
  11. package/dist/discovery.d.ts.map +1 -1
  12. package/dist/discovery.js +157 -230
  13. package/dist/gather.d.ts +4 -0
  14. package/dist/gather.d.ts.map +1 -0
  15. package/dist/gather.js +45 -0
  16. package/dist/handed.d.ts +15 -0
  17. package/dist/handed.d.ts.map +1 -0
  18. package/dist/handed.js +38 -0
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -3
  22. package/dist/map.d.ts +2 -2
  23. package/dist/map.d.ts.map +1 -1
  24. package/dist/map.js +6 -7
  25. package/dist/model.d.ts +7 -18
  26. package/dist/model.d.ts.map +1 -1
  27. package/dist/model.js +60 -57
  28. package/dist/read.d.ts +62 -29
  29. package/dist/read.d.ts.map +1 -1
  30. package/dist/read.js +290 -203
  31. package/dist/referrer.d.ts +7 -0
  32. package/dist/referrer.d.ts.map +1 -0
  33. package/dist/referrer.js +35 -0
  34. package/dist/refusal.d.ts +5 -7
  35. package/dist/refusal.d.ts.map +1 -1
  36. package/dist/refusal.js +47 -68
  37. package/dist/site.d.ts +1 -1
  38. package/dist/site.d.ts.map +1 -1
  39. package/dist/site.js +242 -155
  40. package/dist/stream.d.ts +18 -6
  41. package/dist/stream.d.ts.map +1 -1
  42. package/dist/stream.js +532 -212
  43. package/dist/transport.d.ts +119 -35
  44. package/dist/transport.d.ts.map +1 -1
  45. package/dist/transport.js +4 -3
  46. package/dist/version.d.ts +3 -0
  47. package/dist/version.d.ts.map +1 -1
  48. package/dist/version.js +32 -18
  49. package/dist/write.d.ts +7 -8
  50. package/dist/write.d.ts.map +1 -1
  51. package/dist/write.js +201 -207
  52. package/package.json +4 -13
  53. package/dist/actions.js.map +0 -1
  54. package/dist/adapter.js.map +0 -1
  55. package/dist/digest.js.map +0 -1
  56. package/dist/discovery.js.map +0 -1
  57. package/dist/index.js.map +0 -1
  58. package/dist/map.js.map +0 -1
  59. package/dist/model.js.map +0 -1
  60. package/dist/read.js.map +0 -1
  61. package/dist/refusal.js.map +0 -1
  62. package/dist/site.js.map +0 -1
  63. package/dist/stream.js.map +0 -1
  64. package/dist/transport.js.map +0 -1
  65. package/dist/version.js.map +0 -1
  66. package/dist/write.js.map +0 -1
package/dist/write.js CHANGED
@@ -1,235 +1,204 @@
1
+ import { departure, } from '@agentshouse/mdruntime';
2
+ import { binaryFileOf, headChange, identities } from './read.js';
1
3
  import { sha256Hex, textBytes } from './digest.js';
2
4
  import { nativePath, roomLocalPath } from './map.js';
3
5
  import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
4
6
  import { readPosition, roomVersion } from './version.js';
5
- export const INLINE_BODY_LIMIT_BYTES = 4 * 1024 * 1024;
6
- export const UPLOAD_LINE_BYTES = 37;
7
- export const UPLOAD_BYTES_MAX = 32 * 1024 * 1024 - UPLOAD_LINE_BYTES;
8
7
  function priorField(batch, path, name) {
9
- return batch.preconditions.find((precondition)=>precondition.kind === 'field' && precondition.path === path && precondition.name === name);
8
+ return batch.preconditions.find((precondition) => precondition.kind === 'field' && precondition.path === path && precondition.name === name);
10
9
  }
11
10
  function priorSection(batch, path, name) {
12
- return batch.preconditions.find((precondition)=>precondition.kind === 'section' && precondition.path === path && precondition.name === name);
11
+ return batch.preconditions.find((precondition) => precondition.kind === 'section' && precondition.path === path && precondition.name === name);
13
12
  }
14
13
  function priorPreamble(batch, path) {
15
- return batch.preconditions.find((precondition)=>precondition.kind === 'preamble' && precondition.path === path);
14
+ return batch.preconditions.find((precondition) => precondition.kind === 'preamble' && precondition.path === path);
16
15
  }
17
16
  function priorAbsence(batch, path) {
18
- return batch.preconditions.find((precondition)=>precondition.kind === 'absent' && precondition.path === path);
17
+ return batch.preconditions.find((precondition) => precondition.kind === 'absent' && precondition.path === path);
19
18
  }
20
19
  function priorExistence(batch, path) {
21
- const precondition = batch.preconditions.find((held)=>held.path === path && (held.kind === 'revision' || held.kind === 'present'));
22
- if (precondition === undefined) return undefined;
23
- return precondition.kind === 'revision' ? {
24
- base: precondition.revision
25
- } : {
26
- kind: 'presence'
27
- };
20
+ const precondition = batch.preconditions.find((held) => held.path === path && (held.kind === 'revision' || held.kind === 'present'));
21
+ if (precondition === undefined)
22
+ return undefined;
23
+ return precondition.kind === 'revision' ? { base: precondition.revision } : { kind: 'presence' };
28
24
  }
29
- function typedCreate(change, path) {
25
+ function created(change, path) {
26
+ if ('content' in change)
27
+ return { op: 'create', path, content: change.content };
30
28
  const { type, ...fields } = change.fields;
31
- if (typeof type !== 'string' || type.length === 0) return null;
32
- return {
33
- op: 'create_typed',
34
- path,
35
- type,
36
- fields,
37
- sections: change.sections
38
- };
29
+ if (typeof type !== 'string' || type.length === 0)
30
+ return null;
31
+ return { op: 'create_typed', path, type, fields, sections: change.sections };
39
32
  }
40
33
  function operationOf(batch, change, handle) {
41
34
  const path = nativePath(change.path, handle);
42
35
  if (change.kind === 'field') {
43
36
  const prior = priorField(batch, change.path, change.name);
44
- if (prior === undefined) return {
45
- rule: 'precondition-missing'
46
- };
37
+ if (prior === undefined)
38
+ return { rule: 'precondition-missing' };
47
39
  return {
48
40
  operation: {
49
41
  op: 'set_field',
50
42
  path,
51
43
  field: change.name,
52
44
  value: change.value,
53
- ...prior.value === undefined ? {} : {
54
- base: prior.value
55
- }
56
- }
45
+ ...(prior.value === undefined ? {} : { base: prior.value }),
46
+ },
57
47
  };
58
48
  }
59
49
  if (change.kind === 'section') {
60
50
  const prior = priorSection(batch, change.path, change.name);
61
- if (prior === undefined) return {
62
- rule: 'precondition-missing'
63
- };
51
+ if (prior === undefined)
52
+ return { rule: 'precondition-missing' };
64
53
  return {
65
54
  operation: {
66
55
  op: 'replace_section',
67
56
  path,
68
57
  section: change.name,
69
58
  base: prior.value,
70
- content: change.value
71
- }
59
+ content: change.value,
60
+ },
72
61
  };
73
62
  }
74
63
  if (change.kind === 'preamble') {
75
64
  const prior = priorPreamble(batch, change.path);
76
- if (prior === undefined) return {
77
- rule: 'precondition-missing'
78
- };
65
+ if (prior === undefined)
66
+ return { rule: 'precondition-missing' };
79
67
  return {
80
- operation: {
81
- op: 'replace_preamble',
82
- path,
83
- base: prior.value,
84
- content: change.value
85
- }
68
+ operation: { op: 'replace_preamble', path, base: prior.value, content: change.value },
86
69
  };
87
70
  }
88
71
  if (change.kind === 'create') {
89
- if (priorAbsence(batch, change.path) === undefined) return {
90
- rule: 'precondition-missing'
91
- };
92
- const created = typedCreate(change, path);
93
- return created === null ? {
94
- rule: 'type-missing'
95
- } : {
96
- operation: created
72
+ if (priorAbsence(batch, change.path) === undefined)
73
+ return { rule: 'precondition-missing' };
74
+ const operation = created(change, path);
75
+ return operation === null ? { rule: 'type-missing' } : { operation };
76
+ }
77
+ if (change.kind === 'binary') {
78
+ const written = {
79
+ op: 'upload',
80
+ path,
81
+ local_id: change.localId,
82
+ bytes: change.byteLength,
83
+ sha256: change.sha256,
84
+ media_type: change.mediaType,
97
85
  };
86
+ const from = departure(batch.changes, batch.changes.indexOf(change));
87
+ if (from === change.path && priorAbsence(batch, change.path) !== undefined)
88
+ return { operation: written };
89
+ const replaced = priorExistence(batch, from);
90
+ if (replaced === undefined)
91
+ return { rule: 'precondition-missing' };
92
+ if (!('base' in replaced))
93
+ return { rule: 'presence-base-unrepresentable' };
94
+ return { operation: { ...written, base: replaced.base } };
98
95
  }
99
96
  const existence = priorExistence(batch, change.path);
100
- if (existence === undefined) return {
101
- rule: 'precondition-missing'
102
- };
103
- if (!('base' in existence)) return {
104
- rule: 'presence-base-unrepresentable'
105
- };
97
+ if (existence === undefined)
98
+ return { rule: 'precondition-missing' };
99
+ if (!('base' in existence))
100
+ return { rule: 'presence-base-unrepresentable' };
106
101
  if (change.kind === 'replace') {
107
- return {
108
- operation: {
109
- op: 'replace',
110
- path,
111
- base: existence.base,
112
- content: change.content
113
- }
114
- };
102
+ return { operation: { op: 'replace', path, base: existence.base, content: change.content } };
115
103
  }
116
104
  if (change.kind === 'move') {
117
- if (priorAbsence(batch, change.to) === undefined) return {
118
- rule: 'precondition-missing'
119
- };
105
+ if (priorAbsence(batch, change.to) === undefined)
106
+ return { rule: 'precondition-missing' };
120
107
  return {
121
- operation: {
122
- op: 'rename',
123
- path,
124
- to: nativePath(change.to, handle),
125
- base: existence.base
126
- }
108
+ operation: { op: 'rename', path, to: nativePath(change.to, handle), base: existence.base },
127
109
  };
128
110
  }
129
- return {
130
- operation: {
131
- op: 'remove',
132
- path,
133
- base: existence.base
134
- }
135
- };
111
+ return { operation: { op: 'remove', path, base: existence.base } };
136
112
  }
137
113
  export function houseChanges(batch, handle) {
138
114
  const changes = [];
139
- for (const change of batch.changes){
115
+ for (const change of batch.changes) {
140
116
  const mapped = operationOf(batch, change, handle);
141
- if ('rule' in mapped) return {
142
- kind: 'unmapped',
143
- path: change.path,
144
- rule: mapped.rule
145
- };
117
+ if ('rule' in mapped)
118
+ return { kind: 'unmapped', path: change.path, rule: mapped.rule };
146
119
  changes.push(mapped.operation);
147
120
  }
148
- return {
149
- kind: 'changes',
150
- changes
151
- };
121
+ return { kind: 'changes', changes };
152
122
  }
153
123
  export function operationHead(batch) {
154
124
  const writer = batch.writtenBy;
155
- return writer === undefined ? {
156
- operation_id: batch.id
157
- } : {
158
- operation_id: batch.id,
159
- app_ref: writer.app,
160
- release: writer.release
161
- };
125
+ return writer === undefined
126
+ ? { operation_id: batch.id }
127
+ : { operation_id: batch.id, app_ref: writer.app, release: writer.release };
162
128
  }
163
129
  export function batchPaths(changes) {
164
130
  return [
165
- ...new Set(changes.flatMap((change)=>change.op === 'rename' ? [
166
- String(change.path),
167
- String(change.to)
168
- ] : [
169
- String(change.path)
170
- ]))
131
+ ...new Set(changes.flatMap((change) => change.op === 'rename' ? [String(change.path), String(change.to)] : [String(change.path)])),
171
132
  ].sort();
172
133
  }
173
134
  export function deltaBody(changes) {
174
- return JSON.stringify({
175
- changes
176
- });
135
+ return JSON.stringify({ changes });
177
136
  }
178
137
  export function deltaBytes(delta) {
179
138
  return textBytes(delta);
180
139
  }
181
- export function uploadable(bytes) {
182
- return bytes > INLINE_BODY_LIMIT_BYTES && bytes <= UPLOAD_BYTES_MAX;
140
+ export function uploadable(inline, bytes, bounds) {
141
+ return (textBytes(JSON.stringify(inline)) > bounds.max_inline_body_bytes &&
142
+ bytes <= bounds.max_upload_bytes);
183
143
  }
184
144
  export function deltaDigest(delta) {
185
145
  return sha256Hex(delta);
186
146
  }
187
147
  function material(value, handle) {
188
- if (!Array.isArray(value)) return null;
148
+ if (!Array.isArray(value))
149
+ return null;
189
150
  const held = [];
190
- for (const entry of value){
191
- if (typeof entry !== 'object' || entry === null) return null;
151
+ for (const entry of value) {
152
+ if (typeof entry !== 'object' || entry === null)
153
+ return null;
192
154
  const file = entry;
193
- if (typeof file.path !== 'string') return null;
194
- if (file.content !== null && typeof file.content !== 'string') return null;
195
- if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string') return null;
155
+ if (typeof file.path !== 'string')
156
+ return null;
157
+ if (file.content !== null && typeof file.content !== 'string')
158
+ return null;
159
+ if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')
160
+ return null;
161
+ const binary = binaryFileOf(file);
162
+ if (binary === null)
163
+ return null;
164
+ const head = headChange(file);
165
+ if (head === null)
166
+ return null;
196
167
  let path;
197
168
  try {
198
169
  path = roomLocalPath(file.path, handle);
199
- } catch {
170
+ }
171
+ catch {
200
172
  return null;
201
173
  }
202
174
  held.push({
203
175
  path,
204
176
  content: file.content,
205
- revision: typeof file.revision === 'string' ? file.revision : null
177
+ revision: typeof file.revision === 'string' ? file.revision : null,
178
+ ...(binary === undefined ? {} : { binary }),
179
+ ...(head === undefined ? {} : { head }),
206
180
  });
207
181
  }
208
182
  return held;
209
183
  }
210
184
  function affectedOf(held) {
211
185
  const affected = {};
212
- for (const entry of held){
213
- if (entry.content !== null) affected[entry.path] = entry.content;
186
+ for (const entry of held) {
187
+ if (entry.content !== null)
188
+ affected[entry.path] = entry.content;
214
189
  }
215
190
  return affected;
216
191
  }
217
192
  export function mutationOutcome(status, body, locator, handle) {
218
193
  const refusal = doorRefusal(body);
219
- if (refusal !== null && refusal.code === 'rate_limited') {
220
- const reset = refusal.fields.retry_at;
221
- return {
222
- kind: 'retryable-refusal',
223
- code: refusal.code,
224
- fields: refusal.fields,
225
- ...typeof reset === 'string' ? {
226
- reset
227
- } : {}
228
- };
194
+ if (refusal !== null && refusal.code === 'service_mode_write_halted') {
195
+ return { kind: 'write-halted' };
196
+ }
197
+ if (refusal !== null && refusal.code === 'expired') {
198
+ return refusal.fields.restored === true
199
+ ? { kind: 'expired', restored: true }
200
+ : { kind: 'expired' };
229
201
  }
230
- if (refusal !== null && refusal.code === 'operation_expired') return {
231
- kind: 'expired'
232
- };
233
202
  if (refusal !== null && refusal.code === 'edit_conflict') {
234
203
  const { current, ...fields } = refusal.fields;
235
204
  const held = material(current, handle) ?? [];
@@ -237,58 +206,76 @@ export function mutationOutcome(status, body, locator, handle) {
237
206
  kind: 'conflicted',
238
207
  affected: affectedOf(held),
239
208
  code: refusal.code,
240
- fields
209
+ fields,
210
+ retryable: refusal.retryable,
241
211
  };
242
212
  }
243
213
  if (refusal !== null && status === 404) {
244
214
  return scopedRefusal(locator, 'undisclosed', refusal);
245
215
  }
246
216
  const classified = classifyDoor(status, body, locator);
247
- if (classified !== null && classified.kind !== 'scoped-refusal') {
248
- return classified.kind === 'beyond-horizon' ? {
249
- kind: 'expired'
250
- } : classified;
217
+ const reset = refusal?.fields.retry_at;
218
+ if (refusal?.retryable === true &&
219
+ typeof reset === 'string' &&
220
+ classified?.kind === 'transport-uncertainty') {
221
+ return {
222
+ kind: 'retryable-refusal',
223
+ code: refusal.code,
224
+ fields: refusal.fields,
225
+ retryable: true,
226
+ reset,
227
+ };
251
228
  }
252
- if (classified !== null && status === 403) return classified;
229
+ if (classified !== null && classified.kind !== 'scoped-refusal')
230
+ return classified;
231
+ if (classified !== null && status === 403)
232
+ return classified;
253
233
  if (refusal !== null && status >= 400) {
254
234
  return {
255
235
  kind: 'rejected',
256
236
  affected: {},
257
237
  code: refusal.code,
258
- fields: refusal.fields
238
+ fields: refusal.fields,
239
+ retryable: refusal.retryable,
259
240
  };
260
241
  }
261
242
  if (status !== 200 || typeof body !== 'object' || body === null) {
262
- return {
263
- kind: 'transport-uncertainty'
264
- };
243
+ return { kind: 'transport-uncertainty' };
265
244
  }
266
245
  const held = body;
267
246
  const at = readPosition(held);
268
- if (at === null) return {
269
- kind: 'transport-uncertainty'
270
- };
247
+ if (at === null)
248
+ return { kind: 'transport-uncertainty' };
271
249
  const contents = material(held.contents, handle);
272
- if (contents === null) return {
273
- kind: 'transport-uncertainty'
274
- };
250
+ if (contents === null)
251
+ return { kind: 'transport-uncertainty' };
275
252
  const documents = {};
276
253
  const revisions = {};
254
+ const changes = {};
255
+ const binaryFiles = {};
277
256
  const removals = [];
278
- for (const entry of contents){
279
- if (entry.content === null || entry.revision === null) {
257
+ for (const entry of contents) {
258
+ if (entry.revision === null) {
280
259
  removals.push(entry.path);
281
260
  continue;
282
261
  }
283
- documents[entry.path] = entry.content;
262
+ if (entry.content !== null)
263
+ documents[entry.path] = entry.content;
264
+ if (entry.binary !== undefined)
265
+ binaryFiles[entry.path] = entry.binary;
284
266
  revisions[entry.path] = entry.revision;
267
+ if (entry.head !== undefined)
268
+ changes[entry.path] = entry.head;
285
269
  }
286
270
  return {
287
271
  kind: 'accepted',
288
272
  roomVersion: roomVersion(at),
289
273
  documents,
290
274
  revisions,
291
- removals: removals.sort()
275
+ ...identities(revisions),
276
+ changes,
277
+ removals: removals.sort(),
278
+ ...(Object.keys(binaryFiles).length === 0 ? {} : { binaryFiles }),
292
279
  };
293
280
  }
294
281
  export function rejectedMapping(mapping) {
@@ -296,94 +283,101 @@ export function rejectedMapping(mapping) {
296
283
  kind: 'rejected',
297
284
  affected: {},
298
285
  code: mapping.rule,
299
- fields: {
300
- path: mapping.path
301
- }
286
+ fields: { path: mapping.path },
287
+ retryable: false,
302
288
  };
303
289
  }
304
290
  export function revisionBody(input) {
305
291
  return {
306
292
  path: nativePath(input.path, input.handle),
307
- ...input.revision === undefined ? {} : {
308
- revision: input.revision
309
- },
310
- ...input.pageToken === undefined ? {} : {
311
- before: Number(input.pageToken)
312
- }
293
+ ...(input.revision === undefined ? {} : { revision: input.revision }),
294
+ ...(input.pageToken === undefined ? {} : { before: Number(input.pageToken) }),
313
295
  };
314
296
  }
297
+ function revisionAuthor(entry) {
298
+ const user = entry.author_user;
299
+ const site = entry.author_site;
300
+ const name = entry.author_site_name;
301
+ if (typeof user === 'string' && site === undefined && name === undefined) {
302
+ return { kind: 'user', id: user };
303
+ }
304
+ if (user === null && typeof site === 'string' && typeof name === 'string') {
305
+ return { kind: 'site', id: site, name };
306
+ }
307
+ return null;
308
+ }
309
+ function historyBinary(entry) {
310
+ if (entry.file === undefined)
311
+ return undefined;
312
+ const { file, bytes, media_type: mediaType, sha256 } = entry;
313
+ if (typeof file !== 'string' ||
314
+ typeof bytes !== 'number' ||
315
+ typeof mediaType !== 'string' ||
316
+ typeof sha256 !== 'string')
317
+ return null;
318
+ return { fileRef: file, byteLength: bytes, mediaType, sha256 };
319
+ }
315
320
  export function historyOutcome(status, body, locator, request) {
316
321
  const classified = classifyDoor(status, body, locator);
317
- if (classified !== null) {
318
- return classified.kind === 'beyond-horizon' ? {
319
- kind: 'transport-uncertainty'
320
- } : classified;
321
- }
322
+ if (classified !== null)
323
+ return classified;
322
324
  if (status !== 200 || typeof body !== 'object' || body === null) {
323
- return {
324
- kind: 'transport-uncertainty'
325
- };
325
+ return { kind: 'transport-uncertainty' };
326
326
  }
327
327
  const held = body;
328
- if (!Array.isArray(held.revisions)) return {
329
- kind: 'transport-uncertainty'
330
- };
328
+ if (!Array.isArray(held.revisions))
329
+ return { kind: 'transport-uncertainty' };
331
330
  const entries = [];
332
- for (const entry of held.revisions){
333
- if (typeof entry !== 'object' || entry === null) return {
334
- kind: 'transport-uncertainty'
335
- };
331
+ for (const entry of held.revisions) {
332
+ if (typeof entry !== 'object' || entry === null)
333
+ return { kind: 'transport-uncertainty' };
336
334
  entries.push(entry);
337
335
  }
338
336
  if (request.revision !== undefined) {
339
337
  const named = entries[0];
340
- if (named === undefined) return {
341
- kind: 'no-history'
342
- };
338
+ if (named === undefined)
339
+ return { kind: 'no-history' };
343
340
  if (named.unavailable === true) {
344
341
  return {
345
342
  kind: 'scoped-refusal',
346
343
  locator,
347
- scope: 'content',
344
+ scope: 'operation',
348
345
  code: 'retained_history_unavailable',
349
- fields: {
350
- path: request.path,
351
- revision: request.revision
352
- }
346
+ fields: { path: request.path, revision: request.revision },
347
+ retryable: false,
353
348
  };
354
349
  }
355
- if (typeof named.content !== 'string') return {
356
- kind: 'transport-uncertainty'
357
- };
358
- return {
359
- kind: 'revision',
360
- content: named.content
361
- };
350
+ if (typeof named.file === 'string')
351
+ return { kind: 'no-history' };
352
+ if (typeof named.content !== 'string')
353
+ return { kind: 'transport-uncertainty' };
354
+ return { kind: 'revision', content: named.content };
362
355
  }
363
- if (entries.length === 0) return {
364
- kind: 'no-history'
365
- };
356
+ if (entries.length === 0)
357
+ return { kind: 'no-history' };
366
358
  const revisions = [];
367
- for (const entry of entries){
368
- if (typeof entry.revision !== 'string' || typeof entry.author_user !== 'string' || typeof entry.created_at !== 'string') {
369
- return {
370
- kind: 'transport-uncertainty'
371
- };
359
+ for (const entry of entries) {
360
+ const author = revisionAuthor(entry);
361
+ if (typeof entry.revision !== 'string' ||
362
+ author === null ||
363
+ typeof entry.created_at !== 'string') {
364
+ return { kind: 'transport-uncertainty' };
372
365
  }
366
+ const binaryFile = historyBinary(entry);
367
+ if (binaryFile === null)
368
+ return { kind: 'transport-uncertainty' };
373
369
  revisions.push({
374
370
  revision: entry.revision,
375
- author: entry.author_user,
376
- time: entry.created_at
371
+ author,
372
+ time: entry.created_at,
373
+ ...(binaryFile === undefined ? {} : { binaryFile }),
377
374
  });
378
375
  }
379
376
  const next = held.next_before;
380
377
  return {
381
378
  kind: 'history',
382
379
  revisions,
383
- ...typeof next === 'number' ? {
384
- pageToken: String(next)
385
- } : {}
380
+ ...(typeof next === 'number' ? { pageToken: String(next) } : {}),
381
+ ...(held.deleted === true ? { deleted: true } : {}),
386
382
  };
387
383
  }
388
-
389
- //# sourceMappingURL=write.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.0-c04b3fdfb64c6",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,26 +14,17 @@
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
  },
21
21
  "files": [
22
22
  "dist",
23
23
  "AGENTS.md",
24
+ "README.md",
24
25
  "LICENSE"
25
26
  ],
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/agentshouse/mdruntime.git",
29
- "directory": "packages/mdruntime-adapter"
30
- },
31
- "homepage": "https://github.com/agentshouse/mdruntime#readme",
32
- "bugs": {
33
- "url": "https://github.com/agentshouse/mdruntime/issues"
34
- },
35
27
  "dependencies": {
36
- "@agentshouse/mdmodel": "0.1.0-alpha.11",
37
- "@agentshouse/mdruntime": "0.1.0-alpha.16"
28
+ "@agentshouse/mdruntime": "0.1.0-c13854b9249b6"
38
29
  }
39
30
  }