@agentshouse/mdruntime-families 0.1.0-c686d19f36a21 → 0.1.0-c68eb1cf8f9c2

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 (40) hide show
  1. package/dist/mdruntime/adapter.d.ts +103 -71
  2. package/dist/mdruntime/chain.d.ts +2 -1
  3. package/dist/mdruntime/change.d.ts +1 -0
  4. package/dist/mdruntime/client.d.ts +18 -9
  5. package/dist/mdruntime/collection.d.ts +7 -4
  6. package/dist/mdruntime/compile.d.ts +6 -6
  7. package/dist/mdruntime/connection.d.ts +20 -11
  8. package/dist/mdruntime/conversation-row.d.ts +32 -0
  9. package/dist/mdruntime/conversation.d.ts +27 -18
  10. package/dist/mdruntime/durability.d.ts +6 -1
  11. package/dist/mdruntime/figures.d.ts +47 -0
  12. package/dist/mdruntime/identity.d.ts +0 -1
  13. package/dist/mdruntime/job.d.ts +32 -0
  14. package/dist/mdruntime/media.d.ts +7 -0
  15. package/dist/mdruntime/messages.d.ts +27 -3
  16. package/dist/mdruntime/model.d.ts +8 -10
  17. package/dist/mdruntime/observation.d.ts +3 -2
  18. package/dist/mdruntime/outcome.d.ts +14 -5
  19. package/dist/mdruntime/overlay.d.ts +1 -0
  20. package/dist/mdruntime/query.d.ts +18 -207
  21. package/dist/mdruntime/reach.d.ts +18 -11
  22. package/dist/mdruntime/readiness.d.ts +3 -17
  23. package/dist/mdruntime/reads.d.ts +34 -0
  24. package/dist/mdruntime/recovery.d.ts +1 -0
  25. package/dist/mdruntime/replica.d.ts +10 -9
  26. package/dist/mdruntime/room-draft.d.ts +21 -5
  27. package/dist/mdruntime/save.d.ts +2 -0
  28. package/dist/mdruntime/search.d.ts +12 -63
  29. package/dist/mdruntime/source.d.ts +60 -0
  30. package/dist/mdruntime/status.d.ts +4 -5
  31. package/dist/mdruntime/store.d.ts +104 -62
  32. package/dist/mdruntime/stored.d.ts +66 -55
  33. package/dist/mdruntime/tables.d.ts +118 -65
  34. package/dist/mdruntime/tallies.d.ts +17 -0
  35. package/dist/mdruntime/wire.d.ts +23 -8
  36. package/package.json +7 -2
  37. package/dist/mdruntime/file.d.ts +0 -11
  38. package/dist/mdruntime/fulltext.d.ts +0 -26
  39. package/dist/mdruntime/shared.d.ts +0 -15
  40. package/dist/mdruntime/transfer.d.ts +0 -9
@@ -1,4 +1,6 @@
1
+ import type { SavedFacts, TypedPath } from '@agentshouse/mdmodel';
1
2
  import type { ModelResult } from './model.js';
3
+ export type { SavedFacts, TypedPath };
2
4
  import type { Open } from './open.js';
3
5
  import type { ChangeBatch } from './change.js';
4
6
  export type Authorization = object;
@@ -11,7 +13,7 @@ export type TypedSelection = {
11
13
  };
12
14
  export type OperationScopes = {
13
15
  write: readonly string[];
14
- delete: readonly string[];
16
+ erase: readonly string[];
15
17
  };
16
18
  export type ReplicaAdmission = {
17
19
  selection: string;
@@ -32,25 +34,21 @@ export type Capability = {
32
34
  name: string;
33
35
  limits?: readonly ProviderLimit[];
34
36
  actions?: readonly ActionDeclaration[];
35
- conversationAgents?: ConversationAgents;
36
- };
37
- export type ConversationAgents = {
38
- locator: string;
39
- type: string;
40
- identity: string;
41
- name: string;
42
- retired?: string;
43
37
  };
44
38
  export type ListedConversation = {
45
39
  conversation: string;
46
40
  agent: string;
41
+ agentName: string;
42
+ agentRetired: boolean;
47
43
  name: string;
48
44
  created: string;
49
45
  finished: string | null;
50
46
  outcome: string | null;
51
47
  waiting: boolean;
48
+ newest: string | null;
49
+ processEnded: string | null;
52
50
  };
53
- export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.attach' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
51
+ export type ConversationAction = 'conversations/create' | 'conversations/send' | 'conversations/interaction/answer' | 'conversations/interrupt' | 'conversations/kill' | 'conversations/delete';
54
52
  export type ConversationMessage = {
55
53
  identity: string;
56
54
  turn: string;
@@ -141,6 +139,10 @@ export type SessionOption = (SessionOptionNaming & {
141
139
  type: 'boolean';
142
140
  currentValue: boolean;
143
141
  });
142
+ export type RunningSubagent = {
143
+ description: string;
144
+ activity: string | null;
145
+ };
144
146
  export type ConversationEvent = {
145
147
  kind: 'turn';
146
148
  conversation: string;
@@ -166,6 +168,10 @@ export type ConversationEvent = {
166
168
  kind: 'starting';
167
169
  conversation: string;
168
170
  step: string | null;
171
+ } | {
172
+ kind: 'subagents';
173
+ conversation: string;
174
+ subagents: readonly RunningSubagent[];
169
175
  } | {
170
176
  kind: 'link';
171
177
  conversation: string;
@@ -184,6 +190,9 @@ export type ConversationEvent = {
184
190
  } | {
185
191
  kind: 'list';
186
192
  entries: readonly ListedConversation[];
193
+ whole: boolean;
194
+ more: boolean;
195
+ cursor: string | null;
187
196
  } | {
188
197
  kind: 'listed';
189
198
  entry: ListedConversation;
@@ -191,9 +200,17 @@ export type ConversationEvent = {
191
200
  kind: 'unlisted';
192
201
  conversation: string;
193
202
  };
203
+ export type ListedAgent = {
204
+ agent: string;
205
+ name: string;
206
+ retired: boolean;
207
+ };
194
208
  export type ConversationStream = {
195
209
  replicate(conversations: readonly string[]): void;
210
+ hold(cursor: string | null): void;
196
211
  observe(notify: (event: ConversationEvent) => void): () => void;
212
+ agents?(): Promise<readonly ListedAgent[] | null>;
213
+ history?(request: ConversationHistoryRequest): Promise<ActionResult>;
197
214
  };
198
215
  export type ActionDeclaration = {
199
216
  name: string;
@@ -213,7 +230,6 @@ export type HistoryRetention = {
213
230
  };
214
231
  export type Retention = {
215
232
  history: HistoryRetention;
216
- outcome: number;
217
233
  refreshHorizon: number;
218
234
  };
219
235
  export type Discovery = {
@@ -223,10 +239,6 @@ export type Discovery = {
223
239
  providerLimits: readonly ProviderLimit[];
224
240
  retention: Retention;
225
241
  member?: Member;
226
- covered?: readonly string[];
227
- };
228
- export type DiscoveryScope = {
229
- readonly authorities: readonly string[];
230
242
  };
231
243
  export type TransportUncertainty = {
232
244
  kind: 'transport-uncertainty';
@@ -255,7 +267,7 @@ export type ContractUnavailable = ProviderRefusal & {
255
267
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
256
268
  export type PageToken = string;
257
269
  export type ChangeAuthor = {
258
- kind: Open<'user' | 'site' | 'inbox'>;
270
+ kind: Open<'user' | 'site' | 'inbox' | 'app'>;
259
271
  id: string;
260
272
  name: string;
261
273
  };
@@ -273,50 +285,45 @@ export type BinaryFile = {
273
285
  mediaType: string;
274
286
  sha256: string;
275
287
  };
276
- export type HeldFile = {
277
- readonly path: string;
278
- readonly revision: string;
279
- };
280
- export type HeldContent = {
281
- files(after: string | null, limit: number): Promise<readonly HeldFile[]>;
282
- contents(paths: readonly string[]): Promise<ReadonlyMap<string, {
283
- readonly content: string;
284
- readonly revision: string;
285
- }>>;
286
- };
287
288
  export type BootstrapRequest = {
288
289
  locator: string;
289
290
  selection: string;
290
291
  pageToken?: PageToken;
291
- held?: HeldContent;
292
- received?: Uint8Array;
293
292
  arriving?: (bytes: number) => void;
293
+ signal?: AbortSignal;
294
+ };
295
+ export type BootstrapPart = {
296
+ readonly id: string;
297
+ readonly bytes: number;
294
298
  };
295
299
  export type BootstrapInventory = {
296
- readonly parts: number;
297
300
  readonly bytes: number;
298
301
  };
299
302
  export type RoomModels = {
300
303
  collection?: ModelResult;
301
- selection?: ModelResult;
302
304
  };
303
305
  export type BootstrapPage = {
304
306
  kind: 'bootstrap';
305
307
  roomVersion: string;
306
308
  models?: RoomModels;
307
309
  documents: Readonly<Record<string, string>>;
310
+ facts: Readonly<Record<string, SavedFacts>>;
308
311
  revisions: Readonly<Record<string, string>>;
309
312
  fileIds?: Readonly<Record<string, string>>;
313
+ created?: Readonly<Record<string, string>>;
310
314
  changes: Readonly<Record<string, HeadChange>>;
311
315
  binaryFiles: Readonly<Record<string, BinaryFile>>;
312
316
  folders?: readonly string[];
313
317
  pageToken?: PageToken;
314
- inventory?: BootstrapInventory;
315
- received?: Uint8Array;
318
+ parts?: readonly BootstrapPart[];
319
+ bytes?: number;
320
+ };
321
+ export type NotReady = {
322
+ kind: 'not-ready';
316
323
  };
317
324
  export type BootstrapResult = BootstrapPage | {
318
325
  kind: 'beyond-horizon';
319
- } | AdapterFailure;
326
+ } | NotReady | AdapterFailure;
320
327
  export type RefreshRequest = {
321
328
  locator: string;
322
329
  selection: string;
@@ -328,8 +335,10 @@ export type RefreshPage = {
328
335
  roomVersion: string;
329
336
  models?: RoomModels;
330
337
  documents: Readonly<Record<string, string>>;
338
+ facts: Readonly<Record<string, SavedFacts>>;
331
339
  revisions: Readonly<Record<string, string>>;
332
340
  fileIds?: Readonly<Record<string, string>>;
341
+ created?: Readonly<Record<string, string>>;
333
342
  changes: Readonly<Record<string, HeadChange>>;
334
343
  binaryFiles: Readonly<Record<string, BinaryFile>>;
335
344
  removals: readonly string[];
@@ -379,15 +388,9 @@ export type MutationResult = (AcceptedRoom & {
379
388
  affected: Readonly<Record<string, string>>;
380
389
  }) | RetryableRefusal | {
381
390
  kind: 'write-halted';
382
- } | {
383
- kind: 'expired';
384
- restored?: true;
385
391
  } | AdapterFailure;
386
392
  export type HistoryAuthor = {
387
- kind: 'user';
388
- id: string;
389
- } | {
390
- kind: 'site' | 'inbox';
393
+ kind: 'user' | 'site' | 'inbox' | 'app';
391
394
  id: string;
392
395
  name: string;
393
396
  };
@@ -432,6 +435,22 @@ export type BinaryLinkResult = {
432
435
  kind: 'link';
433
436
  url: string;
434
437
  name: string;
438
+ mediaType?: string;
439
+ } | (ProviderRefusal & {
440
+ kind: 'rejected';
441
+ }) | AdapterFailure;
442
+ export type AttachRequest = {
443
+ locator: string;
444
+ name: string;
445
+ mediaType: string;
446
+ byteLength: number;
447
+ sha256: string;
448
+ blob: Blob;
449
+ };
450
+ export type AttachResult = {
451
+ kind: 'attached';
452
+ path: string;
453
+ revision: string;
435
454
  } | (ProviderRefusal & {
436
455
  kind: 'rejected';
437
456
  }) | AdapterFailure;
@@ -450,64 +469,77 @@ export type ActionResult = {
450
469
  } | (ProviderRefusal & {
451
470
  kind: 'rejected';
452
471
  }) | AdapterFailure;
472
+ export type SearchHit = {
473
+ room: string;
474
+ path: string;
475
+ line?: number;
476
+ snippet?: string;
477
+ };
478
+ export type SearchAsk = {
479
+ text: string;
480
+ rooms: readonly string[] | null;
481
+ };
482
+ export type SearchAnswer = {
483
+ kind: 'found';
484
+ documents: readonly SearchHit[];
485
+ } | (ProviderRefusal & {
486
+ kind: 'rejected';
487
+ }) | AdapterFailure;
453
488
  export type HeldRoom = {
454
489
  locator: string;
490
+ roomVersion: string | null;
491
+ };
492
+ export type RoomChange = {
493
+ kind: 'room-change';
494
+ locator: string;
495
+ from: string | null;
455
496
  roomVersion: string;
497
+ read(): Promise<RefreshPage>;
498
+ };
499
+ export type AuthorityChange = {
500
+ kind: 'authority-changed';
501
+ rooms: readonly DiscoveredRoom[];
502
+ left: readonly string[];
503
+ member?: Member;
456
504
  };
457
- export type HeldRevisions = (locator: string, paths: readonly string[]) => Promise<ReadonlyMap<string, string>>;
458
505
  export type RoomStreamEvent = {
459
506
  kind: 'opened';
507
+ } | {
508
+ kind: 'discovered';
509
+ discovery: Discovery;
460
510
  } | {
461
511
  kind: 'closed';
462
512
  revoked: boolean;
463
513
  lost: boolean;
514
+ authorityChanged: boolean;
464
515
  } | {
465
- kind: 'opening';
516
+ kind: 'caught-up';
466
517
  expired: readonly string[];
467
- } | {
468
- kind: 'authority-changed';
469
- scope?: DiscoveryScope;
470
- } | {
471
- kind: 'room-version';
472
- locator: string;
473
- roomVersion: string;
474
- };
475
- export type KeptReceipt = {
476
- key: string;
477
- head: unknown;
478
- };
479
- export type StreamReceipts = {
480
- heads(): Promise<readonly KeptReceipt[]>;
481
- parts(key: string, count: number): Promise<readonly unknown[]>;
482
- keep(key: string, head: unknown, part?: {
483
- index: number;
484
- value: unknown;
485
- }): Promise<void>;
486
- drop(keys: readonly string[]): Promise<void>;
487
- };
518
+ } | AuthorityChange | RoomChange;
488
519
  export type RoomStream = {
489
520
  hold(rooms: readonly HeldRoom[]): void;
490
- reopen(): void;
491
- published(locator: string, roomVersion: string): void;
492
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts, revisions: HeldRevisions): () => void;
521
+ observe(notify: (event: RoomStreamEvent) => void): () => void;
493
522
  };
494
523
  export type Adapter = {
495
524
  readonly localSaves?: true;
496
- readonly exhaustiveDiscovery?: true;
497
525
  readonly roomTypes?: string;
526
+ readonly nameableRoomTypes?: readonly string[];
527
+ readonly typedPaths?: readonly TypedPath[];
528
+ readonly unkeptReads?: readonly string[];
498
529
  authorize(): Promise<Authorization>;
499
- discover(authorization: Authorization, scope?: DiscoveryScope): Promise<DiscoverResult>;
530
+ discover?(authorization: Authorization): Promise<DiscoverResult>;
500
531
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
501
- refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
532
+ refresh?(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
502
533
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
503
534
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
504
535
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
505
536
  link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
537
+ attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
506
538
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
539
+ search?(authorization: Authorization, request: SearchAsk): Promise<SearchAnswer>;
507
540
  reached(locator: string, roomVersion: string, target: string): boolean;
508
541
  follows(locator: string, roomVersion: string, next: string): boolean;
509
542
  roomStream?: RoomStream;
510
543
  conversations?: ConversationStream;
511
544
  serviceMode?: ServiceModeSignal;
512
545
  };
513
- export {};
@@ -1,5 +1,6 @@
1
+ import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
1
2
  import type { MdRuntimeClient } from './client.js';
2
- import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
3
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
3
4
  type Rows = DocumentResult | GroupResult;
4
5
  export type WindowAnswer = Rows | PendingResult;
5
6
  export type WindowChain = {
@@ -50,6 +50,7 @@ type Arriving = {
50
50
  readonly path: string;
51
51
  readonly revision?: string;
52
52
  readonly fileId?: string;
53
+ readonly created?: string;
53
54
  readonly change?: HeadChange;
54
55
  };
55
56
  export type RoomMove = {
@@ -1,13 +1,16 @@
1
+ import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
1
2
  import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
2
3
  import type { Member, ServiceMode } from './adapter.js';
3
- import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
4
+ import type { UnsentWork } from './durability.js';
5
+ import type { ChatDraft, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationView } from './conversation.js';
4
6
  import { type Observation } from './observation.js';
5
- import type { ChosenFile } from './file.js';
6
- import type { BinaryAnswer, BinaryLinkAnswer, CallResult, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
7
- import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
7
+ import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
8
+ import type { FiguresResult } from './figures.js';
9
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
8
10
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
9
11
  import type { SearchRequest, SearchResult } from './search.js';
10
12
  import type { Readiness } from './readiness.js';
13
+ import type { ObservedRead } from './reads.js';
11
14
  import type { SyncStatus } from './status.js';
12
15
  import { type RuntimePort } from './wire.js';
13
16
  export type MdRuntimeClient = {
@@ -33,14 +36,12 @@ export type MdRuntimeClient = {
33
36
  };
34
37
  conversation: {
35
38
  list(): Promise<readonly ConversationEntry[]>;
36
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
39
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
37
40
  create(input: unknown): Promise<CallResult>;
38
41
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
39
- attach(room: string, file: ChosenFile): Promise<CallResult | Offline>;
40
- answer(conversation: string, answer: unknown): Promise<CallResult>;
42
+ answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
41
43
  interrupt(conversation: string): Promise<CallResult>;
42
44
  kill(conversation: string): Promise<CallResult>;
43
- cancel(conversation: string, turn: string): Promise<CallResult>;
44
45
  delete(conversation: string): Promise<CallResult>;
45
46
  };
46
47
  chatDraft: {
@@ -52,7 +53,8 @@ export type MdRuntimeClient = {
52
53
  resolve(room: string, path: string, destination: string): Promise<Resolution>;
53
54
  binaryFile: {
54
55
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
55
- link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
56
+ attach(room: string, file: File): Promise<AttachAnswer>;
57
+ download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
56
58
  };
57
59
  call(name: string, input: unknown): Promise<CallResult>;
58
60
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
@@ -60,6 +62,9 @@ export type MdRuntimeClient = {
60
62
  persistence(): Promise<boolean>;
61
63
  retry(): Promise<void>;
62
64
  cleanUp(): Promise<number>;
65
+ unsent(): Promise<readonly UnsentWork[]>;
66
+ reset(): Promise<void>;
67
+ readAgain(): Promise<void>;
63
68
  observe: {
64
69
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
65
70
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -69,6 +74,7 @@ export type MdRuntimeClient = {
69
74
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
70
75
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
71
76
  (topic: 'member'): Promise<Observation<Member | null>>;
77
+ (topic: 'authority-changes'): Promise<Observation<number>>;
72
78
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
73
79
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
74
80
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -77,6 +83,8 @@ export type MdRuntimeClient = {
77
83
  (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
78
84
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
79
85
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
86
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
87
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
80
88
  };
81
89
  reauthorize(): Promise<void>;
82
90
  settled(): Promise<void>;
@@ -85,6 +93,7 @@ export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
85
93
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
86
94
  export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
87
95
  export { roomDraftRevision } from './identity.js';
96
+ export { defineRoomMedia, ROOM_MEDIA } from './media.js';
88
97
  export type { Observation } from './observation.js';
89
98
  export type { Open } from './open.js';
90
99
  export { unanswered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,8 +1,6 @@
1
- import { type Document } from '@agentshouse/mdmodel';
1
+ import { type Document, type TypedPath } from '@agentshouse/mdmodel';
2
2
  import type { ModelState } from './model.js';
3
3
  import type { MdModelIdentity } from './adapter.js';
4
- import { type Paths } from './shared.js';
5
- import type { Refused } from './transfer.js';
6
4
  export declare const MD_MODEL: MdModelIdentity;
7
5
  export type Collection = {
8
6
  text: Readonly<Record<string, string>>;
@@ -15,11 +13,16 @@ export type Composition = {
15
13
  roots: readonly string[];
16
14
  model: ModelState;
17
15
  } | null;
16
+ typedPaths: readonly TypedPath[];
18
17
  };
18
+ export type Composed = {
19
+ readonly composition: Composition;
20
+ readonly fingerprint: string;
21
+ };
22
+ export declare function composedOf(composition: Composition): Composed;
19
23
  export declare function selected(composition: Composition, path: string): boolean;
20
24
  export declare function governing(composition: Composition, path: string): ModelState;
21
25
  export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
22
26
  export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
23
- export declare function unreadable(text: Paths<string>, paths?: Iterable<string> | null): Generator<number, Refused | null, void>;
24
27
  export declare function validRoot(root: unknown): root is string;
25
28
  export declare function available(composition: Composition): boolean;
@@ -1,15 +1,15 @@
1
+ import { sql } from '@agentshouse/mdmodel';
1
2
  import type { Plan, QueryRows } from './query.js';
2
- import type { Connection, Value } from './tables.js';
3
+ import type { Connection } from './tables.js';
3
4
  export type QueryRoom = {
4
5
  readonly locator: string;
5
6
  readonly key: number;
6
7
  };
7
- export type Fragment = {
8
- readonly sql: string;
9
- readonly bind: readonly Value[];
10
- };
8
+ type Fragment = sql.Fragment;
9
+ export declare const VISIBLE: (alias: string) => string;
10
+ export declare function within(alias: string, path: string): Fragment;
11
11
  export type QueryAnswer = QueryRows & {
12
12
  readonly more?: string;
13
13
  };
14
- export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
15
14
  export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
15
+ export {};
@@ -1,19 +1,22 @@
1
+ import { type DocumentQuery, type GroupQuery } from '@agentshouse/mdmodel';
1
2
  import { type TypesResult } from './model.js';
2
3
  import { type Observation } from './observation.js';
3
- import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult, type PendingResult } from './query.js';
4
+ import { type DocumentResult, type GroupResult, type PendingResult } from './query.js';
5
+ import { type FiguresResult } from './figures.js';
4
6
  import { type EntrySeed } from './seed.js';
5
7
  import { type SearchRequest, type SearchResult } from './search.js';
6
8
  import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
7
9
  import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
8
10
  import { type WrittenBy } from './change.js';
9
11
  import type { Open } from './open.js';
10
- import { type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
12
+ import { type AttachAnswer, type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HeldShownAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
13
+ import { type ObservedRead } from './reads.js';
11
14
  import { type Recovery } from './recovery.js';
12
15
  import { type SaveRefusal } from './save.js';
13
16
  import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
14
17
  import { type SyncStatus } from './status.js';
15
- import { type RuntimeShell } from './durability.js';
16
- import { type CodeAvailability, type Persistence, type Readiness, type SearchObligation, type Space } from './readiness.js';
18
+ import { type RuntimeShell, type UnsentWork } from './durability.js';
19
+ import { type CodeAvailability, type Persistence, type Readiness } from './readiness.js';
17
20
  import type { RuntimeDatabase } from './tables.js';
18
21
  import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
19
22
  export type AppTypedSelection = {
@@ -54,6 +57,8 @@ export type MdRuntimeOptions = {
54
57
  authorization?: Authorization;
55
58
  signal?: AbortSignal;
56
59
  recovery?: Recovery;
60
+ usableWhenHeld?: readonly string[];
61
+ build?: string;
57
62
  };
58
63
  export type SaveResult = {
59
64
  outcome: 'saved';
@@ -83,6 +88,8 @@ export type PresentationSurface = {
83
88
  export type BinaryFileSurface = {
84
89
  read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
85
90
  link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
91
+ show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
92
+ attach(room: string, file: File): Promise<AttachAnswer>;
86
93
  part(file: string, part: number): Promise<Uint8Array | null>;
87
94
  };
88
95
  export type HistoryQuery = {
@@ -91,13 +98,13 @@ export type HistoryQuery = {
91
98
  };
92
99
  export type MdRuntime = {
93
100
  loaded(): Promise<void>;
94
- rooms(): readonly AppRoom[];
101
+ rooms(): Promise<readonly AppRoom[]>;
95
102
  query: {
96
103
  (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
97
104
  (query: GroupQuery): Promise<GroupResult | PendingResult>;
98
105
  };
99
106
  search(request: SearchRequest): Promise<SearchResult>;
100
- types(locator: string): RoomSchemas;
107
+ types(locator: string): Promise<RoomSchemas>;
101
108
  roomDraft: RoomDraftSurface;
102
109
  conversation: ConversationSurface;
103
110
  chatDraft: ChatDraftSurface;
@@ -113,6 +120,9 @@ export type MdRuntime = {
113
120
  persistence(): boolean;
114
121
  retry(): Promise<void>;
115
122
  cleanUp(): Promise<number>;
123
+ unsent(): Promise<readonly UnsentWork[]>;
124
+ reset(): Promise<void>;
125
+ readAgain(): Promise<void>;
116
126
  observe: {
117
127
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
118
128
  (topic: 'readiness'): Promise<Observation<Readiness>>;
@@ -121,6 +131,7 @@ export type MdRuntime = {
121
131
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
122
132
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
123
133
  (topic: 'member'): Promise<Observation<Member | null>>;
134
+ (topic: 'authority-changes'): Promise<Observation<number>>;
124
135
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
125
136
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
126
137
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -129,22 +140,20 @@ export type MdRuntime = {
129
140
  (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
130
141
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
131
142
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
143
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
144
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
132
145
  };
133
146
  reauthorize(): Promise<void>;
134
147
  };
135
- export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
148
+ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents' | 'figures' | 'read';
136
149
  export type ReadinessPort = {
137
150
  readonly target: string;
138
151
  readonly code: CodeAvailability;
139
- readonly space: Space | null;
140
- readonly search: SearchObligation;
141
152
  };
142
153
  export type ComposedRuntime = RuntimeView & {
143
154
  seed(entry: EntrySeed): void;
144
155
  stop(): Promise<void>;
145
- lose(locators: readonly string[]): Promise<void>;
146
156
  persisted(answer: Persistence): void;
147
- shown(onScreen: boolean): void;
148
157
  within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
149
158
  };
150
159
  export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
@@ -0,0 +1,32 @@
1
+ import type { HeldRow } from './messages.js';
2
+ import { type HouseSource } from './source.js';
3
+ export type ConversationLast = {
4
+ readonly text: string;
5
+ readonly by: 'owner' | 'agent' | 'house';
6
+ readonly at: string;
7
+ };
8
+ export type ConversationStart = Extract<HouseSource, {
9
+ readonly kind: 'request' | 'trigger';
10
+ }>;
11
+ export type ConversationAsk = {
12
+ readonly who: string;
13
+ readonly agent: string | null;
14
+ readonly room: {
15
+ readonly ref: string;
16
+ readonly name: string;
17
+ };
18
+ readonly prompt: string;
19
+ readonly at: string;
20
+ readonly request: string;
21
+ readonly message?: string;
22
+ };
23
+ export type ConversationHeld = {
24
+ readonly last: ConversationLast | null;
25
+ readonly failure: string | null;
26
+ readonly startedBy: ConversationStart | null;
27
+ readonly asks: ConversationAsk | null;
28
+ };
29
+ export declare function heldFacts(held: HeldRow | undefined, listed: {
30
+ readonly outcome: string | null;
31
+ readonly waiting: boolean;
32
+ }): ConversationHeld;