@agentshouse/mdruntime-adapter 0.1.0-alpha.1 → 0.1.0-alpha.3
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 +78 -0
- package/dist/actions.d.ts +16 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +454 -0
- package/dist/actions.js.map +1 -0
- package/dist/adapter.d.ts +8 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +341 -0
- package/dist/adapter.js.map +1 -0
- package/dist/digest.d.ts +3 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +11 -0
- package/dist/digest.js.map +1 -0
- package/dist/discovery.d.ts +60 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +242 -0
- package/dist/discovery.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/map.d.ts +3 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/map.js +15 -0
- package/dist/map.js.map +1 -0
- package/dist/read.d.ts +67 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +244 -0
- package/dist/read.js.map +1 -0
- package/dist/refusal.d.ts +8 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +65 -0
- package/dist/refusal.js.map +1 -0
- package/dist/stream.d.ts +10 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +239 -0
- package/dist/stream.js.map +1 -0
- package/dist/transport.d.ts +77 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +9 -0
- package/dist/transport.js.map +1 -0
- package/dist/write.d.ts +41 -0
- package/dist/write.d.ts.map +1 -0
- package/dist/write.js +377 -0
- package/dist/write.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { declaredActions, HOUSE_CONVERSATION_CARDS } from './actions.js';
|
|
2
|
+
import { PRIVATE_AUTHORITY } from './transport.js';
|
|
3
|
+
export const ROOM_CONTRACT_VERSION = 1;
|
|
4
|
+
export const MD_MODEL_IDENTITY = '@agentshouse/mdmodel';
|
|
5
|
+
export const ROOM_VERSION_NOTIFICATIONS = 'room-version-notifications';
|
|
6
|
+
export const PROVIDER_ACTIONS = 'provider-actions';
|
|
7
|
+
export const DISCOVER_PREFIXES = [
|
|
8
|
+
'/'
|
|
9
|
+
];
|
|
10
|
+
export const PROVIDER_SELECTION_ROOTS = [
|
|
11
|
+
'agents',
|
|
12
|
+
'house'
|
|
13
|
+
];
|
|
14
|
+
export const PROVIDER_SELECTION_MODEL_ROOT = 'house/settings/model';
|
|
15
|
+
const BOUND_KEYS = [
|
|
16
|
+
'max_authored_file_bytes',
|
|
17
|
+
'max_batch_operations',
|
|
18
|
+
'max_path_length',
|
|
19
|
+
'max_path_depth',
|
|
20
|
+
'max_mount_files',
|
|
21
|
+
'max_mount_bytes',
|
|
22
|
+
'change_retention_seconds',
|
|
23
|
+
'operation_retention_seconds'
|
|
24
|
+
];
|
|
25
|
+
const OPERATION_KEYS = [
|
|
26
|
+
'read',
|
|
27
|
+
'sync',
|
|
28
|
+
'write',
|
|
29
|
+
'delete'
|
|
30
|
+
];
|
|
31
|
+
function stringList(value) {
|
|
32
|
+
if (!Array.isArray(value)) return null;
|
|
33
|
+
return value.every((entry)=>typeof entry === 'string') ? value : null;
|
|
34
|
+
}
|
|
35
|
+
function parseBounds(value) {
|
|
36
|
+
if (typeof value !== 'object' || value === null) return null;
|
|
37
|
+
const held = value;
|
|
38
|
+
const bounds = {};
|
|
39
|
+
for (const key of BOUND_KEYS){
|
|
40
|
+
const amount = held[key];
|
|
41
|
+
if (typeof amount !== 'number' || !Number.isFinite(amount)) return null;
|
|
42
|
+
bounds[key] = amount;
|
|
43
|
+
}
|
|
44
|
+
return bounds;
|
|
45
|
+
}
|
|
46
|
+
function parseOperations(value) {
|
|
47
|
+
if (typeof value !== 'object' || value === null) return null;
|
|
48
|
+
const held = value;
|
|
49
|
+
const operations = {};
|
|
50
|
+
for (const key of OPERATION_KEYS){
|
|
51
|
+
const scopes = stringList(held[key]);
|
|
52
|
+
if (scopes === null) return null;
|
|
53
|
+
operations[key] = scopes;
|
|
54
|
+
}
|
|
55
|
+
return operations;
|
|
56
|
+
}
|
|
57
|
+
function parseAuthority(value) {
|
|
58
|
+
if (typeof value !== 'object' || value === null) return null;
|
|
59
|
+
const held = value;
|
|
60
|
+
if (held.kind !== 'room' && held.kind !== 'private') return null;
|
|
61
|
+
if (typeof held.name !== 'string' || held.name.length === 0) return null;
|
|
62
|
+
if (typeof held.collection_root !== 'string' || typeof held.model_root !== 'string') return null;
|
|
63
|
+
if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (typeof held.position !== 'string' || held.position.length === 0) return null;
|
|
67
|
+
const protectedPaths = stringList(held.protected_paths);
|
|
68
|
+
const operations = parseOperations(held.operations);
|
|
69
|
+
if (protectedPaths === null || operations === null) return null;
|
|
70
|
+
if (held.kind === 'private') {
|
|
71
|
+
return {
|
|
72
|
+
kind: 'private',
|
|
73
|
+
roomRef: PRIVATE_AUTHORITY,
|
|
74
|
+
roomHandle: null,
|
|
75
|
+
name: held.name,
|
|
76
|
+
collectionRoot: held.collection_root,
|
|
77
|
+
modelRoot: held.model_root,
|
|
78
|
+
managedReplication: held.managed_replication,
|
|
79
|
+
protectedPaths,
|
|
80
|
+
operations,
|
|
81
|
+
position: held.position
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;
|
|
85
|
+
if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;
|
|
86
|
+
return {
|
|
87
|
+
kind: 'room',
|
|
88
|
+
roomRef: held.room_ref,
|
|
89
|
+
roomHandle: held.room_handle,
|
|
90
|
+
name: held.name,
|
|
91
|
+
collectionRoot: held.collection_root,
|
|
92
|
+
modelRoot: held.model_root,
|
|
93
|
+
managedReplication: held.managed_replication,
|
|
94
|
+
protectedPaths,
|
|
95
|
+
operations,
|
|
96
|
+
position: held.position
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export function parseDiscovery(body) {
|
|
100
|
+
if (typeof body !== 'object' || body === null) return null;
|
|
101
|
+
const held = body;
|
|
102
|
+
const bounds = parseBounds(held.bounds);
|
|
103
|
+
if (bounds === null) return null;
|
|
104
|
+
if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0) return null;
|
|
105
|
+
if (!Array.isArray(held.authorities)) return null;
|
|
106
|
+
const authorities = [];
|
|
107
|
+
for (const entry of held.authorities){
|
|
108
|
+
const authority = parseAuthority(entry);
|
|
109
|
+
if (authority === null) return null;
|
|
110
|
+
authorities.push(authority);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
bounds,
|
|
114
|
+
mdModelVersion: held.md_model_version,
|
|
115
|
+
authorities
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function locatorOf(authority) {
|
|
119
|
+
return authority.roomHandle ?? PRIVATE_AUTHORITY;
|
|
120
|
+
}
|
|
121
|
+
export function trackedFrom(document) {
|
|
122
|
+
return document.authorities.map((authority)=>({
|
|
123
|
+
locator: locatorOf(authority),
|
|
124
|
+
authority: authority.roomRef,
|
|
125
|
+
handle: authority.roomHandle ?? undefined,
|
|
126
|
+
collectionRoot: authority.collectionRoot,
|
|
127
|
+
modelRoot: authority.modelRoot,
|
|
128
|
+
modelRoots: authority.kind === 'private' ? [
|
|
129
|
+
authority.modelRoot,
|
|
130
|
+
PROVIDER_SELECTION_MODEL_ROOT
|
|
131
|
+
] : [
|
|
132
|
+
authority.modelRoot
|
|
133
|
+
],
|
|
134
|
+
roomVersion: authority.position
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
export function providerLimits(bounds) {
|
|
138
|
+
return [
|
|
139
|
+
{
|
|
140
|
+
name: 'document-size',
|
|
141
|
+
value: bounds.max_authored_file_bytes
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: 'change-batch-operations',
|
|
145
|
+
value: bounds.max_batch_operations
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'path-length',
|
|
149
|
+
value: bounds.max_path_length
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'path-depth',
|
|
153
|
+
value: bounds.max_path_depth
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'write-rate'
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'content-ceiling'
|
|
160
|
+
}
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
export function declaredRetention(bounds) {
|
|
164
|
+
return {
|
|
165
|
+
history: {
|
|
166
|
+
kind: 'no-declared-time-bound'
|
|
167
|
+
},
|
|
168
|
+
outcome: bounds.operation_retention_seconds,
|
|
169
|
+
refreshHorizon: bounds.change_retention_seconds
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
export function capabilities() {
|
|
173
|
+
return [
|
|
174
|
+
{
|
|
175
|
+
name: ROOM_VERSION_NOTIFICATIONS
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: PROVIDER_ACTIONS,
|
|
179
|
+
actions: declaredActions(),
|
|
180
|
+
conversationCards: HOUSE_CONVERSATION_CARDS
|
|
181
|
+
}
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
export function providerSelection(attachedModel) {
|
|
185
|
+
return {
|
|
186
|
+
roots: [
|
|
187
|
+
...PROVIDER_SELECTION_ROOTS
|
|
188
|
+
],
|
|
189
|
+
attachedModel
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
export function discoveredRoom(authority, attachedModel, typedSelection) {
|
|
193
|
+
return {
|
|
194
|
+
name: authority.name,
|
|
195
|
+
locator: locatorOf(authority),
|
|
196
|
+
collectionRoot: authority.collectionRoot,
|
|
197
|
+
roomVersion: authority.position,
|
|
198
|
+
operations: {
|
|
199
|
+
read: [
|
|
200
|
+
...authority.operations.read
|
|
201
|
+
],
|
|
202
|
+
sync: [
|
|
203
|
+
...authority.operations.sync
|
|
204
|
+
],
|
|
205
|
+
write: [
|
|
206
|
+
...authority.operations.write
|
|
207
|
+
],
|
|
208
|
+
delete: [
|
|
209
|
+
...authority.operations.delete
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
replica: {
|
|
213
|
+
selection: locatorOf(authority),
|
|
214
|
+
admission: authority.managedReplication
|
|
215
|
+
},
|
|
216
|
+
attachedModel,
|
|
217
|
+
...typedSelection === undefined ? {} : {
|
|
218
|
+
typedSelection
|
|
219
|
+
},
|
|
220
|
+
providerOwnedPaths: [
|
|
221
|
+
...authority.protectedPaths
|
|
222
|
+
]
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
export function mapDiscovery(document, rooms) {
|
|
226
|
+
return {
|
|
227
|
+
kind: 'discovery',
|
|
228
|
+
supportedVersions: [
|
|
229
|
+
ROOM_CONTRACT_VERSION
|
|
230
|
+
],
|
|
231
|
+
mdModel: {
|
|
232
|
+
identity: MD_MODEL_IDENTITY,
|
|
233
|
+
version: document.mdModelVersion
|
|
234
|
+
},
|
|
235
|
+
rooms,
|
|
236
|
+
capabilities: capabilities(),
|
|
237
|
+
providerLimits: providerLimits(document.bounds),
|
|
238
|
+
retention: declaredRetention(document.bounds)
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/discovery.ts"],"sourcesContent":["import type {\n Capability,\n DiscoveredRoom,\n Discovery,\n ProviderLimit,\n Retention,\n TypedSelection,\n} from '@agentshouse/mdruntime';\nimport { declaredActions, HOUSE_CONVERSATION_CARDS } from './actions.js';\nimport { PRIVATE_AUTHORITY } from './transport.js';\n\nexport const ROOM_CONTRACT_VERSION = 1;\n\nexport const MD_MODEL_IDENTITY = '@agentshouse/mdmodel';\n\nexport const ROOM_VERSION_NOTIFICATIONS = 'room-version-notifications';\n\nexport const PROVIDER_ACTIONS = 'provider-actions';\n\nexport const DISCOVER_PREFIXES: readonly string[] = ['/'];\n\nexport const PROVIDER_SELECTION_ROOTS: readonly string[] = ['agents', 'house'];\n\nexport const PROVIDER_SELECTION_MODEL_ROOT = 'house/settings/model';\n\nexport type HouseBounds = {\n max_authored_file_bytes: number;\n max_batch_operations: number;\n max_path_length: number;\n max_path_depth: number;\n max_mount_files: number;\n max_mount_bytes: number;\n change_retention_seconds: number;\n operation_retention_seconds: number;\n};\n\nexport type HouseOperations = {\n read: readonly string[];\n sync: readonly string[];\n write: readonly string[];\n delete: readonly string[];\n};\n\nexport type HouseAuthority = {\n kind: 'room' | 'private';\n roomRef: string;\n roomHandle: string | null;\n name: string;\n collectionRoot: string;\n modelRoot: string;\n managedReplication: 'admitted' | 'unavailable';\n protectedPaths: readonly string[];\n operations: HouseOperations;\n position: string;\n};\n\nexport type HouseDiscoveryDocument = {\n bounds: HouseBounds;\n mdModelVersion: string;\n authorities: readonly HouseAuthority[];\n};\n\nexport type TrackedAuthority = {\n locator: string;\n authority: string;\n handle: string | undefined;\n collectionRoot: string;\n modelRoot: string;\n modelRoots: readonly string[];\n roomVersion: string;\n};\n\nconst BOUND_KEYS: readonly (keyof HouseBounds)[] = [\n 'max_authored_file_bytes',\n 'max_batch_operations',\n 'max_path_length',\n 'max_path_depth',\n 'max_mount_files',\n 'max_mount_bytes',\n 'change_retention_seconds',\n 'operation_retention_seconds',\n];\n\nconst OPERATION_KEYS: readonly (keyof HouseOperations)[] = ['read', 'sync', 'write', 'delete'];\n\nfunction stringList(value: unknown): readonly string[] | null {\n if (!Array.isArray(value)) return null;\n return value.every((entry) => typeof entry === 'string') ? (value as string[]) : null;\n}\n\nfunction parseBounds(value: unknown): HouseBounds | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n const bounds: Partial<HouseBounds> = {};\n for (const key of BOUND_KEYS) {\n const amount = held[key];\n if (typeof amount !== 'number' || !Number.isFinite(amount)) return null;\n bounds[key] = amount;\n }\n return bounds as HouseBounds;\n}\n\nfunction parseOperations(value: unknown): HouseOperations | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n const operations: Partial<Record<keyof HouseOperations, readonly string[]>> = {};\n for (const key of OPERATION_KEYS) {\n const scopes = stringList(held[key]);\n if (scopes === null) return null;\n operations[key] = scopes;\n }\n return operations as HouseOperations;\n}\n\nfunction parseAuthority(value: unknown): HouseAuthority | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (held.kind !== 'room' && held.kind !== 'private') return null;\n if (typeof held.name !== 'string' || held.name.length === 0) return null;\n if (typeof held.collection_root !== 'string' || typeof held.model_root !== 'string') return null;\n if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {\n return null;\n }\n if (typeof held.position !== 'string' || held.position.length === 0) return null;\n const protectedPaths = stringList(held.protected_paths);\n const operations = parseOperations(held.operations);\n if (protectedPaths === null || operations === null) return null;\n if (held.kind === 'private') {\n return {\n kind: 'private',\n roomRef: PRIVATE_AUTHORITY,\n roomHandle: null,\n name: held.name,\n collectionRoot: held.collection_root,\n modelRoot: held.model_root,\n managedReplication: held.managed_replication,\n protectedPaths,\n operations,\n position: held.position,\n };\n }\n if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;\n if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;\n return {\n kind: 'room',\n roomRef: held.room_ref,\n roomHandle: held.room_handle,\n name: held.name,\n collectionRoot: held.collection_root,\n modelRoot: held.model_root,\n managedReplication: held.managed_replication,\n protectedPaths,\n operations,\n position: held.position,\n };\n}\n\nexport function parseDiscovery(body: unknown): HouseDiscoveryDocument | null {\n if (typeof body !== 'object' || body === null) return null;\n const held = body as Record<string, unknown>;\n const bounds = parseBounds(held.bounds);\n if (bounds === null) return null;\n if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0) return null;\n if (!Array.isArray(held.authorities)) return null;\n const authorities: HouseAuthority[] = [];\n for (const entry of held.authorities) {\n const authority = parseAuthority(entry);\n if (authority === null) return null;\n authorities.push(authority);\n }\n return { bounds, mdModelVersion: held.md_model_version, authorities };\n}\n\nexport function locatorOf(authority: HouseAuthority): string {\n return authority.roomHandle ?? PRIVATE_AUTHORITY;\n}\n\nexport function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[] {\n return document.authorities.map((authority) => ({\n locator: locatorOf(authority),\n authority: authority.roomRef,\n handle: authority.roomHandle ?? undefined,\n collectionRoot: authority.collectionRoot,\n modelRoot: authority.modelRoot,\n modelRoots:\n authority.kind === 'private'\n ? [authority.modelRoot, PROVIDER_SELECTION_MODEL_ROOT]\n : [authority.modelRoot],\n roomVersion: authority.position,\n }));\n}\n\nexport function providerLimits(bounds: HouseBounds): readonly ProviderLimit[] {\n return [\n { name: 'document-size', value: bounds.max_authored_file_bytes },\n { name: 'change-batch-operations', value: bounds.max_batch_operations },\n { name: 'path-length', value: bounds.max_path_length },\n { name: 'path-depth', value: bounds.max_path_depth },\n { name: 'write-rate' },\n { name: 'content-ceiling' },\n ];\n}\n\nexport function declaredRetention(bounds: HouseBounds): Retention {\n return {\n history: { kind: 'no-declared-time-bound' },\n outcome: bounds.operation_retention_seconds,\n refreshHorizon: bounds.change_retention_seconds,\n };\n}\n\nexport function capabilities(): readonly Capability[] {\n return [\n { name: ROOM_VERSION_NOTIFICATIONS },\n {\n name: PROVIDER_ACTIONS,\n actions: declaredActions(),\n conversationCards: HOUSE_CONVERSATION_CARDS,\n },\n ];\n}\n\nexport function providerSelection(attachedModel: TypedSelection['attachedModel']): TypedSelection {\n return { roots: [...PROVIDER_SELECTION_ROOTS], attachedModel };\n}\n\nexport function discoveredRoom(\n authority: HouseAuthority,\n attachedModel: DiscoveredRoom['attachedModel'],\n typedSelection: TypedSelection | undefined,\n): DiscoveredRoom {\n return {\n name: authority.name,\n locator: locatorOf(authority),\n collectionRoot: authority.collectionRoot,\n roomVersion: authority.position,\n operations: {\n read: [...authority.operations.read],\n sync: [...authority.operations.sync],\n write: [...authority.operations.write],\n delete: [...authority.operations.delete],\n },\n replica: { selection: locatorOf(authority), admission: authority.managedReplication },\n attachedModel,\n ...(typedSelection === undefined ? {} : { typedSelection }),\n providerOwnedPaths: [...authority.protectedPaths],\n };\n}\n\nexport function mapDiscovery(\n document: HouseDiscoveryDocument,\n rooms: readonly DiscoveredRoom[],\n): Discovery {\n return {\n kind: 'discovery',\n supportedVersions: [ROOM_CONTRACT_VERSION],\n mdModel: { identity: MD_MODEL_IDENTITY, version: document.mdModelVersion },\n rooms,\n capabilities: capabilities(),\n providerLimits: providerLimits(document.bounds),\n retention: declaredRetention(document.bounds),\n };\n}\n"],"names":["declaredActions","HOUSE_CONVERSATION_CARDS","PRIVATE_AUTHORITY","ROOM_CONTRACT_VERSION","MD_MODEL_IDENTITY","ROOM_VERSION_NOTIFICATIONS","PROVIDER_ACTIONS","DISCOVER_PREFIXES","PROVIDER_SELECTION_ROOTS","PROVIDER_SELECTION_MODEL_ROOT","BOUND_KEYS","OPERATION_KEYS","stringList","value","Array","isArray","every","entry","parseBounds","held","bounds","key","amount","Number","isFinite","parseOperations","operations","scopes","parseAuthority","kind","name","length","collection_root","model_root","managed_replication","position","protectedPaths","protected_paths","roomRef","roomHandle","collectionRoot","modelRoot","managedReplication","room_ref","room_handle","parseDiscovery","body","md_model_version","authorities","authority","push","mdModelVersion","locatorOf","trackedFrom","document","map","locator","handle","undefined","modelRoots","roomVersion","providerLimits","max_authored_file_bytes","max_batch_operations","max_path_length","max_path_depth","declaredRetention","history","outcome","operation_retention_seconds","refreshHorizon","change_retention_seconds","capabilities","actions","conversationCards","providerSelection","attachedModel","roots","discoveredRoom","typedSelection","read","sync","write","delete","replica","selection","admission","providerOwnedPaths","mapDiscovery","rooms","supportedVersions","mdModel","identity","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WAAWrC,UAAUP,kBAAkB;QAAC;QACpFkC;QACA,GAAIG,mBAAmBrB,YAAY,CAAC,IAAI;YAAEqB;QAAe,CAAC;QAC1DQ,oBAAoB;eAAItC,UAAUb,cAAc;SAAC;IACnD;AACF;AAEA,OAAO,SAASoD,aACdlC,QAAgC,EAChCmC,KAAgC;IAEhC,OAAO;QACL5D,MAAM;QACN6D,mBAAmB;YAACvF;SAAsB;QAC1CwF,SAAS;YAAEC,UAAUxF;YAAmByF,SAASvC,SAASH,cAAc;QAAC;QACzEsC;QACAjB,cAAcA;QACdX,gBAAgBA,eAAeP,SAASlC,MAAM;QAC9C0E,WAAW5B,kBAAkBZ,SAASlC,MAAM;IAC9C;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
|
+
export { nativePath, roomLocalPath } from './map.js';
|
|
3
|
+
export type { HouseByteAct, HouseByteTransfer, HouseDoorAnswer, HouseStream, HouseStreamAuthority, HouseStreamEntry, HouseStreamFrame, HouseTransport, } from './transport.js';
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/index.ts"],"sourcesContent":["export {};\n"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/index.ts"],"sourcesContent":["export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';\nexport { nativePath, roomLocalPath } from './map.js';\nexport type {\n HouseByteAct,\n HouseByteTransfer,\n HouseDoorAnswer,\n HouseStream,\n HouseStreamAuthority,\n HouseStreamEntry,\n HouseStreamFrame,\n HouseTransport,\n} from './transport.js';\n"],"names":["createAgentsHouseAdapter","nativePath","roomLocalPath"],"mappings":"AAAA,SAASA,wBAAwB,QAAwC,eAAe;AACxF,SAASC,UAAU,EAAEC,aAAa,QAAQ,WAAW"}
|
package/dist/map.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAUnE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAIhE"}
|
package/dist/map.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function roomLocalPath(path, handle) {
|
|
2
|
+
const prefix = handle === undefined ? '/private/' : `/rooms/${handle}/`;
|
|
3
|
+
const local = path.startsWith(prefix) ? path.slice(prefix.length) : path;
|
|
4
|
+
if (local === '' || local.split('/').some((part)=>part === '' || part === '.' || part === '..')) {
|
|
5
|
+
throw new Error('invalid authority-relative path');
|
|
6
|
+
}
|
|
7
|
+
return local;
|
|
8
|
+
}
|
|
9
|
+
export function nativePath(path, handle) {
|
|
10
|
+
if (path.startsWith('/')) throw new Error('canonical Room path required');
|
|
11
|
+
const local = roomLocalPath(path);
|
|
12
|
+
return handle === undefined ? `/private/${local}` : `/rooms/${handle}/${local}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=map.js.map
|
package/dist/map.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/map.ts"],"sourcesContent":["export function roomLocalPath(path: string, handle?: string): string {\n const prefix = handle === undefined ? '/private/' : `/rooms/${handle}/`;\n const local = path.startsWith(prefix) ? path.slice(prefix.length) : path;\n if (\n local === '' ||\n local.split('/').some((part) => part === '' || part === '.' || part === '..')\n ) {\n throw new Error('invalid authority-relative path');\n }\n return local;\n}\n\nexport function nativePath(path: string, handle?: string): string {\n if (path.startsWith('/')) throw new Error('canonical Room path required');\n const local = roomLocalPath(path);\n return handle === undefined ? `/private/${local}` : `/rooms/${handle}/${local}`;\n}\n"],"names":["roomLocalPath","path","handle","prefix","undefined","local","startsWith","slice","length","split","some","part","Error","nativePath"],"mappings":"AAAA,OAAO,SAASA,cAAcC,IAAY,EAAEC,MAAe;IACzD,MAAMC,SAASD,WAAWE,YAAY,cAAc,CAAC,OAAO,EAAEF,OAAO,CAAC,CAAC;IACvE,MAAMG,QAAQJ,KAAKK,UAAU,CAACH,UAAUF,KAAKM,KAAK,CAACJ,OAAOK,MAAM,IAAIP;IACpE,IACEI,UAAU,MACVA,MAAMI,KAAK,CAAC,KAAKC,IAAI,CAAC,CAACC,OAASA,SAAS,MAAMA,SAAS,OAAOA,SAAS,OACxE;QACA,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOP;AACT;AAEA,OAAO,SAASQ,WAAWZ,IAAY,EAAEC,MAAe;IACtD,IAAID,KAAKK,UAAU,CAAC,MAAM,MAAM,IAAIM,MAAM;IAC1C,MAAMP,QAAQL,cAAcC;IAC5B,OAAOC,WAAWE,YAAY,CAAC,SAAS,EAAEC,OAAO,GAAG,CAAC,OAAO,EAAEH,OAAO,CAAC,EAAEG,OAAO;AACjF"}
|
package/dist/read.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { BootstrapResult, RefreshResult } from '@agentshouse/mdruntime';
|
|
2
|
+
import { type TrackedAuthority } from './discovery.js';
|
|
3
|
+
export type HouseManifestFile = {
|
|
4
|
+
path: string;
|
|
5
|
+
revision: string;
|
|
6
|
+
};
|
|
7
|
+
export type HouseContent = {
|
|
8
|
+
path: string;
|
|
9
|
+
content: string;
|
|
10
|
+
};
|
|
11
|
+
export type HouseScope = {
|
|
12
|
+
scope: 'room' | 'private';
|
|
13
|
+
anchor: string;
|
|
14
|
+
roomHandle: string | undefined;
|
|
15
|
+
position: string;
|
|
16
|
+
files: readonly HouseManifestFile[];
|
|
17
|
+
contents: readonly HouseContent[];
|
|
18
|
+
};
|
|
19
|
+
export type HouseEnvelope = {
|
|
20
|
+
scopes: readonly HouseScope[];
|
|
21
|
+
};
|
|
22
|
+
export type HouseGrant = {
|
|
23
|
+
method: 'GET' | 'POST';
|
|
24
|
+
operation: string;
|
|
25
|
+
url: string;
|
|
26
|
+
};
|
|
27
|
+
export type HouseChange = {
|
|
28
|
+
path: string;
|
|
29
|
+
removed: true;
|
|
30
|
+
} | {
|
|
31
|
+
path: string;
|
|
32
|
+
content: string;
|
|
33
|
+
revision: string;
|
|
34
|
+
} | {
|
|
35
|
+
path: string;
|
|
36
|
+
reference: {
|
|
37
|
+
revision: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export type HouseEnumeration = {
|
|
41
|
+
authorities: readonly {
|
|
42
|
+
authority: string;
|
|
43
|
+
position: string;
|
|
44
|
+
changes: readonly HouseChange[];
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
export declare function authorityRoot(handle: string | undefined): string;
|
|
48
|
+
export declare const ROOM_README = "ROOM.md";
|
|
49
|
+
export declare function selectionRoots(tracked: TrackedAuthority): readonly string[];
|
|
50
|
+
export declare function contentPrefixes(tracked: TrackedAuthority): readonly string[];
|
|
51
|
+
export declare function modelPrefix(tracked: TrackedAuthority, modelRoot: string): string;
|
|
52
|
+
export declare function parseGrant(body: unknown): HouseGrant | null;
|
|
53
|
+
export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
|
|
54
|
+
export declare function parseEnumeration(body: unknown): HouseEnumeration | null;
|
|
55
|
+
export declare function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean;
|
|
56
|
+
export declare function withinRoot(path: string, root: string): boolean;
|
|
57
|
+
export declare function selects(tracked: TrackedAuthority, path: string): boolean;
|
|
58
|
+
export declare function bootstrapFrom(envelope: HouseEnvelope, tracked: TrackedAuthority): BootstrapResult;
|
|
59
|
+
export type HouseDefinitions = {
|
|
60
|
+
definitions: Readonly<Record<string, string>>;
|
|
61
|
+
revisions: readonly string[];
|
|
62
|
+
};
|
|
63
|
+
export declare const MODEL_DEFINITION_ADDRESS = "types";
|
|
64
|
+
export declare function definitionAddress(path: string): string;
|
|
65
|
+
export declare function definitionsFrom(envelope: HouseEnvelope, tracked: TrackedAuthority, modelRoot: string): HouseDefinitions | null;
|
|
66
|
+
export declare function refreshFrom(enumeration: HouseEnumeration, tracked: TrackedAuthority, fromRoomVersion: string): RefreshResult;
|
|
67
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb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gB,EACzB,eAAe,EAAE,MAAM,GACtB,aAAa,CA8Bf"}
|
package/dist/read.js
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { PROVIDER_SELECTION_ROOTS } from './discovery.js';
|
|
2
|
+
export function authorityRoot(handle) {
|
|
3
|
+
return handle === undefined ? '/private' : `/rooms/${handle}`;
|
|
4
|
+
}
|
|
5
|
+
export const ROOM_README = 'ROOM.md';
|
|
6
|
+
export function selectionRoots(tracked) {
|
|
7
|
+
if (tracked.handle === undefined) {
|
|
8
|
+
return [
|
|
9
|
+
tracked.collectionRoot,
|
|
10
|
+
...PROVIDER_SELECTION_ROOTS
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
return [
|
|
14
|
+
ROOM_README,
|
|
15
|
+
tracked.collectionRoot
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
export function contentPrefixes(tracked) {
|
|
19
|
+
const root = authorityRoot(tracked.handle);
|
|
20
|
+
return selectionRoots(tracked).filter((entry)=>entry !== ROOM_README).map((entry)=>`${root}/${entry}`);
|
|
21
|
+
}
|
|
22
|
+
export function modelPrefix(tracked, modelRoot) {
|
|
23
|
+
return `${authorityRoot(tracked.handle)}/${modelRoot}`;
|
|
24
|
+
}
|
|
25
|
+
export function parseGrant(body) {
|
|
26
|
+
if (typeof body !== 'object' || body === null) return null;
|
|
27
|
+
if (!('transfer' in body) || typeof body.transfer !== 'object' || body.transfer === null) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const transfer = body.transfer;
|
|
31
|
+
if (transfer.method !== 'GET' && transfer.method !== 'POST') return null;
|
|
32
|
+
if (typeof transfer.operation !== 'string' || typeof transfer.url !== 'string') return null;
|
|
33
|
+
return {
|
|
34
|
+
method: transfer.method,
|
|
35
|
+
operation: transfer.operation,
|
|
36
|
+
url: transfer.url
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function parseScope(value) {
|
|
40
|
+
if (typeof value !== 'object' || value === null) return null;
|
|
41
|
+
const held = value;
|
|
42
|
+
if (typeof held.manifest !== 'object' || held.manifest === null) return null;
|
|
43
|
+
if (!Array.isArray(held.contents)) return null;
|
|
44
|
+
const manifest = held.manifest;
|
|
45
|
+
if (manifest.scope !== 'room' && manifest.scope !== 'private') return null;
|
|
46
|
+
if (typeof manifest.anchor !== 'string' || typeof manifest.position !== 'string') return null;
|
|
47
|
+
if (!Array.isArray(manifest.files)) return null;
|
|
48
|
+
const files = [];
|
|
49
|
+
for (const entry of manifest.files){
|
|
50
|
+
if (typeof entry !== 'object' || entry === null) return null;
|
|
51
|
+
const file = entry;
|
|
52
|
+
if (typeof file.path !== 'string' || typeof file.revision !== 'string') return null;
|
|
53
|
+
files.push({
|
|
54
|
+
path: file.path,
|
|
55
|
+
revision: file.revision
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const contents = [];
|
|
59
|
+
for (const entry of held.contents){
|
|
60
|
+
if (typeof entry !== 'object' || entry === null) return null;
|
|
61
|
+
const content = entry;
|
|
62
|
+
if (typeof content.path !== 'string' || typeof content.content !== 'string') return null;
|
|
63
|
+
contents.push({
|
|
64
|
+
path: content.path,
|
|
65
|
+
content: content.content
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
scope: manifest.scope,
|
|
70
|
+
anchor: manifest.anchor,
|
|
71
|
+
roomHandle: typeof manifest.room_handle === 'string' ? manifest.room_handle : undefined,
|
|
72
|
+
position: manifest.position,
|
|
73
|
+
files,
|
|
74
|
+
contents
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function parseEnvelope(body) {
|
|
78
|
+
if (typeof body !== 'object' || body === null) return null;
|
|
79
|
+
if (!('scopes' in body) || !Array.isArray(body.scopes)) return null;
|
|
80
|
+
const scopes = [];
|
|
81
|
+
for (const entry of body.scopes){
|
|
82
|
+
const scope = parseScope(entry);
|
|
83
|
+
if (scope === null) return null;
|
|
84
|
+
scopes.push(scope);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
scopes
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function parseChange(value) {
|
|
91
|
+
if (typeof value !== 'object' || value === null) return null;
|
|
92
|
+
const held = value;
|
|
93
|
+
if (typeof held.path !== 'string') return null;
|
|
94
|
+
if (held.removed === true) return {
|
|
95
|
+
path: held.path,
|
|
96
|
+
removed: true
|
|
97
|
+
};
|
|
98
|
+
if (typeof held.content === 'string' && typeof held.revision === 'string') {
|
|
99
|
+
return {
|
|
100
|
+
path: held.path,
|
|
101
|
+
content: held.content,
|
|
102
|
+
revision: held.revision
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (typeof held.reference === 'object' && held.reference !== null) {
|
|
106
|
+
const reference = held.reference;
|
|
107
|
+
if (typeof reference.revision !== 'string') return null;
|
|
108
|
+
return {
|
|
109
|
+
path: held.path,
|
|
110
|
+
reference: {
|
|
111
|
+
revision: reference.revision
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
export function parseEnumeration(body) {
|
|
118
|
+
if (typeof body !== 'object' || body === null) return null;
|
|
119
|
+
if (!('authorities' in body) || !Array.isArray(body.authorities)) return null;
|
|
120
|
+
const authorities = [];
|
|
121
|
+
for (const entry of body.authorities){
|
|
122
|
+
if (typeof entry !== 'object' || entry === null) return null;
|
|
123
|
+
const held = entry;
|
|
124
|
+
if (typeof held.authority !== 'string' || typeof held.position !== 'string') return null;
|
|
125
|
+
if (!Array.isArray(held.changes)) return null;
|
|
126
|
+
const changes = [];
|
|
127
|
+
for (const change of held.changes){
|
|
128
|
+
const mapped = parseChange(change);
|
|
129
|
+
if (mapped === null) return null;
|
|
130
|
+
changes.push(mapped);
|
|
131
|
+
}
|
|
132
|
+
authorities.push({
|
|
133
|
+
authority: held.authority,
|
|
134
|
+
position: held.position,
|
|
135
|
+
changes
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
authorities
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function matchesScope(scope, tracked) {
|
|
143
|
+
if (tracked.handle === undefined) return scope.scope === 'private';
|
|
144
|
+
return scope.roomHandle === tracked.handle || scope.anchor === tracked.authority;
|
|
145
|
+
}
|
|
146
|
+
export function withinRoot(path, root) {
|
|
147
|
+
return path === root || path.startsWith(`${root}/`);
|
|
148
|
+
}
|
|
149
|
+
export function selects(tracked, path) {
|
|
150
|
+
if (tracked.modelRoots.some((root)=>withinRoot(path, root))) return false;
|
|
151
|
+
return selectionRoots(tracked).some((root)=>withinRoot(path, root));
|
|
152
|
+
}
|
|
153
|
+
export function bootstrapFrom(envelope, tracked) {
|
|
154
|
+
const scope = envelope.scopes.find((entry)=>matchesScope(entry, tracked));
|
|
155
|
+
if (scope === undefined) return {
|
|
156
|
+
kind: 'room-not-readable',
|
|
157
|
+
locator: tracked.locator
|
|
158
|
+
};
|
|
159
|
+
const contents = new Map(scope.contents.map((entry)=>[
|
|
160
|
+
entry.path,
|
|
161
|
+
entry.content
|
|
162
|
+
]));
|
|
163
|
+
const documents = {};
|
|
164
|
+
const revisions = {};
|
|
165
|
+
const binaryTargets = [];
|
|
166
|
+
for (const file of scope.files){
|
|
167
|
+
if (!selects(tracked, file.path)) continue;
|
|
168
|
+
revisions[file.path] = file.revision;
|
|
169
|
+
const content = contents.get(file.path);
|
|
170
|
+
if (content === undefined) binaryTargets.push(file.path);
|
|
171
|
+
else documents[file.path] = content;
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
kind: 'bootstrap',
|
|
175
|
+
roomVersion: scope.position,
|
|
176
|
+
documents,
|
|
177
|
+
revisions,
|
|
178
|
+
binaryTargets: binaryTargets.sort()
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
export const MODEL_DEFINITION_ADDRESS = 'types';
|
|
182
|
+
export function definitionAddress(path) {
|
|
183
|
+
return `${MODEL_DEFINITION_ADDRESS}/${path.slice(path.lastIndexOf('/') + 1)}`;
|
|
184
|
+
}
|
|
185
|
+
export function definitionsFrom(envelope, tracked, modelRoot) {
|
|
186
|
+
const scope = envelope.scopes.find((entry)=>matchesScope(entry, tracked));
|
|
187
|
+
if (scope === undefined) return null;
|
|
188
|
+
const contents = new Map(scope.contents.map((entry)=>[
|
|
189
|
+
entry.path,
|
|
190
|
+
entry.content
|
|
191
|
+
]));
|
|
192
|
+
const definitions = {};
|
|
193
|
+
const revisions = [];
|
|
194
|
+
for (const file of scope.files){
|
|
195
|
+
if (!withinRoot(file.path, modelRoot)) continue;
|
|
196
|
+
const content = contents.get(file.path);
|
|
197
|
+
const address = definitionAddress(file.path);
|
|
198
|
+
if (content === undefined || Object.hasOwn(definitions, address)) return null;
|
|
199
|
+
definitions[address] = content;
|
|
200
|
+
revisions.push(`${file.path} ${file.revision}`);
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
definitions,
|
|
204
|
+
revisions: revisions.sort()
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
export function refreshFrom(enumeration, tracked, fromRoomVersion) {
|
|
208
|
+
const view = enumeration.authorities.find((entry)=>entry.authority === tracked.authority);
|
|
209
|
+
if (view === undefined) return {
|
|
210
|
+
kind: 'room-not-readable',
|
|
211
|
+
locator: tracked.locator
|
|
212
|
+
};
|
|
213
|
+
if (view.position === fromRoomVersion) return {
|
|
214
|
+
kind: 'still-current'
|
|
215
|
+
};
|
|
216
|
+
const documents = {};
|
|
217
|
+
const revisions = {};
|
|
218
|
+
const binaryTargets = [];
|
|
219
|
+
const removals = [];
|
|
220
|
+
for (const change of view.changes){
|
|
221
|
+
if (!selects(tracked, change.path)) continue;
|
|
222
|
+
if ('removed' in change) {
|
|
223
|
+
removals.push(change.path);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if ('content' in change) {
|
|
227
|
+
documents[change.path] = change.content;
|
|
228
|
+
revisions[change.path] = change.revision;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
binaryTargets.push(change.path);
|
|
232
|
+
revisions[change.path] = change.reference.revision;
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
kind: 'net-advancement',
|
|
236
|
+
roomVersion: view.position,
|
|
237
|
+
documents,
|
|
238
|
+
revisions,
|
|
239
|
+
binaryTargets: binaryTargets.sort(),
|
|
240
|
+
removals: removals.sort()
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
//# sourceMappingURL=read.js.map
|