@agentshouse/mdruntime-adapter 0.1.0-alpha.9 → 0.1.0-c0074032f9909
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 +32 -0
- package/dist/actions.d.ts +8 -16
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +43 -436
- package/dist/adapter.d.ts +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +352 -231
- package/dist/authored-path.d.ts +9 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +34 -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/digest.js +1 -5
- package/dist/discovery.d.ts +49 -42
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +317 -232
- 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 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/map.d.ts +2 -3
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +6 -7
- package/dist/model.d.ts +8 -19
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +43 -57
- package/dist/read.d.ts +65 -54
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +217 -295
- package/dist/refusal.d.ts +7 -11
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +53 -69
- 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/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +103 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/site.d.ts +1 -2
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +142 -172
- 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 +20 -9
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +394 -236
- package/dist/transport.d.ts +172 -47
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +58 -12
- 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 +13 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +65 -0
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +32 -18
- package/dist/write.d.ts +24 -11
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +263 -241
- package/package.json +10 -14
- package/AGENTS.md +0 -79
- package/dist/actions.js.map +0 -1
- package/dist/adapter.js.map +0 -1
- package/dist/digest.js.map +0 -1
- package/dist/discovery.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/map.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/read.js.map +0 -1
- package/dist/refusal.js.map +0 -1
- package/dist/site.js.map +0 -1
- package/dist/stream.js.map +0 -1
- package/dist/transport.js.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/write.js.map +0 -1
package/dist/transport.d.ts
CHANGED
|
@@ -1,79 +1,200 @@
|
|
|
1
|
-
|
|
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', 'apps/features/set', 'apps/source/download', 'apps/source/top/read', 'conversations/history/list', 'files/attach', 'files/batch', 'files/batch-upload', 'files/finish', 'files/read', 'files/revisions/list', 'room-chunks/list', 'rooms/discover', 'rooms/search', 'sites/screenshot/read'];
|
|
5
|
+
readonly frames: readonly ['agent', 'app-message', 'app-rooms', 'authority_changed', 'carried', 'caught_up', 'commands', 'conversation', 'conversation_deleted', 'conversations', 'deliveries', 'deployment', 'held', 'interactions', 'link', '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'): string;
|
|
11
|
+
export declare const SITES_SUBMISSIONS_CREATE = "sites/submissions/create";
|
|
12
|
+
export declare const SITE_DOOR_SUBMIT = "/_house/door/submit";
|
|
11
13
|
export type HouseMode = 'credential' | 'site';
|
|
12
14
|
export type HouseDoorAnswer = {
|
|
13
15
|
status: number;
|
|
14
16
|
body: unknown;
|
|
15
17
|
};
|
|
16
|
-
export
|
|
17
|
-
export type
|
|
18
|
+
export declare const SITE_FILES = "/_house/files/";
|
|
19
|
+
export type HouseBytesAnswer = {
|
|
20
|
+
status: number;
|
|
21
|
+
body: ReadableStream<Uint8Array> | null;
|
|
22
|
+
mediaType: string;
|
|
23
|
+
};
|
|
18
24
|
export type HouseByteTransfer = {
|
|
19
|
-
act: HouseByteAct;
|
|
20
|
-
method: 'GET' | 'POST';
|
|
21
25
|
url: string;
|
|
22
|
-
body
|
|
23
|
-
operation?: string;
|
|
24
|
-
};
|
|
25
|
-
export type HouseStreamAuthority = {
|
|
26
|
-
kind: 'room';
|
|
27
|
-
room: string;
|
|
28
|
-
} | {
|
|
29
|
-
kind: 'private';
|
|
30
|
-
} | {
|
|
31
|
-
kind: 'conversation';
|
|
32
|
-
conversation: string;
|
|
26
|
+
body: string;
|
|
33
27
|
};
|
|
34
28
|
export type HouseStreamEntry = {
|
|
35
29
|
path: string;
|
|
36
|
-
kind: 'edited' | 'removed';
|
|
30
|
+
kind: 'edited' | 'removed' | 'folder';
|
|
31
|
+
removed?: true;
|
|
37
32
|
revision?: string;
|
|
38
|
-
|
|
33
|
+
sha256?: string;
|
|
34
|
+
bytes?: number;
|
|
35
|
+
media_type?: string;
|
|
36
|
+
author?: {
|
|
37
|
+
user: string;
|
|
38
|
+
name: string;
|
|
39
|
+
} | {
|
|
40
|
+
site: string;
|
|
41
|
+
name: string;
|
|
42
|
+
} | {
|
|
43
|
+
inbox: string;
|
|
44
|
+
name: string;
|
|
45
|
+
} | {
|
|
46
|
+
app: string;
|
|
47
|
+
function: string;
|
|
48
|
+
release: string;
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
changed_at?: string;
|
|
52
|
+
created_at?: string;
|
|
53
|
+
content?: string;
|
|
54
|
+
provenance?: string;
|
|
55
|
+
facts?: SavedFacts;
|
|
56
|
+
move?: 'arrival' | 'leaving';
|
|
57
|
+
space?: string;
|
|
39
58
|
};
|
|
40
|
-
|
|
41
|
-
|
|
59
|
+
type LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, {
|
|
60
|
+
kind: K;
|
|
61
|
+
}>;
|
|
62
|
+
export type HouseListedConversation = {
|
|
63
|
+
conversation_id: string;
|
|
64
|
+
agent_id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
created_at: string;
|
|
67
|
+
finished_at: string | null;
|
|
68
|
+
outcome: string | null;
|
|
69
|
+
waiting: boolean;
|
|
70
|
+
newest: number | null;
|
|
71
|
+
process_ended_at: string | null;
|
|
72
|
+
subject: string | null;
|
|
73
|
+
};
|
|
74
|
+
type Listed<Frame extends {
|
|
75
|
+
readonly type: HouseRuntimeFrame;
|
|
76
|
+
}> = Frame;
|
|
77
|
+
export type HouseStreamFrame = Listed<{
|
|
78
|
+
type: 'part';
|
|
42
79
|
authority: string;
|
|
43
|
-
|
|
44
|
-
|
|
80
|
+
carry: string;
|
|
81
|
+
index: number;
|
|
45
82
|
entries: readonly HouseStreamEntry[];
|
|
46
83
|
} | {
|
|
47
|
-
type: '
|
|
84
|
+
type: 'carried';
|
|
48
85
|
authority: string;
|
|
49
|
-
|
|
50
|
-
|
|
86
|
+
carry: string;
|
|
87
|
+
parts: number;
|
|
88
|
+
after: string;
|
|
89
|
+
position: string;
|
|
90
|
+
log_epoch: string;
|
|
51
91
|
} | {
|
|
52
|
-
type: '
|
|
53
|
-
|
|
54
|
-
|
|
92
|
+
type: 'opening';
|
|
93
|
+
member: unknown;
|
|
94
|
+
bounds: unknown;
|
|
95
|
+
actions: readonly unknown[];
|
|
96
|
+
shapes: readonly unknown[];
|
|
97
|
+
rooms: readonly unknown[];
|
|
98
|
+
listed: readonly unknown[];
|
|
99
|
+
spaces: readonly unknown[];
|
|
55
100
|
} | {
|
|
56
|
-
type: '
|
|
57
|
-
|
|
58
|
-
code?: string;
|
|
101
|
+
type: 'caught_up';
|
|
102
|
+
expired: readonly string[];
|
|
59
103
|
} | {
|
|
60
|
-
type: '
|
|
104
|
+
type: 'authority_changed';
|
|
105
|
+
member: unknown;
|
|
106
|
+
authorities: readonly unknown[];
|
|
107
|
+
listed: readonly unknown[];
|
|
108
|
+
spaces: readonly unknown[];
|
|
109
|
+
left: readonly string[];
|
|
110
|
+
} | {
|
|
111
|
+
type: 'turn';
|
|
61
112
|
conversation_id: string;
|
|
62
|
-
session_id: string;
|
|
63
113
|
turn_id: string;
|
|
64
|
-
|
|
114
|
+
at: string;
|
|
115
|
+
} | {
|
|
116
|
+
type: 'turn';
|
|
117
|
+
conversation_id: string;
|
|
118
|
+
turn_id: string;
|
|
119
|
+
operation: Operation;
|
|
65
120
|
} | {
|
|
66
121
|
type: 'message';
|
|
67
122
|
conversation_id: string;
|
|
68
123
|
message: unknown;
|
|
69
124
|
} | {
|
|
70
|
-
type: '
|
|
125
|
+
type: 'interactions';
|
|
126
|
+
conversation_id: string;
|
|
127
|
+
interactions: readonly unknown[];
|
|
128
|
+
} | {
|
|
129
|
+
type: 'deliveries';
|
|
130
|
+
conversation_id: string;
|
|
131
|
+
waiting: readonly string[];
|
|
132
|
+
unknown: readonly string[];
|
|
133
|
+
} | {
|
|
134
|
+
type: 'process';
|
|
71
135
|
conversation_id: string;
|
|
72
|
-
|
|
136
|
+
running: boolean;
|
|
137
|
+
} | {
|
|
138
|
+
type: 'commands';
|
|
139
|
+
conversation_id: string;
|
|
140
|
+
commands: LiveFact<'commands'>['commands'];
|
|
141
|
+
} | {
|
|
142
|
+
type: 'options';
|
|
143
|
+
conversation_id: string;
|
|
144
|
+
options: LiveFact<'options'>['options'];
|
|
145
|
+
} | {
|
|
146
|
+
type: 'starting';
|
|
147
|
+
conversation_id: string;
|
|
148
|
+
step: string | null;
|
|
149
|
+
} | {
|
|
150
|
+
type: 'state';
|
|
151
|
+
conversation_id: string;
|
|
152
|
+
state: SessionState;
|
|
153
|
+
} | {
|
|
154
|
+
type: 'link';
|
|
155
|
+
conversation_id: string;
|
|
156
|
+
connected: boolean;
|
|
157
|
+
} | {
|
|
158
|
+
type: 'conversations';
|
|
159
|
+
agents: readonly ListedAgent[];
|
|
160
|
+
conversations: readonly HouseListedConversation[];
|
|
161
|
+
whole: boolean;
|
|
162
|
+
more: boolean;
|
|
163
|
+
cursor: string | null;
|
|
164
|
+
} | {
|
|
165
|
+
type: 'conversation';
|
|
166
|
+
conversation: HouseListedConversation;
|
|
167
|
+
} | {
|
|
168
|
+
type: 'agent';
|
|
169
|
+
agent: ListedAgent;
|
|
170
|
+
} | {
|
|
171
|
+
type: 'conversation_deleted';
|
|
172
|
+
conversation_id: string;
|
|
173
|
+
} | {
|
|
174
|
+
type: 'signal';
|
|
175
|
+
service_mode: string;
|
|
176
|
+
} | {
|
|
177
|
+
type: 'report';
|
|
178
|
+
}>;
|
|
179
|
+
export type HouseHeldRoom = {
|
|
180
|
+
authority: string;
|
|
181
|
+
position: string;
|
|
182
|
+
log_epoch: string;
|
|
183
|
+
};
|
|
184
|
+
export type HouseOpening = {
|
|
185
|
+
hold(rooms: readonly HouseHeldRoom[], runtime: string, conversations: string | null): void;
|
|
186
|
+
received(authority: string, carry: string, index: number): void;
|
|
187
|
+
close(failure?: unknown): void;
|
|
188
|
+
};
|
|
189
|
+
export type HouseClosing = {
|
|
190
|
+
revoked: boolean;
|
|
191
|
+
lost: boolean;
|
|
192
|
+
authorityChanged: boolean;
|
|
73
193
|
};
|
|
74
194
|
export type HouseStream = {
|
|
75
|
-
subscribe(authorities: readonly HouseStreamAuthority[]): void;
|
|
76
195
|
observe(receive: (frame: HouseStreamFrame) => void): () => void;
|
|
196
|
+
opened(notify: (opening: HouseOpening) => void): () => void;
|
|
197
|
+
closed(notify: (closing: HouseClosing) => void): () => void;
|
|
77
198
|
};
|
|
78
199
|
export type HouseDoor = {
|
|
79
200
|
door(route: string, body: unknown): Promise<HouseDoorAnswer>;
|
|
@@ -81,8 +202,12 @@ export type HouseDoor = {
|
|
|
81
202
|
};
|
|
82
203
|
export type HouseTransport = HouseDoor & {
|
|
83
204
|
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
205
|
+
put(url: string, body: Blob, headers: Readonly<Record<string, string>>): Promise<number>;
|
|
206
|
+
download(url: string): Promise<HouseBytesAnswer>;
|
|
84
207
|
};
|
|
85
208
|
export type HouseSiteTransport = HouseDoor & {
|
|
209
|
+
online(): boolean;
|
|
86
210
|
read(route: string): Promise<HouseDoorAnswer>;
|
|
211
|
+
download(route: string): Promise<HouseBytesAnswer>;
|
|
87
212
|
};
|
|
88
|
-
|
|
213
|
+
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,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","source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vC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,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,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,12 +1,58 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
export const HOUSE_RUNTIME_READS = {
|
|
2
|
+
acts: [
|
|
3
|
+
'account/push/set',
|
|
4
|
+
'apps/features/set',
|
|
5
|
+
'apps/source/download',
|
|
6
|
+
'apps/source/top/read',
|
|
7
|
+
'conversations/history/list',
|
|
8
|
+
'files/attach',
|
|
9
|
+
'files/batch',
|
|
10
|
+
'files/batch-upload',
|
|
11
|
+
'files/finish',
|
|
12
|
+
'files/read',
|
|
13
|
+
'files/revisions/list',
|
|
14
|
+
'room-chunks/list',
|
|
15
|
+
'rooms/discover',
|
|
16
|
+
'rooms/search',
|
|
17
|
+
'sites/screenshot/read',
|
|
18
|
+
],
|
|
19
|
+
frames: [
|
|
20
|
+
'agent',
|
|
21
|
+
'app-message',
|
|
22
|
+
'app-rooms',
|
|
23
|
+
'authority_changed',
|
|
24
|
+
'carried',
|
|
25
|
+
'caught_up',
|
|
26
|
+
'commands',
|
|
27
|
+
'conversation',
|
|
28
|
+
'conversation_deleted',
|
|
29
|
+
'conversations',
|
|
30
|
+
'deliveries',
|
|
31
|
+
'deployment',
|
|
32
|
+
'held',
|
|
33
|
+
'interactions',
|
|
34
|
+
'link',
|
|
35
|
+
'message',
|
|
36
|
+
'opening',
|
|
37
|
+
'options',
|
|
38
|
+
'part',
|
|
39
|
+
'process',
|
|
40
|
+
'received',
|
|
41
|
+
'report',
|
|
42
|
+
'signal',
|
|
43
|
+
'site',
|
|
44
|
+
'starting',
|
|
45
|
+
'state',
|
|
46
|
+
'tab-icon',
|
|
47
|
+
'turn',
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
export function houseDoorRoute(act) {
|
|
51
|
+
return `/door/${act}`;
|
|
52
|
+
}
|
|
53
|
+
export function houseSiteRoute(act) {
|
|
54
|
+
return `/_house/door/${act}`;
|
|
55
|
+
}
|
|
56
|
+
export const SITES_SUBMISSIONS_CREATE = 'sites/submissions/create';
|
|
57
|
+
export const SITE_DOOR_SUBMIT = '/_house/door/submit';
|
|
58
|
+
export const SITE_FILES = '/_house/files/';
|
|
@@ -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,13 @@
|
|
|
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 | {
|
|
12
|
+
readonly unfinished: number;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE3F,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"}
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { sha256 } from '@agentshouse/mdruntime/digest';
|
|
2
|
+
import { houseDoorRoute } 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
|
+
const stored = await transport.put(url, slice, checksum(digests[number - 1]));
|
|
41
|
+
if (stored !== 200)
|
|
42
|
+
return stored;
|
|
43
|
+
}
|
|
44
|
+
return 200;
|
|
45
|
+
}
|
|
46
|
+
export async function finishedUpload(transport, first, blob) {
|
|
47
|
+
const digests = await partSha256(blob, first.partBytes);
|
|
48
|
+
let upload = first;
|
|
49
|
+
for (let round = 0; round < FINISHING_ROUNDS; round += 1) {
|
|
50
|
+
const stored = await sent(transport, upload, blob, digests);
|
|
51
|
+
if (stored !== 200)
|
|
52
|
+
return { unfinished: stored };
|
|
53
|
+
const answer = await transport.door(houseDoorRoute('files/finish'), {
|
|
54
|
+
upload: upload.id,
|
|
55
|
+
part_sha256: digests,
|
|
56
|
+
});
|
|
57
|
+
if (answer.status !== 200)
|
|
58
|
+
return answer;
|
|
59
|
+
const missing = houseUpload(record(answer.body).upload);
|
|
60
|
+
if (missing === null)
|
|
61
|
+
return answer;
|
|
62
|
+
upload = missing;
|
|
63
|
+
}
|
|
64
|
+
return { unfinished: 200 };
|
|
65
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -11,4 +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
|
-
|
|
14
|
+
export declare const DECIMAL: RegExp;
|
|
15
|
+
export declare function reachedVersion(roomVersion: string, target: string, currentEpoch: string | undefined): boolean;
|
|
16
|
+
export declare function followsVersion(roomVersion: string, next: string): boolean;
|
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
|
@@ -3,27 +3,41 @@ export function roomVersion(at) {
|
|
|
3
3
|
}
|
|
4
4
|
export function logPosition(version) {
|
|
5
5
|
const split = version.lastIndexOf(':');
|
|
6
|
-
if (split < 1 || split === version.length - 1)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
position: version.slice(split + 1)
|
|
10
|
-
};
|
|
6
|
+
if (split < 1 || split === version.length - 1)
|
|
7
|
+
return null;
|
|
8
|
+
return { logEpoch: version.slice(0, split), position: version.slice(split + 1) };
|
|
11
9
|
}
|
|
12
10
|
export function readPosition(held) {
|
|
13
11
|
const { position, log_epoch: logEpoch } = held;
|
|
14
|
-
if (typeof position !== 'string' || position.length === 0)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
12
|
+
if (typeof position !== 'string' || position.length === 0)
|
|
13
|
+
return null;
|
|
14
|
+
if (typeof logEpoch !== 'string' || logEpoch.length === 0)
|
|
15
|
+
return null;
|
|
16
|
+
return { position, logEpoch };
|
|
20
17
|
}
|
|
21
18
|
export function presented(authority, at) {
|
|
22
|
-
return {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
return { authority, position: at.position, log_epoch: at.logEpoch };
|
|
20
|
+
}
|
|
21
|
+
export const DECIMAL = /^(?:0|[1-9][0-9]*)$/;
|
|
22
|
+
export function reachedVersion(roomVersion, target, currentEpoch) {
|
|
23
|
+
if (roomVersion === target)
|
|
24
|
+
return true;
|
|
25
|
+
const held = logPosition(roomVersion);
|
|
26
|
+
const wanted = logPosition(target);
|
|
27
|
+
if (held === null || wanted === null)
|
|
28
|
+
return false;
|
|
29
|
+
if (!DECIMAL.test(held.position) || !DECIMAL.test(wanted.position))
|
|
30
|
+
return false;
|
|
31
|
+
if (held.logEpoch === wanted.logEpoch)
|
|
32
|
+
return BigInt(held.position) >= BigInt(wanted.position);
|
|
33
|
+
return held.logEpoch === currentEpoch;
|
|
34
|
+
}
|
|
35
|
+
export function followsVersion(roomVersion, next) {
|
|
36
|
+
const held = logPosition(roomVersion);
|
|
37
|
+
const following = logPosition(next);
|
|
38
|
+
if (held === null || following === null || held.logEpoch !== following.logEpoch)
|
|
39
|
+
return false;
|
|
40
|
+
if (!DECIMAL.test(held.position) || !DECIMAL.test(following.position))
|
|
41
|
+
return false;
|
|
42
|
+
return BigInt(following.position) === BigInt(held.position) + 1n;
|
|
27
43
|
}
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=version.js.map
|
package/dist/write.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export declare const UPLOAD_LINE_BYTES = 37;
|
|
4
|
-
export declare const UPLOAD_BYTES_MAX: number;
|
|
1
|
+
import { type ChangeBatch, type HistoryResult, type MutationResult } from '@agentshouse/mdruntime';
|
|
2
|
+
import type { HouseBounds } from './discovery.js';
|
|
5
3
|
export type HouseOperation = Readonly<Record<string, unknown>>;
|
|
6
4
|
export type ChangeMapping = {
|
|
7
5
|
kind: 'changes';
|
|
@@ -11,19 +9,35 @@ export type ChangeMapping = {
|
|
|
11
9
|
path: string;
|
|
12
10
|
rule: string;
|
|
13
11
|
};
|
|
14
|
-
export declare function houseChanges(batch: ChangeBatch, handle: string
|
|
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;
|
|
15
18
|
export type OperationHead = {
|
|
16
19
|
readonly operation_id: string;
|
|
20
|
+
readonly room_ref: string;
|
|
17
21
|
readonly app_ref?: string;
|
|
18
22
|
readonly release?: string;
|
|
19
23
|
};
|
|
20
|
-
export declare function operationHead(batch: ChangeBatch): OperationHead;
|
|
24
|
+
export declare function operationHead(batch: ChangeBatch, room: string): OperationHead;
|
|
21
25
|
export declare function batchPaths(changes: readonly HouseOperation[]): readonly string[];
|
|
22
26
|
export declare function deltaBody(changes: readonly HouseOperation[]): string;
|
|
23
27
|
export declare function deltaBytes(delta: string): number;
|
|
24
|
-
export declare function uploadable(bytes: number): boolean;
|
|
28
|
+
export declare function uploadable(inline: Readonly<Record<string, unknown>>, bytes: number, bounds: Pick<HouseBounds, 'max_inline_body_bytes' | 'max_upload_bytes'>): boolean;
|
|
25
29
|
export declare function deltaDigest(delta: string): Promise<string>;
|
|
26
|
-
export
|
|
30
|
+
export type MoveAuthorities = {
|
|
31
|
+
readonly source: {
|
|
32
|
+
readonly authority: string;
|
|
33
|
+
readonly handle: string;
|
|
34
|
+
};
|
|
35
|
+
readonly destination: {
|
|
36
|
+
readonly authority: string;
|
|
37
|
+
readonly handle: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare function mutationOutcome(status: number, body: unknown, locator: string, handle: string, move?: MoveAuthorities): Generator<number, MutationResult, void>;
|
|
27
41
|
export declare function rejectedMapping(mapping: Extract<ChangeMapping, {
|
|
28
42
|
kind: 'unmapped';
|
|
29
43
|
}>): {
|
|
@@ -33,15 +47,14 @@ export declare function rejectedMapping(mapping: Extract<ChangeMapping, {
|
|
|
33
47
|
fields: {
|
|
34
48
|
path: string;
|
|
35
49
|
};
|
|
50
|
+
retryable: boolean;
|
|
36
51
|
};
|
|
37
52
|
export declare function revisionBody(input: {
|
|
38
53
|
path: string;
|
|
39
|
-
handle: string
|
|
54
|
+
handle: string;
|
|
40
55
|
revision?: string;
|
|
41
56
|
pageToken?: string;
|
|
42
57
|
}): Record<string, unknown>;
|
|
43
58
|
export declare function historyOutcome(status: number, body: unknown, locator: string, request: {
|
|
44
|
-
path: string;
|
|
45
59
|
revision?: string;
|
|
46
60
|
}): HistoryResult;
|
|
47
|
-
//# 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,CAA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