@agentshouse/app-bridge 0.1.0-ca16e10794fd8 → 0.1.0-ca2cc2cd99f13

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 (47) hide show
  1. package/README.md +6 -6
  2. package/dist/index.d.ts +827 -16
  3. package/dist/mdmodel/condition.d.ts +22 -5
  4. package/dist/mdmodel/document.d.ts +2 -1
  5. package/dist/mdmodel/index.d.ts +15 -5
  6. package/dist/mdmodel/kinds.d.ts +17 -0
  7. package/dist/mdmodel/query/language.d.ts +217 -0
  8. package/dist/mdmodel/query/match.d.ts +11 -0
  9. package/dist/mdmodel/query/rows.d.ts +31 -0
  10. package/dist/mdmodel/query/sql.d.ts +38 -0
  11. package/dist/mdmodel/reserved.d.ts +4 -0
  12. package/dist/mdmodel/types.d.ts +12 -0
  13. package/dist/mdmodel/validate.d.ts +3 -2
  14. package/dist/mdruntime/adapter.d.ts +73 -52
  15. package/dist/mdruntime/chain.d.ts +2 -1
  16. package/dist/mdruntime/client.d.ts +6 -5
  17. package/dist/mdruntime/collection.d.ts +2 -4
  18. package/dist/mdruntime/compile.d.ts +1 -6
  19. package/dist/mdruntime/connection.d.ts +5 -7
  20. package/dist/mdruntime/conversation.d.ts +15 -14
  21. package/dist/mdruntime/durability.d.ts +0 -1
  22. package/dist/mdruntime/media.d.ts +1 -1
  23. package/dist/mdruntime/messages.d.ts +2 -2
  24. package/dist/mdruntime/model.d.ts +1 -3
  25. package/dist/mdruntime/observation.d.ts +2 -2
  26. package/dist/mdruntime/outcome.d.ts +0 -3
  27. package/dist/mdruntime/query.d.ts +5 -209
  28. package/dist/mdruntime/reach.d.ts +7 -7
  29. package/dist/mdruntime/readiness.d.ts +3 -17
  30. package/dist/mdruntime/recovery.d.ts +1 -0
  31. package/dist/mdruntime/replica.d.ts +3 -3
  32. package/dist/mdruntime/room-draft.d.ts +16 -1
  33. package/dist/mdruntime/search.d.ts +12 -63
  34. package/dist/mdruntime/status.d.ts +0 -4
  35. package/dist/mdruntime/store.d.ts +19 -33
  36. package/dist/mdruntime/stored.d.ts +34 -26
  37. package/dist/mdruntime/tables.d.ts +35 -44
  38. package/dist/mdruntime/wire.d.ts +1 -4
  39. package/dist/test-host.d.ts +1 -4
  40. package/dist/test-host.js +2 -27
  41. package/docs/families.md +42 -47
  42. package/package.json +1 -1
  43. package/dist/calls.d.ts +0 -707
  44. package/dist/calls.js +0 -1
  45. package/dist/mdruntime/fulltext.d.ts +0 -26
  46. package/dist/mdruntime/shared.d.ts +0 -15
  47. package/dist/mdruntime/transfer.d.ts +0 -9
@@ -1,93 +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
- folder?: string;
42
- paths?: readonly string[];
43
- hop?: Related & {
44
- field: string;
45
- };
46
- backlinks?: Related & {
47
- field?: string;
48
- };
49
- };
50
- export type Key = 'room' | 'path' | 'type' | 'folder' | {
51
- field: string;
52
- };
53
- export type Select = 'all' | {
54
- fields?: 'all' | readonly string[];
55
- sections?: 'all' | readonly string[];
56
- preamble?: true;
57
- markdown?: true;
58
- backlinks?: true;
59
- change?: true;
60
- fileId?: true;
61
- revision?: true;
62
- };
63
- export type OrderOptions = {
64
- nulls?: 'first' | 'last';
65
- stringSort?: 'lexical' | 'locale';
66
- locale?: string;
67
- localeOptions?: Readonly<Record<string, unknown>>;
68
- };
69
- export type Direction = 'asc' | 'desc';
70
- export type DocumentQuery = Filter & {
71
- select: Select;
72
- orderBy?: readonly ({
73
- by: Key;
74
- direction?: Direction;
75
- } & OrderOptions)[];
76
- limit?: number;
77
- after?: string;
78
- total?: true;
79
- };
80
- export type GroupQuery = Filter & {
81
- groupBy: readonly Exclude<Key, 'path'>[];
82
- orderBy?: readonly {
83
- by: 'count' | Exclude<Key, 'path'>;
84
- direction?: Direction;
85
- }[];
86
- limit?: number;
87
- after?: string;
88
- total?: true;
89
- };
90
- export type LocalQuery = DocumentQuery | GroupQuery;
91
5
  export type Backlink = {
92
6
  path: string;
93
7
  type: string;
@@ -101,6 +15,7 @@ export type QueryDocument = {
101
15
  sections?: Readonly<Record<string, string>>;
102
16
  preamble?: string;
103
17
  markdown?: string;
18
+ textHeld?: false;
104
19
  backlinks?: readonly Backlink[];
105
20
  change?: HeadChange | null;
106
21
  fileId?: string | null;
@@ -147,137 +62,18 @@ export type GroupResult = GroupRows & {
147
62
  coverage: QueryCoverage;
148
63
  };
149
64
  export type QueryResult = DocumentResult | GroupResult | PendingResult;
150
- export type QueryErrorCode = 'invalid-query' | 'unknown-type' | 'unknown-field' | 'wrong-kind';
151
- export type RoomFacts = {
152
- locator: string;
153
- available: boolean;
154
- types: readonly Definition[];
155
- };
156
- export type HeldRooms = {
157
- listed: boolean;
158
- rooms: readonly RoomFacts[];
159
- };
160
- export type Test = {
161
- op: 'eq';
162
- value: Value;
163
- } | {
164
- op: 'ne';
165
- value: Value;
166
- } | {
167
- op: 'in';
168
- values: readonly Value[];
169
- } | {
170
- op: 'nin';
171
- values: readonly Value[];
172
- } | {
173
- op: 'range';
174
- bounds: readonly (readonly ['gt' | 'gte' | 'lt' | 'lte', Value])[];
175
- } | {
176
- op: 'all';
177
- values: readonly Value[];
178
- } | {
179
- op: 'size';
180
- size: number;
181
- } | {
182
- op: 'exists';
183
- exists: boolean;
184
- };
185
- export type Condition = {
186
- every: readonly Condition[];
187
- } | {
188
- some: readonly Condition[];
189
- } | {
190
- field: string;
191
- test: Test;
192
- };
193
- export type Scope = {
194
- types: readonly string[] | null;
195
- where: Condition | null;
196
- pathPrefix: string | null;
197
- };
198
- export type KeyPlan = {
199
- of: 'room';
200
- } | {
201
- of: 'path';
202
- } | {
203
- of: 'type';
204
- } | {
205
- of: 'folder';
206
- } | {
207
- of: 'field';
208
- field: string;
209
- };
210
- export type DocumentShape = {
211
- kind: 'documents';
212
- fields: 'all' | readonly string[] | null;
213
- sections: 'all' | readonly string[] | null;
214
- preamble: boolean;
215
- markdown: boolean;
216
- backlinks: boolean;
217
- change: boolean;
218
- fileId: boolean;
219
- revision: boolean;
220
- orderBy: readonly {
221
- key: KeyPlan;
222
- options: OrderOptions & {
223
- direction: Direction;
224
- };
225
- }[];
226
- };
227
- export type GroupShape = {
228
- kind: 'groups';
229
- groupBy: readonly KeyPlan[];
230
- orderBy: readonly {
231
- by: 'count' | number;
232
- direction: Direction;
233
- }[];
234
- };
235
65
  export type PlanArea = {
236
66
  room: string;
237
67
  path: string;
238
- types: readonly string[];
68
+ open: readonly string[];
239
69
  };
240
70
  export type PlanReach = {
241
71
  rooms: readonly string[];
242
72
  documents: readonly string[];
243
73
  areas: readonly PlanArea[];
244
74
  };
245
- export type Continuation = {
246
- text: string;
247
- values: readonly unknown[] | null;
248
- };
249
- export type Plan = {
250
- key: string;
251
- rooms: readonly string[] | null;
75
+ export type Plan = QueryPlan & {
252
76
  reach: PlanReach | null;
253
77
  locked: readonly string[];
254
- root: Scope;
255
- folder: string | null;
256
- paths: readonly string[] | null;
257
- hop: (Scope & {
258
- field: string;
259
- }) | null;
260
- backlinks: (Scope & {
261
- field: string | null;
262
- }) | null;
263
- shape: DocumentShape | GroupShape;
264
- limit: number | null;
265
- after: Continuation | null;
266
- total: boolean;
267
78
  };
268
- export declare class QueryError extends Error {
269
- readonly code: QueryErrorCode;
270
- readonly retryable = false;
271
- constructor(code: QueryErrorCode, at: string, problem: string);
272
- }
273
- type Entries = Readonly<Record<string, unknown>>;
274
- export declare function invalid(at: string, problem: string): never;
275
- export declare function plain(value: unknown): value is Entries;
276
- export declare function known(value: Entries, allowed: readonly string[], at: string): void;
277
- export declare function flag(input: unknown, at: string): boolean;
278
- export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
279
- export declare function limitOf(input: unknown): number | null;
280
- export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
281
- export declare function queryKey(query: unknown): string;
282
- export declare function identityOf(plan: Plan): string;
283
- export {};
79
+ export declare function planWithin(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
@@ -1,7 +1,7 @@
1
1
  import type { AppRoom, MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
2
2
  import type { Plan, PlanReach, QueryResult } from './query.js';
3
3
  import type { Readiness } from './readiness.js';
4
- import { type SearchResult } from './search.js';
4
+ import type { SearchResult } from './search.js';
5
5
  export type ReachedDocument = {
6
6
  readonly room: string;
7
7
  readonly path: string;
@@ -9,7 +9,7 @@ export type ReachedDocument = {
9
9
  export type ReachedArea = {
10
10
  readonly room: string;
11
11
  readonly path: string;
12
- readonly types: readonly string[];
12
+ readonly open: readonly string[];
13
13
  };
14
14
  export type PortReach = {
15
15
  readonly rooms: readonly string[];
@@ -18,20 +18,20 @@ export type PortReach = {
18
18
  readonly conversations: boolean;
19
19
  };
20
20
  export type Deliver = (message: unknown) => void;
21
- 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;
22
23
  export type RuntimeView = {
23
24
  md: MdRuntime;
24
25
  watch: Watch;
25
26
  };
26
27
  export type NarrowedView = RuntimeView & {
27
28
  narrow(reach: PortReach | null): void;
28
- facts(port: ReadinessPort): void;
29
29
  };
30
30
  export type Reachable = RuntimeView & {
31
31
  plan(input: unknown, reach: PortReach | null): Plan;
32
32
  query(plan: Plan): Promise<QueryResult>;
33
- watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
34
- search(input: unknown, reach: PortReach | null, locked: readonly string[]): Promise<SearchResult>;
33
+ watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
34
+ search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
35
35
  watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
36
36
  locked(room: string): boolean;
37
37
  lockedRooms(): readonly string[];
@@ -50,4 +50,4 @@ export declare function governs(reach: PortReach | null, room: {
50
50
  readonly selection: boolean;
51
51
  };
52
52
  export declare function planReach(reach: PortReach | null): PlanReach | null;
53
- 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,46 +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' | '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
8
  export type ConversationCoverage = Open<'complete' | 'acquiring' | 'undeclared'>;
9
- export type SearchObligation = Open<'required' | 'unused'>;
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
19
  export type Space = Open<'full'>;
22
- export type RefusedRoom = {
23
- readonly room: string;
24
- readonly name: string;
25
- readonly file: string;
26
- readonly rule: string;
27
- readonly location: string | null;
28
- };
29
- export type InstallationStep = Open<'listing' | 'downloading' | 'writing' | 'replaying'>;
30
- export type InstallationPause = Open<'hidden'>;
20
+ export type InstallationStep = Open<'downloading' | 'writing' | 'replaying'>;
31
21
  export type InstallationAmount = {
32
22
  readonly done: number;
33
23
  readonly total: number;
34
24
  };
35
25
  export type Installation = {
36
26
  readonly step: InstallationStep | null;
37
- readonly paused: InstallationPause | null;
38
27
  readonly rooms: InstallationAmount;
39
- readonly parts: InstallationAmount;
40
28
  readonly bytes: InstallationAmount;
41
- readonly received: InstallationAmount;
42
29
  };
43
- export type ReadinessStatus = Open<'preparing' | 'paused' | 'refused' | 'ready' | 'lost'>;
30
+ export type ReadinessStatus = Open<'preparing' | 'paused' | 'ready' | 'lost'>;
44
31
  export type Readiness = {
45
32
  readonly status: ReadinessStatus;
46
33
  readonly ready: boolean;
@@ -53,7 +40,6 @@ export type Readiness = {
53
40
  readonly house: HouseOutcome;
54
41
  readonly space: Space | null;
55
42
  readonly installation: Installation;
56
- readonly refused: readonly RefusedRoom[];
57
43
  readonly lost: boolean;
58
44
  };
59
45
  export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
@@ -21,4 +21,5 @@ export type Recovery = {
21
21
  retire(): Promise<void>;
22
22
  };
23
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,3 +1,4 @@
1
+ import { type TypedPath } from '../mdmodel/index.js';
1
2
  import type { BootstrapInventory, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
2
3
  import { type ChangeBatch, type Precondition } from './change.js';
3
4
  import { type Collection, type Composition } from './collection.js';
@@ -15,7 +16,7 @@ export type ReplicaRecord = {
15
16
  readonly providerOwnedPaths: readonly string[];
16
17
  readonly roomVersion: string;
17
18
  readonly transfer: string;
18
- readonly inventory: BootstrapInventory | null;
19
+ readonly inventory: BootstrapInventory;
19
20
  readonly key: number;
20
21
  };
21
22
  export type HeldReplica = {
@@ -33,8 +34,7 @@ export type Slice = Layer & {
33
34
  readonly written: Readonly<Record<string, string>>;
34
35
  readonly held: ReadonlySet<string>;
35
36
  };
36
- export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState): Composition;
37
- export declare function sameMembership(record: Pick<ReplicaRecord, 'typedSelection'>, other: Pick<ReplicaRecord, 'typedSelection'>): boolean;
37
+ export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
38
38
  export declare function storedRecord(record: ReplicaRecord): string;
39
39
  export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
40
40
  export declare function entryAt(layer: Layer & {
@@ -127,13 +127,14 @@ export type SavedDraft = {
127
127
  readonly path: string;
128
128
  readonly parts: HeldParts;
129
129
  };
130
- export declare function readParts(value: unknown): RoomDraftParts;
130
+ export declare function readParts(value: unknown, path: string): RoomDraftParts;
131
131
  export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
132
132
  export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
133
133
  export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
134
134
  export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
135
135
  export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
136
136
  export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
137
+ export declare function lineEnded(text: string): string;
137
138
  export type TextParts = {
138
139
  readonly fields?: Readonly<Record<string, {
139
140
  readonly value: unknown;
@@ -150,6 +151,20 @@ export declare function returnedInto(existing: HeldParts | undefined, returned:
150
151
  export declare function moveTarget(move: {
151
152
  readonly to: string;
152
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
+ };
153
168
  export declare function changesOf(path: string, parts: HeldParts): {
154
169
  changes: readonly Change[];
155
170
  bases: readonly Precondition[];
@@ -1,72 +1,21 @@
1
- import type { ProviderRefusal } from './adapter.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
- collection?: true;
9
- conversations?: readonly string[];
10
- limit?: number;
11
- after?: string;
12
- total?: true;
5
+ rooms?: readonly string[];
13
6
  };
14
- export type MessagePart = Open<'text'>;
15
- export type Snippet<Part extends string> = {
16
- part: Part;
17
- text: string;
18
- at: readonly [number, number];
19
- };
20
- export type DocumentHit = {
21
- room: string;
22
- path: string;
23
- type: string;
24
- score: number;
25
- matches: Readonly<Record<string, readonly DocumentPart[]>>;
26
- snippet?: Snippet<DocumentPart>;
27
- };
28
- export type MessageHit = {
29
- conversation: string;
30
- identity: string;
31
- score: number;
32
- matches: Readonly<Record<string, readonly MessagePart[]>>;
33
- snippet?: Snippet<MessagePart>;
34
- };
35
- export type SearchCoverage = {
36
- rooms: readonly CoveredRoom[];
37
- conversations: readonly string[];
38
- overlay: readonly string[];
7
+ export type { SearchHit } from './adapter.js';
8
+ export type SearchFound = {
9
+ kind: 'found';
10
+ documents: readonly SearchHit[];
39
11
  };
40
- export type SearchHits = {
41
- documents: readonly DocumentHit[];
42
- messages: readonly MessageHit[];
43
- };
44
- export type SearchWindow = SearchHits & {
45
- next?: string;
46
- total?: {
47
- documents: number;
48
- messages: number;
49
- };
50
- };
51
- export type SearchPending = SearchHits & {
52
- pending: readonly PendingRoom[];
53
- coverage: SearchCoverage;
54
- };
55
- export type SearchUndeclared = ProviderRefusal & {
12
+ export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
13
+ kind: 'rejected';
14
+ }) | (ProviderRefusal & {
56
15
  kind: 'undeclared';
57
- };
58
- export type SearchResult = (SearchWindow & {
59
- coverage: SearchCoverage;
60
- }) | SearchPending | SearchUndeclared;
61
- export declare function undeclaredSearch(): SearchUndeclared;
62
- export type HitCursor = readonly [number, string, string] | readonly [] | null;
16
+ }) | Failure;
63
17
  export type SearchPlan = {
64
18
  text: string;
65
- documents: unknown;
66
- collection: boolean;
67
- conversations: readonly string[] | null;
68
- limit: number | null;
69
- after: readonly [HitCursor, HitCursor] | null;
70
- total: boolean;
19
+ rooms: readonly string[] | null;
71
20
  };
72
21
  export declare function searchPlanOf(input: unknown): SearchPlan;
@@ -1,13 +1,9 @@
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
- } | {
9
- room: string;
10
- refusal: ProviderRefusal;
11
7
  };
12
8
  export type UnsentChange = {
13
9
  room: string;
@@ -1,13 +1,12 @@
1
- import type { BootstrapInventory, Capability, KeptReceipt, Member, ProviderLimit } from './adapter.js';
1
+ import type { BootstrapInventory, Capability, ListedConversation, Member, ProviderLimit } from './adapter.js';
2
2
  import type { ChangeBatch } from './change.js';
3
3
  import { type Composition } from './collection.js';
4
4
  import type { Plan } from './query.js';
5
5
  import type { ReplicaRecord } from './replica.js';
6
6
  import type { Submission } from './outcome.js';
7
7
  import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
8
- import { type ModelState, type StoredModel } from './model.js';
9
- import type { SearchWindow } from './search.js';
10
- import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, KeptPart, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, SearchAsk, StoredEntry, StoredFile, TypedEntry, View, Walked } from './tables.js';
8
+ import type { ModelState, StoredModel } from './model.js';
9
+ import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, HeldText, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
11
10
  export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
12
11
  export type TransferRecord = {
13
12
  readonly locator: string;
@@ -15,8 +14,6 @@ export type TransferRecord = {
15
14
  readonly selection: string;
16
15
  readonly from: string;
17
16
  readonly last: string;
18
- readonly pageToken: string | null;
19
- readonly inventory: BootstrapInventory | null;
20
17
  readonly done: BootstrapInventory;
21
18
  readonly models: {
22
19
  readonly collection: ModelState;
@@ -26,17 +23,11 @@ export type TransferRecord = {
26
23
  export type StoredReplica = Omit<ReplicaRecord, 'model'> & {
27
24
  readonly model: StoredModel;
28
25
  };
29
- export type StoredTransfer = Omit<TransferRecord, 'models'> & {
30
- readonly models: {
31
- readonly collection: StoredModel;
32
- };
33
- };
34
26
  export type PendingState = {
35
27
  readonly drafts: readonly SavedDraft[];
36
28
  readonly submission: Submission;
37
29
  readonly lost: boolean;
38
30
  readonly upload?: unknown;
39
- readonly accepted?: string;
40
31
  };
41
32
  export type TargetRecord = {
42
33
  established: boolean;
@@ -76,10 +67,6 @@ export type AuthoredWrite = {
76
67
  saved?: ReadonlyMap<string, readonly SavedDraft[]>;
77
68
  roomDrafts?: readonly RoomDraftRecord[];
78
69
  consumedRoomDrafts?: readonly string[];
79
- accepted?: readonly {
80
- readonly id: string;
81
- readonly roomVersion: string;
82
- }[];
83
70
  };
84
71
  export type StagedPage = {
85
72
  readonly entries: readonly StoredEntry[];
@@ -91,8 +78,6 @@ export type RefreshedPage = StagedPage & {
91
78
  };
92
79
  export type Opened = {
93
80
  readonly rooms: ReadonlyMap<string, StoredReplica>;
94
- readonly transfers: ReadonlyMap<string, StoredTransfer>;
95
- readonly kept: ReadonlyMap<string, ReadonlyMap<string, number>>;
96
81
  readonly unindexed: ReadonlySet<number>;
97
82
  readonly overlaid: ReadonlyMap<number, ReadonlySet<string>>;
98
83
  readonly erasing: boolean;
@@ -103,6 +88,8 @@ export type Opened = {
103
88
  readonly member: Member | null;
104
89
  readonly targets: Readonly<Record<string, TargetRecord>>;
105
90
  readonly presentation: readonly PresentationRecord[];
91
+ readonly conversationList: readonly ListedConversation[] | null;
92
+ readonly conversationCursor: string | null;
106
93
  };
107
94
  export type Commit = {
108
95
  readonly rooms: readonly RoomCommit[];
@@ -119,23 +106,29 @@ export type RuntimeStore = {
119
106
  entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
120
107
  typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
121
108
  referrers(key: number, view: View, targets: readonly string[], kinds: readonly string[]): Promise<readonly Referrer[]>;
122
- walk(key: number, view: View, after: string | null, bytes: number): Promise<Walked>;
123
109
  files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
124
110
  readonly path: string;
125
111
  readonly revision: string;
126
112
  }[]>;
127
113
  folders(key: number, view: View, paths: readonly string[]): Promise<readonly string[]>;
128
114
  typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
129
- search(ask: SearchAsk): Promise<SearchWindow>;
130
- stage(record: TransferRecord, composition: Composition, page: StagedPage, written?: string): Promise<number | null>;
131
- transferPart(locator: string, token: string): Promise<Uint8Array | null>;
132
- keepParts(parts: readonly KeptPart[]): Promise<void>;
115
+ stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
133
116
  refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
134
117
  unrefresh(key: number): Promise<void>;
118
+ hold(locator: string, key: number, composition: Composition, texts: readonly HeldText[]): Promise<readonly string[]>;
119
+ unhold(locator: string, key: number, composition: Composition): Promise<{
120
+ readonly paths: readonly string[];
121
+ readonly bytes: number;
122
+ }>;
123
+ wanted(locator: string, key: number): Promise<readonly {
124
+ readonly path: string;
125
+ readonly revision: string;
126
+ }[]>;
127
+ remember(locator: string, key: number, paths: readonly string[]): Promise<void>;
135
128
  commit(commit: Commit): Promise<CommittedWrite>;
136
129
  fence(locators: readonly string[]): Promise<void>;
137
130
  erase(locator: string | null, limit: number): Promise<boolean>;
138
- abandon(locator: string, kept?: boolean): Promise<number | null>;
131
+ abandon(locator: string): Promise<void>;
139
132
  release(key: number): Promise<void>;
140
133
  rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
141
134
  readonly done: boolean;
@@ -149,8 +142,8 @@ export type RuntimeStore = {
149
142
  present(record: PresentationRecord): Promise<void>;
150
143
  conversations(): Promise<readonly HeldConversation[]>;
151
144
  keepMessages(write: ConversationWrite): Promise<void>;
152
- messageWindow(conversation: string, limit: number, before: readonly [string, string] | null): Promise<MessageWindow>;
153
- messageCount(conversation: string): Promise<number>;
145
+ messageWindow(conversation: string, limit: number, before: readonly [string, string] | null, phrase?: string | null): Promise<MessageWindow>;
146
+ messageCount(conversation: string, phrase?: string | null): Promise<number>;
154
147
  turnArrived(conversation: string, turn: string): Promise<boolean>;
155
148
  dropConversations(conversations: readonly string[]): Promise<void>;
156
149
  chatDrafts(): Promise<readonly ChatDraftRecord[]>;
@@ -162,13 +155,6 @@ export type RuntimeStore = {
162
155
  keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
163
156
  discardRoomDraft(locator: string, path: string): Promise<void>;
164
157
  fences(): Promise<readonly string[]>;
165
- receivedHeads(): Promise<readonly KeptReceipt[]>;
166
- receivedParts(key: string, count: number): Promise<readonly unknown[]>;
167
- keepReceived(key: string, head: unknown, part?: {
168
- index: number;
169
- value: unknown;
170
- }): Promise<void>;
171
- dropReceived(keys: readonly string[]): Promise<void>;
172
158
  generation(): Promise<string | null>;
173
159
  rememberGeneration(value: string): Promise<void>;
174
160
  file(key: string, type: string): Promise<Blob>;