@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
@@ -1,10 +1,13 @@
1
- import type { ActionResult, AdapterFailure, BinaryResult, HistoryResult, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
1
+ import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
2
2
  import type { ChangeBatch } from './change.js';
3
+ import type { KeptBinary, KeptResult } from './opened.js';
3
4
  type Refused<Kind extends string> = ProviderRefusal & {
4
5
  kind: Kind;
5
6
  };
6
7
  export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
7
8
  locator: string;
9
+ }) | (Refused<'room-locked'> & {
10
+ locator: string;
8
11
  }) | ScopedRefusal;
9
12
  export type CallResult = {
10
13
  kind: 'action';
@@ -14,12 +17,50 @@ export type CallResult = {
14
17
  export type HistoryAnswer = Exclude<HistoryResult, {
15
18
  kind: Failure['kind'];
16
19
  }> | Failure;
20
+ type BinaryRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
17
21
  export type BinaryAnswer = {
18
22
  kind: 'binary';
19
- blob: Blob;
23
+ stream: ReadableStream<Uint8Array>;
24
+ byteLength: number;
25
+ mediaType: string;
26
+ } | BinaryRefusal;
27
+ export type HeldBinaryAnswer = KeptBinary | BinaryRefusal;
28
+ export type BinaryLinkAnswer = {
29
+ kind: 'link';
30
+ url: string;
31
+ name: string;
32
+ mediaType: string;
20
33
  } | Refused<'rejected'> | Refused<'absent'> | Failure;
21
- export declare function absentBinary(path: string): BinaryAnswer;
22
- export declare function binaryAnswer(result: BinaryResult): BinaryAnswer;
34
+ export type HeldShownAnswer = KeptBinary | BinaryLinkAnswer;
35
+ export type ShownAnswer = BinaryAnswer | BinaryLinkAnswer;
36
+ export type AttachAnswer = {
37
+ kind: 'attached';
38
+ path: string;
39
+ } | Offline | Refused<'rejected'> | Failure;
40
+ export type DownloadAnswer = {
41
+ kind: 'started';
42
+ } | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
43
+ export type Resolution = {
44
+ readonly kind: 'document';
45
+ readonly room: string;
46
+ readonly path: string;
47
+ } | {
48
+ readonly kind: 'deleted';
49
+ readonly room: string;
50
+ readonly path: string;
51
+ readonly revision: HistoryRevision;
52
+ } | Refused<'unreadable'> | Refused<'absent'> | Failure;
53
+ export declare const UNREADABLE: Refused<'unreadable'>;
54
+ export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
55
+ export declare const ABSENT_TARGET: Refused<'absent'>;
56
+ export declare function absentBinary(path: string): Refused<'absent'>;
57
+ export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
58
+ export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
59
+ export declare function attachAnswer(result: AttachResult): AttachAnswer;
60
+ export declare const ROOM_LOCKED = "room-locked";
61
+ export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
62
+ locator: string;
63
+ };
23
64
  export type Offline = {
24
65
  readonly kind: 'offline';
25
66
  };
@@ -39,8 +80,5 @@ export type QueueEntry = {
39
80
  readonly batch: ChangeBatch;
40
81
  } & (Submission | {
41
82
  readonly state: 'local';
42
- } | {
43
- readonly state: 'accepted';
44
- readonly roomVersion: string;
45
83
  });
46
84
  export {};
@@ -3,6 +3,7 @@ import type { ChangeBatch } from './change.js';
3
3
  export type Heads = {
4
4
  revisions: Readonly<Record<string, string>>;
5
5
  fileIds: Readonly<Record<string, string>>;
6
+ created: Readonly<Record<string, string>>;
6
7
  changes: Readonly<Record<string, HeadChange>>;
7
8
  };
8
9
  export type HeldBinary = ({
@@ -18,10 +19,7 @@ export type Layer = Heads & {
18
19
  documents: Readonly<Record<string, string>>;
19
20
  binaries: Readonly<Record<string, HeldBinary>>;
20
21
  };
21
- export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Record<string, HeldBinary>;
22
+ export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
22
23
  export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
23
24
  export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
24
- export declare function overlay(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Layer;
25
- export declare function sameLayerText(left: Layer, right: Layer): boolean;
26
- export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
27
- export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
25
+ export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
@@ -1,86 +1,7 @@
1
- import { type Definition } from '../mdmodel/index.js';
1
+ import { type HeldRooms, type QueryPlan } from '../mdmodel/index.js';
2
2
  import type { HeadChange } from './adapter.js';
3
3
  import type { BinaryFileRecord } from './binary.js';
4
4
  import type { Open } from './open.js';
5
- export type Value = string | number | boolean | null;
6
- export type Predicate = Value | {
7
- $eq: Value;
8
- } | {
9
- $ne: Value;
10
- } | {
11
- $in: readonly Value[];
12
- } | {
13
- $nin: readonly Value[];
14
- } | {
15
- $gt?: Value;
16
- $gte?: Value;
17
- $lt?: Value;
18
- $lte?: Value;
19
- } | {
20
- $all: readonly Value[];
21
- } | {
22
- $size: number;
23
- } | {
24
- $exists: boolean;
25
- };
26
- export type Where = {
27
- $and?: readonly Where[];
28
- $or?: readonly Where[];
29
- [field: string]: Predicate | readonly Where[] | undefined;
30
- };
31
- export type Related = {
32
- types?: readonly string[];
33
- where?: Where;
34
- pathPrefix?: string;
35
- };
36
- export type Filter = {
37
- rooms?: readonly string[];
38
- types?: readonly string[];
39
- where?: Where;
40
- pathPrefix?: string;
41
- hop?: Related & {
42
- field: string;
43
- };
44
- backlinks?: Related & {
45
- field?: string;
46
- };
47
- };
48
- export type Key = 'room' | 'path' | 'type' | {
49
- field: string;
50
- };
51
- export type Select = 'all' | {
52
- fields?: 'all' | readonly string[];
53
- sections?: 'all' | readonly string[];
54
- preamble?: true;
55
- markdown?: true;
56
- backlinks?: true;
57
- change?: true;
58
- fileId?: true;
59
- };
60
- export type OrderOptions = {
61
- nulls?: 'first' | 'last';
62
- stringSort?: 'lexical' | 'locale';
63
- locale?: string;
64
- localeOptions?: Readonly<Record<string, unknown>>;
65
- };
66
- export type Direction = 'asc' | 'desc';
67
- export type DocumentQuery = Filter & {
68
- select: Select;
69
- orderBy?: readonly ({
70
- by: Key;
71
- direction?: Direction;
72
- } & OrderOptions)[];
73
- limit?: number;
74
- };
75
- export type GroupQuery = Filter & {
76
- groupBy: readonly Exclude<Key, 'path'>[];
77
- orderBy?: readonly {
78
- by: 'count' | Exclude<Key, 'path'>;
79
- direction?: Direction;
80
- }[];
81
- limit?: number;
82
- };
83
- export type LocalQuery = DocumentQuery | GroupQuery;
84
5
  export type Backlink = {
85
6
  path: string;
86
7
  type: string;
@@ -97,6 +18,7 @@ export type QueryDocument = {
97
18
  backlinks?: readonly Backlink[];
98
19
  change?: HeadChange | null;
99
20
  fileId?: string | null;
21
+ revision?: string | null;
100
22
  binaryFile?: BinaryFileRecord;
101
23
  };
102
24
  export type QueryGroup = {
@@ -113,7 +35,7 @@ export type QueryCoverage = {
113
35
  indexes: readonly string[];
114
36
  overlay: readonly string[];
115
37
  };
116
- export type Awaits = Open<'acquisition' | 'preparation' | 'index'>;
38
+ export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
117
39
  export type PendingRoom = {
118
40
  room: string;
119
41
  awaits: Awaits;
@@ -123,9 +45,13 @@ export type PendingResult = {
123
45
  };
124
46
  export type DocumentRows = {
125
47
  documents: readonly QueryDocument[];
48
+ next?: string;
49
+ total?: number;
126
50
  };
127
51
  export type GroupRows = {
128
52
  groups: readonly QueryGroup[];
53
+ next?: string;
54
+ total?: number;
129
55
  };
130
56
  export type QueryRows = DocumentRows | GroupRows;
131
57
  export type DocumentResult = DocumentRows & {
@@ -135,119 +61,18 @@ export type GroupResult = GroupRows & {
135
61
  coverage: QueryCoverage;
136
62
  };
137
63
  export type QueryResult = DocumentResult | GroupResult | PendingResult;
138
- export type QueryErrorCode = 'invalid-query' | 'unknown-type' | 'unknown-field' | 'wrong-kind';
139
- export type RoomFacts = {
140
- locator: string;
141
- available: boolean;
142
- types: readonly Definition[];
143
- };
144
- export type HeldRooms = {
145
- listed: boolean;
146
- rooms: readonly RoomFacts[];
147
- };
148
- export type Test = {
149
- op: 'eq';
150
- value: Value;
151
- } | {
152
- op: 'ne';
153
- value: Value;
154
- } | {
155
- op: 'in';
156
- values: readonly Value[];
157
- } | {
158
- op: 'nin';
159
- values: readonly Value[];
160
- } | {
161
- op: 'range';
162
- bounds: readonly (readonly ['gt' | 'gte' | 'lt' | 'lte', Value])[];
163
- } | {
164
- op: 'all';
165
- values: readonly Value[];
166
- } | {
167
- op: 'size';
168
- size: number;
169
- } | {
170
- op: 'exists';
171
- exists: boolean;
172
- };
173
- export type Condition = {
174
- every: readonly Condition[];
175
- } | {
176
- some: readonly Condition[];
177
- } | {
178
- field: string;
179
- test: Test;
180
- };
181
- export type Scope = {
182
- types: readonly string[] | null;
183
- where: Condition | null;
184
- pathPrefix: string | null;
185
- };
186
- export type KeyPlan = {
187
- of: 'room';
188
- } | {
189
- of: 'path';
190
- } | {
191
- of: 'type';
192
- } | {
193
- of: 'field';
194
- field: string;
195
- };
196
- export type DocumentShape = {
197
- kind: 'documents';
198
- fields: 'all' | readonly string[] | null;
199
- sections: 'all' | readonly string[] | null;
200
- preamble: boolean;
201
- markdown: boolean;
202
- backlinks: boolean;
203
- change: boolean;
204
- fileId: boolean;
205
- orderBy: readonly {
206
- key: KeyPlan;
207
- options: OrderOptions & {
208
- direction: Direction;
209
- };
210
- }[];
211
- };
212
- export type GroupShape = {
213
- kind: 'groups';
214
- groupBy: readonly KeyPlan[];
215
- orderBy: readonly {
216
- by: 'count' | number;
217
- direction: Direction;
218
- }[];
64
+ export type PlanArea = {
65
+ room: string;
66
+ path: string;
67
+ open: readonly string[];
219
68
  };
220
69
  export type PlanReach = {
221
70
  rooms: readonly string[];
222
71
  documents: readonly string[];
72
+ areas: readonly PlanArea[];
223
73
  };
224
- export type Plan = {
225
- key: string;
226
- rooms: readonly string[] | null;
74
+ export type Plan = QueryPlan & {
227
75
  reach: PlanReach | null;
228
- root: Scope;
229
- hop: (Scope & {
230
- field: string;
231
- }) | null;
232
- backlinks: (Scope & {
233
- field: string | null;
234
- }) | null;
235
- shape: DocumentShape | GroupShape;
236
- limit: number | null;
76
+ locked: readonly string[];
237
77
  };
238
- export declare class QueryError extends Error {
239
- readonly code: QueryErrorCode;
240
- readonly retryable = false;
241
- constructor(code: QueryErrorCode, at: string, problem: string);
242
- }
243
- type Entries = Readonly<Record<string, unknown>>;
244
- export declare function invalid(at: string, problem: string): never;
245
- export declare function plain(value: unknown): value is Entries;
246
- export declare function known(value: Entries, allowed: readonly string[], at: string): void;
247
- export declare function flag(input: unknown, at: string): boolean;
248
- export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
249
- export declare function limitOf(input: unknown): number | null;
250
- export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
251
- export declare function queryKey(query: unknown): string;
252
- export declare function identityOf(plan: Plan): string;
253
- export {};
78
+ export declare function planWithin(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
@@ -1,34 +1,43 @@
1
- import type { ReferrerScope } from './adapter.js';
2
- import type { MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
1
+ import type { AppRoom, MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
3
2
  import type { Plan, PlanReach, QueryResult } from './query.js';
4
3
  import type { Readiness } from './readiness.js';
5
- import { type SearchResult } from './search.js';
4
+ import type { SearchResult } from './search.js';
6
5
  export type ReachedDocument = {
7
6
  readonly room: string;
8
7
  readonly path: string;
9
8
  };
9
+ export type ReachedArea = {
10
+ readonly room: string;
11
+ readonly path: string;
12
+ readonly open: readonly string[];
13
+ };
10
14
  export type PortReach = {
11
15
  readonly rooms: readonly string[];
12
16
  readonly documents: readonly ReachedDocument[];
17
+ readonly areas?: readonly ReachedArea[];
13
18
  readonly conversations: boolean;
14
19
  };
15
20
  export type Deliver = (message: unknown) => void;
16
- export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver) => () => void;
21
+ export type Fail = (error: unknown) => void;
22
+ export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver, fail: Fail) => () => void;
17
23
  export type RuntimeView = {
18
24
  md: MdRuntime;
19
25
  watch: Watch;
20
26
  };
21
27
  export type NarrowedView = RuntimeView & {
22
28
  narrow(reach: PortReach | null): void;
23
- facts(port: ReadinessPort): void;
24
29
  };
25
30
  export type Reachable = RuntimeView & {
26
- plan(input: unknown, reach: PortReach | null): Plan;
31
+ plan(input: unknown, reach: PortReach | null): Promise<Plan>;
27
32
  query(plan: Plan): Promise<QueryResult>;
28
- watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
33
+ watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
29
34
  search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
30
35
  watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
31
- referrerScope(referrer: unknown): ReferrerScope | null;
36
+ locked(room: string): Promise<boolean>;
37
+ lockedRooms(): Promise<readonly string[]>;
38
+ watchLocks(notify: () => void): () => void;
39
+ located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
40
+ room(locator: string): Promise<AppRoom | undefined>;
32
41
  };
33
42
  export declare function holds(reach: PortReach | null, room: string): boolean;
34
43
  export declare function governs(reach: PortReach | null, room: {
@@ -41,4 +50,4 @@ export declare function governs(reach: PortReach | null, room: {
41
50
  readonly selection: boolean;
42
51
  };
43
52
  export declare function planReach(reach: PortReach | null): PlanReach | null;
44
- export declare function narrowed(runtime: Reachable, given: PortReach | null, told: ReadinessPort): NarrowedView;
53
+ export declare function narrowed(runtime: Reachable, given: PortReach | null, port: ReadinessPort): NarrowedView;
@@ -1,35 +1,33 @@
1
1
  import type { Open } from './open.js';
2
2
  export type CodeAvailability = Open<'stored' | 'absent'>;
3
- export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'indexing' | 'refused' | 'unadmitted'>;
3
+ export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'unadmitted'>;
4
4
  export type RoomCoverage = {
5
5
  readonly room: string;
6
6
  readonly state: RoomPreparation;
7
7
  };
8
- export type ConversationCoverage = Open<'complete' | 'acquiring' | 'indexing' | 'undeclared'>;
9
- export type SearchObligation = Open<'required' | 'unused'>;
8
+ export type ConversationCoverage = Open<'complete' | 'acquiring' | 'undeclared'>;
10
9
  export type TargetCoverage = {
11
10
  readonly complete: boolean;
12
11
  readonly listed: boolean;
13
12
  readonly rooms: readonly RoomCoverage[];
14
13
  readonly conversations: ConversationCoverage;
15
- readonly search: SearchObligation;
16
14
  };
17
15
  export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
18
16
  export type Durability = Open<'persistent' | 'best-effort'>;
19
17
  export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
20
18
  export type HouseOutcome = Open<'open' | 'write-halted' | 'refused'>;
21
- export type CapacityCause = {
22
- readonly cause: Open<'insufficient-space' | 'quota-exceeded'>;
23
- readonly needed: number | null;
24
- readonly available: number | null;
19
+ export type Space = Open<'full'>;
20
+ export type InstallationStep = Open<'downloading' | 'writing' | 'replaying'>;
21
+ export type InstallationAmount = {
22
+ readonly done: number;
23
+ readonly total: number;
25
24
  };
26
- export type RefusedRoom = {
27
- readonly room: string;
28
- readonly file: string;
29
- readonly rule: string;
30
- readonly location: string | null;
25
+ export type Installation = {
26
+ readonly step: InstallationStep | null;
27
+ readonly rooms: InstallationAmount;
28
+ readonly bytes: InstallationAmount;
31
29
  };
32
- export type ReadinessStatus = Open<'preparing' | 'paused' | 'refused' | 'ready' | 'lost'>;
30
+ export type ReadinessStatus = Open<'preparing' | 'paused' | 'ready' | 'lost'>;
33
31
  export type Readiness = {
34
32
  readonly status: ReadinessStatus;
35
33
  readonly ready: boolean;
@@ -40,13 +38,12 @@ export type Readiness = {
40
38
  readonly persistence: Persistence;
41
39
  readonly connection: ConnectionAvailability;
42
40
  readonly house: HouseOutcome;
43
- readonly capacity: CapacityCause | null;
44
- readonly refused: readonly RefusedRoom[];
41
+ readonly space: Space | null;
42
+ readonly installation: Installation;
45
43
  readonly lost: boolean;
46
44
  };
47
45
  export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
48
46
  readonly coverage: Omit<TargetCoverage, 'complete'>;
49
47
  readonly established: boolean;
50
48
  };
51
- export declare const SETTLED_ROOMS: ReadonlySet<string>;
52
49
  export declare function readinessOf(facts: ReadinessFacts): Readiness;
@@ -8,7 +8,7 @@ export type AttemptOptions = {
8
8
  };
9
9
  export type RecoveryOptions = {
10
10
  readonly firstMs?: number;
11
- readonly ceilingMs?: number;
11
+ readonly maxMs?: number;
12
12
  readonly attempts?: number;
13
13
  readonly inFlight?: number;
14
14
  };
@@ -20,5 +20,6 @@ export type Recovery = {
20
20
  scope(inFlight?: number): Recovery;
21
21
  retire(): Promise<void>;
22
22
  };
23
- export declare function retryDelay(tries: number, firstMs?: number, ceilingMs?: number): number;
23
+ export declare function retryDelay(tries: number, firstMs?: number, maxMs?: number): number;
24
+ export declare function untilAnswered<T>(ask: () => Promise<T>, signal: AbortSignal, answered?: (answer: T) => boolean): Promise<T>;
24
25
  export declare function createRecovery(options?: RecoveryOptions): Recovery;
@@ -1,45 +1,70 @@
1
- import { type ChangeBatch } from './change.js';
1
+ import { type TypedPath } from '../mdmodel/index.js';
2
+ import type { BootstrapInventory, SavedFacts, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
3
+ import { type ChangeBatch, type Precondition } from './change.js';
2
4
  import { type Collection, type Composition } from './collection.js';
5
+ import { type ModelState } from './model.js';
3
6
  import { type Layer } from './overlay.js';
4
- import type { MutationResult } from './adapter.js';
5
- import type { ReplicaRecord } from './store.js';
6
- import type { Refused } from './transfer.js';
7
- export type ConfirmedLayer = {
8
- record: ReplicaRecord;
9
- collection: Collection;
7
+ import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
8
+ export type ReplicaRecord = {
9
+ readonly locator: string;
10
+ readonly name: string;
11
+ readonly handle: string;
12
+ readonly operations: OperationScopes;
13
+ readonly replica: ReplicaAdmission;
14
+ readonly model: ModelState;
15
+ readonly typedSelection: TypedSelection | null;
16
+ readonly providerOwnedPaths: readonly string[];
17
+ readonly roomVersion: string;
18
+ readonly transfer: string;
19
+ readonly inventory: BootstrapInventory;
20
+ readonly key: number;
21
+ };
22
+ export type HeldReplica = {
23
+ readonly record: ReplicaRecord;
24
+ readonly queue: readonly ChangeBatch[];
25
+ readonly overlaid: ReadonlySet<string>;
26
+ readonly count: number;
27
+ readonly confirmed: number;
28
+ readonly indexed: boolean;
10
29
  };
11
30
  export type VisibleLayer = Layer & {
12
- collection: Collection;
31
+ readonly collection: Collection;
13
32
  };
14
- export type Staged = {
15
- kind: 'staged';
16
- confirmed: ConfirmedLayer;
17
- } | Refused;
18
- export type Replica = {
19
- confirmed: ConfirmedLayer;
20
- queue: readonly ChangeBatch[];
21
- visible: VisibleLayer;
22
- replay: readonly ReplayStep[];
33
+ export type Slice = Layer & {
34
+ readonly written: Readonly<Record<string, string>>;
35
+ readonly facts: Readonly<Record<string, SavedFacts>>;
36
+ readonly held: ReadonlySet<string>;
23
37
  };
24
- type ReplayStep = {
25
- id: string;
26
- before: Layer;
27
- after: Layer;
28
- effective: ChangeBatch;
29
- collection?: Collection;
38
+ export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
39
+ export declare function storedRecord(record: ReplicaRecord): string;
40
+ export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
41
+ export type LayerEntry = Omit<StoredEntry, 'facts'>;
42
+ export declare function entryAt(layer: Layer & {
43
+ readonly written?: Readonly<Record<string, string>>;
44
+ }, path: string): LayerEntry | null;
45
+ export declare function slicingWith(slice: Slice, set: readonly StoredEntry[], removed: readonly string[]): Generator<number, Slice, void>;
46
+ export declare function touchedBy(queue: readonly ChangeBatch[]): Set<string>;
47
+ export declare function movedBy(queue: readonly ChangeBatch[], locator: string): Set<string>;
48
+ export type Replayed = {
49
+ readonly visible: VisibleLayer;
50
+ readonly touched: ReadonlySet<string>;
30
51
  };
31
- export declare function compositionOf(record: ReplicaRecord): Composition;
32
- export declare function confirmedOf(record: ReplicaRecord, previous?: ConfirmedLayer): ConfirmedLayer;
33
- export declare function sameMembership(record: ReplicaRecord, other: ReplicaRecord): boolean;
34
- export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Staged;
35
- export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Staged | {
36
- kind: 'deferred';
52
+ export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
53
+ export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
54
+ export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
55
+ export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
56
+ export type Standing = {
57
+ readonly withdrawn: readonly ChangeBatch[];
58
+ readonly kept: readonly ChangeBatch[];
37
59
  };
60
+ export declare function standing(confirmed: Slice, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean, locator: string, composition: Composition): Generator<number, Standing, void>;
38
61
  type Accepted = Extract<MutationResult, {
39
62
  kind: 'accepted';
40
63
  }>;
41
- export declare function applyReturned(confirmed: ConfirmedLayer, submitted: ChangeBatch, accepted: Accepted, roomVersion: string, writtenAt: string): Staged;
42
- export declare function replicaOf(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Replica;
43
- export declare function landed(batch: ChangeBatch, confirmed: ConfirmedLayer, current?: Readonly<Record<string, string>>): boolean;
44
- export declare function withdrawals(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean): readonly ChangeBatch[];
64
+ export type Returned = {
65
+ readonly set: readonly StoredEntry[];
66
+ readonly removed: readonly string[];
67
+ };
68
+ export declare function returnedPaths(submitted: ChangeBatch, accepted: Accepted): Set<string>;
69
+ export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string, composition: Composition): Generator<number, Returned, void>;
45
70
  export {};