@agentshouse/mdruntime-adapter 0.1.0-cea44707d3919 → 0.1.0-ceb5de2c525b2
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 +3 -3
- package/dist/actions.d.ts +8 -6
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +48 -320
- package/dist/adapter.d.ts +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +304 -228
- package/dist/authored-path.d.ts +66 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +166 -0
- package/dist/chunks.d.ts +36 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +281 -0
- package/dist/digest.d.ts +0 -1
- package/dist/discovery.d.ts +45 -18
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +254 -65
- package/dist/history.d.ts +6 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +85 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/map.d.ts +0 -1
- package/dist/model.d.ts +6 -6
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +31 -44
- package/dist/read.d.ts +54 -48
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +209 -267
- package/dist/refusal.d.ts +8 -10
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +31 -18
- package/dist/renamed.d.ts +10 -0
- package/dist/renamed.d.ts.map +1 -0
- package/dist/renamed.js +29 -0
- package/dist/room-query.d.ts +4 -0
- package/dist/room-query.d.ts.map +1 -0
- package/dist/room-query.js +63 -0
- package/dist/search.d.ts +4 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +47 -0
- package/dist/session-content/check.d.ts +17 -0
- package/dist/session-content/index.d.ts +6 -0
- package/dist/session-content/parts.d.ts +30 -0
- package/dist/session-content/state.d.ts +59 -0
- package/dist/session-content/turn.d.ts +137 -0
- package/dist/site.d.ts +1 -2
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +152 -108
- package/dist/space-schema.d.ts +6 -0
- package/dist/space-schema.d.ts.map +1 -0
- package/dist/space-schema.js +11 -0
- package/dist/stream.d.ts +14 -14
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +279 -154
- package/dist/transport.d.ts +127 -31
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +91 -9
- package/dist/uncertain.d.ts +5 -0
- package/dist/uncertain.d.ts.map +1 -0
- package/dist/uncertain.js +11 -0
- package/dist/upload.d.ts +17 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +106 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/write.d.ts +18 -11
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +177 -71
- package/package.json +11 -7
- package/AGENTS.md +0 -253
- package/dist/gather.d.ts +0 -3
- package/dist/gather.d.ts.map +0 -1
- package/dist/gather.js +0 -40
- package/dist/links.d.ts +0 -20
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -104
package/dist/transport.d.ts
CHANGED
|
@@ -1,44 +1,70 @@
|
|
|
1
|
-
import type { ConversationEvent,
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export declare
|
|
10
|
-
export declare
|
|
1
|
+
import type { ConversationEvent, ListedAgent, SavedFacts } from '@agentshouse/mdruntime';
|
|
2
|
+
import type { Operation, SessionState } from './session-content/index.js';
|
|
3
|
+
export declare const HOUSE_RUNTIME_READS: {
|
|
4
|
+
readonly acts: readonly ['account/push/set', 'account/time-zone/set', 'apps/features/set', 'apps/source/download', 'apps/source/top/read', 'conversations/history/list', 'files/attach', 'files/finish', 'files/read', 'files/revisions/list', 'info', 'room-chunks/list', 'rooms/discover', 'rooms/search', 'sites/screenshot/read', 'update'];
|
|
5
|
+
readonly frames: readonly ['agent', 'app-message', 'app-rooms', 'authority_changed', 'carried', 'caught_up', 'commands', 'conversation', 'conversation_deleted', 'conversations', 'deliveries', 'deployment', 'held', 'interactions', 'message', 'opening', 'options', 'part', 'process', 'received', 'report', 'signal', 'site', 'starting', 'state', 'tab-icon', 'turn'];
|
|
6
|
+
};
|
|
7
|
+
export type HouseRuntimeAct = (typeof HOUSE_RUNTIME_READS.acts)[number];
|
|
8
|
+
export type HouseRuntimeFrame = (typeof HOUSE_RUNTIME_READS.frames)[number];
|
|
9
|
+
export declare function houseDoorRoute(act: HouseRuntimeAct): string;
|
|
10
|
+
export declare function houseSiteRoute(act: 'chunks' | 'discover' | 'query'): string;
|
|
11
|
+
export declare const SITE_QUERY = "query";
|
|
12
|
+
export declare const SITE_FRESH_QUERY = "fresh";
|
|
13
|
+
export declare const SITE_QUERY_ROUTE_CHARACTERS = 12000;
|
|
14
|
+
export declare function siteQueryRoute(room: string, query: Readonly<Record<string, unknown>>, fresh?: boolean): string;
|
|
15
|
+
export declare function siteQueryAsked(address: string): Readonly<Record<string, unknown>> | null;
|
|
16
|
+
export declare const SITES_SUBMISSIONS_CREATE = "sites/submissions/create";
|
|
11
17
|
export declare const SITE_DOOR_SUBMIT = "/_house/door/submit";
|
|
18
|
+
export declare const SITES_FUNCTIONS_CALL = "sites/functions/call";
|
|
19
|
+
export declare const SITE_DOOR_FUNCTION = "/_house/door/function";
|
|
20
|
+
export declare const SITE_DOOR_ACTS: Readonly<Record<string, string>>;
|
|
12
21
|
export type HouseMode = 'credential' | 'site';
|
|
13
22
|
export type HouseDoorAnswer = {
|
|
14
23
|
status: number;
|
|
15
24
|
body: unknown;
|
|
16
25
|
};
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export type
|
|
26
|
+
export declare const SITE_FILES = "/_house/files/";
|
|
27
|
+
export declare const SITE_IMAGE_COPIES_HEADER = "X-House-Image-Copies";
|
|
28
|
+
export type HouseBytesAnswer = {
|
|
29
|
+
status: number;
|
|
30
|
+
body: ReadableStream<Uint8Array> | null;
|
|
31
|
+
mediaType: string;
|
|
32
|
+
copies?: string | null;
|
|
33
|
+
};
|
|
20
34
|
export type HouseByteTransfer = {
|
|
21
|
-
act: HouseByteAct;
|
|
22
|
-
method: 'GET' | 'POST';
|
|
23
35
|
url: string;
|
|
24
|
-
|
|
25
|
-
body?: HouseByteBody;
|
|
26
|
-
operation?: string;
|
|
36
|
+
body: string;
|
|
27
37
|
};
|
|
28
38
|
export type HouseStreamEntry = {
|
|
29
39
|
path: string;
|
|
30
|
-
kind: 'edited' | 'removed';
|
|
40
|
+
kind: 'edited' | 'removed' | 'folder';
|
|
41
|
+
removed?: true;
|
|
31
42
|
revision?: string;
|
|
32
43
|
sha256?: string;
|
|
33
|
-
|
|
44
|
+
bytes?: number;
|
|
45
|
+
media_type?: string;
|
|
34
46
|
author?: {
|
|
35
47
|
user: string;
|
|
36
48
|
name: string;
|
|
37
49
|
} | {
|
|
38
50
|
site: string;
|
|
39
51
|
name: string;
|
|
52
|
+
} | {
|
|
53
|
+
inbox: string;
|
|
54
|
+
name: string;
|
|
55
|
+
} | {
|
|
56
|
+
app: string;
|
|
57
|
+
function: string;
|
|
58
|
+
release: string;
|
|
59
|
+
name: string;
|
|
40
60
|
};
|
|
61
|
+
changed_at?: string;
|
|
41
62
|
created_at?: string;
|
|
63
|
+
content?: string;
|
|
64
|
+
provenance?: string;
|
|
65
|
+
facts?: SavedFacts;
|
|
66
|
+
move?: 'arrival' | 'leaving';
|
|
67
|
+
space?: string;
|
|
42
68
|
};
|
|
43
69
|
type LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, {
|
|
44
70
|
kind: K;
|
|
@@ -48,24 +74,64 @@ export type HouseListedConversation = {
|
|
|
48
74
|
agent_id: string;
|
|
49
75
|
name: string;
|
|
50
76
|
created_at: string;
|
|
51
|
-
finished_at: string | null;
|
|
52
77
|
outcome: string | null;
|
|
78
|
+
waiting: boolean;
|
|
79
|
+
newest: number | null;
|
|
80
|
+
process_ended_at: string | null;
|
|
81
|
+
subject: string | null;
|
|
82
|
+
room_ref: string | null;
|
|
83
|
+
model: string | null;
|
|
84
|
+
effort: string | null;
|
|
53
85
|
};
|
|
54
|
-
|
|
55
|
-
type:
|
|
86
|
+
type Listed<Frame extends {
|
|
87
|
+
readonly type: HouseRuntimeFrame;
|
|
88
|
+
}> = Frame;
|
|
89
|
+
export type HouseStreamFrame = Listed<{
|
|
90
|
+
type: 'part';
|
|
56
91
|
authority: string;
|
|
92
|
+
carry: string;
|
|
93
|
+
index: number;
|
|
94
|
+
entries: readonly HouseStreamEntry[];
|
|
95
|
+
} | {
|
|
96
|
+
type: 'carried';
|
|
97
|
+
authority: string;
|
|
98
|
+
carry: string;
|
|
99
|
+
parts: number;
|
|
57
100
|
after: string;
|
|
58
101
|
position: string;
|
|
59
102
|
log_epoch: string;
|
|
60
|
-
entries: readonly HouseStreamEntry[];
|
|
61
103
|
} | {
|
|
62
104
|
type: 'opening';
|
|
105
|
+
member: unknown;
|
|
106
|
+
time_zone: unknown;
|
|
107
|
+
bounds: unknown;
|
|
108
|
+
actions: readonly unknown[];
|
|
109
|
+
shapes: readonly unknown[];
|
|
110
|
+
rooms: readonly unknown[];
|
|
111
|
+
listed: readonly unknown[];
|
|
112
|
+
spaces: readonly unknown[];
|
|
113
|
+
} | {
|
|
114
|
+
type: 'caught_up';
|
|
63
115
|
expired: readonly string[];
|
|
64
|
-
} |
|
|
116
|
+
} | {
|
|
117
|
+
type: 'authority_changed';
|
|
118
|
+
member: unknown;
|
|
119
|
+
time_zone: unknown;
|
|
120
|
+
authorities: readonly unknown[];
|
|
121
|
+
listed: readonly unknown[];
|
|
122
|
+
spaces: readonly unknown[];
|
|
123
|
+
left: readonly string[];
|
|
124
|
+
} | {
|
|
125
|
+
type: 'turn';
|
|
126
|
+
conversation_id: string;
|
|
127
|
+
turn_id: string;
|
|
128
|
+
at: string;
|
|
129
|
+
} | {
|
|
65
130
|
type: 'turn';
|
|
66
131
|
conversation_id: string;
|
|
67
132
|
turn_id: string;
|
|
68
|
-
|
|
133
|
+
operation: Operation;
|
|
134
|
+
} | {
|
|
69
135
|
type: 'message';
|
|
70
136
|
conversation_id: string;
|
|
71
137
|
message: unknown;
|
|
@@ -73,6 +139,11 @@ export type HouseStreamFrame = {
|
|
|
73
139
|
type: 'interactions';
|
|
74
140
|
conversation_id: string;
|
|
75
141
|
interactions: readonly unknown[];
|
|
142
|
+
} | {
|
|
143
|
+
type: 'deliveries';
|
|
144
|
+
conversation_id: string;
|
|
145
|
+
waiting: readonly string[];
|
|
146
|
+
unknown: readonly string[];
|
|
76
147
|
} | {
|
|
77
148
|
type: 'process';
|
|
78
149
|
conversation_id: string;
|
|
@@ -85,32 +156,55 @@ export type HouseStreamFrame = {
|
|
|
85
156
|
type: 'options';
|
|
86
157
|
conversation_id: string;
|
|
87
158
|
options: LiveFact<'options'>['options'];
|
|
159
|
+
} | {
|
|
160
|
+
type: 'starting';
|
|
161
|
+
conversation_id: string;
|
|
162
|
+
step: string | null;
|
|
163
|
+
} | {
|
|
164
|
+
type: 'state';
|
|
165
|
+
conversation_id: string;
|
|
166
|
+
state: SessionState;
|
|
88
167
|
} | {
|
|
89
168
|
type: 'conversations';
|
|
169
|
+
agents: readonly ListedAgent[];
|
|
90
170
|
conversations: readonly HouseListedConversation[];
|
|
171
|
+
whole: boolean;
|
|
172
|
+
more: boolean;
|
|
173
|
+
cursor: string | null;
|
|
91
174
|
} | {
|
|
92
175
|
type: 'conversation';
|
|
93
176
|
conversation: HouseListedConversation;
|
|
177
|
+
} | {
|
|
178
|
+
type: 'agent';
|
|
179
|
+
agent: ListedAgent;
|
|
94
180
|
} | {
|
|
95
181
|
type: 'conversation_deleted';
|
|
96
182
|
conversation_id: string;
|
|
97
183
|
} | {
|
|
98
184
|
type: 'signal';
|
|
99
185
|
service_mode: string;
|
|
100
|
-
}
|
|
186
|
+
} | {
|
|
187
|
+
type: 'report';
|
|
188
|
+
}>;
|
|
101
189
|
export type HouseHeldRoom = {
|
|
102
190
|
authority: string;
|
|
103
191
|
position: string;
|
|
104
192
|
log_epoch: string;
|
|
105
193
|
};
|
|
106
194
|
export type HouseOpening = {
|
|
107
|
-
hold(rooms: readonly HouseHeldRoom[], runtime: string): void;
|
|
108
|
-
|
|
195
|
+
hold(rooms: readonly HouseHeldRoom[], runtime: string, conversations: string | null): void;
|
|
196
|
+
received(authority: string, carry: string, index: number): void;
|
|
197
|
+
close(failure?: unknown): void;
|
|
198
|
+
};
|
|
199
|
+
export type HouseClosing = {
|
|
200
|
+
revoked: boolean;
|
|
201
|
+
lost: boolean;
|
|
202
|
+
authorityChanged: boolean;
|
|
109
203
|
};
|
|
110
204
|
export type HouseStream = {
|
|
111
205
|
observe(receive: (frame: HouseStreamFrame) => void): () => void;
|
|
112
206
|
opened(notify: (opening: HouseOpening) => void): () => void;
|
|
113
|
-
closed(notify: (
|
|
207
|
+
closed(notify: (closing: HouseClosing) => void): () => void;
|
|
114
208
|
};
|
|
115
209
|
export type HouseDoor = {
|
|
116
210
|
door(route: string, body: unknown): Promise<HouseDoorAnswer>;
|
|
@@ -118,10 +212,12 @@ export type HouseDoor = {
|
|
|
118
212
|
};
|
|
119
213
|
export type HouseTransport = HouseDoor & {
|
|
120
214
|
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
215
|
+
put(url: string, body: Blob, headers: Readonly<Record<string, string>>): Promise<number>;
|
|
216
|
+
download(url: string): Promise<HouseBytesAnswer>;
|
|
121
217
|
};
|
|
122
218
|
export type HouseSiteTransport = HouseDoor & {
|
|
123
219
|
online(): boolean;
|
|
124
220
|
read(route: string): Promise<HouseDoorAnswer>;
|
|
221
|
+
download(route: string): Promise<HouseBytesAnswer>;
|
|
125
222
|
};
|
|
126
223
|
export {};
|
|
127
|
-
//# sourceMappingURL=transport.d.ts.map
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5E,eAAO,MAAM,mBAAmB;aAC9B,IAAI,YACF,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,cAAc,EACd,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,MAAM,EACN,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,QAAQ;aAEV,MAAM,YACJ,OAAO,EACP,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,cAAc,EACd,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,UAAU,EACV,OAAO,EACP,UAAU,EACV,MAAM;CAEA,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAE3D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAE3E;AAED,eAAO,MAAM,UAAU,UAAU,CAAC;A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AE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpD,CAAC"}
|
package/dist/transport.js
CHANGED
|
@@ -1,10 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { plain, queryKey } from '@agentshouse/mdmodel';
|
|
2
|
+
export const HOUSE_RUNTIME_READS = {
|
|
3
|
+
acts: [
|
|
4
|
+
'account/push/set',
|
|
5
|
+
'account/time-zone/set',
|
|
6
|
+
'apps/features/set',
|
|
7
|
+
'apps/source/download',
|
|
8
|
+
'apps/source/top/read',
|
|
9
|
+
'conversations/history/list',
|
|
10
|
+
'files/attach',
|
|
11
|
+
'files/finish',
|
|
12
|
+
'files/read',
|
|
13
|
+
'files/revisions/list',
|
|
14
|
+
'info',
|
|
15
|
+
'room-chunks/list',
|
|
16
|
+
'rooms/discover',
|
|
17
|
+
'rooms/search',
|
|
18
|
+
'sites/screenshot/read',
|
|
19
|
+
'update',
|
|
20
|
+
],
|
|
21
|
+
frames: [
|
|
22
|
+
'agent',
|
|
23
|
+
'app-message',
|
|
24
|
+
'app-rooms',
|
|
25
|
+
'authority_changed',
|
|
26
|
+
'carried',
|
|
27
|
+
'caught_up',
|
|
28
|
+
'commands',
|
|
29
|
+
'conversation',
|
|
30
|
+
'conversation_deleted',
|
|
31
|
+
'conversations',
|
|
32
|
+
'deliveries',
|
|
33
|
+
'deployment',
|
|
34
|
+
'held',
|
|
35
|
+
'interactions',
|
|
36
|
+
'message',
|
|
37
|
+
'opening',
|
|
38
|
+
'options',
|
|
39
|
+
'part',
|
|
40
|
+
'process',
|
|
41
|
+
'received',
|
|
42
|
+
'report',
|
|
43
|
+
'signal',
|
|
44
|
+
'site',
|
|
45
|
+
'starting',
|
|
46
|
+
'state',
|
|
47
|
+
'tab-icon',
|
|
48
|
+
'turn',
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
export function houseDoorRoute(act) {
|
|
52
|
+
return `/door/${act}`;
|
|
53
|
+
}
|
|
54
|
+
export function houseSiteRoute(act) {
|
|
55
|
+
return `/_house/door/${act}`;
|
|
56
|
+
}
|
|
57
|
+
export const SITE_QUERY = 'query';
|
|
58
|
+
export const SITE_FRESH_QUERY = 'fresh';
|
|
59
|
+
export const SITE_QUERY_ROUTE_CHARACTERS = 12_000;
|
|
60
|
+
function addressed(text) {
|
|
61
|
+
let binary = '';
|
|
62
|
+
for (const byte of new TextEncoder().encode(text))
|
|
63
|
+
binary += String.fromCharCode(byte);
|
|
64
|
+
return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/u, '');
|
|
65
|
+
}
|
|
66
|
+
export function siteQueryRoute(room, query, fresh = false) {
|
|
67
|
+
const canonical = queryKey(JSON.parse(JSON.stringify(query)));
|
|
68
|
+
const named = fresh ? SITE_FRESH_QUERY : SITE_QUERY;
|
|
69
|
+
return `${houseSiteRoute('query')}/${room}?${named}=${addressed(canonical)}`;
|
|
70
|
+
}
|
|
71
|
+
export function siteQueryAsked(address) {
|
|
72
|
+
let asked;
|
|
73
|
+
try {
|
|
74
|
+
const binary = atob(address.replaceAll('-', '+').replaceAll('_', '/'));
|
|
75
|
+
const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
76
|
+
asked = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return plain(asked) && addressed(queryKey(asked)) === address ? asked : null;
|
|
82
|
+
}
|
|
83
|
+
export const SITES_SUBMISSIONS_CREATE = 'sites/submissions/create';
|
|
10
84
|
export const SITE_DOOR_SUBMIT = '/_house/door/submit';
|
|
85
|
+
export const SITES_FUNCTIONS_CALL = 'sites/functions/call';
|
|
86
|
+
export const SITE_DOOR_FUNCTION = '/_house/door/function';
|
|
87
|
+
export const SITE_DOOR_ACTS = {
|
|
88
|
+
[SITES_SUBMISSIONS_CREATE]: SITE_DOOR_SUBMIT,
|
|
89
|
+
[SITES_FUNCTIONS_CALL]: SITE_DOOR_FUNCTION,
|
|
90
|
+
};
|
|
91
|
+
export const SITE_FILES = '/_house/files/';
|
|
92
|
+
export const SITE_IMAGE_COPIES_HEADER = 'X-House-Image-Copies';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ProviderRefusal, type TransportUncertainty } from '@agentshouse/mdruntime';
|
|
2
|
+
export declare const UNANSWERED: TransportUncertainty;
|
|
3
|
+
export declare function failedOn(failure: unknown): TransportUncertainty;
|
|
4
|
+
export declare function unusable(): TransportUncertainty;
|
|
5
|
+
export declare function refusedFor(refusal: ProviderRefusal): TransportUncertainty;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uncertain.d.ts","sourceRoot":"","sources":["../src/uncertain.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,UAAU,EAAE,oBAAwD,CAAC;AAElF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAE/D;AAED,wBAAgB,QAAQ,IAAI,oBAAoB,CAE/C;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,oBAAoB,CAEzE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { refusalError, } from '@agentshouse/mdruntime';
|
|
2
|
+
export const UNANSWERED = { kind: 'transport-uncertainty' };
|
|
3
|
+
export function failedOn(failure) {
|
|
4
|
+
return { kind: 'transport-uncertainty', failure };
|
|
5
|
+
}
|
|
6
|
+
export function unusable() {
|
|
7
|
+
return failedOn(new Error());
|
|
8
|
+
}
|
|
9
|
+
export function refusedFor(refusal) {
|
|
10
|
+
return failedOn(refusalError(refusal));
|
|
11
|
+
}
|
package/dist/upload.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TransportUncertainty } from '@agentshouse/mdruntime';
|
|
2
|
+
import { type HouseDoorAnswer, type HouseTransport } from './transport.js';
|
|
3
|
+
export type HouseUpload = {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly partBytes: number;
|
|
6
|
+
readonly parts: readonly {
|
|
7
|
+
readonly part: number;
|
|
8
|
+
readonly url: string;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
export declare function houseUpload(value: unknown): HouseUpload | null;
|
|
12
|
+
export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer | {
|
|
13
|
+
readonly unfinished: number;
|
|
14
|
+
}>;
|
|
15
|
+
type StagedFile = (sha256: unknown) => Promise<Blob> | null;
|
|
16
|
+
export declare function stagedBatch(transport: HouseTransport, body: Readonly<Record<string, unknown>>, file: StagedFile): Promise<HouseDoorAnswer | TransportUncertainty>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGpF,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG3F,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;AA+BD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB5D;AAED,KAAK,UAAU,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAsB5D,wBAAsB,WAAW,CAC/B,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,eAAe,GAAG,oBAAoB,CAAC,CAoBjD"}
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { sha256 } from '@agentshouse/mdruntime/digest';
|
|
2
|
+
import { answeredFailure, doorRefusal } from './refusal.js';
|
|
3
|
+
import { houseDoorRoute } from './transport.js';
|
|
4
|
+
import { unusable } from './uncertain.js';
|
|
5
|
+
const FINISHING_ROUNDS = 24;
|
|
6
|
+
function record(value) {
|
|
7
|
+
return value !== null && typeof value === 'object' ? value : {};
|
|
8
|
+
}
|
|
9
|
+
function part(value) {
|
|
10
|
+
const { part: number, url } = record(value);
|
|
11
|
+
return Number.isSafeInteger(number) && number > 0 && typeof url === 'string'
|
|
12
|
+
? { part: number, url }
|
|
13
|
+
: null;
|
|
14
|
+
}
|
|
15
|
+
export function houseUpload(value) {
|
|
16
|
+
const { id, part_bytes: partBytes, parts = [] } = record(value);
|
|
17
|
+
if (typeof id !== 'string' || !Number.isSafeInteger(partBytes) || partBytes <= 0)
|
|
18
|
+
return null;
|
|
19
|
+
if (!Array.isArray(parts))
|
|
20
|
+
return null;
|
|
21
|
+
const named = parts.map(part);
|
|
22
|
+
if (named.some((one) => one === null))
|
|
23
|
+
return null;
|
|
24
|
+
return { id, partBytes: partBytes, parts: named };
|
|
25
|
+
}
|
|
26
|
+
function checksum(hex) {
|
|
27
|
+
let bytes = '';
|
|
28
|
+
for (let at = 0; at < hex.length; at += 2)
|
|
29
|
+
bytes += String.fromCharCode(Number.parseInt(hex.slice(at, at + 2), 16));
|
|
30
|
+
return { 'x-amz-checksum-sha256': btoa(bytes) };
|
|
31
|
+
}
|
|
32
|
+
async function partSha256(blob, partBytes) {
|
|
33
|
+
const parts = [];
|
|
34
|
+
for (let start = 0; start === 0 || start < blob.size; start += partBytes)
|
|
35
|
+
parts.push(await sha256(blob.slice(start, start + partBytes)));
|
|
36
|
+
return parts;
|
|
37
|
+
}
|
|
38
|
+
async function sent(transport, upload, blob, digests) {
|
|
39
|
+
for (const { part: number, url } of upload.parts) {
|
|
40
|
+
const start = (number - 1) * upload.partBytes;
|
|
41
|
+
const slice = blob.slice(start, start + upload.partBytes);
|
|
42
|
+
const stored = await transport.put(url, slice, checksum(digests[number - 1]));
|
|
43
|
+
if (stored !== 200)
|
|
44
|
+
return stored;
|
|
45
|
+
}
|
|
46
|
+
return 200;
|
|
47
|
+
}
|
|
48
|
+
export async function finishedUpload(transport, first, blob) {
|
|
49
|
+
const digests = await partSha256(blob, first.partBytes);
|
|
50
|
+
let upload = first;
|
|
51
|
+
for (let round = 0; round < FINISHING_ROUNDS; round += 1) {
|
|
52
|
+
const stored = await sent(transport, upload, blob, digests);
|
|
53
|
+
if (stored !== 200)
|
|
54
|
+
return { unfinished: stored };
|
|
55
|
+
const answer = await transport.door(houseDoorRoute('files/finish'), {
|
|
56
|
+
upload: upload.id,
|
|
57
|
+
part_sha256: digests,
|
|
58
|
+
});
|
|
59
|
+
if (answer.status !== 200)
|
|
60
|
+
return answer;
|
|
61
|
+
const missing = houseUpload(record(answer.body).upload);
|
|
62
|
+
if (missing === null)
|
|
63
|
+
return answer;
|
|
64
|
+
upload = missing;
|
|
65
|
+
}
|
|
66
|
+
return { unfinished: 200 };
|
|
67
|
+
}
|
|
68
|
+
function unstagedRefusal(answer) {
|
|
69
|
+
const refusal = doorRefusal(answer.body);
|
|
70
|
+
return refusal?.code === 'files_unstaged' ? refusal : null;
|
|
71
|
+
}
|
|
72
|
+
async function staged(transport, named, file) {
|
|
73
|
+
const upload = houseUpload(named);
|
|
74
|
+
if (upload === null)
|
|
75
|
+
return unusable();
|
|
76
|
+
const blob = file(record(named).sha256);
|
|
77
|
+
if (blob === null)
|
|
78
|
+
return unusable();
|
|
79
|
+
const sent = await finishedUpload(transport, upload, await blob);
|
|
80
|
+
if ('unfinished' in sent)
|
|
81
|
+
return answeredFailure(sent.unfinished, null);
|
|
82
|
+
if (sent.status !== 200)
|
|
83
|
+
return answeredFailure(sent.status, sent.body);
|
|
84
|
+
return record(sent.body).staged === true ? null : unusable();
|
|
85
|
+
}
|
|
86
|
+
export async function stagedBatch(transport, body, file) {
|
|
87
|
+
let answer = await transport.door(houseDoorRoute('update'), body);
|
|
88
|
+
const finished = new Set();
|
|
89
|
+
for (let unstaged = unstagedRefusal(answer); unstaged !== null; unstaged = unstagedRefusal(answer)) {
|
|
90
|
+
const named = unstaged.fields.upload;
|
|
91
|
+
if (!Array.isArray(named))
|
|
92
|
+
return unusable();
|
|
93
|
+
const fresh = named.filter((upload) => !finished.has(record(upload).id));
|
|
94
|
+
if (fresh.length === 0)
|
|
95
|
+
return answeredFailure(answer.status, answer.body);
|
|
96
|
+
for (const upload of fresh) {
|
|
97
|
+
const staging = await staged(transport, upload, file);
|
|
98
|
+
if (staging !== null)
|
|
99
|
+
return staging;
|
|
100
|
+
}
|
|
101
|
+
for (const upload of fresh)
|
|
102
|
+
finished.add(record(upload).id);
|
|
103
|
+
answer = await transport.door(houseDoorRoute('update'), body);
|
|
104
|
+
}
|
|
105
|
+
return answer;
|
|
106
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export declare function roomVersion(at: LogPosition): string;
|
|
|
11
11
|
export declare function logPosition(version: string): LogPosition | null;
|
|
12
12
|
export declare function readPosition(held: Readonly<Record<string, unknown>>): LogPosition | null;
|
|
13
13
|
export declare function presented(authority: string, at: LogPosition): PresentedPosition;
|
|
14
|
+
export declare const DECIMAL: RegExp;
|
|
14
15
|
export declare function reachedVersion(roomVersion: string, target: string, currentEpoch: string | undefined): boolean;
|
|
15
16
|
export declare function followsVersion(roomVersion: string, next: string): boolean;
|
|
16
|
-
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAEnD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,WAAW,GAAG,IAAI,CAKxF;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,iBAAiB,CAE/E;
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAEnD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,WAAW,GAAG,IAAI,CAKxF;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,iBAAiB,CAE/E;AAED,eAAO,MAAM,OAAO,QAAwB,CAAC;AAE7C,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAQT;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMzE"}
|
package/dist/version.js
CHANGED
|
@@ -18,7 +18,7 @@ export function readPosition(held) {
|
|
|
18
18
|
export function presented(authority, at) {
|
|
19
19
|
return { authority, position: at.position, log_epoch: at.logEpoch };
|
|
20
20
|
}
|
|
21
|
-
const DECIMAL = /^(?:0|[1-9][0-9]*)$/;
|
|
21
|
+
export const DECIMAL = /^(?:0|[1-9][0-9]*)$/;
|
|
22
22
|
export function reachedVersion(roomVersion, target, currentEpoch) {
|
|
23
23
|
if (roomVersion === target)
|
|
24
24
|
return true;
|
package/dist/write.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ChangeBatch, type HistoryResult, type MutationResult } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseBounds } from './discovery.js';
|
|
3
3
|
export type HouseOperation = Readonly<Record<string, unknown>>;
|
|
4
4
|
export type ChangeMapping = {
|
|
@@ -10,6 +10,11 @@ export type ChangeMapping = {
|
|
|
10
10
|
rule: string;
|
|
11
11
|
};
|
|
12
12
|
export declare function houseChanges(batch: ChangeBatch, handle: string): ChangeMapping;
|
|
13
|
+
export declare function houseParts(saved: readonly {
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly parts: unknown;
|
|
16
|
+
}[], handle: string): ChangeMapping;
|
|
17
|
+
export declare function houseMove(batch: ChangeBatch, source: string, destination: string): ChangeMapping;
|
|
13
18
|
export type OperationHead = {
|
|
14
19
|
readonly operation_id: string;
|
|
15
20
|
readonly app_ref?: string;
|
|
@@ -21,14 +26,17 @@ export declare function deltaBody(changes: readonly HouseOperation[]): string;
|
|
|
21
26
|
export declare function deltaBytes(delta: string): number;
|
|
22
27
|
export declare function uploadable(inline: Readonly<Record<string, unknown>>, bytes: number, bounds: Pick<HouseBounds, 'max_inline_body_bytes' | 'max_upload_bytes'>): boolean;
|
|
23
28
|
export declare function deltaDigest(delta: string): Promise<string>;
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
export type MoveAuthorities = {
|
|
30
|
+
readonly source: {
|
|
31
|
+
readonly authority: string;
|
|
32
|
+
readonly handle: string;
|
|
33
|
+
};
|
|
34
|
+
readonly destination: {
|
|
35
|
+
readonly authority: string;
|
|
36
|
+
readonly handle: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare function mutationOutcome(status: number, body: unknown, locator: string, handle: string, move?: MoveAuthorities): Generator<number, MutationResult, void>;
|
|
32
40
|
export declare function rejectedMapping(mapping: Extract<ChangeMapping, {
|
|
33
41
|
kind: 'unmapped';
|
|
34
42
|
}>): {
|
|
@@ -38,6 +46,7 @@ export declare function rejectedMapping(mapping: Extract<ChangeMapping, {
|
|
|
38
46
|
fields: {
|
|
39
47
|
path: string;
|
|
40
48
|
};
|
|
49
|
+
retryable: boolean;
|
|
41
50
|
};
|
|
42
51
|
export declare function revisionBody(input: {
|
|
43
52
|
path: string;
|
|
@@ -46,7 +55,5 @@ export declare function revisionBody(input: {
|
|
|
46
55
|
pageToken?: string;
|
|
47
56
|
}): Record<string, unknown>;
|
|
48
57
|
export declare function historyOutcome(status: number, body: unknown, locator: string, request: {
|
|
49
|
-
path: string;
|
|
50
58
|
revision?: string;
|
|
51
59
|
}): HistoryResult;
|
|
52
|
-
//# sourceMappingURL=write.d.ts.map
|
package/dist/write.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAElB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQlD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE/D,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAwHrD,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAQ9E;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,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