@agentshouse/app-bridge 0.1.0-cfb240c3fb89d → 0.1.0-cfbb2e428ff88

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 (63) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +865 -8
  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 +23 -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/project.d.ts +1 -0
  12. package/dist/mdmodel/query/language.d.ts +222 -0
  13. package/dist/mdmodel/query/match.d.ts +13 -0
  14. package/dist/mdmodel/query/rows.d.ts +31 -0
  15. package/dist/mdmodel/query/sql.d.ts +38 -0
  16. package/dist/mdmodel/reserved.d.ts +4 -0
  17. package/dist/mdmodel/types.d.ts +35 -4
  18. package/dist/mdmodel/validate.d.ts +29 -4
  19. package/dist/mdruntime/adapter.d.ts +147 -74
  20. package/dist/mdruntime/binary.d.ts +0 -5
  21. package/dist/mdruntime/chain.d.ts +11 -0
  22. package/dist/mdruntime/change-set.d.ts +9 -16
  23. package/dist/mdruntime/change.d.ts +31 -1
  24. package/dist/mdruntime/client.d.ts +27 -11
  25. package/dist/mdruntime/collection.d.ts +11 -21
  26. package/dist/mdruntime/compile.d.ts +10 -0
  27. package/dist/mdruntime/connection.d.ts +41 -14
  28. package/dist/mdruntime/conversation.d.ts +32 -15
  29. package/dist/mdruntime/durability.d.ts +10 -1
  30. package/dist/mdruntime/identity.d.ts +5 -0
  31. package/dist/mdruntime/media.d.ts +7 -0
  32. package/dist/mdruntime/messages.d.ts +27 -0
  33. package/dist/mdruntime/model.d.ts +11 -10
  34. package/dist/mdruntime/observation.d.ts +17 -2
  35. package/dist/mdruntime/opened.d.ts +21 -0
  36. package/dist/mdruntime/outcome.d.ts +45 -7
  37. package/dist/mdruntime/overlay.d.ts +3 -5
  38. package/dist/mdruntime/query.d.ts +17 -185
  39. package/dist/mdruntime/reach.d.ts +18 -6
  40. package/dist/mdruntime/readiness.d.ts +49 -0
  41. package/dist/mdruntime/recovery.d.ts +3 -2
  42. package/dist/mdruntime/replica.d.ts +58 -33
  43. package/dist/mdruntime/room-draft.d.ts +37 -6
  44. package/dist/mdruntime/save.d.ts +53 -14
  45. package/dist/mdruntime/search.d.ts +15 -77
  46. package/dist/mdruntime/seed.d.ts +15 -0
  47. package/dist/mdruntime/status.d.ts +5 -0
  48. package/dist/mdruntime/store.d.ts +93 -94
  49. package/dist/mdruntime/stored.d.ts +128 -0
  50. package/dist/mdruntime/tables.d.ts +326 -0
  51. package/dist/mdruntime/wire.d.ts +173 -32
  52. package/dist/test-host.d.ts +7 -1
  53. package/dist/test-host.js +19 -1
  54. package/docs/families.md +66 -12
  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/file.d.ts +0 -19
  60. package/dist/mdruntime/rows.d.ts +0 -36
  61. package/dist/mdruntime/shared.d.ts +0 -10
  62. package/dist/mdruntime/transfer.d.ts +0 -9
  63. package/dist/mdruntime/turn.d.ts +0 -6
@@ -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,83 +1,21 @@
1
- import type { ChangeSet } from './change-set.js';
2
- import { type CoveredRoom, type Filter, type PendingRoom } from './query.js';
3
- import type { Open } from './open.js';
4
- export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
1
+ import type { ProviderRefusal, SearchHit } from './adapter.js';
2
+ import type { Failure, Offline } from './outcome.js';
5
3
  export type SearchRequest = {
6
4
  text: string;
7
- documents?: Filter;
8
- conversations?: readonly string[];
9
- limit?: number;
10
- };
11
- export type DocumentHit = {
12
- room: string;
13
- path: string;
14
- type: string;
15
- score: number;
16
- matches: Readonly<Record<string, readonly DocumentPart[]>>;
17
- };
18
- export type MessageHit = {
19
- conversation: string;
20
- identity: string;
21
- score: number;
22
- matches: Readonly<Record<string, readonly Open<'text'>[]>>;
23
- };
24
- export type SearchCoverage = {
25
- rooms: readonly CoveredRoom[];
26
- conversations: readonly string[];
27
- index: string;
28
- overlay: readonly string[];
29
- };
30
- export type PendingConversation = {
31
- conversation: string;
32
- awaits: 'index';
33
- };
34
- export type SearchPending = {
35
- pending: readonly (PendingRoom | PendingConversation)[];
36
- };
37
- export type SearchHits = {
38
- documents: readonly DocumentHit[];
39
- messages: readonly MessageHit[];
40
- };
41
- export type SearchResult = (SearchHits & {
42
- coverage: SearchCoverage;
43
- }) | SearchPending;
44
- export type SearchedDocument = {
45
- room: string;
46
- path: string;
47
- type: string;
48
- fields: Readonly<Record<string, unknown>>;
49
- preamble: string;
50
- sections: Readonly<Record<string, string>>;
51
- };
52
- export type SearchedMessage = {
53
- conversation: string;
54
- identity: string;
55
- text: string;
56
- };
57
- export type SearchSource = {
58
- room(room: string): readonly string[];
59
- document(room: string, path: string): SearchedDocument | null;
60
- };
5
+ rooms?: readonly string[];
6
+ };
7
+ export type { SearchHit } from './adapter.js';
8
+ export type SearchFound = {
9
+ kind: 'found';
10
+ documents: readonly SearchHit[];
11
+ };
12
+ export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
13
+ kind: 'rejected';
14
+ }) | (ProviderRefusal & {
15
+ kind: 'undeclared';
16
+ }) | Failure;
61
17
  export type SearchPlan = {
62
18
  text: string;
63
- documents: unknown;
64
- conversations: readonly string[] | null;
65
- limit: number | null;
66
- };
67
- export type SearchIndex = {
68
- generation(): string;
69
- rooms(): ReadonlySet<string>;
70
- conversations(): ReadonlySet<string>;
71
- indexRoom(room: string): Promise<void>;
72
- indexMessages(conversation: string, messages: readonly SearchedMessage[], whole: boolean): void;
73
- forget(rooms: readonly string[]): void;
74
- changed(set: ChangeSet): void;
75
- changes(): number;
76
- caughtUp(): Promise<void>;
77
- search(plan: SearchPlan, documents: readonly {
78
- room: string;
79
- path: string;
80
- }[] | null, conversations: readonly string[]): SearchHits;
19
+ rooms: readonly string[] | null;
81
20
  };
82
21
  export declare function searchPlanOf(input: unknown): SearchPlan;
83
- export declare function createSearchIndex(source: SearchSource): SearchIndex;
@@ -0,0 +1,15 @@
1
+ import type { KeyedResult } from './observation.js';
2
+ import type { QueryRows } from './query.js';
3
+ export type EntrySeed = {
4
+ readonly at: Readonly<Record<string, string>>;
5
+ readonly queries: readonly {
6
+ readonly query: unknown;
7
+ readonly rows: QueryRows;
8
+ }[];
9
+ };
10
+ export type Seeded = {
11
+ readonly rows: QueryRows;
12
+ readonly at: Readonly<Record<string, string>>;
13
+ };
14
+ export declare function entrySeedOf(value: unknown): EntrySeed | null;
15
+ export declare function seededResult(seed: Seeded): KeyedResult;
@@ -5,11 +5,16 @@ export type AttentionEntry = {
5
5
  path: string;
6
6
  returned: ReturnReason;
7
7
  };
8
+ export type UnsentChange = {
9
+ room: string;
10
+ path: string;
11
+ };
8
12
  export type SyncStatus = {
9
13
  state: Open<'pending' | 'syncing' | 'synced'>;
10
14
  lastCompleted: string | null;
11
15
  providerUnreachable: boolean;
12
16
  attentionRequired: readonly AttentionEntry[];
17
+ unsent: readonly UnsentChange[];
13
18
  reset: string | null;
14
19
  };
15
20
  export type CycleProgress = {
@@ -1,50 +1,36 @@
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
- changes: Readonly<Record<string, HeadChange>>;
27
- written: Readonly<Record<string, string>>;
28
- };
29
- export type StagedLayer = Pick<ReplicaRecord, 'documents' | 'binaries' | 'revisions' | 'changes' | 'written'>;
8
+ import type { ModelState, StoredModel } from './model.js';
9
+ import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
10
+ export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
30
11
  export type TransferRecord = {
31
- locator: string;
32
- transfer: string;
33
- selection: string;
34
- from: string;
35
- last: string;
36
- pageToken: string | null;
37
- models: {
38
- collection: ModelState;
39
- 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;
40
20
  };
21
+ readonly key: number | null;
22
+ };
23
+ export type StoredReplica = Omit<ReplicaRecord, 'model'> & {
24
+ readonly model: StoredModel;
41
25
  };
42
26
  export type PendingState = {
43
27
  readonly drafts: readonly SavedDraft[];
44
28
  readonly submission: Submission;
45
29
  readonly lost: boolean;
46
30
  readonly upload?: unknown;
47
- readonly accepted?: string;
31
+ };
32
+ export type TargetRecord = {
33
+ established: boolean;
48
34
  };
49
35
  export type QueueRecord = {
50
36
  locator: string;
@@ -57,96 +43,109 @@ export type PresentationRecord = {
57
43
  app: string;
58
44
  value: unknown;
59
45
  };
60
- export type HeldConversation = {
61
- conversation: string;
62
- read: string | null | undefined;
63
- partial: boolean;
64
- };
65
- export type ConversationWrite = {
66
- conversation: string;
67
- messages: readonly AcceptedMessage[];
68
- read?: {
69
- at: string | null;
70
- partial: boolean;
71
- };
72
- };
73
46
  export type ChatSubmission = {
74
47
  readonly operation: string;
75
48
  readonly text: string;
76
- readonly files: readonly ChatDraftFile[];
77
49
  readonly turn: string | null;
78
50
  };
79
51
  export type ChatDraftRecord = {
80
52
  conversation: string;
81
53
  text: string;
82
- files: readonly ChatDraftFile[];
83
54
  revision: string;
84
55
  submitted?: readonly ChatSubmission[];
56
+ moves?: readonly string[];
85
57
  };
86
- export type RecordWrite = {
87
- next: ReplicaRecord;
88
- previous: ReplicaRecord | null;
89
- stored?: StagedLayer;
58
+ export type CallRecord = {
59
+ readonly operation: string;
60
+ readonly name: string;
61
+ readonly input: unknown;
90
62
  };
91
63
  export type AuthoredWrite = {
92
64
  locator: string;
93
- queue: readonly ChangeBatch[];
65
+ queue?: readonly ChangeBatch[];
66
+ founded?: readonly ChangeBatch[];
94
67
  saved?: ReadonlyMap<string, readonly SavedDraft[]>;
95
68
  roomDrafts?: readonly RoomDraftRecord[];
96
69
  consumedRoomDrafts?: readonly string[];
97
70
  };
71
+ export type StagedPage = {
72
+ readonly entries: readonly StoredEntry[];
73
+ readonly folders: readonly string[];
74
+ };
75
+ export type RefreshedPage = StagedPage & {
76
+ readonly removals: readonly string[];
77
+ readonly folderRemovals: readonly string[];
78
+ };
79
+ export type Opened = {
80
+ readonly rooms: ReadonlyMap<string, StoredReplica>;
81
+ readonly unindexed: ReadonlySet<number>;
82
+ readonly overlaid: ReadonlyMap<number, ReadonlySet<string>>;
83
+ readonly erasing: boolean;
84
+ readonly orphans: readonly number[];
85
+ readonly lastCompleted: string | null;
86
+ readonly providerLimits: readonly ProviderLimit[];
87
+ readonly capabilities: readonly Capability[];
88
+ readonly member: Member | null;
89
+ readonly targets: Readonly<Record<string, TargetRecord>>;
90
+ readonly presentation: readonly PresentationRecord[];
91
+ readonly conversationList: readonly ListedConversation[] | null;
92
+ readonly conversationCursor: string | null;
93
+ };
94
+ export type Commit = {
95
+ readonly rooms: readonly RoomCommit[];
96
+ readonly writes?: readonly AuthoredWrite[];
97
+ readonly files?: readonly StoredFile[];
98
+ readonly whole?: boolean;
99
+ };
98
100
  export type RuntimeStore = {
99
- all(): Promise<readonly ReplicaRecord[]>;
100
- keepAuthored(input: AuthoredWrite): Promise<void>;
101
- write(input: RecordWrite): Promise<void>;
102
- revokeModels(records: readonly ReplicaRecord[]): Promise<void>;
103
- lastCompleted(): Promise<string | null>;
104
- complete(at: string): Promise<void>;
105
- providerLimits(): Promise<readonly ProviderLimit[]>;
106
- capabilities(): Promise<readonly Capability[]>;
107
- declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[]): Promise<void>;
108
- member(): Promise<Member | null>;
109
- keepMember(member: Member | null): Promise<void>;
101
+ opened(): Promise<Opened>;
102
+ counts(rooms: readonly CountedRoom[]): Promise<readonly number[]>;
103
+ query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
104
+ changes(keys: readonly number[]): number;
105
+ entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
106
+ typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
107
+ referrers(key: number, view: View, targets: readonly string[]): Promise<readonly Referrer[]>;
108
+ files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
109
+ readonly path: string;
110
+ readonly revision: string;
111
+ }[]>;
112
+ folders(key: number, view: View, paths: readonly string[]): Promise<readonly string[]>;
113
+ typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
114
+ stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
115
+ refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
116
+ unrefresh(key: number): Promise<void>;
117
+ commit(commit: Commit): Promise<CommittedWrite>;
118
+ fence(locators: readonly string[]): Promise<void>;
119
+ erase(locator: string | null, limit: number): Promise<boolean>;
120
+ abandon(locator: string): Promise<void>;
121
+ release(key: number): Promise<void>;
122
+ rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
123
+ readonly done: boolean;
124
+ readonly text: number;
125
+ }>;
126
+ fact(name: string, value: unknown): Promise<void>;
110
127
  queues(): Promise<readonly QueueRecord[]>;
111
128
  submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
112
- accept(locator: string, id: string, roomVersion: string): Promise<void>;
113
129
  keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
114
130
  roomDrafts(): Promise<readonly RoomDraftRecord[]>;
115
- presentation(): Promise<readonly PresentationRecord[]>;
116
131
  present(record: PresentationRecord): Promise<void>;
117
132
  conversations(): Promise<readonly HeldConversation[]>;
118
133
  keepMessages(write: ConversationWrite): Promise<void>;
119
- messageWindow(conversation: string, limit: number | undefined): Promise<AcceptedMessage[]>;
120
- messagesAfter(conversation: string, identity: string | null): Promise<AcceptedMessage[]>;
121
- messageIdentities(conversation: string): Promise<readonly string[]>;
134
+ messageWindow(conversation: string, limit: number, before: readonly [string, string] | null, phrase?: string | null): Promise<MessageWindow>;
135
+ messageCount(conversation: string, phrase?: string | null): Promise<number>;
122
136
  turnArrived(conversation: string, turn: string): Promise<boolean>;
123
137
  dropConversations(conversations: readonly string[]): Promise<void>;
124
138
  chatDrafts(): Promise<readonly ChatDraftRecord[]>;
125
- keepChatDraft(record: ChatDraftRecord): Promise<void>;
139
+ keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
126
140
  dropChatDraft(conversation: string): Promise<void>;
127
- keepRoomDraft(record: RoomDraftRecord): Promise<void>;
141
+ calls(): Promise<readonly CallRecord[]>;
142
+ keepCall(record: CallRecord): Promise<void>;
143
+ dropCall(operation: string): Promise<void>;
144
+ keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
128
145
  discardRoomDraft(locator: string, path: string): Promise<void>;
129
146
  fences(): Promise<readonly string[]>;
130
- erase(locators: readonly string[]): Promise<void>;
131
- discard(locator: string): Promise<void>;
132
- transfers(): Promise<readonly TransferRecord[]>;
133
- staged(record: TransferRecord): Promise<StagedLayer>;
134
- stage(record: TransferRecord, page: StagedLayer): Promise<void>;
135
- abandon(locator: string): Promise<void>;
136
- receivedHeads(): Promise<readonly KeptReceipt[]>;
137
- receivedParts(key: string, count: number): Promise<readonly unknown[]>;
138
- keepReceived(key: string, head: unknown, part?: {
139
- index: number;
140
- value: unknown;
141
- }): Promise<void>;
142
- dropReceived(keys: readonly string[]): Promise<void>;
143
147
  generation(): Promise<string | null>;
144
148
  rememberGeneration(value: string): Promise<void>;
145
- close(): void;
149
+ file(key: string, type: string): Promise<Blob>;
146
150
  };
147
- export declare function authoredHolder(): Promise<string | null>;
148
- export declare function authoredBy(holder: string): Promise<boolean>;
149
- export declare function authoredBinding(): Promise<string | null>;
150
- export declare function bindAuthored(binding: string): Promise<void>;
151
- export declare function removeRuntimeStore(holder?: string): Promise<boolean>;
152
- export declare function openRuntimeStore(fenced: (locator: string) => boolean): Promise<RuntimeStore>;
151
+ export declare function openRuntimeStore(fenced: (locator: string) => boolean, authored: RuntimeDatabase): RuntimeStore;
@@ -0,0 +1,128 @@
1
+ import type { SavedFacts, HeadChange } from './adapter.js';
2
+ import { type Composed, type Composition } from './collection.js';
3
+ import type { HeldBinary } from './overlay.js';
4
+ import type { Connection } from './tables.js';
5
+ export declare const REPLICA_TABLES: readonly string[];
6
+ export type View = 'confirmed' | 'visible' | 'refreshed';
7
+ export type StoredEntry = {
8
+ readonly path: string;
9
+ readonly content: string | null;
10
+ readonly binary: HeldBinary | null;
11
+ readonly revision: string | null;
12
+ readonly fileId: string | null;
13
+ readonly change: HeadChange | null;
14
+ readonly written: string | null;
15
+ readonly facts: SavedFacts | null;
16
+ };
17
+ export type OverlayEntry = StoredEntry & {
18
+ readonly present: boolean;
19
+ };
20
+ export type HeldEntry = StoredEntry & {
21
+ readonly type: string | null;
22
+ };
23
+ export type TypedEntry = {
24
+ readonly path: string;
25
+ readonly type: string | null;
26
+ readonly binary: boolean;
27
+ };
28
+ export type Referrer = {
29
+ readonly path: string;
30
+ readonly target: string;
31
+ };
32
+ export type HeldKey = {
33
+ readonly key: number;
34
+ readonly locator: string;
35
+ readonly transfer: string;
36
+ readonly rederiving: number | null;
37
+ };
38
+ export type ReplicaOpened = {
39
+ readonly rooms: readonly {
40
+ readonly locator: string;
41
+ readonly key: number;
42
+ readonly record: string;
43
+ }[];
44
+ readonly keys: readonly HeldKey[];
45
+ readonly facts: Readonly<Record<string, string>>;
46
+ readonly presentation: readonly {
47
+ readonly app: string;
48
+ readonly value: string;
49
+ }[];
50
+ readonly overlaid: readonly {
51
+ readonly key: number;
52
+ readonly path: string;
53
+ }[];
54
+ readonly erasing: readonly {
55
+ readonly key: number;
56
+ readonly locator: string;
57
+ }[];
58
+ readonly orphans: readonly number[];
59
+ };
60
+ export type RoomCommit = {
61
+ readonly locator: string;
62
+ readonly key: number;
63
+ readonly record?: string;
64
+ readonly roots?: readonly string[];
65
+ readonly published?: {
66
+ readonly from: number | null;
67
+ };
68
+ readonly refreshed?: true;
69
+ readonly composed: Composed;
70
+ readonly confirmed?: {
71
+ readonly set: readonly StoredEntry[];
72
+ readonly removed: readonly string[];
73
+ };
74
+ readonly overlay?: {
75
+ readonly set: readonly OverlayEntry[];
76
+ readonly cleared: readonly string[];
77
+ };
78
+ };
79
+ export type Committed = {
80
+ readonly counts: Readonly<Record<string, number>>;
81
+ readonly changed: Readonly<Record<string, readonly string[] | null>>;
82
+ readonly indexed: Readonly<Record<string, boolean>>;
83
+ };
84
+ export type CountedRoom = {
85
+ readonly key: number;
86
+ readonly roots: readonly string[];
87
+ };
88
+ export declare function entered(connection: Connection, locator: string, composition: Composition, rows: readonly StoredEntry[]): number;
89
+ export declare function stage(connection: Connection, request: {
90
+ readonly locator: string;
91
+ readonly transfer: string;
92
+ readonly key: number | null;
93
+ readonly fingerprint: string;
94
+ readonly entries: readonly StoredEntry[];
95
+ readonly folders: readonly string[];
96
+ }): number;
97
+ export declare function refreshing(connection: Connection, request: {
98
+ readonly key: number;
99
+ readonly composed: Composed;
100
+ readonly entries: readonly StoredEntry[];
101
+ readonly removals: readonly string[];
102
+ readonly folders: readonly string[];
103
+ readonly folderRemovals: readonly string[];
104
+ }): null;
105
+ export declare function unrefresh(connection: Connection, key: number): null;
106
+ export declare function counts(connection: Connection, rooms: readonly CountedRoom[]): number[];
107
+ export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
108
+ export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
109
+ export declare function abandon(connection: Connection, locator: string): null;
110
+ export declare function release(connection: Connection, key: number): null;
111
+ export declare function erase(connection: Connection, locator: string | null, limit: number): {
112
+ readonly remaining: boolean;
113
+ };
114
+ export declare function rederive(connection: Connection, key: number, composed: Composed, bytes: number, ms: number, floor: number): {
115
+ readonly done: boolean;
116
+ readonly text: number;
117
+ };
118
+ export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
119
+ export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
120
+ export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]): Referrer[];
121
+ export declare function files(connection: Connection, key: number, view: View, after: string | null, limit: number): {
122
+ readonly path: string;
123
+ readonly revision: string;
124
+ }[];
125
+ export declare function folders(connection: Connection, key: number, view: View, list: readonly string[]): string[];
126
+ export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
127
+ export declare function opened(connection: Connection): ReplicaOpened;
128
+ export declare function ended(connection: Connection): void;