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

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