@agentshouse/mdruntime-families 0.1.0-cf63e048166bf → 0.1.0-cff4656bdc271

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 (36) hide show
  1. package/README.md +6 -4
  2. package/dist/mdruntime/adapter.d.ts +30 -15
  3. package/dist/mdruntime/chain.d.ts +10 -0
  4. package/dist/mdruntime/change-set.d.ts +6 -16
  5. package/dist/mdruntime/change.d.ts +31 -1
  6. package/dist/mdruntime/client.d.ts +6 -1
  7. package/dist/mdruntime/collection.d.ts +6 -20
  8. package/dist/mdruntime/compile.d.ts +15 -0
  9. package/dist/mdruntime/connection.d.ts +11 -5
  10. package/dist/mdruntime/conversation.d.ts +3 -3
  11. package/dist/mdruntime/durability.d.ts +2 -1
  12. package/dist/mdruntime/file.d.ts +2 -10
  13. package/dist/mdruntime/fulltext.d.ts +26 -0
  14. package/dist/mdruntime/messages.d.ts +27 -0
  15. package/dist/mdruntime/observation.d.ts +12 -0
  16. package/dist/mdruntime/opened.d.ts +21 -0
  17. package/dist/mdruntime/outcome.d.ts +29 -4
  18. package/dist/mdruntime/overlay.d.ts +1 -4
  19. package/dist/mdruntime/query.d.ts +5 -1
  20. package/dist/mdruntime/reach.d.ts +5 -1
  21. package/dist/mdruntime/readiness.d.ts +3 -3
  22. package/dist/mdruntime/recovery.d.ts +2 -2
  23. package/dist/mdruntime/replica.d.ts +55 -39
  24. package/dist/mdruntime/room-draft.d.ts +3 -1
  25. package/dist/mdruntime/save.d.ts +49 -14
  26. package/dist/mdruntime/search.d.ts +11 -43
  27. package/dist/mdruntime/shared.d.ts +4 -3
  28. package/dist/mdruntime/store.d.ts +79 -95
  29. package/dist/mdruntime/stored.d.ts +137 -0
  30. package/dist/mdruntime/tables.d.ts +331 -0
  31. package/dist/mdruntime/wire.d.ts +16 -0
  32. package/dist/records.d.ts.map +1 -1
  33. package/dist/records.js +55 -22
  34. package/package.json +2 -2
  35. package/dist/mdruntime/rows.d.ts +0 -38
  36. 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
 
@@ -16,6 +16,7 @@ export type OperationScopes = {
16
16
  export type ReplicaAdmission = {
17
17
  selection: string;
18
18
  admission: Open<'admitted' | 'unavailable'>;
19
+ offline: Open<'locked' | 'open'>;
19
20
  };
20
21
  export type DiscoveredRoom = {
21
22
  name: string;
@@ -49,7 +50,7 @@ export type ListedConversation = {
49
50
  outcome: string | null;
50
51
  waiting: boolean;
51
52
  };
52
- export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
53
+ export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.attach' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
53
54
  export type ConversationMessage = {
54
55
  identity: string;
55
56
  turn: string;
@@ -198,6 +199,7 @@ export type ActionDeclaration = {
198
199
  name: string;
199
200
  inputShape: unknown;
200
201
  resultKind: unknown;
202
+ room?: string;
201
203
  };
202
204
  export type ProviderLimit = {
203
205
  name: string;
@@ -253,7 +255,7 @@ export type ContractUnavailable = ProviderRefusal & {
253
255
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
254
256
  export type PageToken = string;
255
257
  export type ChangeAuthor = {
256
- kind: Open<'user' | 'site'>;
258
+ kind: Open<'user' | 'site' | 'inbox'>;
257
259
  id: string;
258
260
  name: string;
259
261
  };
@@ -272,9 +274,16 @@ export type BinaryFile = {
272
274
  mediaType: string;
273
275
  sha256: string;
274
276
  };
277
+ export type HeldFile = {
278
+ readonly path: string;
279
+ readonly revision: string;
280
+ };
275
281
  export type HeldContent = {
276
- documents: Readonly<Record<string, string>>;
277
- 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
+ }>>;
278
287
  };
279
288
  export type BootstrapRequest = {
280
289
  locator: string;
@@ -295,6 +304,7 @@ export type BootstrapPage = {
295
304
  fileIds?: Readonly<Record<string, string>>;
296
305
  changes: Readonly<Record<string, HeadChange>>;
297
306
  binaryFiles: Readonly<Record<string, BinaryFile>>;
307
+ folders?: readonly string[];
298
308
  pageToken?: PageToken;
299
309
  };
300
310
  export type BootstrapResult = BootstrapPage | {
@@ -316,6 +326,8 @@ export type RefreshPage = {
316
326
  changes: Readonly<Record<string, HeadChange>>;
317
327
  binaryFiles: Readonly<Record<string, BinaryFile>>;
318
328
  removals: readonly string[];
329
+ folders?: readonly string[];
330
+ folderRemovals?: readonly string[];
319
331
  pageToken?: PageToken;
320
332
  };
321
333
  export type RefreshResult = {
@@ -326,6 +338,7 @@ export type RefreshResult = {
326
338
  export type MutationRequest = {
327
339
  locator: string;
328
340
  changeBatch: ChangeBatch;
341
+ file(localId: string): Promise<Blob>;
329
342
  upload?: unknown;
330
343
  };
331
344
  export type RetryableRefusal = ProviderRefusal & {
@@ -336,8 +349,7 @@ export type ServiceMode = Open<'open' | 'write-halted'>;
336
349
  export type ServiceModeSignal = {
337
350
  observe(notify: (mode: ServiceMode) => void): () => void;
338
351
  };
339
- export type MutationResult = {
340
- kind: 'accepted';
352
+ export type AcceptedRoom = {
341
353
  roomVersion: string;
342
354
  documents: Readonly<Record<string, string>>;
343
355
  revisions: Readonly<Record<string, string>>;
@@ -345,9 +357,13 @@ export type MutationResult = {
345
357
  changes: Readonly<Record<string, HeadChange>>;
346
358
  removals: readonly string[];
347
359
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
360
+ };
361
+ export type MutationResult = (AcceptedRoom & {
362
+ kind: 'accepted';
348
363
  author?: string;
349
364
  time?: string;
350
- } | (ProviderRefusal & {
365
+ destination?: AcceptedRoom;
366
+ }) | (ProviderRefusal & {
351
367
  kind: 'conflicted';
352
368
  roomVersion?: string;
353
369
  affected: Readonly<Record<string, string>>;
@@ -364,7 +380,7 @@ export type HistoryAuthor = {
364
380
  kind: 'user';
365
381
  id: string;
366
382
  } | {
367
- kind: 'site';
383
+ kind: 'site' | 'inbox';
368
384
  id: string;
369
385
  name: string;
370
386
  };
@@ -403,15 +419,14 @@ export type BinaryRequest = {
403
419
  referrer: unknown;
404
420
  };
405
421
  export type ReferrerScope = {
406
- kind: 'room';
407
422
  locator: string;
408
423
  path?: string;
409
- } | {
410
- kind: 'conversations';
411
424
  };
412
425
  export type BinaryResult = {
413
426
  kind: 'binary';
414
- blob: Blob;
427
+ body: ReadableStream<Uint8Array>;
428
+ mediaType: string;
429
+ sha256?: string;
415
430
  } | (ProviderRefusal & {
416
431
  kind: 'rejected';
417
432
  }) | AdapterFailure;
@@ -440,9 +455,8 @@ export type ActionResult = {
440
455
  export type HeldRoom = {
441
456
  locator: string;
442
457
  roomVersion: string;
443
- documents: Readonly<Record<string, string>>;
444
- revisions: Readonly<Record<string, string>>;
445
458
  };
459
+ export type HeldRevisions = (locator: string, paths: readonly string[]) => Promise<ReadonlyMap<string, string>>;
446
460
  export type RoomStreamEvent = {
447
461
  kind: 'opened';
448
462
  } | {
@@ -477,11 +491,12 @@ export type RoomStream = {
477
491
  hold(rooms: readonly HeldRoom[]): void;
478
492
  reopen(): void;
479
493
  published(locator: string, roomVersion: string): void;
480
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
494
+ observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts, revisions: HeldRevisions): () => void;
481
495
  };
482
496
  export type Adapter = {
483
497
  readonly localSaves?: true;
484
498
  readonly exhaustiveDiscovery?: true;
499
+ readonly roomTypes?: string;
485
500
  authorize(): Promise<Authorization>;
486
501
  discover(authorization: Authorization, scope?: DiscoveryScope): Promise<DiscoverResult>;
487
502
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
@@ -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 {};
@@ -3,7 +3,8 @@ 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
5
  import type { BinaryReference } from './binary.js';
6
- import type { BinaryAnswer, BinaryLinkAnswer, CallResult, HistoryAnswer, Offline, QueueEntry } from './outcome.js';
6
+ import type { ChosenFile } from './file.js';
7
+ import type { BinaryAnswer, BinaryLinkAnswer, CallResult, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
7
8
  import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
8
9
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
9
10
  import type { SearchRequest, SearchResult } from './search.js';
@@ -36,6 +37,7 @@ export type MdRuntimeClient = {
36
37
  read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
37
38
  create(input: unknown): Promise<CallResult>;
38
39
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
40
+ attach(room: string, file: ChosenFile): Promise<CallResult | Offline>;
39
41
  answer(conversation: string, answer: unknown): Promise<CallResult>;
40
42
  interrupt(conversation: string): Promise<CallResult>;
41
43
  kill(conversation: string): Promise<CallResult>;
@@ -48,6 +50,7 @@ export type MdRuntimeClient = {
48
50
  discard(conversation: string): Promise<void>;
49
51
  };
50
52
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
53
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
51
54
  binaryFile: {
52
55
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
53
56
  link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
@@ -58,6 +61,7 @@ export type MdRuntimeClient = {
58
61
  log(): Promise<string>;
59
62
  persistence(): Promise<boolean>;
60
63
  retry(): Promise<void>;
64
+ cleanUp(): Promise<number>;
61
65
  observe: {
62
66
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
63
67
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -81,6 +85,7 @@ export type MdRuntimeClient = {
81
85
  };
82
86
  export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
83
87
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
88
+ export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
84
89
  export type { Observation } from './observation.js';
85
90
  export type { Open } from './open.js';
86
91
  export { unanswered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,9 +1,8 @@
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
4
  import { type Paths } from './shared.js';
5
5
  import type { Refused } from './transfer.js';
6
- import { type Later } from './turn.js';
7
6
  export declare const MD_MODEL: MdModelIdentity;
8
7
  export type Collection = {
9
8
  text: Readonly<Record<string, string>>;
@@ -17,23 +16,10 @@ export type Composition = {
17
16
  model: ModelState;
18
17
  } | null;
19
18
  };
19
+ export declare function selected(composition: Composition, path: string): boolean;
20
20
  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>;
21
+ export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
22
+ 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>;
26
24
  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
25
  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;
@@ -8,13 +8,14 @@ import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry,
8
8
  import { type WrittenBy } from './change.js';
9
9
  import type { Open } from './open.js';
10
10
  import { type BinaryReference } from './binary.js';
11
- import { type BinaryAnswer, type BinaryLinkAnswer, type CallResult, type HistoryAnswer, type QueueEntry } from './outcome.js';
11
+ import { type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
12
12
  import { type Recovery } from './recovery.js';
13
13
  import { type SaveRefusal } from './save.js';
14
14
  import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
15
15
  import { type SyncStatus } from './status.js';
16
16
  import { type RuntimeShell } from './durability.js';
17
17
  import { type CapacityCause, type CodeAvailability, type Persistence, type Readiness, type SearchObligation } from './readiness.js';
18
+ import type { RuntimeDatabase } from './tables.js';
18
19
  import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
19
20
  export type AppTypedSelection = {
20
21
  roots: readonly string[];
@@ -33,6 +34,7 @@ export type AppRoom = {
33
34
  documents: number;
34
35
  synchronizationAvailable: boolean;
35
36
  refusal: ProviderRefusal | null;
37
+ locked: boolean;
36
38
  };
37
39
  export type RoomSchemas = {
38
40
  collection: TypesResult;
@@ -49,6 +51,7 @@ export type ConnectionRefusal = {
49
51
  export type MdRuntimeOptions = {
50
52
  adapter: Adapter;
51
53
  shell: RuntimeShell;
54
+ database: RuntimeDatabase;
52
55
  authorization?: Authorization;
53
56
  signal?: AbortSignal;
54
57
  recovery?: Recovery;
@@ -69,7 +72,7 @@ export type SavedParts = {
69
72
  };
70
73
  export type RoomDraftSurface = {
71
74
  list(): Promise<readonly RoomDraft[]>;
72
- read(room: string, path: string): RoomDraft | null;
75
+ read(room: string, path: string): Promise<RoomDraft | null>;
73
76
  write(room: string, path: string, revision: string | null, parts: unknown): Promise<RoomDraftWrite>;
74
77
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
75
78
  };
@@ -79,9 +82,10 @@ 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
+ readReference(reference: BinaryReference): Promise<HeldBinaryAnswer>;
88
+ part(file: string, part: number): Promise<Uint8Array | null>;
85
89
  };
86
90
  export type HistoryQuery = {
87
91
  revision?: string;
@@ -103,12 +107,14 @@ export type MdRuntime = {
103
107
  save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
104
108
  saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
105
109
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
110
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
106
111
  binaryFile: BinaryFileSurface;
107
112
  call(name: string, input: unknown): Promise<CallResult>;
108
- reached(locator: string, roomVersion: string, path?: string): boolean;
113
+ reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
109
114
  log(): string;
110
115
  persistence(): boolean;
111
116
  retry(): Promise<void>;
117
+ cleanUp(): Promise<number>;
112
118
  observe: {
113
119
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
114
120
  (topic: 'readiness'): Promise<Observation<Readiness>>;
@@ -1,6 +1,6 @@
1
1
  import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
2
2
  import { type ChangeSet } from './change-set.js';
3
- import { type ChatDraftFile } from './file.js';
3
+ import { type ChosenFile } from './file.js';
4
4
  import type { Open } from './open.js';
5
5
  import { type CallResult, type Offline } from './outcome.js';
6
6
  import type { DocumentResult, PendingResult } from './query.js';
@@ -33,7 +33,6 @@ export type RunningTurn = {
33
33
  };
34
34
  export type ChatDraft = {
35
35
  text: string;
36
- files: readonly ChatDraftFile[];
37
36
  };
38
37
  export type ConversationOptions = {
39
38
  limit?: number;
@@ -66,6 +65,7 @@ export type ConversationSurface = {
66
65
  read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
67
66
  create(input: unknown): Promise<CallResult>;
68
67
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
68
+ attach(room: string, file: ChosenFile): Promise<CallResult | Offline>;
69
69
  answer(conversation: string, answer: unknown): Promise<CallResult>;
70
70
  interrupt(conversation: string): Promise<CallResult>;
71
71
  kill(conversation: string): Promise<CallResult>;
@@ -79,7 +79,7 @@ export type ChatDraftSurface = {
79
79
  };
80
80
  export type ConversationDependencies = {
81
81
  agents(): ConversationAgents | undefined;
82
- documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
82
+ documents(agents: ConversationAgents, after: string | undefined): Promise<DocumentResult | PendingResult>;
83
83
  call(name: ConversationAction, input: unknown): Promise<CallResult>;
84
84
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
85
85
  stream(): ConversationStream | undefined;
@@ -1,7 +1,7 @@
1
1
  import type { Persistence } from './readiness.js';
2
2
  export type StorageEstimate = {
3
3
  readonly usage: number;
4
- readonly quota: number;
4
+ readonly total: number;
5
5
  };
6
6
  export type RuntimeShell = {
7
7
  persistence: Persistence;
@@ -9,6 +9,7 @@ export type RuntimeShell = {
9
9
  keepGeneration(value: string): void | Promise<void>;
10
10
  dropGeneration(): void | Promise<void>;
11
11
  estimate?(): Promise<StorageEstimate | null>;
12
+ cleanUp?(): Promise<number>;
12
13
  };
13
14
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
14
15
  export declare function nextGeneration(stored: string | null, reported: string | null): string;
@@ -1,4 +1,4 @@
1
- export type ChatDraftFile = {
1
+ export type ChosenFile = {
2
2
  name: string;
3
3
  blob: Blob;
4
4
  };
@@ -7,13 +7,5 @@ export type FileDeclaration = {
7
7
  mediaType: string;
8
8
  byteLength: number;
9
9
  contentHash: string;
10
- width?: number;
11
- height?: number;
12
10
  };
13
- export type Extent = {
14
- width: number;
15
- height: number;
16
- };
17
- export declare function extentOf(bytes: Uint8Array): Extent | null;
18
- export declare function hexDigest(digest: ArrayBuffer): string;
19
- export declare function declaredFile(file: ChatDraftFile): Promise<FileDeclaration>;
11
+ export declare function declaredFile(file: ChosenFile): Promise<FileDeclaration>;
@@ -0,0 +1,26 @@
1
+ import { type QueryRoom } from './compile.js';
2
+ import type { Plan } from './query.js';
3
+ import type { HitCursor, SearchWindow } from './search.js';
4
+ import type { Connection } from './tables.js';
5
+ export declare const SEARCH_TABLES: readonly string[];
6
+ export type SearchAsk = {
7
+ readonly text: string;
8
+ readonly limit: number;
9
+ readonly after: readonly [HitCursor, HitCursor] | null;
10
+ readonly total: boolean;
11
+ readonly documents: {
12
+ readonly plan: Plan;
13
+ readonly rooms: readonly QueryRoom[];
14
+ readonly beneath: readonly {
15
+ readonly key: number;
16
+ readonly roots: readonly string[];
17
+ }[];
18
+ } | null;
19
+ readonly conversations: readonly string[];
20
+ };
21
+ export declare function indexDocument(connection: Connection, id: number, path: string, content: string): void;
22
+ export declare function indexMessage(connection: Connection, id: number, text: string): void;
23
+ export declare function unindexDocuments(connection: Connection, ids: Iterable<number>): void;
24
+ export declare function unindexMessages(connection: Connection, ids: Iterable<number>): void;
25
+ export declare function unindexAll(connection: Connection): void;
26
+ export declare function searched(connection: Connection, ask: SearchAsk): SearchWindow;
@@ -0,0 +1,27 @@
1
+ import type { AcceptedMessage } from './adapter.js';
2
+ import type { Connection } from './tables.js';
3
+ export declare const MESSAGE_TABLES: readonly string[];
4
+ export type HeldConversation = {
5
+ readonly conversation: string;
6
+ readonly read: string | null | undefined;
7
+ readonly partial: boolean;
8
+ };
9
+ export type MessageWindow = {
10
+ readonly messages: AcceptedMessage[];
11
+ readonly more: boolean;
12
+ };
13
+ export type ConversationWrite = {
14
+ readonly conversation: string;
15
+ readonly messages: readonly AcceptedMessage[];
16
+ readonly read?: {
17
+ readonly at: string | null;
18
+ readonly partial: boolean;
19
+ };
20
+ };
21
+ export declare function heldConversations(connection: Connection): HeldConversation[];
22
+ export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
23
+ export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null): MessageWindow;
24
+ export declare function messageCount(connection: Connection, conversation: string): number;
25
+ export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
26
+ export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
27
+ export declare function forgottenMessages(connection: Connection): void;
@@ -29,3 +29,15 @@ export declare function applied(keyed: KeyedResult, message: QueryMessage): Keye
29
29
  export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
30
30
  export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
31
31
  export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
32
+ export type Digest = {
33
+ readonly pending: string;
34
+ } | {
35
+ readonly keys: readonly RowKey[];
36
+ readonly rows: ReadonlyMap<RowKey, number>;
37
+ readonly coverage: string;
38
+ readonly next: string | undefined;
39
+ readonly total: number | undefined;
40
+ };
41
+ export declare function digestOf({ result, keys }: KeyedResult): Digest;
42
+ export declare function digestApplied(digest: Digest, message: QueryMessage): Digest;
43
+ export declare function changeOf(previous: Digest, next: KeyedResult): QueryMessage | null;
@@ -0,0 +1,21 @@
1
+ import type { BinaryResult } from './adapter.js';
2
+ import { type RuntimeDatabase } from './tables.js';
3
+ export type OpenedName = {
4
+ readonly locator: string;
5
+ readonly path: string;
6
+ readonly revision: string;
7
+ };
8
+ export type KeptBinary = {
9
+ readonly kind: 'binary';
10
+ readonly file: string;
11
+ readonly byteLength: number;
12
+ readonly mediaType: string;
13
+ };
14
+ export type KeptResult = KeptBinary | Exclude<BinaryResult, {
15
+ kind: 'binary';
16
+ }>;
17
+ export type OpenedFiles = {
18
+ find(name: OpenedName): Promise<KeptBinary | null>;
19
+ fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
20
+ };
21
+ export declare function openedFiles(database: RuntimeDatabase, fenced: (locator: string) => boolean): OpenedFiles;