@agentshouse/mdruntime-adapter 0.1.0-cf6a7cf003c4b → 0.1.0-cf863e7a50d6e

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