@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/refusal.js
CHANGED
|
@@ -1,78 +1,56 @@
|
|
|
1
|
-
const RETRYABLE_CODES = new Set([
|
|
2
|
-
'auth_unavailable',
|
|
3
|
-
'replica_behind',
|
|
4
|
-
'read_replica_unavailable',
|
|
5
|
-
'read_replica_lagging',
|
|
6
|
-
'read_pool_acquisition_timed_out',
|
|
7
|
-
'sync_unavailable',
|
|
8
|
-
'sync_failed',
|
|
9
|
-
'rate_limited',
|
|
10
|
-
'operation_contended',
|
|
11
|
-
'service_mode_write_halted',
|
|
12
|
-
'transaction_budget_exceeded'
|
|
13
|
-
]);
|
|
14
1
|
export function doorRefusal(body) {
|
|
15
|
-
if (typeof body !== 'object' || body === null)
|
|
16
|
-
|
|
2
|
+
if (typeof body !== 'object' || body === null)
|
|
3
|
+
return null;
|
|
4
|
+
if (!('error' in body) || typeof body.error !== 'object' || body.error === null)
|
|
5
|
+
return null;
|
|
17
6
|
const error = body.error;
|
|
18
|
-
if (typeof error.code !== 'string')
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fields
|
|
23
|
-
};
|
|
7
|
+
if (typeof error.code !== 'string')
|
|
8
|
+
return null;
|
|
9
|
+
const { code, retryable, ...fields } = error;
|
|
10
|
+
return { code, fields, retryable: retryable === true };
|
|
24
11
|
}
|
|
25
12
|
export function scopedRefusal(locator, scope, refusal) {
|
|
26
|
-
return {
|
|
27
|
-
kind: 'scoped-refusal',
|
|
28
|
-
locator,
|
|
29
|
-
scope,
|
|
30
|
-
code: refusal.code,
|
|
31
|
-
fields: refusal.fields
|
|
32
|
-
};
|
|
13
|
+
return { kind: 'scoped-refusal', locator, scope, ...refusal };
|
|
33
14
|
}
|
|
34
|
-
|
|
35
|
-
if (status === 0)
|
|
36
|
-
kind: 'transport-uncertainty'
|
|
37
|
-
};
|
|
15
|
+
function doorFailure(status, body) {
|
|
16
|
+
if (status === 0)
|
|
17
|
+
return { kind: 'transport-uncertainty' };
|
|
38
18
|
const refusal = doorRefusal(body);
|
|
39
|
-
if (status === 401)
|
|
40
|
-
kind: 'revoked-authorization'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
19
|
+
if (status === 401)
|
|
20
|
+
return { kind: 'revoked-authorization' };
|
|
21
|
+
if (refusal?.retryable === true)
|
|
22
|
+
return { kind: 'transport-uncertainty' };
|
|
23
|
+
if (status === 404 || refusal?.code === 'room_not_found')
|
|
24
|
+
return { kind: 'room-not-readable' };
|
|
25
|
+
if (status < 400)
|
|
26
|
+
return null;
|
|
27
|
+
if (refusal === null)
|
|
28
|
+
return { kind: 'transport-uncertainty' };
|
|
29
|
+
return { kind: 'refused', scope: status === 403 ? 'operation' : 'undisclosed', refusal };
|
|
30
|
+
}
|
|
31
|
+
export function classifyDoor(status, body, locator) {
|
|
32
|
+
const failure = doorFailure(status, body);
|
|
33
|
+
if (failure === null)
|
|
34
|
+
return null;
|
|
35
|
+
if (failure.kind === 'room-not-readable')
|
|
36
|
+
return { kind: 'room-not-readable', locator };
|
|
37
|
+
if (failure.kind === 'refused')
|
|
38
|
+
return scopedRefusal(locator, failure.scope, failure.refusal);
|
|
39
|
+
return failure;
|
|
40
|
+
}
|
|
41
|
+
export function classifyRead(status, body, locator) {
|
|
42
|
+
if (doorRefusal(body)?.code === 'expired')
|
|
43
|
+
return { kind: 'beyond-horizon' };
|
|
44
|
+
return classifyDoor(status, body, locator);
|
|
63
45
|
}
|
|
64
|
-
export function discoveryFailure(
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
46
|
+
export function discoveryFailure(status, body) {
|
|
47
|
+
const failure = doorFailure(status, body);
|
|
48
|
+
if (failure === null)
|
|
49
|
+
return null;
|
|
50
|
+
if (failure.kind === 'revoked-authorization')
|
|
51
|
+
return failure;
|
|
52
|
+
if (failure.kind === 'refused') {
|
|
53
|
+
return { kind: 'contract-unavailable', ...failure.refusal };
|
|
72
54
|
}
|
|
73
|
-
return {
|
|
74
|
-
kind: 'transport-uncertainty'
|
|
75
|
-
};
|
|
55
|
+
return { kind: 'transport-uncertainty' };
|
|
76
56
|
}
|
|
77
|
-
|
|
78
|
-
//# sourceMappingURL=refusal.js.map
|
package/dist/site.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAOR,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAOR,MAAM,wBAAwB,CAAC;AAsBhC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAiCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CA8KxE"}
|
package/dist/site.js
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { actionOutcome } from './actions.js';
|
|
2
|
+
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
3
|
+
import { scopeModels, streamedModels, viewModels } from './model.js';
|
|
4
|
+
import { advancedScope, bootstrapOf, parseEnumeration, parseSiteBootstrap, refreshFrom, viewOf, } from './read.js';
|
|
5
|
+
import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
|
|
5
6
|
import { houseNotifications } from './stream.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function siteRoom(tracked, attachedModel) {
|
|
12
|
-
const read = selectionRoots(tracked);
|
|
7
|
+
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, SITE_FILE_RECORD, SITE_FILES, } from './transport.js';
|
|
8
|
+
import { houseReferrer } from './referrer.js';
|
|
9
|
+
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
10
|
+
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
11
|
+
function siteRoom(tracked) {
|
|
13
12
|
return {
|
|
14
|
-
name: tracked.
|
|
13
|
+
name: tracked.handle,
|
|
15
14
|
locator: tracked.locator,
|
|
16
|
-
|
|
15
|
+
handle: tracked.handle,
|
|
17
16
|
roomVersion: roomVersion(tracked),
|
|
18
|
-
operations: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
sync: [
|
|
23
|
-
...read
|
|
24
|
-
],
|
|
25
|
-
write: [],
|
|
26
|
-
delete: []
|
|
27
|
-
},
|
|
28
|
-
replica: {
|
|
29
|
-
selection: tracked.locator,
|
|
30
|
-
admission: 'admitted'
|
|
31
|
-
},
|
|
32
|
-
attachedModel,
|
|
33
|
-
providerOwnedPaths: []
|
|
17
|
+
operations: { read: [''], sync: [''], write: [], delete: [] },
|
|
18
|
+
replica: { selection: tracked.locator, admission: 'admitted' },
|
|
19
|
+
providerOwnedPaths: [],
|
|
34
20
|
};
|
|
35
21
|
}
|
|
36
22
|
function settled(refused) {
|
|
@@ -39,160 +25,165 @@ function settled(refused) {
|
|
|
39
25
|
export function createSiteAdapter(transport) {
|
|
40
26
|
const notifications = houseNotifications(transport, 'site');
|
|
41
27
|
const tracked = new Map();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
function published(referrer) {
|
|
29
|
+
const named = houseReferrer(referrer, tracked);
|
|
30
|
+
return named === null || !tracked.has(named.locator) ? null : named;
|
|
31
|
+
}
|
|
45
32
|
async function enumeration(entry, from) {
|
|
46
33
|
const answer = await transport.door(SITE_DOOR_ENUMERATE, {
|
|
47
|
-
positions: [
|
|
48
|
-
presented(entry.authority, from)
|
|
49
|
-
]
|
|
34
|
+
positions: [presented(entry.authority, from)],
|
|
50
35
|
});
|
|
51
|
-
const classified =
|
|
52
|
-
if (classified !== null)
|
|
36
|
+
const classified = classifyRead(answer.status, answer.body, entry.locator);
|
|
37
|
+
if (classified !== null)
|
|
38
|
+
return classified;
|
|
53
39
|
return parseEnumeration(answer.body, 'site') ?? UNCERTAIN;
|
|
54
40
|
}
|
|
55
41
|
async function caughtUp(entry) {
|
|
56
42
|
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}`);
|
|
57
43
|
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
58
|
-
if (classified !== null)
|
|
59
|
-
failure:
|
|
60
|
-
};
|
|
44
|
+
if (classified !== null)
|
|
45
|
+
return { failure: classified };
|
|
61
46
|
const scope = parseSiteBootstrap(answer.body);
|
|
62
|
-
if (scope === null)
|
|
63
|
-
failure: UNCERTAIN
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
scope
|
|
67
|
-
};
|
|
47
|
+
if (scope === null)
|
|
48
|
+
return { failure: UNCERTAIN };
|
|
49
|
+
if (roomVersion(scope) === roomVersion(entry))
|
|
50
|
+
return { scope };
|
|
68
51
|
const found = await enumeration(entry, scope);
|
|
69
|
-
if ('kind' in found)
|
|
70
|
-
failure: settled(found)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
kind: 'room-not-readable',
|
|
76
|
-
locator: entry.locator
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
scope: advancedScope(scope, view)
|
|
81
|
-
};
|
|
52
|
+
if ('kind' in found)
|
|
53
|
+
return { failure: settled(found) };
|
|
54
|
+
const view = viewOf(found, entry);
|
|
55
|
+
if (view === undefined)
|
|
56
|
+
return { failure: { kind: 'room-not-readable', locator: entry.locator } };
|
|
57
|
+
return { scope: advancedScope(scope, view) };
|
|
82
58
|
}
|
|
83
59
|
async function refreshed(entry, fromRoomVersion) {
|
|
84
60
|
const from = logPosition(fromRoomVersion);
|
|
85
|
-
if (from === null)
|
|
86
|
-
kind: 'beyond-horizon'
|
|
87
|
-
};
|
|
61
|
+
if (from === null)
|
|
62
|
+
return { kind: 'beyond-horizon' };
|
|
88
63
|
const streamed = notifications.advance(entry, from);
|
|
89
|
-
if (streamed !== null)
|
|
64
|
+
if (streamed !== null) {
|
|
65
|
+
const models = await streamedModels(streamed.schemas, entry, 'site');
|
|
66
|
+
return models === undefined ? streamed.page : { ...streamed.page, models };
|
|
67
|
+
}
|
|
90
68
|
const found = await enumeration(entry, from);
|
|
91
|
-
if ('kind' in found)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
model
|
|
103
|
-
});
|
|
104
|
-
return model;
|
|
69
|
+
if ('kind' in found)
|
|
70
|
+
return found;
|
|
71
|
+
const view = viewOf(found, entry);
|
|
72
|
+
if (view === undefined)
|
|
73
|
+
return { kind: 'room-not-readable', locator: entry.locator };
|
|
74
|
+
notifications.reach(entry.authority, view);
|
|
75
|
+
const answer = refreshFrom(view, fromRoomVersion);
|
|
76
|
+
if (answer.kind !== 'net-advancement')
|
|
77
|
+
return answer;
|
|
78
|
+
const models = await viewModels(view, entry);
|
|
79
|
+
return models === undefined ? answer : { ...answer, models };
|
|
105
80
|
}
|
|
106
81
|
return {
|
|
107
|
-
|
|
82
|
+
localSaves: true,
|
|
83
|
+
async authorize() {
|
|
108
84
|
return {};
|
|
109
85
|
},
|
|
110
|
-
async
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const classified = classifyDoor(answer.status, answer.body, PRIVATE_AUTHORITY);
|
|
116
|
-
if (classified !== null) return discoveryFailure(classified);
|
|
86
|
+
async discover() {
|
|
87
|
+
const answer = await transport.read(SITE_DOOR_DISCOVER);
|
|
88
|
+
const failed = discoveryFailure(answer.status, answer.body);
|
|
89
|
+
if (failed !== null)
|
|
90
|
+
return failed;
|
|
117
91
|
const document = parseSiteDiscovery(answer.body);
|
|
118
|
-
if (document === null)
|
|
92
|
+
if (document === null)
|
|
93
|
+
return UNCERTAIN;
|
|
119
94
|
const entries = siteTracked(document);
|
|
120
95
|
tracked.clear();
|
|
121
|
-
for (const entry of entries)
|
|
96
|
+
for (const entry of entries)
|
|
97
|
+
tracked.set(entry.locator, entry);
|
|
122
98
|
notifications.track(entries);
|
|
123
|
-
|
|
124
|
-
for (const authority of [
|
|
125
|
-
...acquired.keys()
|
|
126
|
-
]){
|
|
127
|
-
if (!published.has(authority)) acquired.delete(authority);
|
|
128
|
-
}
|
|
129
|
-
const fresh = new Map();
|
|
130
|
-
const current = new Map();
|
|
131
|
-
for (const entry of entries){
|
|
132
|
-
if (current.has(entry.authority)) continue;
|
|
133
|
-
const kept = acquired.get(entry.authority);
|
|
134
|
-
if (kept !== undefined && kept.roomVersion === roomVersion(entry)) {
|
|
135
|
-
current.set(entry.authority, kept.model);
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
const held = await caughtUp(entry);
|
|
139
|
-
fresh.set(entry.authority, held);
|
|
140
|
-
current.set(entry.authority, await acquire(entry, held));
|
|
141
|
-
}
|
|
142
|
-
caught = fresh;
|
|
143
|
-
const rooms = entries.map((entry)=>{
|
|
144
|
-
const shelved = models.retain(modelKey(entry.locator, 'collection'), current.get(entry.authority));
|
|
145
|
-
return siteRoom(entry, shelved?.identity ?? null);
|
|
146
|
-
});
|
|
147
|
-
models.keep(entries.map((entry)=>entry.locator));
|
|
148
|
-
return mapDiscovery(document, rooms, siteCapabilities());
|
|
99
|
+
return mapDiscovery(document, entries.map(siteRoom), siteCapabilities());
|
|
149
100
|
},
|
|
150
|
-
async bootstrap
|
|
101
|
+
async bootstrap(_authorization, request) {
|
|
151
102
|
const entry = tracked.get(request.locator);
|
|
152
|
-
if (entry === undefined)
|
|
153
|
-
kind: 'room-not-readable',
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
103
|
+
if (entry === undefined)
|
|
104
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
105
|
+
if (request.pageToken !== undefined)
|
|
106
|
+
return UNCERTAIN;
|
|
107
|
+
const held = await caughtUp(entry);
|
|
108
|
+
if ('failure' in held)
|
|
109
|
+
return held.failure;
|
|
110
|
+
notifications.reach(entry.authority, held.scope);
|
|
111
|
+
const models = await scopeModels(held.scope, entry);
|
|
112
|
+
return { ...bootstrapOf(held.scope), ...(models === undefined ? {} : { models }) };
|
|
160
113
|
},
|
|
161
|
-
async refresh
|
|
114
|
+
async refresh(_authorization, request) {
|
|
162
115
|
const entry = tracked.get(request.locator);
|
|
163
|
-
if (entry === undefined)
|
|
164
|
-
kind: 'room-not-readable',
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const result = await refreshed(entry, request.fromRoomVersion);
|
|
169
|
-
if (result.kind === 'beyond-horizon') caught.delete(entry.authority);
|
|
170
|
-
return result;
|
|
116
|
+
if (entry === undefined)
|
|
117
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
118
|
+
if (request.pageToken !== undefined)
|
|
119
|
+
return UNCERTAIN;
|
|
120
|
+
return refreshed(entry, request.fromRoomVersion);
|
|
171
121
|
},
|
|
172
|
-
async mutate
|
|
173
|
-
return {
|
|
174
|
-
kind: 'rejected',
|
|
175
|
-
affected: {},
|
|
176
|
-
code: 'write-grant',
|
|
177
|
-
fields: {}
|
|
178
|
-
};
|
|
122
|
+
async mutate() {
|
|
123
|
+
return { kind: 'rejected', affected: {}, code: 'write-grant', fields: {}, retryable: false };
|
|
179
124
|
},
|
|
180
|
-
async history
|
|
181
|
-
return {
|
|
182
|
-
|
|
183
|
-
|
|
125
|
+
async history() {
|
|
126
|
+
return { kind: 'no-history' };
|
|
127
|
+
},
|
|
128
|
+
async binary(_authorization, request) {
|
|
129
|
+
const named = published(request.kind === 'path' ? { room: request.locator, path: request.path } : request.referrer);
|
|
130
|
+
if (named === null) {
|
|
131
|
+
return { kind: 'rejected', code: 'referrer_unknown', fields: {}, retryable: false };
|
|
132
|
+
}
|
|
133
|
+
if (request.fileRef === undefined) {
|
|
134
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
135
|
+
}
|
|
136
|
+
const { room_ref, path, record } = named.referrer;
|
|
137
|
+
const read = await transport.download(`${SITE_FILES}${room_ref}/${encodeURIComponent(request.fileRef)}/${path === undefined
|
|
138
|
+
? `${SITE_FILE_RECORD}/${encodeURIComponent(record)}`
|
|
139
|
+
: encodeURIComponent(path)}`);
|
|
140
|
+
if (read.status === 404) {
|
|
141
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
142
|
+
}
|
|
143
|
+
return read.status === 200 && read.blob !== null
|
|
144
|
+
? { kind: 'binary', blob: read.blob }
|
|
145
|
+
: UNCERTAIN;
|
|
146
|
+
},
|
|
147
|
+
referrerScope(referrer) {
|
|
148
|
+
const named = published(referrer);
|
|
149
|
+
if (named === null)
|
|
150
|
+
return null;
|
|
151
|
+
const { path } = named.referrer;
|
|
152
|
+
return { kind: 'room', locator: named.locator, ...(path === undefined ? {} : { path }) };
|
|
153
|
+
},
|
|
154
|
+
reached(locator, version, target) {
|
|
155
|
+
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
|
156
|
+
},
|
|
157
|
+
follows(_locator, version, next) {
|
|
158
|
+
return followsVersion(version, next);
|
|
159
|
+
},
|
|
160
|
+
async action(_authorization, request) {
|
|
161
|
+
if (request.name !== 'submit') {
|
|
162
|
+
return {
|
|
163
|
+
kind: 'rejected',
|
|
164
|
+
code: 'action-unimplemented',
|
|
165
|
+
fields: { name: request.name },
|
|
166
|
+
retryable: false,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (!transport.online())
|
|
170
|
+
return UNCERTAIN;
|
|
171
|
+
return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), 'submit');
|
|
184
172
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
173
|
+
roomStream: {
|
|
174
|
+
hold(rooms) {
|
|
175
|
+
notifications.send(rooms.flatMap((room) => {
|
|
176
|
+
const entry = tracked.get(room.locator);
|
|
177
|
+
const at = logPosition(room.roomVersion);
|
|
178
|
+
if (entry === undefined || at === null)
|
|
179
|
+
return [];
|
|
180
|
+
notifications.reach(entry.authority, at);
|
|
181
|
+
return [presented(entry.authority, at)];
|
|
182
|
+
}));
|
|
183
|
+
},
|
|
184
|
+
reopen: notifications.reopen,
|
|
185
|
+
observe: notifications.observe,
|
|
193
186
|
},
|
|
194
|
-
|
|
187
|
+
serviceMode: notifications.serviceMode,
|
|
195
188
|
};
|
|
196
189
|
}
|
|
197
|
-
|
|
198
|
-
//# sourceMappingURL=site.js.map
|
package/dist/stream.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import type { RefreshPage,
|
|
1
|
+
import type { ConversationStream, RefreshPage, RoomStreamEvent, ServiceModeSignal } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
import {
|
|
4
|
-
import type { HouseMode } from './transport.js';
|
|
3
|
+
import type { HouseDoor, HouseHeldRoom, HouseMode, HouseStreamEntry } from './transport.js';
|
|
5
4
|
import { type LogPosition } from './version.js';
|
|
6
|
-
export type
|
|
5
|
+
export type HeldRevision = (path: string, revision: string) => boolean;
|
|
6
|
+
export type StreamedAdvancement = {
|
|
7
|
+
page: RefreshPage;
|
|
8
|
+
entries: readonly HouseStreamEntry[];
|
|
9
|
+
schemas: ReadonlyMap<string, HouseStreamEntry>;
|
|
10
|
+
};
|
|
11
|
+
export type HouseNotifications = {
|
|
12
|
+
runtime: string;
|
|
13
|
+
observe(notify: (event: RoomStreamEvent) => void): () => void;
|
|
14
|
+
send(rooms: readonly HouseHeldRoom[]): void;
|
|
15
|
+
reopen(): void;
|
|
7
16
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
8
|
-
|
|
9
|
-
|
|
17
|
+
reach(authority: string, at: LogPosition): void;
|
|
18
|
+
advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): StreamedAdvancement | null;
|
|
19
|
+
conversations: ConversationStream;
|
|
20
|
+
serviceMode: ServiceModeSignal;
|
|
10
21
|
};
|
|
11
22
|
export declare function houseNotifications(transport: HouseDoor, mode: HouseMode): HouseNotifications;
|
|
12
23
|
//# sourceMappingURL=stream.d.ts.map
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,kBAAkB,EAElB,WAAW,EACX,eAAe,EAEf,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,SAAS,EAET,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAgB7D,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAEvE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACrC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC9D,IAAI,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;IAC5C,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,OAAO,CACL,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,EACjB,KAAK,CAAC,EAAE,YAAY,GACnB,mBAAmB,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAuBF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CA8S5F"}
|