@agentshouse/mdruntime-adapter 0.1.0-c38cdd8a6d962 → 0.1.0-c3bd45bca89d3

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/write.js CHANGED
@@ -1,4 +1,4 @@
1
- import { parseOriginals } from './read.js';
1
+ import { headChange, parseOriginals } from './read.js';
2
2
  import { sha256Hex, textBytes } from './digest.js';
3
3
  import { nativePath, roomLocalPath } from './map.js';
4
4
  import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
@@ -138,6 +138,9 @@ function material(value, handle) {
138
138
  return null;
139
139
  if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')
140
140
  return null;
141
+ const head = headChange(file);
142
+ if (head === null)
143
+ return null;
141
144
  let path;
142
145
  try {
143
146
  path = roomLocalPath(file.path, handle);
@@ -149,6 +152,7 @@ function material(value, handle) {
149
152
  path,
150
153
  content: file.content,
151
154
  revision: typeof file.revision === 'string' ? file.revision : null,
155
+ ...(head === undefined ? {} : { head }),
152
156
  });
153
157
  }
154
158
  return held;
@@ -171,7 +175,13 @@ export function mutationOutcome(status, body, locator, handle) {
171
175
  if (refusal !== null && refusal.code === 'edit_conflict') {
172
176
  const { current, ...fields } = refusal.fields;
173
177
  const held = material(current, handle) ?? [];
174
- return { kind: 'conflicted', affected: affectedOf(held), code: refusal.code, fields };
178
+ return {
179
+ kind: 'conflicted',
180
+ affected: affectedOf(held),
181
+ code: refusal.code,
182
+ fields,
183
+ retryable: refusal.retryable,
184
+ };
175
185
  }
176
186
  if (refusal !== null && status === 404) {
177
187
  return scopedRefusal(locator, 'undisclosed', refusal);
@@ -181,14 +191,26 @@ export function mutationOutcome(status, body, locator, handle) {
181
191
  if (refusal?.retryable === true &&
182
192
  typeof reset === 'string' &&
183
193
  classified?.kind === 'transport-uncertainty') {
184
- return { kind: 'retryable-refusal', code: refusal.code, fields: refusal.fields, reset };
194
+ return {
195
+ kind: 'retryable-refusal',
196
+ code: refusal.code,
197
+ fields: refusal.fields,
198
+ retryable: true,
199
+ reset,
200
+ };
185
201
  }
186
202
  if (classified !== null && classified.kind !== 'scoped-refusal')
187
203
  return classified;
188
204
  if (classified !== null && status === 403)
189
205
  return classified;
190
206
  if (refusal !== null && status >= 400) {
191
- return { kind: 'rejected', affected: {}, code: refusal.code, fields: refusal.fields };
207
+ return {
208
+ kind: 'rejected',
209
+ affected: {},
210
+ code: refusal.code,
211
+ fields: refusal.fields,
212
+ retryable: refusal.retryable,
213
+ };
192
214
  }
193
215
  if (status !== 200 || typeof body !== 'object' || body === null) {
194
216
  return { kind: 'transport-uncertainty' };
@@ -205,6 +227,7 @@ export function mutationOutcome(status, body, locator, handle) {
205
227
  return { kind: 'transport-uncertainty' };
206
228
  const documents = {};
207
229
  const revisions = {};
230
+ const changes = {};
208
231
  const removals = [];
209
232
  for (const entry of contents) {
210
233
  if (entry.content === null || entry.revision === null) {
@@ -213,12 +236,15 @@ export function mutationOutcome(status, body, locator, handle) {
213
236
  }
214
237
  documents[entry.path] = entry.content;
215
238
  revisions[entry.path] = entry.revision;
239
+ if (entry.head !== undefined)
240
+ changes[entry.path] = entry.head;
216
241
  }
217
242
  return {
218
243
  kind: 'accepted',
219
244
  roomVersion: roomVersion(at),
220
245
  documents,
221
246
  revisions,
247
+ changes,
222
248
  removals: removals.sort(),
223
249
  originals,
224
250
  };
@@ -229,6 +255,7 @@ export function rejectedMapping(mapping) {
229
255
  affected: {},
230
256
  code: mapping.rule,
231
257
  fields: { path: mapping.path },
258
+ retryable: false,
232
259
  };
233
260
  }
234
261
  export function revisionBody(input) {
@@ -277,6 +304,7 @@ export function historyOutcome(status, body, locator, request) {
277
304
  scope: 'content',
278
305
  code: 'retained_history_unavailable',
279
306
  fields: { path: request.path, revision: request.revision },
307
+ retryable: false,
280
308
  };
281
309
  }
282
310
  if (typeof named.content !== 'string')
@@ -300,5 +328,6 @@ export function historyOutcome(status, body, locator, request) {
300
328
  kind: 'history',
301
329
  revisions,
302
330
  ...(typeof next === 'number' ? { pageToken: String(next) } : {}),
331
+ ...(held.deleted === true ? { deleted: true } : {}),
303
332
  };
304
333
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-c38cdd8a6d962",
3
+ "version": "0.1.0-c3bd45bca89d3",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "LICENSE"
26
26
  ],
27
27
  "dependencies": {
28
- "@agentshouse/mdmodel": "0.1.0-c0bdbbc92d020",
29
- "@agentshouse/mdruntime": "0.1.0-c2647c1a232dd"
28
+ "@agentshouse/mdmodel": "0.1.0-c4fe1bc82bc55",
29
+ "@agentshouse/mdruntime": "0.1.0-c99e5271060cd"
30
30
  }
31
31
  }