@agentshouse/app-bridge 0.1.0-cedebf3bb1f58 → 0.1.0-cefd2eeb54a01

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 (64) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +881 -19
  3. package/dist/mdmodel/definition.d.ts +17 -1
  4. package/dist/mdmodel/document.d.ts +5 -5
  5. package/dist/mdmodel/event.d.ts +77 -0
  6. package/dist/mdmodel/facts.d.ts +14 -0
  7. package/dist/mdmodel/index.d.ts +24 -9
  8. package/dist/mdmodel/kinds.d.ts +18 -0
  9. package/dist/mdmodel/links.d.ts +28 -0
  10. package/dist/mdmodel/paths.d.ts +9 -1
  11. package/dist/mdmodel/pattern.d.ts +9 -0
  12. package/dist/mdmodel/project.d.ts +1 -0
  13. package/dist/mdmodel/query/language.d.ts +222 -0
  14. package/dist/mdmodel/query/match.d.ts +13 -0
  15. package/dist/mdmodel/query/rows.d.ts +31 -0
  16. package/dist/mdmodel/query/sql.d.ts +38 -0
  17. package/dist/mdmodel/reserved.d.ts +4 -0
  18. package/dist/mdmodel/types.d.ts +35 -4
  19. package/dist/mdmodel/validate.d.ts +30 -4
  20. package/dist/mdruntime/adapter.d.ts +144 -79
  21. package/dist/mdruntime/binary.d.ts +0 -5
  22. package/dist/mdruntime/chain.d.ts +11 -0
  23. package/dist/mdruntime/change-set.d.ts +9 -16
  24. package/dist/mdruntime/change.d.ts +32 -1
  25. package/dist/mdruntime/client.d.ts +22 -10
  26. package/dist/mdruntime/collection.d.ts +11 -21
  27. package/dist/mdruntime/compile.d.ts +10 -0
  28. package/dist/mdruntime/connection.d.ts +32 -19
  29. package/dist/mdruntime/conversation.d.ts +34 -17
  30. package/dist/mdruntime/durability.d.ts +7 -4
  31. package/dist/mdruntime/identity.d.ts +5 -0
  32. package/dist/mdruntime/media.d.ts +7 -0
  33. package/dist/mdruntime/messages.d.ts +27 -0
  34. package/dist/mdruntime/model.d.ts +8 -10
  35. package/dist/mdruntime/observation.d.ts +17 -2
  36. package/dist/mdruntime/opened.d.ts +21 -0
  37. package/dist/mdruntime/outcome.d.ts +45 -7
  38. package/dist/mdruntime/overlay.d.ts +3 -5
  39. package/dist/mdruntime/query.d.ts +15 -190
  40. package/dist/mdruntime/reach.d.ts +18 -9
  41. package/dist/mdruntime/readiness.d.ts +14 -17
  42. package/dist/mdruntime/recovery.d.ts +3 -2
  43. package/dist/mdruntime/replica.d.ts +58 -33
  44. package/dist/mdruntime/room-draft.d.ts +25 -6
  45. package/dist/mdruntime/save.d.ts +53 -14
  46. package/dist/mdruntime/search.d.ts +12 -82
  47. package/dist/mdruntime/status.d.ts +4 -5
  48. package/dist/mdruntime/store.d.ts +156 -108
  49. package/dist/mdruntime/stored.d.ts +155 -0
  50. package/dist/mdruntime/tables.d.ts +380 -0
  51. package/dist/mdruntime/wire.d.ts +42 -5
  52. package/dist/test-host.d.ts +7 -4
  53. package/dist/test-host.js +19 -29
  54. package/docs/families.md +69 -53
  55. package/package.json +8 -3
  56. package/dist/calls.d.ts +0 -117
  57. package/dist/calls.js +0 -1
  58. package/dist/mdmodel/condition.d.ts +0 -149
  59. package/dist/mdruntime/acquisition.d.ts +0 -13
  60. package/dist/mdruntime/file.d.ts +0 -19
  61. package/dist/mdruntime/rows.d.ts +0 -37
  62. package/dist/mdruntime/shared.d.ts +0 -10
  63. package/dist/mdruntime/transfer.d.ts +0 -9
  64. package/dist/mdruntime/turn.d.ts +0 -6
@@ -32,6 +32,7 @@ export type RoomDraftParts = {
32
32
  readonly creation?: RoomDraftCreation;
33
33
  readonly move?: {
34
34
  readonly to: string;
35
+ readonly room?: string;
35
36
  readonly base?: string | null;
36
37
  };
37
38
  readonly removal?: {
@@ -39,11 +40,12 @@ export type RoomDraftParts = {
39
40
  };
40
41
  readonly file?: {
41
42
  readonly blob: Blob;
43
+ readonly base?: string | null;
42
44
  };
43
45
  };
44
46
  export type HeldFile = {
45
- readonly blob: Blob;
46
47
  readonly localId: string;
48
+ readonly name?: string;
47
49
  readonly byteLength: number;
48
50
  readonly mediaType: string;
49
51
  readonly sha256: string;
@@ -69,6 +71,7 @@ type HeldParts = {
69
71
  readonly creation?: RoomDraftCreation;
70
72
  readonly move?: {
71
73
  readonly to: string;
74
+ readonly room?: string;
72
75
  readonly base: string | null;
73
76
  };
74
77
  readonly removal?: {
@@ -87,9 +90,9 @@ type ChangedUnderneath = {
87
90
  readonly file?: string | null;
88
91
  };
89
92
  export type ReturnReason = ProviderRefusal & {
90
- readonly kind: Open<'conflicted' | 'rejected' | 'expired' | 'withdrawn'>;
93
+ readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
91
94
  };
92
- export declare function returnedBy(kind: 'expired' | 'withdrawn'): ReturnReason;
95
+ export declare function returnedBy(kind: 'withdrawn'): ReturnReason;
93
96
  export type RoomDraft = {
94
97
  readonly room: string;
95
98
  readonly path: string;
@@ -110,7 +113,7 @@ export type RoomDraftWrite = {
110
113
  export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
111
114
  export type ChangedPart = {
112
115
  readonly path: string;
113
- readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'creation' | 'move' | 'removal' | 'file'>;
116
+ readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'move' | 'removal' | 'file'>;
114
117
  readonly name?: string;
115
118
  };
116
119
  export type RoomDraftRecord = {
@@ -124,12 +127,14 @@ export type SavedDraft = {
124
127
  readonly path: string;
125
128
  readonly parts: HeldParts;
126
129
  };
127
- export declare function readParts(value: unknown): RoomDraftParts;
130
+ export declare function readParts(value: unknown, path: string): RoomDraftParts;
131
+ export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
128
132
  export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
129
133
  export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
130
134
  export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
131
135
  export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
132
- export declare function changedParts(path: string, report: ChangedUnderneath): readonly ChangedPart[];
136
+ export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
137
+ export declare function lineEnded(text: string): string;
133
138
  export type TextParts = {
134
139
  readonly fields?: Readonly<Record<string, {
135
140
  readonly value: unknown;
@@ -146,6 +151,20 @@ export declare function returnedInto(existing: HeldParts | undefined, returned:
146
151
  export declare function moveTarget(move: {
147
152
  readonly to: string;
148
153
  }): string;
154
+ export declare function readSavedParts(named: readonly {
155
+ readonly path: string;
156
+ readonly parts: unknown;
157
+ }[]): readonly {
158
+ readonly path: string;
159
+ readonly parts: RoomDraftParts;
160
+ }[];
161
+ export declare function partsChanges(named: readonly {
162
+ readonly path: string;
163
+ readonly parts: unknown;
164
+ }[]): {
165
+ readonly changes: readonly Change[];
166
+ readonly preconditions: readonly Precondition[];
167
+ };
149
168
  export declare function changesOf(path: string, parts: HeldParts): {
150
169
  changes: readonly Change[];
151
170
  bases: readonly Precondition[];
@@ -1,6 +1,8 @@
1
- import type { ProviderLimit } from './adapter.js';
1
+ import { type Validation } from '../mdmodel/index.js';
2
+ import type { OperationScopes, ProviderLimit } from './adapter.js';
2
3
  import { type Change, type ChangeBatch, type Precondition, type WrittenBy } from './change.js';
3
4
  import { type Composition } from './collection.js';
5
+ import { type Layer } from './overlay.js';
4
6
  import type { VisibleLayer } from './replica.js';
5
7
  import type { ChangedPart } from './room-draft.js';
6
8
  export type SaveRefusal = {
@@ -19,25 +21,29 @@ export type SaveInput = {
19
21
  providerOwnedPaths: readonly string[];
20
22
  providerLimits: readonly ProviderLimit[];
21
23
  visible: VisibleLayer;
24
+ folders: ReadonlySet<string>;
22
25
  handle: string;
23
26
  changes: readonly Change[];
24
27
  bases: readonly Precondition[];
25
28
  queued?: ReadonlySet<string>;
26
29
  writtenBy?: WrittenBy;
27
- clean?: {
28
- text: Readonly<Record<string, string>>;
29
- binaries: Readonly<Record<string, unknown>>;
30
- composition: Composition;
31
- };
30
+ unmodeled: boolean;
31
+ validate: Validator;
32
32
  };
33
- export type BatchResult = {
34
- kind: 'batch';
35
- batch: ChangeBatch;
36
- } | {
33
+ export type Validator = (resulting: Layer, touched: readonly string[]) => Promise<Validation>;
34
+ type Refusing = {
37
35
  kind: 'refused';
38
36
  refusal: SaveRefusal;
39
37
  };
40
- export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): ChangeBatch;
38
+ export type BatchResult = {
39
+ kind: 'batch';
40
+ batch: ChangeBatch;
41
+ } | Refusing;
42
+ export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
43
+ export declare function leavingRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
44
+ export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
45
+ export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
46
+ export declare function queuedDocuments(queue: readonly ChangeBatch[]): ReadonlySet<string>;
41
47
  export type Requeued = {
42
48
  kind: 'requeued';
43
49
  queue: readonly ChangeBatch[];
@@ -57,7 +63,40 @@ export type Joining = {
57
63
  kind: 'refused';
58
64
  refusal: SaveRefusal;
59
65
  };
60
- export declare function requeued(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: (queue: readonly ChangeBatch[]) => VisibleLayer): Requeued;
66
+ type VisibleOver = (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
67
+ export declare function requeuing(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: VisibleOver): Generator<number, Requeued, void>;
61
68
  export declare function joined(queue: readonly ChangeBatch[], owner: ChangeBatch, extra: ChangeBatch): Joining;
62
- export declare function limitedIn(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: (queue: readonly ChangeBatch[]) => VisibleLayer): SaveRefusal | null;
63
- export declare function buildBatch(input: SaveInput): BatchResult;
69
+ export declare function limiting(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: VisibleOver): Generator<number, SaveRefusal | null, void>;
70
+ export declare const MOVE_DOCUMENTS = "move-documents";
71
+ export type MoveSide = {
72
+ room: string;
73
+ handle: string;
74
+ baseRoomVersion: string;
75
+ composition: Composition;
76
+ operations: OperationScopes;
77
+ providerOwnedPaths: readonly string[];
78
+ visible: VisibleLayer;
79
+ folders: ReadonlySet<string>;
80
+ queued: ReadonlySet<string>;
81
+ unmodeled: boolean;
82
+ validate: Validator;
83
+ };
84
+ export type MoveInput = {
85
+ source: MoveSide;
86
+ destination: MoveSide;
87
+ moves: readonly {
88
+ readonly path: string;
89
+ readonly to: string;
90
+ }[];
91
+ providerLimits: readonly ProviderLimit[];
92
+ local: boolean;
93
+ writtenBy?: WrittenBy;
94
+ };
95
+ export type MoveResult = {
96
+ kind: 'moved';
97
+ leaving: ChangeBatch;
98
+ arriving: ChangeBatch;
99
+ } | Refusing;
100
+ export declare function buildMove(input: MoveInput): Promise<MoveResult>;
101
+ export declare function buildBatch(input: SaveInput): Promise<BatchResult>;
102
+ export {};
@@ -1,91 +1,21 @@
1
- import type { ProviderRefusal } from './adapter.js';
2
- import type { ChangeSet } from './change-set.js';
3
- import { type CoveredRoom, type Filter, type PendingRoom } from './query.js';
4
- import type { Open } from './open.js';
5
- export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
1
+ import type { ProviderRefusal, SearchHit } from './adapter.js';
2
+ import type { Failure, Offline } from './outcome.js';
6
3
  export type SearchRequest = {
7
4
  text: string;
8
- documents?: Filter;
9
- collection?: true;
10
- conversations?: readonly string[];
11
- limit?: number;
5
+ rooms?: readonly string[];
12
6
  };
13
- export type DocumentHit = {
14
- room: string;
15
- path: string;
16
- type: string;
17
- score: number;
18
- matches: Readonly<Record<string, readonly DocumentPart[]>>;
7
+ export type { SearchHit } from './adapter.js';
8
+ export type SearchFound = {
9
+ kind: 'found';
10
+ documents: readonly SearchHit[];
19
11
  };
20
- export type MessageHit = {
21
- conversation: string;
22
- identity: string;
23
- score: number;
24
- matches: Readonly<Record<string, readonly Open<'text'>[]>>;
25
- };
26
- export type SearchCoverage = {
27
- rooms: readonly CoveredRoom[];
28
- conversations: readonly string[];
29
- index: string;
30
- overlay: readonly string[];
31
- };
32
- export type PendingConversation = {
33
- conversation: string;
34
- awaits: Open<'index'>;
35
- };
36
- export type SearchHits = {
37
- documents: readonly DocumentHit[];
38
- messages: readonly MessageHit[];
39
- };
40
- export type SearchPending = SearchHits & {
41
- pending: readonly (PendingRoom | PendingConversation)[];
42
- coverage: SearchCoverage;
43
- };
44
- export type SearchUndeclared = ProviderRefusal & {
12
+ export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
13
+ kind: 'rejected';
14
+ }) | (ProviderRefusal & {
45
15
  kind: 'undeclared';
46
- };
47
- export type SearchResult = (SearchHits & {
48
- coverage: SearchCoverage;
49
- }) | SearchPending | SearchUndeclared;
50
- export declare function undeclaredSearch(): SearchUndeclared;
51
- export type SearchedDocument = {
52
- room: string;
53
- path: string;
54
- type: string;
55
- fields: Readonly<Record<string, unknown>>;
56
- preamble: string;
57
- sections: Readonly<Record<string, string>>;
58
- };
59
- export type SearchedMessage = {
60
- conversation: string;
61
- identity: string;
62
- text: string;
63
- };
64
- export type SearchSource = {
65
- room(room: string): readonly string[];
66
- document(room: string, path: string): SearchedDocument | null;
67
- };
16
+ }) | Failure;
68
17
  export type SearchPlan = {
69
18
  text: string;
70
- documents: unknown;
71
- collection: boolean;
72
- conversations: readonly string[] | null;
73
- limit: number | null;
74
- };
75
- export type SearchIndex = {
76
- generation(): string;
77
- rooms(): ReadonlySet<string>;
78
- conversations(): ReadonlySet<string>;
79
- indexRoom(room: string): Promise<void>;
80
- indexMessages(conversation: string, messages: readonly SearchedMessage[], whole: boolean): void;
81
- forget(rooms: readonly string[]): void;
82
- changed(set: ChangeSet): void;
83
- changes(): number;
84
- caughtUp(): Promise<void>;
85
- search(plan: SearchPlan, documents: readonly {
86
- room: string;
87
- path: string;
88
- }[] | null, conversations: readonly string[], rooms: ReadonlySet<string> | null, selections: ReadonlyMap<string, readonly string[]> | null): SearchHits;
19
+ rooms: readonly string[] | null;
89
20
  };
90
21
  export declare function searchPlanOf(input: unknown): SearchPlan;
91
- export declare function createSearchIndex(source: SearchSource): SearchIndex;
@@ -1,19 +1,20 @@
1
1
  import type { Open } from './open.js';
2
- import type { ProviderRefusal } from './adapter.js';
3
2
  import type { ReturnReason } from './room-draft.js';
4
3
  export type AttentionEntry = {
5
4
  room: string;
6
5
  path: string;
7
6
  returned: ReturnReason;
8
- } | {
7
+ };
8
+ export type UnsentChange = {
9
9
  room: string;
10
- refusal: ProviderRefusal;
10
+ path: string;
11
11
  };
12
12
  export type SyncStatus = {
13
13
  state: Open<'pending' | 'syncing' | 'synced'>;
14
14
  lastCompleted: string | null;
15
15
  providerUnreachable: boolean;
16
16
  attentionRequired: readonly AttentionEntry[];
17
+ unsent: readonly UnsentChange[];
17
18
  reset: string | null;
18
19
  };
19
20
  export type CycleProgress = {
@@ -21,6 +22,4 @@ export type CycleProgress = {
21
22
  reachable: boolean;
22
23
  };
23
24
  export declare const STARTING: SyncStatus;
24
- export declare function transferring(status: SyncStatus): SyncStatus;
25
- export declare function saving(status: SyncStatus): SyncStatus;
26
25
  export declare function same(one: SyncStatus, other: SyncStatus): boolean;
@@ -1,160 +1,208 @@
1
- import type { ModelState } from './model.js';
2
- import type { Capability, HeadChange, Member, OperationScopes, ProviderLimit, ReplicaAdmission, TypedSelection } from './adapter.js';
3
- import type { AcceptedMessage, KeptReceipt } from './adapter.js';
1
+ import type { BootstrapInventory, Capability, ListedConversation, Member, ProviderLimit } from './adapter.js';
4
2
  import type { ChangeBatch } from './change.js';
5
- import { type HeldBinary } from './overlay.js';
6
- import type { ChatDraftFile } from './file.js';
3
+ import { type Composition } from './collection.js';
4
+ import type { Plan } from './query.js';
5
+ import type { ReplicaRecord } from './replica.js';
7
6
  import type { Submission } from './outcome.js';
8
7
  import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
9
- export declare const STORE_SCHEMA = 25;
10
- export declare const AUTHORED_SCHEMA = 2;
11
- export type ReplicaRecord = {
12
- locator: string;
13
- name: string;
14
- handle: string;
15
- operations: OperationScopes;
16
- replica: ReplicaAdmission;
17
- model: ModelState;
18
- typedSelection: TypedSelection | null;
19
- selectionModel: ModelState;
20
- providerOwnedPaths: readonly string[];
21
- roomVersion: string;
22
- transfer: string;
23
- documents: Readonly<Record<string, string>>;
24
- binaries: Readonly<Record<string, HeldBinary>>;
25
- revisions: Readonly<Record<string, string>>;
26
- fileIds: Readonly<Record<string, string>>;
27
- changes: Readonly<Record<string, HeadChange>>;
28
- written: Readonly<Record<string, string>>;
29
- };
30
- export type StagedLayer = Pick<ReplicaRecord, 'documents' | 'binaries' | 'revisions' | 'fileIds' | 'changes' | 'written'>;
8
+ import type { ModelState, StoredModel } from './model.js';
9
+ import type { CommittedWrite, ConversationWrite, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, ReplicaOpened, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
10
+ export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
31
11
  export type TransferRecord = {
32
- locator: string;
33
- transfer: string;
34
- selection: string;
35
- from: string;
36
- last: string;
37
- pageToken: string | null;
38
- models: {
39
- collection: ModelState;
40
- selection: ModelState;
12
+ readonly locator: string;
13
+ readonly transfer: string;
14
+ readonly selection: string;
15
+ readonly from: string;
16
+ readonly last: string;
17
+ readonly done: BootstrapInventory;
18
+ readonly models: {
19
+ readonly collection: ModelState;
41
20
  };
21
+ readonly key: number | null;
22
+ };
23
+ export type StoredReplica = Omit<ReplicaRecord, 'model'> & {
24
+ readonly model: StoredModel;
42
25
  };
43
26
  export type PendingState = {
44
27
  readonly drafts: readonly SavedDraft[];
45
28
  readonly submission: Submission;
46
29
  readonly lost: boolean;
47
30
  readonly upload?: unknown;
48
- readonly accepted?: string;
49
31
  };
50
32
  export type TargetRecord = {
51
33
  established: boolean;
52
34
  };
53
- export type QueueRecord = {
54
- locator: string;
55
- pending: readonly {
56
- batch: ChangeBatch;
57
- state: PendingState;
58
- }[];
59
- };
60
35
  export type PresentationRecord = {
61
36
  app: string;
62
37
  value: unknown;
63
38
  };
64
- export type HeldConversation = {
65
- conversation: string;
66
- read: string | null | undefined;
67
- partial: boolean;
68
- };
69
- export type ConversationWrite = {
70
- conversation: string;
71
- messages: readonly AcceptedMessage[];
72
- read?: {
73
- at: string | null;
74
- partial: boolean;
75
- };
76
- };
77
39
  export type ChatSubmission = {
78
40
  readonly operation: string;
79
41
  readonly text: string;
80
- readonly files: readonly ChatDraftFile[];
81
42
  readonly turn: string | null;
82
43
  };
83
44
  export type ChatDraftRecord = {
84
45
  conversation: string;
85
46
  text: string;
86
- files: readonly ChatDraftFile[];
87
47
  revision: string;
88
48
  submitted?: readonly ChatSubmission[];
89
49
  moves?: readonly string[];
90
50
  };
91
- export type RecordWrite = {
92
- next: ReplicaRecord;
93
- previous: ReplicaRecord | null;
94
- stored?: StagedLayer;
51
+ export type CallRecord = {
52
+ readonly operation: string;
53
+ readonly name: string;
54
+ readonly input: unknown;
95
55
  };
96
56
  export type AuthoredWrite = {
97
57
  locator: string;
98
- queue: readonly ChangeBatch[];
58
+ queue?: readonly ChangeBatch[];
59
+ stored?: readonly ChangeBatch[];
60
+ founded?: readonly ChangeBatch[];
99
61
  saved?: ReadonlyMap<string, readonly SavedDraft[]>;
100
62
  roomDrafts?: readonly RoomDraftRecord[];
101
63
  consumedRoomDrafts?: readonly string[];
102
64
  };
65
+ export type StagedPage = {
66
+ readonly entries: readonly StoredEntry[];
67
+ readonly folders: readonly string[];
68
+ readonly part?: string;
69
+ };
70
+ export type ResumedTransfer = {
71
+ readonly key: number | null;
72
+ readonly transfer: string;
73
+ readonly staged: readonly string[];
74
+ };
75
+ export type RefreshedPage = StagedPage & {
76
+ readonly removals: readonly string[];
77
+ readonly folderRemovals: readonly string[];
78
+ };
79
+ export type HeldRoom = {
80
+ readonly record: StoredReplica;
81
+ readonly indexed: boolean;
82
+ readonly documents: number;
83
+ };
84
+ export type QueuedChange = {
85
+ readonly batch: ChangeBatch;
86
+ readonly state: PendingState;
87
+ };
88
+ export type HeldWork = {
89
+ readonly room: (HeldRoom & {
90
+ readonly overlaid: ReadonlySet<string>;
91
+ }) | null;
92
+ readonly queue: readonly QueuedChange[];
93
+ };
94
+ export type CoveredRoom = {
95
+ readonly key: number;
96
+ readonly transfer: string;
97
+ readonly roomVersion: string;
98
+ readonly indexed: boolean;
99
+ readonly documents: number;
100
+ readonly bytes: number;
101
+ readonly offline: string;
102
+ };
103
+ export type HeldCover = {
104
+ readonly rooms: ReadonlyMap<string, CoveredRoom>;
105
+ readonly queues: ReadonlyMap<string, readonly string[]>;
106
+ };
107
+ export type HeldStatus = {
108
+ readonly queued: readonly string[];
109
+ readonly lastCompleted: string | null;
110
+ readonly unsent: readonly {
111
+ readonly room: string;
112
+ readonly path: string;
113
+ }[];
114
+ readonly resets: readonly {
115
+ readonly locator: string;
116
+ readonly reset: string;
117
+ }[];
118
+ readonly returned: readonly RoomDraftRecord[];
119
+ };
120
+ export type Facts = {
121
+ readonly lastCompleted: string | null;
122
+ readonly providerLimits: readonly ProviderLimit[];
123
+ readonly capabilities: readonly Capability[];
124
+ readonly member: Member | null;
125
+ readonly targets: Readonly<Record<string, TargetRecord>>;
126
+ readonly conversationList: readonly ListedConversation[] | null;
127
+ readonly conversationCursor: string | null;
128
+ };
129
+ export type Commit = {
130
+ readonly rooms: readonly RoomCommit[];
131
+ readonly writes?: readonly AuthoredWrite[];
132
+ readonly files?: readonly StoredFile[];
133
+ readonly whole?: boolean;
134
+ };
103
135
  export type RuntimeStore = {
104
- all(): Promise<readonly ReplicaRecord[]>;
105
- keepAuthored(input: AuthoredWrite): Promise<void>;
106
- write(input: RecordWrite): Promise<void>;
107
- revokeModels(records: readonly ReplicaRecord[]): Promise<void>;
108
- lastCompleted(): Promise<string | null>;
109
- complete(at: string): Promise<void>;
110
- providerLimits(): Promise<readonly ProviderLimit[]>;
111
- capabilities(): Promise<readonly Capability[]>;
112
- declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[]): Promise<void>;
113
- member(): Promise<Member | null>;
114
- keepMember(member: Member | null): Promise<void>;
115
- targets(): Promise<Readonly<Record<string, TargetRecord>>>;
116
- keepTargets(targets: Readonly<Record<string, TargetRecord>>): Promise<void>;
117
- queues(): Promise<readonly QueueRecord[]>;
136
+ opened(): Promise<ReplicaOpened>;
137
+ rooms(locators?: readonly string[]): Promise<readonly HeldRoom[]>;
138
+ room(locator: string): Promise<HeldWork>;
139
+ covering(): Promise<HeldCover>;
140
+ offline(locator: string): Promise<string | null>;
141
+ held(): Promise<{
142
+ readonly held: ReadonlySet<string>;
143
+ readonly staged: ReadonlySet<string>;
144
+ }>;
145
+ status(): Promise<HeldStatus>;
146
+ batch(locator: string, id: string): Promise<ChangeBatch | null>;
147
+ order(locator: string): Promise<readonly string[]>;
148
+ queued(): Promise<readonly string[]>;
149
+ moving(): Promise<{
150
+ readonly queued: ReadonlyMap<string, readonly string[]>;
151
+ readonly moving: readonly (QueuedChange & {
152
+ readonly locator: string;
153
+ })[];
154
+ }>;
155
+ pending(locator: string, id: string): Promise<{
156
+ readonly state: PendingState | undefined;
157
+ readonly room: boolean;
158
+ }>;
159
+ facts(): Promise<Facts>;
160
+ presentation(app: string): Promise<unknown>;
161
+ demote(): Promise<void>;
162
+ query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
163
+ changes(keys: readonly number[]): number;
164
+ entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
165
+ typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
166
+ referrers(key: number, view: View, targets: readonly string[]): Promise<readonly Referrer[]>;
167
+ folders(key: number, view: View, paths: readonly string[]): Promise<readonly string[]>;
168
+ typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
169
+ stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
170
+ resume(record: TransferRecord, composition: Composition, parts: readonly string[], published: number | null): Promise<ResumedTransfer | null>;
171
+ refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
172
+ unrefresh(key: number): Promise<void>;
173
+ commit(commit: Commit): Promise<CommittedWrite>;
174
+ fence(locators: readonly string[]): Promise<void>;
175
+ erase(locator: string | null, limit: number): Promise<boolean>;
176
+ abandon(locator: string): Promise<void>;
177
+ unfence(locators: readonly string[]): Promise<ReadonlySet<string>>;
178
+ release(key: number): Promise<void>;
179
+ rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
180
+ readonly done: boolean;
181
+ readonly text: number;
182
+ }>;
183
+ fact(name: string, value: unknown): Promise<void>;
118
184
  submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
119
- accept(locator: string, id: string, roomVersion: string): Promise<void>;
120
185
  keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
121
- roomDrafts(): Promise<readonly RoomDraftRecord[]>;
122
- presentation(): Promise<readonly PresentationRecord[]>;
186
+ roomDrafts(locator?: string, paths?: readonly string[]): Promise<readonly RoomDraftRecord[]>;
123
187
  present(record: PresentationRecord): Promise<void>;
124
- conversations(): Promise<readonly HeldConversation[]>;
188
+ conversations(conversations?: readonly string[]): Promise<readonly HeldConversation[]>;
125
189
  keepMessages(write: ConversationWrite): Promise<void>;
126
- messageWindow(conversation: string, limit: number | undefined): Promise<AcceptedMessage[]>;
127
- messagesAfter(conversation: string, identity: string | null): Promise<AcceptedMessage[]>;
128
- messageIdentities(conversation: string): Promise<readonly string[]>;
190
+ messageWindow(conversation: string, limit: number, before: readonly [string, string] | null, phrase?: string | null): Promise<MessageWindow>;
191
+ messageCount(conversation: string, phrase?: string | null): Promise<number>;
129
192
  turnArrived(conversation: string, turn: string): Promise<boolean>;
130
193
  dropConversations(conversations: readonly string[]): Promise<void>;
131
194
  chatDrafts(): Promise<readonly ChatDraftRecord[]>;
195
+ chatDraft(conversation: string): Promise<ChatDraftRecord | null>;
132
196
  keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
133
197
  dropChatDraft(conversation: string): Promise<void>;
134
- keepRoomDraft(record: RoomDraftRecord): Promise<void>;
198
+ calls(): Promise<readonly CallRecord[]>;
199
+ keepCall(record: CallRecord): Promise<void>;
200
+ dropCall(operation: string): Promise<void>;
201
+ keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
135
202
  discardRoomDraft(locator: string, path: string): Promise<void>;
136
203
  fences(): Promise<readonly string[]>;
137
- erase(locators: readonly string[]): Promise<void>;
138
- discard(locator: string): Promise<void>;
139
- transfers(): Promise<readonly TransferRecord[]>;
140
- staged(record: TransferRecord): Promise<StagedLayer>;
141
- stage(record: TransferRecord, page: StagedLayer): Promise<void>;
142
- abandon(locator: string): Promise<void>;
143
- receivedHeads(): Promise<readonly KeptReceipt[]>;
144
- receivedParts(key: string, count: number): Promise<readonly unknown[]>;
145
- keepReceived(key: string, head: unknown, part?: {
146
- index: number;
147
- value: unknown;
148
- }): Promise<void>;
149
- dropReceived(keys: readonly string[]): Promise<void>;
150
204
  generation(): Promise<string | null>;
151
205
  rememberGeneration(value: string): Promise<void>;
152
- close(): void;
153
- };
154
- export declare function authoredHolder(): Promise<string | null>;
155
- export declare function authoredBy(holder: string): Promise<boolean>;
156
- export declare function authoredBinding(): Promise<string | null>;
157
- export declare function bindAuthored(binding: string): Promise<void>;
158
- export declare function removeRuntimeStore(holder?: string): Promise<boolean>;
159
- export declare function openDatabase(name: string, version: number, upgrade: (opening: IDBOpenDBRequest, oldVersion: number) => void): Promise<IDBDatabase>;
160
- export declare function openRuntimeStore(fenced: (locator: string) => boolean): Promise<RuntimeStore>;
206
+ file(key: string, type: string): Promise<Blob>;
207
+ };
208
+ export declare function openRuntimeStore(authored: RuntimeDatabase): RuntimeStore;