@agentshouse/mdruntime-families 0.1.0-cbcba985a6e71 → 0.1.0-cbf903cc74a09

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 (42) hide show
  1. package/README.md +6 -4
  2. package/dist/mdruntime/adapter.d.ts +65 -52
  3. package/dist/mdruntime/binary.d.ts +0 -5
  4. package/dist/mdruntime/chain.d.ts +10 -0
  5. package/dist/mdruntime/change-set.d.ts +6 -16
  6. package/dist/mdruntime/change.d.ts +31 -1
  7. package/dist/mdruntime/client.d.ts +9 -5
  8. package/dist/mdruntime/collection.d.ts +10 -22
  9. package/dist/mdruntime/compile.d.ts +15 -0
  10. package/dist/mdruntime/connection.d.ts +17 -10
  11. package/dist/mdruntime/conversation.d.ts +9 -6
  12. package/dist/mdruntime/durability.d.ts +2 -5
  13. package/dist/mdruntime/fulltext.d.ts +26 -0
  14. package/dist/mdruntime/identity.d.ts +6 -0
  15. package/dist/mdruntime/media.d.ts +7 -0
  16. package/dist/mdruntime/messages.d.ts +27 -0
  17. package/dist/mdruntime/model.d.ts +6 -1
  18. package/dist/mdruntime/observation.d.ts +13 -0
  19. package/dist/mdruntime/opened.d.ts +21 -0
  20. package/dist/mdruntime/outcome.d.ts +40 -8
  21. package/dist/mdruntime/overlay.d.ts +1 -4
  22. package/dist/mdruntime/query.d.ts +11 -1
  23. package/dist/mdruntime/reach.d.ts +13 -4
  24. package/dist/mdruntime/readiness.d.ts +14 -15
  25. package/dist/mdruntime/recovery.d.ts +3 -2
  26. package/dist/mdruntime/replica.d.ts +55 -39
  27. package/dist/mdruntime/room-draft.d.ts +21 -3
  28. package/dist/mdruntime/save.d.ts +51 -14
  29. package/dist/mdruntime/search.d.ts +11 -43
  30. package/dist/mdruntime/status.d.ts +4 -3
  31. package/dist/mdruntime/store.d.ts +80 -103
  32. package/dist/mdruntime/stored.d.ts +129 -0
  33. package/dist/mdruntime/tables.d.ts +324 -0
  34. package/dist/mdruntime/wire.d.ts +17 -1
  35. package/dist/records.d.ts.map +1 -1
  36. package/dist/records.js +55 -22
  37. package/package.json +8 -3
  38. package/dist/mdruntime/file.d.ts +0 -19
  39. package/dist/mdruntime/rows.d.ts +0 -38
  40. package/dist/mdruntime/shared.d.ts +0 -14
  41. package/dist/mdruntime/transfer.d.ts +0 -9
  42. package/dist/mdruntime/turn.d.ts +0 -8
package/README.md CHANGED
@@ -45,10 +45,12 @@ the Room; a list asked for without a page reads every record, window by
45
45
  window. react-admin's `update` writes the fields
46
46
  that differ from `previousData`, based on it, so the Save of a field another
47
47
  writer changed meanwhile is refused; Refine's `update` and either `updateMany`
48
- compare with the stored record. A list stays current: react-admin's queries of
49
- a resource are invalidated, and Refine's live mode refetches, when a record a
50
- page or a read shows changes, a record a filter names starts or stops matching
51
- it, or a page's total changes.
48
+ compare with the stored record. A Room the Runtime holds locked is left out of
49
+ every list, and a read or a write of a record in it rejects with the code
50
+ `room-locked`. A list stays current: react-admin's queries of a resource are
51
+ invalidated, and Refine's live mode refetches, when a record a page or a read
52
+ shows changes, a record a filter names starts or stops matching it, a page's
53
+ total changes, or a Room the list left out as locked unlocks.
52
54
 
53
55
  ## License
54
56
 
@@ -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 = {
@@ -199,6 +200,7 @@ export type ActionDeclaration = {
199
200
  name: string;
200
201
  inputShape: unknown;
201
202
  resultKind: unknown;
203
+ room?: string;
202
204
  };
203
205
  export type ProviderLimit = {
204
206
  name: string;
@@ -245,7 +247,7 @@ export type ProviderRefusal = {
245
247
  export type ScopedRefusal = ProviderRefusal & {
246
248
  kind: 'scoped-refusal';
247
249
  locator: string;
248
- scope: Open<'content' | 'sync' | 'model' | 'operation' | 'undisclosed'>;
250
+ scope: Open<'content' | 'model' | 'operation' | 'undisclosed'>;
249
251
  };
250
252
  export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
251
253
  export type ContractUnavailable = ProviderRefusal & {
@@ -254,7 +256,7 @@ export type ContractUnavailable = ProviderRefusal & {
254
256
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
255
257
  export type PageToken = string;
256
258
  export type ChangeAuthor = {
257
- kind: Open<'user' | 'site'>;
259
+ kind: Open<'user' | 'site' | 'inbox' | 'app'>;
258
260
  id: string;
259
261
  name: string;
260
262
  };
@@ -268,24 +270,34 @@ export type HeadChange = {
268
270
  time: string;
269
271
  };
270
272
  export type BinaryFile = {
271
- fileRef: string;
272
273
  byteLength: number;
273
274
  mediaType: string;
274
275
  sha256: string;
275
276
  };
277
+ export type HeldFile = {
278
+ readonly path: string;
279
+ readonly revision: string;
280
+ };
276
281
  export type HeldContent = {
277
- documents: Readonly<Record<string, string>>;
278
- 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
+ }>>;
279
287
  };
280
288
  export type BootstrapRequest = {
281
289
  locator: string;
282
290
  selection: string;
283
291
  pageToken?: PageToken;
284
292
  held?: HeldContent;
293
+ arriving?: (bytes: number) => void;
294
+ signal?: AbortSignal;
295
+ };
296
+ export type BootstrapInventory = {
297
+ readonly bytes: number;
285
298
  };
286
299
  export type RoomModels = {
287
300
  collection?: ModelResult;
288
- selection?: ModelResult;
289
301
  };
290
302
  export type BootstrapPage = {
291
303
  kind: 'bootstrap';
@@ -296,7 +308,9 @@ export type BootstrapPage = {
296
308
  fileIds?: Readonly<Record<string, string>>;
297
309
  changes: Readonly<Record<string, HeadChange>>;
298
310
  binaryFiles: Readonly<Record<string, BinaryFile>>;
311
+ folders?: readonly string[];
299
312
  pageToken?: PageToken;
313
+ bytes?: number;
300
314
  };
301
315
  export type BootstrapResult = BootstrapPage | {
302
316
  kind: 'beyond-horizon';
@@ -317,6 +331,8 @@ export type RefreshPage = {
317
331
  changes: Readonly<Record<string, HeadChange>>;
318
332
  binaryFiles: Readonly<Record<string, BinaryFile>>;
319
333
  removals: readonly string[];
334
+ folders?: readonly string[];
335
+ folderRemovals?: readonly string[];
320
336
  pageToken?: PageToken;
321
337
  };
322
338
  export type RefreshResult = {
@@ -327,6 +343,7 @@ export type RefreshResult = {
327
343
  export type MutationRequest = {
328
344
  locator: string;
329
345
  changeBatch: ChangeBatch;
346
+ file(localId: string): Promise<Blob>;
330
347
  upload?: unknown;
331
348
  };
332
349
  export type RetryableRefusal = ProviderRefusal & {
@@ -337,8 +354,7 @@ export type ServiceMode = Open<'open' | 'write-halted'>;
337
354
  export type ServiceModeSignal = {
338
355
  observe(notify: (mode: ServiceMode) => void): () => void;
339
356
  };
340
- export type MutationResult = {
341
- kind: 'accepted';
357
+ export type AcceptedRoom = {
342
358
  roomVersion: string;
343
359
  documents: Readonly<Record<string, string>>;
344
360
  revisions: Readonly<Record<string, string>>;
@@ -346,9 +362,13 @@ export type MutationResult = {
346
362
  changes: Readonly<Record<string, HeadChange>>;
347
363
  removals: readonly string[];
348
364
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
365
+ };
366
+ export type MutationResult = (AcceptedRoom & {
367
+ kind: 'accepted';
349
368
  author?: string;
350
369
  time?: string;
351
- } | (ProviderRefusal & {
370
+ destination?: AcceptedRoom;
371
+ }) | (ProviderRefusal & {
352
372
  kind: 'conflicted';
353
373
  roomVersion?: string;
354
374
  affected: Readonly<Record<string, string>>;
@@ -365,7 +385,7 @@ export type HistoryAuthor = {
365
385
  kind: 'user';
366
386
  id: string;
367
387
  } | {
368
- kind: 'site';
388
+ kind: 'site' | 'inbox' | 'app';
369
389
  id: string;
370
390
  name: string;
371
391
  };
@@ -397,22 +417,12 @@ export type BinaryRequest = {
397
417
  locator: string;
398
418
  path: string;
399
419
  revision: string;
400
- fileRef?: string;
401
- } | {
402
- kind: 'reference';
403
- fileRef: string;
404
- referrer: unknown;
405
- };
406
- export type ReferrerScope = {
407
- kind: 'room';
408
- locator: string;
409
- path?: string;
410
- } | {
411
- kind: 'conversations';
412
420
  };
413
421
  export type BinaryResult = {
414
422
  kind: 'binary';
415
- blob: Blob;
423
+ body: ReadableStream<Uint8Array>;
424
+ mediaType: string;
425
+ sha256?: string;
416
426
  } | (ProviderRefusal & {
417
427
  kind: 'rejected';
418
428
  }) | AdapterFailure;
@@ -420,6 +430,22 @@ export type BinaryLinkResult = {
420
430
  kind: 'link';
421
431
  url: string;
422
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;
443
+ blob: Blob;
444
+ };
445
+ export type AttachResult = {
446
+ kind: 'attached';
447
+ path: string;
448
+ revision: string;
423
449
  } | (ProviderRefusal & {
424
450
  kind: 'rejected';
425
451
  }) | AdapterFailure;
@@ -441,8 +467,13 @@ export type ActionResult = {
441
467
  export type HeldRoom = {
442
468
  locator: string;
443
469
  roomVersion: string;
444
- documents: Readonly<Record<string, string>>;
445
- revisions: Readonly<Record<string, string>>;
470
+ };
471
+ export type RoomChange = {
472
+ kind: 'room-change';
473
+ locator: string;
474
+ from: string;
475
+ roomVersion: string;
476
+ read(): Promise<RefreshPage>;
446
477
  };
447
478
  export type RoomStreamEvent = {
448
479
  kind: 'opened';
@@ -456,44 +487,26 @@ export type RoomStreamEvent = {
456
487
  } | {
457
488
  kind: 'authority-changed';
458
489
  scope?: DiscoveryScope;
459
- } | {
460
- kind: 'room-version';
461
- locator: string;
462
- roomVersion: string;
463
- };
464
- export type KeptReceipt = {
465
- key: string;
466
- head: unknown;
467
- };
468
- export type StreamReceipts = {
469
- heads(): Promise<readonly KeptReceipt[]>;
470
- parts(key: string, count: number): Promise<readonly unknown[]>;
471
- keep(key: string, head: unknown, part?: {
472
- index: number;
473
- value: unknown;
474
- }): Promise<void>;
475
- drop(keys: readonly string[]): Promise<void>;
476
- };
490
+ } | RoomChange;
477
491
  export type RoomStream = {
478
492
  hold(rooms: readonly HeldRoom[]): void;
479
493
  reopen(): void;
480
- published(locator: string, roomVersion: string): void;
481
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
494
+ observe(notify: (event: RoomStreamEvent) => void): () => void;
482
495
  };
483
496
  export type Adapter = {
484
497
  readonly localSaves?: true;
485
498
  readonly exhaustiveDiscovery?: true;
499
+ readonly roomTypes?: string;
500
+ readonly nameableRoomTypes?: readonly string[];
486
501
  authorize(): Promise<Authorization>;
487
502
  discover(authorization: Authorization, scope?: DiscoveryScope): Promise<DiscoverResult>;
488
503
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
489
- refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
504
+ refresh?(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
490
505
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
491
506
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
492
507
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
493
- link(authorization: Authorization, request: Extract<BinaryRequest, {
494
- kind: 'path';
495
- }>): Promise<BinaryLinkResult>;
496
- referrerScope(referrer: unknown): ReferrerScope | null;
508
+ link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
509
+ attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
497
510
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
498
511
  reached(locator: string, roomVersion: string, target: string): boolean;
499
512
  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,18 +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
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
22
  };
32
- export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: Changed): ChangeSet;
33
- export declare function changing(locator: string, before: Replica | null, after: Replica | null, changed?: Changed): Generator<number, ChangeSet, void>;
34
- export declare function entering(locator: string, replica: Replica, paths: readonly string[]): ChangeSet;
35
- export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
23
+ export declare function changeSet(locator: string, changed?: Changed): ChangeSet;
24
+ export declare function conversationChangeSet(conversations: readonly string[]): ChangeSet;
36
25
  export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
26
+ export declare function touches(set: ChangeSet, locator: string, path: string): boolean;
37
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 {};
@@ -2,8 +2,7 @@ import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts,
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, BinaryLinkAnswer, 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,7 +20,7 @@ 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>;
@@ -48,16 +47,18 @@ export type MdRuntimeClient = {
48
47
  discard(conversation: string): Promise<void>;
49
48
  };
50
49
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
50
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
51
51
  binaryFile: {
52
52
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
53
- link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
54
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
53
+ attach(room: string, file: File): Promise<AttachAnswer>;
54
+ download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
55
55
  };
56
56
  call(name: string, input: unknown): Promise<CallResult>;
57
57
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
58
58
  log(): Promise<string>;
59
59
  persistence(): Promise<boolean>;
60
60
  retry(): Promise<void>;
61
+ cleanUp(): Promise<number>;
61
62
  observe: {
62
63
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
63
64
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -81,6 +82,9 @@ export type MdRuntimeClient = {
81
82
  };
82
83
  export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
83
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';
84
88
  export type { Observation } from './observation.js';
85
89
  export type { Open } from './open.js';
86
90
  export { unanswered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,9 +1,6 @@
1
- import { type Document, type Frontmatter, type Validation } from '@agentshouse/mdmodel';
2
- import { type ModelState } from './model.js';
1
+ import { type Document } from '@agentshouse/mdmodel';
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,23 +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 collecting(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Generator<number, Collection, void>;
23
- export declare function passingFrontmatter(collection: Collection, path: string): Frontmatter | undefined;
24
- export declare function documentsOf(collection: Collection): Generator<readonly [string, Document]>;
25
- export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Generator<number, Refused | null, void>;
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>;
26
26
  export declare function validRoot(root: unknown): root is string;
27
- export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Generator<number, Validation, void>;
28
- type Held = {
29
- text: Paths<string>;
30
- binaries: Paths<unknown>;
31
- };
32
- export declare function indexReferrers(held: Held, composition: Composition): Later<void>;
33
- export declare function referencesIndexed(held: Held, composition: Composition): boolean;
34
- export declare function referring(held: Held, composition: Composition, targets: Iterable<string>): ReadonlySet<string> | null;
35
27
  export declare function available(composition: Composition): boolean;
36
- export declare function changedCleanly(next: Held, previous: Held & {
37
- composition: Composition;
38
- }, composition: Composition): Generator<number, boolean, void>;
39
- 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,14 +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 BinaryLinkAnswer, 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
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 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';
18
18
  import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
19
19
  export type AppTypedSelection = {
20
20
  roots: readonly string[];
@@ -33,6 +33,7 @@ export type AppRoom = {
33
33
  documents: number;
34
34
  synchronizationAvailable: boolean;
35
35
  refusal: ProviderRefusal | null;
36
+ locked: boolean;
36
37
  };
37
38
  export type RoomSchemas = {
38
39
  collection: TypesResult;
@@ -49,9 +50,11 @@ export type ConnectionRefusal = {
49
50
  export type MdRuntimeOptions = {
50
51
  adapter: Adapter;
51
52
  shell: RuntimeShell;
53
+ database: RuntimeDatabase;
52
54
  authorization?: Authorization;
53
55
  signal?: AbortSignal;
54
56
  recovery?: Recovery;
57
+ usableWhenHeld?: readonly string[];
55
58
  };
56
59
  export type SaveResult = {
57
60
  outcome: 'saved';
@@ -69,8 +72,8 @@ export type SavedParts = {
69
72
  };
70
73
  export type RoomDraftSurface = {
71
74
  list(): Promise<readonly RoomDraft[]>;
72
- read(room: string, path: string): RoomDraft | null;
73
- 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>;
74
77
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
75
78
  };
76
79
  export type PresentationSurface = {
@@ -79,9 +82,11 @@ export type PresentationSurface = {
79
82
  edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
80
83
  };
81
84
  export type BinaryFileSurface = {
82
- read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
85
+ read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
83
86
  link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
84
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
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>;
85
90
  };
86
91
  export type HistoryQuery = {
87
92
  revision?: string;
@@ -89,7 +94,7 @@ export type HistoryQuery = {
89
94
  };
90
95
  export type MdRuntime = {
91
96
  loaded(): Promise<void>;
92
- rooms(): readonly AppRoom[];
97
+ rooms(): Promise<readonly AppRoom[]>;
93
98
  query: {
94
99
  (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
95
100
  (query: GroupQuery): Promise<GroupResult | PendingResult>;
@@ -103,12 +108,14 @@ export type MdRuntime = {
103
108
  save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
104
109
  saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
105
110
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
111
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
106
112
  binaryFile: BinaryFileSurface;
107
113
  call(name: string, input: unknown): Promise<CallResult>;
108
- reached(locator: string, roomVersion: string, path?: string): boolean;
114
+ reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
109
115
  log(): string;
110
116
  persistence(): boolean;
111
117
  retry(): Promise<void>;
118
+ cleanUp(): Promise<number>;
112
119
  observe: {
113
120
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
114
121
  (topic: 'readiness'): Promise<Observation<Readiness>>;
@@ -132,7 +139,7 @@ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'stora
132
139
  export type ReadinessPort = {
133
140
  readonly target: string;
134
141
  readonly code: CodeAvailability;
135
- readonly capacity: CapacityCause | null;
142
+ readonly space: Space | null;
136
143
  readonly search: SearchObligation;
137
144
  };
138
145
  export type ComposedRuntime = RuntimeView & {