@agentshouse/mdruntime-adapter 0.1.0-alpha.9 → 0.1.0-c0074032f9909
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/README.md +32 -0
- package/dist/actions.d.ts +8 -16
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +43 -436
- package/dist/adapter.d.ts +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +352 -231
- package/dist/authored-path.d.ts +9 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +34 -0
- package/dist/chunks.d.ts +36 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +281 -0
- package/dist/digest.d.ts +0 -1
- package/dist/digest.js +1 -5
- package/dist/discovery.d.ts +49 -42
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +317 -232
- package/dist/history.d.ts +6 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +85 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/map.d.ts +2 -3
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +6 -7
- package/dist/model.d.ts +8 -19
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +43 -57
- package/dist/read.d.ts +65 -54
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +217 -295
- package/dist/refusal.d.ts +7 -11
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +53 -69
- package/dist/search.d.ts +4 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +47 -0
- package/dist/session-content/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +103 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/site.d.ts +1 -2
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +142 -172
- package/dist/space-schema.d.ts +6 -0
- package/dist/space-schema.d.ts.map +1 -0
- package/dist/space-schema.js +11 -0
- package/dist/stream.d.ts +20 -9
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +394 -236
- package/dist/transport.d.ts +172 -47
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +58 -12
- package/dist/uncertain.d.ts +5 -0
- package/dist/uncertain.d.ts.map +1 -0
- package/dist/uncertain.js +11 -0
- package/dist/upload.d.ts +13 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +65 -0
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +32 -18
- package/dist/write.d.ts +24 -11
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +263 -241
- package/package.json +10 -14
- package/AGENTS.md +0 -79
- package/dist/actions.js.map +0 -1
- package/dist/adapter.js.map +0 -1
- package/dist/digest.js.map +0 -1
- package/dist/discovery.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/map.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/read.js.map +0 -1
- package/dist/refusal.js.map +0 -1
- package/dist/site.js.map +0 -1
- package/dist/stream.js.map +0 -1
- package/dist/transport.js.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/write.js.map +0 -1
package/dist/read.js
CHANGED
|
@@ -1,326 +1,248 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const ROOM_README = 'ROOM.md';
|
|
7
|
-
export function selectionRoots(tracked) {
|
|
8
|
-
if (tracked.handle === undefined) {
|
|
9
|
-
return [
|
|
10
|
-
tracked.collectionRoot,
|
|
11
|
-
...PROVIDER_SELECTION_ROOTS
|
|
12
|
-
];
|
|
13
|
-
}
|
|
14
|
-
return [
|
|
15
|
-
ROOM_README,
|
|
16
|
-
tracked.collectionRoot
|
|
17
|
-
];
|
|
1
|
+
import { patching, ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
2
|
+
import { REVISION_REFERENCE_PATTERN } from '@agentshouse/mdmodel';
|
|
3
|
+
import { roomVersion } from './version.js';
|
|
4
|
+
function fileOf(revision) {
|
|
5
|
+
return REVISION_REFERENCE_PATTERN.exec(revision)?.[1];
|
|
18
6
|
}
|
|
19
|
-
export function
|
|
20
|
-
const root = authorityRoot(tracked.handle);
|
|
21
|
-
return selectionRoots(tracked).filter((entry)=>entry !== ROOM_README).map((entry)=>`${root}/${entry}`);
|
|
22
|
-
}
|
|
23
|
-
export function modelPrefix(tracked, modelRoot) {
|
|
24
|
-
return `${authorityRoot(tracked.handle)}/${modelRoot}`;
|
|
25
|
-
}
|
|
26
|
-
export function parseGrant(body) {
|
|
27
|
-
if (typeof body !== 'object' || body === null) return null;
|
|
28
|
-
if (!('transfer' in body) || typeof body.transfer !== 'object' || body.transfer === null) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const transfer = body.transfer;
|
|
32
|
-
if (transfer.method !== 'GET' && transfer.method !== 'POST') return null;
|
|
33
|
-
if (typeof transfer.operation !== 'string' || typeof transfer.url !== 'string') return null;
|
|
7
|
+
export function answering() {
|
|
34
8
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (typeof file.sha256 !== 'string') return null;
|
|
46
|
-
return {
|
|
47
|
-
path: file.path,
|
|
48
|
-
revision: undefined,
|
|
49
|
-
version: file.sha256
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (typeof file.revision !== 'string') return null;
|
|
53
|
-
return {
|
|
54
|
-
path: file.path,
|
|
55
|
-
revision: file.revision,
|
|
56
|
-
version: file.revision
|
|
9
|
+
documents: new Map(),
|
|
10
|
+
facts: new Map(),
|
|
11
|
+
revisions: new Map(),
|
|
12
|
+
fileIds: new Map(),
|
|
13
|
+
created: new Map(),
|
|
14
|
+
changes: new Map(),
|
|
15
|
+
binaryFiles: new Map(),
|
|
16
|
+
removals: new Set(),
|
|
17
|
+
folders: new Set(),
|
|
18
|
+
folderRemovals: new Set(),
|
|
57
19
|
};
|
|
58
20
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
21
|
+
export function revised(answer, path, revision) {
|
|
22
|
+
answer.revisions.set(path, revision);
|
|
23
|
+
const file = fileOf(revision);
|
|
24
|
+
if (file !== undefined)
|
|
25
|
+
answer.fileIds.set(path, file);
|
|
26
|
+
}
|
|
27
|
+
export function forgotten(answer, path) {
|
|
28
|
+
answer.documents.delete(path);
|
|
29
|
+
answer.facts.delete(path);
|
|
30
|
+
answer.revisions.delete(path);
|
|
31
|
+
answer.fileIds.delete(path);
|
|
32
|
+
answer.created.delete(path);
|
|
33
|
+
answer.changes.delete(path);
|
|
34
|
+
answer.binaryFiles.delete(path);
|
|
35
|
+
answer.removals.delete(path);
|
|
36
|
+
}
|
|
37
|
+
export function folded(answer, path, removed) {
|
|
38
|
+
if (removed) {
|
|
39
|
+
answer.folders.delete(path);
|
|
40
|
+
answer.folderRemovals.add(path);
|
|
74
41
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const content = entry;
|
|
79
|
-
if (typeof content.path !== 'string' || typeof content.content !== 'string') return null;
|
|
80
|
-
contents.push({
|
|
81
|
-
path: content.path,
|
|
82
|
-
content: content.content
|
|
83
|
-
});
|
|
42
|
+
else {
|
|
43
|
+
answer.folderRemovals.delete(path);
|
|
44
|
+
answer.folders.add(path);
|
|
84
45
|
}
|
|
85
|
-
return {
|
|
86
|
-
scope: manifest.scope,
|
|
87
|
-
anchor: manifest.anchor,
|
|
88
|
-
roomHandle: typeof manifest.room_handle === 'string' ? manifest.room_handle : undefined,
|
|
89
|
-
...at,
|
|
90
|
-
files,
|
|
91
|
-
contents
|
|
92
|
-
};
|
|
93
46
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const scope = parseScope(entry, 'credential');
|
|
100
|
-
if (scope === null) return null;
|
|
101
|
-
scopes.push(scope);
|
|
47
|
+
function* pathsOf(paths) {
|
|
48
|
+
const list = [];
|
|
49
|
+
for (const path of paths) {
|
|
50
|
+
list.push(path);
|
|
51
|
+
yield ROW_WEIGHT;
|
|
102
52
|
}
|
|
53
|
+
return list;
|
|
54
|
+
}
|
|
55
|
+
export function* answered(answer) {
|
|
56
|
+
const removals = yield* pathsOf(answer.removals);
|
|
103
57
|
return {
|
|
104
|
-
|
|
58
|
+
documents: yield* patching({}, answer.documents),
|
|
59
|
+
facts: yield* patching({}, answer.facts),
|
|
60
|
+
revisions: yield* patching({}, answer.revisions),
|
|
61
|
+
...(answer.fileIds.size === 0 ? {} : { fileIds: yield* patching({}, answer.fileIds) }),
|
|
62
|
+
...(answer.created.size === 0 ? {} : { created: yield* patching({}, answer.created) }),
|
|
63
|
+
changes: yield* patching({}, answer.changes),
|
|
64
|
+
binaryFiles: yield* patching({}, answer.binaryFiles),
|
|
65
|
+
removals,
|
|
66
|
+
...(answer.folders.size === 0 ? {} : { folders: yield* pathsOf(answer.folders) }),
|
|
67
|
+
...(answer.folderRemovals.size === 0
|
|
68
|
+
? {}
|
|
69
|
+
: { folderRemovals: yield* pathsOf(answer.folderRemovals) }),
|
|
105
70
|
};
|
|
106
71
|
}
|
|
107
|
-
export function
|
|
108
|
-
|
|
109
|
-
return scope !== null && scope.scope === 'room' ? scope : null;
|
|
72
|
+
export function authorityRoot(handle) {
|
|
73
|
+
return `/rooms/${handle}`;
|
|
110
74
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
const held = value;
|
|
114
|
-
if (typeof held.path !== 'string') return null;
|
|
115
|
-
if (held.removed === true) return {
|
|
116
|
-
path: held.path,
|
|
117
|
-
removed: true
|
|
118
|
-
};
|
|
119
|
-
if (mode === 'site') {
|
|
120
|
-
if (typeof held.content !== 'string' || typeof held.sha256 !== 'string') return null;
|
|
121
|
-
return {
|
|
122
|
-
path: held.path,
|
|
123
|
-
content: held.content,
|
|
124
|
-
revision: undefined,
|
|
125
|
-
version: held.sha256
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (typeof held.content === 'string' && typeof held.revision === 'string') {
|
|
129
|
-
return {
|
|
130
|
-
path: held.path,
|
|
131
|
-
content: held.content,
|
|
132
|
-
revision: held.revision,
|
|
133
|
-
version: held.revision
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
if (typeof held.reference === 'object' && held.reference !== null) {
|
|
137
|
-
const reference = held.reference;
|
|
138
|
-
if (typeof reference.revision !== 'string') return null;
|
|
139
|
-
return {
|
|
140
|
-
path: held.path,
|
|
141
|
-
reference: {
|
|
142
|
-
revision: reference.revision
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
return null;
|
|
75
|
+
export function schemaPath(handle, schema) {
|
|
76
|
+
return `${authorityRoot(handle)}/${schema}`;
|
|
147
77
|
}
|
|
148
|
-
export function
|
|
149
|
-
if (typeof body !== 'object' || body === null)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (typeof entry !== 'object' || entry === null) return null;
|
|
154
|
-
const held = entry;
|
|
155
|
-
const at = readPosition(held);
|
|
156
|
-
if (typeof held.authority !== 'string' || at === null) return null;
|
|
157
|
-
if (!Array.isArray(held.changes)) return null;
|
|
158
|
-
const changes = [];
|
|
159
|
-
for (const change of held.changes){
|
|
160
|
-
const mapped = parseChange(change, mode);
|
|
161
|
-
if (mapped === null) return null;
|
|
162
|
-
changes.push(mapped);
|
|
163
|
-
}
|
|
164
|
-
authorities.push({
|
|
165
|
-
authority: held.authority,
|
|
166
|
-
...at,
|
|
167
|
-
changes
|
|
168
|
-
});
|
|
78
|
+
export function parseGrant(body) {
|
|
79
|
+
if (typeof body !== 'object' || body === null)
|
|
80
|
+
return null;
|
|
81
|
+
if (!('transfer' in body) || typeof body.transfer !== 'object' || body.transfer === null) {
|
|
82
|
+
return null;
|
|
169
83
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
84
|
+
const transfer = body.transfer;
|
|
85
|
+
if (typeof transfer.url !== 'string')
|
|
86
|
+
return null;
|
|
87
|
+
if (transfer.method !== 'POST' || typeof transfer.operation !== 'string')
|
|
88
|
+
return null;
|
|
89
|
+
return { operation: transfer.operation, url: transfer.url };
|
|
173
90
|
}
|
|
174
|
-
export function
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
for (const change of view.changes){
|
|
184
|
-
files.delete(change.path);
|
|
185
|
-
contents.delete(change.path);
|
|
186
|
-
if ('removed' in change) continue;
|
|
187
|
-
if ('content' in change) {
|
|
188
|
-
files.set(change.path, {
|
|
189
|
-
path: change.path,
|
|
190
|
-
revision: change.revision,
|
|
191
|
-
version: change.version
|
|
192
|
-
});
|
|
193
|
-
contents.set(change.path, change.content);
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
const { revision } = change.reference;
|
|
197
|
-
files.set(change.path, {
|
|
198
|
-
path: change.path,
|
|
199
|
-
revision,
|
|
200
|
-
version: revision
|
|
201
|
-
});
|
|
91
|
+
export function parseFileAddress(body) {
|
|
92
|
+
if (typeof body !== 'object' || body === null)
|
|
93
|
+
return null;
|
|
94
|
+
const { download, name, sha256, media_type: mediaType } = body;
|
|
95
|
+
if (typeof download !== 'string' ||
|
|
96
|
+
typeof name !== 'string' ||
|
|
97
|
+
typeof sha256 !== 'string' ||
|
|
98
|
+
typeof mediaType !== 'string') {
|
|
99
|
+
return null;
|
|
202
100
|
}
|
|
203
|
-
return {
|
|
204
|
-
...scope,
|
|
205
|
-
position: view.position,
|
|
206
|
-
logEpoch: view.logEpoch,
|
|
207
|
-
files: [
|
|
208
|
-
...files.values()
|
|
209
|
-
],
|
|
210
|
-
contents: [
|
|
211
|
-
...contents
|
|
212
|
-
].map(([path, content])=>({
|
|
213
|
-
path,
|
|
214
|
-
content
|
|
215
|
-
}))
|
|
216
|
-
};
|
|
101
|
+
return { url: download, name, sha256, mediaType };
|
|
217
102
|
}
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
|
|
103
|
+
function changeAuthor(value) {
|
|
104
|
+
if (typeof value !== 'object' || value === null)
|
|
105
|
+
return null;
|
|
106
|
+
const { user, site, inbox, app, name } = value;
|
|
107
|
+
if (typeof name !== 'string')
|
|
108
|
+
return null;
|
|
109
|
+
const named = [user, site, inbox, app].filter((id) => id !== undefined);
|
|
110
|
+
if (named.length !== 1)
|
|
111
|
+
return null;
|
|
112
|
+
if (typeof user === 'string')
|
|
113
|
+
return { kind: 'user', id: user, name };
|
|
114
|
+
if (typeof site === 'string')
|
|
115
|
+
return { kind: 'site', id: site, name };
|
|
116
|
+
if (typeof inbox === 'string')
|
|
117
|
+
return { kind: 'inbox', id: inbox, name };
|
|
118
|
+
if (typeof app === 'string')
|
|
119
|
+
return { kind: 'app', id: app, name };
|
|
120
|
+
return null;
|
|
221
121
|
}
|
|
222
|
-
export function
|
|
223
|
-
|
|
122
|
+
export function headChange(held) {
|
|
123
|
+
const author = held.author === undefined ? null : changeAuthor(held.author);
|
|
124
|
+
if (held.author !== undefined && author === null)
|
|
125
|
+
return null;
|
|
126
|
+
if (held.changed_at === undefined)
|
|
127
|
+
return undefined;
|
|
128
|
+
if (typeof held.changed_at !== 'string')
|
|
129
|
+
return null;
|
|
130
|
+
return { author, time: held.changed_at };
|
|
224
131
|
}
|
|
225
|
-
|
|
226
|
-
if (
|
|
227
|
-
|
|
132
|
+
function createdOf(held) {
|
|
133
|
+
if (held.created_at === undefined)
|
|
134
|
+
return undefined;
|
|
135
|
+
return typeof held.created_at === 'string' ? held.created_at : null;
|
|
228
136
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (scope === undefined) return {
|
|
232
|
-
kind: 'room-not-readable',
|
|
233
|
-
locator: tracked.locator
|
|
234
|
-
};
|
|
235
|
-
return bootstrapOf(scope, tracked);
|
|
137
|
+
function createdHeld(created) {
|
|
138
|
+
return created === undefined ? {} : { created };
|
|
236
139
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (file.revision !== undefined) revisions[file.path] = file.revision;
|
|
248
|
-
const content = contents.get(file.path);
|
|
249
|
-
if (content === undefined) binaryTargets.push(file.path);
|
|
250
|
-
else documents[file.path] = content;
|
|
251
|
-
}
|
|
252
|
-
return {
|
|
253
|
-
kind: 'bootstrap',
|
|
254
|
-
roomVersion: roomVersion(scope),
|
|
255
|
-
documents,
|
|
256
|
-
revisions,
|
|
257
|
-
binaryTargets: binaryTargets.sort()
|
|
258
|
-
};
|
|
140
|
+
function headed(head) {
|
|
141
|
+
return head === undefined ? {} : { head };
|
|
142
|
+
}
|
|
143
|
+
export function binaryFileOf(held) {
|
|
144
|
+
if (held.media_type === undefined)
|
|
145
|
+
return undefined;
|
|
146
|
+
const { bytes, media_type: mediaType, sha256 } = held;
|
|
147
|
+
if (typeof bytes !== 'number' || typeof mediaType !== 'string' || typeof sha256 !== 'string')
|
|
148
|
+
return null;
|
|
149
|
+
return { byteLength: bytes, mediaType, sha256 };
|
|
259
150
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return `${MODEL_DEFINITION_ADDRESS}/${path.slice(path.lastIndexOf('/') + 1)}`;
|
|
151
|
+
function binaried(binary) {
|
|
152
|
+
return binary === undefined ? {} : { binary };
|
|
263
153
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
if (scope === undefined) return null;
|
|
267
|
-
return definitionsOf(scope, modelRoot);
|
|
154
|
+
function carriedFacts(held) {
|
|
155
|
+
return held.facts === undefined ? {} : { facts: held.facts };
|
|
268
156
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
157
|
+
function carriedSpace(held) {
|
|
158
|
+
return typeof held.space === 'string' ? { space: held.space } : {};
|
|
159
|
+
}
|
|
160
|
+
export function documentEntry(value, mode) {
|
|
161
|
+
if (typeof value !== 'object' || value === null)
|
|
162
|
+
return null;
|
|
163
|
+
const file = value;
|
|
164
|
+
if (typeof file.path !== 'string')
|
|
165
|
+
return null;
|
|
166
|
+
if (file.content !== undefined && typeof file.content !== 'string')
|
|
167
|
+
return null;
|
|
168
|
+
const head = headChange(file);
|
|
169
|
+
const created = createdOf(file);
|
|
170
|
+
const binary = binaryFileOf(file);
|
|
171
|
+
if (head === null || created === null || binary === null)
|
|
172
|
+
return null;
|
|
173
|
+
const content = file.content === undefined ? {} : { content: file.content };
|
|
174
|
+
if (mode === 'site') {
|
|
175
|
+
if (typeof file.sha256 !== 'string')
|
|
176
|
+
return null;
|
|
177
|
+
return {
|
|
178
|
+
path: file.path,
|
|
179
|
+
revision: binary?.sha256,
|
|
180
|
+
version: file.sha256,
|
|
181
|
+
...headed(head),
|
|
182
|
+
...binaried(binary),
|
|
183
|
+
...carriedFacts(file),
|
|
184
|
+
...content,
|
|
185
|
+
};
|
|
283
186
|
}
|
|
187
|
+
if (typeof file.revision !== 'string')
|
|
188
|
+
return null;
|
|
284
189
|
return {
|
|
285
|
-
|
|
286
|
-
|
|
190
|
+
path: file.path,
|
|
191
|
+
revision: file.revision,
|
|
192
|
+
version: file.revision,
|
|
193
|
+
...headed(head),
|
|
194
|
+
...createdHeld(created),
|
|
195
|
+
...binaried(binary),
|
|
196
|
+
...carriedFacts(file),
|
|
197
|
+
...carriedSpace(file),
|
|
198
|
+
...content,
|
|
287
199
|
};
|
|
288
200
|
}
|
|
289
|
-
export function
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
if ('removed' in change) {
|
|
305
|
-
removals.push(change.path);
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
if ('content' in change) {
|
|
309
|
-
documents[change.path] = change.content;
|
|
310
|
-
if (change.revision !== undefined) revisions[change.path] = change.revision;
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
binaryTargets.push(change.path);
|
|
314
|
-
revisions[change.path] = change.reference.revision;
|
|
315
|
-
}
|
|
201
|
+
export function kept(answer, file) {
|
|
202
|
+
if (file.head !== undefined)
|
|
203
|
+
answer.changes.set(file.path, file.head);
|
|
204
|
+
if (file.created !== undefined)
|
|
205
|
+
answer.created.set(file.path, file.created);
|
|
206
|
+
if (file.binary !== undefined)
|
|
207
|
+
answer.binaryFiles.set(file.path, file.binary);
|
|
208
|
+
else if (file.content !== undefined)
|
|
209
|
+
answer.documents.set(file.path, file.content);
|
|
210
|
+
if (file.binary === undefined && file.facts !== undefined)
|
|
211
|
+
answer.facts.set(file.path, file.facts);
|
|
212
|
+
if (file.revision !== undefined)
|
|
213
|
+
revised(answer, file.path, file.revision);
|
|
214
|
+
}
|
|
215
|
+
export function modelScope(room) {
|
|
316
216
|
return {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
binaryTargets: binaryTargets.sort(),
|
|
322
|
-
removals: removals.sort()
|
|
217
|
+
anchor: room.anchor,
|
|
218
|
+
position: room.position,
|
|
219
|
+
logEpoch: room.logEpoch,
|
|
220
|
+
files: room.models,
|
|
323
221
|
};
|
|
324
222
|
}
|
|
325
|
-
|
|
326
|
-
|
|
223
|
+
export function* bootstrapping(scope) {
|
|
224
|
+
const answer = answering();
|
|
225
|
+
for (const file of scope.files) {
|
|
226
|
+
yield ROW_WEIGHT;
|
|
227
|
+
if (file.space === undefined)
|
|
228
|
+
kept(answer, file);
|
|
229
|
+
}
|
|
230
|
+
for (const folder of scope.folders ?? [])
|
|
231
|
+
folded(answer, folder, false);
|
|
232
|
+
const { removals: _removals, folderRemovals: _folderRemovals, ...page } = yield* answered(answer);
|
|
233
|
+
return { kind: 'bootstrap', roomVersion: roomVersion(scope), ...page };
|
|
234
|
+
}
|
|
235
|
+
export function schemaFile(file) {
|
|
236
|
+
return file.content === undefined
|
|
237
|
+
? null
|
|
238
|
+
: {
|
|
239
|
+
schema: file.content,
|
|
240
|
+
version: file.version,
|
|
241
|
+
revision: file.revision ?? null,
|
|
242
|
+
...(file.space === undefined ? {} : { space: file.space }),
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
export function schemaOf(scope, schema) {
|
|
246
|
+
const file = scope.files.find((entry) => entry.path === schema);
|
|
247
|
+
return file === undefined ? { schema: null, version: null, revision: null } : schemaFile(file);
|
|
248
|
+
}
|
package/dist/refusal.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type { AdapterFailure, DiscoverResult, ProviderRefusal, ScopedRefusal } from '@agentshouse/mdruntime';
|
|
2
|
-
export
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare function discoveryFailure(classified: AdapterFailure | {
|
|
9
|
-
kind: 'beyond-horizon';
|
|
10
|
-
}): DiscoverResult;
|
|
11
|
-
//# sourceMappingURL=refusal.d.ts.map
|
|
1
|
+
import type { AdapterFailure, DiscoverResult, ProviderRefusal, ScopedRefusal, TransportUncertainty } from '@agentshouse/mdruntime';
|
|
2
|
+
export declare function doorRefusal(body: unknown): ProviderRefusal | null;
|
|
3
|
+
export declare function answeredFailure(status: number, body: unknown): TransportUncertainty;
|
|
4
|
+
export declare function resetOf(refusal: ProviderRefusal | null): string | undefined;
|
|
5
|
+
export declare function scopedRefusal(locator: string, scope: ScopedRefusal['scope'], refusal: ProviderRefusal): ScopedRefusal;
|
|
6
|
+
export declare function classifyDoor(status: number, body: unknown, locator: string): AdapterFailure | null;
|
|
7
|
+
export declare function discoveryFailure(status: number, body: unknown): DiscoverResult | null;
|
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,
|
|
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,EACb,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAGhC,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAOjE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,oBAAoB,CAInF;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAG3E;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,aAAa,CAEf;AAoBD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG,IAAI,CAMvB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAQrF"}
|