@agentshouse/mdruntime-adapter 0.1.0-cfdb3a66f1a92 → 0.1.0-cfe552b74bdf7

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