@agentshouse/mdruntime-adapter 0.1.0-cd23c45caa798 → 0.1.0-cd519a0f878dc
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/README.md +2 -2
- package/dist/actions.d.ts +3 -16
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +23 -53
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +124 -132
- 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 +3 -8
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +11 -24
- package/dist/house-model.d.ts +2 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +441 -0
- package/dist/index.d.ts +6 -1
- 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 +4 -2
- package/dist/part.d.ts.map +1 -1
- package/dist/part.js +15 -13
- package/dist/read.d.ts +28 -7
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +172 -95
- 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.map +1 -1
- package/dist/site.js +45 -55
- package/dist/stream.d.ts +1 -0
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +17 -2
- package/dist/transport.d.ts +10 -10
- 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/write.d.ts.map +1 -1
- package/dist/write.js +13 -17
- package/package.json +8 -4
- package/AGENTS.md +0 -304
- package/dist/handed.d.ts +0 -15
- package/dist/handed.d.ts.map +0 -1
- package/dist/handed.js +0 -45
- package/dist/referrer.d.ts +0 -7
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -33
|
@@ -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.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,13 +1,13 @@
|
|
|
1
1
|
import { stepped } from '@agentshouse/mdruntime';
|
|
2
2
|
import { actionOutcome, SITE_SUBMIT } from './actions.js';
|
|
3
3
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
4
|
-
import { partModels, streamedModels, viewModels } from './model.js';
|
|
5
|
-
import {
|
|
6
|
-
import { PART_ATTEMPTS, unverifiedPart } from './part.js';
|
|
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';
|
|
7
7
|
import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
|
|
8
|
+
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
8
9
|
import { houseNotifications } from './stream.js';
|
|
9
|
-
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT,
|
|
10
|
-
import { houseReferrer } from './referrer.js';
|
|
10
|
+
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, SITE_FILES, } from './transport.js';
|
|
11
11
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
12
12
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
13
13
|
function unfound() {
|
|
@@ -24,28 +24,15 @@ function siteRoom(tracked) {
|
|
|
24
24
|
providerOwnedPaths: [],
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function settled(refused) {
|
|
28
|
-
return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;
|
|
29
|
-
}
|
|
30
27
|
export function createSiteAdapter(transport, snapshot = false) {
|
|
31
28
|
const notifications = houseNotifications(transport, 'site');
|
|
32
29
|
const tracked = new Map();
|
|
33
30
|
const expired = new Map();
|
|
34
|
-
function published(referrer) {
|
|
35
|
-
const named = houseReferrer(referrer, tracked);
|
|
36
|
-
return named === null || !tracked.has(named.locator) ? null : named;
|
|
37
|
-
}
|
|
38
31
|
function fileRoute(request) {
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
return { kind: '
|
|
42
|
-
}
|
|
43
|
-
if (request.fileRef === undefined)
|
|
44
|
-
return unfound();
|
|
45
|
-
const { room_ref, path, record } = named.referrer;
|
|
46
|
-
return `${SITE_FILES}${room_ref}/${encodeURIComponent(request.fileRef)}/${path === undefined
|
|
47
|
-
? `${SITE_FILE_RECORD}/${encodeURIComponent(record)}`
|
|
48
|
-
: encodeURIComponent(path)}`;
|
|
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)}`;
|
|
49
36
|
}
|
|
50
37
|
async function enumerated(entry, from, page) {
|
|
51
38
|
const answer = await transport.door(SITE_DOOR_ENUMERATE, {
|
|
@@ -79,34 +66,29 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
79
66
|
const room = parseSiteParted(answer.body);
|
|
80
67
|
return room === null || room.anchor !== entry.authority ? UNCERTAIN : room;
|
|
81
68
|
}
|
|
82
|
-
async function fetchedPart(entry, room, listed) {
|
|
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 };
|
|
75
|
+
}
|
|
83
76
|
for (let attempt = 0; attempt < PART_ATTEMPTS; attempt += 1) {
|
|
84
|
-
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}?part=${encodeURIComponent(listed.part)}
|
|
77
|
+
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}?part=${encodeURIComponent(listed.part)}`, partArrival(listed, arriving));
|
|
85
78
|
const failure = classifyRead(answer.status, answer.body, entry.locator);
|
|
86
79
|
if (failure?.kind === 'beyond-horizon')
|
|
87
80
|
expired.set(entry.locator, room.position);
|
|
88
81
|
if (failure !== null)
|
|
89
82
|
return failure;
|
|
90
|
-
const
|
|
83
|
+
const frame = partFrame(answer.body);
|
|
84
|
+
if (frame === null)
|
|
85
|
+
continue;
|
|
86
|
+
const scope = await housePart(room, frame, listed, 'site');
|
|
91
87
|
if (scope !== null)
|
|
92
|
-
return scope;
|
|
88
|
+
return 'kind' in scope ? scope : { scope, frame };
|
|
93
89
|
}
|
|
94
90
|
return unverifiedPart(entry.locator);
|
|
95
91
|
}
|
|
96
|
-
async function caughtUp(entry, continued) {
|
|
97
|
-
const listed = continued.room.parts[continued.next];
|
|
98
|
-
const scope = listed === undefined
|
|
99
|
-
? emptyScope(continued.room)
|
|
100
|
-
: await fetchedPart(entry, continued.room, listed);
|
|
101
|
-
if ('kind' in scope)
|
|
102
|
-
return scope;
|
|
103
|
-
if (continued.room.parts.length > 1 || roomVersion(scope) === roomVersion(entry))
|
|
104
|
-
return scope;
|
|
105
|
-
const view = await enumeration(entry, scope);
|
|
106
|
-
if ('kind' in view)
|
|
107
|
-
return settled(view);
|
|
108
|
-
return stepped(advancedScope(scope, view));
|
|
109
|
-
}
|
|
110
92
|
async function refreshed(entry, fromRoomVersion) {
|
|
111
93
|
const from = logPosition(fromRoomVersion);
|
|
112
94
|
if (from === null)
|
|
@@ -129,6 +111,8 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
129
111
|
return {
|
|
130
112
|
localSaves: true,
|
|
131
113
|
exhaustiveDiscovery: true,
|
|
114
|
+
roomTypes: HOUSE_ROOM_TYPES,
|
|
115
|
+
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
132
116
|
async authorize() {
|
|
133
117
|
return {};
|
|
134
118
|
},
|
|
@@ -152,29 +136,42 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
152
136
|
if (entry === undefined)
|
|
153
137
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
154
138
|
let continued;
|
|
139
|
+
let inventory;
|
|
155
140
|
if (request.pageToken === undefined) {
|
|
156
141
|
const room = await partedRoom(entry);
|
|
157
142
|
if ('kind' in room)
|
|
158
143
|
return room;
|
|
159
|
-
|
|
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
|
+
}
|
|
160
150
|
}
|
|
161
151
|
else
|
|
162
152
|
continued = JSON.parse(request.pageToken);
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
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;
|
|
166
160
|
notifications.reach(entry.authority, scope);
|
|
167
161
|
const next = continued.next + 1;
|
|
168
162
|
const more = next < continued.room.parts.length;
|
|
169
163
|
const seen = [
|
|
170
164
|
...continued.seen,
|
|
171
|
-
...
|
|
165
|
+
...(scope.files.some((file) => file.path === entry.schema) ? [entry.schema] : []),
|
|
172
166
|
];
|
|
173
167
|
const models = await partModels(scope, entry, new Set(seen), !more);
|
|
168
|
+
const { folders: _folders, ...page } = await stepped(bootstrapping(scope));
|
|
174
169
|
return {
|
|
175
|
-
...
|
|
170
|
+
...page,
|
|
176
171
|
...(models === undefined ? {} : { models }),
|
|
177
172
|
...(more ? { pageToken: JSON.stringify({ ...continued, next, seen }) } : {}),
|
|
173
|
+
...(inventory === undefined ? {} : { inventory }),
|
|
174
|
+
...(sent.frame === null ? {} : { received: sent.frame }),
|
|
178
175
|
};
|
|
179
176
|
},
|
|
180
177
|
async refresh(_authorization, request) {
|
|
@@ -203,8 +200,8 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
203
200
|
const read = await transport.download(route);
|
|
204
201
|
if (read.status === 404)
|
|
205
202
|
return unfound();
|
|
206
|
-
return read.status === 200 && read.
|
|
207
|
-
? { kind: 'binary',
|
|
203
|
+
return read.status === 200 && read.body !== null
|
|
204
|
+
? { kind: 'binary', body: read.body, mediaType: read.mediaType }
|
|
208
205
|
: UNCERTAIN;
|
|
209
206
|
},
|
|
210
207
|
async link(_authorization, request) {
|
|
@@ -217,13 +214,6 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
217
214
|
name: request.path.slice(request.path.lastIndexOf('/') + 1),
|
|
218
215
|
};
|
|
219
216
|
},
|
|
220
|
-
referrerScope(referrer) {
|
|
221
|
-
const named = published(referrer);
|
|
222
|
-
if (named === null)
|
|
223
|
-
return null;
|
|
224
|
-
const { path } = named.referrer;
|
|
225
|
-
return { locator: named.locator, ...(path === undefined ? {} : { path }) };
|
|
226
|
-
},
|
|
227
217
|
reached(locator, version, target) {
|
|
228
218
|
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
|
229
219
|
},
|
package/dist/stream.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type HouseNotifications = {
|
|
|
15
15
|
reopen(): void;
|
|
16
16
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
17
17
|
reach(authority: string, at: LogPosition): void;
|
|
18
|
+
edited(tracked: TrackedAuthority, from: LogPosition): readonly string[];
|
|
18
19
|
advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): Generator<number, StreamedAdvancement | null, void>;
|
|
19
20
|
conversations: ConversationStream;
|
|
20
21
|
serviceMode: ServiceModeSignal;
|
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,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;
|
|
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;AAUv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,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CA8jB5F"}
|
package/dist/stream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { acceptedMessage } from './actions.js';
|
|
3
3
|
import { sha256Hex } from './digest.js';
|
|
4
|
-
import { answered, answering, binaryFileOf, forgotten, headChange, revised } from './read.js';
|
|
4
|
+
import { answered, answering, binaryFileOf, folded, forgotten, headChange, revised, } from './read.js';
|
|
5
5
|
import { roomVersion } from './version.js';
|
|
6
6
|
const HELD_FRAMES_MAX = 256;
|
|
7
7
|
function turnOperation(frame) {
|
|
@@ -556,6 +556,17 @@ export function houseNotifications(transport, mode) {
|
|
|
556
556
|
held,
|
|
557
557
|
});
|
|
558
558
|
},
|
|
559
|
+
edited(tracked, from) {
|
|
560
|
+
const line = lines.get(tracked.authority);
|
|
561
|
+
const start = position(from.position);
|
|
562
|
+
if (line === undefined || start === null || line.logEpoch !== from.logEpoch)
|
|
563
|
+
return [];
|
|
564
|
+
return [
|
|
565
|
+
...new Set(line.frames
|
|
566
|
+
.filter((frame) => frame.position > start)
|
|
567
|
+
.flatMap((frame) => frame.entries.flatMap((entry) => entry.kind === 'edited' && entry.revision !== undefined ? [entry.path] : []))),
|
|
568
|
+
];
|
|
569
|
+
},
|
|
559
570
|
*advance(tracked, from, holds) {
|
|
560
571
|
const line = lines.get(tracked.authority);
|
|
561
572
|
const start = position(from.position);
|
|
@@ -570,13 +581,17 @@ export function houseNotifications(transport, mode) {
|
|
|
570
581
|
for (const frame of pending) {
|
|
571
582
|
for (const entry of frame.entries) {
|
|
572
583
|
yield ROW_WEIGHT + (entry.text?.length ?? 0);
|
|
584
|
+
if (entry.kind === 'folder') {
|
|
585
|
+
folded(answer, entry.path, entry.removed === true);
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
573
588
|
if (entry.kind === 'edited' &&
|
|
574
589
|
entry.revision !== undefined &&
|
|
575
590
|
holds?.(entry.path, entry.revision) === true) {
|
|
576
591
|
forgotten(answer, entry.path);
|
|
577
592
|
continue;
|
|
578
593
|
}
|
|
579
|
-
if (
|
|
594
|
+
if (entry.path === tracked.schema)
|
|
580
595
|
schemas.set(entry.path, entry);
|
|
581
596
|
if (entry.kind === 'removed') {
|
|
582
597
|
forgotten(answer, entry.path);
|
package/dist/transport.d.ts
CHANGED
|
@@ -15,27 +15,26 @@ export type HouseDoorAnswer = {
|
|
|
15
15
|
body: unknown;
|
|
16
16
|
};
|
|
17
17
|
export declare const DOOR_FILES_GET = "/door/files/get";
|
|
18
|
+
export declare const DOOR_FILES_FINISH = "/door/files/finish";
|
|
18
19
|
export declare const SITE_FILES = "/_house/files/";
|
|
19
|
-
export
|
|
20
|
-
export type HouseByteAct = 'authored_batch_upload' | 'file_upload' | 'binary_stage';
|
|
21
|
-
export type HouseByteBody = string | ArrayBuffer | Uint8Array | Blob;
|
|
20
|
+
export type HouseByteAct = 'authored_batch_upload';
|
|
22
21
|
export type HouseBytesAnswer = {
|
|
23
22
|
status: number;
|
|
24
|
-
|
|
23
|
+
body: ReadableStream<Uint8Array> | null;
|
|
24
|
+
mediaType: string;
|
|
25
25
|
};
|
|
26
26
|
export type HouseByteTransfer = {
|
|
27
27
|
act: HouseByteAct;
|
|
28
28
|
url: string;
|
|
29
|
-
body:
|
|
30
|
-
operation?: string;
|
|
29
|
+
body: string;
|
|
31
30
|
};
|
|
32
31
|
export type HouseStreamEntry = {
|
|
33
32
|
path: string;
|
|
34
|
-
kind: 'edited' | 'removed' | 'piece';
|
|
33
|
+
kind: 'edited' | 'removed' | 'piece' | 'folder';
|
|
34
|
+
removed?: true;
|
|
35
35
|
revision?: string;
|
|
36
36
|
sha256?: string;
|
|
37
37
|
text?: string;
|
|
38
|
-
file?: string;
|
|
39
38
|
bytes?: number;
|
|
40
39
|
media_type?: string;
|
|
41
40
|
author?: {
|
|
@@ -165,16 +164,17 @@ export type HouseStream = {
|
|
|
165
164
|
closed(notify: (closing: HouseClosing) => void): () => void;
|
|
166
165
|
};
|
|
167
166
|
export type HouseDoor = {
|
|
168
|
-
door(route: string, body: unknown): Promise<HouseDoorAnswer>;
|
|
167
|
+
door(route: string, body: unknown, arriving?: (bytes: number) => void): Promise<HouseDoorAnswer>;
|
|
169
168
|
stream: HouseStream;
|
|
170
169
|
};
|
|
171
170
|
export type HouseTransport = HouseDoor & {
|
|
172
171
|
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
172
|
+
put(url: string, body: Blob, headers: Readonly<Record<string, string>>): Promise<number>;
|
|
173
173
|
download(url: string): Promise<HouseBytesAnswer>;
|
|
174
174
|
};
|
|
175
175
|
export type HouseSiteTransport = HouseDoor & {
|
|
176
176
|
online(): boolean;
|
|
177
|
-
read(route: string): Promise<HouseDoorAnswer>;
|
|
177
|
+
read(route: string, arriving?: (bytes: number) => void): Promise<HouseDoorAnswer>;
|
|
178
178
|
download(route: string): Promise<HouseBytesAnswer>;
|
|
179
179
|
};
|
|
180
180
|
export {};
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE/E,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,eAAO,MAAM,mBAAmB,2BAA2B,CAA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M,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzF,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAClF,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpD,CAAC"}
|
package/dist/transport.js
CHANGED
|
@@ -9,5 +9,5 @@ export const SITE_DOOR_BOOTSTRAP = '/_house/door/bootstrap/';
|
|
|
9
9
|
export const SITE_DOOR_ENUMERATE = '/_house/door/enumerate';
|
|
10
10
|
export const SITE_DOOR_SUBMIT = '/_house/door/submit';
|
|
11
11
|
export const DOOR_FILES_GET = '/door/files/get';
|
|
12
|
+
export const DOOR_FILES_FINISH = '/door/files/finish';
|
|
12
13
|
export const SITE_FILES = '/_house/files/';
|
|
13
|
-
export const SITE_FILE_RECORD = 'record';
|
package/dist/upload.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type HouseDoorAnswer, type HouseTransport } from './transport.js';
|
|
2
|
+
export type HouseUpload = {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly partBytes: number;
|
|
5
|
+
readonly parts: readonly {
|
|
6
|
+
readonly part: number;
|
|
7
|
+
readonly url: string;
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
export declare function houseUpload(value: unknown): HouseUpload | null;
|
|
11
|
+
export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer | null>;
|
|
12
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE9F,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5E,CAAC;AAeF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAQ9D;AA8BD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAejC"}
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { sha256 } from '@agentshouse/mdruntime/digest';
|
|
2
|
+
import { DOOR_FILES_FINISH } from './transport.js';
|
|
3
|
+
const FINISHING_ROUNDS = 24;
|
|
4
|
+
function record(value) {
|
|
5
|
+
return value !== null && typeof value === 'object' ? value : {};
|
|
6
|
+
}
|
|
7
|
+
function part(value) {
|
|
8
|
+
const { part: number, url } = record(value);
|
|
9
|
+
return Number.isSafeInteger(number) && number > 0 && typeof url === 'string'
|
|
10
|
+
? { part: number, url }
|
|
11
|
+
: null;
|
|
12
|
+
}
|
|
13
|
+
export function houseUpload(value) {
|
|
14
|
+
const { id, part_bytes: partBytes, parts = [] } = record(value);
|
|
15
|
+
if (typeof id !== 'string' || !Number.isSafeInteger(partBytes) || partBytes <= 0)
|
|
16
|
+
return null;
|
|
17
|
+
if (!Array.isArray(parts))
|
|
18
|
+
return null;
|
|
19
|
+
const named = parts.map(part);
|
|
20
|
+
if (named.some((one) => one === null))
|
|
21
|
+
return null;
|
|
22
|
+
return { id, partBytes: partBytes, parts: named };
|
|
23
|
+
}
|
|
24
|
+
function checksum(hex) {
|
|
25
|
+
let bytes = '';
|
|
26
|
+
for (let at = 0; at < hex.length; at += 2)
|
|
27
|
+
bytes += String.fromCharCode(Number.parseInt(hex.slice(at, at + 2), 16));
|
|
28
|
+
return { 'x-amz-checksum-sha256': btoa(bytes) };
|
|
29
|
+
}
|
|
30
|
+
async function partSha256(blob, partBytes) {
|
|
31
|
+
const parts = [];
|
|
32
|
+
for (let start = 0; start === 0 || start < blob.size; start += partBytes)
|
|
33
|
+
parts.push(await sha256(blob.slice(start, start + partBytes)));
|
|
34
|
+
return parts;
|
|
35
|
+
}
|
|
36
|
+
async function sent(transport, upload, blob, digests) {
|
|
37
|
+
for (const { part: number, url } of upload.parts) {
|
|
38
|
+
const start = (number - 1) * upload.partBytes;
|
|
39
|
+
const slice = blob.slice(start, start + upload.partBytes);
|
|
40
|
+
if ((await transport.put(url, slice, checksum(digests[number - 1]))) !== 200)
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
export async function finishedUpload(transport, first, blob) {
|
|
46
|
+
const digests = await partSha256(blob, first.partBytes);
|
|
47
|
+
let upload = first;
|
|
48
|
+
for (let round = 0; round < FINISHING_ROUNDS; round += 1) {
|
|
49
|
+
if (!(await sent(transport, upload, blob, digests)))
|
|
50
|
+
return null;
|
|
51
|
+
const answer = await transport.door(DOOR_FILES_FINISH, {
|
|
52
|
+
upload: upload.id,
|
|
53
|
+
part_sha256: digests,
|
|
54
|
+
});
|
|
55
|
+
if (answer.status !== 200)
|
|
56
|
+
return answer;
|
|
57
|
+
const missing = houseUpload(record(answer.body).upload);
|
|
58
|
+
if (missing === null)
|
|
59
|
+
return answer;
|
|
60
|
+
upload = missing;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
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B,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,aAAa,CAyDf"}
|
package/dist/write.js
CHANGED
|
@@ -338,26 +338,22 @@ export function revisionBody(input) {
|
|
|
338
338
|
function revisionAuthor(entry) {
|
|
339
339
|
const user = entry.author_user;
|
|
340
340
|
const site = entry.author_site;
|
|
341
|
-
const
|
|
342
|
-
|
|
341
|
+
const siteName = entry.author_site_name;
|
|
342
|
+
const inbox = entry.author_inbox;
|
|
343
|
+
const inboxName = entry.author_inbox_name;
|
|
344
|
+
const named = [site, siteName, inbox, inboxName].filter((held) => held !== undefined);
|
|
345
|
+
if (typeof user === 'string' && named.length === 0)
|
|
343
346
|
return { kind: 'user', id: user };
|
|
347
|
+
if (user !== null || named.length !== 2)
|
|
348
|
+
return null;
|
|
349
|
+
if (typeof site === 'string' && typeof siteName === 'string') {
|
|
350
|
+
return { kind: 'site', id: site, name: siteName };
|
|
344
351
|
}
|
|
345
|
-
if (
|
|
346
|
-
return { kind: '
|
|
352
|
+
if (typeof inbox === 'string' && typeof inboxName === 'string') {
|
|
353
|
+
return { kind: 'inbox', id: inbox, name: inboxName };
|
|
347
354
|
}
|
|
348
355
|
return null;
|
|
349
356
|
}
|
|
350
|
-
function historyBinary(entry) {
|
|
351
|
-
if (entry.file === undefined)
|
|
352
|
-
return undefined;
|
|
353
|
-
const { file, bytes, media_type: mediaType, sha256 } = entry;
|
|
354
|
-
if (typeof file !== 'string' ||
|
|
355
|
-
typeof bytes !== 'number' ||
|
|
356
|
-
typeof mediaType !== 'string' ||
|
|
357
|
-
typeof sha256 !== 'string')
|
|
358
|
-
return null;
|
|
359
|
-
return { fileRef: file, byteLength: bytes, mediaType, sha256 };
|
|
360
|
-
}
|
|
361
357
|
export function historyOutcome(status, body, locator, request) {
|
|
362
358
|
const classified = classifyDoor(status, body, locator);
|
|
363
359
|
if (classified !== null)
|
|
@@ -388,7 +384,7 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
388
384
|
retryable: false,
|
|
389
385
|
};
|
|
390
386
|
}
|
|
391
|
-
if (typeof named.
|
|
387
|
+
if (typeof named.media_type === 'string')
|
|
392
388
|
return { kind: 'no-history' };
|
|
393
389
|
if (typeof named.content !== 'string')
|
|
394
390
|
return { kind: 'transport-uncertainty' };
|
|
@@ -404,7 +400,7 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
404
400
|
typeof entry.created_at !== 'string') {
|
|
405
401
|
return { kind: 'transport-uncertainty' };
|
|
406
402
|
}
|
|
407
|
-
const binaryFile =
|
|
403
|
+
const binaryFile = binaryFileOf(entry);
|
|
408
404
|
if (binaryFile === null)
|
|
409
405
|
return { kind: 'transport-uncertainty' };
|
|
410
406
|
revisions.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime-adapter",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-cd519a0f878dc",
|
|
4
4
|
"description": "Agents House Adapter for the MD Runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": ">=24.
|
|
12
|
+
"node": ">=24.22.1"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
@@ -20,11 +20,15 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
|
-
"AGENTS.md",
|
|
24
23
|
"README.md",
|
|
25
24
|
"LICENSE"
|
|
26
25
|
],
|
|
27
26
|
"dependencies": {
|
|
28
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
27
|
+
"@agentshouse/mdruntime": "0.1.0-ccd098ff75bbf"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/agentshouse/core.git",
|
|
32
|
+
"directory": "mdruntime/packages/mdruntime-adapter"
|
|
29
33
|
}
|
|
30
34
|
}
|