@agentshouse/mdruntime-adapter 0.1.0-alpha.9 → 0.1.0-c506c7d6e6199
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 +156 -27
- 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 +271 -197
- package/dist/digest.js +1 -5
- package/dist/discovery.d.ts +22 -26
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +154 -223
- 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 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- 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 +31 -26
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +208 -199
- package/dist/refusal.d.ts +3 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +27 -62
- 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 +209 -213
- package/dist/transport.d.ts +45 -28
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +2 -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 +5 -7
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +127 -215
- 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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Capability, DiscoveredRoom, Discovery, ProviderLimit, Retention
|
|
1
|
+
import type { Capability, DiscoveredRoom, Discovery, ModelIdentity, ProviderLimit, Retention } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type LogPosition } from './version.js';
|
|
3
3
|
export declare const ROOM_CONTRACT_VERSION = 1;
|
|
4
4
|
export declare const MD_MODEL_IDENTITY = "@agentshouse/mdmodel";
|
|
@@ -6,15 +6,18 @@ export declare const ROOM_VERSION_NOTIFICATIONS = "room-version-notifications";
|
|
|
6
6
|
export declare const PROVIDER_ACTIONS = "provider-actions";
|
|
7
7
|
export declare const MOVE_REFERENCE_REWRITES = "move-reference-rewrites";
|
|
8
8
|
export declare const DISCOVER_PREFIXES: readonly string[];
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const PROVIDER_SELECTION_MODEL_ROOT = "house/settings/model";
|
|
9
|
+
export declare const PRIVATE_HANDLE = "private";
|
|
11
10
|
export type HouseBounds = {
|
|
12
11
|
max_authored_file_bytes: number;
|
|
13
12
|
max_batch_operations: number;
|
|
13
|
+
max_batch_documents: number;
|
|
14
14
|
max_path_length: number;
|
|
15
15
|
max_path_depth: number;
|
|
16
16
|
max_mount_files: number;
|
|
17
17
|
max_mount_bytes: number;
|
|
18
|
+
max_inline_body_bytes: number;
|
|
19
|
+
max_upload_bytes: number;
|
|
20
|
+
max_prefixes: number;
|
|
18
21
|
change_retention_seconds: number;
|
|
19
22
|
operation_retention_seconds: number;
|
|
20
23
|
};
|
|
@@ -24,13 +27,16 @@ export type HouseOperations = {
|
|
|
24
27
|
write: readonly string[];
|
|
25
28
|
delete: readonly string[];
|
|
26
29
|
};
|
|
30
|
+
export type HouseModel = {
|
|
31
|
+
root: string;
|
|
32
|
+
paths: readonly string[];
|
|
33
|
+
};
|
|
27
34
|
export type HouseAuthority = LogPosition & {
|
|
28
|
-
kind: 'room' | 'private';
|
|
29
35
|
roomRef: string;
|
|
30
|
-
roomHandle: string
|
|
36
|
+
roomHandle: string;
|
|
31
37
|
name: string;
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
schema: string;
|
|
39
|
+
houseModel: HouseModel | null;
|
|
34
40
|
managedReplication: 'admitted' | 'unavailable';
|
|
35
41
|
protectedPaths: readonly string[];
|
|
36
42
|
operations: HouseOperations;
|
|
@@ -39,45 +45,35 @@ export type HouseDiscoveryDocument = {
|
|
|
39
45
|
bounds: HouseBounds;
|
|
40
46
|
mdModelVersion: string;
|
|
41
47
|
authorities: readonly HouseAuthority[];
|
|
48
|
+
actions: readonly string[];
|
|
42
49
|
};
|
|
43
50
|
export type TrackedAuthority = LogPosition & {
|
|
44
51
|
locator: string;
|
|
45
52
|
authority: string;
|
|
46
|
-
handle: string
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
export type HouseSiteSlot = {
|
|
52
|
-
slot: string;
|
|
53
|
-
roomRef: string | null;
|
|
53
|
+
handle: string;
|
|
54
|
+
schema: string;
|
|
55
|
+
houseModel: HouseModel | null;
|
|
56
|
+
schemas: readonly string[];
|
|
54
57
|
};
|
|
55
58
|
export type HouseSiteAuthority = LogPosition & {
|
|
56
59
|
roomRef: string;
|
|
57
60
|
roomHandle: string;
|
|
58
|
-
|
|
59
|
-
modelRoot: string;
|
|
61
|
+
schema: string;
|
|
60
62
|
};
|
|
61
63
|
export type HouseSiteDiscovery = {
|
|
62
64
|
bounds: HouseBounds;
|
|
63
65
|
mdModelVersion: string;
|
|
64
|
-
slots: readonly HouseSiteSlot[];
|
|
65
66
|
authorities: readonly HouseSiteAuthority[];
|
|
66
67
|
};
|
|
67
|
-
export type SiteTracked = TrackedAuthority & {
|
|
68
|
-
slot: string;
|
|
69
|
-
};
|
|
70
68
|
export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
|
|
71
69
|
export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
|
|
72
|
-
export declare function
|
|
73
|
-
export declare function siteTracked(document: HouseSiteDiscovery): SiteTracked[];
|
|
70
|
+
export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthority[];
|
|
74
71
|
export declare function locatorOf(authority: HouseAuthority): string;
|
|
75
72
|
export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
|
|
76
73
|
export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
|
|
77
74
|
export declare function declaredRetention(bounds: HouseBounds): Retention;
|
|
78
|
-
export declare function capabilities(): readonly Capability[];
|
|
75
|
+
export declare function capabilities(actions: readonly string[]): readonly Capability[];
|
|
79
76
|
export declare function siteCapabilities(): readonly Capability[];
|
|
80
|
-
export declare function
|
|
81
|
-
export declare function discoveredRoom(authority: HouseAuthority, attachedModel: DiscoveredRoom['attachedModel'], typedSelection: TypedSelection | undefined): DiscoveredRoom;
|
|
77
|
+
export declare function discoveredRoom(authority: HouseAuthority, attachedModel: DiscoveredRoom['attachedModel'], selectionModel: ModelIdentity | null): DiscoveredRoom;
|
|
82
78
|
export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds' | 'mdModelVersion'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
|
|
83
79
|
//# sourceMappingURL=discovery.d.ts.map
|
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,
|
|
1
|
+
{"version":3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kB,CAAC,IAAI,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAc3E;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,gBAAgB,EAAE,CAW5E;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,cAAc,GAAG,MAAM,CAE3D;AAQD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,sBAAsB,GAAG,gBAAgB,EAAE,CAWhF;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,cAAc,CAC5B,SAAS,EAAE,cAAc,EACzB,aAAa,EAAE,cAAc,CAAC,eAAe,CAAC,EAC9C,cAAc,EAAE,aAAa,GAAG,IAAI,GACnC,cAAc,CAuBhB;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,271 @@
|
|
|
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
|
-
];
|
|
12
|
-
export const PROVIDER_SELECTION_ROOTS = [
|
|
13
|
-
'agents',
|
|
14
|
-
'house'
|
|
15
|
-
];
|
|
16
|
-
export const PROVIDER_SELECTION_MODEL_ROOT = 'house/settings/model';
|
|
9
|
+
export const DISCOVER_PREFIXES = ['/'];
|
|
10
|
+
export const PRIVATE_HANDLE = 'private';
|
|
17
11
|
const BOUND_KEYS = [
|
|
18
12
|
'max_authored_file_bytes',
|
|
19
13
|
'max_batch_operations',
|
|
14
|
+
'max_batch_documents',
|
|
20
15
|
'max_path_length',
|
|
21
16
|
'max_path_depth',
|
|
22
17
|
'max_mount_files',
|
|
23
18
|
'max_mount_bytes',
|
|
19
|
+
'max_inline_body_bytes',
|
|
20
|
+
'max_upload_bytes',
|
|
21
|
+
'max_prefixes',
|
|
24
22
|
'change_retention_seconds',
|
|
25
|
-
'operation_retention_seconds'
|
|
26
|
-
];
|
|
27
|
-
const OPERATION_KEYS = [
|
|
28
|
-
'read',
|
|
29
|
-
'sync',
|
|
30
|
-
'write',
|
|
31
|
-
'delete'
|
|
23
|
+
'operation_retention_seconds',
|
|
32
24
|
];
|
|
25
|
+
const OPERATION_KEYS = ['read', 'sync', 'write', 'delete'];
|
|
33
26
|
function stringList(value) {
|
|
34
|
-
if (!Array.isArray(value))
|
|
35
|
-
|
|
27
|
+
if (!Array.isArray(value))
|
|
28
|
+
return null;
|
|
29
|
+
return value.every((entry) => typeof entry === 'string') ? value : null;
|
|
36
30
|
}
|
|
37
31
|
function parseBounds(value) {
|
|
38
|
-
if (typeof value !== 'object' || value === null)
|
|
32
|
+
if (typeof value !== 'object' || value === null)
|
|
33
|
+
return null;
|
|
39
34
|
const held = value;
|
|
40
35
|
const bounds = {};
|
|
41
|
-
for (const key of BOUND_KEYS){
|
|
36
|
+
for (const key of BOUND_KEYS) {
|
|
42
37
|
const amount = held[key];
|
|
43
|
-
if (typeof amount !== 'number' || !Number.isFinite(amount))
|
|
38
|
+
if (typeof amount !== 'number' || !Number.isFinite(amount))
|
|
39
|
+
return null;
|
|
44
40
|
bounds[key] = amount;
|
|
45
41
|
}
|
|
46
42
|
return bounds;
|
|
47
43
|
}
|
|
44
|
+
function parseHouseModel(value) {
|
|
45
|
+
if (value === undefined)
|
|
46
|
+
return null;
|
|
47
|
+
if (typeof value !== 'object' || value === null)
|
|
48
|
+
return undefined;
|
|
49
|
+
const held = value;
|
|
50
|
+
const paths = stringList(held.paths);
|
|
51
|
+
if (typeof held.root !== 'string' || held.root.length === 0 || paths === null)
|
|
52
|
+
return undefined;
|
|
53
|
+
return { root: held.root, paths };
|
|
54
|
+
}
|
|
48
55
|
function parseOperations(value) {
|
|
49
|
-
if (typeof value !== 'object' || value === null)
|
|
56
|
+
if (typeof value !== 'object' || value === null)
|
|
57
|
+
return null;
|
|
50
58
|
const held = value;
|
|
51
59
|
const operations = {};
|
|
52
|
-
for (const key of OPERATION_KEYS){
|
|
60
|
+
for (const key of OPERATION_KEYS) {
|
|
53
61
|
const scopes = stringList(held[key]);
|
|
54
|
-
if (scopes === null)
|
|
62
|
+
if (scopes === null)
|
|
63
|
+
return null;
|
|
55
64
|
operations[key] = scopes;
|
|
56
65
|
}
|
|
57
66
|
return operations;
|
|
58
67
|
}
|
|
59
68
|
function parseAuthority(value) {
|
|
60
|
-
if (typeof value !== 'object' || value === null)
|
|
69
|
+
if (typeof value !== 'object' || value === null)
|
|
70
|
+
return null;
|
|
61
71
|
const held = value;
|
|
62
|
-
if (held.kind !== 'room'
|
|
63
|
-
|
|
64
|
-
if (typeof held.
|
|
72
|
+
if (held.kind !== 'room')
|
|
73
|
+
return null;
|
|
74
|
+
if (typeof held.name !== 'string' || held.name.length === 0)
|
|
75
|
+
return null;
|
|
76
|
+
if (typeof held.model_root !== 'string')
|
|
77
|
+
return null;
|
|
65
78
|
if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {
|
|
66
79
|
return null;
|
|
67
80
|
}
|
|
68
81
|
const at = readPosition(held);
|
|
82
|
+
const houseModel = parseHouseModel(held.house_model);
|
|
69
83
|
const protectedPaths = stringList(held.protected_paths);
|
|
70
84
|
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;
|
|
85
|
+
if (at === null || houseModel === undefined || protectedPaths === null || operations === null)
|
|
86
|
+
return null;
|
|
87
|
+
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
|
|
88
|
+
return null;
|
|
89
|
+
if (typeof held.room_handle !== 'string' || held.room_handle.length === 0)
|
|
90
|
+
return null;
|
|
88
91
|
return {
|
|
89
|
-
kind: 'room',
|
|
90
92
|
roomRef: held.room_ref,
|
|
91
93
|
roomHandle: held.room_handle,
|
|
92
94
|
name: held.name,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
schema: held.model_root,
|
|
96
|
+
houseModel,
|
|
95
97
|
managedReplication: held.managed_replication,
|
|
96
98
|
protectedPaths,
|
|
97
99
|
operations,
|
|
98
|
-
...at
|
|
100
|
+
...at,
|
|
99
101
|
};
|
|
100
102
|
}
|
|
101
103
|
export function parseDiscovery(body) {
|
|
102
|
-
if (typeof body !== 'object' || body === null)
|
|
104
|
+
if (typeof body !== 'object' || body === null)
|
|
105
|
+
return null;
|
|
103
106
|
const held = body;
|
|
104
107
|
const bounds = parseBounds(held.bounds);
|
|
105
|
-
if (bounds === null)
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
+
if (bounds === null)
|
|
109
|
+
return null;
|
|
110
|
+
if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0)
|
|
111
|
+
return null;
|
|
112
|
+
const actions = stringList(held.actions);
|
|
113
|
+
if (actions === null ||
|
|
114
|
+
new Set(actions).size !== actions.length ||
|
|
115
|
+
actions.some((name) => name.length === 0))
|
|
116
|
+
return null;
|
|
117
|
+
if (!Array.isArray(held.authorities))
|
|
118
|
+
return null;
|
|
108
119
|
const authorities = [];
|
|
109
|
-
for (const entry of held.authorities){
|
|
120
|
+
for (const entry of held.authorities) {
|
|
110
121
|
const authority = parseAuthority(entry);
|
|
111
|
-
if (authority === null)
|
|
122
|
+
if (authority === null)
|
|
123
|
+
return null;
|
|
112
124
|
authorities.push(authority);
|
|
113
125
|
}
|
|
114
|
-
return {
|
|
115
|
-
bounds,
|
|
116
|
-
mdModelVersion: held.md_model_version,
|
|
117
|
-
authorities
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
function parseSiteSlot(value) {
|
|
121
|
-
if (typeof value !== 'object' || value === null) return null;
|
|
122
|
-
const held = value;
|
|
123
|
-
if (typeof held.slot !== 'string' || held.slot.length === 0) return null;
|
|
124
|
-
if (held.room_ref === null) return {
|
|
125
|
-
slot: held.slot,
|
|
126
|
-
roomRef: null
|
|
127
|
-
};
|
|
128
|
-
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;
|
|
129
|
-
return {
|
|
130
|
-
slot: held.slot,
|
|
131
|
-
roomRef: held.room_ref
|
|
132
|
-
};
|
|
126
|
+
return { bounds, mdModelVersion: held.md_model_version, authorities, actions };
|
|
133
127
|
}
|
|
134
128
|
function parseSiteAuthority(value) {
|
|
135
|
-
if (typeof value !== 'object' || value === null)
|
|
129
|
+
if (typeof value !== 'object' || value === null)
|
|
130
|
+
return null;
|
|
136
131
|
const held = value;
|
|
137
|
-
if (held.kind !== 'room')
|
|
138
|
-
|
|
139
|
-
if (typeof held.
|
|
140
|
-
|
|
132
|
+
if (held.kind !== 'room')
|
|
133
|
+
return null;
|
|
134
|
+
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
|
|
135
|
+
return null;
|
|
136
|
+
if (typeof held.room_handle !== 'string' || held.room_handle.length === 0)
|
|
137
|
+
return null;
|
|
138
|
+
if (typeof held.model_root !== 'string')
|
|
139
|
+
return null;
|
|
141
140
|
const at = readPosition(held);
|
|
142
|
-
if (at === null)
|
|
141
|
+
if (at === null)
|
|
142
|
+
return null;
|
|
143
143
|
return {
|
|
144
144
|
roomRef: held.room_ref,
|
|
145
145
|
roomHandle: held.room_handle,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...at
|
|
146
|
+
schema: held.model_root,
|
|
147
|
+
...at,
|
|
149
148
|
};
|
|
150
149
|
}
|
|
151
150
|
export function parseSiteDiscovery(body) {
|
|
152
|
-
if (typeof body !== 'object' || body === null)
|
|
151
|
+
if (typeof body !== 'object' || body === null)
|
|
152
|
+
return null;
|
|
153
153
|
const held = body;
|
|
154
154
|
const bounds = parseBounds(held.bounds);
|
|
155
|
-
if (bounds === null)
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (slot === null) return null;
|
|
162
|
-
slots.push(slot);
|
|
163
|
-
}
|
|
155
|
+
if (bounds === null)
|
|
156
|
+
return null;
|
|
157
|
+
if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0)
|
|
158
|
+
return null;
|
|
159
|
+
if (!Array.isArray(held.authorities))
|
|
160
|
+
return null;
|
|
164
161
|
const authorities = [];
|
|
165
|
-
for (const entry of held.authorities){
|
|
162
|
+
for (const entry of held.authorities) {
|
|
166
163
|
const authority = parseSiteAuthority(entry);
|
|
167
|
-
if (authority === null)
|
|
164
|
+
if (authority === null)
|
|
165
|
+
return null;
|
|
168
166
|
authorities.push(authority);
|
|
169
167
|
}
|
|
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}`;
|
|
168
|
+
return { bounds, mdModelVersion: held.md_model_version, authorities };
|
|
179
169
|
}
|
|
180
170
|
export function siteTracked(document) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
locator: siteLocator(slot, authority.roomRef),
|
|
192
|
-
authority: authority.roomRef,
|
|
193
|
-
handle: authority.roomHandle,
|
|
194
|
-
collectionRoot: authority.collectionRoot,
|
|
195
|
-
modelRoot: authority.modelRoot,
|
|
196
|
-
modelRoots: [
|
|
197
|
-
authority.modelRoot
|
|
198
|
-
],
|
|
199
|
-
position: authority.position,
|
|
200
|
-
logEpoch: authority.logEpoch
|
|
201
|
-
}
|
|
202
|
-
];
|
|
203
|
-
});
|
|
171
|
+
return document.authorities.map((authority) => ({
|
|
172
|
+
locator: authority.roomRef,
|
|
173
|
+
authority: authority.roomRef,
|
|
174
|
+
handle: authority.roomHandle,
|
|
175
|
+
schema: authority.schema,
|
|
176
|
+
houseModel: null,
|
|
177
|
+
schemas: [authority.schema],
|
|
178
|
+
position: authority.position,
|
|
179
|
+
logEpoch: authority.logEpoch,
|
|
180
|
+
}));
|
|
204
181
|
}
|
|
205
182
|
export function locatorOf(authority) {
|
|
206
|
-
return authority.roomHandle
|
|
183
|
+
return authority.roomHandle === PRIVATE_HANDLE ? PRIVATE_LOCATOR : authority.roomRef;
|
|
184
|
+
}
|
|
185
|
+
function schemasOf(authority) {
|
|
186
|
+
return authority.houseModel === null
|
|
187
|
+
? [authority.schema]
|
|
188
|
+
: [authority.schema, authority.houseModel.root];
|
|
207
189
|
}
|
|
208
190
|
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
|
-
}));
|
|
191
|
+
return document.authorities.map((authority) => ({
|
|
192
|
+
locator: locatorOf(authority),
|
|
193
|
+
authority: authority.roomRef,
|
|
194
|
+
handle: authority.roomHandle,
|
|
195
|
+
schema: authority.schema,
|
|
196
|
+
houseModel: authority.houseModel,
|
|
197
|
+
schemas: schemasOf(authority),
|
|
198
|
+
position: authority.position,
|
|
199
|
+
logEpoch: authority.logEpoch,
|
|
200
|
+
}));
|
|
224
201
|
}
|
|
225
202
|
export function providerLimits(bounds) {
|
|
226
203
|
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
|
-
}
|
|
204
|
+
{ name: 'document-size', value: bounds.max_authored_file_bytes },
|
|
205
|
+
{ name: 'change-batch-operations', value: bounds.max_batch_operations },
|
|
206
|
+
{ name: 'change-documents', value: bounds.max_batch_documents },
|
|
207
|
+
{ name: 'path-length', value: bounds.max_path_length },
|
|
208
|
+
{ name: 'path-depth', value: bounds.max_path_depth },
|
|
209
|
+
{ name: 'write-rate' },
|
|
210
|
+
{ name: 'content-ceiling' },
|
|
249
211
|
];
|
|
250
212
|
}
|
|
251
213
|
export function declaredRetention(bounds) {
|
|
252
214
|
return {
|
|
253
|
-
history: {
|
|
254
|
-
kind: 'no-declared-time-bound'
|
|
255
|
-
},
|
|
215
|
+
history: { kind: 'no-declared-time-bound' },
|
|
256
216
|
outcome: bounds.operation_retention_seconds,
|
|
257
|
-
refreshHorizon: bounds.change_retention_seconds
|
|
217
|
+
refreshHorizon: bounds.change_retention_seconds,
|
|
258
218
|
};
|
|
259
219
|
}
|
|
260
|
-
export function capabilities() {
|
|
220
|
+
export function capabilities(actions) {
|
|
261
221
|
return [
|
|
262
|
-
{
|
|
263
|
-
name: ROOM_VERSION_NOTIFICATIONS
|
|
264
|
-
},
|
|
222
|
+
{ name: ROOM_VERSION_NOTIFICATIONS },
|
|
265
223
|
{
|
|
266
224
|
name: PROVIDER_ACTIONS,
|
|
267
|
-
actions: declaredActions(),
|
|
268
|
-
conversationCards: HOUSE_CONVERSATION_CARDS
|
|
225
|
+
actions: declaredActions(actions),
|
|
226
|
+
conversationCards: HOUSE_CONVERSATION_CARDS,
|
|
269
227
|
},
|
|
270
|
-
{
|
|
271
|
-
name: MOVE_REFERENCE_REWRITES
|
|
272
|
-
}
|
|
228
|
+
{ name: MOVE_REFERENCE_REWRITES },
|
|
273
229
|
];
|
|
274
230
|
}
|
|
275
231
|
export function siteCapabilities() {
|
|
276
232
|
return [
|
|
277
|
-
{
|
|
278
|
-
|
|
279
|
-
}
|
|
233
|
+
{ name: ROOM_VERSION_NOTIFICATIONS },
|
|
234
|
+
{ name: PROVIDER_ACTIONS, actions: [{ name: 'submit', inputShape: {}, resultKind: 'house' }] },
|
|
280
235
|
];
|
|
281
236
|
}
|
|
282
|
-
export function
|
|
283
|
-
return {
|
|
284
|
-
roots: [
|
|
285
|
-
...PROVIDER_SELECTION_ROOTS
|
|
286
|
-
],
|
|
287
|
-
attachedModel
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
export function discoveredRoom(authority, attachedModel, typedSelection) {
|
|
237
|
+
export function discoveredRoom(authority, attachedModel, selectionModel) {
|
|
291
238
|
return {
|
|
292
239
|
name: authority.name,
|
|
293
240
|
locator: locatorOf(authority),
|
|
294
|
-
collectionRoot: authority.collectionRoot,
|
|
295
241
|
roomVersion: roomVersion(authority),
|
|
296
242
|
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
|
|
243
|
+
read: [...authority.operations.read],
|
|
244
|
+
sync: [...authority.operations.sync],
|
|
245
|
+
write: [...authority.operations.write],
|
|
246
|
+
delete: [...authority.operations.delete],
|
|
313
247
|
},
|
|
248
|
+
replica: { selection: locatorOf(authority), admission: authority.managedReplication },
|
|
314
249
|
attachedModel,
|
|
315
|
-
...
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
250
|
+
...(authority.houseModel === null
|
|
251
|
+
? {}
|
|
252
|
+
: {
|
|
253
|
+
typedSelection: {
|
|
254
|
+
roots: [...authority.houseModel.paths],
|
|
255
|
+
attachedModel: selectionModel,
|
|
256
|
+
},
|
|
257
|
+
}),
|
|
258
|
+
providerOwnedPaths: [...authority.protectedPaths, ...schemasOf(authority)],
|
|
321
259
|
};
|
|
322
260
|
}
|
|
323
261
|
export function mapDiscovery(document, rooms, declared) {
|
|
324
262
|
return {
|
|
325
263
|
kind: 'discovery',
|
|
326
|
-
supportedVersions: [
|
|
327
|
-
|
|
328
|
-
],
|
|
329
|
-
mdModel: {
|
|
330
|
-
identity: MD_MODEL_IDENTITY,
|
|
331
|
-
version: document.mdModelVersion
|
|
332
|
-
},
|
|
264
|
+
supportedVersions: [ROOM_CONTRACT_VERSION],
|
|
265
|
+
mdModel: { identity: MD_MODEL_IDENTITY, version: document.mdModelVersion },
|
|
333
266
|
rooms,
|
|
334
267
|
capabilities: declared,
|
|
335
268
|
providerLimits: providerLimits(document.bounds),
|
|
336
|
-
retention: declaredRetention(document.bounds)
|
|
269
|
+
retention: declaredRetention(document.bounds),
|
|
337
270
|
};
|
|
338
271
|
}
|
|
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
|
+
}
|