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

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 (38) hide show
  1. package/README.md +6 -4
  2. package/dist/mdruntime/adapter.d.ts +39 -29
  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 +8 -4
  8. package/dist/mdruntime/collection.d.ts +6 -20
  9. package/dist/mdruntime/compile.d.ts +15 -0
  10. package/dist/mdruntime/connection.d.ts +14 -9
  11. package/dist/mdruntime/conversation.d.ts +5 -3
  12. package/dist/mdruntime/durability.d.ts +3 -5
  13. package/dist/mdruntime/file.d.ts +2 -10
  14. package/dist/mdruntime/fulltext.d.ts +26 -0
  15. package/dist/mdruntime/identity.d.ts +6 -0
  16. package/dist/mdruntime/messages.d.ts +27 -0
  17. package/dist/mdruntime/observation.d.ts +12 -0
  18. package/dist/mdruntime/opened.d.ts +21 -0
  19. package/dist/mdruntime/outcome.d.ts +28 -4
  20. package/dist/mdruntime/overlay.d.ts +1 -4
  21. package/dist/mdruntime/query.d.ts +5 -1
  22. package/dist/mdruntime/reach.d.ts +5 -3
  23. package/dist/mdruntime/readiness.d.ts +20 -9
  24. package/dist/mdruntime/recovery.d.ts +2 -2
  25. package/dist/mdruntime/replica.d.ts +57 -39
  26. package/dist/mdruntime/room-draft.d.ts +4 -1
  27. package/dist/mdruntime/save.d.ts +49 -14
  28. package/dist/mdruntime/search.d.ts +11 -43
  29. package/dist/mdruntime/shared.d.ts +4 -3
  30. package/dist/mdruntime/store.d.ts +87 -94
  31. package/dist/mdruntime/stored.d.ts +144 -0
  32. package/dist/mdruntime/tables.d.ts +353 -0
  33. package/dist/mdruntime/wire.d.ts +13 -1
  34. package/dist/records.d.ts.map +1 -1
  35. package/dist/records.js +55 -22
  36. package/package.json +3 -3
  37. package/dist/mdruntime/rows.d.ts +0 -38
  38. 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
  };
@@ -267,20 +269,32 @@ export type HeadChange = {
267
269
  time: string;
268
270
  };
269
271
  export type BinaryFile = {
270
- fileRef: string;
271
272
  byteLength: number;
272
273
  mediaType: string;
273
274
  sha256: string;
274
275
  };
276
+ export type HeldFile = {
277
+ readonly path: string;
278
+ readonly revision: string;
279
+ };
275
280
  export type HeldContent = {
276
- documents: Readonly<Record<string, string>>;
277
- revisions: Readonly<Record<string, string>>;
281
+ files(after: string | null, limit: number): Promise<readonly HeldFile[]>;
282
+ contents(paths: readonly string[]): Promise<ReadonlyMap<string, {
283
+ readonly content: string;
284
+ readonly revision: string;
285
+ }>>;
278
286
  };
279
287
  export type BootstrapRequest = {
280
288
  locator: string;
281
289
  selection: string;
282
290
  pageToken?: PageToken;
283
291
  held?: HeldContent;
292
+ received?: Uint8Array;
293
+ arriving?: (bytes: number) => void;
294
+ };
295
+ export type BootstrapInventory = {
296
+ readonly parts: number;
297
+ readonly bytes: number;
284
298
  };
285
299
  export type RoomModels = {
286
300
  collection?: ModelResult;
@@ -295,7 +309,10 @@ export type BootstrapPage = {
295
309
  fileIds?: Readonly<Record<string, string>>;
296
310
  changes: Readonly<Record<string, HeadChange>>;
297
311
  binaryFiles: Readonly<Record<string, BinaryFile>>;
312
+ folders?: readonly string[];
298
313
  pageToken?: PageToken;
314
+ inventory?: BootstrapInventory;
315
+ received?: Uint8Array;
299
316
  };
300
317
  export type BootstrapResult = BootstrapPage | {
301
318
  kind: 'beyond-horizon';
@@ -316,6 +333,8 @@ export type RefreshPage = {
316
333
  changes: Readonly<Record<string, HeadChange>>;
317
334
  binaryFiles: Readonly<Record<string, BinaryFile>>;
318
335
  removals: readonly string[];
336
+ folders?: readonly string[];
337
+ folderRemovals?: readonly string[];
319
338
  pageToken?: PageToken;
320
339
  };
321
340
  export type RefreshResult = {
@@ -326,6 +345,7 @@ export type RefreshResult = {
326
345
  export type MutationRequest = {
327
346
  locator: string;
328
347
  changeBatch: ChangeBatch;
348
+ file(localId: string): Promise<Blob>;
329
349
  upload?: unknown;
330
350
  };
331
351
  export type RetryableRefusal = ProviderRefusal & {
@@ -336,8 +356,7 @@ export type ServiceMode = Open<'open' | 'write-halted'>;
336
356
  export type ServiceModeSignal = {
337
357
  observe(notify: (mode: ServiceMode) => void): () => void;
338
358
  };
339
- export type MutationResult = {
340
- kind: 'accepted';
359
+ export type AcceptedRoom = {
341
360
  roomVersion: string;
342
361
  documents: Readonly<Record<string, string>>;
343
362
  revisions: Readonly<Record<string, string>>;
@@ -345,9 +364,13 @@ export type MutationResult = {
345
364
  changes: Readonly<Record<string, HeadChange>>;
346
365
  removals: readonly string[];
347
366
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
367
+ };
368
+ export type MutationResult = (AcceptedRoom & {
369
+ kind: 'accepted';
348
370
  author?: string;
349
371
  time?: string;
350
- } | (ProviderRefusal & {
372
+ destination?: AcceptedRoom;
373
+ }) | (ProviderRefusal & {
351
374
  kind: 'conflicted';
352
375
  roomVersion?: string;
353
376
  affected: Readonly<Record<string, string>>;
@@ -364,7 +387,7 @@ export type HistoryAuthor = {
364
387
  kind: 'user';
365
388
  id: string;
366
389
  } | {
367
- kind: 'site';
390
+ kind: 'site' | 'inbox';
368
391
  id: string;
369
392
  name: string;
370
393
  };
@@ -396,22 +419,12 @@ export type BinaryRequest = {
396
419
  locator: string;
397
420
  path: string;
398
421
  revision: string;
399
- fileRef?: string;
400
- } | {
401
- kind: 'reference';
402
- fileRef: string;
403
- referrer: unknown;
404
- };
405
- export type ReferrerScope = {
406
- kind: 'room';
407
- locator: string;
408
- path?: string;
409
- } | {
410
- kind: 'conversations';
411
422
  };
412
423
  export type BinaryResult = {
413
424
  kind: 'binary';
414
- blob: Blob;
425
+ body: ReadableStream<Uint8Array>;
426
+ mediaType: string;
427
+ sha256?: string;
415
428
  } | (ProviderRefusal & {
416
429
  kind: 'rejected';
417
430
  }) | AdapterFailure;
@@ -440,9 +453,8 @@ export type ActionResult = {
440
453
  export type HeldRoom = {
441
454
  locator: string;
442
455
  roomVersion: string;
443
- documents: Readonly<Record<string, string>>;
444
- revisions: Readonly<Record<string, string>>;
445
456
  };
457
+ export type HeldRevisions = (locator: string, paths: readonly string[]) => Promise<ReadonlyMap<string, string>>;
446
458
  export type RoomStreamEvent = {
447
459
  kind: 'opened';
448
460
  } | {
@@ -477,11 +489,12 @@ export type RoomStream = {
477
489
  hold(rooms: readonly HeldRoom[]): void;
478
490
  reopen(): void;
479
491
  published(locator: string, roomVersion: string): void;
480
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
492
+ observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts, revisions: HeldRevisions): () => void;
481
493
  };
482
494
  export type Adapter = {
483
495
  readonly localSaves?: true;
484
496
  readonly exhaustiveDiscovery?: true;
497
+ readonly roomTypes?: string;
485
498
  authorize(): Promise<Authorization>;
486
499
  discover(authorization: Authorization, scope?: DiscoveryScope): Promise<DiscoverResult>;
487
500
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
@@ -489,10 +502,7 @@ export type Adapter = {
489
502
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
490
503
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
491
504
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
492
- link(authorization: Authorization, request: Extract<BinaryRequest, {
493
- kind: 'path';
494
- }>): Promise<BinaryLinkResult>;
495
- referrerScope(referrer: unknown): ReferrerScope | null;
505
+ link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
496
506
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
497
507
  reached(locator: string, roomVersion: string, target: string): boolean;
498
508
  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,8 @@ 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 { ChosenFile } from './file.js';
6
+ import type { BinaryAnswer, BinaryLinkAnswer, CallResult, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
7
7
  import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
8
8
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
9
9
  import type { SearchRequest, SearchResult } from './search.js';
@@ -21,7 +21,7 @@ export type MdRuntimeClient = {
21
21
  roomDraft: {
22
22
  list(): Promise<readonly RoomDraft[]>;
23
23
  read(room: string, path: string): Promise<RoomDraft | null>;
24
- write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
24
+ write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
25
25
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
26
26
  };
27
27
  save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
@@ -36,6 +36,7 @@ export type MdRuntimeClient = {
36
36
  read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
37
37
  create(input: unknown): Promise<CallResult>;
38
38
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
39
+ attach(room: string, file: ChosenFile): Promise<CallResult | Offline>;
39
40
  answer(conversation: string, answer: unknown): Promise<CallResult>;
40
41
  interrupt(conversation: string): Promise<CallResult>;
41
42
  kill(conversation: string): Promise<CallResult>;
@@ -48,16 +49,17 @@ export type MdRuntimeClient = {
48
49
  discard(conversation: string): Promise<void>;
49
50
  };
50
51
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
52
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
51
53
  binaryFile: {
52
54
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
53
55
  link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
54
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
55
56
  };
56
57
  call(name: string, input: unknown): Promise<CallResult>;
57
58
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
58
59
  log(): Promise<string>;
59
60
  persistence(): Promise<boolean>;
60
61
  retry(): Promise<void>;
62
+ cleanUp(): Promise<number>;
61
63
  observe: {
62
64
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
63
65
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -81,6 +83,8 @@ export type MdRuntimeClient = {
81
83
  };
82
84
  export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
83
85
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
86
+ export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
87
+ export { roomDraftRevision } from './identity.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,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;
@@ -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 BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, 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,6 +50,7 @@ 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;
@@ -69,8 +71,8 @@ export type SavedParts = {
69
71
  };
70
72
  export type RoomDraftSurface = {
71
73
  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>;
74
+ read(room: string, path: string): Promise<RoomDraft | null>;
75
+ write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
74
76
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
75
77
  };
76
78
  export type PresentationSurface = {
@@ -79,9 +81,9 @@ export type PresentationSurface = {
79
81
  edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
80
82
  };
81
83
  export type BinaryFileSurface = {
82
- read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
84
+ read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
83
85
  link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
84
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
86
+ part(file: string, part: number): Promise<Uint8Array | null>;
85
87
  };
86
88
  export type HistoryQuery = {
87
89
  revision?: string;
@@ -103,12 +105,14 @@ export type MdRuntime = {
103
105
  save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
104
106
  saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
105
107
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
108
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
106
109
  binaryFile: BinaryFileSurface;
107
110
  call(name: string, input: unknown): Promise<CallResult>;
108
- reached(locator: string, roomVersion: string, path?: string): boolean;
111
+ reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
109
112
  log(): string;
110
113
  persistence(): boolean;
111
114
  retry(): Promise<void>;
115
+ cleanUp(): Promise<number>;
112
116
  observe: {
113
117
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
114
118
  (topic: 'readiness'): Promise<Observation<Readiness>>;
@@ -132,7 +136,7 @@ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'stora
132
136
  export type ReadinessPort = {
133
137
  readonly target: string;
134
138
  readonly code: CodeAvailability;
135
- readonly capacity: CapacityCause | null;
139
+ readonly space: Space | null;
136
140
  readonly search: SearchObligation;
137
141
  };
138
142
  export type ComposedRuntime = RuntimeView & {
@@ -140,6 +144,7 @@ export type ComposedRuntime = RuntimeView & {
140
144
  stop(): Promise<void>;
141
145
  lose(locators: readonly string[]): Promise<void>;
142
146
  persisted(answer: Persistence): void;
147
+ shown(onScreen: boolean): void;
143
148
  within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
144
149
  };
145
150
  export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
@@ -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,12 +79,13 @@ 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;
86
86
  publish(set: ChangeSet): void;
87
87
  online(): boolean;
88
+ full(): boolean;
88
89
  closed(): boolean;
89
90
  unanswered(): void;
90
91
  expired(operation: string): boolean;
@@ -112,5 +113,6 @@ export type ConversationStore = {
112
113
  };
113
114
  export declare function unheldView(conversation: string): ConversationView;
114
115
  export declare const SESSION_STARTED = "Session started";
116
+ export declare const HISTORY_CONVERSATIONS = 64;
115
117
  export declare function newChat(agent: string): string;
116
118
  export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
@@ -1,14 +1,12 @@
1
1
  import type { Persistence } from './readiness.js';
2
- export type StorageEstimate = {
3
- readonly usage: number;
4
- readonly quota: number;
5
- };
6
2
  export type RuntimeShell = {
7
3
  persistence: Persistence;
8
4
  generation: string | null;
5
+ onScreen: boolean;
9
6
  keepGeneration(value: string): void | Promise<void>;
10
7
  dropGeneration(): void | Promise<void>;
11
- estimate?(): Promise<StorageEstimate | null>;
8
+ cleanUp?(): Promise<number>;
12
9
  };
10
+ export declare function refusedForSpace(error: unknown): boolean;
13
11
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
14
12
  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,6 @@
1
+ export declare function changeBatchIdentity(at?: number): string;
2
+ export declare function identityTime(identity: string): number;
3
+ export declare function roomDraftRevision(): string;
4
+ export declare function chatDraftRevision(): string;
5
+ export declare function transferIdentity(): string;
6
+ export declare function binaryLocalId(): string;