@agentshouse/app-bridge 0.1.0-ca559eade7c19 → 0.1.0-ca6bf24eae119

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 (55) hide show
  1. package/README.md +9 -9
  2. package/dist/calls.d.ts +676 -69
  3. package/dist/index.d.ts +36 -18
  4. package/dist/mdmodel/condition.d.ts +23 -10
  5. package/dist/mdmodel/definition.d.ts +3 -1
  6. package/dist/mdmodel/document.d.ts +5 -5
  7. package/dist/mdmodel/index.d.ts +9 -7
  8. package/dist/mdmodel/links.d.ts +28 -0
  9. package/dist/mdmodel/paths.d.ts +9 -1
  10. package/dist/mdmodel/project.d.ts +1 -0
  11. package/dist/mdmodel/types.d.ts +28 -4
  12. package/dist/mdmodel/validate.d.ts +27 -3
  13. package/dist/mdruntime/adapter.d.ts +83 -48
  14. package/dist/mdruntime/binary.d.ts +0 -5
  15. package/dist/mdruntime/chain.d.ts +10 -0
  16. package/dist/mdruntime/change-set.d.ts +9 -16
  17. package/dist/mdruntime/change.d.ts +31 -1
  18. package/dist/mdruntime/client.d.ts +13 -5
  19. package/dist/mdruntime/collection.d.ts +10 -21
  20. package/dist/mdruntime/compile.d.ts +15 -0
  21. package/dist/mdruntime/connection.d.ts +25 -13
  22. package/dist/mdruntime/conversation.d.ts +19 -6
  23. package/dist/mdruntime/durability.d.ts +2 -5
  24. package/dist/mdruntime/fulltext.d.ts +26 -0
  25. package/dist/mdruntime/identity.d.ts +6 -0
  26. package/dist/mdruntime/media.d.ts +7 -0
  27. package/dist/mdruntime/messages.d.ts +27 -0
  28. package/dist/mdruntime/model.d.ts +6 -1
  29. package/dist/mdruntime/observation.d.ts +15 -0
  30. package/dist/mdruntime/opened.d.ts +21 -0
  31. package/dist/mdruntime/outcome.d.ts +45 -7
  32. package/dist/mdruntime/overlay.d.ts +2 -5
  33. package/dist/mdruntime/query.d.ts +32 -2
  34. package/dist/mdruntime/reach.d.ts +13 -4
  35. package/dist/mdruntime/readiness.d.ts +14 -15
  36. package/dist/mdruntime/recovery.d.ts +3 -2
  37. package/dist/mdruntime/replica.d.ts +55 -33
  38. package/dist/mdruntime/room-draft.d.ts +21 -3
  39. package/dist/mdruntime/save.d.ts +53 -14
  40. package/dist/mdruntime/search.d.ts +23 -42
  41. package/dist/mdruntime/status.d.ts +4 -3
  42. package/dist/mdruntime/store.d.ts +90 -97
  43. package/dist/mdruntime/stored.d.ts +129 -0
  44. package/dist/mdruntime/tables.d.ts +324 -0
  45. package/dist/mdruntime/wire.d.ts +33 -1
  46. package/dist/test-host.d.ts +7 -4
  47. package/dist/test-host.js +18 -28
  48. package/docs/families.md +50 -49
  49. package/package.json +8 -3
  50. package/dist/mdruntime/acquisition.d.ts +0 -13
  51. package/dist/mdruntime/file.d.ts +0 -19
  52. package/dist/mdruntime/rows.d.ts +0 -37
  53. package/dist/mdruntime/shared.d.ts +0 -10
  54. package/dist/mdruntime/transfer.d.ts +0 -9
  55. package/dist/mdruntime/turn.d.ts +0 -6
@@ -1,6 +1,5 @@
1
- import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
1
+ import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ListedConversation, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
2
2
  import { type ChangeSet } from './change-set.js';
3
- import { type ChatDraftFile } from './file.js';
4
3
  import type { Open } from './open.js';
5
4
  import { type CallResult, type Offline } from './outcome.js';
6
5
  import type { DocumentResult, PendingResult } from './query.js';
@@ -17,6 +16,7 @@ export type ConversationEntry = {
17
16
  created: string;
18
17
  finished: string | null;
19
18
  outcome: string | null;
19
+ waiting: boolean;
20
20
  state: ConversationState;
21
21
  started: string | null;
22
22
  };
@@ -32,14 +32,17 @@ export type RunningTurn = {
32
32
  };
33
33
  export type ChatDraft = {
34
34
  text: string;
35
- files: readonly ChatDraftFile[];
36
35
  };
37
36
  export type ConversationOptions = {
38
37
  limit?: number;
38
+ after?: string;
39
+ total?: true;
39
40
  };
40
41
  export type ConversationView = {
41
42
  conversation: string;
42
43
  messages: readonly ConversationMessage[];
44
+ next?: string;
45
+ total?: number;
43
46
  turn: RunningTurn | null;
44
47
  questions: readonly unknown[];
45
48
  process: {
@@ -47,6 +50,11 @@ export type ConversationView = {
47
50
  } | null;
48
51
  commands: readonly ProcessCommand[];
49
52
  options: readonly SessionOption[];
53
+ starting: string | null;
54
+ link: {
55
+ connected: boolean;
56
+ } | null;
57
+ deliveryUnknown: readonly string[];
50
58
  chatDraft: (ChatDraft & {
51
59
  readonly revision: string;
52
60
  }) | null;
@@ -64,16 +72,19 @@ export type ConversationSurface = {
64
72
  };
65
73
  export type ChatDraftSurface = {
66
74
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
75
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
67
76
  discard(conversation: string): Promise<void>;
68
77
  };
69
78
  export type ConversationDependencies = {
70
79
  agents(): ConversationAgents | undefined;
71
- documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
80
+ documents(agents: ConversationAgents, after: string | undefined): Promise<DocumentResult | PendingResult>;
72
81
  call(name: ConversationAction, input: unknown): Promise<CallResult>;
73
82
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
74
83
  stream(): ConversationStream | undefined;
75
84
  publish(set: ChangeSet): void;
76
85
  online(): boolean;
86
+ listed(): boolean;
87
+ full(): boolean;
77
88
  closed(): boolean;
78
89
  unanswered(): void;
79
90
  expired(operation: string): boolean;
@@ -81,13 +92,14 @@ export type ConversationDependencies = {
81
92
  export type ConversationStore = {
82
93
  surface: ConversationSurface;
83
94
  chatDraft: ChatDraftSurface;
84
- hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[]): void;
95
+ hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null): void;
85
96
  reconcile(): Promise<void>;
86
97
  catchUp(progress: CycleProgress): Promise<void>;
87
98
  resend(progress: CycleProgress): Promise<void>;
88
99
  current(): boolean;
89
100
  known(): boolean;
90
- reconnected(): void;
101
+ learned(): void;
102
+ declared(): void;
91
103
  reopened(): void;
92
104
  lost(): void;
93
105
  watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
@@ -101,5 +113,6 @@ export type ConversationStore = {
101
113
  };
102
114
  export declare function unheldView(conversation: string): ConversationView;
103
115
  export declare const SESSION_STARTED = "Session started";
116
+ export declare const HISTORY_CONVERSATIONS = 64;
104
117
  export declare function newChat(agent: string): string;
105
118
  export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
@@ -1,14 +1,11 @@
1
1
  import type { Persistence } from './readiness.js';
2
- export type StorageEstimate = {
3
- readonly usage: number;
4
- readonly quota: number;
5
- };
6
2
  export type RuntimeShell = {
7
3
  persistence: Persistence;
8
4
  generation: string | null;
9
5
  keepGeneration(value: string): void | Promise<void>;
10
6
  dropGeneration(): void | Promise<void>;
11
- estimate?(): Promise<StorageEstimate | null>;
7
+ cleanUp?(): Promise<number>;
12
8
  };
9
+ export declare function refusedForSpace(error: unknown): boolean;
13
10
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
14
11
  export declare function nextGeneration(stored: string | null, reported: string | null): string;
@@ -0,0 +1,26 @@
1
+ import { type QueryRoom } from './compile.js';
2
+ import type { Plan } from './query.js';
3
+ import type { HitCursor, SearchWindow } from './search.js';
4
+ import type { Connection } from './tables.js';
5
+ export declare const SEARCH_TABLES: readonly string[];
6
+ export type SearchAsk = {
7
+ readonly text: string;
8
+ readonly limit: number;
9
+ readonly after: readonly [HitCursor, HitCursor] | null;
10
+ readonly total: boolean;
11
+ readonly documents: {
12
+ readonly plan: Plan;
13
+ readonly rooms: readonly QueryRoom[];
14
+ readonly beneath: readonly {
15
+ readonly key: number;
16
+ readonly roots: readonly string[];
17
+ }[];
18
+ } | null;
19
+ readonly conversations: readonly string[];
20
+ };
21
+ export declare function indexDocument(connection: Connection, id: number, path: string, content: string): void;
22
+ export declare function indexMessage(connection: Connection, id: number, text: string): void;
23
+ export declare function unindexDocuments(connection: Connection, ids: Iterable<number>): void;
24
+ export declare function unindexMessages(connection: Connection, ids: Iterable<number>): void;
25
+ export declare function unindexAll(connection: Connection): void;
26
+ export declare function searched(connection: Connection, ask: SearchAsk): SearchWindow;
@@ -0,0 +1,6 @@
1
+ export declare function changeBatchIdentity(at?: number): string;
2
+ export declare function identityTime(identity: string): number;
3
+ export declare function roomDraftRevision(): string;
4
+ export declare function chatDraftRevision(): string;
5
+ export declare function transferIdentity(): string;
6
+ export declare function binaryLocalId(): string;
@@ -0,0 +1,7 @@
1
+ import type { MdRuntimeClient } from './client.js';
2
+ import { type ShownAnswer } from './outcome.js';
3
+ export declare const ROOM_MEDIA = "room-media";
4
+ type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
5
+ export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
6
+ export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
7
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { AcceptedMessage } from './adapter.js';
2
+ import type { Connection } from './tables.js';
3
+ export declare const MESSAGE_TABLES: readonly string[];
4
+ export type HeldConversation = {
5
+ readonly conversation: string;
6
+ readonly read: string | null | undefined;
7
+ readonly partial: boolean;
8
+ };
9
+ export type MessageWindow = {
10
+ readonly messages: AcceptedMessage[];
11
+ readonly more: boolean;
12
+ };
13
+ export type ConversationWrite = {
14
+ readonly conversation: string;
15
+ readonly messages: readonly AcceptedMessage[];
16
+ readonly read?: {
17
+ readonly at: string | null;
18
+ readonly partial: boolean;
19
+ };
20
+ };
21
+ export declare function heldConversations(connection: Connection): HeldConversation[];
22
+ export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
23
+ export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null): MessageWindow;
24
+ export declare function messageCount(connection: Connection, conversation: string): number;
25
+ export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
26
+ export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
27
+ export declare function forgottenMessages(connection: Connection): void;
@@ -28,6 +28,11 @@ export type ModelState = {
28
28
  verifiedWith: ModelIdentity;
29
29
  types: VerifiedModel['types'];
30
30
  };
31
+ export type StoredModel = Extract<ModelState, {
32
+ status: 'unavailable';
33
+ }> | Omit<Extract<ModelState, {
34
+ status: 'current' | 'cached';
35
+ }>, 'types'>;
31
36
  export type TypesResult = {
32
37
  status: Open<'unavailable'>;
33
38
  reason: ModelUnavailableReason;
@@ -51,7 +56,7 @@ export type ValidationReceipt = {
51
56
  export declare const NO_MODEL: ModelState;
52
57
  export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
53
58
  export declare function modelTypes(state: ModelState): TypesResult;
59
+ export declare function storedModel(state: ModelState): StoredModel;
54
60
  export declare function cached(state: ModelState): ModelState;
55
61
  export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
56
- export declare function sameTyping(left: ModelState, right: ModelState): boolean;
57
62
  export declare function referenceField(facts: ValueFacts | undefined): boolean;
@@ -14,6 +14,8 @@ export type QueryChange = {
14
14
  removed: readonly RowKey[];
15
15
  order: readonly RowKey[] | null;
16
16
  coverage?: QueryCoverage;
17
+ next?: string | null;
18
+ total?: number;
17
19
  };
18
20
  export type QueryMessage = KeyedResult | QueryChange;
19
21
  export type Observed = {
@@ -27,3 +29,16 @@ export declare function applied(keyed: KeyedResult, message: QueryMessage): Keye
27
29
  export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
28
30
  export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
29
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>>;
32
+ export type Digest = {
33
+ readonly pending: string;
34
+ } | {
35
+ readonly keys: readonly RowKey[];
36
+ readonly rows: ReadonlyMap<RowKey, number>;
37
+ readonly coverage: string;
38
+ readonly next: string | undefined;
39
+ readonly total: number | undefined;
40
+ };
41
+ export declare function hashed(text: string): number;
42
+ export declare function digestOf({ result, keys }: KeyedResult): Digest;
43
+ export declare function digestApplied(digest: Digest, message: QueryMessage): Digest;
44
+ export declare function changeOf(previous: Digest, next: KeyedResult): QueryMessage | null;
@@ -0,0 +1,21 @@
1
+ import type { BinaryResult } from './adapter.js';
2
+ import { type RuntimeDatabase } from './tables.js';
3
+ export type OpenedName = {
4
+ readonly locator: string;
5
+ readonly path: string;
6
+ readonly revision: string;
7
+ };
8
+ export type KeptBinary = {
9
+ readonly kind: 'binary';
10
+ readonly file: string;
11
+ readonly byteLength: number;
12
+ readonly mediaType: string;
13
+ };
14
+ export type KeptResult = KeptBinary | Exclude<BinaryResult, {
15
+ kind: 'binary';
16
+ }>;
17
+ export type OpenedFiles = {
18
+ find(name: OpenedName): Promise<KeptBinary | null>;
19
+ fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
20
+ };
21
+ export declare function openedFiles(database: RuntimeDatabase, fenced: (locator: string) => boolean): OpenedFiles;
@@ -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 {};
@@ -18,10 +18,7 @@ export type Layer = Heads & {
18
18
  documents: Readonly<Record<string, string>>;
19
19
  binaries: Readonly<Record<string, HeldBinary>>;
20
20
  };
21
- export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Record<string, HeldBinary>;
21
+ export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
22
22
  export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
23
23
  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;
24
+ export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
@@ -38,6 +38,8 @@ export type Filter = {
38
38
  types?: readonly string[];
39
39
  where?: Where;
40
40
  pathPrefix?: string;
41
+ folder?: string;
42
+ paths?: readonly string[];
41
43
  hop?: Related & {
42
44
  field: string;
43
45
  };
@@ -45,7 +47,7 @@ export type Filter = {
45
47
  field?: string;
46
48
  };
47
49
  };
48
- export type Key = 'room' | 'path' | 'type' | {
50
+ export type Key = 'room' | 'path' | 'type' | 'folder' | {
49
51
  field: string;
50
52
  };
51
53
  export type Select = 'all' | {
@@ -56,6 +58,7 @@ export type Select = 'all' | {
56
58
  backlinks?: true;
57
59
  change?: true;
58
60
  fileId?: true;
61
+ revision?: true;
59
62
  };
60
63
  export type OrderOptions = {
61
64
  nulls?: 'first' | 'last';
@@ -71,6 +74,8 @@ export type DocumentQuery = Filter & {
71
74
  direction?: Direction;
72
75
  } & OrderOptions)[];
73
76
  limit?: number;
77
+ after?: string;
78
+ total?: true;
74
79
  };
75
80
  export type GroupQuery = Filter & {
76
81
  groupBy: readonly Exclude<Key, 'path'>[];
@@ -79,6 +84,8 @@ export type GroupQuery = Filter & {
79
84
  direction?: Direction;
80
85
  }[];
81
86
  limit?: number;
87
+ after?: string;
88
+ total?: true;
82
89
  };
83
90
  export type LocalQuery = DocumentQuery | GroupQuery;
84
91
  export type Backlink = {
@@ -97,6 +104,7 @@ export type QueryDocument = {
97
104
  backlinks?: readonly Backlink[];
98
105
  change?: HeadChange | null;
99
106
  fileId?: string | null;
107
+ revision?: string | null;
100
108
  binaryFile?: BinaryFileRecord;
101
109
  };
102
110
  export type QueryGroup = {
@@ -113,7 +121,7 @@ export type QueryCoverage = {
113
121
  indexes: readonly string[];
114
122
  overlay: readonly string[];
115
123
  };
116
- export type Awaits = Open<'acquisition' | 'preparation' | 'index'>;
124
+ export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
117
125
  export type PendingRoom = {
118
126
  room: string;
119
127
  awaits: Awaits;
@@ -123,9 +131,13 @@ export type PendingResult = {
123
131
  };
124
132
  export type DocumentRows = {
125
133
  documents: readonly QueryDocument[];
134
+ next?: string;
135
+ total?: number;
126
136
  };
127
137
  export type GroupRows = {
128
138
  groups: readonly QueryGroup[];
139
+ next?: string;
140
+ total?: number;
129
141
  };
130
142
  export type QueryRows = DocumentRows | GroupRows;
131
143
  export type DocumentResult = DocumentRows & {
@@ -189,6 +201,8 @@ export type KeyPlan = {
189
201
  of: 'path';
190
202
  } | {
191
203
  of: 'type';
204
+ } | {
205
+ of: 'folder';
192
206
  } | {
193
207
  of: 'field';
194
208
  field: string;
@@ -202,6 +216,7 @@ export type DocumentShape = {
202
216
  backlinks: boolean;
203
217
  change: boolean;
204
218
  fileId: boolean;
219
+ revision: boolean;
205
220
  orderBy: readonly {
206
221
  key: KeyPlan;
207
222
  options: OrderOptions & {
@@ -217,15 +232,28 @@ export type GroupShape = {
217
232
  direction: Direction;
218
233
  }[];
219
234
  };
235
+ export type PlanArea = {
236
+ room: string;
237
+ path: string;
238
+ types: readonly string[];
239
+ };
220
240
  export type PlanReach = {
221
241
  rooms: readonly string[];
222
242
  documents: readonly string[];
243
+ areas: readonly PlanArea[];
244
+ };
245
+ export type Continuation = {
246
+ text: string;
247
+ values: readonly unknown[] | null;
223
248
  };
224
249
  export type Plan = {
225
250
  key: string;
226
251
  rooms: readonly string[] | null;
227
252
  reach: PlanReach | null;
253
+ locked: readonly string[];
228
254
  root: Scope;
255
+ folder: string | null;
256
+ paths: readonly string[] | null;
229
257
  hop: (Scope & {
230
258
  field: string;
231
259
  }) | null;
@@ -234,6 +262,8 @@ export type Plan = {
234
262
  }) | null;
235
263
  shape: DocumentShape | GroupShape;
236
264
  limit: number | null;
265
+ after: Continuation | null;
266
+ total: boolean;
237
267
  };
238
268
  export declare class QueryError extends Error {
239
269
  readonly code: QueryErrorCode;
@@ -1,5 +1,4 @@
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
4
  import { type SearchResult } from './search.js';
@@ -7,9 +6,15 @@ 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 types: 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;
@@ -26,9 +31,13 @@ export type Reachable = RuntimeView & {
26
31
  plan(input: unknown, reach: PortReach | null): Plan;
27
32
  query(plan: Plan): Promise<QueryResult>;
28
33
  watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
29
- search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
34
+ search(input: unknown, reach: PortReach | null, locked: readonly string[]): 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): boolean;
37
+ lockedRooms(): readonly string[];
38
+ watchLocks(notify: () => void): () => void;
39
+ located(room: string, path: string, destination: string): ReachedDocument | null;
40
+ room(locator: string): 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: {
@@ -1,11 +1,11 @@
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'>;
8
+ export type ConversationCoverage = Open<'complete' | 'acquiring' | 'undeclared'>;
9
9
  export type SearchObligation = Open<'required' | 'unused'>;
10
10
  export type TargetCoverage = {
11
11
  readonly complete: boolean;
@@ -18,18 +18,18 @@ export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
18
18
  export type Durability = Open<'persistent' | 'best-effort'>;
19
19
  export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
20
20
  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;
21
+ export type Space = Open<'full'>;
22
+ export type InstallationStep = Open<'downloading' | 'writing' | 'replaying'>;
23
+ export type InstallationAmount = {
24
+ readonly done: number;
25
+ readonly total: number;
25
26
  };
26
- export type RefusedRoom = {
27
- readonly room: string;
28
- readonly file: string;
29
- readonly rule: string;
30
- readonly location: string | null;
27
+ export type Installation = {
28
+ readonly step: InstallationStep | null;
29
+ readonly rooms: InstallationAmount;
30
+ readonly bytes: InstallationAmount;
31
31
  };
32
- export type ReadinessStatus = Open<'preparing' | 'paused' | 'refused' | 'ready' | 'lost'>;
32
+ export type ReadinessStatus = Open<'preparing' | 'paused' | 'ready' | 'lost'>;
33
33
  export type Readiness = {
34
34
  readonly status: ReadinessStatus;
35
35
  readonly ready: boolean;
@@ -40,13 +40,12 @@ export type Readiness = {
40
40
  readonly persistence: Persistence;
41
41
  readonly connection: ConnectionAvailability;
42
42
  readonly house: HouseOutcome;
43
- readonly capacity: CapacityCause | null;
44
- readonly refused: readonly RefusedRoom[];
43
+ readonly space: Space | null;
44
+ readonly installation: Installation;
45
45
  readonly lost: boolean;
46
46
  };
47
47
  export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
48
48
  readonly coverage: Omit<TargetCoverage, 'complete'>;
49
49
  readonly established: boolean;
50
50
  };
51
- export declare const SETTLED_ROOMS: ReadonlySet<string>;
52
51
  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;