@agentshouse/app-bridge 0.1.0-c8d8dc6285bbd → 0.1.0-c8dd3de04bf64

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 (95) hide show
  1. package/README.md +7 -7
  2. package/dist/index.d.ts +910 -19
  3. package/dist/mdmodel/definition.d.ts +1 -1
  4. package/dist/mdmodel/document.d.ts +2 -1
  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 +19 -7
  8. package/dist/mdmodel/kinds.d.ts +17 -0
  9. package/dist/mdmodel/pattern.d.ts +9 -0
  10. package/dist/mdmodel/query/language.d.ts +253 -0
  11. package/dist/mdmodel/query/match.d.ts +13 -0
  12. package/dist/mdmodel/query/rows.d.ts +31 -0
  13. package/dist/mdmodel/query/sql.d.ts +38 -0
  14. package/dist/mdmodel/reserved.d.ts +5 -0
  15. package/dist/mdmodel/types.d.ts +11 -0
  16. package/dist/mdmodel/validate.d.ts +7 -5
  17. package/dist/mdruntime/actions.d.ts +19 -0
  18. package/dist/mdruntime/adapter.d.ts +107 -71
  19. package/dist/mdruntime/attached-model.d.ts +7 -0
  20. package/dist/mdruntime/bootstrap.d.ts +43 -0
  21. package/dist/mdruntime/cell.d.ts +5 -0
  22. package/dist/mdruntime/chain.d.ts +2 -1
  23. package/dist/mdruntime/change.d.ts +1 -0
  24. package/dist/mdruntime/client.d.ts +28 -11
  25. package/dist/mdruntime/collection.d.ts +7 -4
  26. package/dist/mdruntime/compile.d.ts +6 -6
  27. package/dist/mdruntime/conversation-live.d.ts +135 -0
  28. package/dist/mdruntime/conversation-row.d.ts +32 -0
  29. package/dist/mdruntime/conversation.d.ts +41 -45
  30. package/dist/mdruntime/durability.d.ts +15 -1
  31. package/dist/mdruntime/figures.d.ts +48 -0
  32. package/dist/mdruntime/holdings.d.ts +28 -0
  33. package/dist/mdruntime/identity.d.ts +0 -1
  34. package/dist/mdruntime/install.d.ts +55 -0
  35. package/dist/mdruntime/job.d.ts +32 -0
  36. package/dist/mdruntime/listing.d.ts +52 -0
  37. package/dist/mdruntime/live.d.ts +22 -0
  38. package/dist/mdruntime/log.d.ts +5 -0
  39. package/dist/mdruntime/media.d.ts +7 -0
  40. package/dist/mdruntime/messages.d.ts +27 -3
  41. package/dist/mdruntime/model.d.ts +8 -10
  42. package/dist/mdruntime/observation.d.ts +3 -2
  43. package/dist/mdruntime/outcome.d.ts +17 -6
  44. package/dist/mdruntime/overlay.d.ts +1 -0
  45. package/dist/mdruntime/preparation.d.ts +19 -0
  46. package/dist/mdruntime/query.d.ts +18 -208
  47. package/dist/mdruntime/reach.d.ts +20 -11
  48. package/dist/mdruntime/readiness.d.ts +3 -18
  49. package/dist/mdruntime/reads.d.ts +36 -0
  50. package/dist/mdruntime/recovery.d.ts +1 -0
  51. package/dist/mdruntime/refresh.d.ts +26 -0
  52. package/dist/mdruntime/replica.d.ts +11 -12
  53. package/dist/mdruntime/room-draft.d.ts +21 -7
  54. package/dist/mdruntime/room-drafts.d.ts +23 -0
  55. package/dist/mdruntime/runtime.d.ts +42 -0
  56. package/dist/mdruntime/save.d.ts +7 -1
  57. package/dist/mdruntime/saves.d.ts +69 -0
  58. package/dist/mdruntime/search.d.ts +12 -63
  59. package/dist/mdruntime/seed.d.ts +11 -2
  60. package/dist/mdruntime/socket/admission.d.ts +6 -0
  61. package/dist/mdruntime/socket/answers.d.ts +5 -0
  62. package/dist/mdruntime/socket/lanes.d.ts +19 -0
  63. package/dist/mdruntime/socket/rooms.d.ts +43 -0
  64. package/dist/mdruntime/socket/session.d.ts +37 -0
  65. package/dist/mdruntime/socket.d.ts +69 -0
  66. package/dist/mdruntime/source.d.ts +60 -0
  67. package/dist/mdruntime/status.d.ts +4 -5
  68. package/dist/mdruntime/store/fences.d.ts +15 -0
  69. package/dist/mdruntime/store/installs.d.ts +29 -0
  70. package/dist/mdruntime/store/readiness.d.ts +9 -0
  71. package/dist/mdruntime/store/records.d.ts +211 -0
  72. package/dist/mdruntime/store/room-held.d.ts +7 -0
  73. package/dist/mdruntime/store/space.d.ts +10 -0
  74. package/dist/mdruntime/store/watchers.d.ts +16 -0
  75. package/dist/mdruntime/store/writes.d.ts +23 -0
  76. package/dist/mdruntime/store.d.ts +105 -158
  77. package/dist/mdruntime/stored.d.ts +66 -55
  78. package/dist/mdruntime/surface.d.ts +87 -0
  79. package/dist/mdruntime/tables.d.ts +131 -69
  80. package/dist/mdruntime/tallies.d.ts +17 -0
  81. package/dist/mdruntime/transfer.d.ts +0 -5
  82. package/dist/mdruntime/turn.d.ts +8 -0
  83. package/dist/mdruntime/wire.d.ts +25 -9
  84. package/dist/test-host.d.ts +1 -4
  85. package/dist/test-host.js +2 -28
  86. package/docs/families.md +49 -53
  87. package/package.json +1 -1
  88. package/dist/calls.d.ts +0 -1007
  89. package/dist/calls.js +0 -1
  90. package/dist/mdmodel/condition.d.ts +0 -160
  91. package/dist/mdmodel/profile.d.ts +0 -5
  92. package/dist/mdruntime/connection.d.ts +0 -151
  93. package/dist/mdruntime/file.d.ts +0 -11
  94. package/dist/mdruntime/fulltext.d.ts +0 -26
  95. package/dist/mdruntime/shared.d.ts +0 -15
@@ -1,169 +1,116 @@
1
- import type { BootstrapInventory, Capability, KeptReceipt, Member, ProviderLimit } from './adapter.js';
1
+ import type { TypedPath } from './adapter.js';
2
+ import { schemaTypes } from './attached-model.js';
3
+ import { type Cell } from './cell.js';
2
4
  import type { ChangeBatch } from './change.js';
5
+ import type { ChangeSet } from './change-set.js';
3
6
  import type { Composition } from './collection.js';
4
- import type { Plan } from './query.js';
5
- import type { ReplicaRecord } from './replica.js';
6
- import type { Submission } from './outcome.js';
7
- import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
7
+ import type { ReadinessWatch } from './preparation.js';
8
+ import type { Persistence } from './readiness.js';
9
+ import type { Listing } from './listing.js';
10
+ import type { Seeded } from './seed.js';
8
11
  import type { ModelState } from './model.js';
9
- import type { SearchWindow } from './search.js';
10
- import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, SearchAsk, StoredEntry, StoredFile, TypedEntry, View, Walked } from './tables.js';
11
- export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
12
- export type TransferWriting = {
13
- readonly token: string | null;
14
- readonly written: number;
12
+ import { type OpenedFiles } from './opened.js';
13
+ import { type HeldReplica, type ReplicaRecord } from './replica.js';
14
+ import type { RoomDraftRecord } from './room-draft.js';
15
+ import { type SyncStatus } from './status.js';
16
+ import type { RuntimeDatabase } from './tables.js';
17
+ import { type Fences } from './store/fences.js';
18
+ import { type Installs } from './store/installs.js';
19
+ import { type HeldCover, type PendingState, type RuntimeStore } from './store/records.js';
20
+ import { type ReadinessQueue } from './store/readiness.js';
21
+ import { type RoomHeld } from './store/room-held.js';
22
+ import { type Space } from './store/space.js';
23
+ import { type Watcher, type Watching } from './store/watchers.js';
24
+ import { createWrites, type InstallHold } from './store/writes.js';
25
+ export { NO_INSTALL, type RoomInstall } from './store/installs.js';
26
+ export type { AuthoredWrite, ChatDraftRecord, ChatSubmission, CoveredRoom, Facts, HeldConversation, HeldCover, PendingState, RefreshedPage, RuntimeStore, StagedPage, TransferRecord, } from './store/records.js';
27
+ export type { InstallHold } from './store/writes.js';
28
+ export type { CommittedWrite, QueryRoom, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, View, } from './tables.js';
29
+ export type Stored = {
30
+ readonly record: ReplicaRecord;
31
+ readonly indexed: boolean;
32
+ readonly documents: number;
15
33
  };
16
- export type TransferRecord = {
17
- readonly locator: string;
18
- readonly transfer: string;
19
- readonly selection: string;
20
- readonly from: string;
21
- readonly last: string;
22
- readonly pageToken: string | null;
23
- readonly writing: TransferWriting | null;
24
- readonly inventory: BootstrapInventory | null;
25
- readonly done: BootstrapInventory;
26
- readonly models: {
27
- readonly collection: ModelState;
28
- readonly selection: ModelState;
29
- };
30
- readonly key: number | null;
34
+ export type Held = HeldReplica & {
35
+ readonly states: ReadonlyMap<string, PendingState>;
31
36
  };
32
- export type PendingState = {
33
- readonly drafts: readonly SavedDraft[];
34
- readonly submission: Submission;
35
- readonly lost: boolean;
36
- readonly upload?: unknown;
37
- readonly accepted?: string;
37
+ export type Work = {
38
+ readonly replica: Held | undefined;
39
+ readonly queue: readonly ChangeBatch[];
40
+ readonly states: ReadonlyMap<string, PendingState>;
38
41
  };
39
- export type TargetRecord = {
40
- established: boolean;
42
+ type LandedAhead = Readonly<Record<string, string | undefined>>;
43
+ type AttachedFile = {
44
+ readonly revision: string;
45
+ readonly mediaType: string;
41
46
  };
42
- export type QueueRecord = {
43
- locator: string;
44
- pending: readonly {
45
- batch: ChangeBatch;
46
- state: PendingState;
47
- }[];
47
+ type Seeds = {
48
+ of(key: string): Seeded | undefined;
49
+ keep(key: string, seed: Seeded): void;
50
+ drop(key: string): void;
48
51
  };
49
- export type PresentationRecord = {
50
- app: string;
51
- value: unknown;
52
+ type Device = {
53
+ readonly persistence: Persistence;
54
+ readonly storageLoss: string | null;
55
+ readonly heldWhenOpened: boolean;
56
+ readonly preparing: boolean;
57
+ readonly sweeping: boolean;
58
+ readonly unpreparedDemand: ReadonlySet<string>;
59
+ readonly establishing: ReadonlySet<string>;
60
+ readonly status: SyncStatus;
61
+ readonly roomsShown: Listing | null;
52
62
  };
53
- export type ChatSubmission = {
54
- readonly operation: string;
55
- readonly text: string;
56
- readonly turn: string | null;
63
+ type StoreOptions = {
64
+ readonly database: RuntimeDatabase;
65
+ readonly roomTypes: Parameters<typeof schemaTypes>[1];
66
+ readonly builtIn: ModelState;
67
+ readonly typedPaths: readonly TypedPath[];
68
+ readonly persistence: Persistence;
69
+ opening(records: RuntimeStore): Promise<RuntimeStore>;
70
+ unpublished(error: unknown): void;
71
+ changed(set: ChangeSet): Promise<void>;
72
+ deliverReadiness(owed: readonly ReadinessWatch[]): Promise<void>;
73
+ spaceFreed(): void;
57
74
  };
58
- export type ChatDraftRecord = {
59
- conversation: string;
60
- text: string;
61
- revision: string;
62
- submitted?: readonly ChatSubmission[];
63
- moves?: readonly string[];
75
+ export type Store = {
76
+ readonly device: Cell<Device>;
77
+ readonly space: Space;
78
+ readonly readiness: ReadinessQueue<ReadinessWatch>;
79
+ ask: RuntimeDatabase['ask'];
80
+ changed(set: ChangeSet): Promise<void>;
81
+ open(): Promise<RuntimeStore>;
82
+ durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
83
+ exclusive<T>(work: () => Promise<T>): Promise<T>;
84
+ gathered<I, T>(key: string, input: I, merge: (earlier: I, later: I) => I | null, work: (input: I) => Promise<T>): Promise<T>;
85
+ written(): Promise<unknown>;
86
+ startingWrite<T>(work: () => Promise<T>): Promise<T>;
87
+ finishingWrite<T>(work: () => Promise<T>): Promise<T>;
88
+ ahead<T>(work: (hold: InstallHold) => Promise<T>): Promise<T>;
89
+ rederive: ReturnType<typeof createWrites>['rederive'];
90
+ refreshPage: ReturnType<typeof createWrites>['refreshPage'];
91
+ stageBytes(): number;
92
+ deriveBytes(): number;
93
+ rooms(locators?: readonly string[]): Promise<ReadonlyMap<string, Stored>>;
94
+ record(locator: string): Promise<ReplicaRecord | undefined>;
95
+ work(locator: string): Promise<Work>;
96
+ replica(locator: string): Promise<Held | undefined>;
97
+ covering(): Promise<HeldCover>;
98
+ drafts(locator?: string, paths?: readonly string[]): Promise<readonly RoomDraftRecord[]>;
99
+ draft(locator: string, path: string): Promise<RoomDraftRecord | undefined>;
100
+ composed(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>): Composition;
101
+ publication(work: () => Promise<void>): Promise<void>;
102
+ owing<T>(topic: string, add: (owed: T | undefined) => T, work: (owed: T) => Promise<void>): Promise<void>;
103
+ watch(topic: string, notify: (value: unknown) => void): Watcher;
104
+ watching(topic: string, which?: Watching): readonly Watcher[];
105
+ tell(topic: string, value: unknown): void;
106
+ readonly fences: Fences;
107
+ readonly installs: Installs;
108
+ readonly seeds: Seeds;
109
+ readonly landed: RoomHeld<LandedAhead>;
110
+ readonly attached: RoomHeld<AttachedFile>;
111
+ readonly opened: OpenedFiles;
112
+ part(file: string, part: number): Promise<Uint8Array | null>;
113
+ forget(locator: string): void;
114
+ close(): void;
64
115
  };
65
- export type CallRecord = {
66
- readonly operation: string;
67
- readonly name: string;
68
- readonly input: unknown;
69
- };
70
- export type AuthoredWrite = {
71
- locator: string;
72
- queue?: readonly ChangeBatch[];
73
- founded?: readonly ChangeBatch[];
74
- saved?: ReadonlyMap<string, readonly SavedDraft[]>;
75
- roomDrafts?: readonly RoomDraftRecord[];
76
- consumedRoomDrafts?: readonly string[];
77
- accepted?: readonly {
78
- readonly id: string;
79
- readonly roomVersion: string;
80
- }[];
81
- };
82
- export type StagedPage = {
83
- readonly entries: readonly StoredEntry[];
84
- readonly folders: readonly string[];
85
- };
86
- export type RefreshedPage = StagedPage & {
87
- readonly removals: readonly string[];
88
- readonly folderRemovals: readonly string[];
89
- };
90
- export type Opened = {
91
- readonly rooms: ReadonlyMap<string, ReplicaRecord>;
92
- readonly transfers: ReadonlyMap<string, TransferRecord>;
93
- readonly unindexed: ReadonlySet<number>;
94
- readonly overlaid: ReadonlyMap<number, ReadonlySet<string>>;
95
- readonly erasing: boolean;
96
- readonly orphans: readonly number[];
97
- readonly lastCompleted: string | null;
98
- readonly providerLimits: readonly ProviderLimit[];
99
- readonly capabilities: readonly Capability[];
100
- readonly member: Member | null;
101
- readonly targets: Readonly<Record<string, TargetRecord>>;
102
- readonly presentation: readonly PresentationRecord[];
103
- };
104
- export type Commit = {
105
- readonly rooms: readonly RoomCommit[];
106
- readonly writes?: readonly AuthoredWrite[];
107
- readonly files?: readonly StoredFile[];
108
- readonly whole?: boolean;
109
- readonly discards?: readonly string[];
110
- };
111
- export type RuntimeStore = {
112
- opened(): Promise<Opened>;
113
- counts(rooms: readonly CountedRoom[]): Promise<readonly number[]>;
114
- query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
115
- changes(keys: readonly number[]): number;
116
- entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
117
- typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
118
- referrers(key: number, view: View, targets: readonly string[], kinds: readonly string[]): Promise<readonly Referrer[]>;
119
- walk(key: number, view: View, after: string | null, bytes: number): Promise<Walked>;
120
- files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
121
- readonly path: string;
122
- readonly revision: string;
123
- }[]>;
124
- typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
125
- search(ask: SearchAsk): Promise<SearchWindow>;
126
- stage(record: TransferRecord, composition: Composition, page: StagedPage, written?: string): Promise<number | null>;
127
- transferPart(locator: string, token: string): Promise<Uint8Array | null>;
128
- keepPart(locator: string, token: string, part: Uint8Array): Promise<void>;
129
- refresh(key: number, page: RefreshedPage): Promise<void>;
130
- unrefresh(key: number): Promise<void>;
131
- commit(commit: Commit): Promise<CommittedWrite>;
132
- fence(locators: readonly string[]): Promise<void>;
133
- erase(locator: string | null, limit: number): Promise<boolean>;
134
- abandon(locator: string, kept?: boolean): Promise<number | null>;
135
- release(key: number): Promise<void>;
136
- rederive(key: number, limit: number): Promise<boolean>;
137
- fact(name: string, value: unknown): Promise<void>;
138
- queues(): Promise<readonly QueueRecord[]>;
139
- submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
140
- keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
141
- roomDrafts(): Promise<readonly RoomDraftRecord[]>;
142
- present(record: PresentationRecord): Promise<void>;
143
- conversations(): Promise<readonly HeldConversation[]>;
144
- keepMessages(write: ConversationWrite): Promise<void>;
145
- messageWindow(conversation: string, limit: number, before: readonly [string, string] | null): Promise<MessageWindow>;
146
- messageCount(conversation: string): Promise<number>;
147
- turnArrived(conversation: string, turn: string): Promise<boolean>;
148
- dropConversations(conversations: readonly string[]): Promise<void>;
149
- chatDrafts(): Promise<readonly ChatDraftRecord[]>;
150
- keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
151
- dropChatDraft(conversation: string): Promise<void>;
152
- calls(): Promise<readonly CallRecord[]>;
153
- keepCall(record: CallRecord): Promise<void>;
154
- dropCall(operation: string): Promise<void>;
155
- keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
156
- discardRoomDraft(locator: string, path: string): Promise<void>;
157
- fences(): Promise<readonly string[]>;
158
- receivedHeads(): Promise<readonly KeptReceipt[]>;
159
- receivedParts(key: string, count: number): Promise<readonly unknown[]>;
160
- keepReceived(key: string, head: unknown, part?: {
161
- index: number;
162
- value: unknown;
163
- }): Promise<void>;
164
- dropReceived(keys: readonly string[]): Promise<void>;
165
- generation(): Promise<string | null>;
166
- rememberGeneration(value: string): Promise<void>;
167
- file(key: string, type: string): Promise<Blob>;
168
- };
169
- export declare function openRuntimeStore(fenced: (locator: string) => boolean, authored: RuntimeDatabase): RuntimeStore;
116
+ export declare function createStore(options: StoreOptions): Store;
@@ -1,5 +1,5 @@
1
- import type { HeadChange } from './adapter.js';
2
- import type { Composition } from './collection.js';
1
+ import type { SavedFacts, HeadChange } from './adapter.js';
2
+ import { type Composed, type Composition } from './collection.js';
3
3
  import type { HeldBinary } from './overlay.js';
4
4
  import type { Connection } from './tables.js';
5
5
  export declare const REPLICA_TABLES: readonly string[];
@@ -10,8 +10,10 @@ export type StoredEntry = {
10
10
  readonly binary: HeldBinary | null;
11
11
  readonly revision: string | null;
12
12
  readonly fileId: string | null;
13
+ readonly created: string | null;
13
14
  readonly change: HeadChange | null;
14
15
  readonly written: string | null;
16
+ readonly facts: SavedFacts | null;
15
17
  };
16
18
  export type OverlayEntry = StoredEntry & {
17
19
  readonly present: boolean;
@@ -27,39 +29,46 @@ export type TypedEntry = {
27
29
  export type Referrer = {
28
30
  readonly path: string;
29
31
  readonly target: string;
30
- readonly kind: string;
31
32
  };
32
- export type HeldKey = {
33
- readonly key: number;
33
+ export type HeldRoomRow = {
34
34
  readonly locator: string;
35
- readonly transfer: string;
36
- readonly rederiving: number | null;
35
+ readonly key: number;
36
+ readonly record: string;
37
+ readonly indexed: boolean;
38
+ readonly documents: number;
37
39
  };
38
- export type ReplicaOpened = {
39
- readonly rooms: readonly {
40
- readonly locator: string;
41
- readonly key: number;
42
- readonly record: string;
40
+ export type HeldRoomWork = {
41
+ readonly room: (HeldRoomRow & {
42
+ readonly overlaid: readonly string[];
43
+ }) | null;
44
+ readonly queue: readonly {
45
+ readonly id: string;
46
+ readonly batch: string;
47
+ readonly state: string;
43
48
  }[];
44
- readonly transfers: readonly {
49
+ };
50
+ export type Covering = {
51
+ readonly rooms: readonly {
45
52
  readonly locator: string;
46
53
  readonly key: number;
47
- readonly record: string;
54
+ readonly transfer: string;
55
+ readonly roomVersion: string;
56
+ readonly indexed: boolean;
57
+ readonly documents: number;
58
+ readonly bytes: number;
59
+ readonly offline: string;
48
60
  }[];
49
- readonly keys: readonly HeldKey[];
50
- readonly facts: Readonly<Record<string, string>>;
51
- readonly presentation: readonly {
52
- readonly app: string;
53
- readonly value: string;
54
- }[];
55
- readonly overlaid: readonly {
56
- readonly key: number;
57
- readonly path: string;
58
- }[];
59
- readonly erasing: readonly {
60
- readonly key: number;
61
+ readonly queues: readonly {
61
62
  readonly locator: string;
63
+ readonly ids: readonly string[];
62
64
  }[];
65
+ };
66
+ export type HeldLocators = {
67
+ readonly held: readonly string[];
68
+ readonly staged: readonly string[];
69
+ };
70
+ export type ReplicaOpened = {
71
+ readonly erasing: boolean;
63
72
  readonly orphans: readonly number[];
64
73
  };
65
74
  export type RoomCommit = {
@@ -71,7 +80,7 @@ export type RoomCommit = {
71
80
  readonly from: number | null;
72
81
  };
73
82
  readonly refreshed?: true;
74
- readonly composition?: Composition;
83
+ readonly composed: Composed;
75
84
  readonly confirmed?: {
76
85
  readonly set: readonly StoredEntry[];
77
86
  readonly removed: readonly string[];
@@ -82,63 +91,65 @@ export type RoomCommit = {
82
91
  };
83
92
  };
84
93
  export type Committed = {
85
- readonly counts: Readonly<Record<string, number>>;
86
94
  readonly changed: Readonly<Record<string, readonly string[] | null>>;
87
95
  readonly indexed: Readonly<Record<string, boolean>>;
88
96
  };
89
- export type CountedRoom = {
90
- readonly key: number;
91
- readonly roots: readonly string[];
92
- };
93
- export type Walked = {
94
- readonly entries: readonly HeldEntry[];
95
- readonly next: string | null;
96
- };
97
- export declare function fingerprint(composition: Composition): string;
98
97
  export declare function entered(connection: Connection, locator: string, composition: Composition, rows: readonly StoredEntry[]): number;
99
98
  export declare function stage(connection: Connection, request: {
100
99
  readonly locator: string;
101
100
  readonly transfer: string;
102
- readonly record: string;
103
101
  readonly key: number | null;
104
- readonly composition: Composition;
102
+ readonly fingerprint: string;
105
103
  readonly entries: readonly StoredEntry[];
106
104
  readonly folders: readonly string[];
107
- readonly written?: string;
105
+ readonly part: string | null;
108
106
  }): number;
107
+ export type Resumed = {
108
+ readonly key: number | null;
109
+ readonly transfer: string;
110
+ readonly staged: readonly string[];
111
+ };
112
+ export declare function resume(connection: Connection, request: {
113
+ readonly locator: string;
114
+ readonly transfer: string;
115
+ readonly fingerprint: string;
116
+ readonly parts: readonly string[];
117
+ readonly published: number | null;
118
+ }): Resumed;
109
119
  export declare function refreshing(connection: Connection, request: {
110
120
  readonly key: number;
121
+ readonly composed: Composed;
111
122
  readonly entries: readonly StoredEntry[];
112
123
  readonly removals: readonly string[];
113
124
  readonly folders: readonly string[];
114
125
  readonly folderRemovals: readonly string[];
115
126
  }): null;
116
127
  export declare function unrefresh(connection: Connection, key: number): null;
117
- export declare function counts(connection: Connection, rooms: readonly CountedRoom[]): number[];
118
128
  export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
119
129
  export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
120
- export declare function abandon(connection: Connection, locator: string, kept: boolean): number | null;
130
+ export declare function abandon(connection: Connection, locator: string): null;
121
131
  export declare function release(connection: Connection, key: number): null;
122
132
  export declare function erase(connection: Connection, locator: string | null, limit: number): {
123
133
  readonly remaining: boolean;
124
134
  };
125
- export declare function rederive(connection: Connection, key: number, limit: number): {
135
+ export declare function rederive(connection: Connection, key: number, composed: Composed, bytes: number, ms: number, floor: number): {
126
136
  readonly done: boolean;
137
+ readonly text: number;
127
138
  };
128
139
  export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
129
140
  export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
130
- export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[], kinds: readonly string[]): Referrer[];
131
- export declare function walk(connection: Connection, key: number, view: View, after: string | null, bytes: number): Walked;
132
- export declare function files(connection: Connection, key: number, view: View, after: string | null, limit: number): {
133
- readonly path: string;
134
- readonly revision: string;
135
- }[];
141
+ export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]): Referrer[];
142
+ export declare function folders(connection: Connection, key: number, list: readonly string[]): string[];
136
143
  export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
137
- export declare function transferPart(connection: Connection, locator: string, token: string): Uint8Array | null;
138
- export declare function keepPart(connection: Connection, request: {
139
- readonly locator: string;
140
- readonly token: string;
141
- readonly part: Uint8Array;
142
- }): null;
143
144
  export declare function opened(connection: Connection): ReplicaOpened;
145
+ export declare function heldRooms(connection: Connection, locators: readonly string[] | null): readonly HeldRoomRow[];
146
+ export declare function heldRoom(connection: Connection, locator: string): HeldRoomRow | null;
147
+ export declare function overlaid(connection: Connection, key: number): readonly string[];
148
+ export declare function covering(connection: Connection): Covering['rooms'];
149
+ export declare function offlineMode(connection: Connection, locator: string): string | null;
150
+ export declare function stagedLocators(connection: Connection): readonly string[];
151
+ export declare function heldLocators(connection: Connection): readonly string[];
152
+ export declare function demoted(connection: Connection): null;
153
+ export declare function facts(connection: Connection): Readonly<Record<string, string>>;
154
+ export declare function presentation(connection: Connection, app: string): string | null;
144
155
  export declare function ended(connection: Connection): void;
@@ -0,0 +1,87 @@
1
+ import type { DocumentQuery, GroupQuery } from '../mdmodel/index.js';
2
+ import { type HistoryQuery } from './actions.js';
3
+ import type { Member, ServiceMode } from './adapter.js';
4
+ import type { WrittenBy } from './change.js';
5
+ import { type ChatDraftSurface, type ConversationEntry, type ConversationAgent, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
6
+ import type { UnsentWork } from './durability.js';
7
+ import type { FiguresResult } from './figures.js';
8
+ import { type Holdings } from './holdings.js';
9
+ import { type AppRoom } from './listing.js';
10
+ import { type TypesResult } from './model.js';
11
+ import { type Observation } from './observation.js';
12
+ import type { HistoryAnswer, QueueEntry, Resolution, CallResult } from './outcome.js';
13
+ import { type ReadinessPort } from './preparation.js';
14
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
15
+ import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
16
+ import type { Persistence, Readiness } from './readiness.js';
17
+ import type { ObservedRead } from './reads.js';
18
+ import type { RoomDraft } from './room-draft.js';
19
+ import { type PresentationSurface, type RoomDraftSurface } from './room-drafts.js';
20
+ import type { Runtime } from './runtime.js';
21
+ import { type BinaryFileSurface, type SavedParts, type SavedRoomDraft, type SaveResult } from './saves.js';
22
+ import type { SearchRequest, SearchResult } from './search.js';
23
+ import { type EntrySeed } from './seed.js';
24
+ import type { ConnectionRefusal } from './socket.js';
25
+ import type { SyncStatus } from './status.js';
26
+ export type RoomSchemas = {
27
+ collection: TypesResult;
28
+ typedSelection: TypesResult | null;
29
+ };
30
+ export type MdRuntime = {
31
+ loaded(): Promise<void>;
32
+ rooms(): Promise<readonly AppRoom[]>;
33
+ query: {
34
+ (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
35
+ (query: GroupQuery): Promise<GroupResult | PendingResult>;
36
+ };
37
+ search(request: SearchRequest): Promise<SearchResult>;
38
+ types(locator: string): Promise<RoomSchemas>;
39
+ roomDraft: RoomDraftSurface;
40
+ conversation: ConversationSurface;
41
+ chatDraft: ChatDraftSurface;
42
+ presentation: PresentationSurface;
43
+ save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
44
+ saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
45
+ history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
46
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
47
+ binaryFile: BinaryFileSurface;
48
+ call(name: string, input: unknown): Promise<CallResult>;
49
+ reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
50
+ log(): string;
51
+ persistence(): boolean;
52
+ retry(): Promise<void>;
53
+ cleanUp(): Promise<number>;
54
+ unsent(): Promise<readonly UnsentWork[]>;
55
+ reset(): Promise<void>;
56
+ readAgain(): Promise<void>;
57
+ observe: {
58
+ (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
59
+ (topic: 'readiness'): Promise<Observation<Readiness>>;
60
+ (topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
61
+ (topic: 'storage-loss'): Promise<Observation<string | null>>;
62
+ (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
63
+ (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
64
+ (topic: 'member'): Promise<Observation<Member | null>>;
65
+ (topic: 'authority-changes'): Promise<Observation<number>>;
66
+ (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
67
+ (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
68
+ (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
69
+ (topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
70
+ (topic: 'presentation', app: string): Promise<Observation<unknown>>;
71
+ (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
72
+ (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
73
+ (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
74
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
75
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
76
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
77
+ };
78
+ reauthorize(): Promise<void>;
79
+ };
80
+ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents' | 'figures' | 'holdings' | 'read';
81
+ export type ComposedRuntime = RuntimeView & {
82
+ seed(entry: EntrySeed): void;
83
+ stop(): Promise<void>;
84
+ persisted(answer: Persistence): void;
85
+ within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
86
+ };
87
+ export declare function composedRuntime(runtime: Runtime): ComposedRuntime;