@agentshouse/app-bridge 0.1.0-caabde65fcc7f → 0.1.0-cac2ee656ded8

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 (107) hide show
  1. package/README.md +6 -6
  2. package/dist/index.d.ts +136 -406
  3. package/dist/mdmodel/body.d.ts +84 -0
  4. package/dist/mdmodel/built-in.d.ts +3 -0
  5. package/dist/mdmodel/crockford.d.ts +3 -0
  6. package/dist/mdmodel/definition.d.ts +20 -10
  7. package/dist/mdmodel/document.d.ts +14 -8
  8. package/dist/mdmodel/event.d.ts +76 -0
  9. package/dist/mdmodel/facts.d.ts +14 -0
  10. package/dist/mdmodel/fields.d.ts +1 -1
  11. package/dist/mdmodel/house-model.d.ts +826 -0
  12. package/dist/mdmodel/house-references.d.ts +3 -0
  13. package/dist/mdmodel/index.d.ts +34 -13
  14. package/dist/mdmodel/kinds.d.ts +17 -0
  15. package/dist/mdmodel/markdown.d.ts +74 -0
  16. package/dist/mdmodel/paths.d.ts +10 -1
  17. package/dist/mdmodel/pattern.d.ts +9 -0
  18. package/dist/mdmodel/query/language.d.ts +253 -0
  19. package/dist/mdmodel/query/match.d.ts +13 -0
  20. package/dist/mdmodel/query/rows.d.ts +31 -0
  21. package/dist/mdmodel/query/sql.d.ts +38 -0
  22. package/dist/mdmodel/reserved.d.ts +5 -0
  23. package/dist/mdmodel/room-types.d.ts +6 -0
  24. package/dist/mdmodel/types.d.ts +21 -12
  25. package/dist/mdmodel/validate.d.ts +10 -6
  26. package/dist/mdruntime/actions.d.ts +25 -0
  27. package/dist/mdruntime/adapter.d.ts +88 -79
  28. package/dist/mdruntime/attached-model.d.ts +6 -0
  29. package/dist/mdruntime/bootstrap.d.ts +43 -0
  30. package/dist/mdruntime/cell.d.ts +5 -0
  31. package/dist/mdruntime/chain.d.ts +2 -1
  32. package/dist/mdruntime/change-set.d.ts +4 -0
  33. package/dist/mdruntime/change.d.ts +1 -0
  34. package/dist/mdruntime/client.d.ts +28 -21
  35. package/dist/mdruntime/collection.d.ts +23 -4
  36. package/dist/mdruntime/compile.d.ts +9 -7
  37. package/dist/mdruntime/conversation-live.d.ts +146 -0
  38. package/dist/mdruntime/conversation-row.d.ts +32 -0
  39. package/dist/mdruntime/conversation.d.ts +62 -45
  40. package/dist/mdruntime/declaration.d.ts +9 -0
  41. package/dist/mdruntime/durability.d.ts +19 -0
  42. package/dist/mdruntime/failure.d.ts +3 -0
  43. package/dist/mdruntime/figures.d.ts +48 -0
  44. package/dist/mdruntime/holdings.d.ts +28 -0
  45. package/dist/mdruntime/identity.d.ts +0 -1
  46. package/dist/mdruntime/listing.d.ts +47 -0
  47. package/dist/mdruntime/live.d.ts +22 -0
  48. package/dist/mdruntime/media.d.ts +1 -1
  49. package/dist/mdruntime/messages.d.ts +33 -5
  50. package/dist/mdruntime/model.d.ts +2 -10
  51. package/dist/mdruntime/observation.d.ts +4 -3
  52. package/dist/mdruntime/opened.d.ts +1 -1
  53. package/dist/mdruntime/outcome.d.ts +7 -1
  54. package/dist/mdruntime/overlay.d.ts +6 -1
  55. package/dist/mdruntime/preparation.d.ts +19 -0
  56. package/dist/mdruntime/presence.d.ts +51 -0
  57. package/dist/mdruntime/query.d.ts +13 -211
  58. package/dist/mdruntime/reach.d.ts +14 -12
  59. package/dist/mdruntime/readiness.d.ts +1 -4
  60. package/dist/mdruntime/reads.d.ts +38 -0
  61. package/dist/mdruntime/recovery.d.ts +3 -1
  62. package/dist/mdruntime/refresh.d.ts +26 -0
  63. package/dist/mdruntime/replica.d.ts +11 -16
  64. package/dist/mdruntime/retried.d.ts +29 -0
  65. package/dist/mdruntime/room-draft.d.ts +6 -7
  66. package/dist/mdruntime/room-drafts.d.ts +23 -0
  67. package/dist/mdruntime/runtime.d.ts +33 -0
  68. package/dist/mdruntime/save.d.ts +42 -86
  69. package/dist/mdruntime/saves.d.ts +31 -0
  70. package/dist/mdruntime/search.d.ts +12 -63
  71. package/dist/mdruntime/seed.d.ts +11 -2
  72. package/dist/mdruntime/socket/admission.d.ts +6 -0
  73. package/dist/mdruntime/socket/answers.d.ts +5 -0
  74. package/dist/mdruntime/socket/lanes.d.ts +27 -0
  75. package/dist/mdruntime/socket/session.d.ts +37 -0
  76. package/dist/mdruntime/socket.d.ts +66 -0
  77. package/dist/mdruntime/source.d.ts +53 -0
  78. package/dist/mdruntime/status.d.ts +0 -2
  79. package/dist/mdruntime/store/installs.d.ts +29 -0
  80. package/dist/mdruntime/store/readiness.d.ts +9 -0
  81. package/dist/mdruntime/store/records.d.ts +214 -0
  82. package/dist/mdruntime/store/room-held.d.ts +7 -0
  83. package/dist/mdruntime/store/space.d.ts +10 -0
  84. package/dist/mdruntime/store/watchers.d.ts +16 -0
  85. package/dist/mdruntime/store/writes.d.ts +23 -0
  86. package/dist/mdruntime/store.d.ts +112 -155
  87. package/dist/mdruntime/stored.d.ts +60 -66
  88. package/dist/mdruntime/surface.d.ts +88 -0
  89. package/dist/mdruntime/tables.d.ts +120 -56
  90. package/dist/mdruntime/tallies.d.ts +17 -0
  91. package/dist/mdruntime/transfer.d.ts +4 -0
  92. package/dist/mdruntime/wire.d.ts +67 -7
  93. package/dist/session-content/bounds.d.ts +7 -0
  94. package/dist/session-content/check.d.ts +18 -0
  95. package/dist/session-content/index.d.ts +7 -0
  96. package/dist/session-content/parts.d.ts +103 -0
  97. package/dist/session-content/state.d.ts +61 -0
  98. package/dist/session-content/turn.d.ts +328 -0
  99. package/dist/test-host.js +1 -1
  100. package/docs/families.md +22 -16
  101. package/package.json +2 -2
  102. package/dist/mdmodel/blocks.d.ts +0 -10
  103. package/dist/mdmodel/condition.d.ts +0 -180
  104. package/dist/mdmodel/links.d.ts +0 -28
  105. package/dist/mdmodel/profile.d.ts +0 -5
  106. package/dist/mdruntime/connection.d.ts +0 -153
  107. package/dist/mdruntime/fulltext.d.ts +0 -26
@@ -1,4 +1,4 @@
1
- import type { Definition, ValueFacts, VerifiedModel } from '../mdmodel/index.js';
1
+ import type { Definition, VerifiedModel } from '../mdmodel/index.js';
2
2
  import type { Open } from './open.js';
3
3
  export type ModelIdentity = {
4
4
  identity: string;
@@ -8,7 +8,7 @@ export type ModelSnapshot = ModelIdentity & {
8
8
  schema: string | null;
9
9
  revision: string | null;
10
10
  };
11
- export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired' | 'invalid'>;
11
+ export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'>;
12
12
  export type ModelResult = {
13
13
  kind: 'model';
14
14
  snapshot: ModelSnapshot;
@@ -20,8 +20,6 @@ export type MdType = Definition;
20
20
  export type ModelState = {
21
21
  status: 'unavailable';
22
22
  reason: ModelUnavailableReason;
23
- schema?: string | null;
24
- revision?: string | null;
25
23
  } | {
26
24
  status: 'current' | 'cached';
27
25
  snapshot: ModelSnapshot;
@@ -37,8 +35,6 @@ export type TypesResult = {
37
35
  status: Open<'unavailable'>;
38
36
  reason: ModelUnavailableReason;
39
37
  types: null;
40
- schema?: string | null;
41
- revision?: string | null;
42
38
  } | {
43
39
  status: Open<'current' | 'cached'>;
44
40
  identity: string;
@@ -54,9 +50,5 @@ export type ValidationReceipt = {
54
50
  source: Open<'current' | 'cached'>;
55
51
  };
56
52
  export declare const NO_MODEL: ModelState;
57
- export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
58
53
  export declare function modelTypes(state: ModelState): TypesResult;
59
54
  export declare function storedModel(state: ModelState): StoredModel;
60
- export declare function cached(state: ModelState): ModelState;
61
- export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
62
- export declare function referenceField(facts: ValueFacts | undefined): boolean;
@@ -25,10 +25,11 @@ export type Observed = {
25
25
  };
26
26
  export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
27
27
  export declare function whole(message: QueryMessage): message is KeyedResult;
28
+ export declare function replaces(topic: string, message: unknown): boolean;
28
29
  export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
29
- export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
30
- export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
31
- export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
30
+ export declare function observed(first: unknown, stop: () => void, topic: string): Observed;
31
+ export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, topic: string): Promise<Observation<unknown>>;
32
+ export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
32
33
  export type Digest = {
33
34
  readonly pending: string;
34
35
  } | {
@@ -18,4 +18,4 @@ export type OpenedFiles = {
18
18
  find(name: OpenedName): Promise<KeptBinary | null>;
19
19
  fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
20
20
  };
21
- export declare function openedFiles(database: RuntimeDatabase, fenced: (locator: string) => boolean): OpenedFiles;
21
+ export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
@@ -1,5 +1,6 @@
1
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 { Attempt, Retries } from './retried.js';
3
4
  import type { KeptBinary, KeptResult } from './opened.js';
4
5
  type Refused<Kind extends string> = ProviderRefusal & {
5
6
  kind: Kind;
@@ -13,7 +14,9 @@ export type CallResult = {
13
14
  kind: 'action';
14
15
  result: unknown;
15
16
  at?: RoomVersionAt;
16
- } | Refused<'rejected'> | Refused<'undeclared'> | Failure;
17
+ } | (Refused<'rejected'> & {
18
+ reset?: string;
19
+ }) | Refused<'undeclared'> | Failure;
17
20
  export type HistoryAnswer = Exclude<HistoryResult, {
18
21
  kind: Failure['kind'];
19
22
  }> | Failure;
@@ -65,6 +68,7 @@ export type Offline = {
65
68
  readonly kind: 'offline';
66
69
  };
67
70
  export declare const OFFLINE: Offline;
71
+ export declare function answeredResult(value: unknown): boolean;
68
72
  export declare const UNCERTAIN: Failure;
69
73
  export declare function undeclared(name: string): CallResult;
70
74
  export declare function failure(result: AdapterFailure): Failure;
@@ -81,4 +85,6 @@ export type QueueEntry = {
81
85
  } & (Submission | {
82
86
  readonly state: 'local';
83
87
  });
88
+ export declare const UNANSWERED: ActionResult;
89
+ export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
84
90
  export {};
@@ -1,8 +1,11 @@
1
+ import { type ApplyResult } from '../mdmodel/index.js';
1
2
  import type { BinaryFile, HeadChange } from './adapter.js';
3
+ import { type Composition } from './collection.js';
2
4
  import type { ChangeBatch } from './change.js';
3
5
  export type Heads = {
4
6
  revisions: Readonly<Record<string, string>>;
5
7
  fileIds: Readonly<Record<string, string>>;
8
+ created: Readonly<Record<string, string>>;
6
9
  changes: Readonly<Record<string, HeadChange>>;
7
10
  };
8
11
  export type HeldBinary = ({
@@ -21,4 +24,6 @@ export type Layer = Heads & {
21
24
  export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
22
25
  export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
23
26
  export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
24
- export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
27
+ export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
28
+ export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
29
+ export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
@@ -0,0 +1,19 @@
1
+ import type { PlanReach } from './query.js';
2
+ import { type PortReach } from './reach.js';
3
+ import { type CodeAvailability, type ConnectionAvailability, type Readiness } from './readiness.js';
4
+ import type { Runtime } from './runtime.js';
5
+ export type ReadinessPort = {
6
+ readonly target: string;
7
+ readonly code: CodeAvailability;
8
+ };
9
+ export type ReadinessWatch = {
10
+ readonly port: ReadinessPort;
11
+ readonly reach: PortReach | null;
12
+ readonly deliver: (readiness: Readiness) => void;
13
+ };
14
+ export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
15
+ export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
16
+ export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
17
+ export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[]): Promise<void>;
18
+ export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
19
+ export declare function filled(runtime: Runtime): void;
@@ -0,0 +1,51 @@
1
+ import type { DiscoveredRoom, ProviderRefusal, ScopedRefusal } from './adapter.js';
2
+ import type { ModelState } from './model.js';
3
+ type Repairable = {
4
+ readonly reset: string | undefined;
5
+ };
6
+ type Standing = {
7
+ readonly stale: boolean;
8
+ readonly repairable: Repairable | null;
9
+ readonly repairing: boolean;
10
+ readonly reloadDue: boolean;
11
+ };
12
+ type Listing = {
13
+ readonly whole: boolean;
14
+ readonly live: boolean;
15
+ };
16
+ export type Presence = {
17
+ list(found: readonly DiscoveredRoom[], how: Listing): readonly DiscoveredRoom[];
18
+ room(locator: string): DiscoveredRoom | undefined;
19
+ rooms(): readonly DiscoveredRoom[];
20
+ available(locator: string, selection?: string): boolean;
21
+ refusal(locator: string): ProviderRefusal | null;
22
+ unheldModel(locator: string): ModelState | null;
23
+ refused(locator: string, refusal: ScopedRefusal | null): void;
24
+ readable(locator: string): boolean;
25
+ modelled(locator: string, model: ModelState | null): void;
26
+ installed(locator: string, bootstrapped: boolean): void;
27
+ locked(locator: string, stored: () => Promise<string | null>): Promise<boolean>;
28
+ lockedAmong(stored: ReadonlyMap<string, string>): readonly string[];
29
+ connectionLost(lapsed: () => void): void;
30
+ connectionLive(): void;
31
+ lapse(): void;
32
+ stood(locator: string, stale: boolean, repairable?: Repairable | null): void;
33
+ repairing(locator: string, running: boolean): void;
34
+ reload(locator: string, due: boolean): void;
35
+ standing(locator: string): Standing;
36
+ settled(): boolean;
37
+ repairsOwed(): readonly string[];
38
+ askAgain(locator: string, ask: () => void): void;
39
+ stopAsking(locator?: string): void;
40
+ lose(locator: string, during: number): boolean;
41
+ writing(locator: string): boolean;
42
+ unwritten(locator: string): void;
43
+ lost(locator: string): boolean;
44
+ losses(): number;
45
+ lostSince(locator: string, losses: number): boolean;
46
+ liftable(locator: string, discovery: number): boolean;
47
+ lift(locator: string, discovery: number, unfenced: boolean): void;
48
+ close(): void;
49
+ };
50
+ export declare function createPresence(): Presence;
51
+ export {};
@@ -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,16 +15,25 @@ export type QueryDocument = {
101
15
  sections?: Readonly<Record<string, string>>;
102
16
  preamble?: string;
103
17
  markdown?: string;
104
- textHeld?: false;
105
18
  backlinks?: readonly Backlink[];
106
19
  change?: HeadChange | null;
107
20
  fileId?: string | null;
108
21
  revision?: string | null;
109
22
  binaryFile?: BinaryFileRecord;
23
+ size?: number | null;
24
+ created?: string | null;
25
+ };
26
+ export type GroupTotal = {
27
+ count: number;
28
+ size: number;
110
29
  };
111
30
  export type QueryGroup = {
112
31
  key: readonly unknown[];
113
32
  count: number;
33
+ documents?: GroupTotal;
34
+ files?: GroupTotal;
35
+ updated?: string | null;
36
+ greatest?: unknown;
114
37
  };
115
38
  export type CoveredRoom = {
116
39
  room: string;
@@ -119,7 +42,6 @@ export type CoveredRoom = {
119
42
  };
120
43
  export type QueryCoverage = {
121
44
  rooms: readonly CoveredRoom[];
122
- indexes: readonly string[];
123
45
  overlay: readonly string[];
124
46
  };
125
47
  export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
@@ -148,92 +70,6 @@ export type GroupResult = GroupRows & {
148
70
  coverage: QueryCoverage;
149
71
  };
150
72
  export type QueryResult = DocumentResult | GroupResult | PendingResult;
151
- export type QueryErrorCode = 'invalid-query' | 'unknown-type' | 'unknown-field' | 'wrong-kind';
152
- export type RoomFacts = {
153
- locator: string;
154
- available: boolean;
155
- types: readonly Definition[];
156
- };
157
- export type HeldRooms = {
158
- listed: boolean;
159
- rooms: readonly RoomFacts[];
160
- };
161
- export type Test = {
162
- op: 'eq';
163
- value: Value;
164
- } | {
165
- op: 'ne';
166
- value: Value;
167
- } | {
168
- op: 'in';
169
- values: readonly Value[];
170
- } | {
171
- op: 'nin';
172
- values: readonly Value[];
173
- } | {
174
- op: 'range';
175
- bounds: readonly (readonly ['gt' | 'gte' | 'lt' | 'lte', Value])[];
176
- } | {
177
- op: 'all';
178
- values: readonly Value[];
179
- } | {
180
- op: 'size';
181
- size: number;
182
- } | {
183
- op: 'exists';
184
- exists: boolean;
185
- };
186
- export type Condition = {
187
- every: readonly Condition[];
188
- } | {
189
- some: readonly Condition[];
190
- } | {
191
- field: string;
192
- test: Test;
193
- };
194
- export type Scope = {
195
- types: readonly string[] | null;
196
- where: Condition | null;
197
- pathPrefix: string | null;
198
- };
199
- export type KeyPlan = {
200
- of: 'room';
201
- } | {
202
- of: 'path';
203
- } | {
204
- of: 'type';
205
- } | {
206
- of: 'folder';
207
- } | {
208
- of: 'field';
209
- field: string;
210
- };
211
- export type DocumentShape = {
212
- kind: 'documents';
213
- fields: 'all' | readonly string[] | null;
214
- sections: 'all' | readonly string[] | null;
215
- preamble: boolean;
216
- markdown: boolean;
217
- backlinks: boolean;
218
- change: boolean;
219
- fileId: boolean;
220
- revision: boolean;
221
- orderBy: readonly {
222
- key: KeyPlan;
223
- options: OrderOptions & {
224
- direction: Direction;
225
- };
226
- }[];
227
- };
228
- export declare function bodied(shape: DocumentShape): boolean;
229
- export type GroupShape = {
230
- kind: 'groups';
231
- groupBy: readonly KeyPlan[];
232
- orderBy: readonly {
233
- by: 'count' | number;
234
- direction: Direction;
235
- }[];
236
- };
237
73
  export type PlanArea = {
238
74
  room: string;
239
75
  path: string;
@@ -244,42 +80,8 @@ export type PlanReach = {
244
80
  documents: readonly string[];
245
81
  areas: readonly PlanArea[];
246
82
  };
247
- export type Continuation = {
248
- text: string;
249
- values: readonly unknown[] | null;
250
- };
251
- export type Plan = {
252
- key: string;
253
- rooms: readonly string[] | null;
83
+ export type Plan = QueryPlan & {
254
84
  reach: PlanReach | null;
255
85
  locked: readonly string[];
256
- root: Scope;
257
- folder: string | null;
258
- paths: readonly string[] | null;
259
- hop: (Scope & {
260
- field: string;
261
- }) | null;
262
- backlinks: (Scope & {
263
- field: string | null;
264
- }) | null;
265
- shape: DocumentShape | GroupShape;
266
- limit: number | null;
267
- after: Continuation | null;
268
- total: boolean;
269
86
  };
270
- export declare class QueryError extends Error {
271
- readonly code: QueryErrorCode;
272
- readonly retryable = false;
273
- constructor(code: QueryErrorCode, at: string, problem: string);
274
- }
275
- type Entries = Readonly<Record<string, unknown>>;
276
- export declare function invalid(at: string, problem: string): never;
277
- export declare function plain(value: unknown): value is Entries;
278
- export declare function known(value: Entries, allowed: readonly string[], at: string): void;
279
- export declare function flag(input: unknown, at: string): boolean;
280
- export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
281
- export declare function limitOf(input: unknown): number | null;
282
- export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
283
- export declare function queryKey(query: unknown): string;
284
- export declare function identityOf(plan: Plan): string;
285
- export {};
87
+ export declare function planWithin(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
@@ -1,7 +1,9 @@
1
- import type { AppRoom, MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
1
+ import type { AppRoom } from './listing.js';
2
+ import type { ReadinessPort } from './preparation.js';
3
+ import type { MdRuntime, RuntimeTopic } from './surface.js';
2
4
  import type { Plan, PlanReach, QueryResult } from './query.js';
3
5
  import type { Readiness } from './readiness.js';
4
- import { type SearchResult } from './search.js';
6
+ import type { SearchResult } from './search.js';
5
7
  export type ReachedDocument = {
6
8
  readonly room: string;
7
9
  readonly path: string;
@@ -18,26 +20,26 @@ export type PortReach = {
18
20
  readonly conversations: boolean;
19
21
  };
20
22
  export type Deliver = (message: unknown) => void;
21
- export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver) => () => void;
23
+ export type Fail = (error: unknown) => void;
24
+ export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver, fail: Fail) => () => void;
22
25
  export type RuntimeView = {
23
26
  md: MdRuntime;
24
27
  watch: Watch;
25
28
  };
26
29
  export type NarrowedView = RuntimeView & {
27
30
  narrow(reach: PortReach | null): void;
28
- facts(port: ReadinessPort): void;
29
31
  };
30
32
  export type Reachable = RuntimeView & {
31
- plan(input: unknown, reach: PortReach | null): Plan;
33
+ plan(input: unknown, reach: PortReach | null): Promise<Plan>;
32
34
  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>;
35
+ watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
36
+ search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
35
37
  watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
36
- locked(room: string): boolean;
37
- lockedRooms(): readonly string[];
38
+ locked(room: string): Promise<boolean>;
39
+ lockedRooms(): Promise<readonly string[]>;
38
40
  watchLocks(notify: () => void): () => void;
39
- located(room: string, path: string, destination: string): ReachedDocument | null;
40
- room(locator: string): AppRoom | undefined;
41
+ located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
42
+ room(locator: string): Promise<AppRoom | undefined>;
41
43
  };
42
44
  export declare function holds(reach: PortReach | null, room: string): boolean;
43
45
  export declare function governs(reach: PortReach | null, room: {
@@ -50,4 +52,4 @@ export declare function governs(reach: PortReach | null, room: {
50
52
  readonly selection: boolean;
51
53
  };
52
54
  export declare function planReach(reach: PortReach | null): PlanReach | null;
53
- export declare function narrowed(runtime: Reachable, given: PortReach | null, told: ReadinessPort): NarrowedView;
55
+ export declare function narrowed(runtime: Reachable, given: PortReach | null, port: ReadinessPort): NarrowedView;
@@ -6,15 +6,13 @@ export type RoomCoverage = {
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
- export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
15
+ export type Persistence = Open<'granted' | 'denied' | 'unavailable' | 'memory'>;
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'>;
@@ -26,7 +24,6 @@ export type InstallationAmount = {
26
24
  };
27
25
  export type Installation = {
28
26
  readonly step: InstallationStep | null;
29
- readonly rooms: InstallationAmount;
30
27
  readonly bytes: InstallationAmount;
31
28
  };
32
29
  export type ReadinessStatus = Open<'preparing' | 'paused' | 'ready' | 'lost'>;
@@ -0,0 +1,38 @@
1
+ import { type CallResult } from './outcome.js';
2
+ import type { Recovery } from './recovery.js';
3
+ import type { Attempt, Retries } from './retried.js';
4
+ import type { Connection, RuntimeDatabase } from './tables.js';
5
+ export declare const READ_TABLES: readonly string[];
6
+ export type ReadAt = {
7
+ readonly name: string;
8
+ readonly input: string;
9
+ readonly build: string;
10
+ };
11
+ export type ObservedRead = {
12
+ readonly answer: unknown;
13
+ readonly failure: CallResult | null;
14
+ readonly kept: boolean;
15
+ };
16
+ export type ReadAnswers = {
17
+ watch(name: string, input: unknown, deliver: (read: ObservedRead) => void): () => void;
18
+ again(): void;
19
+ reopened(): void;
20
+ };
21
+ export type ReadAnswersOptions = {
22
+ readonly database: RuntimeDatabase;
23
+ readonly build: string;
24
+ readonly unkept: readonly string[];
25
+ readonly leading: readonly string[];
26
+ readonly recovery: Recovery;
27
+ readonly retries: Retries;
28
+ call(name: string, input: unknown, attempt: Attempt): Promise<CallResult>;
29
+ online(): boolean;
30
+ streaming(): boolean;
31
+ closed(): boolean;
32
+ full(): boolean;
33
+ filled(): void;
34
+ };
35
+ export declare function storedRead(connection: Connection, { name, input, build }: ReadAt): string | null;
36
+ export declare function keptRead(connection: Connection, { name, input, build }: ReadAt, answer: string): null;
37
+ export declare function readsOfOtherBuildsForgotten(connection: Connection, build: string): null;
38
+ export declare function readAnswers(options: ReadAnswersOptions): ReadAnswers;
@@ -16,10 +16,12 @@ export type Recovery = {
16
16
  attempt(intent: string, run: Attempt, options?: AttemptOptions): Promise<boolean>;
17
17
  pending(intent: string): boolean;
18
18
  resume(): void;
19
+ again(): void;
20
+ waits(wake: () => void): () => void;
19
21
  cancel(intent: string): void;
20
22
  scope(inFlight?: number): Recovery;
21
23
  retire(): Promise<void>;
22
24
  };
23
25
  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>;
26
+ export declare function untilAnswered<T>(ask: () => Promise<T>, signal: AbortSignal, answered?: (answer: T) => boolean, owner?: Recovery): Promise<T>;
25
27
  export declare function createRecovery(options?: RecoveryOptions): Recovery;
@@ -0,0 +1,26 @@
1
+ import type { AdapterFailure, Authorization, RefreshPage, RefreshRequest, RefreshResult, RetryableRefusal } from './adapter.js';
2
+ import type { Remodel } from './bootstrap.js';
3
+ import type { ReplicaRecord } from './replica.js';
4
+ import type { RefreshedPage } from './store.js';
5
+ import type { HeldEntry, StoredEntry } from './tables.js';
6
+ import { type Unconfirmed } from './transfer.js';
7
+ export type Advancement = {
8
+ kind: 'still-current';
9
+ } | {
10
+ kind: 'advanced';
11
+ record: ReplicaRecord;
12
+ changed: ReadonlySet<string>;
13
+ } | {
14
+ kind: 'beyond-horizon';
15
+ } | RetryableRefusal | Unconfirmed | AdapterFailure;
16
+ export type Refresher = (authorization: Authorization, request: RefreshRequest) => Promise<RefreshResult>;
17
+ export type Refreshing = {
18
+ turn(): void;
19
+ prior(paths: readonly string[]): Promise<ReadonlyMap<string, HeldEntry>>;
20
+ later(paths: readonly string[], roomVersion: string): Promise<ReadonlySet<string>>;
21
+ stage(page: RefreshedPage): Promise<boolean>;
22
+ };
23
+ type PageContent = Pick<RefreshPage, 'documents' | 'facts' | 'revisions' | 'fileIds' | 'created' | 'changes' | 'binaryFiles'>;
24
+ export declare function pageEntries(page: PageContent, removals: readonly string[], roomVersion: string, prior: (paths: readonly string[]) => Promise<ReadonlyMap<string, HeldEntry>>): Promise<StoredEntry[]>;
25
+ export declare function advancement(refresh: Refresher, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean, staging: Refreshing): Promise<Advancement>;
26
+ export {};