@agentshouse/mdruntime-adapter 0.1.0-c8917c5e9ea34 → 0.1.0-c89cce0171cd2

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.
Files changed (77) hide show
  1. package/README.md +3 -3
  2. package/dist/actions.d.ts +6 -67
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +26 -342
  5. package/dist/adapter.d.ts +0 -1
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +299 -397
  8. package/dist/authored-path.d.ts +65 -0
  9. package/dist/authored-path.d.ts.map +1 -0
  10. package/dist/authored-path.js +164 -0
  11. package/dist/chunks.d.ts +36 -0
  12. package/dist/chunks.d.ts.map +1 -0
  13. package/dist/chunks.js +281 -0
  14. package/dist/digest.d.ts +0 -1
  15. package/dist/discovery.d.ts +45 -19
  16. package/dist/discovery.d.ts.map +1 -1
  17. package/dist/discovery.js +252 -67
  18. package/dist/history.d.ts +6 -0
  19. package/dist/history.d.ts.map +1 -0
  20. package/dist/history.js +85 -0
  21. package/dist/index.d.ts +10 -3
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +9 -1
  24. package/dist/map.d.ts +0 -1
  25. package/dist/model.d.ts +6 -6
  26. package/dist/model.d.ts.map +1 -1
  27. package/dist/model.js +31 -48
  28. package/dist/read.d.ts +51 -72
  29. package/dist/read.d.ts.map +1 -1
  30. package/dist/read.js +192 -329
  31. package/dist/refusal.d.ts +6 -5
  32. package/dist/refusal.d.ts.map +1 -1
  33. package/dist/refusal.js +27 -11
  34. package/dist/room-query.d.ts +4 -0
  35. package/dist/room-query.d.ts.map +1 -0
  36. package/dist/room-query.js +48 -0
  37. package/dist/search.d.ts +4 -0
  38. package/dist/search.d.ts.map +1 -0
  39. package/dist/search.js +47 -0
  40. package/dist/session-content/check.d.ts +17 -0
  41. package/dist/session-content/index.d.ts +6 -0
  42. package/dist/session-content/parts.d.ts +30 -0
  43. package/dist/session-content/state.d.ts +59 -0
  44. package/dist/session-content/turn.d.ts +137 -0
  45. package/dist/site.d.ts +0 -1
  46. package/dist/site.d.ts.map +1 -1
  47. package/dist/site.js +135 -207
  48. package/dist/space-schema.d.ts +6 -0
  49. package/dist/space-schema.d.ts.map +1 -0
  50. package/dist/space-schema.js +11 -0
  51. package/dist/stream.d.ts +15 -16
  52. package/dist/stream.d.ts.map +1 -1
  53. package/dist/stream.js +259 -423
  54. package/dist/transport.d.ts +101 -49
  55. package/dist/transport.d.ts.map +1 -1
  56. package/dist/transport.js +91 -11
  57. package/dist/uncertain.d.ts +5 -0
  58. package/dist/uncertain.d.ts.map +1 -0
  59. package/dist/uncertain.js +11 -0
  60. package/dist/upload.d.ts +13 -0
  61. package/dist/upload.d.ts.map +1 -0
  62. package/dist/upload.js +65 -0
  63. package/dist/version.d.ts +0 -1
  64. package/dist/write.d.ts +18 -4
  65. package/dist/write.d.ts.map +1 -1
  66. package/dist/write.js +123 -95
  67. package/package.json +9 -4
  68. package/AGENTS.md +0 -299
  69. package/dist/gather.d.ts +0 -4
  70. package/dist/gather.d.ts.map +0 -1
  71. package/dist/gather.js +0 -45
  72. package/dist/handed.d.ts +0 -15
  73. package/dist/handed.d.ts.map +0 -1
  74. package/dist/handed.js +0 -38
  75. package/dist/referrer.d.ts +0 -7
  76. package/dist/referrer.d.ts.map +0 -1
  77. package/dist/referrer.js +0 -35
@@ -1,41 +1,46 @@
1
- import type { ConversationEvent, TurnOperation } from '@agentshouse/mdruntime';
2
- export declare const DOOR_DISCOVER = "/door/discover";
3
- export declare const DOOR_BOOTSTRAP = "/door/bootstrap";
4
- export declare const DOOR_ENUMERATE = "/door/enumerate";
5
- export declare const DOOR_BATCH = "/door/batch";
6
- export declare const DOOR_BATCH_UPLOAD = "/door/batch-upload";
7
- export declare const DOOR_REVISIONS = "/door/revisions";
8
- export declare const SITE_DOOR_DISCOVER = "/_house/door/discover";
9
- export declare const SITE_DOOR_BOOTSTRAP = "/_house/door/bootstrap/";
10
- export declare const SITE_DOOR_ENUMERATE = "/_house/door/enumerate";
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/batch', 'files/batch-upload', 'files/finish', 'files/read', 'files/revisions/list', 'room-chunks/list', 'rooms/discover', 'rooms/query', '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', '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 declare const DOOR_FILES_GET = "/door/files/get";
18
26
  export declare const SITE_FILES = "/_house/files/";
19
- export declare const SITE_FILE_RECORD = "record";
20
- export type HouseByteAct = 'authored_batch_upload' | 'conversation_file_upload' | 'binary_stage';
21
- export type HouseByteBody = string | ArrayBuffer | Uint8Array | Blob;
27
+ export declare const SITE_IMAGE_COPIES_HEADER = "X-House-Image-Copies";
22
28
  export type HouseBytesAnswer = {
23
29
  status: number;
24
- blob: Blob | null;
30
+ body: ReadableStream<Uint8Array> | null;
31
+ mediaType: string;
32
+ copies?: string | null;
25
33
  };
26
34
  export type HouseByteTransfer = {
27
- act: HouseByteAct;
28
35
  url: string;
29
- body: HouseByteBody;
30
- operation?: string;
36
+ body: string;
31
37
  };
32
38
  export type HouseStreamEntry = {
33
39
  path: string;
34
- kind: 'edited' | 'removed' | 'piece';
40
+ kind: 'edited' | 'removed' | 'folder';
41
+ removed?: true;
35
42
  revision?: string;
36
43
  sha256?: string;
37
- text?: string;
38
- file?: string;
39
44
  bytes?: number;
40
45
  media_type?: string;
41
46
  author?: {
@@ -44,9 +49,22 @@ export type HouseStreamEntry = {
44
49
  } | {
45
50
  site: string;
46
51
  name: string;
52
+ } | {
53
+ inbox: string;
54
+ name: string;
55
+ } | {
56
+ app: string;
57
+ function: string;
58
+ release: string;
59
+ name: string;
47
60
  };
61
+ changed_at?: string;
48
62
  created_at?: string;
49
- continued?: true;
63
+ content?: string;
64
+ provenance?: string;
65
+ facts?: SavedFacts;
66
+ move?: 'arrival' | 'leaving';
67
+ space?: string;
50
68
  };
51
69
  type LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, {
52
70
  kind: K;
@@ -58,16 +76,19 @@ export type HouseListedConversation = {
58
76
  created_at: string;
59
77
  finished_at: string | null;
60
78
  outcome: string | null;
79
+ waiting: boolean;
80
+ newest: number | null;
81
+ process_ended_at: string | null;
82
+ subject: string | null;
61
83
  };
62
- export type HouseStreamFrame = {
84
+ type Listed<Frame extends {
85
+ readonly type: HouseRuntimeFrame;
86
+ }> = Frame;
87
+ export type HouseStreamFrame = Listed<{
63
88
  type: 'part';
64
89
  authority: string;
65
90
  carry: string;
66
91
  index: number;
67
- after: string;
68
- from: string;
69
- target: string;
70
- handled: number;
71
92
  entries: readonly HouseStreamEntry[];
72
93
  } | {
73
94
  type: 'carried';
@@ -79,12 +100,36 @@ export type HouseStreamFrame = {
79
100
  log_epoch: string;
80
101
  } | {
81
102
  type: 'opening';
103
+ member: unknown;
104
+ time_zone: unknown;
105
+ bounds: unknown;
106
+ actions: readonly unknown[];
107
+ shapes: readonly unknown[];
108
+ rooms: readonly unknown[];
109
+ listed: readonly unknown[];
110
+ spaces: readonly unknown[];
111
+ } | {
112
+ type: 'caught_up';
82
113
  expired: readonly string[];
83
- } | ({
114
+ } | {
115
+ type: 'authority_changed';
116
+ member: unknown;
117
+ time_zone: unknown;
118
+ authorities: readonly unknown[];
119
+ listed: readonly unknown[];
120
+ spaces: readonly unknown[];
121
+ left: readonly string[];
122
+ } | {
84
123
  type: 'turn';
85
124
  conversation_id: string;
86
125
  turn_id: string;
87
- } & TurnOperation) | {
126
+ at: string;
127
+ } | {
128
+ type: 'turn';
129
+ conversation_id: string;
130
+ turn_id: string;
131
+ operation: Operation;
132
+ } | {
88
133
  type: 'message';
89
134
  conversation_id: string;
90
135
  message: unknown;
@@ -92,6 +137,11 @@ export type HouseStreamFrame = {
92
137
  type: 'interactions';
93
138
  conversation_id: string;
94
139
  interactions: readonly unknown[];
140
+ } | {
141
+ type: 'deliveries';
142
+ conversation_id: string;
143
+ waiting: readonly string[];
144
+ unknown: readonly string[];
95
145
  } | {
96
146
  type: 'process';
97
147
  conversation_id: string;
@@ -104,48 +154,50 @@ export type HouseStreamFrame = {
104
154
  type: 'options';
105
155
  conversation_id: string;
106
156
  options: LiveFact<'options'>['options'];
157
+ } | {
158
+ type: 'starting';
159
+ conversation_id: string;
160
+ step: string | null;
161
+ } | {
162
+ type: 'state';
163
+ conversation_id: string;
164
+ state: SessionState;
107
165
  } | {
108
166
  type: 'conversations';
167
+ agents: readonly ListedAgent[];
109
168
  conversations: readonly HouseListedConversation[];
169
+ whole: boolean;
170
+ more: boolean;
171
+ cursor: string | null;
110
172
  } | {
111
173
  type: 'conversation';
112
174
  conversation: HouseListedConversation;
175
+ } | {
176
+ type: 'agent';
177
+ agent: ListedAgent;
113
178
  } | {
114
179
  type: 'conversation_deleted';
115
180
  conversation_id: string;
116
181
  } | {
117
182
  type: 'signal';
118
183
  service_mode: string;
119
- };
120
- export type HouseHeldCarry = {
121
- id: string;
122
- parts: number;
123
- from: string;
124
- target: string;
125
- handled: number;
126
- piece?: {
127
- sha256: string;
128
- offset: number;
129
- };
130
- };
184
+ } | {
185
+ type: 'report';
186
+ }>;
131
187
  export type HouseHeldRoom = {
132
188
  authority: string;
133
189
  position: string;
134
190
  log_epoch: string;
135
- carry?: HouseHeldCarry;
136
- };
137
- export type HouseDemand = {
138
- rooms: readonly string[];
139
- conversations: boolean;
140
191
  };
141
192
  export type HouseOpening = {
142
- hold(rooms: readonly HouseHeldRoom[], runtime: string, demand: HouseDemand | null): void;
193
+ hold(rooms: readonly HouseHeldRoom[], runtime: string, conversations: string | null): void;
143
194
  received(authority: string, carry: string, index: number): void;
144
- close(): void;
195
+ close(failure?: unknown): void;
145
196
  };
146
197
  export type HouseClosing = {
147
198
  revoked: boolean;
148
199
  lost: boolean;
200
+ authorityChanged: boolean;
149
201
  };
150
202
  export type HouseStream = {
151
203
  observe(receive: (frame: HouseStreamFrame) => void): () => void;
@@ -158,6 +210,7 @@ export type HouseDoor = {
158
210
  };
159
211
  export type HouseTransport = HouseDoor & {
160
212
  transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
213
+ put(url: string, body: Blob, headers: Readonly<Record<string, string>>): Promise<number>;
161
214
  download(url: string): Promise<HouseBytesAnswer>;
162
215
  };
163
216
  export type HouseSiteTransport = HouseDoor & {
@@ -166,4 +219,3 @@ export type HouseSiteTransport = HouseDoor & {
166
219
  download(route: string): Promise<HouseBytesAnswer>;
167
220
  };
168
221
  export {};
169
- //# sourceMappingURL=transport.d.ts.map
@@ -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,CAAC;AAE5D,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAE3C,eAAO,MAAM,gBAAgB,WAAW,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,uBAAuB,GAAG,0BAA0B,GAAG,cAAc,CAAC;AAEjG,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,CAAC;AAErE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CACnB,CAAC;AAEF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C,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5D,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG;IACvC,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,13 +1,93 @@
1
- export const DOOR_DISCOVER = '/door/discover';
2
- export const DOOR_BOOTSTRAP = '/door/bootstrap';
3
- export const DOOR_ENUMERATE = '/door/enumerate';
4
- export const DOOR_BATCH = '/door/batch';
5
- export const DOOR_BATCH_UPLOAD = '/door/batch-upload';
6
- export const DOOR_REVISIONS = '/door/revisions';
7
- export const SITE_DOOR_DISCOVER = '/_house/door/discover';
8
- export const SITE_DOOR_BOOTSTRAP = '/_house/door/bootstrap/';
9
- export const SITE_DOOR_ENUMERATE = '/_house/door/enumerate';
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/batch',
12
+ 'files/batch-upload',
13
+ 'files/finish',
14
+ 'files/read',
15
+ 'files/revisions/list',
16
+ 'room-chunks/list',
17
+ 'rooms/discover',
18
+ 'rooms/query',
19
+ 'rooms/search',
20
+ 'sites/screenshot/read',
21
+ ],
22
+ frames: [
23
+ 'agent',
24
+ 'app-message',
25
+ 'app-rooms',
26
+ 'authority_changed',
27
+ 'carried',
28
+ 'caught_up',
29
+ 'commands',
30
+ 'conversation',
31
+ 'conversation_deleted',
32
+ 'conversations',
33
+ 'deliveries',
34
+ 'deployment',
35
+ 'held',
36
+ 'interactions',
37
+ 'message',
38
+ 'opening',
39
+ 'options',
40
+ 'part',
41
+ 'process',
42
+ 'received',
43
+ 'report',
44
+ 'signal',
45
+ 'site',
46
+ 'starting',
47
+ 'state',
48
+ 'tab-icon',
49
+ 'turn',
50
+ ],
51
+ };
52
+ export function houseDoorRoute(act) {
53
+ return `/door/${act}`;
54
+ }
55
+ export function houseSiteRoute(act) {
56
+ return `/_house/door/${act}`;
57
+ }
58
+ export const SITE_QUERY = 'query';
59
+ export const SITE_FRESH_QUERY = 'fresh';
60
+ export const SITE_QUERY_ROUTE_CHARACTERS = 12_000;
61
+ function addressed(text) {
62
+ let binary = '';
63
+ for (const byte of new TextEncoder().encode(text))
64
+ binary += String.fromCharCode(byte);
65
+ return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/u, '');
66
+ }
67
+ export function siteQueryRoute(room, query, fresh = false) {
68
+ const canonical = queryKey(JSON.parse(JSON.stringify(query)));
69
+ const named = fresh ? SITE_FRESH_QUERY : SITE_QUERY;
70
+ return `${houseSiteRoute('query')}/${room}?${named}=${addressed(canonical)}`;
71
+ }
72
+ export function siteQueryAsked(address) {
73
+ let asked;
74
+ try {
75
+ const binary = atob(address.replaceAll('-', '+').replaceAll('_', '/'));
76
+ const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
77
+ asked = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
78
+ }
79
+ catch {
80
+ return null;
81
+ }
82
+ return plain(asked) && addressed(queryKey(asked)) === address ? asked : null;
83
+ }
84
+ export const SITES_SUBMISSIONS_CREATE = 'sites/submissions/create';
10
85
  export const SITE_DOOR_SUBMIT = '/_house/door/submit';
11
- export const DOOR_FILES_GET = '/door/files/get';
86
+ export const SITES_FUNCTIONS_CALL = 'sites/functions/call';
87
+ export const SITE_DOOR_FUNCTION = '/_house/door/function';
88
+ export const SITE_DOOR_ACTS = {
89
+ [SITES_SUBMISSIONS_CREATE]: SITE_DOOR_SUBMIT,
90
+ [SITES_FUNCTIONS_CALL]: SITE_DOOR_FUNCTION,
91
+ };
12
92
  export const SITE_FILES = '/_house/files/';
13
- export const SITE_FILE_RECORD = 'record';
93
+ 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
+ }
@@ -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
@@ -14,4 +14,3 @@ export declare function presented(authority: string, at: LogPosition): Presented
14
14
  export declare const DECIMAL: RegExp;
15
15
  export declare function reachedVersion(roomVersion: string, target: string, currentEpoch: string | undefined): boolean;
16
16
  export declare function followsVersion(roomVersion: string, next: string): boolean;
17
- //# sourceMappingURL=version.d.ts.map
package/dist/write.d.ts CHANGED
@@ -10,18 +10,34 @@ 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;
20
+ readonly room_ref: string;
15
21
  readonly app_ref?: string;
16
22
  readonly release?: string;
17
23
  };
18
- export declare function operationHead(batch: ChangeBatch): OperationHead;
24
+ export declare function operationHead(batch: ChangeBatch, room: string): OperationHead;
19
25
  export declare function batchPaths(changes: readonly HouseOperation[]): readonly string[];
20
26
  export declare function deltaBody(changes: readonly HouseOperation[]): string;
21
27
  export declare function deltaBytes(delta: string): number;
22
28
  export declare function uploadable(inline: Readonly<Record<string, unknown>>, bytes: number, bounds: Pick<HouseBounds, 'max_inline_body_bytes' | 'max_upload_bytes'>): boolean;
23
29
  export declare function deltaDigest(delta: string): Promise<string>;
24
- export declare function mutationOutcome(status: number, body: unknown, locator: string, handle: string): MutationResult;
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>;
25
41
  export declare function rejectedMapping(mapping: Extract<ChangeMapping, {
26
42
  kind: 'unmapped';
27
43
  }>): {
@@ -40,7 +56,5 @@ export declare function revisionBody(input: {
40
56
  pageToken?: string;
41
57
  }): Record<string, unknown>;
42
58
  export declare function historyOutcome(status: number, body: unknown, locator: string, request: {
43
- path: string;
44
59
  revision?: string;
45
60
  }): HistoryResult;
46
- //# sourceMappingURL=write.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAElB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAOlD,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,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