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