@agentshouse/app-bridge 0.1.0-ca559eade7c19 → 0.1.0-ca6bf24eae119

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 (55) hide show
  1. package/README.md +9 -9
  2. package/dist/calls.d.ts +676 -69
  3. package/dist/index.d.ts +36 -18
  4. package/dist/mdmodel/condition.d.ts +23 -10
  5. package/dist/mdmodel/definition.d.ts +3 -1
  6. package/dist/mdmodel/document.d.ts +5 -5
  7. package/dist/mdmodel/index.d.ts +9 -7
  8. package/dist/mdmodel/links.d.ts +28 -0
  9. package/dist/mdmodel/paths.d.ts +9 -1
  10. package/dist/mdmodel/project.d.ts +1 -0
  11. package/dist/mdmodel/types.d.ts +28 -4
  12. package/dist/mdmodel/validate.d.ts +27 -3
  13. package/dist/mdruntime/adapter.d.ts +83 -48
  14. package/dist/mdruntime/binary.d.ts +0 -5
  15. package/dist/mdruntime/chain.d.ts +10 -0
  16. package/dist/mdruntime/change-set.d.ts +9 -16
  17. package/dist/mdruntime/change.d.ts +31 -1
  18. package/dist/mdruntime/client.d.ts +13 -5
  19. package/dist/mdruntime/collection.d.ts +10 -21
  20. package/dist/mdruntime/compile.d.ts +15 -0
  21. package/dist/mdruntime/connection.d.ts +25 -13
  22. package/dist/mdruntime/conversation.d.ts +19 -6
  23. package/dist/mdruntime/durability.d.ts +2 -5
  24. package/dist/mdruntime/fulltext.d.ts +26 -0
  25. package/dist/mdruntime/identity.d.ts +6 -0
  26. package/dist/mdruntime/media.d.ts +7 -0
  27. package/dist/mdruntime/messages.d.ts +27 -0
  28. package/dist/mdruntime/model.d.ts +6 -1
  29. package/dist/mdruntime/observation.d.ts +15 -0
  30. package/dist/mdruntime/opened.d.ts +21 -0
  31. package/dist/mdruntime/outcome.d.ts +45 -7
  32. package/dist/mdruntime/overlay.d.ts +2 -5
  33. package/dist/mdruntime/query.d.ts +32 -2
  34. package/dist/mdruntime/reach.d.ts +13 -4
  35. package/dist/mdruntime/readiness.d.ts +14 -15
  36. package/dist/mdruntime/recovery.d.ts +3 -2
  37. package/dist/mdruntime/replica.d.ts +55 -33
  38. package/dist/mdruntime/room-draft.d.ts +21 -3
  39. package/dist/mdruntime/save.d.ts +53 -14
  40. package/dist/mdruntime/search.d.ts +23 -42
  41. package/dist/mdruntime/status.d.ts +4 -3
  42. package/dist/mdruntime/store.d.ts +90 -97
  43. package/dist/mdruntime/stored.d.ts +129 -0
  44. package/dist/mdruntime/tables.d.ts +324 -0
  45. package/dist/mdruntime/wire.d.ts +33 -1
  46. package/dist/test-host.d.ts +7 -4
  47. package/dist/test-host.js +18 -28
  48. package/docs/families.md +50 -49
  49. package/package.json +8 -3
  50. package/dist/mdruntime/acquisition.d.ts +0 -13
  51. package/dist/mdruntime/file.d.ts +0 -19
  52. package/dist/mdruntime/rows.d.ts +0 -37
  53. package/dist/mdruntime/shared.d.ts +0 -10
  54. package/dist/mdruntime/transfer.d.ts +0 -9
  55. package/dist/mdruntime/turn.d.ts +0 -6
@@ -10,14 +10,13 @@ export type TypedSelection = {
10
10
  roots: readonly string[];
11
11
  };
12
12
  export type OperationScopes = {
13
- read: readonly string[];
14
- sync: readonly string[];
15
13
  write: readonly string[];
16
14
  delete: readonly string[];
17
15
  };
18
16
  export type ReplicaAdmission = {
19
17
  selection: string;
20
18
  admission: Open<'admitted' | 'unavailable'>;
19
+ offline: Open<'locked' | 'open'>;
21
20
  };
22
21
  export type DiscoveredRoom = {
23
22
  name: string;
@@ -49,6 +48,8 @@ export type ListedConversation = {
49
48
  created: string;
50
49
  finished: string | null;
51
50
  outcome: string | null;
51
+ waiting: boolean;
52
+ newest: string | null;
52
53
  };
53
54
  export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
54
55
  export type ConversationMessage = {
@@ -162,6 +163,18 @@ export type ConversationEvent = {
162
163
  kind: 'options';
163
164
  conversation: string;
164
165
  options: readonly SessionOption[];
166
+ } | {
167
+ kind: 'starting';
168
+ conversation: string;
169
+ step: string | null;
170
+ } | {
171
+ kind: 'link';
172
+ conversation: string;
173
+ connected: boolean;
174
+ } | {
175
+ kind: 'deliveries';
176
+ conversation: string;
177
+ unknown: readonly string[];
165
178
  } | {
166
179
  kind: 'accepted-message';
167
180
  conversation: string;
@@ -187,6 +200,7 @@ export type ActionDeclaration = {
187
200
  name: string;
188
201
  inputShape: unknown;
189
202
  resultKind: unknown;
203
+ room?: string;
190
204
  };
191
205
  export type ProviderLimit = {
192
206
  name: string;
@@ -210,6 +224,10 @@ export type Discovery = {
210
224
  providerLimits: readonly ProviderLimit[];
211
225
  retention: Retention;
212
226
  member?: Member;
227
+ covered?: readonly string[];
228
+ };
229
+ export type DiscoveryScope = {
230
+ readonly authorities: readonly string[];
213
231
  };
214
232
  export type TransportUncertainty = {
215
233
  kind: 'transport-uncertainty';
@@ -229,7 +247,7 @@ export type ProviderRefusal = {
229
247
  export type ScopedRefusal = ProviderRefusal & {
230
248
  kind: 'scoped-refusal';
231
249
  locator: string;
232
- scope: Open<'content' | 'sync' | 'model' | 'operation' | 'undisclosed'>;
250
+ scope: Open<'content' | 'model' | 'operation' | 'undisclosed'>;
233
251
  };
234
252
  export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
235
253
  export type ContractUnavailable = ProviderRefusal & {
@@ -238,7 +256,7 @@ export type ContractUnavailable = ProviderRefusal & {
238
256
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
239
257
  export type PageToken = string;
240
258
  export type ChangeAuthor = {
241
- kind: Open<'user' | 'site'>;
259
+ kind: Open<'user' | 'site' | 'inbox' | 'app'>;
242
260
  id: string;
243
261
  name: string;
244
262
  };
@@ -252,24 +270,34 @@ export type HeadChange = {
252
270
  time: string;
253
271
  };
254
272
  export type BinaryFile = {
255
- fileRef: string;
256
273
  byteLength: number;
257
274
  mediaType: string;
258
275
  sha256: string;
259
276
  };
277
+ export type HeldFile = {
278
+ readonly path: string;
279
+ readonly revision: string;
280
+ };
260
281
  export type HeldContent = {
261
- documents: Readonly<Record<string, string>>;
262
- revisions: Readonly<Record<string, string>>;
282
+ files(after: string | null, limit: number): Promise<readonly HeldFile[]>;
283
+ contents(paths: readonly string[]): Promise<ReadonlyMap<string, {
284
+ readonly content: string;
285
+ readonly revision: string;
286
+ }>>;
263
287
  };
264
288
  export type BootstrapRequest = {
265
289
  locator: string;
266
290
  selection: string;
267
291
  pageToken?: PageToken;
268
292
  held?: HeldContent;
293
+ arriving?: (bytes: number) => void;
294
+ signal?: AbortSignal;
295
+ };
296
+ export type BootstrapInventory = {
297
+ readonly bytes: number;
269
298
  };
270
299
  export type RoomModels = {
271
300
  collection?: ModelResult;
272
- selection?: ModelResult;
273
301
  };
274
302
  export type BootstrapPage = {
275
303
  kind: 'bootstrap';
@@ -280,7 +308,9 @@ export type BootstrapPage = {
280
308
  fileIds?: Readonly<Record<string, string>>;
281
309
  changes: Readonly<Record<string, HeadChange>>;
282
310
  binaryFiles: Readonly<Record<string, BinaryFile>>;
311
+ folders?: readonly string[];
283
312
  pageToken?: PageToken;
313
+ bytes?: number;
284
314
  };
285
315
  export type BootstrapResult = BootstrapPage | {
286
316
  kind: 'beyond-horizon';
@@ -301,6 +331,8 @@ export type RefreshPage = {
301
331
  changes: Readonly<Record<string, HeadChange>>;
302
332
  binaryFiles: Readonly<Record<string, BinaryFile>>;
303
333
  removals: readonly string[];
334
+ folders?: readonly string[];
335
+ folderRemovals?: readonly string[];
304
336
  pageToken?: PageToken;
305
337
  };
306
338
  export type RefreshResult = {
@@ -311,6 +343,7 @@ export type RefreshResult = {
311
343
  export type MutationRequest = {
312
344
  locator: string;
313
345
  changeBatch: ChangeBatch;
346
+ file(localId: string): Promise<Blob>;
314
347
  upload?: unknown;
315
348
  };
316
349
  export type RetryableRefusal = ProviderRefusal & {
@@ -321,8 +354,7 @@ export type ServiceMode = Open<'open' | 'write-halted'>;
321
354
  export type ServiceModeSignal = {
322
355
  observe(notify: (mode: ServiceMode) => void): () => void;
323
356
  };
324
- export type MutationResult = {
325
- kind: 'accepted';
357
+ export type AcceptedRoom = {
326
358
  roomVersion: string;
327
359
  documents: Readonly<Record<string, string>>;
328
360
  revisions: Readonly<Record<string, string>>;
@@ -330,9 +362,13 @@ export type MutationResult = {
330
362
  changes: Readonly<Record<string, HeadChange>>;
331
363
  removals: readonly string[];
332
364
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
365
+ };
366
+ export type MutationResult = (AcceptedRoom & {
367
+ kind: 'accepted';
333
368
  author?: string;
334
369
  time?: string;
335
- } | (ProviderRefusal & {
370
+ destination?: AcceptedRoom;
371
+ }) | (ProviderRefusal & {
336
372
  kind: 'conflicted';
337
373
  roomVersion?: string;
338
374
  affected: Readonly<Record<string, string>>;
@@ -349,7 +385,7 @@ export type HistoryAuthor = {
349
385
  kind: 'user';
350
386
  id: string;
351
387
  } | {
352
- kind: 'site';
388
+ kind: 'site' | 'inbox' | 'app';
353
389
  id: string;
354
390
  name: string;
355
391
  };
@@ -381,22 +417,35 @@ export type BinaryRequest = {
381
417
  locator: string;
382
418
  path: string;
383
419
  revision: string;
384
- fileRef?: string;
385
- } | {
386
- kind: 'reference';
387
- fileRef: string;
388
- referrer: unknown;
389
- };
390
- export type ReferrerScope = {
391
- kind: 'room';
392
- locator: string;
393
- path?: string;
394
- } | {
395
- kind: 'conversations';
396
420
  };
397
421
  export type BinaryResult = {
398
422
  kind: 'binary';
423
+ body: ReadableStream<Uint8Array>;
424
+ mediaType: string;
425
+ sha256?: string;
426
+ } | (ProviderRefusal & {
427
+ kind: 'rejected';
428
+ }) | AdapterFailure;
429
+ export type BinaryLinkResult = {
430
+ kind: 'link';
431
+ url: string;
432
+ name: string;
433
+ mediaType?: string;
434
+ } | (ProviderRefusal & {
435
+ kind: 'rejected';
436
+ }) | AdapterFailure;
437
+ export type AttachRequest = {
438
+ locator: string;
439
+ name: string;
440
+ mediaType: string;
441
+ byteLength: number;
442
+ sha256: string;
399
443
  blob: Blob;
444
+ };
445
+ export type AttachResult = {
446
+ kind: 'attached';
447
+ path: string;
448
+ revision: string;
400
449
  } | (ProviderRefusal & {
401
450
  kind: 'rejected';
402
451
  }) | AdapterFailure;
@@ -418,8 +467,6 @@ export type ActionResult = {
418
467
  export type HeldRoom = {
419
468
  locator: string;
420
469
  roomVersion: string;
421
- documents: Readonly<Record<string, string>>;
422
- revisions: Readonly<Record<string, string>>;
423
470
  };
424
471
  export type RoomStreamEvent = {
425
472
  kind: 'opened';
@@ -430,45 +477,33 @@ export type RoomStreamEvent = {
430
477
  } | {
431
478
  kind: 'opening';
432
479
  expired: readonly string[];
480
+ } | {
481
+ kind: 'authority-changed';
482
+ scope?: DiscoveryScope;
433
483
  } | {
434
484
  kind: 'room-version';
435
485
  locator: string;
436
486
  roomVersion: string;
437
487
  };
438
- export type KeptReceipt = {
439
- key: string;
440
- head: unknown;
441
- };
442
- export type StreamReceipts = {
443
- heads(): Promise<readonly KeptReceipt[]>;
444
- parts(key: string, count: number): Promise<readonly unknown[]>;
445
- keep(key: string, head: unknown, part?: {
446
- index: number;
447
- value: unknown;
448
- }): Promise<void>;
449
- drop(keys: readonly string[]): Promise<void>;
450
- };
451
- export type AcquiredDemand = {
452
- rooms: readonly string[];
453
- conversations: boolean;
454
- };
455
488
  export type RoomStream = {
456
- hold(rooms: readonly HeldRoom[], demand: AcquiredDemand | null): void;
489
+ hold(rooms: readonly HeldRoom[]): void;
457
490
  reopen(): void;
458
- published(locator: string, roomVersion: string): void;
459
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
491
+ observe(notify: (event: RoomStreamEvent) => void): () => void;
460
492
  };
461
493
  export type Adapter = {
462
494
  readonly localSaves?: true;
463
495
  readonly exhaustiveDiscovery?: true;
496
+ readonly roomTypes?: string;
497
+ readonly nameableRoomTypes?: readonly string[];
464
498
  authorize(): Promise<Authorization>;
465
- discover(authorization: Authorization): Promise<DiscoverResult>;
499
+ discover(authorization: Authorization, scope?: DiscoveryScope): Promise<DiscoverResult>;
466
500
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
467
501
  refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
468
502
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
469
503
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
470
504
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
471
- referrerScope(referrer: unknown): ReferrerScope | null;
505
+ link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
506
+ attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
472
507
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
473
508
  reached(locator: string, roomVersion: string, target: string): boolean;
474
509
  follows(locator: string, roomVersion: string, next: string): boolean;
@@ -3,7 +3,6 @@ export type BinaryFileRecord = {
3
3
  readonly state: 'accepted';
4
4
  readonly revision: string;
5
5
  readonly path: string;
6
- readonly fileRef: string;
7
6
  readonly byteLength: number;
8
7
  readonly mediaType: string;
9
8
  readonly sha256: string;
@@ -15,8 +14,4 @@ export type BinaryFileRecord = {
15
14
  readonly mediaType: string;
16
15
  readonly sha256: string;
17
16
  };
18
- export type BinaryReference = {
19
- readonly fileRef: string;
20
- readonly referrer: unknown;
21
- };
22
17
  export declare function binaryRecord(path: string, held: HeldBinary, revision: string | undefined): BinaryFileRecord;
@@ -0,0 +1,10 @@
1
+ import type { MdRuntimeClient } from './client.js';
2
+ import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
3
+ type Rows = DocumentResult | GroupResult;
4
+ export type WindowAnswer = Rows | PendingResult;
5
+ export type WindowChain = {
6
+ want(count: number): void;
7
+ close(): void;
8
+ };
9
+ export declare function chainedWindows(runtime: MdRuntimeClient, query: DocumentQuery | GroupQuery, count: number, publish: (answers: readonly (WindowAnswer | null)[], settled: boolean) => void): WindowChain;
10
+ export {};
@@ -1,15 +1,6 @@
1
- import { type Replica } from './replica.js';
2
- import { type Row } from './rows.js';
3
1
  export type DocumentChange = {
4
- locator: string;
5
- path: string;
6
- before: readonly Row[];
7
- after: readonly Row[];
8
- };
9
- export type MessageChange = {
10
- conversation: string;
11
- identity: string;
12
- text: string | null;
2
+ readonly locator: string;
3
+ readonly path: string | null;
13
4
  };
14
5
  export type ChangeSet = {
15
6
  documents: readonly DocumentChange[];
@@ -20,15 +11,17 @@ export type ChangeSet = {
20
11
  rooms: readonly string[];
21
12
  queues: readonly string[];
22
13
  presentations: readonly string[];
23
- messages: readonly MessageChange[];
24
14
  conversations: readonly string[];
25
15
  };
26
- export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: {
16
+ type Changed = {
17
+ documents?: readonly string[] | null;
27
18
  drafts?: readonly string[];
28
19
  room?: boolean;
29
20
  queue?: boolean;
30
21
  presentation?: string;
31
- }): ChangeSet;
32
- export declare function entering(locator: string, replica: Replica, paths: readonly string[]): ChangeSet;
33
- export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
22
+ };
23
+ export declare function changeSet(locator: string, changed?: Changed): ChangeSet;
24
+ export declare function conversationChangeSet(conversations: readonly string[]): ChangeSet;
34
25
  export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
26
+ export declare function touches(set: ChangeSet, locator: string, path: string): boolean;
27
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { BinaryFile, HeadChange } from './adapter.js';
1
2
  export type Change = {
2
3
  readonly kind: 'field';
3
4
  readonly path: string;
@@ -29,7 +30,6 @@ export type Change = {
29
30
  readonly kind: 'binary';
30
31
  readonly path: string;
31
32
  readonly localId: string;
32
- readonly blob: Blob;
33
33
  readonly byteLength: number;
34
34
  readonly mediaType: string;
35
35
  readonly sha256: string;
@@ -40,6 +40,32 @@ export type Change = {
40
40
  } | {
41
41
  readonly kind: 'remove';
42
42
  readonly path: string;
43
+ } | (Arriving & {
44
+ readonly content: string;
45
+ }) | (Arriving & {
46
+ readonly binary: BinaryFile;
47
+ });
48
+ type Arriving = {
49
+ readonly kind: 'arrival';
50
+ readonly path: string;
51
+ readonly revision?: string;
52
+ readonly fileId?: string;
53
+ readonly change?: HeadChange;
54
+ };
55
+ export type RoomMove = {
56
+ readonly source: {
57
+ readonly room: string;
58
+ readonly baseRoomVersion: string;
59
+ };
60
+ readonly destination: {
61
+ readonly room: string;
62
+ readonly baseRoomVersion: string;
63
+ readonly handle: string;
64
+ };
65
+ readonly moves: readonly {
66
+ readonly path: string;
67
+ readonly to: string;
68
+ }[];
43
69
  };
44
70
  export type Precondition = {
45
71
  readonly kind: 'field';
@@ -81,8 +107,12 @@ export type ChangeBatch = {
81
107
  readonly changes: readonly Change[];
82
108
  readonly preconditions: readonly Precondition[];
83
109
  readonly writtenBy?: WrittenBy;
110
+ readonly between?: RoomMove;
84
111
  };
85
112
  export declare function immutable(batch: ChangeBatch): ChangeBatch;
113
+ export declare function partnerOf(batch: ChangeBatch, locator: string): string | null;
114
+ export declare function leaving(batch: ChangeBatch, locator: string): boolean;
86
115
  export declare function landing(changes: readonly Change[], index: number, path: string): string | null;
87
116
  export declare function departure(changes: readonly Change[], index: number): string;
88
117
  export declare function queuedFile(batch: ChangeBatch, path: string, localId: string): number;
118
+ export {};
@@ -1,9 +1,8 @@
1
- import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedRoomDraft, SaveResult } from './connection.js';
1
+ import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
2
2
  import type { Member, ServiceMode } from './adapter.js';
3
3
  import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
4
4
  import { type Observation } from './observation.js';
5
- import type { BinaryReference } from './binary.js';
6
- import type { BinaryAnswer, CallResult, HistoryAnswer, Offline, QueueEntry } from './outcome.js';
5
+ import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
7
6
  import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
8
7
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
9
8
  import type { SearchRequest, SearchResult } from './search.js';
@@ -21,13 +20,15 @@ export type MdRuntimeClient = {
21
20
  roomDraft: {
22
21
  list(): Promise<readonly RoomDraft[]>;
23
22
  read(room: string, path: string): Promise<RoomDraft | null>;
24
- write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
23
+ write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
25
24
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
26
25
  };
27
26
  save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
27
+ saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
28
28
  presentation: {
29
29
  read(): Promise<unknown>;
30
30
  write(value: unknown): Promise<void>;
31
+ edit(members: Readonly<Record<string, unknown>>): Promise<void>;
31
32
  };
32
33
  conversation: {
33
34
  list(): Promise<readonly ConversationEntry[]>;
@@ -42,18 +43,22 @@ export type MdRuntimeClient = {
42
43
  };
43
44
  chatDraft: {
44
45
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
46
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
45
47
  discard(conversation: string): Promise<void>;
46
48
  };
47
49
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
50
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
48
51
  binaryFile: {
49
52
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
50
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
53
+ attach(room: string, file: File): Promise<AttachAnswer>;
54
+ download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
51
55
  };
52
56
  call(name: string, input: unknown): Promise<CallResult>;
53
57
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
54
58
  log(): Promise<string>;
55
59
  persistence(): Promise<boolean>;
56
60
  retry(): Promise<void>;
61
+ cleanUp(): Promise<number>;
57
62
  observe: {
58
63
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
59
64
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -77,6 +82,9 @@ export type MdRuntimeClient = {
77
82
  };
78
83
  export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
79
84
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
85
+ export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
86
+ export { roomDraftRevision } from './identity.js';
87
+ export { defineRoomMedia, ROOM_MEDIA } from './media.js';
80
88
  export type { Observation } from './observation.js';
81
89
  export type { Open } from './open.js';
82
90
  export { unanswered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,9 +1,6 @@
1
- import { type Document, type Frontmatter, type Validation } from '../mdmodel/index.js';
2
- import { type ModelState } from './model.js';
1
+ import { type Document } from '../mdmodel/index.js';
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
- import { type Later } from './turn.js';
7
4
  export declare const MD_MODEL: MdModelIdentity;
8
5
  export type Collection = {
9
6
  text: Readonly<Record<string, string>>;
@@ -17,22 +14,14 @@ export type Composition = {
17
14
  model: ModelState;
18
15
  } | null;
19
16
  };
17
+ export type Composed = {
18
+ readonly composition: Composition;
19
+ readonly fingerprint: string;
20
+ };
21
+ export declare function composedOf(composition: Composition): Composed;
22
+ export declare function selected(composition: Composition, path: string): boolean;
20
23
  export declare function governing(composition: Composition, path: string): ModelState;
21
- export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Collection;
22
- export declare function passingFrontmatter(collection: Collection, path: string): Frontmatter | undefined;
23
- export declare function documentsOf(collection: Collection): Generator<readonly [string, Document]>;
24
- export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Refused | null;
24
+ export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
25
+ export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
25
26
  export declare function validRoot(root: unknown): root is string;
26
- export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Validation;
27
- type Held = {
28
- text: Paths<string>;
29
- binaries: Paths<unknown>;
30
- };
31
- export declare function indexReferrers(held: Held, composition: Composition): Later<void>;
32
- export declare function referencesIndexed(held: Held, composition: Composition): boolean;
33
- export declare function referring(held: Held, composition: Composition, targets: Iterable<string>): ReadonlySet<string> | null;
34
27
  export declare function available(composition: Composition): boolean;
35
- export declare function changedCleanly(next: Held, previous: Held & {
36
- composition: Composition;
37
- }, composition: Composition): boolean;
38
- export {};
@@ -0,0 +1,15 @@
1
+ import type { Plan, QueryRows } from './query.js';
2
+ import type { Connection, Value } from './tables.js';
3
+ export type QueryRoom = {
4
+ readonly locator: string;
5
+ readonly key: number;
6
+ };
7
+ export type Fragment = {
8
+ readonly sql: string;
9
+ readonly bind: readonly Value[];
10
+ };
11
+ export type QueryAnswer = QueryRows & {
12
+ readonly more?: string;
13
+ };
14
+ export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
15
+ export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
@@ -7,15 +7,14 @@ import { type Adapter, type Authorization, type Member, type ProviderRefusal, ty
7
7
  import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
8
8
  import { type WrittenBy } from './change.js';
9
9
  import type { Open } from './open.js';
10
- import { type BinaryReference } from './binary.js';
11
- import { type BinaryAnswer, type CallResult, type HistoryAnswer, type QueueEntry } from './outcome.js';
10
+ import { type AttachAnswer, type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HeldShownAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
12
11
  import { type Recovery } from './recovery.js';
13
12
  import { type SaveRefusal } from './save.js';
14
- import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
13
+ import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
15
14
  import { type SyncStatus } from './status.js';
16
15
  import { type RuntimeShell } from './durability.js';
17
- import { type RuntimeDemand } from './acquisition.js';
18
- import { type CapacityCause, type CodeAvailability, type Persistence, type Readiness, type SearchObligation } from './readiness.js';
16
+ import { type CodeAvailability, type Persistence, type Readiness, type SearchObligation, type Space } from './readiness.js';
17
+ import type { RuntimeDatabase } from './tables.js';
19
18
  import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
20
19
  export type AppTypedSelection = {
21
20
  roots: readonly string[];
@@ -34,6 +33,7 @@ export type AppRoom = {
34
33
  documents: number;
35
34
  synchronizationAvailable: boolean;
36
35
  refusal: ProviderRefusal | null;
36
+ locked: boolean;
37
37
  };
38
38
  export type RoomSchemas = {
39
39
  collection: TypesResult;
@@ -50,9 +50,11 @@ export type ConnectionRefusal = {
50
50
  export type MdRuntimeOptions = {
51
51
  adapter: Adapter;
52
52
  shell: RuntimeShell;
53
+ database: RuntimeDatabase;
53
54
  authorization?: Authorization;
54
55
  signal?: AbortSignal;
55
56
  recovery?: Recovery;
57
+ usableWhenHeld?: readonly string[];
56
58
  };
57
59
  export type SaveResult = {
58
60
  outcome: 'saved';
@@ -64,19 +66,27 @@ export type SavedRoomDraft = {
64
66
  readonly path: string;
65
67
  readonly revision: string;
66
68
  };
69
+ export type SavedParts = {
70
+ readonly path: string;
71
+ readonly parts: RoomDraftParts;
72
+ };
67
73
  export type RoomDraftSurface = {
68
74
  list(): Promise<readonly RoomDraft[]>;
69
- read(room: string, path: string): RoomDraft | null;
70
- write(room: string, path: string, revision: string | null, parts: unknown): Promise<RoomDraftWrite>;
75
+ read(room: string, path: string): Promise<RoomDraft | null>;
76
+ write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
71
77
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
72
78
  };
73
79
  export type PresentationSurface = {
74
80
  read(app: string): Promise<unknown>;
75
81
  write(app: string, value: unknown): Promise<void>;
82
+ edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
76
83
  };
77
84
  export type BinaryFileSurface = {
78
- read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
79
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
85
+ read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
86
+ link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
87
+ show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
88
+ attach(room: string, file: File): Promise<AttachAnswer>;
89
+ part(file: string, part: number): Promise<Uint8Array | null>;
80
90
  };
81
91
  export type HistoryQuery = {
82
92
  revision?: string;
@@ -84,7 +94,7 @@ export type HistoryQuery = {
84
94
  };
85
95
  export type MdRuntime = {
86
96
  loaded(): Promise<void>;
87
- rooms(): readonly AppRoom[];
97
+ rooms(): Promise<readonly AppRoom[]>;
88
98
  query: {
89
99
  (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
90
100
  (query: GroupQuery): Promise<GroupResult | PendingResult>;
@@ -96,13 +106,16 @@ export type MdRuntime = {
96
106
  chatDraft: ChatDraftSurface;
97
107
  presentation: PresentationSurface;
98
108
  save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
109
+ saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
99
110
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
111
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
100
112
  binaryFile: BinaryFileSurface;
101
113
  call(name: string, input: unknown): Promise<CallResult>;
102
- reached(locator: string, roomVersion: string, path?: string): boolean;
114
+ reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
103
115
  log(): string;
104
116
  persistence(): boolean;
105
117
  retry(): Promise<void>;
118
+ cleanUp(): Promise<number>;
106
119
  observe: {
107
120
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
108
121
  (topic: 'readiness'): Promise<Observation<Readiness>>;
@@ -126,14 +139,13 @@ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'stora
126
139
  export type ReadinessPort = {
127
140
  readonly target: string;
128
141
  readonly code: CodeAvailability;
129
- readonly capacity: CapacityCause | null;
142
+ readonly space: Space | null;
130
143
  readonly search: SearchObligation;
131
144
  };
132
145
  export type ComposedRuntime = RuntimeView & {
133
146
  seed(entry: EntrySeed): void;
134
147
  stop(): Promise<void>;
135
148
  lose(locators: readonly string[]): Promise<void>;
136
- acquire(demand: RuntimeDemand): void;
137
149
  persisted(answer: Persistence): void;
138
150
  within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
139
151
  };