@agentshouse/mdruntime-adapter 0.1.0-c6ddfd288ac81 → 0.1.0-cc63dd043d0e2
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/AGENTS.md +27 -22
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +32 -21
- package/dist/discovery.d.ts +11 -17
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +33 -74
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/links.d.ts +1 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +17 -2
- package/dist/read.d.ts +3 -4
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +2 -20
- package/dist/refusal.d.ts +3 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -16
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +9 -7
- package/dist/stream.d.ts +3 -1
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +54 -65
- package/dist/transport.d.ts +5 -13
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +0 -1
- package/dist/write.d.ts +2 -4
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +9 -14
- package/package.json +3 -3
package/dist/read.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BootstrapPage, RefreshResult, RoomAttachment } from '@agentshouse/mdruntime';
|
|
2
|
-
import {
|
|
2
|
+
import type { TrackedAuthority } from './discovery.js';
|
|
3
3
|
import type { HouseMode } from './transport.js';
|
|
4
4
|
import { type LogPosition } from './version.js';
|
|
5
5
|
export type HeadChange = BootstrapPage['changes'][string];
|
|
@@ -66,8 +66,7 @@ export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
|
|
|
66
66
|
export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
|
|
67
67
|
export declare function advancedScope(scope: HouseScope, view: HouseView): HouseScope;
|
|
68
68
|
export declare function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean;
|
|
69
|
-
export declare function
|
|
70
|
-
export declare function bootstrapOf(scope: HouseScope, tracked: TrackedAuthority): BootstrapPage;
|
|
69
|
+
export declare function bootstrapOf(scope: HouseScope): BootstrapPage;
|
|
71
70
|
export type HouseSchema = {
|
|
72
71
|
schema: string | null;
|
|
73
72
|
version: string | null;
|
|
@@ -75,5 +74,5 @@ export type HouseSchema = {
|
|
|
75
74
|
export declare function schemaFrom(envelope: HouseEnvelope, tracked: TrackedAuthority, schema: string): HouseSchema | null;
|
|
76
75
|
export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
|
|
77
76
|
export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
|
|
78
|
-
export declare function refreshFrom(view: HouseView,
|
|
77
|
+
export declare function refreshFrom(view: HouseView, fromRoomVersion: string): RefreshResult;
|
|
79
78
|
//# sourceMappingURL=read.d.ts.map
|
package/dist/read.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACb,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACb,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;A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GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF,wBAAgB,UAAU,CACxB,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,MAAM,GACb,WAAW,GAAG,IAAI,CAIpB;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAK9E;AAED,wBAAgB,MAAM,CACpB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,SAAS,GAAG,SAAS,CAEvB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,aAAa,CA+BnF"}
|
package/dist/read.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PRIVATE_HANDLE, UNTYPED_FOLDERS, PROVIDER_SELECTION_ROOTS, RESERVED_NAMES, } from './discovery.js';
|
|
2
1
|
import { readPosition, roomVersion } from './version.js';
|
|
3
2
|
export function authorityRoot(handle) {
|
|
4
3
|
return `/rooms/${handle}`;
|
|
@@ -256,28 +255,13 @@ export function advancedScope(scope, view) {
|
|
|
256
255
|
export function matchesScope(scope, tracked) {
|
|
257
256
|
return scope.anchor === tracked.authority;
|
|
258
257
|
}
|
|
259
|
-
|
|
260
|
-
function homes(tracked) {
|
|
261
|
-
return tracked.handle === PRIVATE_HANDLE
|
|
262
|
-
? [...ROOM_HOMES, ...PROVIDER_SELECTION_ROOTS]
|
|
263
|
-
: ROOM_HOMES;
|
|
264
|
-
}
|
|
265
|
-
export function selects(tracked, path) {
|
|
266
|
-
if (tracked.schemas.includes(path))
|
|
267
|
-
return false;
|
|
268
|
-
const first = path.split('/', 1)[0].toLowerCase();
|
|
269
|
-
return (!RESERVED_NAMES.some((name) => name.toLowerCase() === first) ||
|
|
270
|
-
homes(tracked).some((home) => path === home || path.startsWith(`${home}/`)));
|
|
271
|
-
}
|
|
272
|
-
export function bootstrapOf(scope, tracked) {
|
|
258
|
+
export function bootstrapOf(scope) {
|
|
273
259
|
const contents = new Map(scope.contents.map((entry) => [entry.path, entry.content]));
|
|
274
260
|
const documents = {};
|
|
275
261
|
const revisions = {};
|
|
276
262
|
const changes = {};
|
|
277
263
|
const binaryTargets = [];
|
|
278
264
|
for (const file of scope.files) {
|
|
279
|
-
if (!selects(tracked, file.path))
|
|
280
|
-
continue;
|
|
281
265
|
if (file.revision !== undefined)
|
|
282
266
|
revisions[file.path] = file.revision;
|
|
283
267
|
if (file.head !== undefined)
|
|
@@ -314,7 +298,7 @@ export function schemaOf(scope, schema) {
|
|
|
314
298
|
export function viewOf(enumeration, tracked) {
|
|
315
299
|
return enumeration.authorities.find((entry) => entry.authority === tracked.authority);
|
|
316
300
|
}
|
|
317
|
-
export function refreshFrom(view,
|
|
301
|
+
export function refreshFrom(view, fromRoomVersion) {
|
|
318
302
|
if (roomVersion(view) === fromRoomVersion)
|
|
319
303
|
return { kind: 'still-current' };
|
|
320
304
|
const documents = {};
|
|
@@ -323,8 +307,6 @@ export function refreshFrom(view, tracked, fromRoomVersion) {
|
|
|
323
307
|
const binaryTargets = [];
|
|
324
308
|
const removals = [];
|
|
325
309
|
for (const change of view.changes) {
|
|
326
|
-
if (!selects(tracked, change.path))
|
|
327
|
-
continue;
|
|
328
310
|
if ('removed' in change) {
|
|
329
311
|
removals.push(change.path);
|
|
330
312
|
continue;
|
package/dist/refusal.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { AdapterFailure, DiscoverResult, ProviderRefusal, ScopedRefusal } from '@agentshouse/mdruntime';
|
|
2
|
-
export type DoorRefusal = ProviderRefusal
|
|
2
|
+
export type DoorRefusal = ProviderRefusal & {
|
|
3
|
+
retryable: boolean;
|
|
4
|
+
};
|
|
3
5
|
export declare function doorRefusal(body: unknown): DoorRefusal | null;
|
|
4
6
|
export declare function scopedRefusal(locator: string, scope: ScopedRefusal['scope'], refusal: DoorRefusal): ScopedRefusal;
|
|
5
7
|
export declare function classifyDoor(status: number, body: unknown, locator: string): AdapterFailure | {
|
package/dist/refusal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnE,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAO7D;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,aAAa,CAEf;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,CAapD;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GACtD,cAAc,CAMhB"}
|
package/dist/refusal.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
const RETRYABLE_CODES = new Set([
|
|
2
|
-
'auth_unavailable',
|
|
3
|
-
'replica_behind',
|
|
4
|
-
'read_replica_unavailable',
|
|
5
|
-
'read_replica_lagging',
|
|
6
|
-
'read_pool_acquisition_timed_out',
|
|
7
|
-
'sync_unavailable',
|
|
8
|
-
'sync_failed',
|
|
9
|
-
'rate_limited',
|
|
10
|
-
'operation_contended',
|
|
11
|
-
'transaction_budget_exceeded',
|
|
12
|
-
]);
|
|
13
1
|
export function doorRefusal(body) {
|
|
14
2
|
if (typeof body !== 'object' || body === null)
|
|
15
3
|
return null;
|
|
@@ -19,7 +7,7 @@ export function doorRefusal(body) {
|
|
|
19
7
|
if (typeof error.code !== 'string')
|
|
20
8
|
return null;
|
|
21
9
|
const { code, ...fields } = error;
|
|
22
|
-
return { code, fields };
|
|
10
|
+
return { code, fields, retryable: error.retryable === true };
|
|
23
11
|
}
|
|
24
12
|
export function scopedRefusal(locator, scope, refusal) {
|
|
25
13
|
return { kind: 'scoped-refusal', locator, scope, code: refusal.code, fields: refusal.fields };
|
|
@@ -30,15 +18,13 @@ export function classifyDoor(status, body, locator) {
|
|
|
30
18
|
const refusal = doorRefusal(body);
|
|
31
19
|
if (status === 401)
|
|
32
20
|
return { kind: 'revoked-authorization' };
|
|
33
|
-
if (refusal
|
|
21
|
+
if (refusal?.retryable === true)
|
|
34
22
|
return { kind: 'transport-uncertainty' };
|
|
35
23
|
if (refusal !== null && refusal.code === 'position_expired')
|
|
36
24
|
return { kind: 'beyond-horizon' };
|
|
37
25
|
if (status === 404 || refusal?.code === 'room_not_found') {
|
|
38
26
|
return { kind: 'room-not-readable', locator };
|
|
39
27
|
}
|
|
40
|
-
if (status >= 500)
|
|
41
|
-
return { kind: 'transport-uncertainty' };
|
|
42
28
|
if (status < 400)
|
|
43
29
|
return null;
|
|
44
30
|
if (refusal === null)
|
package/dist/site.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAQR,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAQR,MAAM,wBAAwB,CAAC;AA+BhC,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAsCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAuKxE"}
|
package/dist/site.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { actionOutcome } from './actions.js';
|
|
2
|
-
import {
|
|
2
|
+
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
3
3
|
import { MODEL_ABSENT, failedModel, heldModel, modelKey, modelShelf, } from './model.js';
|
|
4
4
|
import { advancedScope, bootstrapOf, parseEnumeration, parseSiteBootstrap, refreshFrom, schemaOf, schemaPath, viewOf, } from './read.js';
|
|
5
5
|
import { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';
|
|
@@ -15,7 +15,6 @@ function siteRoom(tracked, attachedModel) {
|
|
|
15
15
|
operations: { read: [''], sync: [''], write: [], delete: [] },
|
|
16
16
|
replica: { selection: tracked.locator, admission: 'admitted' },
|
|
17
17
|
attachedModel,
|
|
18
|
-
untypedFolders: [...UNTYPED_FOLDERS],
|
|
19
18
|
providerOwnedPaths: [],
|
|
20
19
|
};
|
|
21
20
|
}
|
|
@@ -35,8 +34,9 @@ export function createSiteAdapter(transport) {
|
|
|
35
34
|
positions: [presented(entry.authority, from)],
|
|
36
35
|
});
|
|
37
36
|
const behind = doorRefusal(answer.body);
|
|
38
|
-
if (behind?.code === 'replica_behind')
|
|
39
|
-
return { kind: 'retryable-refusal',
|
|
37
|
+
if (behind?.code === 'replica_behind' && behind.retryable) {
|
|
38
|
+
return { kind: 'retryable-refusal', code: behind.code, fields: behind.fields };
|
|
39
|
+
}
|
|
40
40
|
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
41
41
|
if (classified !== null)
|
|
42
42
|
return classified;
|
|
@@ -73,7 +73,8 @@ export function createSiteAdapter(transport) {
|
|
|
73
73
|
const view = viewOf(found, entry);
|
|
74
74
|
if (view === undefined)
|
|
75
75
|
return { kind: 'room-not-readable', locator: entry.locator };
|
|
76
|
-
|
|
76
|
+
notifications.hold(entry.authority, view);
|
|
77
|
+
return refreshFrom(view, fromRoomVersion);
|
|
77
78
|
}
|
|
78
79
|
async function acquire(entry, held) {
|
|
79
80
|
if ('failure' in held)
|
|
@@ -125,7 +126,7 @@ export function createSiteAdapter(transport) {
|
|
|
125
126
|
return siteRoom(entry, shelved?.identity ?? null);
|
|
126
127
|
});
|
|
127
128
|
models.keep(entries.map((entry) => entry.locator));
|
|
128
|
-
return
|
|
129
|
+
return mapDiscovery(document, rooms, siteCapabilities());
|
|
129
130
|
},
|
|
130
131
|
async bootstrap(_authorization, request) {
|
|
131
132
|
const entry = tracked.get(request.locator);
|
|
@@ -136,7 +137,8 @@ export function createSiteAdapter(transport) {
|
|
|
136
137
|
const held = caught.get(entry.authority) ?? (await caughtUp(entry));
|
|
137
138
|
if ('failure' in held)
|
|
138
139
|
return held.failure;
|
|
139
|
-
|
|
140
|
+
notifications.hold(entry.authority, held.scope);
|
|
141
|
+
return bootstrapOf(held.scope);
|
|
140
142
|
},
|
|
141
143
|
async refresh(_authorization, request) {
|
|
142
144
|
const entry = tracked.get(request.locator);
|
package/dist/stream.d.ts
CHANGED
|
@@ -2,13 +2,15 @@ import type { ConversationStream, RefreshPage, SelectedRooms, ServiceModeSignal
|
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
3
|
import type { HouseDoor, HouseMode, HouseStreamEntry } from './transport.js';
|
|
4
4
|
import { type LogPosition } from './version.js';
|
|
5
|
+
export type HeldRevision = (path: string, revision: string) => boolean;
|
|
5
6
|
export type StreamedAdvancement = {
|
|
6
7
|
page: RefreshPage;
|
|
7
8
|
entries: readonly HouseStreamEntry[];
|
|
8
9
|
};
|
|
9
10
|
export type HouseNotifications = SelectedRooms & {
|
|
10
11
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
11
|
-
|
|
12
|
+
hold(authority: string, at: LogPosition): void;
|
|
13
|
+
advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): StreamedAdvancement | null;
|
|
12
14
|
conversations: ConversationStream;
|
|
13
15
|
serviceMode: ServiceModeSignal;
|
|
14
16
|
};
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EAEX,aAAa,EAEb,iBAAiB,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EAEX,aAAa,EAEb,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAoB,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAgB7D,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAEvE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/C,OAAO,CACL,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,EACjB,KAAK,CAAC,EAAE,YAAY,GACnB,mBAAmB,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAYF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CA2P5F"}
|
package/dist/stream.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { acceptedMessage } from './actions.js';
|
|
2
|
-
import { headChange
|
|
2
|
+
import { headChange } from './read.js';
|
|
3
3
|
import { roomVersion } from './version.js';
|
|
4
|
-
const
|
|
4
|
+
const HELD_FRAMES_MAX = 256;
|
|
5
|
+
function turnOperation(frame) {
|
|
6
|
+
const { type: _type, conversation_id: _conversation, turn_id: _turn, ...operation } = frame;
|
|
7
|
+
return structuredClone(operation);
|
|
8
|
+
}
|
|
5
9
|
function position(value) {
|
|
6
10
|
if (!/^(?:0|[1-9][0-9]*)$/.test(value))
|
|
7
11
|
return null;
|
|
@@ -17,7 +21,6 @@ export function houseNotifications(transport, mode) {
|
|
|
17
21
|
const modeObservers = new Set();
|
|
18
22
|
let replicated = [];
|
|
19
23
|
const live = new Set();
|
|
20
|
-
const noted = new Set();
|
|
21
24
|
let listening = false;
|
|
22
25
|
let catching = false;
|
|
23
26
|
function listen() {
|
|
@@ -32,42 +35,20 @@ export function houseNotifications(transport, mode) {
|
|
|
32
35
|
for (const observer of conversationObservers)
|
|
33
36
|
observer(event);
|
|
34
37
|
}
|
|
35
|
-
function unnote(conversation) {
|
|
36
|
-
if (!noted.delete(conversation))
|
|
37
|
-
return;
|
|
38
|
-
emitConversation({ kind: 'working-note', conversation, note: null });
|
|
39
|
-
}
|
|
40
38
|
function reopened() {
|
|
41
39
|
const gapped = new Set([...replicated, ...live]);
|
|
42
40
|
live.clear();
|
|
43
|
-
noted.clear();
|
|
44
41
|
for (const conversation of gapped)
|
|
45
42
|
emitConversation({ kind: 'gap', conversation });
|
|
46
43
|
}
|
|
47
44
|
function converse(frame) {
|
|
48
45
|
const conversation = frame.conversation_id;
|
|
49
|
-
if (frame.type === '
|
|
50
|
-
unnote(conversation);
|
|
46
|
+
if (frame.type === 'turn') {
|
|
51
47
|
emitConversation({
|
|
52
|
-
kind: '
|
|
48
|
+
kind: 'turn',
|
|
53
49
|
conversation,
|
|
54
50
|
turn: frame.turn_id,
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
emitConversation({
|
|
58
|
-
kind: 'plan',
|
|
59
|
-
conversation,
|
|
60
|
-
turn: frame.turn_id,
|
|
61
|
-
plan: structuredClone(frame.steps),
|
|
62
|
-
});
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (frame.type === 'working-note') {
|
|
66
|
-
noted.add(conversation);
|
|
67
|
-
emitConversation({
|
|
68
|
-
kind: 'working-note',
|
|
69
|
-
conversation,
|
|
70
|
-
note: { noteId: frame.note_id, text: frame.text },
|
|
51
|
+
operation: turnOperation(frame),
|
|
71
52
|
});
|
|
72
53
|
return;
|
|
73
54
|
}
|
|
@@ -77,7 +58,6 @@ export function houseNotifications(transport, mode) {
|
|
|
77
58
|
return;
|
|
78
59
|
emitConversation({ kind: 'commands', conversation, commands: [] });
|
|
79
60
|
emitConversation({ kind: 'options', conversation, options: [] });
|
|
80
|
-
unnote(conversation);
|
|
81
61
|
return;
|
|
82
62
|
}
|
|
83
63
|
if (frame.type === 'commands') {
|
|
@@ -104,9 +84,6 @@ export function houseNotifications(transport, mode) {
|
|
|
104
84
|
if (message === null)
|
|
105
85
|
return;
|
|
106
86
|
emitConversation({ kind: 'accepted-message', conversation, message });
|
|
107
|
-
if (frame.message.role === 'user')
|
|
108
|
-
return;
|
|
109
|
-
unnote(conversation);
|
|
110
87
|
}
|
|
111
88
|
function announce(authority, at, modelChanged) {
|
|
112
89
|
const version = roomVersion(at);
|
|
@@ -121,7 +98,7 @@ export function houseNotifications(transport, mode) {
|
|
|
121
98
|
function interrupt(authority) {
|
|
122
99
|
const line = lines.get(authority);
|
|
123
100
|
if (line !== undefined)
|
|
124
|
-
lines.set(authority, {
|
|
101
|
+
lines.set(authority, { ...line, frames: [] });
|
|
125
102
|
}
|
|
126
103
|
function receive(frame) {
|
|
127
104
|
if (frame.type === 'signal') {
|
|
@@ -132,8 +109,7 @@ export function houseNotifications(transport, mode) {
|
|
|
132
109
|
observer(mode);
|
|
133
110
|
return;
|
|
134
111
|
}
|
|
135
|
-
if (frame.type === '
|
|
136
|
-
frame.type === 'working-note' ||
|
|
112
|
+
if (frame.type === 'turn' ||
|
|
137
113
|
frame.type === 'process' ||
|
|
138
114
|
frame.type === 'commands' ||
|
|
139
115
|
frame.type === 'options' ||
|
|
@@ -145,21 +121,21 @@ export function houseNotifications(transport, mode) {
|
|
|
145
121
|
if (frame.type !== 'entries')
|
|
146
122
|
return;
|
|
147
123
|
const at = position(frame.position);
|
|
148
|
-
|
|
124
|
+
const after = position(frame.after);
|
|
125
|
+
if (at === null || after === null || after >= at) {
|
|
149
126
|
interrupt(frame.authority);
|
|
150
127
|
return;
|
|
151
128
|
}
|
|
152
129
|
const line = lines.get(frame.authority);
|
|
153
130
|
if (line?.logEpoch === frame.log_epoch) {
|
|
131
|
+
if (line.held !== null && at <= line.held)
|
|
132
|
+
return;
|
|
154
133
|
const last = line.frames.at(-1);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
lines.set(frame.authority, {
|
|
160
|
-
logEpoch: line.logEpoch,
|
|
161
|
-
frames: next.length > HELD_POSITIONS_MAX ? [] : next,
|
|
162
|
-
});
|
|
134
|
+
if (last !== undefined && at <= last.position)
|
|
135
|
+
return;
|
|
136
|
+
const held = { after, position: at, entries: frame.entries };
|
|
137
|
+
const next = last !== undefined && after <= last.position ? [...line.frames, held] : [held];
|
|
138
|
+
lines.set(frame.authority, { ...line, frames: next.length > HELD_FRAMES_MAX ? [] : next });
|
|
163
139
|
}
|
|
164
140
|
else {
|
|
165
141
|
interrupt(frame.authority);
|
|
@@ -200,7 +176,7 @@ export function houseNotifications(transport, mode) {
|
|
|
200
176
|
locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);
|
|
201
177
|
schemas.set(entry.authority, entry.schemas);
|
|
202
178
|
if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {
|
|
203
|
-
lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [] });
|
|
179
|
+
lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [], held: null });
|
|
204
180
|
}
|
|
205
181
|
}
|
|
206
182
|
for (const authority of lines.keys()) {
|
|
@@ -216,29 +192,48 @@ export function houseNotifications(transport, mode) {
|
|
|
216
192
|
observers.delete(notify);
|
|
217
193
|
};
|
|
218
194
|
},
|
|
219
|
-
|
|
195
|
+
hold(authority, at) {
|
|
196
|
+
const line = lines.get(authority);
|
|
197
|
+
const held = position(at.position);
|
|
198
|
+
if (line === undefined || held === null || line.logEpoch !== at.logEpoch)
|
|
199
|
+
return;
|
|
200
|
+
lines.set(authority, { ...line, held });
|
|
201
|
+
},
|
|
202
|
+
advance(tracked, from, holds) {
|
|
220
203
|
const line = lines.get(tracked.authority);
|
|
221
204
|
const start = position(from.position);
|
|
222
205
|
if (line === undefined || start === null || line.logEpoch !== from.logEpoch)
|
|
223
206
|
return null;
|
|
224
|
-
const
|
|
225
|
-
|
|
207
|
+
const pending = line.frames.filter((frame) => frame.position > start);
|
|
208
|
+
const first = pending[0];
|
|
209
|
+
if (first === undefined || first.after > start)
|
|
226
210
|
return null;
|
|
227
|
-
const pending = line.frames.slice(at);
|
|
228
211
|
const documents = {};
|
|
229
212
|
const revisions = {};
|
|
230
213
|
const changes = {};
|
|
231
214
|
const removals = [];
|
|
215
|
+
const applied = [];
|
|
216
|
+
const forget = (path) => {
|
|
217
|
+
delete documents[path];
|
|
218
|
+
delete revisions[path];
|
|
219
|
+
delete changes[path];
|
|
220
|
+
const removed = removals.indexOf(path);
|
|
221
|
+
if (removed !== -1)
|
|
222
|
+
removals.splice(removed, 1);
|
|
223
|
+
};
|
|
232
224
|
for (const frame of pending) {
|
|
233
225
|
for (const entry of frame.entries) {
|
|
234
|
-
if (
|
|
226
|
+
if (entry.kind === 'edited' &&
|
|
227
|
+
entry.text === undefined &&
|
|
228
|
+
entry.revision !== undefined &&
|
|
229
|
+
holds?.(entry.path, entry.revision) === true) {
|
|
230
|
+
forget(entry.path);
|
|
235
231
|
continue;
|
|
232
|
+
}
|
|
233
|
+
applied.push(entry);
|
|
236
234
|
if (entry.kind === 'removed') {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
delete changes[entry.path];
|
|
240
|
-
if (!removals.includes(entry.path))
|
|
241
|
-
removals.push(entry.path);
|
|
235
|
+
forget(entry.path);
|
|
236
|
+
removals.push(entry.path);
|
|
242
237
|
continue;
|
|
243
238
|
}
|
|
244
239
|
if (entry.text === undefined)
|
|
@@ -248,22 +243,16 @@ export function houseNotifications(transport, mode) {
|
|
|
248
243
|
const head = headChange(entry);
|
|
249
244
|
if (head === null)
|
|
250
245
|
return null;
|
|
246
|
+
forget(entry.path);
|
|
251
247
|
documents[entry.path] = entry.text;
|
|
252
248
|
if (entry.revision !== undefined)
|
|
253
249
|
revisions[entry.path] = entry.revision;
|
|
254
|
-
if (head
|
|
255
|
-
delete changes[entry.path];
|
|
256
|
-
else
|
|
250
|
+
if (head !== undefined)
|
|
257
251
|
changes[entry.path] = head;
|
|
258
|
-
const removed = removals.indexOf(entry.path);
|
|
259
|
-
if (removed !== -1)
|
|
260
|
-
removals.splice(removed, 1);
|
|
261
252
|
}
|
|
262
253
|
}
|
|
263
254
|
const last = pending.at(-1);
|
|
264
|
-
|
|
265
|
-
return null;
|
|
266
|
-
lines.set(tracked.authority, { logEpoch: line.logEpoch, frames: pending });
|
|
255
|
+
lines.set(tracked.authority, { ...line, frames: pending, held: last.position });
|
|
267
256
|
return {
|
|
268
257
|
page: {
|
|
269
258
|
kind: 'net-advancement',
|
|
@@ -274,7 +263,7 @@ export function houseNotifications(transport, mode) {
|
|
|
274
263
|
binaryTargets: [],
|
|
275
264
|
removals: removals.sort(),
|
|
276
265
|
},
|
|
277
|
-
entries:
|
|
266
|
+
entries: applied,
|
|
278
267
|
};
|
|
279
268
|
},
|
|
280
269
|
};
|
package/dist/transport.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConversationEvent } from '@agentshouse/mdruntime';
|
|
1
|
+
import type { ConversationEvent, TurnOperation } from '@agentshouse/mdruntime';
|
|
2
2
|
export declare const DOOR_DISCOVER = "/door/discover";
|
|
3
3
|
export declare const DOOR_BOOTSTRAP = "/door/bootstrap";
|
|
4
4
|
export declare const DOOR_ENUMERATE = "/door/enumerate";
|
|
@@ -10,7 +10,6 @@ export declare const SITE_DOOR_BOOTSTRAP = "/_house/door/bootstrap/";
|
|
|
10
10
|
export declare const SITE_DOOR_ENUMERATE = "/_house/door/enumerate";
|
|
11
11
|
export declare const SITE_DOOR_SUBMIT = "/_house/door/submit";
|
|
12
12
|
export declare const PRIVATE_LOCATOR = "private";
|
|
13
|
-
export declare const DOOR_SELECTION_MAX = 256;
|
|
14
13
|
export type HouseMode = 'credential' | 'site';
|
|
15
14
|
export type HouseDoorAnswer = {
|
|
16
15
|
status: number;
|
|
@@ -47,17 +46,15 @@ type LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent,
|
|
|
47
46
|
export type HouseStreamFrame = {
|
|
48
47
|
type: 'entries';
|
|
49
48
|
authority: string;
|
|
49
|
+
after: string;
|
|
50
50
|
position: string;
|
|
51
51
|
log_epoch: string;
|
|
52
52
|
entries: readonly HouseStreamEntry[];
|
|
53
|
-
} | {
|
|
54
|
-
type: '
|
|
53
|
+
} | ({
|
|
54
|
+
type: 'turn';
|
|
55
55
|
conversation_id: string;
|
|
56
56
|
turn_id: string;
|
|
57
|
-
|
|
58
|
-
blocks: readonly unknown[];
|
|
59
|
-
steps: LiveFact<'plan'>['plan'];
|
|
60
|
-
} | {
|
|
57
|
+
} & TurnOperation) | {
|
|
61
58
|
type: 'message';
|
|
62
59
|
conversation_id: string;
|
|
63
60
|
message: unknown;
|
|
@@ -65,11 +62,6 @@ export type HouseStreamFrame = {
|
|
|
65
62
|
type: 'interactions';
|
|
66
63
|
conversation_id: string;
|
|
67
64
|
interactions: readonly unknown[];
|
|
68
|
-
} | {
|
|
69
|
-
type: 'working-note';
|
|
70
|
-
conversation_id: string;
|
|
71
|
-
note_id: string;
|
|
72
|
-
text: string;
|
|
73
65
|
} | {
|
|
74
66
|
type: 'process';
|
|
75
67
|
conversation_id: string;
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE/E,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC,MAAM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,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG;IACvC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/C,CAAC"}
|
package/dist/transport.js
CHANGED
package/dist/write.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { ChangeBatch, HistoryResult, MutationResult } from '@agentshouse/mdruntime';
|
|
2
|
-
|
|
3
|
-
export declare const UPLOAD_LINE_BYTES = 37;
|
|
4
|
-
export declare const UPLOAD_BYTES_MAX: number;
|
|
2
|
+
import type { HouseBounds } from './discovery.js';
|
|
5
3
|
export type HouseOperation = Readonly<Record<string, unknown>>;
|
|
6
4
|
export type ChangeMapping = {
|
|
7
5
|
kind: 'changes';
|
|
@@ -21,7 +19,7 @@ export declare function operationHead(batch: ChangeBatch): OperationHead;
|
|
|
21
19
|
export declare function batchPaths(changes: readonly HouseOperation[]): readonly string[];
|
|
22
20
|
export declare function deltaBody(changes: readonly HouseOperation[]): string;
|
|
23
21
|
export declare function deltaBytes(delta: string): number;
|
|
24
|
-
export declare function uploadable(bytes: number): boolean;
|
|
22
|
+
export declare function uploadable(inline: Readonly<Record<string, unknown>>, bytes: number, bounds: Pick<HouseBounds, 'max_inline_body_bytes' | 'max_upload_bytes'>): boolean;
|
|
25
23
|
export declare function deltaDigest(delta: string): Promise<string>;
|
|
26
24
|
export declare function mutationOutcome(status: number, body: unknown, locator: string, handle: string): MutationResult;
|
|
27
25
|
export declare function rejectedMapping(mapping: Extract<ChangeMapping, {
|
package/dist/write.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EAEX,aAAa,EAEb,cAAc,EAEf,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EAEX,aAAa,EAEb,cAAc,EAEf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMlD,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;AAuGrD,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAQ9E;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CAK/D;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,MAAM,EAAE,CAQhF;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAEpE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,UAAU,CACxB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,uBAAuB,GAAG,kBAAkB,CAAC,GACtE,OAAO,CAKT;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE1D;AAqCD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,cAAc,CAwDhB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;IAEjF,IAAI,EAAE,UAAU;IAChB,QAAQ;IACR,IAAI;IACJ,MAAM;QAAI,IAAI;;EAEjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1B;AAeD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,aAAa,CAiDf"}
|
package/dist/write.js
CHANGED
|
@@ -2,9 +2,6 @@ import { sha256Hex, textBytes } from './digest.js';
|
|
|
2
2
|
import { nativePath, roomLocalPath } from './map.js';
|
|
3
3
|
import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
|
|
4
4
|
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
5
|
function priorField(batch, path, name) {
|
|
9
6
|
return batch.preconditions.find((precondition) => precondition.kind === 'field' && precondition.path === path && precondition.name === name);
|
|
10
7
|
}
|
|
@@ -119,8 +116,9 @@ export function deltaBody(changes) {
|
|
|
119
116
|
export function deltaBytes(delta) {
|
|
120
117
|
return textBytes(delta);
|
|
121
118
|
}
|
|
122
|
-
export function uploadable(bytes) {
|
|
123
|
-
return
|
|
119
|
+
export function uploadable(inline, bytes, bounds) {
|
|
120
|
+
return (textBytes(JSON.stringify(inline)) > bounds.max_inline_body_bytes &&
|
|
121
|
+
bytes <= bounds.max_upload_bytes);
|
|
124
122
|
}
|
|
125
123
|
export function deltaDigest(delta) {
|
|
126
124
|
return sha256Hex(delta);
|
|
@@ -167,15 +165,6 @@ export function mutationOutcome(status, body, locator, handle) {
|
|
|
167
165
|
if (refusal !== null && refusal.code === 'service_mode_write_halted') {
|
|
168
166
|
return { kind: 'write-halted' };
|
|
169
167
|
}
|
|
170
|
-
if (refusal !== null && refusal.code === 'rate_limited') {
|
|
171
|
-
const reset = refusal.fields.retry_at;
|
|
172
|
-
return {
|
|
173
|
-
kind: 'retryable-refusal',
|
|
174
|
-
code: refusal.code,
|
|
175
|
-
fields: refusal.fields,
|
|
176
|
-
...(typeof reset === 'string' ? { reset } : {}),
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
168
|
if (refusal !== null && refusal.code === 'operation_expired')
|
|
180
169
|
return { kind: 'expired' };
|
|
181
170
|
if (refusal !== null && refusal.code === 'edit_conflict') {
|
|
@@ -187,6 +176,12 @@ export function mutationOutcome(status, body, locator, handle) {
|
|
|
187
176
|
return scopedRefusal(locator, 'undisclosed', refusal);
|
|
188
177
|
}
|
|
189
178
|
const classified = classifyDoor(status, body, locator);
|
|
179
|
+
const reset = refusal?.fields.retry_at;
|
|
180
|
+
if (refusal?.retryable === true &&
|
|
181
|
+
typeof reset === 'string' &&
|
|
182
|
+
classified?.kind === 'transport-uncertainty') {
|
|
183
|
+
return { kind: 'retryable-refusal', code: refusal.code, fields: refusal.fields, reset };
|
|
184
|
+
}
|
|
190
185
|
if (classified !== null && classified.kind !== 'scoped-refusal') {
|
|
191
186
|
return classified.kind === 'beyond-horizon' ? { kind: 'expired' } : classified;
|
|
192
187
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime-adapter",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-cc63dd043d0e2",
|
|
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-
|
|
29
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
28
|
+
"@agentshouse/mdmodel": "0.1.0-c6b0c6dc1a195",
|
|
29
|
+
"@agentshouse/mdruntime": "0.1.0-cc7bd7a53214e"
|
|
30
30
|
}
|
|
31
31
|
}
|