@agentshouse/mdruntime-adapter 0.1.0-cc63dd043d0e2 → 0.1.0-cc7da2d4669a3

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 (69) hide show
  1. package/README.md +4 -4
  2. package/dist/actions.d.ts +3 -4
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +10 -327
  5. package/dist/adapter.d.ts +1 -0
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +283 -246
  8. package/dist/app-reference.d.ts +2 -0
  9. package/dist/app-reference.d.ts.map +1 -0
  10. package/dist/app-reference.js +2 -0
  11. package/dist/crockford.d.ts +4 -0
  12. package/dist/crockford.d.ts.map +1 -0
  13. package/dist/crockford.js +3 -0
  14. package/dist/discovery.d.ts +18 -23
  15. package/dist/discovery.d.ts.map +1 -1
  16. package/dist/discovery.js +80 -73
  17. package/dist/history.d.ts +12 -0
  18. package/dist/history.d.ts.map +1 -0
  19. package/dist/history.js +91 -0
  20. package/dist/house-model.d.ts +2915 -0
  21. package/dist/house-model.d.ts.map +1 -0
  22. package/dist/house-model.js +1603 -0
  23. package/dist/index.d.ts +10 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +9 -1
  26. package/dist/model.d.ts +10 -18
  27. package/dist/model.d.ts.map +1 -1
  28. package/dist/model.js +39 -37
  29. package/dist/part.d.ts +14 -0
  30. package/dist/part.d.ts.map +1 -0
  31. package/dist/part.js +90 -0
  32. package/dist/read.d.ts +52 -41
  33. package/dist/read.d.ts.map +1 -1
  34. package/dist/read.js +248 -237
  35. package/dist/refusal.d.ts +4 -11
  36. package/dist/refusal.d.ts.map +1 -1
  37. package/dist/refusal.js +26 -17
  38. package/dist/room-stream.d.ts +19 -0
  39. package/dist/room-stream.d.ts.map +1 -0
  40. package/dist/room-stream.js +57 -0
  41. package/dist/room-types.d.ts +7 -0
  42. package/dist/room-types.d.ts.map +1 -0
  43. package/dist/room-types.js +126 -0
  44. package/dist/site.d.ts +1 -1
  45. package/dist/site.d.ts.map +1 -1
  46. package/dist/site.js +132 -142
  47. package/dist/stream.d.ts +16 -11
  48. package/dist/stream.d.ts.map +1 -1
  49. package/dist/stream.js +229 -143
  50. package/dist/transport.d.ts +109 -22
  51. package/dist/transport.d.ts.map +1 -1
  52. package/dist/transport.js +53 -10
  53. package/dist/upload.d.ts +12 -0
  54. package/dist/upload.d.ts.map +1 -0
  55. package/dist/upload.js +63 -0
  56. package/dist/version.d.ts +2 -0
  57. package/dist/version.d.ts.map +1 -1
  58. package/dist/version.js +10 -1
  59. package/dist/write.d.ts +18 -2
  60. package/dist/write.d.ts.map +1 -1
  61. package/dist/write.js +169 -42
  62. package/package.json +9 -6
  63. package/AGENTS.md +0 -215
  64. package/dist/gather.d.ts +0 -3
  65. package/dist/gather.d.ts.map +0 -1
  66. package/dist/gather.js +0 -40
  67. package/dist/links.d.ts +0 -12
  68. package/dist/links.d.ts.map +0 -1
  69. package/dist/links.js +0 -66
package/dist/stream.js CHANGED
@@ -1,45 +1,137 @@
1
- import { acceptedMessage } from './actions.js';
2
- import { headChange } from './read.js';
3
- import { roomVersion } from './version.js';
4
- const HELD_FRAMES_MAX = 256;
1
+ import { ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
2
+ import { acceptedMessage, cursorPosition, houseHistory } from './history.js';
3
+ import { streamedModels } from './model.js';
4
+ import { answered, answering, binaryFileOf, folded, forgotten, headChange, revised, } from './read.js';
5
+ import { houseDoorRoute, } from './transport.js';
6
+ import { DECIMAL, roomVersion } from './version.js';
5
7
  function turnOperation(frame) {
6
8
  const { type: _type, conversation_id: _conversation, turn_id: _turn, ...operation } = frame;
7
9
  return structuredClone(operation);
8
10
  }
11
+ async function houseAgents(transport) {
12
+ const answer = await transport.door(houseDoorRoute('agents/read'), {});
13
+ const agents = answer.status === 200 ? answer.body?.agents : null;
14
+ if (!Array.isArray(agents))
15
+ return null;
16
+ return agents.flatMap((one) => {
17
+ const { id, name, retired_at: retired } = (one ?? {});
18
+ return typeof id === 'string' && typeof name === 'string'
19
+ ? [{ agent: id, name, retired: retired !== null && retired !== undefined }]
20
+ : [];
21
+ });
22
+ }
23
+ function listedConversation(listed) {
24
+ return {
25
+ conversation: listed.conversation_id,
26
+ agent: listed.agent_id,
27
+ agentName: listed.agent_name,
28
+ agentRetired: listed.agent_retired,
29
+ name: listed.name,
30
+ created: listed.created_at,
31
+ finished: listed.finished_at,
32
+ outcome: listed.outcome,
33
+ waiting: listed.waiting,
34
+ newest: listed.newest === null ? null : cursorPosition(listed.newest),
35
+ };
36
+ }
9
37
  function position(value) {
10
- if (!/^(?:0|[1-9][0-9]*)$/.test(value))
38
+ if (!DECIMAL.test(value))
11
39
  return null;
12
40
  return BigInt(value);
13
41
  }
14
- export function houseNotifications(transport, mode) {
15
- const stream = transport.stream;
16
- const lines = new Map();
17
- const locators = new Map();
42
+ function* changed(tracked, entries, version, schemas) {
43
+ const answer = answering();
44
+ for (const entry of entries) {
45
+ yield ROW_WEIGHT + (entry.text?.length ?? 0);
46
+ if (entry.kind === 'folder') {
47
+ folded(answer, entry.path, entry.removed === true);
48
+ continue;
49
+ }
50
+ if (entry.path === tracked.schema)
51
+ schemas.set(entry.path, entry);
52
+ forgotten(answer, entry.path);
53
+ if (entry.kind === 'removed') {
54
+ answer.removals.add(entry.path);
55
+ continue;
56
+ }
57
+ const binary = binaryFileOf(entry);
58
+ if (binary === undefined)
59
+ answer.documents.set(entry.path, entry.text ?? '');
60
+ else if (binary !== null)
61
+ answer.binaryFiles.set(entry.path, binary);
62
+ const revision = entry.revision ?? binary?.sha256;
63
+ if (revision !== undefined)
64
+ revised(answer, entry.path, revision);
65
+ const head = headChange(entry);
66
+ if (head)
67
+ answer.changes.set(entry.path, head);
68
+ }
69
+ return { kind: 'net-advancement', roomVersion: version, ...(yield* answered(answer)) };
70
+ }
71
+ async function changePage(tracked, entries, version, mode) {
18
72
  const schemas = new Map();
73
+ const page = await stepped(changed(tracked, entries, version, schemas));
74
+ const models = await streamedModels(schemas, tracked, mode);
75
+ return models === undefined ? page : { ...page, models };
76
+ }
77
+ export function houseNotifications(transport, mode, discovering) {
78
+ const stream = transport.stream;
79
+ const staged = new Map();
80
+ let socket = null;
81
+ const tracking = new Map();
19
82
  const observers = new Set();
20
83
  const conversationObservers = new Set();
21
84
  const modeObservers = new Set();
22
85
  let replicated = [];
23
86
  const live = new Set();
24
- let listening = false;
25
- let catching = false;
26
- function listen() {
27
- if (listening)
28
- return;
29
- listening = true;
30
- stream.observe(receive);
87
+ let opening = null;
88
+ let announced = null;
89
+ const runtime = crypto.randomUUID();
90
+ function emit(event) {
91
+ for (const observer of observers)
92
+ observer(event);
31
93
  }
32
94
  function emitConversation(event) {
33
- if (event.kind !== 'gap' && event.kind !== 'accepted-message')
95
+ if (event.kind === 'turn' ||
96
+ event.kind === 'questions' ||
97
+ event.kind === 'process' ||
98
+ event.kind === 'commands' ||
99
+ event.kind === 'options' ||
100
+ event.kind === 'starting' ||
101
+ event.kind === 'link' ||
102
+ event.kind === 'deliveries') {
34
103
  live.add(event.conversation);
104
+ }
35
105
  for (const observer of conversationObservers)
36
106
  observer(event);
37
107
  }
38
- function reopened() {
108
+ function reopened(next) {
109
+ opening = next;
110
+ announced = null;
111
+ socket = next;
112
+ staged.clear();
39
113
  const gapped = new Set([...replicated, ...live]);
40
114
  live.clear();
41
115
  for (const conversation of gapped)
42
116
  emitConversation({ kind: 'gap', conversation });
117
+ emit({ kind: 'opened' });
118
+ if (mode === 'site')
119
+ announce(next, null);
120
+ }
121
+ function announce(via, frame) {
122
+ void discovering.opened(frame).then((discovery) => {
123
+ if (socket !== via)
124
+ return;
125
+ if (discovery === null) {
126
+ via.close();
127
+ return;
128
+ }
129
+ announced = { kind: 'discovered', discovery };
130
+ emit(announced);
131
+ }, () => {
132
+ if (socket === via)
133
+ via.close();
134
+ });
43
135
  }
44
136
  function converse(frame) {
45
137
  const conversation = frame.conversation_id;
@@ -72,6 +164,18 @@ export function houseNotifications(transport, mode) {
72
164
  emitConversation({ kind: 'options', conversation, options: structuredClone(frame.options) });
73
165
  return;
74
166
  }
167
+ if (frame.type === 'starting') {
168
+ emitConversation({ kind: 'starting', conversation, step: frame.step });
169
+ return;
170
+ }
171
+ if (frame.type === 'link') {
172
+ emitConversation({ kind: 'link', conversation, connected: frame.connected });
173
+ return;
174
+ }
175
+ if (frame.type === 'deliveries') {
176
+ emitConversation({ kind: 'deliveries', conversation, unknown: [...frame.unknown] });
177
+ return;
178
+ }
75
179
  if (frame.type === 'interactions') {
76
180
  emitConversation({
77
181
  kind: 'questions',
@@ -85,22 +189,32 @@ export function houseNotifications(transport, mode) {
85
189
  return;
86
190
  emitConversation({ kind: 'accepted-message', conversation, message });
87
191
  }
88
- function announce(authority, at, modelChanged) {
89
- const version = roomVersion(at);
90
- for (const locator of locators.get(authority) ?? []) {
91
- for (const observer of observers) {
92
- observer(modelChanged
93
- ? { locator, roomVersion: version, modelChanged: true }
94
- : { locator, roomVersion: version });
192
+ function stage(frame, via) {
193
+ const held = staged.get(frame.carry);
194
+ if (frame.index !== (held?.parts ?? 0)) {
195
+ staged.delete(frame.carry);
196
+ return;
197
+ }
198
+ if (held === undefined) {
199
+ for (const [carry, other] of staged) {
200
+ if (other.authority === frame.authority)
201
+ staged.delete(carry);
95
202
  }
96
203
  }
204
+ const next = held ?? { authority: frame.authority, parts: 0, entries: [] };
205
+ next.entries.push(...frame.entries);
206
+ next.parts += 1;
207
+ staged.set(frame.carry, next);
208
+ via?.received(frame.authority, frame.carry, frame.index);
97
209
  }
98
- function interrupt(authority) {
99
- const line = lines.get(authority);
100
- if (line !== undefined)
101
- lines.set(authority, { ...line, frames: [] });
210
+ function carried(frame) {
211
+ const held = staged.get(frame.carry);
212
+ staged.delete(frame.carry);
213
+ if ((held?.parts ?? 0) !== frame.parts)
214
+ return;
215
+ publish(frame, held?.entries ?? []);
102
216
  }
103
- function receive(frame) {
217
+ function handle(frame, via) {
104
218
  if (frame.type === 'signal') {
105
219
  const mode = frame.service_mode;
106
220
  if (mode !== 'open' && mode !== 'write-halted')
@@ -109,45 +223,84 @@ export function houseNotifications(transport, mode) {
109
223
  observer(mode);
110
224
  return;
111
225
  }
226
+ if (frame.type === 'opening') {
227
+ if (via !== null && mode === 'credential')
228
+ announce(via, frame);
229
+ return;
230
+ }
231
+ if (frame.type === 'caught_up') {
232
+ emit({
233
+ kind: 'caught-up',
234
+ expired: frame.expired.flatMap((authority) => (tracking.get(authority) ?? []).map((tracked) => tracked.locator)),
235
+ });
236
+ return;
237
+ }
238
+ if (frame.type === 'authority_changed') {
239
+ const change = discovering.changed(frame);
240
+ if (change !== null)
241
+ emit(change);
242
+ return;
243
+ }
244
+ if (frame.type === 'conversations') {
245
+ emitConversation({ kind: 'list', entries: frame.conversations.map(listedConversation) });
246
+ return;
247
+ }
248
+ if (frame.type === 'conversation') {
249
+ emitConversation({ kind: 'listed', entry: listedConversation(frame.conversation) });
250
+ return;
251
+ }
252
+ if (frame.type === 'conversation_deleted') {
253
+ emitConversation({ kind: 'unlisted', conversation: frame.conversation_id });
254
+ return;
255
+ }
112
256
  if (frame.type === 'turn' ||
113
257
  frame.type === 'process' ||
114
258
  frame.type === 'commands' ||
115
259
  frame.type === 'options' ||
260
+ frame.type === 'starting' ||
261
+ frame.type === 'link' ||
262
+ frame.type === 'deliveries' ||
116
263
  frame.type === 'interactions' ||
117
264
  frame.type === 'message') {
118
265
  converse(frame);
119
266
  return;
120
267
  }
121
- if (frame.type !== 'entries')
122
- return;
268
+ if (frame.type === 'part')
269
+ stage(frame, via);
270
+ else if (frame.type === 'carried')
271
+ carried(frame);
272
+ }
273
+ function publish(frame, entries) {
123
274
  const at = position(frame.position);
124
275
  const after = position(frame.after);
125
- if (at === null || after === null || after >= at) {
126
- interrupt(frame.authority);
276
+ if (at === null || after === null || after >= at)
127
277
  return;
278
+ const from = roomVersion({ position: frame.after, logEpoch: frame.log_epoch });
279
+ const version = roomVersion({ position: frame.position, logEpoch: frame.log_epoch });
280
+ for (const tracked of tracking.get(frame.authority) ?? []) {
281
+ emit({
282
+ kind: 'room-change',
283
+ locator: tracked.locator,
284
+ from,
285
+ roomVersion: version,
286
+ read: () => changePage(tracked, entries, version, mode),
287
+ });
128
288
  }
129
- const line = lines.get(frame.authority);
130
- if (line?.logEpoch === frame.log_epoch) {
131
- if (line.held !== null && at <= line.held)
132
- return;
133
- const last = line.frames.at(-1);
134
- if (last !== undefined && at <= last.position)
135
- return;
136
- const held = { after, position: at, entries: frame.entries };
137
- const next = last !== undefined && after <= last.position ? [...line.frames, held] : [held];
138
- lines.set(frame.authority, { ...line, frames: next.length > HELD_FRAMES_MAX ? [] : next });
139
- }
140
- else {
141
- interrupt(frame.authority);
142
- }
143
- const addresses = schemas.get(frame.authority) ?? [];
144
- announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch }, frame.entries.some((entry) => addresses.includes(entry.path)));
145
289
  }
290
+ stream.observe((frame) => handle(frame, socket));
291
+ stream.opened(reopened);
292
+ stream.closed(({ revoked, lost }) => {
293
+ opening = null;
294
+ announced = null;
295
+ socket = null;
296
+ staged.clear();
297
+ emit({ kind: 'closed', revoked, lost });
298
+ });
146
299
  return {
300
+ runtime,
147
301
  serviceMode: {
148
302
  observe(notify) {
149
303
  modeObservers.add(notify);
150
- listen();
151
304
  return () => {
152
305
  modeObservers.delete(notify);
153
306
  };
@@ -159,112 +312,45 @@ export function houseNotifications(transport, mode) {
159
312
  },
160
313
  observe(notify) {
161
314
  conversationObservers.add(notify);
162
- listen();
163
- if (!catching) {
164
- catching = true;
165
- stream.opened(reopened);
166
- }
167
315
  return () => {
168
316
  conversationObservers.delete(notify);
169
317
  };
170
318
  },
171
- },
172
- track(entries) {
173
- locators.clear();
174
- schemas.clear();
175
- for (const entry of entries) {
176
- locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);
177
- schemas.set(entry.authority, entry.schemas);
178
- if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {
179
- lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [], held: null });
319
+ ...(mode === 'credential'
320
+ ? {
321
+ agents: () => houseAgents(transport),
322
+ history: (request) => houseHistory(transport, request),
180
323
  }
181
- }
182
- for (const authority of lines.keys()) {
183
- if (!locators.has(authority))
184
- lines.delete(authority);
185
- }
324
+ : {}),
186
325
  },
187
- select() { },
188
326
  observe(notify) {
189
327
  observers.add(notify);
190
- listen();
328
+ const replayed = opening === null ? [] : [{ kind: 'opened' }, announced];
329
+ if (replayed.length > 0) {
330
+ queueMicrotask(() => {
331
+ for (const event of replayed)
332
+ if (event !== null && observers.has(notify))
333
+ notify(event);
334
+ });
335
+ }
191
336
  return () => {
192
337
  observers.delete(notify);
193
338
  };
194
339
  },
195
- hold(authority, at) {
196
- const line = lines.get(authority);
197
- const held = position(at.position);
198
- if (line === undefined || held === null || line.logEpoch !== at.logEpoch)
199
- return;
200
- lines.set(authority, { ...line, held });
340
+ send(rooms) {
341
+ opening = null;
342
+ announced = null;
343
+ socket?.hold(rooms, runtime);
201
344
  },
202
- advance(tracked, from, holds) {
203
- const line = lines.get(tracked.authority);
204
- const start = position(from.position);
205
- if (line === undefined || start === null || line.logEpoch !== from.logEpoch)
206
- return null;
207
- const pending = line.frames.filter((frame) => frame.position > start);
208
- const first = pending[0];
209
- if (first === undefined || first.after > start)
210
- return null;
211
- const documents = {};
212
- const revisions = {};
213
- const changes = {};
214
- const removals = [];
215
- const applied = [];
216
- const forget = (path) => {
217
- delete documents[path];
218
- delete revisions[path];
219
- delete changes[path];
220
- const removed = removals.indexOf(path);
221
- if (removed !== -1)
222
- removals.splice(removed, 1);
223
- };
224
- for (const frame of pending) {
225
- for (const entry of frame.entries) {
226
- if (entry.kind === 'edited' &&
227
- entry.text === undefined &&
228
- entry.revision !== undefined &&
229
- holds?.(entry.path, entry.revision) === true) {
230
- forget(entry.path);
231
- continue;
232
- }
233
- applied.push(entry);
234
- if (entry.kind === 'removed') {
235
- forget(entry.path);
236
- removals.push(entry.path);
237
- continue;
238
- }
239
- if (entry.text === undefined)
240
- return null;
241
- if (mode === 'credential' && entry.revision === undefined)
242
- return null;
243
- const head = headChange(entry);
244
- if (head === null)
245
- return null;
246
- forget(entry.path);
247
- documents[entry.path] = entry.text;
248
- if (entry.revision !== undefined)
249
- revisions[entry.path] = entry.revision;
250
- if (head !== undefined)
251
- changes[entry.path] = head;
252
- }
345
+ track(entries) {
346
+ tracking.clear();
347
+ for (const entry of entries) {
348
+ tracking.set(entry.authority, [...(tracking.get(entry.authority) ?? []), entry]);
349
+ }
350
+ for (const [carry, held] of staged) {
351
+ if (!tracking.has(held.authority))
352
+ staged.delete(carry);
253
353
  }
254
- const last = pending.at(-1);
255
- lines.set(tracked.authority, { ...line, frames: pending, held: last.position });
256
- return {
257
- page: {
258
- kind: 'net-advancement',
259
- roomVersion: roomVersion({ position: last.position.toString(), logEpoch: line.logEpoch }),
260
- documents,
261
- revisions,
262
- changes,
263
- binaryTargets: [],
264
- removals: removals.sort(),
265
- },
266
- entries: applied,
267
- };
268
354
  },
269
355
  };
270
356
  }
@@ -1,36 +1,40 @@
1
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";
2
+ export declare const HOUSE_RUNTIME_READS: {
3
+ readonly acts: readonly ['account/push', 'agents/read', 'apps/features/set', 'apps/source/download', 'apps/source/top', 'batch', 'batch-upload', 'bootstrap', 'conversations/history', 'discover', 'files/attach', 'files/finish', 'files/get', 'revisions', 'sites/screenshot/read'];
4
+ readonly frames: readonly ['app-message', 'authority_changed', 'carried', 'caught_up', 'commands', 'conversation', 'conversation_deleted', 'conversations', 'deliveries', 'deployment', 'held', 'interactions', 'link', 'message', 'opening', 'options', 'part', 'process', 'received', 'signal', 'site', 'starting', 'tab-icon', 'turn'];
5
+ };
6
+ export type HouseRuntimeAct = (typeof HOUSE_RUNTIME_READS.acts)[number];
7
+ export type HouseRuntimeFrame = (typeof HOUSE_RUNTIME_READS.frames)[number];
8
+ export declare function houseDoorRoute(act: HouseRuntimeAct): string;
9
+ export declare function houseSiteRoute(act: Extract<HouseRuntimeAct, 'bootstrap' | 'discover'>): string;
10
+ export declare const SITE_SUBMISSION = "site/submission";
11
11
  export declare const SITE_DOOR_SUBMIT = "/_house/door/submit";
12
- export declare const PRIVATE_LOCATOR = "private";
13
12
  export type HouseMode = 'credential' | 'site';
14
13
  export type HouseDoorAnswer = {
15
14
  status: number;
16
15
  body: unknown;
17
16
  };
18
- export type HouseByteAct = 'local_copy_bundle' | 'authored_batch_upload' | 'conversation_original_upload' | 'original_upload' | 'original_download';
19
- export type HouseByteBody = string | ArrayBuffer | Uint8Array;
20
- export type HouseByteAnswer = 'json' | 'bytes';
17
+ export declare const SITE_FILES = "/_house/files/";
18
+ export type HouseByteAct = 'authored_batch_upload';
19
+ export type HouseBytesAnswer = {
20
+ status: number;
21
+ body: ReadableStream<Uint8Array> | null;
22
+ mediaType: string;
23
+ };
21
24
  export type HouseByteTransfer = {
22
25
  act: HouseByteAct;
23
- method: 'GET' | 'POST';
24
26
  url: string;
25
- answer: HouseByteAnswer;
26
- body?: HouseByteBody;
27
- operation?: string;
27
+ body: string;
28
28
  };
29
29
  export type HouseStreamEntry = {
30
30
  path: string;
31
- kind: 'edited' | 'removed';
31
+ kind: 'edited' | 'removed' | 'folder';
32
+ removed?: true;
32
33
  revision?: string;
34
+ sha256?: string;
33
35
  text?: string;
36
+ bytes?: number;
37
+ media_type?: string;
34
38
  author?: {
35
39
  user: string;
36
40
  name: string;
@@ -43,13 +47,52 @@ export type HouseStreamEntry = {
43
47
  type LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, {
44
48
  kind: K;
45
49
  }>;
46
- export type HouseStreamFrame = {
47
- type: 'entries';
50
+ export type HouseListedConversation = {
51
+ conversation_id: string;
52
+ agent_id: string;
53
+ agent_name: string;
54
+ agent_retired: boolean;
55
+ name: string;
56
+ created_at: string;
57
+ finished_at: string | null;
58
+ outcome: string | null;
59
+ waiting: boolean;
60
+ newest: {
61
+ accepted_at: string;
62
+ message_id: string;
63
+ } | null;
64
+ };
65
+ type Listed<Frame extends {
66
+ readonly type: HouseRuntimeFrame;
67
+ }> = Frame;
68
+ export type HouseStreamFrame = Listed<{
69
+ type: 'part';
70
+ authority: string;
71
+ carry: string;
72
+ index: number;
73
+ entries: readonly HouseStreamEntry[];
74
+ } | {
75
+ type: 'carried';
48
76
  authority: string;
77
+ carry: string;
78
+ parts: number;
49
79
  after: string;
50
80
  position: string;
51
81
  log_epoch: string;
52
- entries: readonly HouseStreamEntry[];
82
+ } | {
83
+ type: 'opening';
84
+ member: unknown;
85
+ bounds: unknown;
86
+ actions: readonly unknown[];
87
+ authorities: readonly unknown[];
88
+ } | {
89
+ type: 'caught_up';
90
+ expired: readonly string[];
91
+ } | {
92
+ type: 'authority_changed';
93
+ member: unknown;
94
+ authorities: readonly unknown[];
95
+ left: readonly string[];
53
96
  } | ({
54
97
  type: 'turn';
55
98
  conversation_id: string;
@@ -62,6 +105,10 @@ export type HouseStreamFrame = {
62
105
  type: 'interactions';
63
106
  conversation_id: string;
64
107
  interactions: readonly unknown[];
108
+ } | {
109
+ type: 'deliveries';
110
+ conversation_id: string;
111
+ unknown: readonly string[];
65
112
  } | {
66
113
  type: 'process';
67
114
  conversation_id: string;
@@ -74,24 +121,64 @@ export type HouseStreamFrame = {
74
121
  type: 'options';
75
122
  conversation_id: string;
76
123
  options: LiveFact<'options'>['options'];
124
+ } | {
125
+ type: 'starting';
126
+ conversation_id: string;
127
+ step: string | null;
128
+ } | {
129
+ type: 'link';
130
+ conversation_id: string;
131
+ connected: boolean;
132
+ } | {
133
+ type: 'conversations';
134
+ conversations: readonly HouseListedConversation[];
135
+ } | {
136
+ type: 'conversation';
137
+ conversation: HouseListedConversation;
138
+ } | {
139
+ type: 'conversation_deleted';
140
+ conversation_id: string;
77
141
  } | {
78
142
  type: 'signal';
79
143
  service_mode: string;
144
+ }>;
145
+ export type HouseHeldRoom = {
146
+ authority: string;
147
+ position: string;
148
+ log_epoch: string;
149
+ };
150
+ export type HouseOpening = {
151
+ hold(rooms: readonly HouseHeldRoom[], runtime: string): void;
152
+ received(authority: string, carry: string, index: number): void;
153
+ close(): void;
154
+ };
155
+ export type HouseClosing = {
156
+ revoked: boolean;
157
+ lost: boolean;
80
158
  };
81
159
  export type HouseStream = {
82
160
  observe(receive: (frame: HouseStreamFrame) => void): () => void;
83
- opened(notify: () => void): () => void;
161
+ opened(notify: (opening: HouseOpening) => void): () => void;
162
+ closed(notify: (closing: HouseClosing) => void): () => void;
163
+ };
164
+ export type HouseStreamed = HouseDoorAnswer & {
165
+ room: ReadableStream<Uint8Array> | null;
84
166
  };
85
167
  export type HouseDoor = {
86
168
  door(route: string, body: unknown): Promise<HouseDoorAnswer>;
87
169
  stream: HouseStream;
88
170
  };
89
171
  export type HouseTransport = HouseDoor & {
172
+ streamed(route: string, body: unknown, signal: AbortSignal): Promise<HouseStreamed>;
90
173
  transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
174
+ put(url: string, body: Blob, headers: Readonly<Record<string, string>>): Promise<number>;
175
+ download(url: string): Promise<HouseBytesAnswer>;
91
176
  };
92
177
  export type HouseSiteTransport = HouseDoor & {
93
178
  online(): boolean;
94
179
  read(route: string): Promise<HouseDoorAnswer>;
180
+ streamed(route: string, signal: AbortSignal): Promise<HouseStreamed>;
181
+ download(route: string): Promise<HouseBytesAnswer>;
95
182
  };
96
183
  export {};
97
184
  //# sourceMappingURL=transport.d.ts.map