@agentshouse/mdruntime-adapter 0.1.0-cc63dd043d0e2 → 0.1.0-cca5d676bc88e
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 +24 -8
- package/README.md +3 -3
- package/dist/actions.d.ts +2 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +4 -4
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +67 -101
- package/dist/discovery.d.ts +3 -9
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +9 -27
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- 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 +8 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +89 -37
- package/dist/transport.d.ts +31 -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/stream.js
CHANGED
|
@@ -6,6 +6,16 @@ function turnOperation(frame) {
|
|
|
6
6
|
const { type: _type, conversation_id: _conversation, turn_id: _turn, ...operation } = frame;
|
|
7
7
|
return structuredClone(operation);
|
|
8
8
|
}
|
|
9
|
+
function listedConversation(listed) {
|
|
10
|
+
return {
|
|
11
|
+
conversation: listed.conversation_id,
|
|
12
|
+
agent: listed.agent_id,
|
|
13
|
+
name: listed.name,
|
|
14
|
+
created: listed.created_at,
|
|
15
|
+
finished: listed.finished_at,
|
|
16
|
+
outcome: listed.outcome,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
9
19
|
function position(value) {
|
|
10
20
|
if (!/^(?:0|[1-9][0-9]*)$/.test(value))
|
|
11
21
|
return null;
|
|
@@ -15,31 +25,35 @@ export function houseNotifications(transport, mode) {
|
|
|
15
25
|
const stream = transport.stream;
|
|
16
26
|
const lines = new Map();
|
|
17
27
|
const locators = new Map();
|
|
18
|
-
const schemas = new Map();
|
|
19
28
|
const observers = new Set();
|
|
20
29
|
const conversationObservers = new Set();
|
|
21
30
|
const modeObservers = new Set();
|
|
22
31
|
let replicated = [];
|
|
23
32
|
const live = new Set();
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
listening = true;
|
|
30
|
-
stream.observe(receive);
|
|
33
|
+
let opening = null;
|
|
34
|
+
const runtime = crypto.randomUUID();
|
|
35
|
+
function emit(event) {
|
|
36
|
+
for (const observer of observers)
|
|
37
|
+
observer(event);
|
|
31
38
|
}
|
|
32
39
|
function emitConversation(event) {
|
|
33
|
-
if (event.kind
|
|
40
|
+
if (event.kind === 'turn' ||
|
|
41
|
+
event.kind === 'questions' ||
|
|
42
|
+
event.kind === 'process' ||
|
|
43
|
+
event.kind === 'commands' ||
|
|
44
|
+
event.kind === 'options') {
|
|
34
45
|
live.add(event.conversation);
|
|
46
|
+
}
|
|
35
47
|
for (const observer of conversationObservers)
|
|
36
48
|
observer(event);
|
|
37
49
|
}
|
|
38
|
-
function reopened() {
|
|
50
|
+
function reopened(next) {
|
|
51
|
+
opening = next;
|
|
39
52
|
const gapped = new Set([...replicated, ...live]);
|
|
40
53
|
live.clear();
|
|
41
54
|
for (const conversation of gapped)
|
|
42
55
|
emitConversation({ kind: 'gap', conversation });
|
|
56
|
+
emit({ kind: 'opened' });
|
|
43
57
|
}
|
|
44
58
|
function converse(frame) {
|
|
45
59
|
const conversation = frame.conversation_id;
|
|
@@ -85,14 +99,10 @@ export function houseNotifications(transport, mode) {
|
|
|
85
99
|
return;
|
|
86
100
|
emitConversation({ kind: 'accepted-message', conversation, message });
|
|
87
101
|
}
|
|
88
|
-
function announce(authority, at
|
|
102
|
+
function announce(authority, at) {
|
|
89
103
|
const version = roomVersion(at);
|
|
90
104
|
for (const locator of locators.get(authority) ?? []) {
|
|
91
|
-
|
|
92
|
-
observer(modelChanged
|
|
93
|
-
? { locator, roomVersion: version, modelChanged: true }
|
|
94
|
-
: { locator, roomVersion: version });
|
|
95
|
-
}
|
|
105
|
+
emit({ kind: 'room-version', locator, roomVersion: version });
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
108
|
function interrupt(authority) {
|
|
@@ -109,6 +119,25 @@ export function houseNotifications(transport, mode) {
|
|
|
109
119
|
observer(mode);
|
|
110
120
|
return;
|
|
111
121
|
}
|
|
122
|
+
if (frame.type === 'opening') {
|
|
123
|
+
emit({
|
|
124
|
+
kind: 'opening',
|
|
125
|
+
expired: frame.expired.flatMap((authority) => locators.get(authority) ?? []),
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (frame.type === 'conversations') {
|
|
130
|
+
emitConversation({ kind: 'list', entries: frame.conversations.map(listedConversation) });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (frame.type === 'conversation') {
|
|
134
|
+
emitConversation({ kind: 'listed', entry: listedConversation(frame.conversation) });
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (frame.type === 'conversation_deleted') {
|
|
138
|
+
emitConversation({ kind: 'unlisted', conversation: frame.conversation_id });
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
112
141
|
if (frame.type === 'turn' ||
|
|
113
142
|
frame.type === 'process' ||
|
|
114
143
|
frame.type === 'commands' ||
|
|
@@ -140,14 +169,19 @@ export function houseNotifications(transport, mode) {
|
|
|
140
169
|
else {
|
|
141
170
|
interrupt(frame.authority);
|
|
142
171
|
}
|
|
143
|
-
|
|
144
|
-
announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch }, frame.entries.some((entry) => addresses.includes(entry.path)));
|
|
172
|
+
announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch });
|
|
145
173
|
}
|
|
174
|
+
stream.observe(receive);
|
|
175
|
+
stream.opened(reopened);
|
|
176
|
+
stream.closed((revoked) => {
|
|
177
|
+
opening = null;
|
|
178
|
+
emit({ kind: 'closed', revoked });
|
|
179
|
+
});
|
|
146
180
|
return {
|
|
181
|
+
runtime,
|
|
147
182
|
serviceMode: {
|
|
148
183
|
observe(notify) {
|
|
149
184
|
modeObservers.add(notify);
|
|
150
|
-
listen();
|
|
151
185
|
return () => {
|
|
152
186
|
modeObservers.delete(notify);
|
|
153
187
|
};
|
|
@@ -159,22 +193,39 @@ export function houseNotifications(transport, mode) {
|
|
|
159
193
|
},
|
|
160
194
|
observe(notify) {
|
|
161
195
|
conversationObservers.add(notify);
|
|
162
|
-
listen();
|
|
163
|
-
if (!catching) {
|
|
164
|
-
catching = true;
|
|
165
|
-
stream.opened(reopened);
|
|
166
|
-
}
|
|
167
196
|
return () => {
|
|
168
197
|
conversationObservers.delete(notify);
|
|
169
198
|
};
|
|
170
199
|
},
|
|
171
200
|
},
|
|
201
|
+
observe(notify) {
|
|
202
|
+
observers.add(notify);
|
|
203
|
+
if (opening !== null) {
|
|
204
|
+
queueMicrotask(() => {
|
|
205
|
+
if (observers.has(notify))
|
|
206
|
+
notify({ kind: 'opened' });
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return () => {
|
|
210
|
+
observers.delete(notify);
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
send(rooms) {
|
|
214
|
+
for (const room of rooms) {
|
|
215
|
+
const line = lines.get(room.authority);
|
|
216
|
+
const held = position(room.position);
|
|
217
|
+
if (line === undefined || held === null || line.logEpoch !== room.log_epoch)
|
|
218
|
+
continue;
|
|
219
|
+
lines.set(room.authority, { ...line, frames: [], held });
|
|
220
|
+
}
|
|
221
|
+
const current = opening;
|
|
222
|
+
opening = null;
|
|
223
|
+
current?.hold(rooms, runtime);
|
|
224
|
+
},
|
|
172
225
|
track(entries) {
|
|
173
226
|
locators.clear();
|
|
174
|
-
schemas.clear();
|
|
175
227
|
for (const entry of entries) {
|
|
176
228
|
locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);
|
|
177
|
-
schemas.set(entry.authority, entry.schemas);
|
|
178
229
|
if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {
|
|
179
230
|
lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [], held: null });
|
|
180
231
|
}
|
|
@@ -184,20 +235,18 @@ export function houseNotifications(transport, mode) {
|
|
|
184
235
|
lines.delete(authority);
|
|
185
236
|
}
|
|
186
237
|
},
|
|
187
|
-
|
|
188
|
-
observe(notify) {
|
|
189
|
-
observers.add(notify);
|
|
190
|
-
listen();
|
|
191
|
-
return () => {
|
|
192
|
-
observers.delete(notify);
|
|
193
|
-
};
|
|
194
|
-
},
|
|
195
|
-
hold(authority, at) {
|
|
238
|
+
reach(authority, at) {
|
|
196
239
|
const line = lines.get(authority);
|
|
197
240
|
const held = position(at.position);
|
|
198
241
|
if (line === undefined || held === null || line.logEpoch !== at.logEpoch)
|
|
199
242
|
return;
|
|
200
|
-
|
|
243
|
+
if (line.held !== null && held <= line.held)
|
|
244
|
+
return;
|
|
245
|
+
lines.set(authority, {
|
|
246
|
+
...line,
|
|
247
|
+
frames: line.frames.filter((frame) => frame.position > held),
|
|
248
|
+
held,
|
|
249
|
+
});
|
|
201
250
|
},
|
|
202
251
|
advance(tracked, from, holds) {
|
|
203
252
|
const line = lines.get(tracked.authority);
|
|
@@ -213,6 +262,7 @@ export function houseNotifications(transport, mode) {
|
|
|
213
262
|
const changes = {};
|
|
214
263
|
const removals = [];
|
|
215
264
|
const applied = [];
|
|
265
|
+
const schemas = new Map();
|
|
216
266
|
const forget = (path) => {
|
|
217
267
|
delete documents[path];
|
|
218
268
|
delete revisions[path];
|
|
@@ -224,13 +274,14 @@ export function houseNotifications(transport, mode) {
|
|
|
224
274
|
for (const frame of pending) {
|
|
225
275
|
for (const entry of frame.entries) {
|
|
226
276
|
if (entry.kind === 'edited' &&
|
|
227
|
-
entry.text === undefined &&
|
|
228
277
|
entry.revision !== undefined &&
|
|
229
278
|
holds?.(entry.path, entry.revision) === true) {
|
|
230
279
|
forget(entry.path);
|
|
231
280
|
continue;
|
|
232
281
|
}
|
|
233
282
|
applied.push(entry);
|
|
283
|
+
if (tracked.schemas.includes(entry.path))
|
|
284
|
+
schemas.set(entry.path, entry);
|
|
234
285
|
if (entry.kind === 'removed') {
|
|
235
286
|
forget(entry.path);
|
|
236
287
|
removals.push(entry.path);
|
|
@@ -264,6 +315,7 @@ export function houseNotifications(transport, mode) {
|
|
|
264
315
|
removals: removals.sort(),
|
|
265
316
|
},
|
|
266
317
|
entries: applied,
|
|
318
|
+
schemas,
|
|
267
319
|
};
|
|
268
320
|
},
|
|
269
321
|
};
|
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;
|
|
@@ -43,6 +44,14 @@ export type HouseStreamEntry = {
|
|
|
43
44
|
type LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, {
|
|
44
45
|
kind: K;
|
|
45
46
|
}>;
|
|
47
|
+
export type HouseListedConversation = {
|
|
48
|
+
conversation_id: string;
|
|
49
|
+
agent_id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
created_at: string;
|
|
52
|
+
finished_at: string | null;
|
|
53
|
+
outcome: string | null;
|
|
54
|
+
};
|
|
46
55
|
export type HouseStreamFrame = {
|
|
47
56
|
type: 'entries';
|
|
48
57
|
authority: string;
|
|
@@ -50,6 +59,9 @@ export type HouseStreamFrame = {
|
|
|
50
59
|
position: string;
|
|
51
60
|
log_epoch: string;
|
|
52
61
|
entries: readonly HouseStreamEntry[];
|
|
62
|
+
} | {
|
|
63
|
+
type: 'opening';
|
|
64
|
+
expired: readonly string[];
|
|
53
65
|
} | ({
|
|
54
66
|
type: 'turn';
|
|
55
67
|
conversation_id: string;
|
|
@@ -74,13 +86,31 @@ export type HouseStreamFrame = {
|
|
|
74
86
|
type: 'options';
|
|
75
87
|
conversation_id: string;
|
|
76
88
|
options: LiveFact<'options'>['options'];
|
|
89
|
+
} | {
|
|
90
|
+
type: 'conversations';
|
|
91
|
+
conversations: readonly HouseListedConversation[];
|
|
92
|
+
} | {
|
|
93
|
+
type: 'conversation';
|
|
94
|
+
conversation: HouseListedConversation;
|
|
95
|
+
} | {
|
|
96
|
+
type: 'conversation_deleted';
|
|
97
|
+
conversation_id: string;
|
|
77
98
|
} | {
|
|
78
99
|
type: 'signal';
|
|
79
100
|
service_mode: string;
|
|
80
101
|
};
|
|
102
|
+
export type HouseHeldRoom = {
|
|
103
|
+
authority: string;
|
|
104
|
+
position: string;
|
|
105
|
+
log_epoch: string;
|
|
106
|
+
};
|
|
107
|
+
export type HouseOpening = {
|
|
108
|
+
hold(rooms: readonly HouseHeldRoom[], runtime: string): void;
|
|
109
|
+
};
|
|
81
110
|
export type HouseStream = {
|
|
82
111
|
observe(receive: (frame: HouseStreamFrame) => void): () => void;
|
|
83
|
-
opened(notify: () => void): () => void;
|
|
112
|
+
opened(notify: (opening: HouseOpening) => void): () => void;
|
|
113
|
+
closed(notify: (revoked: boolean) => void): () => void;
|
|
84
114
|
};
|
|
85
115
|
export type HouseDoor = {
|
|
86
116
|
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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are 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":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EAEX,aAAa,EAEb,cAAc,
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EAEX,aAAa,EAEb,cAAc,EAEd,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,C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AAI,EAAE,UAAU,CAAA;CAAE,CAAC,GAC7C,CAAC,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GAAG;IAAE,SAAS,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,CAAC,CAAC;AAE/F,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,gBAAgB,CA2DlB;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
|
@@ -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-cca5d676bc88e",
|
|
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-c68e2039f1ca8",
|
|
29
|
+
"@agentshouse/mdruntime": "0.1.0-cf6041a06849c"
|
|
30
30
|
}
|
|
31
31
|
}
|