@agentshouse/mdruntime-adapter 0.1.0-alpha.9 → 0.1.0-c023d3564cb7c
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 +312 -74
- package/README.md +32 -0
- package/dist/actions.d.ts +57 -13
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +274 -397
- package/dist/adapter.d.ts +1 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +525 -216
- package/dist/digest.js +1 -5
- package/dist/discovery.d.ts +27 -36
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +173 -228
- package/dist/gather.d.ts +4 -0
- package/dist/gather.d.ts.map +1 -0
- package/dist/gather.js +35 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- 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 +7 -18
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +60 -57
- package/dist/part.d.ts +15 -0
- package/dist/part.d.ts.map +1 -0
- package/dist/part.js +85 -0
- package/dist/read.d.ts +93 -35
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +415 -245
- package/dist/refusal.d.ts +5 -7
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +47 -68
- package/dist/room-types.d.ts +6 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +66 -0
- package/dist/site.d.ts +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +219 -161
- package/dist/stream.d.ts +18 -6
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +556 -214
- package/dist/transport.d.ts +131 -38
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +4 -3
- package/dist/upload.d.ts +12 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +52 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +32 -18
- package/dist/write.d.ts +18 -8
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +259 -228
- package/package.json +4 -13
- 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/digest.js
CHANGED
|
@@ -3,9 +3,5 @@ export function textBytes(value) {
|
|
|
3
3
|
}
|
|
4
4
|
export async function sha256Hex(value) {
|
|
5
5
|
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value));
|
|
6
|
-
return [
|
|
7
|
-
...new Uint8Array(digest)
|
|
8
|
-
].map((byte)=>byte.toString(16).padStart(2, '0')).join('');
|
|
6
|
+
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=digest.js.map
|
package/dist/discovery.d.ts
CHANGED
|
@@ -1,83 +1,74 @@
|
|
|
1
|
-
import type { Capability, DiscoveredRoom, Discovery, ProviderLimit, Retention
|
|
1
|
+
import type { Capability, DiscoveredRoom, Discovery, Member, ProviderLimit, Retention } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type LogPosition } from './version.js';
|
|
3
|
-
export declare const ROOM_CONTRACT_VERSION = 1;
|
|
4
|
-
export declare const MD_MODEL_IDENTITY = "@agentshouse/mdmodel";
|
|
5
|
-
export declare const ROOM_VERSION_NOTIFICATIONS = "room-version-notifications";
|
|
6
3
|
export declare const PROVIDER_ACTIONS = "provider-actions";
|
|
7
|
-
export declare const MOVE_REFERENCE_REWRITES = "move-reference-rewrites";
|
|
8
4
|
export declare const DISCOVER_PREFIXES: readonly string[];
|
|
9
|
-
export declare const PROVIDER_SELECTION_ROOTS: readonly string[];
|
|
10
|
-
export declare const PROVIDER_SELECTION_MODEL_ROOT = "house/settings/model";
|
|
11
5
|
export type HouseBounds = {
|
|
12
6
|
max_authored_file_bytes: number;
|
|
13
7
|
max_batch_operations: number;
|
|
8
|
+
max_batch_documents: number;
|
|
14
9
|
max_path_length: number;
|
|
15
10
|
max_path_depth: number;
|
|
16
11
|
max_mount_files: number;
|
|
17
12
|
max_mount_bytes: number;
|
|
13
|
+
max_inline_body_bytes: number;
|
|
14
|
+
max_upload_bytes: number;
|
|
15
|
+
max_prefixes: number;
|
|
16
|
+
max_held_files: number;
|
|
18
17
|
change_retention_seconds: number;
|
|
19
18
|
operation_retention_seconds: number;
|
|
19
|
+
max_move_documents?: number;
|
|
20
20
|
};
|
|
21
21
|
export type HouseOperations = {
|
|
22
|
-
read: readonly string[];
|
|
23
|
-
sync: readonly string[];
|
|
24
22
|
write: readonly string[];
|
|
25
23
|
delete: readonly string[];
|
|
26
24
|
};
|
|
25
|
+
export type HouseReadLevel = 'mcp' | 'online' | 'local';
|
|
26
|
+
export type HouseModel = {
|
|
27
|
+
root: string;
|
|
28
|
+
paths: readonly string[];
|
|
29
|
+
};
|
|
27
30
|
export type HouseAuthority = LogPosition & {
|
|
28
|
-
kind: 'room' | 'private';
|
|
29
31
|
roomRef: string;
|
|
30
|
-
roomHandle: string
|
|
32
|
+
roomHandle: string;
|
|
31
33
|
name: string;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
schema: string;
|
|
35
|
+
houseModel: HouseModel | null;
|
|
34
36
|
managedReplication: 'admitted' | 'unavailable';
|
|
35
37
|
protectedPaths: readonly string[];
|
|
38
|
+
read: HouseReadLevel;
|
|
36
39
|
operations: HouseOperations;
|
|
37
40
|
};
|
|
38
41
|
export type HouseDiscoveryDocument = {
|
|
42
|
+
member: Member;
|
|
39
43
|
bounds: HouseBounds;
|
|
40
|
-
mdModelVersion: string;
|
|
41
44
|
authorities: readonly HouseAuthority[];
|
|
45
|
+
actions: readonly string[];
|
|
42
46
|
};
|
|
43
47
|
export type TrackedAuthority = LogPosition & {
|
|
44
48
|
locator: string;
|
|
45
49
|
authority: string;
|
|
46
|
-
handle: string
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
export type HouseSiteSlot = {
|
|
52
|
-
slot: string;
|
|
53
|
-
roomRef: string | null;
|
|
50
|
+
handle: string;
|
|
51
|
+
schema: string;
|
|
52
|
+
houseModel: HouseModel | null;
|
|
53
|
+
schemas: readonly string[];
|
|
54
54
|
};
|
|
55
55
|
export type HouseSiteAuthority = LogPosition & {
|
|
56
56
|
roomRef: string;
|
|
57
57
|
roomHandle: string;
|
|
58
|
-
|
|
59
|
-
modelRoot: string;
|
|
58
|
+
schema: string;
|
|
60
59
|
};
|
|
61
60
|
export type HouseSiteDiscovery = {
|
|
62
61
|
bounds: HouseBounds;
|
|
63
|
-
mdModelVersion: string;
|
|
64
|
-
slots: readonly HouseSiteSlot[];
|
|
65
62
|
authorities: readonly HouseSiteAuthority[];
|
|
66
63
|
};
|
|
67
|
-
export type SiteTracked = TrackedAuthority & {
|
|
68
|
-
slot: string;
|
|
69
|
-
};
|
|
70
64
|
export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
|
|
71
65
|
export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
|
|
72
|
-
export declare function
|
|
73
|
-
export declare function siteTracked(document: HouseSiteDiscovery): SiteTracked[];
|
|
74
|
-
export declare function locatorOf(authority: HouseAuthority): string;
|
|
66
|
+
export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthority[];
|
|
75
67
|
export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
|
|
76
68
|
export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
|
|
77
69
|
export declare function declaredRetention(bounds: HouseBounds): Retention;
|
|
78
|
-
export declare function capabilities(): readonly Capability[];
|
|
70
|
+
export declare function capabilities(actions: HouseDiscoveryDocument['actions'], rooms: readonly Pick<TrackedAuthority, 'authority' | 'houseModel'>[]): readonly Capability[];
|
|
79
71
|
export declare function siteCapabilities(): readonly Capability[];
|
|
80
|
-
export declare function
|
|
81
|
-
export declare function
|
|
82
|
-
export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds' | 'mdModelVersion'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
|
|
72
|
+
export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
|
|
73
|
+
export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
|
|
83
74
|
//# 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,SAAS,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,MAAM,EACN,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;AAE1D,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc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;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,EAChD,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,SAAS,CAQX"}
|
package/dist/discovery.js
CHANGED
|
@@ -1,340 +1,285 @@
|
|
|
1
|
-
import { declaredActions,
|
|
2
|
-
import { PRIVATE_AUTHORITY } from './transport.js';
|
|
1
|
+
import { declaredActions, houseConversationAgents, SITE_SUBMIT } from './actions.js';
|
|
3
2
|
import { readPosition, roomVersion } from './version.js';
|
|
4
|
-
export const ROOM_CONTRACT_VERSION = 1;
|
|
5
|
-
export const MD_MODEL_IDENTITY = '@agentshouse/mdmodel';
|
|
6
|
-
export const ROOM_VERSION_NOTIFICATIONS = 'room-version-notifications';
|
|
7
3
|
export const PROVIDER_ACTIONS = 'provider-actions';
|
|
8
|
-
export const
|
|
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';
|
|
4
|
+
export const DISCOVER_PREFIXES = ['/'];
|
|
17
5
|
const BOUND_KEYS = [
|
|
18
6
|
'max_authored_file_bytes',
|
|
19
7
|
'max_batch_operations',
|
|
8
|
+
'max_batch_documents',
|
|
20
9
|
'max_path_length',
|
|
21
10
|
'max_path_depth',
|
|
22
11
|
'max_mount_files',
|
|
23
12
|
'max_mount_bytes',
|
|
13
|
+
'max_inline_body_bytes',
|
|
14
|
+
'max_upload_bytes',
|
|
15
|
+
'max_prefixes',
|
|
16
|
+
'max_held_files',
|
|
24
17
|
'change_retention_seconds',
|
|
25
|
-
'operation_retention_seconds'
|
|
26
|
-
];
|
|
27
|
-
const OPERATION_KEYS = [
|
|
28
|
-
'read',
|
|
29
|
-
'sync',
|
|
30
|
-
'write',
|
|
31
|
-
'delete'
|
|
18
|
+
'operation_retention_seconds',
|
|
32
19
|
];
|
|
20
|
+
const OPERATION_KEYS = ['write', 'delete'];
|
|
21
|
+
const READ_LEVELS = ['mcp', 'online', 'local'];
|
|
33
22
|
function stringList(value) {
|
|
34
|
-
if (!Array.isArray(value))
|
|
35
|
-
|
|
23
|
+
if (!Array.isArray(value))
|
|
24
|
+
return null;
|
|
25
|
+
return value.every((entry) => typeof entry === 'string') ? value : null;
|
|
36
26
|
}
|
|
37
27
|
function parseBounds(value) {
|
|
38
|
-
if (typeof value !== 'object' || value === null)
|
|
28
|
+
if (typeof value !== 'object' || value === null)
|
|
29
|
+
return null;
|
|
39
30
|
const held = value;
|
|
40
31
|
const bounds = {};
|
|
41
|
-
for (const key of BOUND_KEYS){
|
|
32
|
+
for (const key of BOUND_KEYS) {
|
|
42
33
|
const amount = held[key];
|
|
43
|
-
if (typeof amount !== 'number' || !Number.isFinite(amount))
|
|
34
|
+
if (typeof amount !== 'number' || !Number.isFinite(amount))
|
|
35
|
+
return null;
|
|
44
36
|
bounds[key] = amount;
|
|
45
37
|
}
|
|
38
|
+
const moves = held.max_move_documents;
|
|
39
|
+
if (moves !== undefined) {
|
|
40
|
+
if (typeof moves !== 'number' || !Number.isFinite(moves))
|
|
41
|
+
return null;
|
|
42
|
+
bounds.max_move_documents = moves;
|
|
43
|
+
}
|
|
46
44
|
return bounds;
|
|
47
45
|
}
|
|
46
|
+
function parseHouseModel(value) {
|
|
47
|
+
if (value === undefined)
|
|
48
|
+
return null;
|
|
49
|
+
if (typeof value !== 'object' || value === null)
|
|
50
|
+
return undefined;
|
|
51
|
+
const held = value;
|
|
52
|
+
const paths = stringList(held.paths);
|
|
53
|
+
if (typeof held.root !== 'string' || held.root.length === 0 || paths === null)
|
|
54
|
+
return undefined;
|
|
55
|
+
return { root: held.root, paths };
|
|
56
|
+
}
|
|
57
|
+
function parseMember(value) {
|
|
58
|
+
if (typeof value !== 'object' || value === null)
|
|
59
|
+
return null;
|
|
60
|
+
const { user, name } = value;
|
|
61
|
+
if (typeof user !== 'string' || typeof name !== 'string')
|
|
62
|
+
return null;
|
|
63
|
+
return { kind: 'user', id: user, name };
|
|
64
|
+
}
|
|
48
65
|
function parseOperations(value) {
|
|
49
|
-
if (typeof value !== 'object' || value === null)
|
|
66
|
+
if (typeof value !== 'object' || value === null)
|
|
67
|
+
return null;
|
|
50
68
|
const held = value;
|
|
51
69
|
const operations = {};
|
|
52
|
-
for (const key of OPERATION_KEYS){
|
|
70
|
+
for (const key of OPERATION_KEYS) {
|
|
53
71
|
const scopes = stringList(held[key]);
|
|
54
|
-
if (scopes === null)
|
|
72
|
+
if (scopes === null)
|
|
73
|
+
return null;
|
|
55
74
|
operations[key] = scopes;
|
|
56
75
|
}
|
|
57
76
|
return operations;
|
|
58
77
|
}
|
|
59
78
|
function parseAuthority(value) {
|
|
60
|
-
if (typeof value !== 'object' || value === null)
|
|
79
|
+
if (typeof value !== 'object' || value === null)
|
|
80
|
+
return null;
|
|
61
81
|
const held = value;
|
|
62
|
-
if (held.kind !== 'room'
|
|
63
|
-
|
|
64
|
-
if (typeof held.
|
|
82
|
+
if (held.kind !== 'room')
|
|
83
|
+
return null;
|
|
84
|
+
if (typeof held.name !== 'string' || held.name.length === 0)
|
|
85
|
+
return null;
|
|
86
|
+
if (typeof held.model_root !== 'string')
|
|
87
|
+
return null;
|
|
65
88
|
if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {
|
|
66
89
|
return null;
|
|
67
90
|
}
|
|
68
91
|
const at = readPosition(held);
|
|
92
|
+
const houseModel = parseHouseModel(held.house_model);
|
|
69
93
|
const protectedPaths = stringList(held.protected_paths);
|
|
70
94
|
const operations = parseOperations(held.operations);
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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;
|
|
95
|
+
const read = READ_LEVELS.find((level) => level === held.read);
|
|
96
|
+
if (at === null ||
|
|
97
|
+
houseModel === undefined ||
|
|
98
|
+
protectedPaths === null ||
|
|
99
|
+
read === undefined ||
|
|
100
|
+
operations === null)
|
|
101
|
+
return null;
|
|
102
|
+
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
|
|
103
|
+
return null;
|
|
104
|
+
if (typeof held.room_handle !== 'string' || held.room_handle.length === 0)
|
|
105
|
+
return null;
|
|
88
106
|
return {
|
|
89
|
-
kind: 'room',
|
|
90
107
|
roomRef: held.room_ref,
|
|
91
108
|
roomHandle: held.room_handle,
|
|
92
109
|
name: held.name,
|
|
93
|
-
|
|
94
|
-
|
|
110
|
+
schema: held.model_root,
|
|
111
|
+
houseModel,
|
|
95
112
|
managedReplication: held.managed_replication,
|
|
96
113
|
protectedPaths,
|
|
114
|
+
read,
|
|
97
115
|
operations,
|
|
98
|
-
...at
|
|
116
|
+
...at,
|
|
99
117
|
};
|
|
100
118
|
}
|
|
101
119
|
export function parseDiscovery(body) {
|
|
102
|
-
if (typeof body !== 'object' || body === null)
|
|
120
|
+
if (typeof body !== 'object' || body === null)
|
|
121
|
+
return null;
|
|
103
122
|
const held = body;
|
|
123
|
+
const member = parseMember(held.member);
|
|
124
|
+
if (member === null)
|
|
125
|
+
return null;
|
|
104
126
|
const bounds = parseBounds(held.bounds);
|
|
105
|
-
if (bounds === null)
|
|
106
|
-
|
|
107
|
-
|
|
127
|
+
if (bounds === null)
|
|
128
|
+
return null;
|
|
129
|
+
const actions = stringList(held.actions);
|
|
130
|
+
if (actions === null ||
|
|
131
|
+
new Set(actions).size !== actions.length ||
|
|
132
|
+
actions.some((name) => name.length === 0))
|
|
133
|
+
return null;
|
|
134
|
+
if (!Array.isArray(held.authorities))
|
|
135
|
+
return null;
|
|
108
136
|
const authorities = [];
|
|
109
|
-
for (const entry of held.authorities){
|
|
137
|
+
for (const entry of held.authorities) {
|
|
110
138
|
const authority = parseAuthority(entry);
|
|
111
|
-
if (authority === null)
|
|
139
|
+
if (authority === null)
|
|
140
|
+
return null;
|
|
112
141
|
authorities.push(authority);
|
|
113
142
|
}
|
|
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
|
-
};
|
|
143
|
+
return { member, bounds, authorities, actions };
|
|
133
144
|
}
|
|
134
145
|
function parseSiteAuthority(value) {
|
|
135
|
-
if (typeof value !== 'object' || value === null)
|
|
146
|
+
if (typeof value !== 'object' || value === null)
|
|
147
|
+
return null;
|
|
136
148
|
const held = value;
|
|
137
|
-
if (held.kind !== 'room')
|
|
138
|
-
|
|
139
|
-
if (typeof held.
|
|
140
|
-
|
|
149
|
+
if (held.kind !== 'room')
|
|
150
|
+
return null;
|
|
151
|
+
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
|
|
152
|
+
return null;
|
|
153
|
+
if (typeof held.room_handle !== 'string' || held.room_handle.length === 0)
|
|
154
|
+
return null;
|
|
155
|
+
if (typeof held.model_root !== 'string')
|
|
156
|
+
return null;
|
|
141
157
|
const at = readPosition(held);
|
|
142
|
-
if (at === null)
|
|
158
|
+
if (at === null)
|
|
159
|
+
return null;
|
|
143
160
|
return {
|
|
144
161
|
roomRef: held.room_ref,
|
|
145
162
|
roomHandle: held.room_handle,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...at
|
|
163
|
+
schema: held.model_root,
|
|
164
|
+
...at,
|
|
149
165
|
};
|
|
150
166
|
}
|
|
151
167
|
export function parseSiteDiscovery(body) {
|
|
152
|
-
if (typeof body !== 'object' || body === null)
|
|
168
|
+
if (typeof body !== 'object' || body === null)
|
|
169
|
+
return null;
|
|
153
170
|
const held = body;
|
|
154
171
|
const bounds = parseBounds(held.bounds);
|
|
155
|
-
if (bounds === null)
|
|
156
|
-
|
|
157
|
-
if (!Array.isArray(held.
|
|
158
|
-
|
|
159
|
-
for (const entry of held.slots){
|
|
160
|
-
const slot = parseSiteSlot(entry);
|
|
161
|
-
if (slot === null) return null;
|
|
162
|
-
slots.push(slot);
|
|
163
|
-
}
|
|
172
|
+
if (bounds === null)
|
|
173
|
+
return null;
|
|
174
|
+
if (!Array.isArray(held.authorities))
|
|
175
|
+
return null;
|
|
164
176
|
const authorities = [];
|
|
165
|
-
for (const entry of held.authorities){
|
|
177
|
+
for (const entry of held.authorities) {
|
|
166
178
|
const authority = parseSiteAuthority(entry);
|
|
167
|
-
if (authority === null)
|
|
179
|
+
if (authority === null)
|
|
180
|
+
return null;
|
|
168
181
|
authorities.push(authority);
|
|
169
182
|
}
|
|
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}`;
|
|
183
|
+
return { bounds, authorities };
|
|
179
184
|
}
|
|
180
185
|
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
|
-
});
|
|
186
|
+
return document.authorities.map((authority) => ({
|
|
187
|
+
locator: authority.roomRef,
|
|
188
|
+
authority: authority.roomRef,
|
|
189
|
+
handle: authority.roomHandle,
|
|
190
|
+
schema: authority.schema,
|
|
191
|
+
houseModel: null,
|
|
192
|
+
schemas: [authority.schema],
|
|
193
|
+
position: authority.position,
|
|
194
|
+
logEpoch: authority.logEpoch,
|
|
195
|
+
}));
|
|
204
196
|
}
|
|
205
|
-
|
|
206
|
-
return authority.
|
|
197
|
+
function schemasOf(authority) {
|
|
198
|
+
return authority.houseModel === null
|
|
199
|
+
? [authority.schema]
|
|
200
|
+
: [authority.schema, authority.houseModel.root];
|
|
207
201
|
}
|
|
208
202
|
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
|
-
}));
|
|
203
|
+
return document.authorities.map((authority) => ({
|
|
204
|
+
locator: authority.roomRef,
|
|
205
|
+
authority: authority.roomRef,
|
|
206
|
+
handle: authority.roomHandle,
|
|
207
|
+
schema: authority.schema,
|
|
208
|
+
houseModel: authority.houseModel,
|
|
209
|
+
schemas: schemasOf(authority),
|
|
210
|
+
position: authority.position,
|
|
211
|
+
logEpoch: authority.logEpoch,
|
|
212
|
+
}));
|
|
224
213
|
}
|
|
225
214
|
export function providerLimits(bounds) {
|
|
226
215
|
return [
|
|
227
|
-
{
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
{
|
|
236
|
-
|
|
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
|
-
}
|
|
216
|
+
{ name: 'document-size', value: bounds.max_authored_file_bytes },
|
|
217
|
+
{ name: 'change-batch-operations', value: bounds.max_batch_operations },
|
|
218
|
+
{ name: 'change-documents', value: bounds.max_batch_documents },
|
|
219
|
+
{ name: 'path-length', value: bounds.max_path_length },
|
|
220
|
+
{ name: 'path-depth', value: bounds.max_path_depth },
|
|
221
|
+
...(bounds.max_move_documents === undefined
|
|
222
|
+
? []
|
|
223
|
+
: [{ name: 'move-documents', value: bounds.max_move_documents }]),
|
|
224
|
+
{ name: 'write-rate' },
|
|
225
|
+
{ name: 'storage-limit' },
|
|
249
226
|
];
|
|
250
227
|
}
|
|
251
228
|
export function declaredRetention(bounds) {
|
|
252
229
|
return {
|
|
253
|
-
history: {
|
|
254
|
-
kind: 'no-declared-time-bound'
|
|
255
|
-
},
|
|
230
|
+
history: { kind: 'no-declared-time-bound' },
|
|
256
231
|
outcome: bounds.operation_retention_seconds,
|
|
257
|
-
refreshHorizon: bounds.change_retention_seconds
|
|
232
|
+
refreshHorizon: bounds.change_retention_seconds,
|
|
258
233
|
};
|
|
259
234
|
}
|
|
260
|
-
export function capabilities() {
|
|
235
|
+
export function capabilities(actions, rooms) {
|
|
236
|
+
const house = rooms.find((room) => room.houseModel !== null);
|
|
261
237
|
return [
|
|
262
|
-
{
|
|
263
|
-
name: ROOM_VERSION_NOTIFICATIONS
|
|
264
|
-
},
|
|
265
238
|
{
|
|
266
239
|
name: PROVIDER_ACTIONS,
|
|
267
|
-
actions: declaredActions(),
|
|
268
|
-
|
|
240
|
+
actions: declaredActions(actions),
|
|
241
|
+
...(house === undefined
|
|
242
|
+
? {}
|
|
243
|
+
: { conversationAgents: houseConversationAgents(house.authority) }),
|
|
269
244
|
},
|
|
270
|
-
{
|
|
271
|
-
name: MOVE_REFERENCE_REWRITES
|
|
272
|
-
}
|
|
273
245
|
];
|
|
274
246
|
}
|
|
275
247
|
export function siteCapabilities() {
|
|
276
248
|
return [
|
|
277
249
|
{
|
|
278
|
-
name:
|
|
279
|
-
|
|
250
|
+
name: PROVIDER_ACTIONS,
|
|
251
|
+
actions: [{ name: SITE_SUBMIT, inputShape: {}, resultKind: 'house' }],
|
|
252
|
+
},
|
|
280
253
|
];
|
|
281
254
|
}
|
|
282
|
-
export function
|
|
283
|
-
|
|
284
|
-
roots: [
|
|
285
|
-
...PROVIDER_SELECTION_ROOTS
|
|
286
|
-
],
|
|
287
|
-
attachedModel
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
export function discoveredRoom(authority, attachedModel, typedSelection) {
|
|
255
|
+
export function discoveredRoom(authority) {
|
|
256
|
+
const locator = authority.roomRef;
|
|
291
257
|
return {
|
|
292
258
|
name: authority.name,
|
|
293
|
-
locator
|
|
294
|
-
|
|
259
|
+
locator,
|
|
260
|
+
handle: authority.roomHandle,
|
|
295
261
|
roomVersion: roomVersion(authority),
|
|
296
262
|
operations: {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
],
|
|
300
|
-
sync: [
|
|
301
|
-
...authority.operations.sync
|
|
302
|
-
],
|
|
303
|
-
write: [
|
|
304
|
-
...authority.operations.write
|
|
305
|
-
],
|
|
306
|
-
delete: [
|
|
307
|
-
...authority.operations.delete
|
|
308
|
-
]
|
|
263
|
+
write: [...authority.operations.write],
|
|
264
|
+
delete: [...authority.operations.delete],
|
|
309
265
|
},
|
|
310
266
|
replica: {
|
|
311
|
-
selection:
|
|
312
|
-
admission: authority.managedReplication
|
|
267
|
+
selection: locator,
|
|
268
|
+
admission: authority.managedReplication,
|
|
269
|
+
offline: authority.read === 'online' ? 'locked' : 'open',
|
|
313
270
|
},
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
typedSelection
|
|
317
|
-
|
|
318
|
-
providerOwnedPaths: [
|
|
319
|
-
...authority.protectedPaths
|
|
320
|
-
]
|
|
271
|
+
...(authority.houseModel === null
|
|
272
|
+
? {}
|
|
273
|
+
: { typedSelection: { roots: [...authority.houseModel.paths] } }),
|
|
274
|
+
providerOwnedPaths: [...authority.protectedPaths, ...schemasOf(authority)],
|
|
321
275
|
};
|
|
322
276
|
}
|
|
323
277
|
export function mapDiscovery(document, rooms, declared) {
|
|
324
278
|
return {
|
|
325
279
|
kind: 'discovery',
|
|
326
|
-
supportedVersions: [
|
|
327
|
-
ROOM_CONTRACT_VERSION
|
|
328
|
-
],
|
|
329
|
-
mdModel: {
|
|
330
|
-
identity: MD_MODEL_IDENTITY,
|
|
331
|
-
version: document.mdModelVersion
|
|
332
|
-
},
|
|
333
280
|
rooms,
|
|
334
281
|
capabilities: declared,
|
|
335
282
|
providerLimits: providerLimits(document.bounds),
|
|
336
|
-
retention: declaredRetention(document.bounds)
|
|
283
|
+
retention: declaredRetention(document.bounds),
|
|
337
284
|
};
|
|
338
285
|
}
|
|
339
|
-
|
|
340
|
-
//# sourceMappingURL=discovery.js.map
|
package/dist/gather.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function gatheredEach<A, R>(send: (asks: readonly A[], answer: (ask: number, result: R) => void) => Promise<void>): (ask: A) => Promise<R>;
|
|
2
|
+
export declare function gathered<A, R>(send: (asks: readonly A[]) => Promise<readonly R[]>): (ask: A) => Promise<R>;
|
|
3
|
+
export declare function selections<T>(items: readonly T[], limit: number): readonly (readonly T[])[];
|
|
4
|
+
//# sourceMappingURL=gather.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAC/B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,GACpF,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAwBxB;AAED,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,CAMxB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAO3F"}
|