@agentshouse/mdruntime-adapter 0.1.0-c29c7d612b2d0 → 0.1.0-c2aee37343279
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 +289 -276
- package/dist/actions.d.ts +15 -21
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +87 -144
- package/dist/adapter.d.ts +1 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +311 -140
- package/dist/app-reference.d.ts +2 -0
- package/dist/app-reference.d.ts.map +1 -0
- package/dist/app-reference.js +2 -0
- package/dist/crockford.d.ts +4 -0
- package/dist/crockford.d.ts.map +1 -0
- package/dist/crockford.js +3 -0
- package/dist/discovery.d.ts +7 -10
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +38 -32
- package/dist/gather.d.ts +1 -1
- package/dist/gather.d.ts.map +1 -1
- package/dist/gather.js +4 -14
- package/dist/house-model.d.ts +2 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +414 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/model.d.ts +5 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +11 -13
- package/dist/part.d.ts +15 -0
- package/dist/part.d.ts.map +1 -0
- package/dist/part.js +82 -0
- package/dist/read.d.ts +71 -20
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +319 -129
- package/dist/room-types.d.ts +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +124 -0
- package/dist/site.d.ts +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +144 -132
- package/dist/stream.d.ts +5 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +276 -78
- package/dist/transport.d.ts +48 -11
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +1 -1
- package/dist/upload.d.ts +12 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +63 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/write.d.ts +12 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +98 -57
- package/package.json +8 -3
- package/dist/handed.d.ts +0 -15
- package/dist/handed.d.ts.map +0 -1
- package/dist/handed.js +0 -38
- package/dist/referrer.d.ts +0 -7
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -35
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { APP_REFERENCE_PATTERN } from './app-reference.js';
|
|
2
|
+
import { HOUSE_MODEL_TYPES } from './house-model.js';
|
|
3
|
+
export const INBOX_CHANNEL_KINDS = [
|
|
4
|
+
'telegram-bot',
|
|
5
|
+
'whatsapp',
|
|
6
|
+
'messenger',
|
|
7
|
+
'instagram',
|
|
8
|
+
'viber',
|
|
9
|
+
'tiktok',
|
|
10
|
+
];
|
|
11
|
+
export const INBOX_CHAT_TYPE = 'inbox-chat';
|
|
12
|
+
export const INBOX_MESSAGE_TYPE = 'inbox-message';
|
|
13
|
+
export const HOUSE_NAMEABLE_ROOM_TYPES = [INBOX_CHAT_TYPE, INBOX_MESSAGE_TYPE];
|
|
14
|
+
const WAYFINDING_MAP_TYPE = 'wayfinding-map';
|
|
15
|
+
const WAYFINDING_TICKET_TYPE = 'wayfinding-ticket';
|
|
16
|
+
const WAYFINDING_MAP_SECTIONS = [
|
|
17
|
+
'Destination',
|
|
18
|
+
'Notes',
|
|
19
|
+
'Decisions so far',
|
|
20
|
+
'Not yet specified',
|
|
21
|
+
'Out of scope',
|
|
22
|
+
];
|
|
23
|
+
const IDENTITY = "{ type: string, pattern: '^\\S+$' }";
|
|
24
|
+
const AGENT = [' agent: { type: string, format: uuid }', ' name: { type: string }'];
|
|
25
|
+
const ASSIGNEE = [
|
|
26
|
+
' type: object',
|
|
27
|
+
' properties:',
|
|
28
|
+
' user: { type: string, format: uuid }',
|
|
29
|
+
...AGENT,
|
|
30
|
+
];
|
|
31
|
+
export const HOUSE_ROOM_TYPES = [
|
|
32
|
+
`${INBOX_CHAT_TYPE}:`,
|
|
33
|
+
' properties:',
|
|
34
|
+
' inbox: { type: string, format: uuid }',
|
|
35
|
+
` channel: { enum: [${INBOX_CHANNEL_KINDS.join(', ')}] }`,
|
|
36
|
+
` chat: ${IDENTITY}`,
|
|
37
|
+
' customer:',
|
|
38
|
+
' type: object',
|
|
39
|
+
' properties:',
|
|
40
|
+
' name: { type: string }',
|
|
41
|
+
` username: ${IDENTITY}`,
|
|
42
|
+
` phone: ${IDENTITY}`,
|
|
43
|
+
' assignee:',
|
|
44
|
+
...ASSIGNEE,
|
|
45
|
+
' return_to:',
|
|
46
|
+
' type: object',
|
|
47
|
+
' properties:',
|
|
48
|
+
...AGENT,
|
|
49
|
+
' conversation: { type: string, format: uuid }',
|
|
50
|
+
' required: [inbox, channel, chat, customer]',
|
|
51
|
+
`${INBOX_MESSAGE_TYPE}:`,
|
|
52
|
+
' properties:',
|
|
53
|
+
' direction: { enum: [in, out] }',
|
|
54
|
+
' sender:',
|
|
55
|
+
' type: object',
|
|
56
|
+
' properties:',
|
|
57
|
+
' name: { type: string }',
|
|
58
|
+
` username: ${IDENTITY}`,
|
|
59
|
+
' sent_at: { type: string, format: date-time }',
|
|
60
|
+
` channel_message: ${IDENTITY}`,
|
|
61
|
+
' state: { enum: [sending, sent, failed] }',
|
|
62
|
+
' reason: { type: string }',
|
|
63
|
+
' reactions:',
|
|
64
|
+
' type: array',
|
|
65
|
+
' items:',
|
|
66
|
+
' type: object',
|
|
67
|
+
' properties:',
|
|
68
|
+
' reaction: { type: string, minLength: 1 }',
|
|
69
|
+
' sender:',
|
|
70
|
+
' type: object',
|
|
71
|
+
' properties:',
|
|
72
|
+
` id: ${IDENTITY}`,
|
|
73
|
+
' name: { type: string }',
|
|
74
|
+
` username: ${IDENTITY}`,
|
|
75
|
+
' count: { type: integer, minimum: 1 }',
|
|
76
|
+
' required: [reaction]',
|
|
77
|
+
` post: ${IDENTITY}`,
|
|
78
|
+
' assignee:',
|
|
79
|
+
...ASSIGNEE,
|
|
80
|
+
' sent_outside: { const: true }',
|
|
81
|
+
' template:',
|
|
82
|
+
' type: object',
|
|
83
|
+
' properties:',
|
|
84
|
+
' name: { type: string, minLength: 1 }',
|
|
85
|
+
' language: { type: string, minLength: 1 }',
|
|
86
|
+
' required: [name, language]',
|
|
87
|
+
' values:',
|
|
88
|
+
' type: object',
|
|
89
|
+
' additionalProperties: { type: string }',
|
|
90
|
+
' withheld: { const: true }',
|
|
91
|
+
' required: [direction]',
|
|
92
|
+
' if: { properties: { direction: { const: in } } }',
|
|
93
|
+
' then: { required: [sent_at] }',
|
|
94
|
+
`${WAYFINDING_MAP_TYPE}:`,
|
|
95
|
+
' properties:',
|
|
96
|
+
' title: { type: string }',
|
|
97
|
+
' required: [title]',
|
|
98
|
+
' sections:',
|
|
99
|
+
...WAYFINDING_MAP_SECTIONS.map((name) => ` ${name}: { kind: text, required: true }`),
|
|
100
|
+
`${WAYFINDING_TICKET_TYPE}:`,
|
|
101
|
+
' properties:',
|
|
102
|
+
' title: { type: string }',
|
|
103
|
+
' kind: { enum: [research, prototype, grilling, task] }',
|
|
104
|
+
' status: { enum: [open, in-progress, done, out-of-scope] }',
|
|
105
|
+
` map: { type: string, reference: ${WAYFINDING_MAP_TYPE} }`,
|
|
106
|
+
` blocked_by: { type: array, items: { type: string, reference: ${WAYFINDING_TICKET_TYPE} } }`,
|
|
107
|
+
' assignee:',
|
|
108
|
+
...ASSIGNEE,
|
|
109
|
+
' conversation: { type: string, format: uuid }',
|
|
110
|
+
` app: { type: string, pattern: '${APP_REFERENCE_PATTERN.source}' }`,
|
|
111
|
+
' required: [title, kind, status, map, blocked_by]',
|
|
112
|
+
' sections:',
|
|
113
|
+
' Question: { kind: text }',
|
|
114
|
+
' Answer: { kind: text }',
|
|
115
|
+
' allOf:',
|
|
116
|
+
' - if: { properties: { status: { enum: [in-progress, done, out-of-scope] } }, required: [status] }',
|
|
117
|
+
' then: { required: [assignee] }',
|
|
118
|
+
' else: { properties: { assignee: false } }',
|
|
119
|
+
' - if: { properties: { assignee: { required: [agent] } }, required: [assignee] }',
|
|
120
|
+
' else: { properties: { conversation: false } }',
|
|
121
|
+
' - if: { properties: { status: { enum: [done, out-of-scope] } }, required: [status] }',
|
|
122
|
+
' then: { sections: { Answer: { kind: text, required: true } } }',
|
|
123
|
+
HOUSE_MODEL_TYPES,
|
|
124
|
+
].join('\n');
|
package/dist/site.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Adapter } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type HouseSiteTransport } from './transport.js';
|
|
3
|
-
export declare function createSiteAdapter(transport: HouseSiteTransport): Adapter;
|
|
3
|
+
export declare function createSiteAdapter(transport: HouseSiteTransport, snapshot?: boolean): Adapter;
|
|
4
4
|
//# sourceMappingURL=site.d.ts.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,
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAWR,MAAM,wBAAwB,CAAC;AA+BhC,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAoCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAwP1F"}
|
package/dist/site.js
CHANGED
|
@@ -1,126 +1,108 @@
|
|
|
1
|
+
import { stepped } from '@agentshouse/mdruntime';
|
|
1
2
|
import { actionOutcome, SITE_SUBMIT } from './actions.js';
|
|
2
3
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
3
|
-
import { partModels, streamedModels, viewModels } from './model.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { manifestedModels, partModels, streamedModels, viewModels } from './model.js';
|
|
5
|
+
import { bootstrapping, emptyScope, housePart, manifested, parseEnumeration, parseSiteParted, partInventory, refreshFrom, viewOf, wholeView, } from './read.js';
|
|
6
|
+
import { PART_ATTEMPTS, partArrival, partFrame, unverifiedPart } from './part.js';
|
|
6
7
|
import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
|
|
8
|
+
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
7
9
|
import { houseNotifications } from './stream.js';
|
|
8
|
-
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT,
|
|
9
|
-
import { houseReferrer } from './referrer.js';
|
|
10
|
+
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, SITE_FILES, } from './transport.js';
|
|
10
11
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
11
12
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
13
|
+
function unfound() {
|
|
14
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
15
|
+
}
|
|
12
16
|
function siteRoom(tracked) {
|
|
13
17
|
return {
|
|
14
18
|
name: tracked.handle,
|
|
15
19
|
locator: tracked.locator,
|
|
16
20
|
handle: tracked.handle,
|
|
17
21
|
roomVersion: roomVersion(tracked),
|
|
18
|
-
operations: {
|
|
19
|
-
replica: { selection: tracked.locator, admission: 'admitted' },
|
|
22
|
+
operations: { write: [], delete: [] },
|
|
23
|
+
replica: { selection: tracked.locator, admission: 'admitted', offline: 'open' },
|
|
20
24
|
providerOwnedPaths: [],
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
|
-
function
|
|
24
|
-
return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;
|
|
25
|
-
}
|
|
26
|
-
export function createSiteAdapter(transport) {
|
|
27
|
+
export function createSiteAdapter(transport, snapshot = false) {
|
|
27
28
|
const notifications = houseNotifications(transport, 'site');
|
|
28
29
|
const tracked = new Map();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const expired = new Map();
|
|
31
|
+
function fileRoute(request) {
|
|
32
|
+
const entry = tracked.get(request.locator);
|
|
33
|
+
if (entry === undefined)
|
|
34
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
35
|
+
return `${SITE_FILES}${entry.authority}/${encodeURIComponent(request.revision)}/${encodeURIComponent(request.path)}`;
|
|
32
36
|
}
|
|
33
|
-
async function
|
|
37
|
+
async function enumerated(entry, from, page) {
|
|
34
38
|
const answer = await transport.door(SITE_DOOR_ENUMERATE, {
|
|
35
|
-
positions: [
|
|
39
|
+
positions: [
|
|
40
|
+
page === undefined
|
|
41
|
+
? presented(entry.authority, from)
|
|
42
|
+
: {
|
|
43
|
+
...presented(entry.authority, { position: page.after, logEpoch: from.logEpoch }),
|
|
44
|
+
page: { through: page.through, read: page.read },
|
|
45
|
+
},
|
|
46
|
+
],
|
|
36
47
|
});
|
|
37
48
|
const classified = classifyRead(answer.status, answer.body, entry.locator);
|
|
38
49
|
if (classified !== null)
|
|
39
50
|
return classified;
|
|
40
|
-
|
|
51
|
+
const found = parseEnumeration(answer.body, 'site');
|
|
52
|
+
if (found === null)
|
|
53
|
+
return UNCERTAIN;
|
|
54
|
+
return viewOf(found, entry) ?? { kind: 'room-not-readable', locator: entry.locator };
|
|
55
|
+
}
|
|
56
|
+
async function enumeration(entry, from) {
|
|
57
|
+
const first = await enumerated(entry, from);
|
|
58
|
+
return 'kind' in first ? first : wholeView(first, (page) => enumerated(entry, from, page));
|
|
41
59
|
}
|
|
42
|
-
async function
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
...(offset === null ? [] : [`offset=${offset}`]),
|
|
46
|
-
];
|
|
47
|
-
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${query.length === 0 ? '' : `?${query.join('&')}`}`);
|
|
60
|
+
async function partedRoom(entry) {
|
|
61
|
+
const cut = expired.get(entry.locator);
|
|
62
|
+
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${cut === undefined ? '' : `?expired=${cut}`}`);
|
|
48
63
|
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
49
64
|
if (classified !== null)
|
|
50
|
-
return
|
|
51
|
-
const
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
async function assembled(entry, scope, path, offset) {
|
|
55
|
-
const opened = scope.contents.at(-1);
|
|
56
|
-
if (opened === undefined || opened.path !== path || opened.content.length !== offset) {
|
|
57
|
-
return UNCERTAIN;
|
|
58
|
-
}
|
|
59
|
-
let text = opened.content;
|
|
60
|
-
for (;;) {
|
|
61
|
-
const part = await bootstrapPart(entry, path, text.length);
|
|
62
|
-
if ('failure' in part)
|
|
63
|
-
return part.failure;
|
|
64
|
-
const [piece] = part.scope.contents;
|
|
65
|
-
if (piece === undefined ||
|
|
66
|
-
part.scope.contents.length !== 1 ||
|
|
67
|
-
piece.path !== path ||
|
|
68
|
-
piece.content.length === 0) {
|
|
69
|
-
return UNCERTAIN;
|
|
70
|
-
}
|
|
71
|
-
text += piece.content;
|
|
72
|
-
const more = siteBootstrapOffset(part.body);
|
|
73
|
-
if (more === null)
|
|
74
|
-
break;
|
|
75
|
-
if (more !== text.length)
|
|
76
|
-
return UNCERTAIN;
|
|
77
|
-
}
|
|
78
|
-
const file = scope.files.find((held) => held.path === path);
|
|
79
|
-
if (file === undefined || (await sha256Hex(text)) !== file.version)
|
|
80
|
-
return UNCERTAIN;
|
|
81
|
-
return { ...scope, contents: [...scope.contents.slice(0, -1), { path, content: text }] };
|
|
65
|
+
return classified;
|
|
66
|
+
const room = parseSiteParted(answer.body);
|
|
67
|
+
return room === null || room.anchor !== entry.authority ? UNCERTAIN : room;
|
|
82
68
|
}
|
|
83
|
-
async function
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (offset !== null) {
|
|
90
|
-
if (next === null)
|
|
91
|
-
return { failure: UNCERTAIN };
|
|
92
|
-
const scope = await assembled(entry, part.scope, next, offset);
|
|
93
|
-
return 'kind' in scope ? { failure: scope } : { scope, next };
|
|
69
|
+
async function fetchedPart(entry, room, listed, received, arriving) {
|
|
70
|
+
if (received !== undefined) {
|
|
71
|
+
const kept = new Uint8Array(received);
|
|
72
|
+
const held = await housePart(room, kept, listed, 'site');
|
|
73
|
+
if (held !== null)
|
|
74
|
+
return 'kind' in held ? held : { scope: held, frame: kept };
|
|
94
75
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
76
|
+
for (let attempt = 0; attempt < PART_ATTEMPTS; attempt += 1) {
|
|
77
|
+
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}?part=${encodeURIComponent(listed.part)}`, partArrival(listed, arriving));
|
|
78
|
+
const failure = classifyRead(answer.status, answer.body, entry.locator);
|
|
79
|
+
if (failure?.kind === 'beyond-horizon')
|
|
80
|
+
expired.set(entry.locator, room.position);
|
|
81
|
+
if (failure !== null)
|
|
82
|
+
return failure;
|
|
83
|
+
const frame = partFrame(answer.body);
|
|
84
|
+
if (frame === null)
|
|
85
|
+
continue;
|
|
86
|
+
const scope = await housePart(room, frame, listed, 'site');
|
|
87
|
+
if (scope !== null)
|
|
88
|
+
return 'kind' in scope ? scope : { scope, frame };
|
|
98
89
|
}
|
|
99
|
-
|
|
100
|
-
if ('kind' in found)
|
|
101
|
-
return { failure: settled(found) };
|
|
102
|
-
const view = viewOf(found, entry);
|
|
103
|
-
if (view === undefined)
|
|
104
|
-
return { failure: { kind: 'room-not-readable', locator: entry.locator } };
|
|
105
|
-
return { scope: advancedScope(scope, view), next: null };
|
|
90
|
+
return unverifiedPart(entry.locator);
|
|
106
91
|
}
|
|
107
92
|
async function refreshed(entry, fromRoomVersion) {
|
|
108
93
|
const from = logPosition(fromRoomVersion);
|
|
109
94
|
if (from === null)
|
|
110
95
|
return { kind: 'beyond-horizon' };
|
|
111
|
-
const streamed = notifications.advance(entry, from);
|
|
96
|
+
const streamed = await stepped(notifications.advance(entry, from));
|
|
112
97
|
if (streamed !== null) {
|
|
113
98
|
const models = await streamedModels(streamed.schemas, entry, 'site');
|
|
114
99
|
return models === undefined ? streamed.page : { ...streamed.page, models };
|
|
115
100
|
}
|
|
116
|
-
const
|
|
117
|
-
if ('kind' in
|
|
118
|
-
return
|
|
119
|
-
const view = viewOf(found, entry);
|
|
120
|
-
if (view === undefined)
|
|
121
|
-
return { kind: 'room-not-readable', locator: entry.locator };
|
|
101
|
+
const view = await enumeration(entry, from);
|
|
102
|
+
if ('kind' in view)
|
|
103
|
+
return view;
|
|
122
104
|
notifications.reach(entry.authority, view);
|
|
123
|
-
const answer = refreshFrom(view, fromRoomVersion);
|
|
105
|
+
const answer = await refreshFrom(view, fromRoomVersion);
|
|
124
106
|
if (answer.kind !== 'net-advancement')
|
|
125
107
|
return answer;
|
|
126
108
|
const models = await viewModels(view, entry);
|
|
@@ -128,6 +110,9 @@ export function createSiteAdapter(transport) {
|
|
|
128
110
|
}
|
|
129
111
|
return {
|
|
130
112
|
localSaves: true,
|
|
113
|
+
exhaustiveDiscovery: true,
|
|
114
|
+
roomTypes: HOUSE_ROOM_TYPES,
|
|
115
|
+
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
131
116
|
async authorize() {
|
|
132
117
|
return {};
|
|
133
118
|
},
|
|
@@ -150,23 +135,43 @@ export function createSiteAdapter(transport) {
|
|
|
150
135
|
const entry = tracked.get(request.locator);
|
|
151
136
|
if (entry === undefined)
|
|
152
137
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
138
|
+
let continued;
|
|
139
|
+
let inventory;
|
|
140
|
+
if (request.pageToken === undefined) {
|
|
141
|
+
const room = await partedRoom(entry);
|
|
142
|
+
if ('kind' in room)
|
|
143
|
+
return room;
|
|
144
|
+
const { models, seen } = await manifestedModels(room, entry);
|
|
145
|
+
continued = { room, next: 0, seen };
|
|
146
|
+
inventory = partInventory(room);
|
|
147
|
+
if (inventory.parts > 0) {
|
|
148
|
+
return manifested(room, inventory, JSON.stringify(continued), models);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else
|
|
152
|
+
continued = JSON.parse(request.pageToken);
|
|
153
|
+
const listed = continued.room.parts[continued.next];
|
|
154
|
+
const sent = listed === undefined
|
|
155
|
+
? { scope: emptyScope(continued.room), frame: null }
|
|
156
|
+
: await fetchedPart(entry, continued.room, listed, request.received, request.arriving);
|
|
157
|
+
if ('kind' in sent)
|
|
158
|
+
return sent;
|
|
159
|
+
const { scope } = sent;
|
|
160
|
+
notifications.reach(entry.authority, scope);
|
|
161
|
+
const next = continued.next + 1;
|
|
162
|
+
const more = next < continued.room.parts.length;
|
|
160
163
|
const seen = [
|
|
161
|
-
...
|
|
162
|
-
...
|
|
164
|
+
...continued.seen,
|
|
165
|
+
...(scope.files.some((file) => file.path === entry.schema) ? [entry.schema] : []),
|
|
163
166
|
];
|
|
164
|
-
const models = await partModels(
|
|
165
|
-
const
|
|
167
|
+
const models = await partModels(scope, entry, new Set(seen), !more);
|
|
168
|
+
const { folders: _folders, ...page } = await stepped(bootstrapping(scope));
|
|
166
169
|
return {
|
|
167
|
-
...
|
|
170
|
+
...page,
|
|
168
171
|
...(models === undefined ? {} : { models }),
|
|
169
|
-
...(
|
|
172
|
+
...(more ? { pageToken: JSON.stringify({ ...continued, next, seen }) } : {}),
|
|
173
|
+
...(inventory === undefined ? {} : { inventory }),
|
|
174
|
+
...(sent.frame === null ? {} : { received: sent.frame }),
|
|
170
175
|
};
|
|
171
176
|
},
|
|
172
177
|
async refresh(_authorization, request) {
|
|
@@ -175,6 +180,11 @@ export function createSiteAdapter(transport) {
|
|
|
175
180
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
176
181
|
if (request.pageToken !== undefined)
|
|
177
182
|
return UNCERTAIN;
|
|
183
|
+
if (snapshot) {
|
|
184
|
+
return request.fromRoomVersion === roomVersion(entry)
|
|
185
|
+
? { kind: 'still-current' }
|
|
186
|
+
: { kind: 'beyond-horizon' };
|
|
187
|
+
}
|
|
178
188
|
return refreshed(entry, request.fromRoomVersion);
|
|
179
189
|
},
|
|
180
190
|
async mutate() {
|
|
@@ -184,30 +194,25 @@ export function createSiteAdapter(transport) {
|
|
|
184
194
|
return { kind: 'no-history' };
|
|
185
195
|
},
|
|
186
196
|
async binary(_authorization, request) {
|
|
187
|
-
const
|
|
188
|
-
if (
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
if (
|
|
192
|
-
return
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const read = await transport.download(`${SITE_FILES}${room_ref}/${encodeURIComponent(request.fileRef)}/${path === undefined
|
|
196
|
-
? `${SITE_FILE_RECORD}/${encodeURIComponent(record)}`
|
|
197
|
-
: encodeURIComponent(path)}`);
|
|
198
|
-
if (read.status === 404) {
|
|
199
|
-
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
200
|
-
}
|
|
201
|
-
return read.status === 200 && read.blob !== null
|
|
202
|
-
? { kind: 'binary', blob: read.blob }
|
|
197
|
+
const route = fileRoute(request);
|
|
198
|
+
if (typeof route !== 'string')
|
|
199
|
+
return route;
|
|
200
|
+
const read = await transport.download(route);
|
|
201
|
+
if (read.status === 404)
|
|
202
|
+
return unfound();
|
|
203
|
+
return read.status === 200 && read.body !== null
|
|
204
|
+
? { kind: 'binary', body: read.body, mediaType: read.mediaType }
|
|
203
205
|
: UNCERTAIN;
|
|
204
206
|
},
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
208
|
-
return
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
async link(_authorization, request) {
|
|
208
|
+
const route = fileRoute(request);
|
|
209
|
+
if (typeof route !== 'string')
|
|
210
|
+
return route;
|
|
211
|
+
return {
|
|
212
|
+
kind: 'link',
|
|
213
|
+
url: route,
|
|
214
|
+
name: request.path.slice(request.path.lastIndexOf('/') + 1),
|
|
215
|
+
};
|
|
211
216
|
},
|
|
212
217
|
reached(locator, version, target) {
|
|
213
218
|
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
|
@@ -228,20 +233,27 @@ export function createSiteAdapter(transport) {
|
|
|
228
233
|
return UNCERTAIN;
|
|
229
234
|
return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), SITE_SUBMIT);
|
|
230
235
|
},
|
|
231
|
-
roomStream:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
236
|
+
roomStream: snapshot
|
|
237
|
+
? undefined
|
|
238
|
+
: {
|
|
239
|
+
hold(rooms) {
|
|
240
|
+
notifications.send(rooms.flatMap((room) => {
|
|
241
|
+
const entry = tracked.get(room.locator);
|
|
242
|
+
const at = logPosition(room.roomVersion);
|
|
243
|
+
if (entry === undefined || at === null)
|
|
244
|
+
return [];
|
|
245
|
+
notifications.reach(entry.authority, at);
|
|
246
|
+
return [presented(entry.authority, at)];
|
|
247
|
+
}));
|
|
248
|
+
},
|
|
249
|
+
reopen: notifications.reopen,
|
|
250
|
+
observe: notifications.observe,
|
|
251
|
+
published(locator, roomVersion) {
|
|
252
|
+
const at = logPosition(roomVersion);
|
|
253
|
+
if (at !== null)
|
|
254
|
+
notifications.published(locator, at);
|
|
255
|
+
},
|
|
241
256
|
},
|
|
242
|
-
reopen: notifications.reopen,
|
|
243
|
-
observe: notifications.observe,
|
|
244
|
-
},
|
|
245
257
|
serviceMode: notifications.serviceMode,
|
|
246
258
|
};
|
|
247
259
|
}
|
package/dist/stream.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ConversationStream, type RefreshPage, type RoomStreamEvent, type ServiceModeSignal, type StreamReceipts } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
3
|
import type { HouseDoor, HouseHeldRoom, HouseMode, HouseStreamEntry } from './transport.js';
|
|
4
4
|
import { type LogPosition } from './version.js';
|
|
5
5
|
export type HeldRevision = (path: string, revision: string) => boolean;
|
|
6
6
|
export type StreamedAdvancement = {
|
|
7
7
|
page: RefreshPage;
|
|
8
|
-
entries: readonly HouseStreamEntry[];
|
|
9
8
|
schemas: ReadonlyMap<string, HouseStreamEntry>;
|
|
10
9
|
};
|
|
11
10
|
export type HouseNotifications = {
|
|
12
11
|
runtime: string;
|
|
13
|
-
observe(notify: (event: RoomStreamEvent) => void): () => void;
|
|
12
|
+
observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
|
|
14
13
|
send(rooms: readonly HouseHeldRoom[]): void;
|
|
14
|
+
published(locator: string, at: LogPosition): void;
|
|
15
15
|
reopen(): void;
|
|
16
16
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
17
17
|
reach(authority: string, at: LogPosition): void;
|
|
18
|
-
|
|
18
|
+
edited(tracked: TrackedAuthority, from: LogPosition): readonly string[];
|
|
19
|
+
advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): Generator<number, StreamedAdvancement | null, void>;
|
|
19
20
|
conversations: ConversationStream;
|
|
20
21
|
serviceMode: ServiceModeSignal;
|
|
21
22
|
};
|
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,EAGL,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAChB,KAAK,eAAe,EAEpB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAUvD,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,SAAS,EAET,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AA0C7D,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,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,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI,CAAC;IACxF,IAAI,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;IAC5C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC;IAClD,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,MAAM,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,SAAS,MAAM,EAAE,CAAC;IACxE,OAAO,CACL,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,EACjB,KAAK,CAAC,EAAE,YAAY,GACnB,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC;IACvD,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAmFF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CA8jB5F"}
|