@agentshouse/mdruntime-adapter 0.1.0-c17fae3d012d0 → 0.1.0-c26cd225263b7
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 +8 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +64 -98
- package/dist/discovery.d.ts +2 -2
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +5 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/links.d.ts +9 -1
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +40 -2
- package/dist/model.d.ts +7 -18
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +48 -41
- package/dist/read.d.ts +1 -1
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +5 -8
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +38 -72
- package/dist/stream.d.ts +7 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +59 -36
- package/dist/transport.d.ts +14 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +9 -0
- package/dist/write.d.ts +9 -2
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +5 -0
- package/package.json +3 -3
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,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,aA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SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,aAAa,CA+BnF"}
|
package/dist/read.js
CHANGED
|
@@ -3,7 +3,10 @@ export function authorityRoot(handle) {
|
|
|
3
3
|
return `/rooms/${handle}`;
|
|
4
4
|
}
|
|
5
5
|
export function contentPrefixes(tracked) {
|
|
6
|
-
return [
|
|
6
|
+
return [
|
|
7
|
+
authorityRoot(tracked.handle),
|
|
8
|
+
...tracked.schemas.map((schema) => schemaPath(tracked.handle, schema)),
|
|
9
|
+
];
|
|
7
10
|
}
|
|
8
11
|
export function schemaPath(handle, schema) {
|
|
9
12
|
return `${authorityRoot(handle)}/${schema}`;
|
|
@@ -60,7 +63,7 @@ function parseOriginal(value) {
|
|
|
60
63
|
return null;
|
|
61
64
|
return { reference: attachment, name, byteLength: bytes, mediaType, entry: value };
|
|
62
65
|
}
|
|
63
|
-
function parseOriginals(value) {
|
|
66
|
+
export function parseOriginals(value) {
|
|
64
67
|
if (!Array.isArray(value))
|
|
65
68
|
return null;
|
|
66
69
|
const attachments = [];
|
|
@@ -282,12 +285,6 @@ export function bootstrapOf(scope) {
|
|
|
282
285
|
...declared(scope.attachments),
|
|
283
286
|
};
|
|
284
287
|
}
|
|
285
|
-
export function schemaFrom(envelope, tracked, schema) {
|
|
286
|
-
const scope = envelope.scopes.find((entry) => matchesScope(entry, tracked));
|
|
287
|
-
if (scope === undefined)
|
|
288
|
-
return null;
|
|
289
|
-
return schemaOf(scope, schema);
|
|
290
|
-
}
|
|
291
288
|
export function schemaOf(scope, schema) {
|
|
292
289
|
const file = scope.files.find((entry) => entry.path === schema);
|
|
293
290
|
if (file === undefined)
|
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,
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAMR,MAAM,wBAAwB,CAAC;AAsBhC,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AA+BxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAiIxE"}
|
package/dist/site.js
CHANGED
|
@@ -1,42 +1,32 @@
|
|
|
1
1
|
import { actionOutcome } from './actions.js';
|
|
2
2
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
3
|
-
import {
|
|
4
|
-
import { advancedScope, bootstrapOf, parseEnumeration, parseSiteBootstrap, refreshFrom,
|
|
5
|
-
import { classifyDoor, discoveryFailure
|
|
3
|
+
import { scopeModels, streamedModels, viewModels } from './model.js';
|
|
4
|
+
import { advancedScope, bootstrapOf, parseEnumeration, parseSiteBootstrap, refreshFrom, viewOf, } from './read.js';
|
|
5
|
+
import { classifyDoor, discoveryFailure } from './refusal.js';
|
|
6
6
|
import { houseNotifications } from './stream.js';
|
|
7
7
|
import { PRIVATE_LOCATOR, SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, } from './transport.js';
|
|
8
|
-
import { logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
8
|
+
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
9
9
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
10
|
-
function siteRoom(tracked
|
|
10
|
+
function siteRoom(tracked) {
|
|
11
11
|
return {
|
|
12
12
|
name: tracked.handle,
|
|
13
13
|
locator: tracked.locator,
|
|
14
14
|
roomVersion: roomVersion(tracked),
|
|
15
15
|
operations: { read: [''], sync: [''], write: [], delete: [] },
|
|
16
16
|
replica: { selection: tracked.locator, admission: 'admitted' },
|
|
17
|
-
attachedModel,
|
|
18
17
|
providerOwnedPaths: [],
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
20
|
function settled(refused) {
|
|
22
|
-
return refused.kind === 'beyond-horizon'
|
|
23
|
-
? UNCERTAIN
|
|
24
|
-
: refused;
|
|
21
|
+
return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;
|
|
25
22
|
}
|
|
26
23
|
export function createSiteAdapter(transport) {
|
|
27
24
|
const notifications = houseNotifications(transport, 'site');
|
|
28
25
|
const tracked = new Map();
|
|
29
|
-
const models = modelShelf();
|
|
30
|
-
const acquired = new Map();
|
|
31
|
-
let caught = new Map();
|
|
32
26
|
async function enumeration(entry, from) {
|
|
33
27
|
const answer = await transport.door(SITE_DOOR_ENUMERATE, {
|
|
34
28
|
positions: [presented(entry.authority, from)],
|
|
35
29
|
});
|
|
36
|
-
const behind = doorRefusal(answer.body);
|
|
37
|
-
if (behind?.code === 'replica_behind' && behind.retryable) {
|
|
38
|
-
return { kind: 'retryable-refusal', code: behind.code, fields: behind.fields };
|
|
39
|
-
}
|
|
40
30
|
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
41
31
|
if (classified !== null)
|
|
42
32
|
return classified;
|
|
@@ -65,31 +55,27 @@ export function createSiteAdapter(transport) {
|
|
|
65
55
|
if (from === null)
|
|
66
56
|
return { kind: 'beyond-horizon' };
|
|
67
57
|
const streamed = notifications.advance(entry, from);
|
|
68
|
-
if (streamed !== null)
|
|
69
|
-
|
|
58
|
+
if (streamed !== null) {
|
|
59
|
+
const models = await streamedModels(streamed.schemas, entry, 'site');
|
|
60
|
+
return models === undefined ? streamed.page : { ...streamed.page, models };
|
|
61
|
+
}
|
|
70
62
|
const found = await enumeration(entry, from);
|
|
71
63
|
if ('kind' in found)
|
|
72
64
|
return found;
|
|
73
65
|
const view = viewOf(found, entry);
|
|
74
66
|
if (view === undefined)
|
|
75
67
|
return { kind: 'room-not-readable', locator: entry.locator };
|
|
76
|
-
notifications.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const model = await heldModel(schemaOf(held.scope, entry.schema), schemaPath(entry.handle, entry.schema), MODEL_ABSENT);
|
|
83
|
-
acquired.set(entry.authority, { roomVersion: roomVersion(held.scope), model });
|
|
84
|
-
return model;
|
|
68
|
+
notifications.reach(entry.authority, view);
|
|
69
|
+
const answer = refreshFrom(view, fromRoomVersion);
|
|
70
|
+
if (answer.kind !== 'net-advancement')
|
|
71
|
+
return answer;
|
|
72
|
+
const models = await viewModels(view, entry);
|
|
73
|
+
return models === undefined ? answer : { ...answer, models };
|
|
85
74
|
}
|
|
86
75
|
return {
|
|
87
76
|
async authorize() {
|
|
88
77
|
return {};
|
|
89
78
|
},
|
|
90
|
-
async model(_authorization, request) {
|
|
91
|
-
return models.answer(request);
|
|
92
|
-
},
|
|
93
79
|
async discover() {
|
|
94
80
|
const answer = await transport.read(SITE_DOOR_DISCOVER);
|
|
95
81
|
const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);
|
|
@@ -103,30 +89,7 @@ export function createSiteAdapter(transport) {
|
|
|
103
89
|
for (const entry of entries)
|
|
104
90
|
tracked.set(entry.locator, entry);
|
|
105
91
|
notifications.track(entries);
|
|
106
|
-
|
|
107
|
-
for (const authority of [...acquired.keys()]) {
|
|
108
|
-
if (!published.has(authority))
|
|
109
|
-
acquired.delete(authority);
|
|
110
|
-
}
|
|
111
|
-
const fresh = new Map();
|
|
112
|
-
const current = new Map();
|
|
113
|
-
for (const entry of entries) {
|
|
114
|
-
const kept = acquired.get(entry.authority);
|
|
115
|
-
if (kept !== undefined && kept.roomVersion === roomVersion(entry)) {
|
|
116
|
-
current.set(entry.authority, kept.model);
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
const held = await caughtUp(entry);
|
|
120
|
-
fresh.set(entry.authority, held);
|
|
121
|
-
current.set(entry.authority, await acquire(entry, held));
|
|
122
|
-
}
|
|
123
|
-
caught = fresh;
|
|
124
|
-
const rooms = entries.map((entry) => {
|
|
125
|
-
const shelved = models.retain(modelKey(entry.locator, 'collection'), current.get(entry.authority));
|
|
126
|
-
return siteRoom(entry, shelved?.identity ?? null);
|
|
127
|
-
});
|
|
128
|
-
models.keep(entries.map((entry) => entry.locator));
|
|
129
|
-
return mapDiscovery(document, rooms, siteCapabilities());
|
|
92
|
+
return mapDiscovery(document, entries.map(siteRoom), siteCapabilities());
|
|
130
93
|
},
|
|
131
94
|
async bootstrap(_authorization, request) {
|
|
132
95
|
const entry = tracked.get(request.locator);
|
|
@@ -134,11 +97,12 @@ export function createSiteAdapter(transport) {
|
|
|
134
97
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
135
98
|
if (request.pageToken !== undefined)
|
|
136
99
|
return UNCERTAIN;
|
|
137
|
-
const held =
|
|
100
|
+
const held = await caughtUp(entry);
|
|
138
101
|
if ('failure' in held)
|
|
139
102
|
return held.failure;
|
|
140
|
-
notifications.
|
|
141
|
-
|
|
103
|
+
notifications.reach(entry.authority, held.scope);
|
|
104
|
+
const models = await scopeModels(held.scope, entry);
|
|
105
|
+
return { ...bootstrapOf(held.scope), ...(models === undefined ? {} : { models }) };
|
|
142
106
|
},
|
|
143
107
|
async refresh(_authorization, request) {
|
|
144
108
|
const entry = tracked.get(request.locator);
|
|
@@ -146,20 +110,7 @@ export function createSiteAdapter(transport) {
|
|
|
146
110
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
147
111
|
if (request.pageToken !== undefined)
|
|
148
112
|
return UNCERTAIN;
|
|
149
|
-
|
|
150
|
-
if (result.kind === 'beyond-horizon')
|
|
151
|
-
caught.delete(entry.authority);
|
|
152
|
-
const answered = result.kind === 'net-advancement'
|
|
153
|
-
? result.roomVersion
|
|
154
|
-
: result.kind === 'still-current'
|
|
155
|
-
? request.fromRoomVersion
|
|
156
|
-
: null;
|
|
157
|
-
if (request.minPosition !== undefined &&
|
|
158
|
-
answered !== null &&
|
|
159
|
-
!reachedVersion(answered, request.minPosition, entry.logEpoch)) {
|
|
160
|
-
return { kind: 'retryable-refusal', code: 'replica_behind', fields: {} };
|
|
161
|
-
}
|
|
162
|
-
return result;
|
|
113
|
+
return refreshed(entry, request.fromRoomVersion);
|
|
163
114
|
},
|
|
164
115
|
async mutate() {
|
|
165
116
|
return { kind: 'rejected', affected: {}, code: 'write-grant', fields: {} };
|
|
@@ -170,6 +121,9 @@ export function createSiteAdapter(transport) {
|
|
|
170
121
|
reached(locator, version, target) {
|
|
171
122
|
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
|
172
123
|
},
|
|
124
|
+
follows(_locator, version, next) {
|
|
125
|
+
return followsVersion(version, next);
|
|
126
|
+
},
|
|
173
127
|
async action(_authorization, request) {
|
|
174
128
|
if (request.name !== 'submit') {
|
|
175
129
|
return { kind: 'rejected', code: 'action-unimplemented', fields: { name: request.name } };
|
|
@@ -178,7 +132,19 @@ export function createSiteAdapter(transport) {
|
|
|
178
132
|
return UNCERTAIN;
|
|
179
133
|
return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), 'submit');
|
|
180
134
|
},
|
|
181
|
-
|
|
135
|
+
roomStream: {
|
|
136
|
+
hold(rooms) {
|
|
137
|
+
notifications.send(rooms.flatMap((room) => {
|
|
138
|
+
const entry = tracked.get(room.locator);
|
|
139
|
+
const at = logPosition(room.roomVersion);
|
|
140
|
+
if (entry === undefined || at === null)
|
|
141
|
+
return [];
|
|
142
|
+
notifications.reach(entry.authority, at);
|
|
143
|
+
return [presented(entry.authority, at)];
|
|
144
|
+
}));
|
|
145
|
+
},
|
|
146
|
+
observe: notifications.observe,
|
|
147
|
+
},
|
|
182
148
|
serviceMode: notifications.serviceMode,
|
|
183
149
|
};
|
|
184
150
|
}
|
package/dist/stream.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import type { ConversationStream, RefreshPage,
|
|
1
|
+
import type { ConversationStream, RefreshPage, RoomStreamEvent, ServiceModeSignal } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
import type { HouseDoor, HouseMode, HouseStreamEntry } from './transport.js';
|
|
3
|
+
import type { HouseDoor, HouseHeldRoom, HouseMode, HouseStreamEntry } from './transport.js';
|
|
4
4
|
import { type LogPosition } from './version.js';
|
|
5
5
|
export type HeldRevision = (path: string, revision: string) => boolean;
|
|
6
6
|
export type StreamedAdvancement = {
|
|
7
7
|
page: RefreshPage;
|
|
8
8
|
entries: readonly HouseStreamEntry[];
|
|
9
|
+
schemas: ReadonlyMap<string, HouseStreamEntry>;
|
|
9
10
|
};
|
|
10
|
-
export type HouseNotifications =
|
|
11
|
+
export type HouseNotifications = {
|
|
12
|
+
observe(notify: (event: RoomStreamEvent) => void): () => void;
|
|
13
|
+
send(rooms: readonly HouseHeldRoom[]): void;
|
|
11
14
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
12
|
-
|
|
15
|
+
reach(authority: string, at: LogPosition): void;
|
|
13
16
|
advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): StreamedAdvancement | null;
|
|
14
17
|
conversations: ConversationStream;
|
|
15
18
|
serviceMode: ServiceModeSignal;
|
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,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EACX,eAAe,EAEf,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,SAAS,EAET,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,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;IACrC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC9D,IAAI,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,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,CAyQ5F"}
|
package/dist/stream.js
CHANGED
|
@@ -15,19 +15,15 @@ export function houseNotifications(transport, mode) {
|
|
|
15
15
|
const stream = transport.stream;
|
|
16
16
|
const lines = new Map();
|
|
17
17
|
const locators = new Map();
|
|
18
|
-
const schemas = new Map();
|
|
19
18
|
const observers = new Set();
|
|
20
19
|
const conversationObservers = new Set();
|
|
21
20
|
const modeObservers = new Set();
|
|
22
21
|
let replicated = [];
|
|
23
22
|
const live = new Set();
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return;
|
|
29
|
-
listening = true;
|
|
30
|
-
stream.observe(receive);
|
|
23
|
+
let opening = null;
|
|
24
|
+
function emit(event) {
|
|
25
|
+
for (const observer of observers)
|
|
26
|
+
observer(event);
|
|
31
27
|
}
|
|
32
28
|
function emitConversation(event) {
|
|
33
29
|
if (event.kind !== 'gap' && event.kind !== 'accepted-message')
|
|
@@ -35,11 +31,13 @@ export function houseNotifications(transport, mode) {
|
|
|
35
31
|
for (const observer of conversationObservers)
|
|
36
32
|
observer(event);
|
|
37
33
|
}
|
|
38
|
-
function reopened() {
|
|
34
|
+
function reopened(next) {
|
|
35
|
+
opening = next;
|
|
39
36
|
const gapped = new Set([...replicated, ...live]);
|
|
40
37
|
live.clear();
|
|
41
38
|
for (const conversation of gapped)
|
|
42
39
|
emitConversation({ kind: 'gap', conversation });
|
|
40
|
+
emit({ kind: 'opened' });
|
|
43
41
|
}
|
|
44
42
|
function converse(frame) {
|
|
45
43
|
const conversation = frame.conversation_id;
|
|
@@ -85,14 +83,10 @@ export function houseNotifications(transport, mode) {
|
|
|
85
83
|
return;
|
|
86
84
|
emitConversation({ kind: 'accepted-message', conversation, message });
|
|
87
85
|
}
|
|
88
|
-
function announce(authority, at
|
|
86
|
+
function announce(authority, at) {
|
|
89
87
|
const version = roomVersion(at);
|
|
90
88
|
for (const locator of locators.get(authority) ?? []) {
|
|
91
|
-
|
|
92
|
-
observer(modelChanged
|
|
93
|
-
? { locator, roomVersion: version, modelChanged: true }
|
|
94
|
-
: { locator, roomVersion: version });
|
|
95
|
-
}
|
|
89
|
+
emit({ kind: 'room-version', locator, roomVersion: version });
|
|
96
90
|
}
|
|
97
91
|
}
|
|
98
92
|
function interrupt(authority) {
|
|
@@ -109,6 +103,13 @@ export function houseNotifications(transport, mode) {
|
|
|
109
103
|
observer(mode);
|
|
110
104
|
return;
|
|
111
105
|
}
|
|
106
|
+
if (frame.type === 'opening') {
|
|
107
|
+
emit({
|
|
108
|
+
kind: 'opening',
|
|
109
|
+
expired: frame.expired.flatMap((authority) => locators.get(authority) ?? []),
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
112
113
|
if (frame.type === 'turn' ||
|
|
113
114
|
frame.type === 'process' ||
|
|
114
115
|
frame.type === 'commands' ||
|
|
@@ -140,14 +141,18 @@ export function houseNotifications(transport, mode) {
|
|
|
140
141
|
else {
|
|
141
142
|
interrupt(frame.authority);
|
|
142
143
|
}
|
|
143
|
-
|
|
144
|
-
announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch }, frame.entries.some((entry) => addresses.includes(entry.path)));
|
|
144
|
+
announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch });
|
|
145
145
|
}
|
|
146
|
+
stream.observe(receive);
|
|
147
|
+
stream.opened(reopened);
|
|
148
|
+
stream.closed((revoked) => {
|
|
149
|
+
opening = null;
|
|
150
|
+
emit({ kind: 'closed', revoked });
|
|
151
|
+
});
|
|
146
152
|
return {
|
|
147
153
|
serviceMode: {
|
|
148
154
|
observe(notify) {
|
|
149
155
|
modeObservers.add(notify);
|
|
150
|
-
listen();
|
|
151
156
|
return () => {
|
|
152
157
|
modeObservers.delete(notify);
|
|
153
158
|
};
|
|
@@ -159,22 +164,39 @@ export function houseNotifications(transport, mode) {
|
|
|
159
164
|
},
|
|
160
165
|
observe(notify) {
|
|
161
166
|
conversationObservers.add(notify);
|
|
162
|
-
listen();
|
|
163
|
-
if (!catching) {
|
|
164
|
-
catching = true;
|
|
165
|
-
stream.opened(reopened);
|
|
166
|
-
}
|
|
167
167
|
return () => {
|
|
168
168
|
conversationObservers.delete(notify);
|
|
169
169
|
};
|
|
170
170
|
},
|
|
171
171
|
},
|
|
172
|
+
observe(notify) {
|
|
173
|
+
observers.add(notify);
|
|
174
|
+
if (opening !== null) {
|
|
175
|
+
queueMicrotask(() => {
|
|
176
|
+
if (observers.has(notify))
|
|
177
|
+
notify({ kind: 'opened' });
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return () => {
|
|
181
|
+
observers.delete(notify);
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
send(rooms) {
|
|
185
|
+
for (const room of rooms) {
|
|
186
|
+
const line = lines.get(room.authority);
|
|
187
|
+
const held = position(room.position);
|
|
188
|
+
if (line === undefined || held === null || line.logEpoch !== room.log_epoch)
|
|
189
|
+
continue;
|
|
190
|
+
lines.set(room.authority, { ...line, frames: [], held });
|
|
191
|
+
}
|
|
192
|
+
const current = opening;
|
|
193
|
+
opening = null;
|
|
194
|
+
current?.hold(rooms);
|
|
195
|
+
},
|
|
172
196
|
track(entries) {
|
|
173
197
|
locators.clear();
|
|
174
|
-
schemas.clear();
|
|
175
198
|
for (const entry of entries) {
|
|
176
199
|
locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);
|
|
177
|
-
schemas.set(entry.authority, entry.schemas);
|
|
178
200
|
if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {
|
|
179
201
|
lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [], held: null });
|
|
180
202
|
}
|
|
@@ -184,20 +206,18 @@ export function houseNotifications(transport, mode) {
|
|
|
184
206
|
lines.delete(authority);
|
|
185
207
|
}
|
|
186
208
|
},
|
|
187
|
-
|
|
188
|
-
observe(notify) {
|
|
189
|
-
observers.add(notify);
|
|
190
|
-
listen();
|
|
191
|
-
return () => {
|
|
192
|
-
observers.delete(notify);
|
|
193
|
-
};
|
|
194
|
-
},
|
|
195
|
-
hold(authority, at) {
|
|
209
|
+
reach(authority, at) {
|
|
196
210
|
const line = lines.get(authority);
|
|
197
211
|
const held = position(at.position);
|
|
198
212
|
if (line === undefined || held === null || line.logEpoch !== at.logEpoch)
|
|
199
213
|
return;
|
|
200
|
-
|
|
214
|
+
if (line.held !== null && held <= line.held)
|
|
215
|
+
return;
|
|
216
|
+
lines.set(authority, {
|
|
217
|
+
...line,
|
|
218
|
+
frames: line.frames.filter((frame) => frame.position > held),
|
|
219
|
+
held,
|
|
220
|
+
});
|
|
201
221
|
},
|
|
202
222
|
advance(tracked, from, holds) {
|
|
203
223
|
const line = lines.get(tracked.authority);
|
|
@@ -213,6 +233,7 @@ export function houseNotifications(transport, mode) {
|
|
|
213
233
|
const changes = {};
|
|
214
234
|
const removals = [];
|
|
215
235
|
const applied = [];
|
|
236
|
+
const schemas = new Map();
|
|
216
237
|
const forget = (path) => {
|
|
217
238
|
delete documents[path];
|
|
218
239
|
delete revisions[path];
|
|
@@ -224,13 +245,14 @@ export function houseNotifications(transport, mode) {
|
|
|
224
245
|
for (const frame of pending) {
|
|
225
246
|
for (const entry of frame.entries) {
|
|
226
247
|
if (entry.kind === 'edited' &&
|
|
227
|
-
entry.text === undefined &&
|
|
228
248
|
entry.revision !== undefined &&
|
|
229
249
|
holds?.(entry.path, entry.revision) === true) {
|
|
230
250
|
forget(entry.path);
|
|
231
251
|
continue;
|
|
232
252
|
}
|
|
233
253
|
applied.push(entry);
|
|
254
|
+
if (tracked.schemas.includes(entry.path))
|
|
255
|
+
schemas.set(entry.path, entry);
|
|
234
256
|
if (entry.kind === 'removed') {
|
|
235
257
|
forget(entry.path);
|
|
236
258
|
removals.push(entry.path);
|
|
@@ -264,6 +286,7 @@ export function houseNotifications(transport, mode) {
|
|
|
264
286
|
removals: removals.sort(),
|
|
265
287
|
},
|
|
266
288
|
entries: applied,
|
|
289
|
+
schemas,
|
|
267
290
|
};
|
|
268
291
|
},
|
|
269
292
|
};
|
package/dist/transport.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export type HouseStreamEntry = {
|
|
|
30
30
|
path: string;
|
|
31
31
|
kind: 'edited' | 'removed';
|
|
32
32
|
revision?: string;
|
|
33
|
+
sha256?: string;
|
|
33
34
|
text?: string;
|
|
34
35
|
author?: {
|
|
35
36
|
user: string;
|
|
@@ -50,6 +51,9 @@ export type HouseStreamFrame = {
|
|
|
50
51
|
position: string;
|
|
51
52
|
log_epoch: string;
|
|
52
53
|
entries: readonly HouseStreamEntry[];
|
|
54
|
+
} | {
|
|
55
|
+
type: 'opening';
|
|
56
|
+
expired: readonly string[];
|
|
53
57
|
} | ({
|
|
54
58
|
type: 'turn';
|
|
55
59
|
conversation_id: string;
|
|
@@ -78,9 +82,18 @@ export type HouseStreamFrame = {
|
|
|
78
82
|
type: 'signal';
|
|
79
83
|
service_mode: string;
|
|
80
84
|
};
|
|
85
|
+
export type HouseHeldRoom = {
|
|
86
|
+
authority: string;
|
|
87
|
+
position: string;
|
|
88
|
+
log_epoch: string;
|
|
89
|
+
};
|
|
90
|
+
export type HouseOpening = {
|
|
91
|
+
hold(rooms: readonly HouseHeldRoom[]): void;
|
|
92
|
+
};
|
|
81
93
|
export type HouseStream = {
|
|
82
94
|
observe(receive: (frame: HouseStreamFrame) => void): () => void;
|
|
83
|
-
opened(notify: () => void): () => void;
|
|
95
|
+
opened(notify: (opening: HouseOpening) => void): () => void;
|
|
96
|
+
closed(notify: (revoked: boolean) => void): () => void;
|
|
84
97
|
};
|
|
85
98
|
export type HouseDoor = {
|
|
86
99
|
door(route: string, body: unknown): Promise<HouseDoorAnswer>;
|
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,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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c,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/version.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export declare function logPosition(version: string): LogPosition | null;
|
|
|
12
12
|
export declare function readPosition(held: Readonly<Record<string, unknown>>): LogPosition | null;
|
|
13
13
|
export declare function presented(authority: string, at: LogPosition): PresentedPosition;
|
|
14
14
|
export declare function reachedVersion(roomVersion: string, target: string, currentEpoch: string | undefined): boolean;
|
|
15
|
+
export declare function followsVersion(roomVersion: string, next: string): boolean;
|
|
15
16
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAEnD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,WAAW,GAAG,IAAI,CAKxF;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,iBAAiB,CAE/E;AAID,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAQT"}
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAEnD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,WAAW,GAAG,IAAI,CAKxF;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,iBAAiB,CAE/E;AAID,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAQT;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMzE"}
|
package/dist/version.js
CHANGED
|
@@ -32,3 +32,12 @@ export function reachedVersion(roomVersion, target, currentEpoch) {
|
|
|
32
32
|
return BigInt(held.position) >= BigInt(wanted.position);
|
|
33
33
|
return held.logEpoch === currentEpoch;
|
|
34
34
|
}
|
|
35
|
+
export function followsVersion(roomVersion, next) {
|
|
36
|
+
const held = logPosition(roomVersion);
|
|
37
|
+
const following = logPosition(next);
|
|
38
|
+
if (held === null || following === null || held.logEpoch !== following.logEpoch)
|
|
39
|
+
return false;
|
|
40
|
+
if (!DECIMAL.test(held.position) || !DECIMAL.test(following.position))
|
|
41
|
+
return false;
|
|
42
|
+
return BigInt(following.position) === BigInt(held.position) + 1n;
|
|
43
|
+
}
|
package/dist/write.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChangeBatch, HistoryResult, MutationResult } from '@agentshouse/mdruntime';
|
|
1
|
+
import type { ChangeBatch, HistoryResult, MutationResult, RoomAttachment } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseBounds } from './discovery.js';
|
|
3
3
|
export type HouseOperation = Readonly<Record<string, unknown>>;
|
|
4
4
|
export type ChangeMapping = {
|
|
@@ -21,7 +21,14 @@ export declare function deltaBody(changes: readonly HouseOperation[]): string;
|
|
|
21
21
|
export declare function deltaBytes(delta: string): number;
|
|
22
22
|
export declare function uploadable(inline: Readonly<Record<string, unknown>>, bytes: number, bounds: Pick<HouseBounds, 'max_inline_body_bytes' | 'max_upload_bytes'>): boolean;
|
|
23
23
|
export declare function deltaDigest(delta: string): Promise<string>;
|
|
24
|
-
export
|
|
24
|
+
export type SubmittedOutcome = Exclude<MutationResult, {
|
|
25
|
+
kind: 'accepted';
|
|
26
|
+
}> | (Extract<MutationResult, {
|
|
27
|
+
kind: 'accepted';
|
|
28
|
+
}> & {
|
|
29
|
+
originals: readonly RoomAttachment[];
|
|
30
|
+
});
|
|
31
|
+
export declare function mutationOutcome(status: number, body: unknown, locator: string, handle: string): SubmittedOutcome;
|
|
25
32
|
export declare function rejectedMapping(mapping: Extract<ChangeMapping, {
|
|
26
33
|
kind: 'unmapped';
|
|
27
34
|
}>): {
|
package/dist/write.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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3C,aAAa,CAiDf"}
|
package/dist/write.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseOriginals } from './read.js';
|
|
1
2
|
import { sha256Hex, textBytes } from './digest.js';
|
|
2
3
|
import { nativePath, roomLocalPath } from './map.js';
|
|
3
4
|
import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
|
|
@@ -200,6 +201,9 @@ export function mutationOutcome(status, body, locator, handle) {
|
|
|
200
201
|
const contents = material(held.contents, handle);
|
|
201
202
|
if (contents === null)
|
|
202
203
|
return { kind: 'transport-uncertainty' };
|
|
204
|
+
const originals = parseOriginals(held.originals);
|
|
205
|
+
if (originals === null)
|
|
206
|
+
return { kind: 'transport-uncertainty' };
|
|
203
207
|
const documents = {};
|
|
204
208
|
const revisions = {};
|
|
205
209
|
const removals = [];
|
|
@@ -217,6 +221,7 @@ export function mutationOutcome(status, body, locator, handle) {
|
|
|
217
221
|
documents,
|
|
218
222
|
revisions,
|
|
219
223
|
removals: removals.sort(),
|
|
224
|
+
originals,
|
|
220
225
|
};
|
|
221
226
|
}
|
|
222
227
|
export function rejectedMapping(mapping) {
|
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-c26cd225263b7",
|
|
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-ca7c26c6bc27e"
|
|
30
30
|
}
|
|
31
31
|
}
|