@agentshouse/mdruntime-adapter 0.1.0-alpha.9 → 0.1.0-c9f1e531ad7c8
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 +157 -26
- package/README.md +32 -0
- package/dist/actions.d.ts +4 -12
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +239 -332
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +258 -193
- package/dist/digest.js +1 -5
- package/dist/discovery.d.ts +20 -18
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +182 -210
- package/dist/gather.d.ts +3 -0
- package/dist/gather.d.ts.map +1 -0
- package/dist/gather.js +40 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/links.d.ts +12 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +66 -0
- package/dist/map.d.ts +2 -2
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +6 -7
- package/dist/model.d.ts +2 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +21 -39
- package/dist/read.d.ts +29 -23
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +222 -195
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +30 -51
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +110 -124
- package/dist/stream.d.ts +11 -5
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +211 -213
- package/dist/transport.d.ts +46 -28
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +3 -3
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +23 -18
- package/dist/write.d.ts +3 -3
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +120 -203
- package/package.json +4 -12
- 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/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,EACf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AAExD,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;AAE1D,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,EACf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AAExD,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,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C,SAAS,EAAE,cAAc,GAAG,MAAM,CAE3D;AAQD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,sBAAsB,GAAG,gBAAgB,EAAE,CAUhF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,aAAa,EAAE,CAU5E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAMhE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,UAAU,EAAE,CAU9E;AAED,wBAAgB,gBAAgB,IAAI,SAAS,UAAU,EAAE,CAKxD;AAED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,cAAc,CAAC,eAAe,CAAC,GAAG,cAAc,CAEhG;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,cAAc,EACzB,aAAa,EAAE,cAAc,CAAC,eAAe,CAAC,EAC9C,cAAc,EAAE,cAAc,GAAG,SAAS,GACzC,cAAc,CAiBhB;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,GAAG,gBAAgB,CAAC,EACnE,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,SAAS,CAUX"}
|
package/dist/discovery.js
CHANGED
|
@@ -1,340 +1,312 @@
|
|
|
1
1
|
import { declaredActions, HOUSE_CONVERSATION_CARDS } from './actions.js';
|
|
2
|
-
import {
|
|
2
|
+
import { PRIVATE_LOCATOR } from './transport.js';
|
|
3
3
|
import { readPosition, roomVersion } from './version.js';
|
|
4
4
|
export const ROOM_CONTRACT_VERSION = 1;
|
|
5
5
|
export const MD_MODEL_IDENTITY = '@agentshouse/mdmodel';
|
|
6
6
|
export const ROOM_VERSION_NOTIFICATIONS = 'room-version-notifications';
|
|
7
7
|
export const PROVIDER_ACTIONS = 'provider-actions';
|
|
8
8
|
export const MOVE_REFERENCE_REWRITES = 'move-reference-rewrites';
|
|
9
|
-
export const DISCOVER_PREFIXES = [
|
|
10
|
-
'/'
|
|
11
|
-
];
|
|
9
|
+
export const DISCOVER_PREFIXES = ['/'];
|
|
12
10
|
export const PROVIDER_SELECTION_ROOTS = [
|
|
13
11
|
'agents',
|
|
14
|
-
'
|
|
12
|
+
'collaboration/routines',
|
|
13
|
+
'house',
|
|
14
|
+
'settings/apps',
|
|
15
|
+
'settings/panel.md',
|
|
16
|
+
];
|
|
17
|
+
export const UNTYPED_FOLDERS = ['capture'];
|
|
18
|
+
export const RESERVED_NAMES = [
|
|
19
|
+
'ROOM.md',
|
|
20
|
+
'capture',
|
|
21
|
+
'settings',
|
|
22
|
+
'collaboration',
|
|
23
|
+
'rooms',
|
|
24
|
+
'agents',
|
|
25
|
+
'house',
|
|
26
|
+
'work',
|
|
27
|
+
'entities',
|
|
28
|
+
'schema',
|
|
29
|
+
'commitments',
|
|
15
30
|
];
|
|
16
|
-
export const
|
|
31
|
+
export const HOUSE_SCHEMA = 'house/schema.yaml';
|
|
32
|
+
export const PRIVATE_HANDLE = 'private';
|
|
17
33
|
const BOUND_KEYS = [
|
|
18
34
|
'max_authored_file_bytes',
|
|
19
35
|
'max_batch_operations',
|
|
36
|
+
'max_batch_documents',
|
|
20
37
|
'max_path_length',
|
|
21
38
|
'max_path_depth',
|
|
22
39
|
'max_mount_files',
|
|
23
40
|
'max_mount_bytes',
|
|
24
41
|
'change_retention_seconds',
|
|
25
|
-
'operation_retention_seconds'
|
|
26
|
-
];
|
|
27
|
-
const OPERATION_KEYS = [
|
|
28
|
-
'read',
|
|
29
|
-
'sync',
|
|
30
|
-
'write',
|
|
31
|
-
'delete'
|
|
42
|
+
'operation_retention_seconds',
|
|
32
43
|
];
|
|
44
|
+
const OPERATION_KEYS = ['read', 'sync', 'write', 'delete'];
|
|
33
45
|
function stringList(value) {
|
|
34
|
-
if (!Array.isArray(value))
|
|
35
|
-
|
|
46
|
+
if (!Array.isArray(value))
|
|
47
|
+
return null;
|
|
48
|
+
return value.every((entry) => typeof entry === 'string') ? value : null;
|
|
36
49
|
}
|
|
37
50
|
function parseBounds(value) {
|
|
38
|
-
if (typeof value !== 'object' || value === null)
|
|
51
|
+
if (typeof value !== 'object' || value === null)
|
|
52
|
+
return null;
|
|
39
53
|
const held = value;
|
|
40
54
|
const bounds = {};
|
|
41
|
-
for (const key of BOUND_KEYS){
|
|
55
|
+
for (const key of BOUND_KEYS) {
|
|
42
56
|
const amount = held[key];
|
|
43
|
-
if (typeof amount !== 'number' || !Number.isFinite(amount))
|
|
57
|
+
if (typeof amount !== 'number' || !Number.isFinite(amount))
|
|
58
|
+
return null;
|
|
44
59
|
bounds[key] = amount;
|
|
45
60
|
}
|
|
46
61
|
return bounds;
|
|
47
62
|
}
|
|
48
63
|
function parseOperations(value) {
|
|
49
|
-
if (typeof value !== 'object' || value === null)
|
|
64
|
+
if (typeof value !== 'object' || value === null)
|
|
65
|
+
return null;
|
|
50
66
|
const held = value;
|
|
51
67
|
const operations = {};
|
|
52
|
-
for (const key of OPERATION_KEYS){
|
|
68
|
+
for (const key of OPERATION_KEYS) {
|
|
53
69
|
const scopes = stringList(held[key]);
|
|
54
|
-
if (scopes === null)
|
|
70
|
+
if (scopes === null)
|
|
71
|
+
return null;
|
|
55
72
|
operations[key] = scopes;
|
|
56
73
|
}
|
|
57
74
|
return operations;
|
|
58
75
|
}
|
|
59
76
|
function parseAuthority(value) {
|
|
60
|
-
if (typeof value !== 'object' || value === null)
|
|
77
|
+
if (typeof value !== 'object' || value === null)
|
|
78
|
+
return null;
|
|
61
79
|
const held = value;
|
|
62
|
-
if (held.kind !== 'room'
|
|
63
|
-
|
|
64
|
-
if (typeof held.
|
|
80
|
+
if (held.kind !== 'room')
|
|
81
|
+
return null;
|
|
82
|
+
if (typeof held.name !== 'string' || held.name.length === 0)
|
|
83
|
+
return null;
|
|
84
|
+
if (typeof held.model_root !== 'string')
|
|
85
|
+
return null;
|
|
65
86
|
if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {
|
|
66
87
|
return null;
|
|
67
88
|
}
|
|
68
89
|
const at = readPosition(held);
|
|
69
90
|
const protectedPaths = stringList(held.protected_paths);
|
|
70
91
|
const operations = parseOperations(held.operations);
|
|
71
|
-
if (at === null || protectedPaths === null || operations === null)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
name: held.name,
|
|
78
|
-
collectionRoot: held.collection_root,
|
|
79
|
-
modelRoot: held.model_root,
|
|
80
|
-
managedReplication: held.managed_replication,
|
|
81
|
-
protectedPaths,
|
|
82
|
-
operations,
|
|
83
|
-
...at
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;
|
|
87
|
-
if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;
|
|
92
|
+
if (at === null || protectedPaths === null || operations === null)
|
|
93
|
+
return null;
|
|
94
|
+
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
|
|
95
|
+
return null;
|
|
96
|
+
if (typeof held.room_handle !== 'string' || held.room_handle.length === 0)
|
|
97
|
+
return null;
|
|
88
98
|
return {
|
|
89
|
-
kind: 'room',
|
|
90
99
|
roomRef: held.room_ref,
|
|
91
100
|
roomHandle: held.room_handle,
|
|
92
101
|
name: held.name,
|
|
93
|
-
|
|
94
|
-
modelRoot: held.model_root,
|
|
102
|
+
schema: held.model_root,
|
|
95
103
|
managedReplication: held.managed_replication,
|
|
96
104
|
protectedPaths,
|
|
97
105
|
operations,
|
|
98
|
-
...at
|
|
106
|
+
...at,
|
|
99
107
|
};
|
|
100
108
|
}
|
|
101
109
|
export function parseDiscovery(body) {
|
|
102
|
-
if (typeof body !== 'object' || body === null)
|
|
110
|
+
if (typeof body !== 'object' || body === null)
|
|
111
|
+
return null;
|
|
103
112
|
const held = body;
|
|
104
113
|
const bounds = parseBounds(held.bounds);
|
|
105
|
-
if (bounds === null)
|
|
106
|
-
|
|
107
|
-
if (
|
|
114
|
+
if (bounds === null)
|
|
115
|
+
return null;
|
|
116
|
+
if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0)
|
|
117
|
+
return null;
|
|
118
|
+
const actions = stringList(held.actions);
|
|
119
|
+
if (actions === null ||
|
|
120
|
+
new Set(actions).size !== actions.length ||
|
|
121
|
+
actions.some((name) => name.length === 0))
|
|
122
|
+
return null;
|
|
123
|
+
if (!Array.isArray(held.authorities))
|
|
124
|
+
return null;
|
|
108
125
|
const authorities = [];
|
|
109
|
-
for (const entry of held.authorities){
|
|
126
|
+
for (const entry of held.authorities) {
|
|
110
127
|
const authority = parseAuthority(entry);
|
|
111
|
-
if (authority === null)
|
|
128
|
+
if (authority === null)
|
|
129
|
+
return null;
|
|
112
130
|
authorities.push(authority);
|
|
113
131
|
}
|
|
114
|
-
return {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
return { bounds, mdModelVersion: held.md_model_version, authorities, actions };
|
|
133
|
+
}
|
|
134
|
+
function parseSiteEntry(value) {
|
|
135
|
+
if (typeof value !== 'object' || value === null)
|
|
136
|
+
return null;
|
|
137
|
+
const held = value;
|
|
138
|
+
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
|
|
139
|
+
return null;
|
|
140
|
+
if (typeof held.segment !== 'string' || held.segment.length === 0)
|
|
141
|
+
return null;
|
|
142
|
+
return { roomRef: held.room_ref, segment: held.segment };
|
|
119
143
|
}
|
|
120
144
|
function parseSiteSlot(value) {
|
|
121
|
-
if (typeof value !== 'object' || value === null)
|
|
145
|
+
if (typeof value !== 'object' || value === null)
|
|
146
|
+
return null;
|
|
122
147
|
const held = value;
|
|
123
|
-
if (typeof held.slot !== 'string' || held.slot.length === 0)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
148
|
+
if (typeof held.slot !== 'string' || held.slot.length === 0)
|
|
149
|
+
return null;
|
|
150
|
+
if (!Array.isArray(held.entries))
|
|
151
|
+
return null;
|
|
152
|
+
const entries = [];
|
|
153
|
+
for (const entry of held.entries) {
|
|
154
|
+
const parsed = parseSiteEntry(entry);
|
|
155
|
+
if (parsed === null)
|
|
156
|
+
return null;
|
|
157
|
+
entries.push(parsed);
|
|
158
|
+
}
|
|
159
|
+
return { slot: held.slot, entries };
|
|
133
160
|
}
|
|
134
161
|
function parseSiteAuthority(value) {
|
|
135
|
-
if (typeof value !== 'object' || value === null)
|
|
162
|
+
if (typeof value !== 'object' || value === null)
|
|
163
|
+
return null;
|
|
136
164
|
const held = value;
|
|
137
|
-
if (held.kind !== 'room')
|
|
138
|
-
|
|
139
|
-
if (typeof held.
|
|
140
|
-
|
|
165
|
+
if (held.kind !== 'room')
|
|
166
|
+
return null;
|
|
167
|
+
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
|
|
168
|
+
return null;
|
|
169
|
+
if (typeof held.room_handle !== 'string' || held.room_handle.length === 0)
|
|
170
|
+
return null;
|
|
171
|
+
if (typeof held.model_root !== 'string')
|
|
172
|
+
return null;
|
|
141
173
|
const at = readPosition(held);
|
|
142
|
-
if (at === null)
|
|
174
|
+
if (at === null)
|
|
175
|
+
return null;
|
|
143
176
|
return {
|
|
144
177
|
roomRef: held.room_ref,
|
|
145
178
|
roomHandle: held.room_handle,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...at
|
|
179
|
+
schema: held.model_root,
|
|
180
|
+
...at,
|
|
149
181
|
};
|
|
150
182
|
}
|
|
151
183
|
export function parseSiteDiscovery(body) {
|
|
152
|
-
if (typeof body !== 'object' || body === null)
|
|
184
|
+
if (typeof body !== 'object' || body === null)
|
|
185
|
+
return null;
|
|
153
186
|
const held = body;
|
|
154
187
|
const bounds = parseBounds(held.bounds);
|
|
155
|
-
if (bounds === null)
|
|
156
|
-
|
|
157
|
-
if (
|
|
188
|
+
if (bounds === null)
|
|
189
|
+
return null;
|
|
190
|
+
if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0)
|
|
191
|
+
return null;
|
|
192
|
+
if (!Array.isArray(held.slots) || !Array.isArray(held.authorities))
|
|
193
|
+
return null;
|
|
158
194
|
const slots = [];
|
|
159
|
-
for (const entry of held.slots){
|
|
195
|
+
for (const entry of held.slots) {
|
|
160
196
|
const slot = parseSiteSlot(entry);
|
|
161
|
-
if (slot === null)
|
|
197
|
+
if (slot === null)
|
|
198
|
+
return null;
|
|
162
199
|
slots.push(slot);
|
|
163
200
|
}
|
|
164
201
|
const authorities = [];
|
|
165
|
-
for (const entry of held.authorities){
|
|
202
|
+
for (const entry of held.authorities) {
|
|
166
203
|
const authority = parseSiteAuthority(entry);
|
|
167
|
-
if (authority === null)
|
|
204
|
+
if (authority === null)
|
|
205
|
+
return null;
|
|
168
206
|
authorities.push(authority);
|
|
169
207
|
}
|
|
170
|
-
return {
|
|
171
|
-
bounds,
|
|
172
|
-
mdModelVersion: held.md_model_version,
|
|
173
|
-
slots,
|
|
174
|
-
authorities
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
export function siteLocator(slot, roomRef) {
|
|
178
|
-
return `${slot}:${roomRef}`;
|
|
208
|
+
return { bounds, mdModelVersion: held.md_model_version, slots, authorities };
|
|
179
209
|
}
|
|
180
210
|
export function siteTracked(document) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
modelRoots: [
|
|
197
|
-
authority.modelRoot
|
|
198
|
-
],
|
|
199
|
-
position: authority.position,
|
|
200
|
-
logEpoch: authority.logEpoch
|
|
201
|
-
}
|
|
202
|
-
];
|
|
203
|
-
});
|
|
211
|
+
return document.authorities.map((authority) => ({
|
|
212
|
+
locator: authority.roomRef,
|
|
213
|
+
authority: authority.roomRef,
|
|
214
|
+
handle: authority.roomHandle,
|
|
215
|
+
schema: authority.schema,
|
|
216
|
+
schemas: [authority.schema],
|
|
217
|
+
position: authority.position,
|
|
218
|
+
logEpoch: authority.logEpoch,
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
export function siteSlots(document) {
|
|
222
|
+
return document.slots.map(({ slot, entries }) => ({
|
|
223
|
+
slot,
|
|
224
|
+
entries: entries.map(({ roomRef, segment }) => ({ locator: roomRef, segment })),
|
|
225
|
+
}));
|
|
204
226
|
}
|
|
205
227
|
export function locatorOf(authority) {
|
|
206
|
-
return authority.roomHandle
|
|
228
|
+
return authority.roomHandle === PRIVATE_HANDLE ? PRIVATE_LOCATOR : authority.roomRef;
|
|
229
|
+
}
|
|
230
|
+
function schemasOf(authority) {
|
|
231
|
+
return authority.roomHandle === PRIVATE_HANDLE
|
|
232
|
+
? [authority.schema, HOUSE_SCHEMA]
|
|
233
|
+
: [authority.schema];
|
|
207
234
|
}
|
|
208
235
|
export function trackedFrom(document) {
|
|
209
|
-
return document.authorities.map((authority)=>({
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
] : [
|
|
219
|
-
authority.modelRoot
|
|
220
|
-
],
|
|
221
|
-
position: authority.position,
|
|
222
|
-
logEpoch: authority.logEpoch
|
|
223
|
-
}));
|
|
236
|
+
return document.authorities.map((authority) => ({
|
|
237
|
+
locator: locatorOf(authority),
|
|
238
|
+
authority: authority.roomRef,
|
|
239
|
+
handle: authority.roomHandle,
|
|
240
|
+
schema: authority.schema,
|
|
241
|
+
schemas: schemasOf(authority),
|
|
242
|
+
position: authority.position,
|
|
243
|
+
logEpoch: authority.logEpoch,
|
|
244
|
+
}));
|
|
224
245
|
}
|
|
225
246
|
export function providerLimits(bounds) {
|
|
226
247
|
return [
|
|
227
|
-
{
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
name: 'path-length',
|
|
237
|
-
value: bounds.max_path_length
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
name: 'path-depth',
|
|
241
|
-
value: bounds.max_path_depth
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
name: 'write-rate'
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
name: 'content-ceiling'
|
|
248
|
-
}
|
|
248
|
+
{ name: 'document-size', value: bounds.max_authored_file_bytes },
|
|
249
|
+
{ name: 'change-batch-operations', value: bounds.max_batch_operations },
|
|
250
|
+
{ name: 'change-documents', value: bounds.max_batch_documents },
|
|
251
|
+
{ name: 'path-length', value: bounds.max_path_length },
|
|
252
|
+
{ name: 'path-depth', value: bounds.max_path_depth },
|
|
253
|
+
{ name: 'write-rate' },
|
|
254
|
+
{ name: 'content-ceiling' },
|
|
249
255
|
];
|
|
250
256
|
}
|
|
251
257
|
export function declaredRetention(bounds) {
|
|
252
258
|
return {
|
|
253
|
-
history: {
|
|
254
|
-
kind: 'no-declared-time-bound'
|
|
255
|
-
},
|
|
259
|
+
history: { kind: 'no-declared-time-bound' },
|
|
256
260
|
outcome: bounds.operation_retention_seconds,
|
|
257
|
-
refreshHorizon: bounds.change_retention_seconds
|
|
261
|
+
refreshHorizon: bounds.change_retention_seconds,
|
|
258
262
|
};
|
|
259
263
|
}
|
|
260
|
-
export function capabilities() {
|
|
264
|
+
export function capabilities(actions) {
|
|
261
265
|
return [
|
|
262
|
-
{
|
|
263
|
-
name: ROOM_VERSION_NOTIFICATIONS
|
|
264
|
-
},
|
|
266
|
+
{ name: ROOM_VERSION_NOTIFICATIONS },
|
|
265
267
|
{
|
|
266
268
|
name: PROVIDER_ACTIONS,
|
|
267
|
-
actions: declaredActions(),
|
|
268
|
-
conversationCards: HOUSE_CONVERSATION_CARDS
|
|
269
|
+
actions: declaredActions(actions),
|
|
270
|
+
conversationCards: HOUSE_CONVERSATION_CARDS,
|
|
269
271
|
},
|
|
270
|
-
{
|
|
271
|
-
name: MOVE_REFERENCE_REWRITES
|
|
272
|
-
}
|
|
272
|
+
{ name: MOVE_REFERENCE_REWRITES },
|
|
273
273
|
];
|
|
274
274
|
}
|
|
275
275
|
export function siteCapabilities() {
|
|
276
276
|
return [
|
|
277
|
-
{
|
|
278
|
-
|
|
279
|
-
}
|
|
277
|
+
{ name: ROOM_VERSION_NOTIFICATIONS },
|
|
278
|
+
{ name: PROVIDER_ACTIONS, actions: [{ name: 'submit', inputShape: {}, resultKind: 'house' }] },
|
|
280
279
|
];
|
|
281
280
|
}
|
|
282
281
|
export function providerSelection(attachedModel) {
|
|
283
|
-
return {
|
|
284
|
-
roots: [
|
|
285
|
-
...PROVIDER_SELECTION_ROOTS
|
|
286
|
-
],
|
|
287
|
-
attachedModel
|
|
288
|
-
};
|
|
282
|
+
return { roots: [...PROVIDER_SELECTION_ROOTS], attachedModel };
|
|
289
283
|
}
|
|
290
284
|
export function discoveredRoom(authority, attachedModel, typedSelection) {
|
|
291
285
|
return {
|
|
292
286
|
name: authority.name,
|
|
293
287
|
locator: locatorOf(authority),
|
|
294
|
-
collectionRoot: authority.collectionRoot,
|
|
295
288
|
roomVersion: roomVersion(authority),
|
|
296
289
|
operations: {
|
|
297
|
-
read: [
|
|
298
|
-
|
|
299
|
-
],
|
|
300
|
-
|
|
301
|
-
...authority.operations.sync
|
|
302
|
-
],
|
|
303
|
-
write: [
|
|
304
|
-
...authority.operations.write
|
|
305
|
-
],
|
|
306
|
-
delete: [
|
|
307
|
-
...authority.operations.delete
|
|
308
|
-
]
|
|
309
|
-
},
|
|
310
|
-
replica: {
|
|
311
|
-
selection: locatorOf(authority),
|
|
312
|
-
admission: authority.managedReplication
|
|
290
|
+
read: [...authority.operations.read],
|
|
291
|
+
sync: [...authority.operations.sync],
|
|
292
|
+
write: [...authority.operations.write],
|
|
293
|
+
delete: [...authority.operations.delete],
|
|
313
294
|
},
|
|
295
|
+
replica: { selection: locatorOf(authority), admission: authority.managedReplication },
|
|
314
296
|
attachedModel,
|
|
315
|
-
...typedSelection === undefined ? {} : {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
providerOwnedPaths: [
|
|
319
|
-
...authority.protectedPaths
|
|
320
|
-
]
|
|
297
|
+
...(typedSelection === undefined ? {} : { typedSelection }),
|
|
298
|
+
untypedFolders: [...UNTYPED_FOLDERS],
|
|
299
|
+
providerOwnedPaths: [...authority.protectedPaths, ...schemasOf(authority)],
|
|
321
300
|
};
|
|
322
301
|
}
|
|
323
302
|
export function mapDiscovery(document, rooms, declared) {
|
|
324
303
|
return {
|
|
325
304
|
kind: 'discovery',
|
|
326
|
-
supportedVersions: [
|
|
327
|
-
|
|
328
|
-
],
|
|
329
|
-
mdModel: {
|
|
330
|
-
identity: MD_MODEL_IDENTITY,
|
|
331
|
-
version: document.mdModelVersion
|
|
332
|
-
},
|
|
305
|
+
supportedVersions: [ROOM_CONTRACT_VERSION],
|
|
306
|
+
mdModel: { identity: MD_MODEL_IDENTITY, version: document.mdModelVersion },
|
|
333
307
|
rooms,
|
|
334
308
|
capabilities: declared,
|
|
335
309
|
providerLimits: providerLimits(document.bounds),
|
|
336
|
-
retention: declaredRetention(document.bounds)
|
|
310
|
+
retention: declaredRetention(document.bounds),
|
|
337
311
|
};
|
|
338
312
|
}
|
|
339
|
-
|
|
340
|
-
//# sourceMappingURL=discovery.js.map
|
package/dist/gather.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function gathered<A, R>(send: (asks: readonly A[]) => Promise<readonly R[]>): (ask: A) => Promise<R>;
|
|
2
|
+
export declare function selections<T>(items: readonly T[], weight: (item: T) => number, limit: number): readonly (readonly T[])[];
|
|
3
|
+
//# sourceMappingURL=gather.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAMA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAClD,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CA0BxB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAC3B,KAAK,EAAE,MAAM,GACZ,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAgB3B"}
|
package/dist/gather.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function gathered(send) {
|
|
2
|
+
let held = [];
|
|
3
|
+
function flush() {
|
|
4
|
+
const taken = held;
|
|
5
|
+
held = [];
|
|
6
|
+
send(taken.map((entry) => entry.ask)).then((answers) => {
|
|
7
|
+
taken.forEach((entry, index) => {
|
|
8
|
+
entry.resolve(answers[index]);
|
|
9
|
+
});
|
|
10
|
+
}, (reason) => {
|
|
11
|
+
for (const entry of taken)
|
|
12
|
+
entry.reject(reason);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return (ask) => new Promise((resolve, reject) => {
|
|
16
|
+
if (held.length === 0) {
|
|
17
|
+
// Asks made in one task wait a single event-loop turn so they leave as one batch.
|
|
18
|
+
setTimeout(flush, 0);
|
|
19
|
+
}
|
|
20
|
+
held.push({ ask, resolve, reject });
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function selections(items, weight, limit) {
|
|
24
|
+
const parts = [];
|
|
25
|
+
let part = [];
|
|
26
|
+
let carried = 0;
|
|
27
|
+
for (const item of items) {
|
|
28
|
+
const weighed = weight(item);
|
|
29
|
+
if (part.length > 0 && carried + weighed > limit) {
|
|
30
|
+
parts.push(part);
|
|
31
|
+
part = [];
|
|
32
|
+
carried = 0;
|
|
33
|
+
}
|
|
34
|
+
part.push(item);
|
|
35
|
+
carried += weighed;
|
|
36
|
+
}
|
|
37
|
+
if (part.length > 0)
|
|
38
|
+
parts.push(part);
|
|
39
|
+
return parts;
|
|
40
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
2
|
export { nativePath, roomLocalPath } from './map.js';
|
|
3
|
-
export type { HouseByteAct, HouseByteTransfer, HouseDoorAnswer, HouseStream,
|
|
3
|
+
export type { HouseByteAct, HouseByteAnswer, HouseByteTransfer, HouseDoorAnswer, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
|
4
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,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,
|
|
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,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/links.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HouseScope, HouseView } from './read.js';
|
|
2
|
+
import type { StreamedAdvancement } from './stream.js';
|
|
3
|
+
export type RoomLinks = {
|
|
4
|
+
roomVersion: string;
|
|
5
|
+
handed: ReadonlySet<string>;
|
|
6
|
+
paths: ReadonlyMap<string, ReadonlySet<string>>;
|
|
7
|
+
revisions: ReadonlyMap<string, string>;
|
|
8
|
+
};
|
|
9
|
+
export declare function scopeLinks(scope: HouseScope): RoomLinks;
|
|
10
|
+
export declare function enumeratedLinks(view: HouseView, earlier: RoomLinks | undefined): RoomLinks;
|
|
11
|
+
export declare function streamedLinks(held: RoomLinks, advanced: StreamedAdvancement): RoomLinks | null;
|
|
12
|
+
//# sourceMappingURL=links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvD,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAYF,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAWvD;AAOD,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAgB1F;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI,CAoB9F"}
|