@agentshouse/mdruntime 0.1.0-c7bd7ca3faee4 → 0.1.0-c89fa07b05d4b
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 +259 -216
- package/README.md +11 -1
- package/dist/adapter.d.ts +66 -16
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attempt.d.ts +16 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +70 -0
- package/dist/binary.d.ts +23 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +17 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +109 -37
- package/dist/change-set.d.ts +2 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +48 -16
- package/dist/change.d.ts +15 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +26 -1
- package/dist/chat/acts.d.ts +33 -0
- package/dist/chat/acts.d.ts.map +1 -0
- package/dist/chat/acts.js +36 -0
- package/dist/chat/context.d.ts +3 -0
- package/dist/chat/context.d.ts.map +1 -0
- package/dist/chat/context.js +10 -0
- package/dist/chat/input.d.ts +9 -0
- package/dist/chat/input.d.ts.map +1 -0
- package/dist/chat/input.js +99 -0
- package/dist/chat/kit.d.ts +60 -0
- package/dist/chat/kit.d.ts.map +1 -0
- package/dist/chat/kit.js +123 -0
- package/dist/chat/lasting.d.ts +6 -0
- package/dist/chat/lasting.d.ts.map +1 -0
- package/dist/chat/lasting.js +19 -0
- package/dist/chat/list.d.ts +26 -0
- package/dist/chat/list.d.ts.map +1 -0
- package/dist/chat/list.js +62 -0
- package/dist/chat/markdown.d.ts +20 -0
- package/dist/chat/markdown.d.ts.map +1 -0
- package/dist/chat/markdown.js +188 -0
- package/dist/chat/message.d.ts +6 -0
- package/dist/chat/message.d.ts.map +1 -0
- package/dist/chat/message.js +192 -0
- package/dist/chat/messages.d.ts +21 -0
- package/dist/chat/messages.d.ts.map +1 -0
- package/dist/chat/messages.js +151 -0
- package/dist/chat/name.d.ts +6 -0
- package/dist/chat/name.d.ts.map +1 -0
- package/dist/chat/name.js +37 -0
- package/dist/chat/opened.d.ts +11 -0
- package/dist/chat/opened.d.ts.map +1 -0
- package/dist/chat/opened.js +17 -0
- package/dist/chat/overlay.d.ts +31 -0
- package/dist/chat/overlay.d.ts.map +1 -0
- package/dist/chat/overlay.js +97 -0
- package/dist/chat/parts.d.ts +57 -0
- package/dist/chat/parts.d.ts.map +1 -0
- package/dist/chat/parts.js +119 -0
- package/dist/chat/process.d.ts +20 -0
- package/dist/chat/process.d.ts.map +1 -0
- package/dist/chat/process.js +32 -0
- package/dist/chat/provider.d.ts +63 -0
- package/dist/chat/provider.d.ts.map +1 -0
- package/dist/chat/provider.js +620 -0
- package/dist/chat/question.d.ts +9 -0
- package/dist/chat/question.d.ts.map +1 -0
- package/dist/chat/question.js +80 -0
- package/dist/chat/questions.d.ts +31 -0
- package/dist/chat/questions.d.ts.map +1 -0
- package/dist/chat/questions.js +111 -0
- package/dist/chat/read.d.ts +5 -0
- package/dist/chat/read.d.ts.map +1 -0
- package/dist/chat/read.js +13 -0
- package/dist/chat/ready.d.ts +33 -0
- package/dist/chat/ready.d.ts.map +1 -0
- package/dist/chat/ready.js +91 -0
- package/dist/chat/style.d.ts +4 -0
- package/dist/chat/style.d.ts.map +1 -0
- package/dist/chat/style.js +302 -0
- package/dist/chat.d.ts +14 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +8 -0
- package/dist/client.d.ts +18 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +31 -16
- package/dist/collection.d.ts +21 -12
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +271 -23
- package/dist/connection.d.ts +28 -14
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1218 -370
- package/dist/conversation.d.ts +23 -10
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +304 -136
- package/dist/entry.d.ts +17 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +156 -0
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/host.d.ts +4 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +17 -13
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +19 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/memory.d.ts +4 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +63 -21
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +9 -0
- package/dist/observation.d.ts +5 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +22 -11
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/outcome.d.ts +32 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +42 -1
- package/dist/overlay.d.ts +15 -3
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +94 -77
- package/dist/query.d.ts +32 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -0
- package/dist/reach.d.ts +2 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +45 -21
- package/dist/react.d.ts +7 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +3 -2
- package/dist/read-side.d.ts +13 -6
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +291 -85
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +197 -0
- package/dist/refresh.d.ts +10 -0
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +43 -38
- package/dist/replica.d.ts +8 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +114 -67
- package/dist/room-draft.d.ts +26 -9
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +132 -23
- package/dist/rows.d.ts +8 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +12 -14
- package/dist/save.d.ts +31 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +376 -45
- package/dist/search.d.ts +31 -8
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +109 -44
- package/dist/shared.d.ts +11 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +368 -0
- package/dist/status.d.ts +2 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -8
- package/dist/store.d.ts +64 -18
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +494 -195
- package/dist/turn.d.ts +7 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +45 -0
- package/dist/wire.d.ts +6 -3
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +14 -2
- package/package.json +26 -14
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
package/dist/collection.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { parse, validate, VERSION, } from '@agentshouse/mdmodel';
|
|
1
|
+
import { checkDocument, parseFrontmatter, references, sectionReferences, target, parse, resolves, validate, VERSION, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { beneath, normalize } from './paths.js';
|
|
3
|
+
import { sameTyping } from './model.js';
|
|
4
|
+
import { differing, patched, shared } from './shared.js';
|
|
5
|
+
import { inUnits, ROW_WEIGHT } from './turn.js';
|
|
3
6
|
export const MD_MODEL = { identity: '@agentshouse/mdmodel', version: VERSION };
|
|
4
7
|
const NO_TYPES = { types: {} };
|
|
5
8
|
function selected(composition, path) {
|
|
@@ -11,30 +14,81 @@ export function governing(composition, path) {
|
|
|
11
14
|
? composition.selection.model
|
|
12
15
|
: composition.model;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const parsedIn = new WeakMap();
|
|
18
|
+
function carried(previous, text) {
|
|
19
|
+
const held = parsedIn.get(previous);
|
|
20
|
+
if (held === undefined)
|
|
21
|
+
return shared({});
|
|
22
|
+
const kept = patched(held.base, held.added);
|
|
23
|
+
held.base = kept;
|
|
24
|
+
held.added = new Map();
|
|
25
|
+
return patched(kept, [], differing(previous.text, text));
|
|
26
|
+
}
|
|
27
|
+
function cachedIn(collection, path) {
|
|
28
|
+
const held = parsedIn.get(collection);
|
|
29
|
+
if (held === undefined)
|
|
30
|
+
return undefined;
|
|
31
|
+
if (held.added.has(path))
|
|
32
|
+
return held.added.get(path);
|
|
33
|
+
return Object.hasOwn(held.base, path) ? held.base[path] : undefined;
|
|
34
|
+
}
|
|
35
|
+
export function collectionOf(text, composition, previous) {
|
|
36
|
+
const parsed = {
|
|
37
|
+
base: previous === undefined ? shared({}) : carried(previous, text),
|
|
38
|
+
added: new Map(),
|
|
39
|
+
};
|
|
40
|
+
const collection = {
|
|
41
|
+
text,
|
|
42
|
+
composition,
|
|
43
|
+
document(path) {
|
|
44
|
+
const held = cachedIn(collection, path);
|
|
45
|
+
if (held !== undefined)
|
|
46
|
+
return held ?? undefined;
|
|
47
|
+
const content = text[path];
|
|
48
|
+
if (content === undefined)
|
|
49
|
+
return undefined;
|
|
50
|
+
const read = parse(content, path);
|
|
51
|
+
parsed.added.set(path, read.ok ? read.document : null);
|
|
52
|
+
return read.ok ? read.document : undefined;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
parsedIn.set(collection, parsed);
|
|
56
|
+
return collection;
|
|
57
|
+
}
|
|
58
|
+
export function passingFrontmatter(collection, path) {
|
|
59
|
+
const held = cachedIn(collection, path);
|
|
60
|
+
if (held !== undefined)
|
|
61
|
+
return held ?? undefined;
|
|
62
|
+
const content = collection.text[path];
|
|
63
|
+
if (content === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
const read = parseFrontmatter(content, path);
|
|
66
|
+
return read.ok ? read.frontmatter : undefined;
|
|
67
|
+
}
|
|
68
|
+
export function* documentsOf(collection) {
|
|
69
|
+
for (const path of Object.keys(collection.text).sort()) {
|
|
70
|
+
const held = cachedIn(collection, path);
|
|
71
|
+
if (held === null)
|
|
72
|
+
continue;
|
|
73
|
+
if (held !== undefined) {
|
|
74
|
+
yield [path, held];
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const read = parse(collection.text[path], path);
|
|
78
|
+
if (read.ok)
|
|
79
|
+
yield [path, read.document];
|
|
26
80
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
81
|
+
}
|
|
82
|
+
export function unreadable(text, previous) {
|
|
83
|
+
const paths = previous === undefined
|
|
84
|
+
? Object.keys(text)
|
|
85
|
+
: [...differing(previous, text)].filter((path) => text[path] !== undefined);
|
|
86
|
+
for (const path of paths.sort()) {
|
|
87
|
+
const read = parse(text[path], path);
|
|
88
|
+
if (!read.ok)
|
|
89
|
+
return { kind: 'refused', refusal: read.refusal };
|
|
36
90
|
}
|
|
37
|
-
return
|
|
91
|
+
return null;
|
|
38
92
|
}
|
|
39
93
|
export function validRoot(root) {
|
|
40
94
|
return typeof root === 'string' && normalize(root) === root;
|
|
@@ -70,3 +124,197 @@ export function validateCollection(text, binaryTargets, composition) {
|
|
|
70
124
|
return verdicts[0];
|
|
71
125
|
return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];
|
|
72
126
|
}
|
|
127
|
+
const referrersOf = new WeakMap();
|
|
128
|
+
function typing(left, right) {
|
|
129
|
+
return (sameTyping(left.model, right.model) &&
|
|
130
|
+
(left.selection === null || right.selection === null
|
|
131
|
+
? left.selection === right.selection
|
|
132
|
+
: sameTyping(left.selection.model, right.selection.model)) &&
|
|
133
|
+
JSON.stringify(left.selection?.roots ?? null) === JSON.stringify(right.selection?.roots ?? null));
|
|
134
|
+
}
|
|
135
|
+
function declared(content) {
|
|
136
|
+
if (content === undefined)
|
|
137
|
+
return undefined;
|
|
138
|
+
const read = parseFrontmatter(content);
|
|
139
|
+
return read.ok ? (read.frontmatter.type ?? 'any') : undefined;
|
|
140
|
+
}
|
|
141
|
+
function typedIn(content) {
|
|
142
|
+
const type = declared(content);
|
|
143
|
+
return type !== undefined && type !== 'any';
|
|
144
|
+
}
|
|
145
|
+
function modelOf(composition, path) {
|
|
146
|
+
const model = governing(composition, path);
|
|
147
|
+
return model.status === 'unavailable' ? null : { types: model.types };
|
|
148
|
+
}
|
|
149
|
+
function checked(path, content, composition) {
|
|
150
|
+
return checkDocument(path, content, modelOf(composition, path) ?? NO_TYPES);
|
|
151
|
+
}
|
|
152
|
+
function targetsOf(check) {
|
|
153
|
+
if (!check.ok)
|
|
154
|
+
return [];
|
|
155
|
+
return [...new Set(check.references.flatMap(({ target }) => (target === null ? [] : [target])))];
|
|
156
|
+
}
|
|
157
|
+
function referencedBy(path, content, composition) {
|
|
158
|
+
const model = modelOf(composition, path);
|
|
159
|
+
if (model === null)
|
|
160
|
+
return [];
|
|
161
|
+
const read = parseFrontmatter(content, path);
|
|
162
|
+
const type = read.ok ? read.frontmatter.type : undefined;
|
|
163
|
+
if (!read.ok || type === undefined || !Object.hasOwn(model.types, type))
|
|
164
|
+
return [];
|
|
165
|
+
const definition = model.types[type];
|
|
166
|
+
return [
|
|
167
|
+
...new Set([
|
|
168
|
+
...references(read.frontmatter, definition).flatMap(({ value }) => {
|
|
169
|
+
const found = target(path, value);
|
|
170
|
+
return found === null ? [] : [found];
|
|
171
|
+
}),
|
|
172
|
+
...sectionReferences(path, content, definition).flatMap(({ target }) => target === null ? [] : [target]),
|
|
173
|
+
]),
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
function reindexed(index, changed) {
|
|
177
|
+
const referrers = new Map();
|
|
178
|
+
const touch = (target) => {
|
|
179
|
+
let held = referrers.get(target);
|
|
180
|
+
if (held === undefined) {
|
|
181
|
+
held = new Set(Object.hasOwn(index.referrers, target) ? index.referrers[target] : []);
|
|
182
|
+
referrers.set(target, held);
|
|
183
|
+
}
|
|
184
|
+
return held;
|
|
185
|
+
};
|
|
186
|
+
for (const [path, found] of changed) {
|
|
187
|
+
const before = Object.hasOwn(index.targets, path) ? index.targets[path] : [];
|
|
188
|
+
for (const target of before)
|
|
189
|
+
touch(target).delete(path);
|
|
190
|
+
for (const target of found)
|
|
191
|
+
touch(target).add(path);
|
|
192
|
+
}
|
|
193
|
+
const emptied = [...referrers].filter(([, held]) => held.size === 0).map(([target]) => target);
|
|
194
|
+
return {
|
|
195
|
+
composition: index.composition,
|
|
196
|
+
targets: patched(index.targets, [...changed].filter(([, found]) => found.length > 0), [...changed].filter(([, found]) => found.length === 0).map(([path]) => path)),
|
|
197
|
+
referrers: patched(index.referrers, [...referrers]
|
|
198
|
+
.filter(([, held]) => held.size > 0)
|
|
199
|
+
.map(([target, held]) => [target, [...held]]), emptied),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function heldIndex(held, composition) {
|
|
203
|
+
const index = referrersOf.get(held.text);
|
|
204
|
+
return index !== undefined && typing(index.composition, composition) ? index : null;
|
|
205
|
+
}
|
|
206
|
+
const indexing = new WeakMap();
|
|
207
|
+
export function indexReferrers(held, composition) {
|
|
208
|
+
if (heldIndex(held, composition) !== null)
|
|
209
|
+
return;
|
|
210
|
+
const running = indexing.get(held.text);
|
|
211
|
+
if (running !== undefined)
|
|
212
|
+
return running;
|
|
213
|
+
const targets = new Map();
|
|
214
|
+
const referrers = new Map();
|
|
215
|
+
const filled = inUnits(Object.keys(held.text), (path) => {
|
|
216
|
+
const content = held.text[path];
|
|
217
|
+
const found = referencedBy(path, content, composition);
|
|
218
|
+
if (found.length > 0)
|
|
219
|
+
targets.set(path, found);
|
|
220
|
+
for (const target of found)
|
|
221
|
+
referrers.set(target, [...(referrers.get(target) ?? []), path]);
|
|
222
|
+
return ROW_WEIGHT + content.length;
|
|
223
|
+
});
|
|
224
|
+
const indexed = () => {
|
|
225
|
+
referrersOf.set(held.text, {
|
|
226
|
+
composition,
|
|
227
|
+
targets: patched(shared({}), targets),
|
|
228
|
+
referrers: patched(shared({}), referrers),
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
if (!(filled instanceof Promise))
|
|
232
|
+
return indexed();
|
|
233
|
+
const building = filled.then(indexed).finally(() => indexing.delete(held.text));
|
|
234
|
+
indexing.set(held.text, building);
|
|
235
|
+
return building;
|
|
236
|
+
}
|
|
237
|
+
export function referencesIndexed(held, composition) {
|
|
238
|
+
return heldIndex(held, composition) !== null;
|
|
239
|
+
}
|
|
240
|
+
export function referring(held, composition, targets) {
|
|
241
|
+
const index = heldIndex(held, composition);
|
|
242
|
+
if (index === null)
|
|
243
|
+
return null;
|
|
244
|
+
const found = new Set();
|
|
245
|
+
for (const target of targets) {
|
|
246
|
+
if (!Object.hasOwn(index.referrers, target))
|
|
247
|
+
continue;
|
|
248
|
+
for (const file of index.referrers[target])
|
|
249
|
+
found.add(file);
|
|
250
|
+
}
|
|
251
|
+
return found;
|
|
252
|
+
}
|
|
253
|
+
export function available(composition) {
|
|
254
|
+
return (composition.model.status !== 'unavailable' &&
|
|
255
|
+
(composition.selection === null || composition.selection.model.status !== 'unavailable'));
|
|
256
|
+
}
|
|
257
|
+
export function changedCleanly(next, previous, composition) {
|
|
258
|
+
if (!typing(previous.composition, composition))
|
|
259
|
+
return false;
|
|
260
|
+
const paths = new Set([
|
|
261
|
+
...differing(previous.text, next.text),
|
|
262
|
+
...differing(previous.binaries, next.binaries, () => true),
|
|
263
|
+
]);
|
|
264
|
+
const binary = (path) => Object.hasOwn(next.binaries, path);
|
|
265
|
+
const within = (file) => (path) => selected(composition, path) === selected(composition, file);
|
|
266
|
+
const reaching = (file, check) => {
|
|
267
|
+
if (!check.ok)
|
|
268
|
+
return false;
|
|
269
|
+
const part = within(file);
|
|
270
|
+
return check.references.every((reference) => resolves(reference, (path) => (part(path) ? declared(next.text[path]) : undefined), (path) => part(path) && binary(path)));
|
|
271
|
+
};
|
|
272
|
+
const changedTargets = new Map();
|
|
273
|
+
const shifted = [];
|
|
274
|
+
for (const path of paths) {
|
|
275
|
+
const now = next.text[path];
|
|
276
|
+
const was = previous.text[path];
|
|
277
|
+
const modeled = modelOf(composition, path) !== null;
|
|
278
|
+
if ((now === undefined) !== (was === undefined) ||
|
|
279
|
+
declared(now) !== declared(was) ||
|
|
280
|
+
binary(path) !== Object.hasOwn(previous.binaries, path)) {
|
|
281
|
+
shifted.push(path);
|
|
282
|
+
}
|
|
283
|
+
if (!modeled && typedIn(was) && !typedIn(now))
|
|
284
|
+
return false;
|
|
285
|
+
if (now === undefined) {
|
|
286
|
+
if (modeled)
|
|
287
|
+
changedTargets.set(path, []);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (binary(path))
|
|
291
|
+
return false;
|
|
292
|
+
if (!modeled) {
|
|
293
|
+
if (declared(now) === undefined)
|
|
294
|
+
return false;
|
|
295
|
+
if (!typedIn(now) && !checked(path, now, composition).ok)
|
|
296
|
+
return false;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const check = checked(path, now, composition);
|
|
300
|
+
if (!reaching(path, check))
|
|
301
|
+
return false;
|
|
302
|
+
changedTargets.set(path, targetsOf(check));
|
|
303
|
+
}
|
|
304
|
+
const index = heldIndex(previous, composition);
|
|
305
|
+
if (index === null && shifted.length > 0)
|
|
306
|
+
return false;
|
|
307
|
+
for (const target of shifted) {
|
|
308
|
+
const files = index !== null && Object.hasOwn(index.referrers, target) ? index.referrers[target] : [];
|
|
309
|
+
for (const file of files) {
|
|
310
|
+
if (paths.has(file))
|
|
311
|
+
continue;
|
|
312
|
+
if (!reaching(file, checked(file, next.text[file], composition)))
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (index !== null) {
|
|
317
|
+
referrersOf.set(next.text, changedTargets.size === 0 ? index : reindexed(index, changedTargets));
|
|
318
|
+
}
|
|
319
|
+
return true;
|
|
320
|
+
}
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { type TypesResult } from './model.js';
|
|
2
2
|
import { type Observation } from './observation.js';
|
|
3
|
-
import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult } from './query.js';
|
|
3
|
+
import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult, type PendingResult } from './query.js';
|
|
4
4
|
import { type SearchRequest, type SearchResult } from './search.js';
|
|
5
|
-
import { type Adapter, type Authorization, type
|
|
6
|
-
import { type ChatDraftSurface, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
7
|
-
import type
|
|
8
|
-
import type {
|
|
5
|
+
import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
|
|
6
|
+
import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
7
|
+
import { type WrittenBy } from './change.js';
|
|
8
|
+
import type { Open } from './open.js';
|
|
9
|
+
import { type BinaryReference } from './binary.js';
|
|
10
|
+
import { type BinaryAnswer, type CallResult, type HistoryAnswer, type QueueEntry } from './outcome.js';
|
|
11
|
+
import { type Recovery } from './recovery.js';
|
|
9
12
|
import { type SaveRefusal } from './save.js';
|
|
10
13
|
import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
|
|
11
14
|
import { type SyncStatus } from './status.js';
|
|
@@ -25,7 +28,7 @@ export type AppRoom = {
|
|
|
25
28
|
typedSelection: AppTypedSelection | null;
|
|
26
29
|
providerOwnedPaths: readonly string[];
|
|
27
30
|
roomVersion: string | null;
|
|
28
|
-
|
|
31
|
+
documents: number;
|
|
29
32
|
synchronizationAvailable: boolean;
|
|
30
33
|
refusal: ProviderRefusal | null;
|
|
31
34
|
};
|
|
@@ -33,9 +36,11 @@ export type RoomSchemas = {
|
|
|
33
36
|
collection: TypesResult;
|
|
34
37
|
typedSelection: TypesResult | null;
|
|
35
38
|
};
|
|
36
|
-
|
|
39
|
+
type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
|
|
40
|
+
export type ConnectionRefusalCode = Open<RefusalReason>;
|
|
37
41
|
export type ConnectionRefusal = {
|
|
38
|
-
|
|
42
|
+
code: ConnectionRefusalCode;
|
|
43
|
+
retryable: boolean;
|
|
39
44
|
reauthorizationOffered: boolean;
|
|
40
45
|
refusal: ProviderRefusal | null;
|
|
41
46
|
};
|
|
@@ -44,6 +49,7 @@ export type MdRuntimeOptions = {
|
|
|
44
49
|
shell: RuntimeShell;
|
|
45
50
|
authorization?: Authorization;
|
|
46
51
|
signal?: AbortSignal;
|
|
52
|
+
recovery?: Recovery;
|
|
47
53
|
};
|
|
48
54
|
export type SaveResult = {
|
|
49
55
|
outcome: 'saved';
|
|
@@ -65,6 +71,10 @@ export type PresentationSurface = {
|
|
|
65
71
|
read(app: string): Promise<unknown>;
|
|
66
72
|
write(app: string, value: unknown): Promise<void>;
|
|
67
73
|
};
|
|
74
|
+
export type BinaryFileSurface = {
|
|
75
|
+
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
76
|
+
readReference(reference: BinaryReference): Promise<BinaryAnswer>;
|
|
77
|
+
};
|
|
68
78
|
export type HistoryQuery = {
|
|
69
79
|
revision?: string;
|
|
70
80
|
pageToken?: string;
|
|
@@ -73,8 +83,8 @@ export type MdRuntime = {
|
|
|
73
83
|
loaded(): Promise<void>;
|
|
74
84
|
rooms(): readonly AppRoom[];
|
|
75
85
|
query: {
|
|
76
|
-
(query: DocumentQuery): Promise<DocumentResult>;
|
|
77
|
-
(query: GroupQuery): Promise<GroupResult>;
|
|
86
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
87
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
78
88
|
};
|
|
79
89
|
search(request: SearchRequest): Promise<SearchResult>;
|
|
80
90
|
types(locator: string): RoomSchemas;
|
|
@@ -83,7 +93,8 @@ export type MdRuntime = {
|
|
|
83
93
|
chatDraft: ChatDraftSurface;
|
|
84
94
|
presentation: PresentationSurface;
|
|
85
95
|
save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
86
|
-
history(locator: string, path: string, query?: HistoryQuery): Promise<
|
|
96
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
97
|
+
binaryFile: BinaryFileSurface;
|
|
87
98
|
call(name: string, input: unknown): Promise<CallResult>;
|
|
88
99
|
reached(locator: string, roomVersion: string, path?: string): boolean;
|
|
89
100
|
log(): string;
|
|
@@ -95,20 +106,23 @@ export type MdRuntime = {
|
|
|
95
106
|
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
96
107
|
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
97
108
|
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
98
|
-
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
|
|
99
|
-
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
|
|
109
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
110
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
100
111
|
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
101
112
|
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
102
113
|
(topic: 'presentation', app: string): Promise<Observation<unknown>>;
|
|
103
114
|
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
104
115
|
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
116
|
+
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
105
117
|
};
|
|
106
118
|
reauthorize(): Promise<void>;
|
|
107
119
|
};
|
|
108
|
-
export type RuntimeTopic = 'rooms' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations';
|
|
120
|
+
export type RuntimeTopic = 'rooms' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
|
|
109
121
|
export type ComposedRuntime = RuntimeView & {
|
|
110
122
|
stop(): Promise<void>;
|
|
123
|
+
lose(locators: readonly string[]): Promise<void>;
|
|
111
124
|
within(reach: PortReach | null): NarrowedView;
|
|
112
125
|
};
|
|
113
126
|
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
127
|
+
export {};
|
|
114
128
|
//# sourceMappingURL=connection.d.ts.map
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAa,KAAK,WAAW,E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